/* Shell chrome shared by every game page (F4): the preview ribbon, the
   "Made with CVArcade" badge, the /text nav, the status/message pages, and
   /text's print rules. All positioning is plain CSS, never inline `style=`
   (the shell's CSP is `style-src 'self'`).

   Every template's #topbar sits top-right (kit.css): the badge (top-left)
   and ribbon (top-centre) below deliberately stay clear of it. --ink/--accent come
   from templates/kit/kit.css's colour tokens when it's loaded (game/text
   pages); message pages never load kit.css, hence the literal fallbacks. */

.ribbon {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  pointer-events: none;
  background: var(--accent, #e07a5f);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.badge {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 30;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge[hidden] {
  display: none;
}
.badge:hover,
.badge:focus-visible {
  background: rgba(0, 0, 0, 0.85);
}

.text-nav {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 24px 0;
}
.text-nav a {
  color: var(--ink, #1d3b57);
  font-weight: 600;
}

/* /text: the Report link, small and muted under the CV. */
.report {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 32px;
  font-size: 13px;
}
.report a {
  display: inline-block; /* a bigger tap target */
  padding: 4px 0;
  color: var(--ink, #1d3b57);
  opacity: 0.75;
}

/* The game's "Read as text" overlay (and the no-JS fallback): printable and
   Report links, the last child of #cv, a 44px tap row. `.cv .cv-links`
   outranks the kit's `.cv p` (margin, font-size). */
.cv .cv-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 24px;
  margin-top: 40px;
  font-size: 13px;
}
.cv-links a {
  display: inline-block;
  padding: 12px 0;
  color: var(--ink, #1d3b57);
}

.msg {
  max-width: 480px;
  margin: 15vh auto 0;
  padding: 0 24px;
  text-align: center;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1d3b57;
}
.msg h1 {
  margin: 0 0 8px;
  font-size: 22px;
}
.msg p {
  margin: 0 0 8px;
  color: #4a6a80;
  line-height: 1.5;
}
.msg a {
  color: #1d3b57;
}

@media (max-width: 700px) {
  .ribbon {
    top: 8px;
    font-size: 11px;
    padding: 3px 12px;
  }
  .badge {
    top: 8px;
    left: 8px;
  }
}

/* /text: keep this after the rules above so print always wins for that page. */
@media print {
  .text-nav,
  .report,
  .cv-links,
  .badge {
    display: none;
  }
  html,
  body {
    height: auto;
    background: #fff;
    color: #000;
  }
  .cv {
    max-width: none;
    padding: 0;
  }
  .cv .entry {
    break-inside: avoid;
  }
  .cv h2 {
    break-after: avoid;
  }
}

/* F16 recruiter pass (appended last so rebases stay clean): the start card
   (#glance), the Contact pill and popover (#dock, #contact) and the skip bar
   (#skipbar). Tokens come from kit.css. Positions are
   taken from the templates: #topbar top-right (z 10), #timeline bottom: 12px
   (z 10), #card z 20 (a top sheet: 54px from the top, up to 44vh), Summit
   Trail's #steps and Night Train's #ride at bottom 66px (54px on a phone).
   On a phone the start card sits in #card's box (F24, the block at the end). */
#glance {
  box-sizing: border-box;
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  border: 0;
  border-radius: 16px;
  /* --card is 93% opaque; over the light F17 backdrop the world's signs would
     read through it, so it's layered on the opaque --paper. */
  background: linear-gradient(var(--card), var(--card)), var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 40px rgba(20, 50, 60, 0.3);
}
#glance::backdrop {
  background: rgba(10, 20, 30, 0.2);
}
#glance h2 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
#glance p {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
#glance .glance-sub {
  color: var(--soft);
  font-weight: 600;
}
.glance-k {
  display: inline-block;
  margin-right: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--soft);
}
.glance-role .date {
  margin-left: 4px;
  color: var(--soft);
  font-size: 14px;
}
.glance-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}
/* Three stacked choices, each with what it does on a second line. */
.glance-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.glance-actions .btn {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 14px;
  font-size: 15px;
  text-align: left;
}
.glance-h {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.85;
}
.glance-actions .btn:focus-visible,
#dock button:focus-visible,
#skipbar button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Contact: the pill sits where #topbar appears until the game is ready, then
   shell.js moves the button into #topbar (which styles it). */
