/* /play: the launch briefing on one screen, over an infected charging the viewer.
   Loaded only by play.html (after site.css). The scene is the key art poster until
   play-hero.js reports data-hero="live" on [data-play-stage]; then its canvas fades in.
   --hero-focus-x / --hero-focus-y tell the renderer where the charging infected should sit. */

/* ---------- The header floats over the scene ---------- */
.page-play .site-header {
  position: absolute; inset: 0 0 auto;
  background: transparent; border-bottom: 0;
}
.page-play .site-header::before {
  content: ""; position: absolute; inset: 0 0 -48px; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, rgb(14 15 17 / 0.92), rgb(14 15 17 / 0.62) 55%, rgb(14 15 17 / 0));
}
/* One primary action per screen: the launch button. The header's Enlist steps back to a ghost. */
.page-play .site-header .button--amber { background: transparent; color: var(--bone); border-color: var(--bone-dim); box-shadow: none; }
.page-play .site-header .button--amber:hover { color: var(--amber); border-color: var(--amber); transform: none; }

/* ---------- Stage ---------- */
.play-stage {
  --hero-focus-x: 0.5;
  --hero-focus-y: 0.36;
  --stage-pad-bottom: max(20px, env(safe-area-inset-bottom));
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 100vh; min-height: 100svh;
  padding: calc(var(--header-h) + 16px) 0 var(--stage-pad-bottom);
  background: var(--ink-env);
  border-bottom: 1px solid var(--grey-dark);
}

/* The scene: poster underneath, live canvas on top of it. */
.play-stage__scene { position: absolute; inset: 0; z-index: -2; overflow: hidden; background: var(--ink-env); }
.play-stage__poster { position: absolute; inset: 0; display: block; }
.play-stage__poster img {
  position: absolute; inset: 0 0 auto; width: 100%; height: 100%; max-width: none;
  object-fit: cover; object-position: 50% 55%;
}
.play-stage__canvas {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  opacity: 0; transition: opacity 900ms ease;
}
[data-play-stage][data-hero="live"] .play-stage__canvas { opacity: 1; }

