/* The "Start reading" trailer (CHE-487). Stand-alone: it does not load the site stylesheet.
   Colour tokens are copied from the app's client/src/index.css (parchment palette) - copied,
   not imported. The reading face is Atkinson Hyperlegible, the app's. A page never scrolls. */

:root {
  /* copied from the app (client/src/index.css :root) */
  --parchment: #efe6d2;
  --parchment-light: #f6efde;
  --parchment-deep: #e2d6b8;
  --ink: #1c1a17;
  --ink-soft: #3a342d;
  --ink-mute: #6b6357;
  --oxblood: #7d3a35;
  --brass: #b8893a;
  --border: #91793b;            /* hsl(43 42% 40%) - the app's --border */
  --muted-foreground: #655d52;  /* hsl(36 10% 36%) - the app's --muted-foreground */
  --primary-wash: rgba(28, 26, 23, 0.1);  /* the app's bg-primary/10 badge ground */
  --card: var(--parchment-light);

  --top: 56px;
  --measure: 40rem;
  --frame-max: 46rem;
  --font-read: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-stake: "Cormorant Garamond", Georgia, serif;
  --font-display: "Cinzel", "Cormorant Garamond", Georgia, serif;
  /* the narrator's face: plainly not the site's display set and not the reading face */
  --font-narrator: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; }

body.start {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  font-family: var(--font-read);
  color: var(--ink-soft);
  background: var(--parchment);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(184,137,58,0.05) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(125,58,53,0.04) 0%, transparent 40%);
}

:where(a, button):focus-visible {
  outline: 3px solid var(--oxblood);
  outline-offset: 2px;
}
.is-focus-target:focus { outline: none; }

/* ------------------------------ top bar ------------------------------ */
.top {
  flex: none;
  height: var(--top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
}
.top-brand { display: inline-flex; border: 0; }
.top-brand img { width: 40px; height: 40px; border-radius: 2px; }
.voice { display: inline-flex; gap: 8px; }
.voice[hidden] { display: none; }
.voice button {
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 12px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink-mute);
  border-radius: 2px;
  cursor: pointer;
}
.voice button[aria-pressed="true"] { background: var(--ink); color: var(--parchment); border-color: var(--ink); }

/* ------------------------------ stage + frame ------------------------------ */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  padding: 0 12px 12px;
}
.screen { width: 100%; height: 100%; display: flex; justify-content: center; }

@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
  .screen { animation: screen-in 0.28s ease both; }
}

.frame {
  width: 100%;
  max-width: var(--frame-max);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--parchment-deep);
  box-shadow: 0 1px 0 rgba(28,26,23,0.06), 0 24px 48px -28px rgba(28,26,23,0.25);
  padding: 14px 18px 0;
  overflow: hidden;
}
.frame--wall { max-width: 72rem; }

/* The picture page, as the app sets it (StoryReader.tsx "story-page-image"): a box the height of the page minus the
   menu that shares it minus a 24px gap (set inline, in px), rounded-lg, the image centered, contained, never
   cropped (max-h-full max-w-full object-contain). No ground colour. */
.plate {
  flex: none;
  margin: 0 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0.5rem;
}
.plate img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; display: block; }
/* A readable measure, centered in the frame (the app's reader holds its column the same way). */
.plate, .prose, .menu { width: 100%; max-width: var(--measure); align-self: center; }

/* The prose. Measured by an identical element in .measure-host: keep every rule that changes
   a line's height or width on the shared selector below. */
.prose {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flow-root;
  /* the app's reading page (client/src/index.css .story-content): 1.1rem, line-height 1.85, a 1rem paragraph
     gap, a 1.5rem first-line indent on every paragraph but the first of a page that starts one */
  font-size: 1.1rem;
  line-height: 1.85;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
}
.prose p { margin: 0 0 1rem; text-indent: 1.5rem; }
.prose p.no-indent { text-indent: 0; }
.prose.is-empty { display: none; }
.prose.is-empty ~ .menu { margin-top: auto; margin-bottom: auto; }       /* a menu-only page: centered in the page */
.plate ~ .prose.is-empty ~ .menu { margin-top: 0; margin-bottom: 0; }   /* a menu under its picture: right beneath it */
.prose strong { color: var(--ink); font-weight: 700; }

/* The menu as the app sets it: space-y-3 (0.75rem) between the stake and the options and between options;
   the stake mt-4 (1rem); mt-8 (2rem) above a menu that follows prose; each option p-4 with a 2px border. */
.menu { flex: none; margin-top: 0; padding-bottom: 8px; }
.menu--after-prose { margin-top: 2rem; }
.stake {
  margin: 1rem 0 0;
  font-family: var(--font-stake);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.35;
  color: var(--muted-foreground);
}
.options { display: grid; gap: 0.75rem; }
.stake + .options { margin-top: 0.75rem; }
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--border);
  padding: 1rem;
  cursor: pointer;
}
.option:hover { border-color: var(--ink); background: rgba(28,26,23,0.05); }
.badge {
  flex: none;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--primary-wash);
}
.option:hover .badge { background: var(--ink); color: var(--parchment); }
.option .label { font-weight: 700; }
.option .tail { font-style: italic; color: var(--muted-foreground); }

