/* APSIS — COSMIC WARP entry portal. Neon-on-void. Strict CSP: no inline style, all dynamic values via JS setProperty/classList. */

:root {
  --void:   #050310;
  --void-2: #0b0722;
  --ink:    #eaf0ff;
  --muted:  #9aa6d6;
  --dim:    #66709c;
  --cyan:   #37e8ff;
  --magenta:#ff2fa0;
  --violet: #8b6bff;
  --gold:   #ffd27a;

  --edge: rgba(140,160,255,.18);
  --edge-hot: rgba(55,232,255,.55);

  --ui: "Inter", "SF Pro Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --warp-in: 620ms;
  --ease-out: cubic-bezier(.16,.9,.3,1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  background: var(--void);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  overflow-y: hidden;
  position: relative;
}

/* ---------- skip link ---------- */
.skip {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 60;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--cyan);
  color: #04121a;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  transition: top .18s var(--ease-out);
}
.skip:focus-visible { top: 12px; outline: 2px solid var(--ink); outline-offset: 3px; }

/* ---------- cosmic void backdrop (GPU-free first paint) ---------- */
.void {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% 118%, #12082e 0%, rgba(11,7,34,0) 55%),
    radial-gradient(90% 70% at 50% -20%, #0a0a2c 0%, rgba(5,3,16,0) 60%),
    var(--void);
  pointer-events: none;
}
.neb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .5;
  mix-blend-mode: screen;
  will-change: transform;
}
.neb--cyan   { width: 46vmax; height: 46vmax; left: -12vmax; top: 8vmax;  background: radial-gradient(circle, rgba(55,232,255,.5), transparent 65%); animation: drift1 34s ease-in-out infinite; }
.neb--mag    { width: 40vmax; height: 40vmax; right: -14vmax; top: -10vmax; background: radial-gradient(circle, rgba(255,47,160,.42), transparent 65%); animation: drift2 41s ease-in-out infinite; }
.neb--violet { width: 52vmax; height: 52vmax; left: 30vmax; bottom: -26vmax; background: radial-gradient(circle, rgba(139,107,255,.4), transparent 66%); animation: drift3 47s ease-in-out infinite; }

@keyframes drift1 { 0%,100%{ transform: translate3d(0,0,0) scale(1);} 50%{ transform: translate3d(4vmax,3vmax,0) scale(1.08);} }
@keyframes drift2 { 0%,100%{ transform: translate3d(0,0,0) scale(1);} 50%{ transform: translate3d(-5vmax,4vmax,0) scale(1.1);} }
@keyframes drift3 { 0%,100%{ transform: translate3d(0,0,0) scale(1);} 50%{ transform: translate3d(-3vmax,-4vmax,0) scale(1.06);} }

.grain {
  position: absolute;
  inset: -50%;
  opacity: .05;
  background-image: radial-gradient(rgba(255,255,255,.9) .5px, transparent .5px);
  background-size: 3px 3px;
}

/* ---------- WebGL star-tunnel ---------- */
.warp {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.1s ease;
}
html.gpu-live .warp { opacity: 1; }

