/* =====================================================================
   Stage: the 3D studio canvas (scene3d.js) and the HTML screens laid onto
   it (atril displays, the emblem). Shared by the game (index.html) and the
   «Muy pronto» page (muy-pronto.html); loaded after components.css.
   ===================================================================== */

/* --- Studio canvas ------------------------------------------------- */
body > #scene3dContainer {
  position: fixed; inset: 0; z-index: var(--z-stage); pointer-events: none;
  background: radial-gradient(ellipse at 50% 38%, #0f2036, var(--ink-0) 72%);
}
#scene3dContainer > canvas { position: relative; z-index: 1; display: block; width: 100%; height: 100%; }
/* Screens (atriles, emblem) sit under the canvas and show through its holes. */
#scene3dContainer .stage-screens { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
/* Lighting cue on top of the render: the house lights dim while a
   question is on air so the eye goes to the question. */
body > #scene3dContainer::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse 70% 62% at 50% 46%, transparent 40%, rgb(2 3 7 / .85) 100%);
  opacity: .35; transition: opacity var(--dur-stage) var(--ease-in-out);
}
body[data-stage="question"] > #scene3dContainer::after { opacity: .62; }
body[data-stage="final"] > #scene3dContainer::after { opacity: .78; }
body[data-stage="reveal"] > #scene3dContainer::after { opacity: .4; }
body[data-stage="finished"] > #scene3dContainer::after { opacity: .5; }

/* --- Stage screens: HTML laid onto the 3D set (scene3d.js) --------------
   Laid out at a fixed size and mapped onto the 3D quad with matrix3d, so
   HTML defines layout; text and icons are rasterized before projection. */
