/* Café Bardo — the ledger of arrivals.
   Palette taken from the booth's own artwork and the paper-cutout reference:
   a near-black ground shifted green, luminous celadon for the frame's light,
   ember red for the glow behind it. A single ember rule carries the
   whole page: threshold while answering, sweep while generating, frame edge at
   the reveal. Everything else stays quiet. */

:root {
  --ink:         #0A0F0D;
  --ink-2:       #121A17;
  --veil:        #22302B;
  --celadon:     #BFDCC9;
  --celadon-dim: #6E8A7B;
  --ember:       #D6402F;
  --ember-dim:   #7E2A20;
  --bone:        #DCE7E0;
  --bone-dim:    #7E8F87;

  --serif: "Newsreader", "Iowan Old Style", Palatino, Georgia, serif;
  --mono:  "Space Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(20px, 6vw, 34px);
  --rule-h: 2px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  /* --viewport-h is set from visualViewport when the keyboard opens, for
     browsers that ignore interactive-widget (iOS Safari). 100svh otherwise. */
  min-height: var(--viewport-h, 100svh);
  max-height: var(--viewport-h, none);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* The room: a slow indigo breath with a lamp somewhere off to one side. */
.room {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 78% 8%, rgba(214, 64, 47, 0.14), transparent 58%),
    radial-gradient(100% 70% at 12% 96%, rgba(34, 62, 52, 0.55), transparent 62%),
    var(--ink);
  animation: breathe 19s var(--ease) infinite alternate;
}
.room::after {           /* grain, so the dark is a material and not a void */
  content: "";
  position: absolute;
  inset: -50%;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)'/></svg>");
}
@keyframes breathe {
  from { transform: scale(1)    translate3d(0, 0, 0); }
  to   { transform: scale(1.06) translate3d(-1.5%, 1%, 0); }
}

/* ── the ember rule, in its first state ──────────────────────────────────── */

.threshold {
  position: relative;
  z-index: 2;
  height: var(--rule-h);
  background: var(--veil);
  flex: none;
}
.threshold__fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--ember-dim), var(--ember));
  box-shadow: 0 0 14px rgba(214, 64, 47, 0.6);
  transition: width 620ms var(--ease);
}
body[data-phase="working"] .threshold__fill {
  width: 100%;
  animation: sweep 1.9s var(--ease) infinite;
}
@keyframes sweep {
  0%   { opacity: 0.25; transform: translateX(-100%); }
  50%  { opacity: 1; }
  100% { opacity: 0.25; transform: translateX(100%); }
}

/* ── stage ───────────────────────────────────────────────────────────────── */

.stage {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px var(--gutter) 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  /* When the keyboard has taken most of the screen there may not be room to
     centre anything. Scroll the question rather than push the button off. */
  overflow-y: auto;
  min-height: 0;
}

.panel { display: none; }
.panel.is-active { display: block; animation: rise 560ms var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--celadon-dim);
  margin: 0 0 14px;
}

.ask {
  font-size: clamp(30px, 8.5vw, 46px);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
  text-wrap: balance;
}
.ask em { font-style: italic; color: var(--celadon); }

.hint {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--bone-dim);
  margin: 0 0 26px;
  min-height: 1em;
}

/* ── options ─────────────────────────────────────────────────────────────── */

.options { display: grid; gap: 10px; margin: 0 0 8px; padding: 0; list-style: none; }
.options--images { grid-template-columns: repeat(2, 1fr); gap: 12px; }

.opt {
  appearance: none;
  width: 100%;
  display: block;
  text-align: left;
  cursor: pointer;
  color: var(--bone);
  background: var(--ink-2);
  border: 1px solid var(--veil);
  border-radius: 3px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 300;
  padding: 15px 17px;
  transition: border-color 200ms var(--ease), background 200ms var(--ease),
              transform 140ms var(--ease);
}
.opt:hover { border-color: var(--celadon-dim); }
.opt:active { transform: scale(0.988); }
.opt[aria-pressed="true"] {
  border-color: var(--celadon);
  background: linear-gradient(180deg, rgba(191, 220, 201, 0.16), rgba(191, 220, 201, 0.05));
  color: #EFFAF2;
}