#dock {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 10;
}
#dock[hidden],
#skipbar[hidden] {
  display: none;
}
#dock button,
#skipbar button {
  background: var(--bar);
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(20, 50, 60, 0.2);
}
/* Hidden unless open, so a browser without the Popover API never shows it. */
#contact {
  display: none;
}
#contact:popover-open {
  display: block;
}
#contact[popover] {
  position: fixed;
  inset: auto 16px auto auto;
  top: 56px;
  box-sizing: border-box;
  margin: 0;
  max-width: min(360px, calc(100vw - 32px));
  padding: 14px 18px;
  border: 0;
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 8px 40px rgba(20, 50, 60, 0.25);
  overflow-wrap: anywhere;
}
#contact .links {
  margin: 0;
}

/* Skip bar: ⏮ ⏭, a music player's round icon buttons, in the right end of
   the game's own timeline where its count was (z 15: above its 10, below
   #card's 20). The gap keeps their 44px hit areas (F24) from overlapping:
   centres 44px apart (32px buttons + 12px; 30px + 14px on a phone). Under
   body.skipbar the rail gives up that end (rail-relative %, so the dots,
   ticks and track shrink together) and the count hides.
   #steps: Summit Trail's own ▼▲ "Previous/Next stop" pair, which the skip bar
   replaces, so there's one pair, not two. Night Train's #ride (hold to ride)
   is a different action and stays. */
#skipbar {
  position: fixed;
  right: 22px;
  bottom: 18px;
  z-index: 15;
  display: flex;
  gap: 12px;
}
#skipbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  box-shadow: none;
  background: var(--sea);
  color: var(--ink);
}
#skipbar svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
#skipbar button[aria-disabled="true"] {
  opacity: 0.4;
  cursor: default;
}
body.skipbar #timeline .rail {
  right: 96px;
}
body.skipbar #timeline .count,
body.skipbar #steps {
  display: none;
}

body[data-fallback] :is(#dock, #skipbar, .glance-play) {
  display: none;
}

@media (max-width: 700px) {
  /* A top sheet in the kit card's box, so the player shows under it (F24).
     The UA's modal max-width (100% - 6px - 2em) would make it 337px wide. */
  #glance {
    margin: 54px auto auto;
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    max-height: calc(100dvh - 62px);
    padding: 16px;
  }
  #dock {
    top: 10px;
    right: 10px;
  }
  #dock button {
    padding: 6px 10px;
  }
  #contact[popover] {
    top: 50px;
    left: 8px;
    right: 8px;
    max-width: none;
  }
  /* The kit's phone timeline: 34px tall, 8px from the sides. */
  #skipbar {
    right: 12px;
    bottom: 14px;
    gap: 14px;
  }
  #skipbar button {
    width: 30px;
    height: 30px;
  }
  body.skipbar #timeline .rail {
    right: 92px;
  }
}

/* F17 opening title (docs/features/17-opening-title.md): the start card's
   name spelled out in the game's own material. glance.ts splits the name into
   .gl-w words of .gl-l graphemes (aria-hidden, beside the visually hidden
   plain .gl-name) and sets data-template only for the templates styled here
   (TITLED: Night Train's split-flap board, Summit Trail's carved plank, Pixel
   Town's marquee); shell.js sets --n (letter count) and each letter's --i.
   The base rules ARE the final frame: every animation lives in the one
   prefers-reduced-motion: no-preference block below, so reduced motion (or no
   CSS animations) shows the finished title at once. Only transform, opacity
   and clip-path animate; every bulb and letter goes off to on once (no
   flashing); .glance-actions never animates, so Play works at t = 0. */
/* globals.css's .visually-hidden, copied: shell.css doesn't load globals. */
#glance .gl-name {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#glance .gl-letters {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  gap: 0.12em 0.32em;
  max-width: 100%;
  margin: 0 0 6px;
  --fs: 34px;
  font-size: var(--fs);
  line-height: 1.15;
  -webkit-user-select: none;
  user-select: none;
}
#glance .gl-letters.long {
  --fs: 26px;
}
/* A word keeps together when it fits and wraps inside itself when it can't
   (a 60-letter word at 360px). */
