/* title.css — the title card. Owned by lead; loaded after style.css so it wins.
 *
 * Brief: gold on black, "swagged out". The reference is not a game menu — it is a
 * luxury mark. Foil-stamped high-contrast serif, hairline rules, a slow light sweep
 * across the metal, and a lot of empty black around it. Restraint is the swagger:
 * expensive things do not crowd the page.
 */

#boot {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  background: #050405;
  overflow: hidden;
  opacity: 1;
  transition: opacity 1.1s cubic-bezier(.22, 1, .36, 1);
}
#boot.gone { opacity: 0; pointer-events: none; }

/* Faint warm bloom behind the mark so the black is not flat, plus a vignette. */
.boot-vig {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(58% 42% at 50% 42%, rgba(201, 162, 39, .16), transparent 68%),
    radial-gradient(120% 90% at 50% 50%, transparent 42%, rgba(0, 0, 0, .92));
  pointer-events: none;
}

.boot-inner {
  position: relative;
  text-align: center;
  padding: 0 24px;
  animation: boot-rise 1.5s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes boot-rise { from { opacity: 0; transform: translateY(16px); } }

/* --- the mark ------------------------------------------------------------ */
/* style.css paints magenta/cyan text-shadows and uses ::before + ::after for its own
 * rules. Those shadows draw opaque coloured copies BEHIND the transparent glyphs, so
 * the foil never shows — the letters read as white with RGB fringing. Reset them here. */
#boot-title::before { content: none !important; }

#boot-title {
  margin: 0;
  text-shadow: none !important;
  animation: none !important;
  font-family: "Didot", "Bodoni MT", "Playfair Display", "Hoefler Text", Garamond, Georgia, serif;
  font-weight: 500;
  font-size: clamp(34px, 8.2vw, 104px);
  letter-spacing: .11em;
  line-height: 1;
  text-indent: .11em;              /* balances the trailing letterspace */
  white-space: nowrap;

  /* Real foil: a banded gradient with a hot specular through the middle, not flat yellow. */
  background: linear-gradient(
    177deg,
    #6b4d14 0%,
    #a87f22 14%,
    #e3c25c 30%,
    #fff6cf 45%,
    #f0d886 52%,
    #c9a227 66%,
    #8a6618 82%,
    #5c420f 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .85))
          drop-shadow(0 0 34px rgba(201, 162, 39, .30));
}

/* The light sweep — a slow highlight travelling across the metal. */
#boot-title::after {
  content: attr(data-text) !important;
  position: absolute;
  inset: 0;
  left: 0; right: 0; width: auto; height: auto;
  transform: none;
  letter-spacing: inherit;
  text-indent: inherit;
  font: inherit;
  display: grid;
  place-items: center;
  background: linear-gradient(
    100deg,
    transparent 38%,
    rgba(255, 255, 255, .78) 48%,
    rgba(255, 255, 255, .95) 50%,
    rgba(255, 255, 255, .78) 52%,
    transparent 62%
  );
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: boot-sheen 6.5s ease-in-out 1.4s infinite;
  pointer-events: none;
}
@keyframes boot-sheen {
  0%          { background-position: 175% 0; }
  38%, 100%   { background-position: -75% 0; }
}

/* --- hairline rules ------------------------------------------------------ */
.boot-rule {
  height: 1px;
  margin: 0 auto;
  width: min(560px, 78vw);
  background: linear-gradient(90deg, transparent, rgba(201, 162, 39, .55), transparent);
  position: relative;
}
.boot-rule-top { margin-bottom: 26px; }
.boot-rule-bot { margin-top: 26px; }
/* A small diamond on the rule — the one ornament, and it earns its place. */
.boot-rule i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px; height: 5px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: #d9b545;
  box-shadow: 0 0 10px rgba(217, 181, 69, .8);
}

/* --- subtitle ------------------------------------------------------------ */
#boot-sub {
  margin-top: 20px;
  font-family: "Didot", "Bodoni MT", "Playfair Display", Georgia, serif;
  font-style: italic;
  font-size: clamp(13px, 1.6vw, 19px);
  letter-spacing: .34em;
  text-indent: .34em;
  color: #c9a227;
  opacity: .92;
}