/* Scrims for text contrast, a vignette, and a faint surveillance-feed texture. */
.play-stage__shade { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.play-stage__shade::before, .play-stage__shade::after { content: ""; position: absolute; pointer-events: none; }
.play-stage__shade::before {
  inset: 0;
  background:
    repeating-linear-gradient(180deg, rgb(14 15 17 / 0.09) 0 1px, rgb(14 15 17 / 0) 1px 3px),
    radial-gradient(ellipse 140% 110% at 50% 38%, rgb(14 15 17 / 0) 52%, rgb(14 15 17 / 0.72) 100%);
}
/* A slow signal sweep down the feed (off with reduced motion). */
.play-stage__shade::after {
  inset: 0 0 auto; height: 22%; opacity: 0;
  background: linear-gradient(180deg, rgb(237 232 220 / 0), rgb(237 232 220 / 0.035) 60%, rgb(237 232 220 / 0.05) 80%, rgb(237 232 220 / 0));
}
@media (prefers-reduced-motion: no-preference) {
  .play-stage__shade::after { animation: play-sweep 11s linear 1.5s infinite; }
  @keyframes play-sweep {
    from { transform: translateY(-100%); opacity: 1; }
    to { transform: translateY(460%); opacity: 1; }
  }
  .play-stage__content { animation: play-arrive 650ms ease-out both; }
  @keyframes play-arrive { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  .play-stage__feed .signal-dot { animation: play-blink 1.6s steps(2, jump-none) infinite; }
  @keyframes play-blink { 50% { opacity: 0.25; } }
}

/* Feed caption, bottom right on wide screens. */
.play-stage__feed {
  position: absolute; right: clamp(16px, 3.5vw, 64px); bottom: 24px; z-index: 1;
  display: none; align-items: center; margin: 0;
  font-size: var(--t-label); letter-spacing: 0.14em; color: var(--bone-dim);
}

/* ---------- Content: the route column, with the evac line running down its left edge ---------- */
.play-stage__content {
  position: relative; width: 100%; max-width: var(--max); margin: 0 auto;
  padding: 0 var(--gutter) 0 var(--inset);
}
.play-stage__content::before {
  content: ""; position: absolute; left: var(--line-x); top: 6px; bottom: calc(-1 * var(--stage-pad-bottom));
  width: 4px; background: var(--evac-line);
}
.play-stage__content > :not(dialog) { max-width: 600px; }

.play-stage__gantry { margin: 0 0 30px; }
.play-stage__gantry .gantry__panel { padding: 8px 14px; }
.play-stage__gantry .gantry__line { font-size: clamp(0.82rem, 1.5vw, 1.05rem); }

.play-stage__title {
  margin: 0 0 0.28em;
  font-size: clamp(2.45rem, min(10.5vw, 9svh), 5.7rem);
  line-height: 0.94;
  letter-spacing: -0.03em;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgb(14 15 17 / 0.55);
}
.play-stage__lead {
  margin: 0 0 20px; max-width: 42ch;
  font-size: clamp(1.08rem, 1.7vw, 1.32rem); line-height: 1.35; color: var(--bone);
  text-shadow: 0 1px 12px rgb(14 15 17 / 0.7);
}

.play-stage__launch { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; margin: 0 0 14px; }
.play-stage__launch .button { min-height: 56px; }
.play-stage__go {
  gap: 18px; padding-inline: 1.3em;
  font-size: clamp(1.25rem, 2vw, 1.55rem); letter-spacing: 0.08em;
}
.play-stage__go > span { font-family: var(--font-mono); font-size: 1.1em; transition: transform 0.15s ease; }
.play-stage__go:hover > span { transform: translateX(4px); }
.play-stage__unfiltered { font-size: 1.02rem; padding-inline: 1em; }

.play-stage__controls { margin: 0 0 16px; font-size: var(--t-label); letter-spacing: 0.12em; line-height: 1.6; color: var(--bone-dim); }

/* The four rules as one strip: number + title; the body only where there is room. */
.play-rules {
  list-style: none; margin: 0; padding: 12px 0 0;
  display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 0;
  border-top: 1px solid var(--grey-mid);
}
.play-rules__item { display: flex; align-items: baseline; gap: 8px; padding: 0 16px; border-left: 1px solid var(--grey-mid); }
.play-rules__item:nth-child(odd) { padding-left: 0; border-left: 0; }
.play-rules__number { font-family: var(--font-display); font-size: 1.05rem; line-height: 1; color: var(--amber); }
.play-rules__title { font-weight: 700; font-size: 1rem; line-height: 1.2; letter-spacing: 0.06em; text-transform: uppercase; color: var(--bone); white-space: nowrap; }
.play-rules__body {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (min-width: 520px) {
  .play-rules { grid-template-columns: repeat(4, max-content); }
  .play-rules__item:nth-child(odd) { padding-left: 16px; border-left: 1px solid var(--grey-mid); }
  .play-rules__item:first-child { padding-left: 0; border-left: 0; }
}

.play-stage__note { margin: 14px 0 0; font-size: 0.95rem; line-height: 1.35; color: var(--bone-dim); }
/* Open beta: keeping the full game (PLAY_LISTED + ACCOUNTS_LISTED). Gives way with the note. */
.play-stage__pledge { margin: 10px 0 0; padding-left: 12px; border-left: 3px solid var(--amber); font-size: 0.95rem; line-height: 1.35; color: var(--bone); }

/* No build yet: the enlist form in the same column. */
.play-stage__enlist { max-width: 520px; gap: 0; padding: 22px 0 0; margin-top: 4px; }

/* ---------- Portrait and narrow: the infected above, the briefing below ---------- */
@media (orientation: portrait), (max-width: 639px) {
  /* The poster fills the upper part of the screen and fades into ink under the text,
     so the charging infected sit above the briefing. */
  .play-stage__poster img {
    height: 56%; object-position: 42% 100%;
    -webkit-mask-image: linear-gradient(180deg, var(--ink) 72%, rgb(14 15 17 / 0));
    mask-image: linear-gradient(180deg, var(--ink) 72%, rgb(14 15 17 / 0));
  }
  .play-stage__shade {
    background: linear-gradient(0deg, var(--ink-env) 0%, rgb(18 19 20 / 0.94) 30%, rgb(18 19 20 / 0.5) 46%, rgb(18 19 20 / 0) 60%);
  }
  /* The screen belongs to the charge: the four rules (on the home page too) and the note
     give way, so the briefing is title, one line, launch and controls. */
  .play-stage { --hero-focus-y: 0.3; }
  .play-rules, .play-stage__note, .play-stage__pledge { display: none; }
  .play-stage__launch .button { flex: 1 1 100%; justify-content: space-between; }
  .play-stage__launch .play-stage__unfiltered { justify-content: center; min-height: 48px; }
  .play-stage__go { min-height: 60px; }
}
@media (orientation: portrait) and (min-width: 520px), (min-width: 520px) and (max-width: 639px) {
  .play-stage__launch .button { flex: 0 1 auto; }
  .play-stage__launch .play-stage__unfiltered { min-height: 60px; }
}
/* Phones upright: the gantry would cover the horde; the header already carries the name. */
@media (orientation: portrait) and (max-height: 900px) {
  .play-stage__gantry { display: none; }
}
/* Short portrait phones: keep title, launch and controls in view. */
@media (orientation: portrait) and (max-height: 760px) {
  .play-stage { --hero-focus-y: 0.27; padding-top: calc(var(--header-h) + 8px); }
  .play-stage__title { font-size: clamp(2.2rem, 9.5vw, 3.4rem); }
  .play-stage__note, .play-stage__pledge { display: none; }
}
@media (orientation: portrait) and (max-height: 680px) {
  .play-stage__lead { font-size: 1rem; margin-bottom: 14px; }
  .play-rules { display: none; }
}

/* ---------- Landscape: briefing in a left column, the infected on the right ---------- */
@media (orientation: landscape) and (min-width: 640px) {
  .play-stage { --hero-focus-x: 0.68; --hero-focus-y: 0.5; }
  .play-stage__poster img { object-position: 62% 55%; }
  .play-stage__shade {
    background:
      linear-gradient(90deg, rgb(14 15 17 / 0.95) 0%, rgb(14 15 17 / 0.86) 26%, rgb(14 15 17 / 0.5) 44%, rgb(14 15 17 / 0) 64%),
      linear-gradient(0deg, rgb(14 15 17 / 0.8) 0%, rgb(14 15 17 / 0) 32%);
  }
  .play-stage__shade::before {
    background:
      repeating-linear-gradient(180deg, rgb(14 15 17 / 0.09) 0 1px, rgb(14 15 17 / 0) 1px 3px),
      radial-gradient(ellipse 120% 100% at 66% 50%, rgb(14 15 17 / 0) 50%, rgb(14 15 17 / 0.7) 100%);
  }
  .play-stage { padding-bottom: max(48px, env(safe-area-inset-bottom)); --stage-pad-bottom: max(48px, env(safe-area-inset-bottom)); }
  .play-stage__content > :not(dialog) { max-width: 560px; }
  .play-stage__feed { display: flex; }
}
/* Wide desktop with height to spare: the rules get their one-line bodies. */
@media (orientation: landscape) and (min-width: 1200px) and (min-height: 840px) {
  .play-stage__content > .play-rules { max-width: 640px; }
  .play-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 0; padding-top: 16px; }
  .play-rules__item, .play-rules__item:nth-child(odd) { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 0 20px 0 0; border-left: 0; }
  .play-rules__item:nth-child(even) { padding: 0 0 0 20px; border-left: 1px solid var(--grey-mid); }
  .play-rules__body {
    position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; white-space: normal;
    grid-column: 2; font-size: 0.95rem; line-height: 1.3; color: var(--bone-dim);
  }
}
/* Short landscape (phones on their side, small laptop windows): the essentials only. */
@media (orientation: landscape) and (max-height: 620px) {
  .play-stage { padding-top: calc(var(--header-h) + 4px); --stage-pad-bottom: max(18px, env(safe-area-inset-bottom)); padding-bottom: var(--stage-pad-bottom); }
  .play-stage__gantry, .play-rules, .play-stage__note, .play-stage__pledge, .play-stage__feed { display: none; }
  .play-stage__title { font-size: clamp(2rem, 11svh, 3.6rem); margin-bottom: 0.22em; }
  .play-stage__lead { font-size: 1rem; margin-bottom: 14px; }
  .play-stage__launch .button { min-height: 52px; }
  .play-stage__go { font-size: 1.2rem; }
  .play-stage__controls { margin-bottom: 0; }
}
@media (orientation: landscape) and (max-height: 440px) {
  .play-stage__lead { display: none; }
}

/* No-build state on a phone: the form may scroll, and the stage grows with it. */
.play-stage--pending .play-stage__lead { margin-bottom: 8px; }
@media (orientation: portrait) and (max-height: 680px) {
  .play-stage--pending .play-stage__lead { display: block; }
}

@media (forced-colors: active) {
  .play-stage__content::before { background: CanvasText; }
  .page-play .site-header::before { display: none; }
}