/* Image options: the picture is the control, the label sits on it. */
.opt--image { padding: 0; overflow: hidden; position: relative; aspect-ratio: 1; }
.opt--image img { width: 100%; height: 100%; object-fit: cover; display: block;
                  opacity: 0.72; transition: opacity 240ms var(--ease); }
.opt--image[aria-pressed="true"] img { opacity: 1; }
.opt--image .opt__label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 22px 12px 11px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  background: linear-gradient(transparent, rgba(10, 15, 13, 0.94));
}

/* ── free text ───────────────────────────────────────────────────────────── */

.field {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--veil);
  color: var(--bone);
  font-family: var(--serif);
  font-size: clamp(21px, 5.5vw, 26px);
  font-weight: 300;
  padding: 10px 2px;
  transition: border-color 220ms var(--ease);
}
.field::placeholder { color: #4C5A53; }
.field:focus { outline: none; border-bottom-color: var(--celadon); }
.counter {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--bone-dim);
  text-align: right;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* ── birth moment: five fields, thumb-sized ──────────────────────────────── */

.moment {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px 12px;
  margin-bottom: 6px;
}
.moment__time { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.moment label { display: block; }
.moment span {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-bottom: 5px;
}
.moment input {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--veil);
  border-radius: 3px;
  color: var(--bone);
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 300;
  text-align: center;
  padding: 12px 6px;
  transition: border-color 200ms var(--ease);
  /* Number spinners are useless at this size and steal tap area. */
  -moz-appearance: textfield;
}
.moment input::-webkit-outer-spin-button,
.moment input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.moment input:focus { outline: none; border-color: var(--celadon); }
/* Keyed on aria-invalid, which booth.js sets only once the field has as many
   digits as its maximum — NOT on :invalid, which fires on the first keystroke
   because "1" is below 1900, reddening the box while 1990 is being typed. */
.moment input[aria-invalid="true"] { border-color: var(--ember); }

/* ── scale: seven weights, tapped not dragged ────────────────────────────── */

.scale { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 12px; }

/* Icon steps: equal-height cells, since the glyph carries the weight now and
   a rising row of boxes would say it twice. */
.scale--icons { align-items: stretch; gap: 4px; }
.scale__step--icon {
  aspect-ratio: 1;
  height: auto;
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--bone-dim);
}
.scale__step--icon svg {
  width: 100%;
  height: auto;
  max-width: 34px;
  fill: currentColor;
  /* The heavy glyphs are drawn as fills and the light ones as strokes, so both
     have to follow the colour. */
  stroke: none;
}
.scale__step--icon[aria-pressed="true"] {
  background: var(--ember);
  border-color: var(--ember);
  color: var(--ink);
}
@media (hover: hover) {
  .scale__step--icon:hover { color: var(--bone); border-color: var(--celadon-dim); }
  .scale__step--icon[aria-pressed="true"]:hover { color: var(--ink); }
}
.scale__step {
  appearance: none;
  flex: 1;
  cursor: pointer;
  background: var(--ink-2);
  border: 1px solid var(--veil);
  border-radius: 2px;
  padding: 0;
  transition: background 200ms var(--ease), border-color 200ms var(--ease);
}
.scale__step[aria-pressed="true"] { background: var(--ember); border-color: var(--ember); }
.scale__ends {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--bone-dim);
}

/* ── actions ─────────────────────────────────────────────────────────────── */

