/* Live read ownership: the inline held-reveal state after the first room lands. */

/* ===========================================================================
   LIVING READ STATE — the inline "read in progress" state (#stage-reading)
   The live codex walk (and the brief cached/demo wait) is a DARK ROOM (brand law:
   loading runs on --screen/#101412), not a paper card. The base geometry of
   #stage-reading / .stage-reading-card / .stage-reading-steps lives in
   read-shell.css. read-loading-
   shell.js adds body.reading-room-live and renders one held-reveal object into
   #stage-reading-steps (the engine hook). Everything below RE-TONES that card
   into the dark room; the body-scoped selectors intentionally refine the base read-shell state. Depth = hard
   ink offset, never blur; gold (lamp --gold-soft) is legal here — this is a dark
   room. Every animation below is guarded by prefers-reduced-motion.
   =========================================================================== */

body.reading-room-live .stage-reading-card {
  background: var(--screen);
  border: 2px solid var(--screen);
  box-shadow: var(--offset);
  color: var(--on-screen);
  grid-template-columns: minmax(0, 1fr);
  position: relative;
}

/* Low grain so the dark room has texture, not a flat black box. */
body.reading-room-live .stage-reading-card::before {
  background-image: var(--grain);
  content: "";
  inset: 0;
  opacity: 0.05;
  pointer-events: none;
  position: absolute;
}

/* Keep the room's content above the grain. */
body.reading-room-live .stage-reading-card > * { position: relative; z-index: 1; }

body.reading-room-live .stage-reading-kicker { color: var(--gold-soft); }
body.reading-room-live .stage-reading-line { color: var(--on-screen); }
body.reading-room-live .stage-reading-copy { color: var(--screen-dim); }
body.reading-room-live .stage-reading-meta { color: var(--screen-dim); }
body.reading-room-live .stage-reading-dot { background: var(--gold-soft); }

/* The headline dot pulses (the lamp). Guarded below for reduced motion. */
body.reading-room-live .stage-reading-dot {
  animation: room-pulse 1.4s ease-in-out infinite;
}

/* The live-progress bar was removed (it tracked nothing real and aligned with
   nothing) — see read-loading-shell.js ensureRoomChrome. The elapsed timer + the
   active room's scan beam are the only "still working" signals now. */

/* ---------- The held reveal (#stage-reading-steps) ----------
   The engine may know which room is active, but the wait surface does not. This
   remains one calm object until the finished read is ready to unlock. */
body.reading-room-live .stage-reading-steps {
  border-left: 0;
  border-top: 1px solid var(--screen-hairline);
}

body.reading-room-live .stage-reading-steps li.room-row {
  align-items: center;
  border-top: 1px solid var(--screen-hairline);
  display: grid;
  gap: 0 12px;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 11px 4px;
  position: relative;
}

body.reading-room-live .stage-reading-steps li.room-row:first-child { border-top: 0; }

body.reading-room-live .room-num {
  color: var(--screen-dim);
  font-family: var(--brand);
  font-size: var(--fs-slug);
  font-weight: var(--fw-bold);
}

body.reading-room-live .room-name {
  color: var(--on-screen);
  font-family: var(--brand);
  font-size: var(--fs-slug);
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body.reading-room-live .room-status {
  color: var(--screen-dim);
  font-family: var(--brand);
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-align: right;
  text-transform: uppercase;
}

/* The verdict/marker cell sits before the status. */
body.reading-room-live .room-tick {
  background: var(--screen-hairline);
  border-radius: 50%;
  display: inline-block;
  grid-column: 3;
  height: 7px;
  justify-self: end;
  width: 7px;
}

/* Waiting rooms read quiet. */
body.reading-room-live .room-row.is-waiting .room-name { color: var(--screen-dim); }

/* ---------- The CURRENT reader: the lamp lit + the scan beam ----------
   The active room glows lamp-gold and a beam sweeps across faint ruled "script
   page" lines behind it, so the reader is visibly WORKING mid-page. */
body.reading-room-live .room-row.is-reading {
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 6px,
      rgba(240, 237, 226, 0.05) 6px,
      rgba(240, 237, 226, 0.05) 7px
    );
}

body.reading-room-live .room-row.is-reading .room-num,
body.reading-room-live .room-row.is-reading .room-name,
body.reading-room-live .room-row.is-reading .room-status { color: var(--gold-soft); }

/* The scanning beam: a lamp-gold sweep crossing the ACTIVE reader's row left->right.
   Ungated from the lit state so the active reader keeps this ambient movement through
   the whole DIM read (only .is-reading — the one active bucket, never the idle rows). */
.room-row.is-reading::after {
  background: linear-gradient(
    90deg,
    transparent 0,
    rgba(201, 168, 106, 0.28) 50%,
    transparent 100%
  );
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  transform: translateX(-100%);
  animation: room-scan 2.6s linear infinite;
}

/* A room that failed keeps its status legible in the room red. */
.stage-reading-steps .room-row.is-failed .room-status { color: var(--red-on-screen); }

.stage-reading-steps .room-row.is-waiting .room-tick {
  animation: reveal-signal 2.8s ease-in-out infinite;
}

@keyframes room-scan { to { transform: translateX(100%); } }
@keyframes reveal-signal {
  0%, 74%, 100% { box-shadow: none; opacity: 0.72; }
  36% { box-shadow: 0 0 14px rgba(201, 168, 106, 0.58); opacity: 1; }
}

/* Reduced motion: kill every sweep/pulse + the one-shot check settle; the active
   lamp-gold dot, the active row, and the settled check all stay legible static. */
@media (prefers-reduced-motion: reduce) {
  body.reading-room-live .stage-reading-dot,
  .room-row.is-reading::after,
  .stage-reading-steps .room-row.is-waiting .room-tick {
    animation: none;
  }
}