/* --- begin --------------------------------------------------------------- */
#boot-start {
  margin-top: 46px;
  position: relative;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(201, 162, 39, .5);
  color: #e8d69a;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .42em;
  text-indent: .42em;
  padding: 15px 40px;
  overflow: hidden;
  transition: color .35s ease, border-color .35s ease, box-shadow .35s ease;
}
/* Gold wipes in from the left on hover, and the label flips to black. */
#boot-start::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #a87f22, #f0d886 46%, #c9a227);
  transform: translateX(-101%);
  transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}
#boot-start span { position: relative; }
#boot-start:hover,
#boot-start:focus-visible {
  color: #17120a;
  border-color: #e3c25c;
  box-shadow: 0 10px 40px rgba(201, 162, 39, .28);
  outline: none;
}
#boot-start:hover::before,
#boot-start:focus-visible::before { transform: translateX(0); }
#boot-start:active { transform: translateY(1px); }

.boot-arcade {
  display: block;
  margin: 12px auto 0;
  min-width: 190px;
  cursor: pointer;
  padding: 11px 22px;
  border: 1px solid rgba(255, 45, 82, .58);
  background: rgba(154, 8, 42, .14);
  color: #ff6987;
  font: 800 10px/1 ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .32em;
  text-indent: .32em;
  box-shadow: inset 0 0 18px rgba(255, 45, 82, .06);
  transition: color .25s ease, background .25s ease, box-shadow .25s ease;
}
.boot-arcade[hidden] { display: none; }
.boot-arcade:hover, .boot-arcade:focus-visible {
  color: #fff;
  background: rgba(190, 10, 50, .32);
  box-shadow: 0 0 26px rgba(255, 45, 82, .25);
  outline: none;
}

