/* Fixed chrome above the story: focus ring, skip link, nav, chapter sheet, era/progress HUD,
   key hint, jump veil and the 3D-anchored labels. Loads after components.css.
   There is no loader (the hero's words show at once and the canvas fades in from black: fallback.css) and no
   custom cursor: the pointer is the system's own. */

/* ---------- Focus: one ring, for keyboard users only ---------- */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px }
:focus:not(:focus-visible) { outline: none }

/* ---------- HUD base ---------- */
.hud {
  position: fixed; z-index: 20; font-family: var(--body); font-size: 12px; font-weight: 500; letter-spacing: -.005em;
  color: var(--grey); pointer-events: none; font-variant-numeric: tabular-nums;
}
.hud a, .hud button { pointer-events: auto }

/* ---------- Skip link: hidden until it has keyboard focus ---------- */
.skip-link {
  position: fixed; top: 12px; left: max(12px, var(--safe-l, 0px)); z-index: 5; padding: 10px 18px; border-radius: 980px;
  font-family: var(--body); font-size: 14px; font-weight: 500; line-height: 20px; letter-spacing: -.016em;
  color: #04040c; background: var(--white); box-shadow: 0 8px 30px rgba(0,0,0,.4);
  transform: translateY(calc(-100% - 24px)); transition: transform .2s cubic-bezier(.2,.7,.1,1);
}
.skip-link:focus, .skip-link:focus-visible { transform: none }

/* ---------- Nav ---------- */
#nav {
  top: 0; left: 0; right: 0; display: flex; align-items: center;
  padding: max(14px, var(--safe-t, 0px)) var(--pad-r, var(--gutter)) 14px var(--pad-l, var(--gutter));
  min-height: 72px; background: linear-gradient(rgba(3,3,10,.8),rgba(3,3,10,0));
}
.logo {
  font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: -.022em; color: var(--ink);
  text-transform: none; display: flex; align-items: center; gap: 10px; padding: 8px 0; border-radius: 8px;
}
.logo em { font-style: normal }
.logo b { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 12px var(--blue); animation: beat 2.4s ease-in-out infinite }
@keyframes beat { 0%, 100% { transform: scale(1); opacity: 1 } 50% { transform: scale(.6); opacity: .6 } }
.logo span {
  background: var(--grad-loop); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  color: transparent; animation: flow 8s linear infinite;
}
#nav .tag { margin-left: 20px }
.nav-links { margin-left: auto; margin-right: -10px; display: flex; align-items: center; gap: 2px }
.nav-link {
  appearance: none; -webkit-appearance: none; border: 0; background: none; cursor: pointer;
  min-height: 44px; padding: 12px 10px; border-radius: 10px; display: inline-flex; align-items: center;
  font-family: var(--body); font-size: 14px; font-weight: 500; line-height: 20px; letter-spacing: -.016em;
  color: rgba(245,245,247,.8); transition: color .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.nav-link:hover, .nav-link[aria-expanded="true"] { color: var(--white) }

/* ---------- Chapter sheet (a modal <dialog>) ---------- */
.sheet {
  position: fixed; inset: 76px var(--pad-r, var(--gutter)) auto auto; margin: 0; padding: 0; border: 0;
  width: min(380px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 100px);
  border-radius: 24px; color: var(--white); background: rgba(22,22,28,.8);
  backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
  box-shadow: inset 0 .5px 0 rgba(255,255,255,.22), inset 0 0 0 .5px rgba(255,255,255,.06), 0 30px 90px rgba(0,0,0,.55);
  display: flex; flex-direction: column; overflow: hidden; overscroll-behavior: contain;
  opacity: 0; transform: translateY(-8px) scale(.98); transform-origin: top right;
  transition: opacity .2s ease, transform .3s cubic-bezier(.2,.8,.2,1);
}
.sheet:not([open]) { display: none }
.sheet.is-open { opacity: 1; transform: none }
.sheet::backdrop { background: rgba(3,3,10,0); transition: background .25s ease }
.sheet.is-open::backdrop { background: rgba(3,3,10,.5) }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 14px 4px 22px; flex: none }
.sheet-title { font-family: var(--body); font-size: 17px; font-weight: 600; line-height: 21px; letter-spacing: -.022em; color: var(--kicker, var(--grey)); margin: 0 }
.sheet-close {
  appearance: none; -webkit-appearance: none; border: 0; cursor: pointer; flex: none;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  color: var(--white); background: rgba(255,255,255,.08); transition: background-color .2s ease;
}
.sheet-close:hover { background: rgba(255,255,255,.15) }
.sheet-close svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round }
.sheet-list { list-style: none; margin: 0; padding: 6px 8px 12px; overflow-y: auto; overscroll-behavior: contain; min-height: 0 }
.sheet-list a {
  display: grid; grid-template-columns: 68px 1fr 8px; align-items: center; gap: 10px; min-height: 44px;
  padding: 10px 14px; border-radius: 12px; transition: background-color .15s ease;
}
.sheet-list a:hover { background: rgba(255,255,255,.06) }
.sheet-list .yr { font-size: 13px; font-weight: 500; letter-spacing: -.008em; color: var(--grey-2, var(--grey)); font-variant-numeric: tabular-nums }
.sheet-list .nm { font-family: var(--body); font-size: 17px; font-weight: 600; line-height: 22px; letter-spacing: -.022em; color: var(--white) }
.sheet-list a[aria-current] .yr { color: var(--blue) }
.sheet-list a[aria-current]::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 10px var(--blue) }