.actions {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px var(--gutter) max(22px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  flex: none;
}

.btn {
  appearance: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  padding: 15px 26px;
  border-radius: 2px;
  border: 1px solid var(--ember);
  background: var(--ember);
  color: #120805;
  transition: opacity 200ms var(--ease), transform 140ms var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn[disabled] { opacity: 0.28; cursor: default; }
.btn--ghost { background: transparent; color: var(--bone-dim); border-color: var(--veil); }
.btn--ghost:hover:not([disabled]) { color: var(--bone); border-color: var(--celadon-dim); }
.spacer { flex: 1; }

.notice {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  line-height: 1.6;
  color: #E0A0A0;
  margin: 14px 0 0;
  min-height: 1em;
}

/* ── working ─────────────────────────────────────────────────────────────── */

.working { text-align: left; }
.working__word {
  font-size: clamp(30px, 8.5vw, 46px);
  font-weight: 300;
  font-style: italic;
  color: var(--celadon);
  margin: 0 0 10px;
}

/* ── the reveal ──────────────────────────────────────────────────────────── */

.plate {
  border-top: var(--rule-h) solid var(--ember);
  background: var(--ink-2);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.62);
  animation: develop 1100ms var(--ease) both;
}
/* The published asset carries alpha — the frame's centre is a hole. A dark
   ground behind it shows the composite the way the wall will. */
.plate img { width: 100%; display: block; background: #050807; }
@keyframes develop {
  from { opacity: 0; filter: blur(14px) saturate(0.4); transform: translateY(10px); }
  to   { opacity: 1; filter: none; transform: none; }
}

/* The other two generations, filled in as they finish. Reserved from the
   start so the plate does not jump when they arrive. */
/* ── The reveal's own header ────────────────────────────────────────────────
 *
 * The visitor's name, under the installation's. It opens the panel the way the
 * act closes it — a small mono label over a serif line — so the two ends of the
 * result read as a pair rather than as two unrelated blocks.
 */
.reveal {
  text-align: center;
  margin: 0 0 18px;
}
.reveal__place {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--celadon-dim);
  margin: 0 0 6px;
}
.reveal__name {
  font-family: var(--serif);
  /* A name can be one letter or forty; clamped, and balanced when it wraps. */
  font-size: clamp(26px, 8vw, 40px);
  line-height: 1.1;
  font-weight: 500;
  color: var(--bone);
  margin: 0;
  text-wrap: balance;
}

/* ── The act ────────────────────────────────────────────────────────────────
 *
 * The last thing on the path, and the line a visitor reads out to whoever they
 * came with — so it is set like a closing line rather than like a field: a rule
 * above it for a beat of silence, a small mono label, then the name at display
 * size in the serif.
 *
 * The name is allowed to be LONG. "LE SSERAFIM" and "BABYMONSTER" are twice the
 * width of "eaJ" and a fixed size would either shrink the short ones to nothing
 * or push the long ones off a narrow phone, so it is clamped against the
 * viewport and balanced when it wraps.
 */
.act {
  margin: 26px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--veil);
  text-align: center;
}
.act__label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--celadon-dim);
  margin: 0 0 10px;
}
.act__name {
  font-family: var(--serif);
  font-size: clamp(30px, 11vw, 54px);
  line-height: 1.05;
  font-weight: 500;
  /* Full white, not the celadon everything else on this page is set in. The
     act is the end of the path and the only thing here allowed to be plain. */
  color: #fff;
  margin: 0;
  text-wrap: balance;
  /* It arrives after the images have settled, so it fades in rather than
     appearing — the reveal is a sequence, not a page load. */
  animation: act-in 900ms var(--ease) both;
}
.act__why {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.55;
  font-style: italic;
  color: var(--bone-dim);
  max-width: 34ch;
  margin: 10px auto 0;
  text-wrap: pretty;
  animation: act-in 900ms 160ms var(--ease) both;
}
/* The act's own colour, as one line of light.
 *
 * --act-accent is set from the record by booth.js; the fallback keeps the rule
 * visible for an act with no colour on file rather than drawing nothing.
 *
 * The bloom is three shadows rather than one: a tight bright core, a mid
 * spread, and a wide dim haze. One large blur reads as a grey smudge on a dark
 * ground — the layering is what makes it read as emission.
 */