/* --- byline -------------------------------------------------------------- */
.boot-byline {
  margin-top: 40px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 10.5px;
  letter-spacing: .16em;
  color: #6c6152;
}
.boot-byline b { color: #a89258; font-weight: 600; letter-spacing: .18em; }

@media (max-width: 560px) {
  #boot-title { letter-spacing: .06em; text-indent: .06em; white-space: normal; }
  #boot-sub { letter-spacing: .24em; text-indent: .24em; }
}

@media (prefers-reduced-motion: reduce) {
  #boot-inner, #boot-title::after { animation: none; }
  #boot-title::after { display: none; }
}

/* ===================================================================== *
 * Mobile fixes — found on an actual iPhone, not in a desktop viewport.
 * ===================================================================== */

/* GHOSTING: .mi-hud transitions transform over a live WebGL canvas. iOS Safari
 * leaves a stale composited layer behind, which renders as a second, clipped copy
 * of the stat block at the transform's start position. Promoting the element to
 * its own layer explicitly — and using a 3D transform so it is GPU-composited from
 * the first frame — stops the stale layer being left behind. */
.mi-hud {
  will-change: opacity;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translate3d(-10px, 0, 0);
  transform: translate3d(-10px, 0, 0);
}
.mi-hud.is-on {
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
}

/* PERFORMANCE: backdrop-filter over a running WebGL canvas forces a full readback
 * of the framebuffer every frame. On a phone that is enough to stall the main
 * thread and starve the audio scheduler — which is why the music dropped out
 * during sequences. Not worth it for a subtle blur. */
@media (hover: none), (pointer: coarse) {
  .rf-lane,
  .rf-mode-intimacy .rf-lane,
  .ms-pad {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .rf-lane, .rf-mode-intimacy .rf-lane {
    background: linear-gradient(to bottom, rgba(12, 8, 16, .38), rgba(12, 8, 16, .62));
  }
  .ms-pad { background: rgba(18, 14, 22, .72); }
}

/* Loading state on BEGIN while the crowd warms. */
#boot-start.is-loading { pointer-events: none; color: #8a7c58; border-color: rgba(201,162,39,.28); }
#boot-start.is-loading span { animation: boot-pulse 1.2s ease-in-out infinite; }
@keyframes boot-pulse { 50% { opacity: .42; } }

/* TAP-THROUGH BUG: .mi-advance is a full-screen invisible button used to advance
 * dialogue. It lives in .mi, which has no z-index, so it *should* sit under the
 * sequence overlays — but .mi is painted after nothing else establishes order, and
 * elementFromPoint resolves it as the top hit target across the whole viewport.
 * On desktop nobody noticed because sequences are played with arrow keys. On a phone
 * it ate every tap and made all nine minigames unplayable.
 *
 * Fix: while a sequence is running, the advance button is disabled for pointers. */
body:has(.rf) .mi-advance,
body:has(.ms) .mi-advance,
body:has(.end) .mi-advance {
  pointer-events: none !important;
}

/* Belt and braces for engines without :has() — the overlays raise themselves above
 * the dialogue layer explicitly rather than relying on document order. */
.rf  { z-index: 120 !important; }
.ms  { z-index: 120 !important; }
.drv { z-index: 120 !important; }
.end { z-index: 300 !important; }

/* Runtime marker equivalent of the :has() rules above. */
body.seq-active .mi-advance { pointer-events: none !important; }

/* ROOT CAUSE of "taps don't register": #ui is pointer-events:none so that dialogue
 * doesn't block the scene, and nothing ever restored it for the sequence overlays.
 * .mi works only because .mi-advance sets pointer-events:auto on itself. Sequence roots
 * must opt back in or every tap falls through to the WebGL canvas. Keyboard play hides
 * that failure completely on desktop.
 *
 * (playground.html has `#ui > * { pointer-events: auto }`, which is exactly why the
 * sequences were tappable there and dead in the real game.) */
#ui > .rf,
#ui > .ms,
#ui > .drv,
#ui > .fgt,
#ui > .end { pointer-events: auto; }

/* =============================================================================
   HOUSE STYLE — chapter cards and the ending inherit the title's language.
   =============================================================================
   The title card is the mark: foil-stamped high-contrast serif, gold hairlines with a
   single diamond, deep black, and a lot of air. The chapter cards and the end screen
   were speaking a different language — neon magenta/cyan, heavy sans, wide tracking —
   so the game opened luxury and then turned into a different product. Same vocabulary
   everywhere now.

   Loaded last, so these win over style.css's per-chapter palette without !important
   except where style.css uses text-shadow/animation on the same elements.
*/

:root {
  --foil: linear-gradient(177deg,
    #6b4d14 0%, #a87f22 14%, #e3c25c 30%, #fff6cf 45%,
    #f0d886 52%, #c9a227 66%, #8a6618 82%, #5c420f 100%);
  --serif: "Didot", "Bodoni MT", "Playfair Display", "Hoefler Text", Garamond, Georgia, serif;
  --gold: #c9a227;
  --gold-lo: rgba(201, 162, 39, .55);
}

/* Shared foil-stamp treatment.
 *
 * The chapter title is typeset into per-character <span class="mi-ch"> for the reveal,
 * and those spans carry a transform. A transformed descendant paints in its own context,
 * so a background-clip:text gradient set on the PARENT never reaches it — the characters
 * inherited `-webkit-text-fill-color: transparent` with no gradient of their own and the
 * chapter names vanished entirely. The foil therefore has to be applied to whatever
 * element actually paints the glyphs, which is why .mi-ch is listed here too.
 */
.mi-chapcard-title,
.mi-chapcard-title .mi-ch,
.end-title {
  font-family: var(--serif);
  font-weight: 500;
  background: var(--foil);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: none !important;
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .85))
          drop-shadow(0 0 34px rgba(201, 162, 39, .28));
}

/* Shared kicker: gold, small, widely tracked. */
.mi-chapcard-kicker,
.end-kicker {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--gold) !important;
  text-shadow: none !important;
  letter-spacing: .34em;
  text-indent: .34em;
}