/* ---------- Era + chapter counter (bottom right) ---------- */
#era { right: var(--pad-r, var(--gutter)); bottom: 54px; text-align: right }
#era-yr {
  font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; font-size: clamp(20px,1.9vw,28px);
  letter-spacing: -.025em; line-height: 1; color: var(--white); text-transform: none;
}
#era-nm { margin-top: 4px; color: var(--grey) }
#hud-br { right: var(--pad-r, var(--gutter)); bottom: 28px; display: flex; align-items: center; gap: 16px }
.sec-btn {
  appearance: none; -webkit-appearance: none; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--white); padding: 6px 10px; margin: -6px -10px; border-radius: 980px;
  display: inline-flex; align-items: center; gap: 8px; transition: background-color .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.sec-btn:hover { background: rgba(255,255,255,.08) }
.sec-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }
#hud-br .track { display: block; width: 120px; height: 1px; background: var(--faint); position: relative }
#hud-br .track i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--white); transform-origin: left; transform: scaleX(0) }
#sec-num { color: var(--white) }

/* ---------- One-time keyboard hint ---------- */
.key-hint {
  position: fixed; right: var(--pad-r, var(--gutter)); bottom: 118px; z-index: 20; pointer-events: none;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--body); font-size: 12px; font-weight: 500; letter-spacing: -.005em; color: var(--grey);
  opacity: 0; transform: translateY(6px); transition: opacity .5s ease, transform .5s cubic-bezier(.2,.7,.1,1);
}
.key-hint.on { opacity: 1; transform: none }
.key-hint kbd {
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; display: inline-grid; place-items: center;
  font-family: var(--body); font-size: 12px; font-weight: 600; line-height: 1; color: var(--white);
  background: rgba(255,255,255,.06); box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.key-hint span { margin-left: 4px }

/* ---------- Jump veil: a quick dip to black while a jump lands (scroll.js) ---------- */
#cut-veil { position: fixed; inset: 0; z-index: 15; background: var(--bg); opacity: 0; pointer-events: none; transition: opacity .38s cubic-bezier(.3,0,.2,1) }
.is-cutting #cut-veil { opacity: 1; transition: opacity .16s cubic-bezier(.4,0,1,1) }
.sheet-open { overflow: hidden }   /* the page stays put while the chapter sheet is open */

/* ---------- 3D-anchored labels (positioned every frame by ui.js) ---------- */
#labels { position: fixed; inset: 0; z-index: 12; pointer-events: none }
.lbl {
  position: absolute; left: 0; top: 0; font-family: var(--body); font-size: 13px; font-weight: 600; letter-spacing: -.01em;
  color: var(--white); text-align: center; white-space: nowrap; opacity: 0; will-change: transform, opacity;
  text-shadow: 0 0 12px rgba(3,3,10,.9);
}
.lbl small { display: block; font-size: 11px; font-weight: 400; color: var(--grey); letter-spacing: -.005em; margin-top: 1px }
.lbl.tok { font-family: var(--body); font-size: 16px; letter-spacing: 0 }
.lbl.hot { color: var(--blue); font-weight: 600 }
.lbl.grid { text-align: right }   /* size and colour: components.css (#labels .lbl.grid) */

/* ---------- Responsive ---------- */
@media (max-width:820px) {
  #nav .tag { display: none }
  .lbl small { display: none }   /* label sizes on small screens: components.css */
  #hud-br .track { width: 60px }
}
/* phones: no era block; a slim progress bar and a Chapters pill, and the sheet becomes a bottom sheet */
@media (max-width:734px) {
  #nav { min-height: 60px; padding-top: max(8px, var(--safe-t, 0px)); padding-bottom: 8px }
  #nav-chapters { display: none }
  #era { display: none }
  #hud-br { left: var(--pad-l, var(--gutter)); right: var(--pad-r, var(--gutter)); bottom: calc(14px + var(--safe-b, 0px)); gap: 14px }
  #hud-br .track { order: -1; flex: 1; width: auto; height: 2px; border-radius: 1px; overflow: hidden; transition: opacity .4s ease }
  .at-start #hud-br .track { opacity: 0 }   /* the hero's "Swipe up to begin" cue sits on this line */
  .sec-btn {
    position: relative; margin: 0; height: 36px; padding: 0 16px; font-size: 13px; font-weight: 600; letter-spacing: -.01em;
    background: rgba(255,255,255,.1); box-shadow: inset 0 .5px 0 rgba(255,255,255,.25);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
  .sec-btn::after { content: ""; position: absolute; inset: -4px -2px }   /* a 44px-tall hit area round the 36px pill */
  .sec-btn::before { content: ""; width: 12px; height: 9px; flex: none; background: linear-gradient(currentColor 0 0) top/100% 1.5px no-repeat, linear-gradient(currentColor 0 0) center/100% 1.5px no-repeat, linear-gradient(currentColor 0 0) bottom/100% 1.5px no-repeat; opacity: .9 }
  .sec-lbl { position: static; width: auto; height: auto; overflow: visible; clip-path: none }
  #sec-num { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }
  .sheet {
    inset: auto 0 0 0; width: 100%; max-height: min(82dvh, 680px); border-radius: 28px 28px 0 0;
    padding-bottom: var(--safe-b, 0px); transform: translateY(32px); transform-origin: bottom center;
  }
  .sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.22); transform: translateX(-50%) }
  .sheet-head { padding-top: 22px }
}
/* short landscape (phones on their side, 1440×900 at 200% zoom): the cards reach the bottom corners, so the
   bottom-right HUD steps aside. Chapters moves into the nav, and progress becomes a hairline along the top edge. */
@media (max-height:500px) and (orientation:landscape) {
  #era { display: none }
  #nav-chapters { display: inline-flex }
  #hud-br .sec-btn { display: none }
  #hud-br .track { position: fixed; top: 0; left: 0; right: 0; width: auto; height: 2px; border-radius: 0 }
}