.pd, .emblem-face { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.pd {
  --tone: var(--pc, var(--signal));
  display: grid; align-content: center; justify-items: center; gap: 2px;
  padding: 10px 18px 12px; overflow: hidden;
  border-radius: 16px;
  border: 4px solid var(--tone);
  background:
    radial-gradient(circle, color-mix(in srgb, var(--tone) 34%, transparent) 1.6px, transparent 2.2px) 0 100% / 11px 11px repeat-x,
    linear-gradient(180deg, #121c30 0%, #070b14 62%, color-mix(in srgb, var(--tone) 14%, #05080f) 100%);
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / .55), inset 0 0 26px color-mix(in srgb, var(--tone) 30%, transparent);
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; line-height: 1;
  color: var(--text-1); text-align: center; white-space: nowrap;
}
.pd-top, .pd-bottom { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; max-width: 100%; min-width: 0; }
.pd-ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; visibility: visible; }
.pd [data-ink-ready="true"] > :not(.pd-ink) { visibility: hidden; }
.pd i { flex-shrink: 0; }
.pd-text {
  overflow: hidden; text-overflow: ellipsis;
  /* Keep ellipsis horizontally, with room for font ink above/below the line.
     Firefox can clip that ink when the display has a perspective transform. */
  padding-block: .16em; margin-block: -.16em;
}
.pd-top { font-size: 58px; letter-spacing: .02em; text-shadow: 0 0 18px color-mix(in srgb, var(--tone) 45%, transparent); }
.pd-bottom { font-size: 36px; letter-spacing: .05em; color: var(--tone); }
.pd-top i { color: var(--spot); font-size: .78em; }
.pd-bottom i { font-size: .9em; }
.pd[data-tone="player"] .pd-bottom { color: color-mix(in srgb, var(--pc) 70%, #fff); }
.pd.is-event .pd-top { color: var(--tone); }
.pd.is-event .pd-bottom { color: var(--text-1); }
.pd[data-tone="muted"] { --tone: var(--text-3); }
@media (prefers-reduced-motion: no-preference) {
  body:not(.reduce-motion) .pd.is-pulse .pd-bottom { animation: pdPulse 1.4s ease-in-out infinite; }
  body:not(.reduce-motion) .pd.is-flash { animation: pdFlash .5s var(--ease-out); }
}
@keyframes pdPulse { 50% { opacity: .55; } }
@keyframes pdFlash { from { filter: brightness(1.8); } to { filter: none; } }

.emblem-face {
  --cat: var(--signal);
  display: grid; place-content: center; justify-items: center; gap: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #16264a 0%, #0a1222 55%, #04070d 100%);
  box-shadow: inset 0 0 0 10px rgb(160 182 224 / .06), inset 0 0 0 90px rgb(0 0 0 / .18);
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; line-height: 1.2; text-align: center;
  color: var(--text-1);
}
/* Rasterize only the emblem's ink. Source HTML still defines the layout;
   Firefox projects one bitmap instead of individual font glyphs. */
.emblem-face > :not(.emblem-ink) { visibility: hidden; }
#stageScreens .emblem-ink { position: absolute; inset: 0; width: 100%; height: 100%; }
.ef-brain { font-size: 230px; color: var(--signal); text-shadow: 0 0 34px rgb(57 207 238 / .65); margin: -10px 0 6px; }
.ef-mascot { display: block; width: 270px; height: 270px; object-fit: contain; margin: -10px 0 6px; }
.emblem-face[data-kind="brand"] .ef-mascot { width: 420px; height: 420px; margin: 0; }
.emblem-face[data-kind="question"] .ef-mascot { width: 220px; height: 220px; }
.ef-title { font-size: 92px; letter-spacing: .08em; color: var(--text-1); }
.ef-sub { font-size: 54px; letter-spacing: .22em; color: var(--spot); }
.ef-kicker { max-width: 82%; font-size: clamp(20px, 3vw, 40px); letter-spacing: clamp(.02em, .14vw, .1em); line-height: 1.08; text-wrap: balance; color: var(--text-2); }
.ef-cat { display: inline-flex; align-items: center; gap: 12px; color: var(--cat); }
.ef-line { font-size: 46px; letter-spacing: .1em; color: var(--text-3); }
.emblem-face[data-kind="room"] .ef-line { max-width: 72%; line-height: 1.05; color: var(--text-1); }
.ef-code { white-space: nowrap; font-size: 150px; letter-spacing: .04em; color: var(--spot); text-shadow: 0 0 30px rgb(246 183 82 / .5); margin: 10px 0; }
.ef-code small { font-size: .45em; color: var(--text-3); } /* "3/5" */
.ef-crown { font-size: 200px; color: var(--spot); text-shadow: 0 0 40px rgb(246 183 82 / .6); }
.emblem-face[data-kind="question"] .ef-brain { font-size: 190px; }


/* --- The screen powering on (presentation only) -------------------------
   scene3d.js sets data-power, --power (0…1.3) and --reveal (0…1) while the
   «Muy pronto» page switches the screen on; a match never does. The light
   opens from the centre with a soft cyan edge, then settles. */
.emblem-face[data-power] { filter: brightness(var(--power, 1)); }
.emblem-face[data-power]::after {
  content: ""; position: absolute; inset: -1%; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, transparent calc(var(--reveal, 1) * 80%), rgb(57 207 238 / .55) calc(var(--reveal, 1) * 80% + 3%), transparent calc(var(--reveal, 1) * 80% + 9%)),
    radial-gradient(circle at 50% 50%, transparent calc(var(--reveal, 1) * 80%), #000 calc(var(--reveal, 1) * 80% + 16%));
}

/* --- The emblem speaks (stage/on-air.js) ---------------------------------
   headline: one event in one or two lines; tally: the pot; board: the
   standings. Ink only (rasterized): colour and glow carry it, no boxes. */
.emblem-face[data-kind="headline"], .emblem-face[data-kind="tally"], .emblem-face[data-kind="board"] { gap: 10px; }
.ef-headline {
  display: grid; justify-items: center; width: max-content;
  font-size: 132px; line-height: .9; letter-spacing: .01em; font-weight: 800;
  color: var(--tone); text-shadow: 0 0 34px color-mix(in srgb, var(--tone) 60%, transparent);
}
.ef-headline.is-player { color: var(--pc); text-shadow: 0 0 34px color-mix(in srgb, var(--pc) 60%, transparent); }
.ef-headline-line { max-width: 74%; line-height: 1.05; color: var(--text-1); letter-spacing: .06em; }
.ef-icon { font-size: 96px; color: var(--tone); text-shadow: 0 0 30px color-mix(in srgb, var(--tone) 55%, transparent); margin-bottom: -6px; }
.emblem-face[data-kind] .ef-kicker { color: var(--text-2); }
.ef-tally { display: flex; gap: 56px; align-items: start; }
.ef-tally-item { display: grid; justify-items: center; gap: 4px; color: var(--it); }
.ef-tally-value { display: inline-flex; align-items: center; gap: 10px; font-size: 140px; line-height: .9; text-shadow: 0 0 30px color-mix(in srgb, var(--it) 55%, transparent); }
.ef-tally-value i { font-size: .5em; }
.ef-tally-label { font-size: 34px; letter-spacing: .08em; color: var(--text-2); }
/* One grid for every row: places, names and points line up in columns. */
.ef-board {
  display: grid; grid-template-columns: auto auto auto; gap: 12px 26px; align-items: baseline;
  width: max-content; font-size: 62px; line-height: 1;
}
.ef-board-row { display: contents; color: var(--text-2); }
.ef-board-rank { color: var(--text-3); text-align: right; }
.ef-board-name { color: var(--rc); text-align: left; }
.ef-board-value { color: var(--text-1); text-align: right; }
.ef-board-row:first-child { font-size: 1.22em; }
.ef-board-row:first-child .ef-board-rank { color: var(--spot); }
.emblem-face[data-layout="low"] { place-content: end center; padding-bottom: 74px; gap: 2px; }
.emblem-face[data-layout="low"] .ef-headline { font-size: 96px; }
.emblem-face[data-layout="low"] .ef-headline-line { font-size: 38px; color: var(--text-2); }