.act__rule {
  --act-accent: var(--celadon);
  /* Doubled from 180px. At the short length it read as a bullet under the
     name; at this one it reads as a rule beneath a title, which is what the
     act deserves as the last thing on the path. */
  width: min(360px, 84%);
  height: 2px;
  margin: 18px auto 0;
  border-radius: 2px;
  background: var(--act-accent);
  box-shadow:
    0 0 4px var(--act-accent),
    0 0 12px var(--act-accent),
    0 0 28px color-mix(in srgb, var(--act-accent) 55%, transparent);
  /* Widens as it arrives, so the line reads as being drawn rather than as
     having been there all along. */
  animation: act-rule 700ms 120ms var(--ease) both;
}
@keyframes act-rule {
  from { opacity: 0; width: 0; }
  to   { opacity: 1; width: min(360px, 84%); }
}
@keyframes act-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .act__name, .act__why, .act__rule { animation: none; }
}

.companions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.companion {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--veil);
  border-radius: 3px;
  background: var(--ink-2);
  overflow: hidden;
}
.companion img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 700ms var(--ease);
}
.companion.is-ready img { opacity: 1; }
/* A slow pulse while a slot is still waiting, so an empty square reads as
   "coming" rather than "broken". */
.companion:not(.is-ready)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%,
              rgba(191, 220, 201, 0.06) 50%, transparent 70%);
  animation: shimmer 2.4s var(--ease) infinite;
}
.companion.is-failed::after { animation: none; opacity: 0; }
@keyframes shimmer {
  from { transform: translateX(-60%); }
  to   { transform: translateX(60%); }
}

/* ── the elemental balance ───────────────────────────────────────────────── */
/*
 * A SELF-CONTAINED colour system. The element colours are the elements stated
 * boldly; they are not part of the booth's celadon-and-ember palette and must
 * not be tinted by it. Nothing in this block reads a site token — the ink and
 * track values below are its own, so restyling the page cannot quietly restyle
 * the reading.
 *
 * The element colours themselves arrive inline from diviner/elements.py, where
 * they were validated; there are none in this file at all.
 */
.balance {
  --chart-ink:       #f2f5f3;   /* names + values: near-white, not --bone     */
  --chart-ink-dim:   #8c968f;   /* zero rows                                  */
  --chart-well:      #14100f;   /* the disc sits in its own dark well         */
  --chart-rule:      #2a312d;

  margin: 0 0 26px;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--chart-rule);
}
.balance__title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chart-ink);
  margin-bottom: 16px;
}

/* Disc and legend side by side; they stack on a narrow phone. */
.balance__body {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  align-items: center;
  gap: 22px;
}
@media (max-width: 420px) {
  .balance__body { grid-template-columns: 1fr; justify-items: center; gap: 16px; }
  .balance__rows { width: 100%; }
}

/* Square whatever is in it, so the layout does not jump when the elaborated
   disc arrives after the legend. */
.balance__disc { width: 100%; aspect-ratio: 1; }
.balance__disc svg,
.balance__disc .balance__image { display: block; width: 100%; height: auto; }
.balance__image { animation: rise 700ms var(--ease) both; }

/* The legend is also the table: every element, every exact value. */
.balance__rows { display: grid; gap: 9px; }
.balance__row {
  display: grid;
  grid-template-columns: 12px 1fr 2.8em;
  align-items: center;
  gap: 10px;
}
.balance__swatch { width: 12px; height: 12px; border-radius: 2px; }
/* Text wears text tokens, never the series colour — the swatch beside it
   carries identity. */
.balance__name {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--chart-ink);
}
.balance__value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--chart-ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.balance__row--zero .balance__name,
.balance__row--zero .balance__value { color: var(--chart-ink-dim); }
.balance__row--zero .balance__swatch { opacity: 0.3; }

/* ── quality floor ───────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--celadon);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