/* ---------- FX overlay: the 8 gesture-tech demos ---------- */
.fxlayer {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.fxc {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  mix-blend-mode: screen;
  transition: opacity .6s ease;
  will-change: opacity;
}
.fxc.on { opacity: .78; }

/* HUD chip naming the active gesture-tech */
.hud {
  position: fixed;
  z-index: 30;
  left: 50%;
  top: max(14px, env(safe-area-inset-top));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(9, 10, 30, .72);
  border: 1px solid var(--edge-hot);
  box-shadow: 0 0 24px -6px rgba(55, 232, 255, .5);
  backdrop-filter: blur(9px);
  font-size: 12px;
  max-width: min(92vw, 460px);
  animation: hudin .3s var(--ease-out);
}
.hud[hidden] { display: none; }
.hud-g {
  font-weight: 800;
  letter-spacing: .18em;
  color: var(--cyan);
  white-space: nowrap;
}
.hud-t {
  color: var(--muted);
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes hudin { from { opacity: 0; transform: translateX(-50%) translateY(-6px); } }

/* gesture panel launcher */
.gbtn {
  position: fixed;
  z-index: 31;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--edge);
  background: rgba(9, 10, 30, .7);
  color: var(--muted);
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  cursor: pointer;
  backdrop-filter: blur(9px);
  transition: color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.gbtn:hover { color: var(--ink); border-color: var(--edge-hot); box-shadow: 0 0 20px -8px rgba(55, 232, 255, .6); }
.gbtn-ico { width: 16px; height: 16px; color: var(--cyan); flex: none; }

/* gesture panel */
.gpanel {
  position: fixed;
  z-index: 32;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 48px);
  width: min(340px, calc(100vw - 28px));
  /* LAW 1 — THIS is the site where the static fallback is load-bearing, and it is `svh` INSTEAD of
     `dvh`, not beneath it. Unlike the app shell, this page really scrolls (`body{overflow-y:auto}` in
     the landscape block below), and `.gpanel` is fixed + bottom-anchored, so it grows UPWARD: a `dvh`
     cap would drag its top edge down/up on every toolbar retraction while the reader scrolls — a
     scroll-linked reflow of a layout box. `svh` sizes for the toolbar-out worst case, so it always
     FITS and never moves; the panel scrolls internally either way. (`70vh` resolved to `70lvh`, i.e.
     too generous — that was the original defect.)
     The `min(70%, 520px)` line above it is the live no-`dvh`/`svh` fallback: `.gpanel` is
     `position:fixed` with `top:auto`, so its containing block is the initial containing block and the
     percentage is a viewport percentage in every engine. It is not dead cascade — `svh` and `dvh`
     share one support baseline (2022), so only a non-viewport-unit line can ever apply. */
  max-height: min(70%, 520px);
  max-height: min(70svh, 520px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--edge);
  background: linear-gradient(180deg, rgba(18, 22, 52, .94), rgba(8, 9, 26, .96));
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .9);
  backdrop-filter: blur(12px);
  animation: panelin .22s var(--ease-out);
}
.gpanel[hidden] { display: none; }
@keyframes panelin { from { opacity: 0; transform: translateY(8px); } }
.gpanel-head {
  margin: 0 0 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--cyan);
}
.gpanel-grid {
  display: grid;
  gap: 7px;
}
.gitem {
  display: grid;
  grid-template-columns: 26px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 11px;
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .03);
  color: var(--ink);
  font-family: var(--ui);
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .12s ease;
}
.gitem svg { grid-row: 1 / 3; width: 22px; height: 22px; color: var(--cyan); }
.gitem:hover, .gitem:focus-visible {
  background: rgba(55, 232, 255, .08);
  border-color: var(--edge-hot);
  transform: translateX(2px);
  outline: none;
}
.gitem-g { font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.gitem-t { font-size: 11px; letter-spacing: .01em; color: var(--muted); }

:where(.gbtn, .gitem):focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* event-horizon collapse at the moment of the jump — DARK by mandate: a bright white-out here
   is a photosensitivity hazard; the jump falls INTO the void, it never flashes */
.blowout {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: radial-gradient(circle at 50% 50%, #0b0d12 0%, #060a14 45%, rgba(6,10,20,0.86) 70%, rgba(6,10,20,0) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 520ms ease-in;
}
html.blowout-on .blowout { opacity: 1; transition-duration: 460ms; }

/* ---------- the gate ---------- */
.gate {
  position: relative;
  z-index: 10;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(18px, 2.6vh, 30px);
  max-width: 660px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 84px);
  transition: transform var(--warp-in) var(--ease-out), opacity var(--warp-in) ease;
}
html.crossing .gate { transform: scale(1.6) translateZ(0); opacity: 0; filter: blur(6px); }

/* brand row */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mark { width: 38px; height: 38px; color: var(--cyan); flex: none; filter: drop-shadow(0 0 8px rgba(55,232,255,.5)); }
.mark-apo { animation: apo 6s linear infinite; transform-origin: 20px 20px; }
@keyframes apo { to { transform: rotate(360deg); } }
.wordmark {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: .42em;
  padding-left: .1em;
  color: var(--ink);
}
.reg {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--dim);
}

/* eyebrow */
.eyebrow {
  margin: clamp(10px,2vh,26px) 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--cyan);
}

/* display headline — wide cinematic */
.display {
  margin: 0;
  font-weight: 800;
  font-size: clamp(46px, 12vw, 108px);
  line-height: .92;
  letter-spacing: -.01em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 40px rgba(90,120,255,.25);
  overflow-wrap: anywhere;
}
.display-accent {
  background: linear-gradient(96deg, var(--cyan) 0%, #b6a3ff 46%, var(--magenta) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  text-shadow: none;
}

.sub {
  margin: 0;
  max-width: 46ch;
  font-size: clamp(15px, 1.7vw, 18px);
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- key form ---------- */
.key { margin: clamp(6px,1.6vh,16px) 0 0; }
.key-label {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}
.slab {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 7px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(20,26,60,.72), rgba(9,10,30,.72));
  border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 18px 50px -24px rgba(0,0,0,.9);
  backdrop-filter: blur(8px);
  transition: border-color .2s ease, box-shadow .25s ease;
}
.slab:focus-within {
  border-color: var(--edge-hot);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 0 0 3px rgba(55,232,255,.18), 0 18px 50px -20px rgba(0,0,0,.9);
}
.key-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 54px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 18px;
  letter-spacing: .16em;
  outline: none;
}
.key-input::placeholder { color: #4a5384; letter-spacing: .4em; }
.key-input:focus-visible { outline: none; }

.submit {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  font-family: var(--ui);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .06em;
  color: #041018;
  background: linear-gradient(96deg, var(--cyan), #7ad7ff);
  box-shadow: 0 0 22px rgba(55,232,255,.4), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .16s var(--ease-out), box-shadow .2s ease, filter .2s ease, opacity .2s ease;
}
.submit-ico { width: 20px; height: 20px; }
.submit:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 30px rgba(55,232,255,.6), inset 0 1px 0 rgba(255,255,255,.6); }
.submit:active:not(:disabled) { transform: translateY(0) scale(.98); }
.submit:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.3); box-shadow: none; }

