/* ============================================================================
   VOID HORIZON — landing overlays (split out of landing.css, web-design-pass)
   The full-res lightbox and the ship-stats sheet are native modal <dialog>s
   (modern-web-guidance: light-dismiss-a-dialog — closedby="any" + showModal(),
   with the guide's click-outside fallback in index.html). The review-mode flag
   UI (task-378) keeps its fixed-position chrome here too. Uses landing.css tokens.
   ========================================================================== */

/* ── Lightbox (stays dark — full-res art viewing) ─────────────────────────── */
#lightbox {
  box-sizing: border-box; max-width: none; max-height: none; width: 100vw; height: 100dvh; margin: 0; padding: 3vh 3vw;
  border: 0; background: transparent; color: #cfe0f2; cursor: zoom-out; overflow: hidden;
}
#lightbox[open] { display: flex; align-items: center; justify-content: center; }
/* ::backdrop does not inherit custom properties in every engine — use the literal overlay colour. */
#lightbox::backdrop { background: rgba(2,4,10,.94); }
#lightbox img, #lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; border: 1px solid #24405e; border-radius: var(--r-sm); box-shadow: 0 24px 80px rgba(0,0,0,.7); }
#lightbox video { cursor: auto; }
#lightbox video[hidden], #lightbox img[hidden] { display: none; }
#lightbox form { position: fixed; top: 12px; right: 14px; margin: 0; }
#lightbox-close {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  color: #cfe0f2; background: rgba(8,17,29,.8); border: 1px solid #24405e; border-radius: var(--r-sm);
  font-size: 22px; line-height: 1; cursor: pointer;
}
#lightbox-close:hover { background: #12233a; }

/* Zoomable art: each gallery image is wrapped in a real <button> (keyboard + screen reader). */
#teaser button.zoom { display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none; color: inherit; cursor: zoom-in; }
#teaser button.zoom:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
/* A thumbnail whose object is missing collapses to its caption instead of a broken-image glyph. */
#teaser figure.img-missing button.zoom, #teaser figure.img-missing > img { display: none; }
#teaser figure.img-missing::before {
  content: "image unavailable"; display: block; padding: 22px 8px; text-align: center;
  color: var(--text-mute); font-size: var(--fs-sm); border-bottom: 1px dashed var(--edge);
}

/* ── Review CMS (task-378) — one-tap flag overlay, review mode only ────────── */
#review-badge { position: fixed; right: 10px; bottom: 10px; z-index: 60; font: var(--fs-sm)/1 var(--mono); letter-spacing: .12em; color: #ffb4b4; background: rgba(40,8,12,.8); border: 1px solid #6d2530; border-radius: 6px; padding: 6px 8px; pointer-events: none; }
#flag-lb { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 420; background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger); border-radius: var(--r-md); padding: 12px 20px; font: 15px/1 var(--mono); cursor: pointer; }
#flag-toast { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); z-index: 620; background: var(--surface-2); color: #cfe0f2; border: 1px solid #24405e; border-radius: var(--r-sm); padding: 10px 16px; font: var(--fs-base)/1.3 var(--mono); max-width: 86vw; text-align: center; }
/* Native modal <dialog closedby="any">: Esc, Android back and backdrop taps close it; the panel is the
   dialog box itself so an outside tap lands on ::backdrop (modern-web-guidance: light-dismiss-a-dialog). */