#glance .gl-w {
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
}

/* Night Train: a split-flap departures board. Amber letters (#ffcf5a, about
   11:1 on the cell) each on its own flap, split across the middle, in a near-
   black frame. */
#glance[data-template="night-train"] .gl-letters {
  width: fit-content;
  padding: 10px 12px;
  border-radius: 6px;
  background: #0c0e13;
  box-shadow: 0 4px 14px rgba(10, 14, 30, 0.35);
}
#glance[data-template="night-train"] .gl-w {
  gap: 0.08em;
}
#glance[data-template="night-train"] .gl-l {
  box-sizing: border-box;
  min-width: 0.72em;
  padding: 0.02em 0.06em;
  text-align: center;
  font-family:
    ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  color: #ffcf5a;
  background: linear-gradient(#262b36 0 48%, #0c0e13 48% 52%, #1e222b 52%);
  border-radius: 3px;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
}

/* Summit Trail: a trail-sign plank, nailed at both ends, the name routed into
   it in a slab face. --wood/--wood-dark are Summit Trail's own colour props.
   ponytail: the fallbacks are its default values, so a summit-trail@2 that
   drops them still renders. Wood-dark (#7a5133) is >= 6:1 against
   #fbf8f1. */
#glance[data-template="summit-trail"] .gl-letters {
  position: relative;
  width: fit-content;
  padding: 0.18em 0.5em;
  border-radius: 6px;
  font-family: Rockwell, "Roboto Slab", "DejaVu Serif", Georgia, serif;
  letter-spacing: 0.03em;
  background:
    repeating-linear-gradient(
      176deg,
      rgba(255, 255, 255, 0.06) 0 2px,
      transparent 2px 9px
    ),
    linear-gradient(rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.14)),
    var(--wood-dark, #7a5133);
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.25),
    0 3px 0 var(--wood, #b37c50),
    0 6px 14px rgba(20, 30, 20, 0.25);
  transform-origin: 50% 0;
}
#glance[data-template="summit-trail"] .gl-letters::before,
#glance[data-template="summit-trail"] .gl-letters::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.17em;
  width: 0.16em;
  height: 0.16em;
  margin-top: -0.08em;
  border-radius: 50%;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.45),
    rgba(0, 0, 0, 0.55) 70%
  );
}
#glance[data-template="summit-trail"] .gl-letters::after {
  left: auto;
  right: 0.17em;
}
#glance[data-template="summit-trail"] .gl-l {
  color: #fbf8f1;
  text-shadow:
    0 -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Pixel Town: a marquee. Monospace letters lit on a dark LED board, in an ink
   frame, with a row of square
   bulbs above and below. */
#glance[data-template="pixel-town"] {
  --bulb: #ffd66e;
  --board: #141b26;
}
#glance[data-template="pixel-town"] .gl-letters {
  position: relative;
  width: fit-content;
  padding: 14px 12px;
  gap: 0.12em 0.6em;
  border: 3px solid var(--ink, #1d3b57);
  border-radius: 2px;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.06) 1px, transparent 1.5px) 0
    0 / 5px 5px,
    var(--board);
  font-family:
    ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-weight: 700;
}
#glance[data-template="pixel-town"] .gl-letters::before,
#glance[data-template="pixel-town"] .gl-letters::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--bulb) 0 4px,
    transparent 4px 10px
  );
}
#glance[data-template="pixel-town"] .gl-letters::after {
  top: auto;
  bottom: 4px;
}
#glance[data-template="pixel-town"] .gl-l {
  color: var(--bulb);
  text-shadow: 0 0 8px rgba(255, 214, 110, 0.45);
}

@media (max-width: 700px) {
  #glance .gl-letters {
    --fs: 28px;
  }
  #glance .gl-letters.long {
    --fs: 22px;
  }
  #glance[data-template="pixel-town"] .gl-letters {
    padding: 10px 8px;
  }
  #glance[data-template="night-train"] .gl-letters {
    padding: 8px;
  }
}