/* --- chapter card -------------------------------------------------------- */
.mi-chapcard {
  background:
    radial-gradient(58% 42% at 50% 46%, rgba(201, 162, 39, .13), transparent 68%),
    radial-gradient(120% 90% at 50% 50%, transparent 42%, rgba(0, 0, 0, .94)),
    #050405;
}
.mi-chapcard-title {
  font-weight: 500;
  letter-spacing: .11em;
  text-indent: .11em;
  font-size: clamp(30px, 7vw, 96px);
}
.mi-chapcard-kicker { font-size: clamp(10px, 1.1vw, 14px); }

/* Gold hairlines, and the diamond ornament the title card uses. */
.mi-chapcard-rule {
  background: linear-gradient(90deg, transparent, var(--gold-lo), transparent);
  width: min(560px, 78vw);
  position: relative;
}
.mi-chapcard-rule::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  transform: translate(-50%, -50%) rotate(45deg);
  background: #d9b545;
  box-shadow: 0 0 10px rgba(217, 181, 69, .8);
}

/* --- ending -------------------------------------------------------------- */
.end {
  background:
    radial-gradient(58% 42% at 50% 30%, rgba(201, 162, 39, .13), transparent 68%),
    radial-gradient(120% 90% at 50% 50%, transparent 40%, rgba(0, 0, 0, .94));
  background-color: #050405;
}
.end-title {
  letter-spacing: .09em;
  text-indent: .09em;
  font-size: clamp(24px, 5vw, 54px);
}
.end-kicker { color: var(--gold) !important; }

/* The prose line reads as a book, not a HUD. */
.end-line {
  font-family: var(--serif);
  font-style: italic;
  color: #d8cfbe;
  letter-spacing: .012em;
}

/* Stat cards: hairline gold, no plastic fills. */
.end-stat {
  background: rgba(201, 162, 39, .045);
  border: 1px solid rgba(201, 162, 39, .22);
  border-radius: 0;
}
.end-k { color: var(--gold); letter-spacing: .34em; font-weight: 600; }
.end-v { font-family: var(--serif); font-weight: 500; color: #f4ead2; }
.end-n { color: #8d8474; font-style: italic; font-family: var(--serif); }

/* The choice log: gold ticks instead of magenta bars. */
.end-log > div { border-left: 1px solid var(--gold-lo); color: #cfc6b6; }
.end-tarot span { color: var(--gold); font-family: var(--serif); font-style: italic; }

/* PLAY AGAIN matches BEGIN on the title card: outlined gold, not a filled slab. */
.end-btn {
  background: transparent;
  border: 1px solid rgba(201, 162, 39, .5);
  color: #e8d9a6;
  font-family: var(--serif);
  letter-spacing: .3em;
  text-indent: .3em;
  border-radius: 0;
  padding: 15px 40px;
  transition: background .5s var(--ease, ease), color .5s var(--ease, ease);
}
.end-btn:hover {
  background: rgba(201, 162, 39, .12);
  color: #fff6cf;
}
.end-foot { color: #6f6858; font-family: var(--serif); font-style: italic; }
.end-foot b { color: var(--gold); font-style: normal; letter-spacing: .18em; }

/* --- continue (shown only when a save exists) ----------------------------- */
#boot-continue {
  display: block;
  margin: 14px auto 0;
  position: relative;
  cursor: pointer;
  background: transparent;
  border: 1px solid rgba(201, 162, 39, .28);
  color: #b9a878;
  font-family: var(--serif);
  font-size: clamp(10px, 1.15vw, 12px);
  letter-spacing: .3em;
  text-indent: .3em;
  padding: 13px 30px;
  transition: color .5s ease, border-color .5s ease, background .5s ease;
  -webkit-tap-highlight-color: transparent;
}
#boot-continue:hover {
  color: #fff6cf;
  border-color: rgba(201, 162, 39, .6);
  background: rgba(201, 162, 39, .1);
}

/* The tarot rail leaving for good after Ameera's reading. */
.mi-rail.is-retiring {
  opacity: 0 !important;
  transform: translateX(24px);
  transition: opacity .9s cubic-bezier(.22, 1, .36, 1), transform .9s cubic-bezier(.22, 1, .36, 1);
  pointer-events: none;
}