:where(.submit, .key-input, .skip):focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.hint {
  margin: 12px 2px 0;
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--dim);
}

/* verdict / aria-live */
.verdict {
  margin: 4px 2px 0;
  min-height: 1.4em;
  font-size: 14px;
  letter-spacing: .02em;
  color: var(--cyan);
  transition: color .2s ease;
}
.verdict.is-deny { color: #ff6b8f; }

/* deny shake */
html.deny .slab { animation: shake .42s cubic-bezier(.36,.07,.19,.97) both; border-color: rgba(255,90,130,.6); }
html.deny .void { animation: denyflash .5s ease; }
@keyframes shake {
  10%,90% { transform: translateX(-2px); }
  20%,80% { transform: translateX(4px); }
  30%,50%,70% { transform: translateX(-8px); }
  40%,60% { transform: translateX(8px); }
}
@keyframes denyflash { 0%,100%{ filter: none; } 30%{ filter: hue-rotate(-30deg) brightness(1.15); } }

/* footer */
.rest {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: clamp(14px,3vh,34px) 0 0;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}
.rest-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ opacity: .4; } 50%{ opacity: 1; } }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .slab { flex-wrap: wrap; }
  .submit { width: 100%; justify-content: center; }
  .reg { display: none; }
  .display { font-size: clamp(38px, 12.5vw, 64px); }
  .gbtn span { display: none; }        /* icon-only pill on narrow screens */
  .gbtn { padding: 10px; }
}

/* short + landscape: let the gate scroll, shrink the cinematic type so nothing clips */
@media (max-height: 560px) and (orientation: landscape) {
  body { overflow-y: auto; }
  .gate {
    justify-content: flex-start;
    min-height: auto;
    gap: clamp(10px, 2vh, 18px);
    padding: clamp(18px, 5vh, 34px) clamp(24px, 6vw, 60px) 72px;
    max-width: 760px;
  }
  .display { font-size: clamp(30px, 8vh, 56px); }
  .sub { font-size: 14px; max-width: 52ch; }
  .eyebrow { margin-top: 8px; }
  .key-input, .submit { height: 48px; }
  /* LAW 1 — `svh`, not `dvh`, for the reason spelled out at the base rule: `body{overflow-y:auto}`
     two lines up means this page genuinely scrolls, and a fixed bottom-anchored panel sized in `dvh`
     moves its top edge every time the toolbar retracts. `svh` is the worst-case-smallest, so it fits
     and never jumps. `calc(100% - 74px)` is the live pre-2022 fallback (fixed element, `top:auto`,
     so the percentage resolves against the initial containing block). */
  .gpanel { max-height: calc(100% - 74px); max-height: calc(100svh - 74px); }
}

/* very short viewports (small landscape phones) */
@media (max-height: 420px) {
  .brand { margin-bottom: 2px; }
  .rest { margin-top: 12px; }
  .display { line-height: .95; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .neb, .mark-apo, .rest-dot, .grain { animation: none !important; }
  .warp { transition: none; }
  .gate { transition: opacity 160ms ease; }
  html.crossing .gate { transform: none; filter: none; }
  .blowout { transition: opacity 160ms ease; }
  .hud, .gpanel { animation: none; }
  .fxc { transition: opacity 200ms ease; }
  * { scroll-behavior: auto; }
}

/* exit veil: the LAST painted frame before leaving must match the app's dark canvas (#0b0d12) so the
   browser never shows a bright frame between documents — photosensitivity mandate, applies to every exit */
.exit-veil{ position:fixed; inset:0; z-index:2147483000; background:#0b0d12; opacity:0; pointer-events:none; transition:opacity .3s ease; }
.exit-veil.is-on{ opacity:1; }
@media (prefers-reduced-motion: reduce){ .exit-veil{ transition:none; } }
