/* Cafe Bardo — the ledger of arrivals.
   Indigo and gold, taken from the artwork's own style notes. One gold rule
   carries the whole page: threshold while answering, sweep while generating,
   frame edge at the reveal. Everything else stays quiet. */

:root {
  --ink:      #0B0A12;
  --ink-2:    #14121F;
  --veil:     #241F35;
  --gold:     #D4A84B;
  --gold-dim: #8A7434;
  --bone:     #EDE6D6;
  --bone-dim: #9A927F;

  --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 {
  min-height: 100svh;
  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(212, 168, 75, 0.13), transparent 58%),
    radial-gradient(100% 70% at 12% 96%, rgba(56, 44, 96, 0.5), 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 gold 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(--gold-dim), var(--gold));
  box-shadow: 0 0 14px rgba(212, 168, 75, 0.55);
  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%); }
}

/* ── ledger head ─────────────────────────────────────────────────────────── */

.ledger {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px var(--gutter) 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--bone-dim);
  flex: none;
}
.ledger__station { color: var(--gold); }
.ledger__count { font-variant-numeric: tabular-nums; }

/* ── 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;
}

.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(--gold-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(--gold); }

.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(--gold-dim); }
.opt:active { transform: scale(0.988); }
.opt[aria-pressed="true"] {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(212, 168, 75, 0.14), rgba(212, 168, 75, 0.05));
  color: #FFF3D6;
}

/* 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(11, 10, 18, 0.93));
}

/* ── 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: #5A5470; }
.field:focus { outline: none; border-bottom-color: var(--gold); }
.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;
}

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

.scale { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 12px; }
.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(--gold); border-color: var(--gold); }
.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);
}
.scale__reading {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--gold);
  margin-top: 14px;
  min-height: 1.3em;
}

/* ── 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(--gold);
  background: var(--gold);
  color: #16110A;
  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(--gold-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(--gold);
  margin: 0 0 10px;
}
.working__note {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-dim);
}

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

.plate {
  border-top: var(--rule-h) solid var(--gold);
  background: var(--ink-2);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.62);
  animation: develop 1100ms var(--ease) both;
}
.plate img { width: 100%; display: block; }
@keyframes develop {
  from { opacity: 0; filter: blur(14px) saturate(0.4); transform: translateY(10px); }
  to   { opacity: 1; filter: none; transform: none; }
}
.caption {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

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

:focus-visible {
  outline: 2px solid var(--gold);
  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;
  }
}