/* Timing: --t0 the first letter, --step the stagger, --dur one letter. The
   stagger is capped so the last letter starts by --t0 + 1.4 s whatever the
   name's length (--n from shell.js); the card's lines then fade in. Worst
   case (n >= 20) everything ends by about 2.2 s. */
#glance[data-template] {
  --t0: 150ms;
  --step: 70ms;
  --dur: 520ms;
  --s: min(var(--step), 1400ms / var(--n, 1));
}
#glance[data-template="night-train"] {
  --t0: 300ms;
  --step: 75ms;
  --dur: 380ms;
}
#glance[data-template="summit-trail"] {
  --t0: 350ms;
  --step: 85ms;
  --dur: 300ms;
}
#glance[data-template="pixel-town"] {
  --t0: 400ms;
  --step: 90ms;
  --dur: 200ms;
}

@media (prefers-reduced-motion: no-preference) {
  #glance[data-template] .gl-l {
    animation-duration: var(--dur);
    animation-delay: calc(var(--t0) + var(--i, 0) * var(--s));
    animation-fill-mode: both;
  }
  #glance[data-template] :is(.glance-sub, .glance-role, .glance-skills) {
    animation: gl-fade 300ms ease-out both;
    animation-delay: calc(var(--t0) + var(--n, 0) * var(--s) + var(--dur) / 2);
  }
  #glance[data-template="night-train"] .gl-l {
    animation-name: gl-flap;
    animation-timing-function: ease-out;
  }
  #glance[data-template="summit-trail"] .gl-letters {
    animation: gl-drop 450ms ease-out both;
  }
  #glance[data-template="summit-trail"] .gl-l {
    animation-name: gl-carve;
    animation-timing-function: steps(4);
  }
  /* ponytail: steps(10) isn't exactly one step per bulb (the row width
     varies); it reads as a chase. Per-bulb elements if the owner wants exact. */
  #glance[data-template="pixel-town"] .gl-letters::before {
    animation: gl-carve 600ms steps(10) both;
  }
  #glance[data-template="pixel-town"] .gl-letters::after {
    animation: gl-carve-back 600ms steps(10) both;
  }
  #glance[data-template="pixel-town"] .gl-l {
    animation-name: gl-lit;
    animation-timing-function: steps(1, jump-end);
  }
}
@keyframes gl-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
/* A flap drops from the top, swings a little past and settles. */
@keyframes gl-flap {
  from {
    transform: perspective(300px) rotateX(90deg);
    opacity: 0;
  }
  70% {
    transform: perspective(300px) rotateX(-12deg);
    opacity: 1;
  }
  to {
    transform: perspective(300px) rotateX(0);
  }
}
@keyframes gl-drop {
  from {
    transform: translateY(-48px) rotate(-3deg);
    opacity: 0;
  }
  60% {
    transform: translateY(5px) rotate(1deg);
    opacity: 1;
  }
  82% {
    transform: translateY(-2px);
  }
}
/* A left-to-right wipe: a letter routed into the plank, or a row of bulbs. */
@keyframes gl-carve {
  from {
    clip-path: inset(0 100% 0 0);
  }
}
/* The bottom bulb row chases back, right to left. */
@keyframes gl-carve-back {
  from {
    clip-path: inset(0 0 0 100%);
  }
}
@keyframes gl-lit {
  from {
    opacity: 0.2;
  }
}

/* F17 addendum (docs/features/17-opening-title.md §10): curtain up, and the
   name lands in the world. While the start card is open the game's own
   reading card stays hidden (one summary, not two); once it closes, kit.css's
   #card.in shows it again. */
body:has(#glance[open]) #card {
  visibility: hidden;
}
/* Let the world show: a light dim (the card itself stays opaque) and, on
   desktop, the card in the kit card's column (right: 24px, centred), which
   every template's camera already keeps clear, so the first station and the
   player stay in view. Phones get a top sheet (see the F24 block at the end:
   every phone camera keeps the player under the kit's top sheet). */