.turnbar {
  flex: none;
  margin-top: auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: auto -18px 0;
  padding: 0 10px;
  border-top: 1px solid var(--parchment-deep);
}
.turn {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  padding: 10px 12px;
  cursor: pointer;
}
.turn:hover:not(:disabled) { background: rgba(28,26,23,0.06); }
.turn:disabled { opacity: 0.4; cursor: default; }
.turn[hidden-slot] { visibility: hidden; }
.pageno { font-size: 0.9rem; color: var(--muted-foreground); }
.bar-mid { display: inline-flex; align-items: center; gap: 12px; }
.turnbar .play { width: 40px; height: 40px; font-size: 0.95rem; }

/* ------------------------------ the wall ------------------------------ */
/* The wall is one group centred in the frame, never scrolling: two door tiles side by side, then her "More doors"
   button with her line directly under it. Each tile hugs its content - the whole picture (a 2:3 portrait, contained,
   never cropped), the name, the caption - and no more: the engine sets --pic-h to the tallest picture the room allows,
   and the tile's width follows the picture. */
.wall {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 0;
}
.plaques {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, min-content);
  grid-template-rows: auto;
  justify-content: center;
  gap: 10px;
}
.plaques li { min-height: 0; min-width: 0; display: flex; align-items: stretch; }   /* equal tiles: the taller caption sets both */
.plaque {
  flex: 1;
  min-width: 9.5rem;   /* room for the caption on a short window, where the picture is narrow */
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--border);
  padding: 6px;
  cursor: pointer;
}
.plaque:hover:not(:disabled) { border-color: var(--ink); background: rgba(28,26,23,0.05); }
.plaque img {
  flex: none;
  width: auto;
  height: var(--pic-h, 200px);
  aspect-ratio: 2 / 3;
  align-self: center;   /* no percentage max-width here: a compressible replaced element would let the tile collapse to its longest word */
  object-fit: contain;
  display: block;
}
.plaque-name {
  flex: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  line-height: 1.25;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.plaque-tease {
  flex: none;
  font-family: var(--font-stake);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.25;
  color: var(--muted-foreground);
}
.plaque:disabled { cursor: default; filter: grayscale(1); opacity: 0.55; }

@media (min-width: 760px) {
  .wall { gap: 20px; }
  .plaques { gap: 18px; }
  .plaque { padding: 10px; }
  .plaque-name { font-size: 0.9rem; }
  .plaque-tease { font-size: 1.05rem; }
}

/* the way out: her button, centred under the two doors, with her line directly under it in the caption's own italic */
.wayout { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 34rem; text-align: center; }
.wayout-note {
  margin: 0;
  font-family: var(--font-stake);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.3;
  color: var(--muted-foreground);
}

/* ------------------------------ bridges (the narrator) ------------------------------ */
.bridge {
  width: 100%;
  max-width: 40rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 0 20px;
  text-align: center;
}
/* a chapter's card above the narrator line (the app: the picture is the flexible part, never cropped, 45vh at most) */
.bridge-card { flex: 1 1 0; min-height: 0; width: 100%; max-height: 45vh; object-fit: contain; display: block; }
.bridge-text {
  margin: 0;
  font-family: var(--font-narrator);
  font-size: clamp(1.05rem, 2.6vw, 1.45rem);
  line-height: 1.7;
  color: var(--ink);
}
.bridge-actions { display: flex; align-items: center; gap: 14px; }
.play {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: 1.1rem;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}
.play[hidden] { display: none; }
.play[aria-pressed="true"] { background: var(--ink); color: var(--parchment); }

/* the site's own button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 14px 28px;
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--parchment);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--oxblood); border-color: var(--oxblood); color: var(--parchment); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); border-color: var(--ink); color: var(--parchment); }

/* ------------------------------ chooser + end card ------------------------------ */
.centered {
  width: 100%;
  max-width: 40rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 20px;
  text-align: center;
}
.chooser-heading, .end-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  line-height: 1.15;
  color: var(--ink);
}
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; width: 100%; }
.narrator-card {
  flex: 1 1 14rem;
  max-width: 18rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: inherit;
  text-align: center;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--border);
  padding: 18px 14px;
  cursor: pointer;
}
.narrator-card:hover { border-color: var(--ink); background: rgba(28,26,23,0.05); }
.narrator-card .n-label { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; letter-spacing: 0.06em; }
.narrator-card .n-desc { font-family: var(--font-stake); font-style: italic; font-size: 1.1rem; color: var(--muted-foreground); }
.chooser-footer, .end-trust, .end-ai {
  margin: 0;
  font-family: var(--font-stake);
  font-size: 1.1rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.chooser-footer, .end-ai { font-style: italic; color: var(--muted-foreground); }
.end-trust { font-size: 1.15rem; }
.end-trust + .end-trust { color: var(--ink-mute); margin-top: -12px; }

@media (max-width: 480px) {
  .frame { padding: 12px 14px 0; }
  .turnbar { margin: auto -14px 0; }
  .prose { font-size: 1.0625rem; }
}

/* ------------------------------ off-screen measuring copy ------------------------------ */
.measure-host {
  position: fixed;
  left: -100000px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}
.measure-host .screen { animation: none; }

.visually-hidden {
  position: absolute !important;
  height: 1px; width: 1px; overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}