#flag-form { width: min(420px, 94vw); max-width: none; padding: 0; border: 0; background: transparent; color: inherit; overflow: visible; }
#flag-form::backdrop { background: rgba(2,4,10,.82); }
#flag-form-inner { box-sizing: border-box; width: 100%; background: var(--surface-2); border: 1px solid #24405e; border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-modal); }
#flag-form-what { color: #9fb6cf; font: var(--fs-data)/1.4 var(--mono); margin-bottom: 10px; word-break: break-word; }
#flag-form-reason { width: 100%; box-sizing: border-box; background: #050a12; color: #e6f0fb; border: 1px solid #24405e; border-radius: var(--r-sm); padding: 10px; font: 15px/1.4 var(--mono); resize: vertical; }
#flag-form-row { display: flex; gap: 10px; margin-top: 12px; }
#flag-form-row button { flex: 1; border-radius: var(--r-sm); padding: 13px 10px; font: 14px/1 var(--mono); cursor: pointer; }
#flag-form-cancel { background: #12233a; color: #cfe0f2; border: 1px solid #24405e; }
#flag-form-send { background: var(--danger-bg); color: var(--danger-ink); border: 1px solid var(--danger); }
#flag-lb[hidden], #flag-toast[hidden], #review-badge[hidden] { display: none; }
body.review-on .flagtarget { position: relative; }
.flag-tile { position: absolute; top: 4px; right: 4px; z-index: 3; width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--danger); background: rgba(60,10,18,.78); color: var(--danger-ink); font-size: 15px; line-height: 1; cursor: pointer; padding: 0; }
figure.flagged { opacity: .42; outline: 2px solid var(--danger); outline-offset: -2px; }
figure.flagged .flag-tile { background: var(--danger); opacity: 1; }

/* ── Stats modal (native dialog) ──────────────────────────────────────────── */
#stats-btn { position: fixed; left: 12px; bottom: 12px; z-index: 50; background: var(--surface-2); color: var(--cyan); border: 1px solid #24405e; border-radius: var(--r-sm); padding: 8px 12px; min-height: 36px; cursor: pointer; font: var(--fs-base)/1 var(--mono); backdrop-filter: blur(4px); }
#stats-btn:hover { background: var(--hover-fill); }
#stats-modal {
  width: min(940px, 96vw); height: min(86vh, 900px); max-width: none; max-height: none; padding: 0;
  background: #05070d; border: 1px solid #24405e; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-modal);
}
#stats-modal::backdrop { background: rgba(2,4,10,.72); backdrop-filter: blur(3px); }
#stats-modal form { position: absolute; right: 8px; top: 8px; z-index: 2; margin: 0; }
#stats-close { background: #12233a; color: #cfe0f2; border: 1px solid #24405e; border-radius: 6px; width: 36px; height: 36px; cursor: pointer; font-size: 16px; }
#stats-close:hover { background: #1a3454; }
#stats-frame { width: 100%; height: 100%; border: 0; background: #05070d; display: block; }

/* ── Entry / exit for every top-layer dialog (modern-web-guidance: animate-to-from-top-layer) ──
   Closed state = the exit target; [open] + @starting-style = the entry. display + overlay transition
   discretely so the dialog stays in the top layer until the fade ends. Engines without
   @starting-style / overlay simply show and hide instantly, as before. */
#lightbox { opacity: 0; transition: opacity .2s ease-out, display .2s allow-discrete, overlay .2s allow-discrete; }
#lightbox[open] { opacity: 1; }
@starting-style { #lightbox[open] { opacity: 0; } }
/* (The lightbox fades without scaling: a transform would re-anchor its fixed close/flag buttons.) */
#stats-modal, #flag-form {
  opacity: 0; transform: scale(.97);
  transition-property: opacity, transform, display, overlay;
  transition-duration: .2s; transition-timing-function: ease-out;
  transition-behavior: allow-discrete;
}
#stats-modal[open], #flag-form[open] { opacity: 1; transform: none; }
@starting-style {
  #stats-modal[open], #flag-form[open] { opacity: 0; transform: scale(.97); }
}
#lightbox::backdrop, #stats-modal::backdrop, #flag-form::backdrop {
  opacity: 0;
  transition: display .2s allow-discrete, overlay .2s allow-discrete, opacity .2s ease-out;
}
#lightbox[open]::backdrop, #stats-modal[open]::backdrop, #flag-form[open]::backdrop { opacity: 1; }
@starting-style {
  #lightbox[open]::backdrop, #stats-modal[open]::backdrop, #flag-form[open]::backdrop { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #lightbox, #stats-modal, #flag-form { transform: none; transition-duration: .1s; }
  @starting-style { #stats-modal[open], #flag-form[open] { transform: none; } }
}