@media (min-width: 701px) {
  #glance {
    margin: auto 24px auto auto;
    width: min(400px, calc(100% - 48px));
  }
}
/* shell.js's lift(): a same-document view transition, only with motion
   allowed and a lettered title. The card slides down (up on phones) and fades; the letters
   (named only when the game gave a target) fly into #gl-land, a shell-owned
   empty box at window.game.titleTarget()'s rect, shrinking into it and
   fading at the end; the root crossfade lifts the dimming. Names are set only
   for the transition, so nothing else ever carries them. */
#glance.gl-vt {
  view-transition-name: gl-card;
}
#glance.gl-fly .gl-letters {
  view-transition-name: gl-title;
}
#gl-land {
  position: fixed;
  pointer-events: none;
  view-transition-name: gl-title;
}
/* The dim lifts and the game's own card fades in once this one has mostly
   gone, so the two cards never read on top of each other. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-delay: 200ms;
}
::view-transition-old(gl-card) {
  animation: gl-card-out 250ms ease-in both;
}
::view-transition-group(gl-title) {
  animation-duration: 600ms;
  animation-timing-function: ease-in-out;
}
::view-transition-old(gl-title) {
  animation: gl-title-out 600ms ease-in-out both;
}
::view-transition-new(gl-title) {
  animation: none;
  opacity: 0;
}
@keyframes gl-card-out {
  to {
    transform: translateY(48px);
    opacity: 0;
  }
}
@keyframes gl-title-out {
  0%,
  70% {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* F24 (docs/features/24-night-train-polish.md): the world shows under or
   beside the start card. Every phone camera keeps the player under the kit's
   top sheet (54px + 44vh), so on a phone the card sits there too; short
   screens get a compact card whose actions never scroll away. */
@media (max-width: 700px), (max-height: 500px) {
  #glance p {
    margin-bottom: 8px;
  }
  /* One row of skills; the rest wrap out of sight (screen readers still
     read all five; the game shows them all). */
  #glance .glance-skills {
    max-height: 26px;
    overflow: hidden;
    margin-bottom: 8px;
  }
  #glance .chip {
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .glance-actions {
    position: sticky;
    bottom: 0;
    flex-direction: row;
    padding-top: 8px;
    margin-top: 4px;
    background: linear-gradient(var(--card), var(--card)), var(--paper);
  }
  .glance-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 14px;
  }
}
@media (min-width: 701px) and (max-height: 500px) {
  #glance {
    padding: 16px 18px;
  }
}
@media (max-width: 700px) {
  ::view-transition-old(gl-card) {
    animation-name: gl-card-up;
  }
}
/* Landscape phone: a strip along the top, the choices in their own column.
   [open] only: a closed dialog must keep the UA's display: none. */
@media (max-width: 700px) and (orientation: landscape) {
  #glance {
    margin: 8px auto auto;
    max-width: 640px;
    max-height: calc(100dvh - 16px);
    padding: 14px 16px;
  }
  #glance[open] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 200px);
    column-gap: 16px;
    align-content: start;
  }
  #glance > :not(.glance-actions) {
    grid-column: 1;
  }
  .glance-actions {
    grid-column: 2;
    grid-row: 1 / span 4;
    align-self: start;
    flex-direction: column;
    padding-top: 0;
    margin-top: 0;
  }
  .glance-actions .btn {
    flex: none; /* else flex-basis 0 crushes them in a column */
  }
  #glance .gl-letters {
    --fs: 24px;
  }
  #glance .gl-letters.long {
    --fs: 20px;
  }
  #glance p {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 6px;
  }
}
@keyframes gl-card-up {
  to {
    transform: translateY(-48px);
    opacity: 0;
  }
}

/* F24: 44px touch targets without moving anything (pseudo-elements don't
   change a box's rect). A dot's strip is only its own width: on a long
   route dots sit 8px apart, so shell.js gives each the bar nearest to it. */
#skipbar button,
#topbar button,
#dock button {
  position: relative;
}
#timeline .dot::before,
#skipbar button::before,
#topbar button::before,
#dock button::before {
  content: "";
  position: absolute;
}
#timeline .dot::before {
  left: 50%;
  top: 50%;
  width: 14px;
  height: 44px;
  transform: translate(-50%, -50%);
}
#skipbar button::before {
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}
#topbar button::before,
#dock button::before {
  inset: -8px 0;
}
