/* ==========================================================================
   play.css — the only styles that belong to /play and to nothing else.

   Rule for this file: every value is a token from brand.css. No new colour,
   no new font, no new radius, no new shadow is invented here. If /play needs
   something the site does not already have a token for, that is a signal the
   thing does not belong on this site.
   ========================================================================== */

/* ------------------------------------------------------------------ gate */

.play-gate {
  display: grid;
  gap: var(--sp-6);
  align-items: start;
}

@media (min-width: 62rem) {
  .play-gate { grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: var(--sp-8); }
}

/* The label chip is centred on the frame's top edge, so a frame that opens a
   section needs headroom or the chip collides with whatever sits above it. */
.play-gate > .rag-frame { margin-top: var(--sp-2); }

/* The site's masthead wraps onto two rows between 901px and 1240px, because
   below 1240 the six nav items plus the 372px account corner stop fitting on
   one line. /play's nav has a seventh item, so the same collision happens
   ~112px higher up. Same declarations as brand.css uses at its own
   breakpoint — only the window moves. Above this the masthead is one row,
   exactly as on every other page. */
@media (width >= 901px) and (width <= 1360px) {
  .rag-masthead__in { flex-wrap: wrap; row-gap: var(--sp-2); padding-block: var(--sp-2); }
  .rag-account { margin-inline-start: auto; }
}

/* The masthead account corner carries both faces. .rag-account is a 1×1 grid
   and every .rag-account__row is placed at 1/1, which is how the SPA
   cross-fades them — so without this they stack on top of each other. */
.rag-account[data-state="signed-out"] .rag-account__row[data-when="signed-in"],
.rag-account[data-state="signed-in"]  .rag-account__row[data-when="signed-out"] { display: none; }

/* One frame, two states. Both are in the DOM so the swap after sign-in does
   not reflow the page out from under the player's cursor. */
#gate-frame[data-state="signed-out"] .play-when-in,
#gate-frame[data-state="signed-in"] .play-when-out { display: none; }

.play-when-out,
.play-when-in { display: grid; gap: var(--sp-6); }

.play-labelrow {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
}

.play-labelrow a {
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--parch-400);
  background: none;
}

.play-labelrow a:hover { color: var(--gold-100); }

.play-foot {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
  color: var(--ink-mute);
  text-align: center;
}

/* A button that has to read as a link. brand.css styles every <button> that
   is not opted out with .rag-bare, so the opt-out is the site's own hook —
   and then this borrows the gilt underline brand.css gives inline links. */
.play-linkbtn {
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  color: var(--gold-200);
  background-image: var(--gilt-rule);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: color var(--dur-fast) var(--ease-out), background-size var(--dur-base) var(--ease-out);
}

.play-linkbtn:hover { color: var(--gold-000); background-size: 100% 2px; text-shadow: var(--glow-gold-xs); }

.play-prose {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
  color: var(--ink-dim);
}

.play-prose + .play-prose { margin-top: var(--sp-4); }
.play-prose strong { color: var(--gold-200); font-weight: var(--fw-regular); }

/* ---------------------------------------------------------------- alerts */

/* One alert component, three tones, all borrowed from --state-*. It is a
   frame-inset, not a coloured slab, because nothing on this site is a
   coloured slab. */
.play-alert {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border: var(--frame-hair) solid var(--rule-soft);
  border-left-width: var(--frame);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  box-shadow: var(--inset-well);
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  letter-spacing: var(--ls-wide);
  color: var(--ink-dim);
  text-align: left; /* it is a diagnostic, not a title — even inside the centred loader */
}

.play-alert[hidden] { display: none; }
.play-alert__mark { flex: none; margin-top: 1px; line-height: 1; font-size: var(--fs-sm); }
.play-alert__body b {
  display: block;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.play-alert[data-tone="danger"] { border-left-color: var(--state-danger); }
.play-alert[data-tone="danger"] .play-alert__mark,
.play-alert[data-tone="danger"] .play-alert__body b { color: var(--state-danger); }

.play-alert[data-tone="warn"] { border-left-color: var(--state-warn); }
.play-alert[data-tone="warn"] .play-alert__mark,
.play-alert[data-tone="warn"] .play-alert__body b { color: var(--state-warn); }

.play-alert[data-tone="info"] { border-left-color: var(--gold-500); }
.play-alert[data-tone="info"] .play-alert__mark,
.play-alert[data-tone="info"] .play-alert__body b { color: var(--gold-200); }

/* ------------------------------------------------------------- checklist */

.play-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }

.play-check {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  column-gap: var(--sp-3);
  align-items: start;
  padding: var(--sp-3) 0;
  border-bottom: var(--frame-hair) solid #f0c8981a;
}

.play-check:last-child { border-bottom: 0; }
.play-check__dot { margin-top: 6px; }

.play-check__name {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--gold-300);
}

.play-check__val {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  color: var(--ink-mute);
  margin-top: 2px;
}

.play-check[data-state="ok"]   .play-check__val { color: var(--ink-dim); }
.play-check[data-state="warn"] .play-check__val { color: var(--state-warn); }
.play-check[data-state="fail"] .play-check__val { color: var(--state-danger); }

/* --------------------------------------------------------------- signet */

/* Signed-in card. Same anatomy as the masthead signet so the two read as one
   idea rather than two components that happen to show a username. */
.play-signet {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border: var(--frame-hair) solid var(--rule-soft);
  border-radius: var(--r-sm);
  background: linear-gradient(180deg, #f0c89812, #00000038), var(--tex-stone);
  box-shadow: var(--inset-relief);
}

.play-signet__seal { color: var(--gold-100); filter: drop-shadow(0 0 8px #f0c89859); flex: none; }
.play-signet__id { display: flex; flex-direction: column; min-width: 0; line-height: 1; }

.play-signet__kicker {
  font-family: var(--font-ui);
  font-size: var(--fs-3xs);
  font-weight: var(--fw-semibold);
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--parch-500);
}

.play-signet__name {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--gold-100);
  text-shadow: var(--glow-gold-xs);
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- stage */

/* The stage is a full-viewport takeover, not a section in the page flow: the
   game gets the whole window and the site chrome steps out of the way. */
.play-stage {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal, 80);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background:
    radial-gradient(90% 60% at 50% 0%, #7a0d0d3d 0%, transparent 66%),
    var(--ox-950);
}

.play-stage[hidden] { display: none; }

/* brand.css styles every non-.rag-bare <button> through a selector carrying
   seven :not()s — specificity 0,7,1 — and gives it display:inline-flex. That
   beats the UA's [hidden]{display:none} and anything reasonable written here,
   so [hidden] inside the stage is asserted. It is a contract, not a
   preference: a retry button visible during a healthy load, or a stale error
   box under a moving meter, is exactly the kind of small lie this page is
   supposed to not tell. */
.play-stage [hidden] { display: none !important; }

.play-stage__bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--gutter);
  min-height: 46px;
  border-bottom: var(--frame-hair) solid #f0c89829;
  background: linear-gradient(180deg, rgba(58, 10, 13, .94) 0%, rgba(13, 3, 2, .98) 100%), var(--tex-stone);
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--ink-faint);
}

.play-stage__bar .rag-mark__img { width: 62px; height: 34px; }
.play-stage__spacer { flex: 1 1 auto; }

.play-stage__quit {
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--parch-400);
  padding: var(--sp-2) 0;
}

.play-stage__quit:hover { color: var(--gold-050); }

.play-stage__field {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--ox-950);
}

/* ── THE MOUNT POINT ──────────────────────────────────────────────────────
   Lane 3's client owns everything inside #ro-canvas-mount. The shell sizes
   it and never draws in it. See INTEGRATION.md. */
#ro-canvas-mount {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

#ro-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated; /* RO sprites are pixel art; smoothing ruins them */
  background: #000;
}

.play-stage:not([data-phase="playing"]) #ro-canvas { visibility: hidden; }

/* --------------------------------------------------------------- loader */

.play-loader {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--sp-6);
  padding: var(--gutter);
  overflow-y: auto;
  text-align: center;
}

.play-stage[data-phase="playing"] .play-loader { display: none; }

.play-loader__inner { width: 100%; max-width: 640px; display: grid; gap: var(--sp-6); }

.play-loader__crest { color: var(--gold-100); opacity: .9; justify-self: center; filter: drop-shadow(0 0 18px #f0c89840); }

.play-loader__title {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-black);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  line-height: var(--lh-tight);
  background: var(--gilt);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px #f0c89852);
}

.play-loader__sub {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: var(--sp-2);
}

/* ---------------------------------------------------------------- meter */

/* An honest meter. It has exactly two appearances:
     data-mode="measured"  — the fill is bytes-loaded / bytes-total, full stop.
     data-mode="unmeasured" — a STATIC hatched track. It does not creep, crawl
       or animate, because a bar that moves without data is a lie about
       progress. The readout underneath says what is actually known instead. */
.play-meter {
  height: 10px;
  border: var(--frame-hair) solid var(--rule-soft);
  border-radius: var(--r-pill);
  background: var(--bg-inset);
  box-shadow: var(--inset-well);
  overflow: hidden;
}

.play-meter > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gilt);
  box-shadow: var(--glow-gold-sm);
  transition: width var(--dur-base) var(--ease-out);
}

.play-meter[data-mode="unmeasured"] > i {
  width: 100%;
  background: repeating-linear-gradient(
    108deg,
    #f0c89826 0 6px,
    transparent 6px 14px
  );
  box-shadow: none;
  transition: none;
}

/* Nothing left to measure. */
.play-stage[data-phase="failed"] .play-meterblock { display: none; }

.play-readout {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: var(--sp-2);
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--ink-faint);
}

.play-readout b {
  font-weight: var(--fw-semibold);
  color: var(--gold-200);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- phases */

.play-phases { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; text-align: left; }

.play-phase {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  column-gap: var(--sp-3);
  align-items: baseline;
  padding: var(--sp-3) 0;
  border-bottom: var(--frame-hair) solid #f0c8981a;
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
}

.play-phase:last-child { border-bottom: 0; }
.play-phase__dot { justify-self: center; }
.play-phase__name { text-transform: uppercase; color: var(--parch-500); }
.play-phase__detail {
  grid-column: 2 / -1;
  margin-top: 3px;
  font-size: var(--fs-2xs);
  letter-spacing: var(--ls-normal);
  text-transform: none;
  color: var(--ink-faint);
}
.play-phase__val { color: var(--gold-300); font-variant-numeric: tabular-nums; text-align: right; }

.play-phase[data-state="active"] .play-phase__name { color: var(--gold-100); }
.play-phase[data-state="done"]   .play-phase__name { color: var(--parch-400); }
.play-phase[data-state="done"]   .play-phase__val  { color: var(--state-online); }
.play-phase[data-state="failed"] .play-phase__name { color: var(--state-danger); }
.play-phase[data-state="failed"] .play-phase__val  { color: var(--state-danger); }
.play-phase[data-state="stalled"] .play-phase__name { color: var(--state-warn); }
.play-phase[data-state="pending"] { opacity: .5; }

/* ---------------------------------------------------------------- 390px */

/* The site's own chrome already reflows at this width — the masthead wraps
   and the nav centres — so the only things that need saying here are the
   ones /play adds. */
@media (max-width: 46rem) {
  .play-stage__bar { min-height: 42px; gap: var(--sp-3); }
  .play-stage__bar .play-stage__meta { display: none; }
  .play-loader { gap: var(--sp-5); align-content: start; padding-top: var(--sp-8); }
  .play-loader__title { font-size: var(--fs-lg); }
  .play-phase { grid-template-columns: 14px minmax(0, 1fr); }
  .play-phase__val { grid-column: 2; text-align: left; margin-top: 3px; color: var(--gold-300); }
  .play-signet { gap: var(--sp-3); padding: var(--sp-3); }
  .play-readout { flex-direction: column; gap: var(--sp-1); }
}

@media (prefers-reduced-motion: reduce) {
  .play-meter > i { transition: none; }
}
