/* VEIL — offline field instrument, gothic-cathedral skin.
   Matches the native iOS app: stone-black night, bone parchment, verdigris
   confirm, candle-gold marks, blood-crimson strike, violet Oracle voice.
   Cinzel display + EB Garamond body, both bundled (no network). All art is
   bundled WebP. Fully offline. */

@font-face { font-family:"Cinzel"; src:url("../fonts/Cinzel-normal-400.woff2") format("woff2"); font-weight:400 700; font-display:swap; }
@font-face { font-family:"EB Garamond"; src:url("../fonts/EBGaramond-normal-400.woff2") format("woff2"); font-style:normal; font-display:swap; }
@font-face { font-family:"EB Garamond"; src:url("../fonts/EBGaramond-italic-400.woff2") format("woff2"); font-style:italic; font-display:swap; }

:root {
  --void: #0c0a0d;          /* stone-black night */
  --room: #120e11;          /* deep stone */
  --panel: #1a1417;         /* dark stone (cards) */
  --raised: #241b1f;        /* lit stone */
  --line: #4a3b38;          /* stone edge */
  --rule: rgba(224,178,74,0.28);   /* gold hairline */
  --rule-faint: rgba(224,178,74,0.14);
  --bone: #e8dbc2;          /* parchment text */
  --dim: #a8927a;           /* aged parchment (plain line) */
  --faint: #7a6653;         /* fine print */
  --gold: #e0b24a;          /* candlelight marks */
  --gold-cap: #f0d493;      /* brighter gold over art */
  --gold-dim: #9c7a34;
  --teal: #5e9b84;          /* verdigris — primary / confirm */
  --teal-deep: #24443a;
  --rose: #b23a3a;          /* crimson — strike / destructive */
  --violet: #9270ae;        /* the Oracle / semantic tier */
  --rec: #b23a3a;
  --onset: #8a6da8; --peak: #e0b24a; --plateau: #9270ae; --comedown: #5e9b84; --afterglow: #a8927a;
  --body: "EB Garamond", Georgia, serif;
  --display: "Cinzel", "Times New Roman", serif;
  --mono: var(--body);      /* legacy alias — chambers still ask for --mono */
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; border-radius: 0 !important; }
html, body { height: 100%; }
body {
  background: var(--void); color: var(--bone);
  font-family: var(--body); font-size: 17px; line-height: 1.55;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
/* candlelit vignette over everything */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background:
    radial-gradient(120% 90% at 50% 30%, transparent 55%, rgba(5,3,6,0.55) 100%),
    radial-gradient(60% 30% at 50% 0%, rgba(224,178,74,0.05), transparent 70%);
}
#stars { display: none; }

/* --------------------------------------------------------------- top bar */
#bar {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; padding-top: calc(11px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--rule); background: var(--room);
}
#bar .brand { font-family: var(--display); letter-spacing: .34em; color: var(--gold); font-size: 15px; font-weight: 600; }
#bar .prog { margin-left: auto; display: flex; gap: 5px; }
#bar .prog i { width: 10px; height: 8px; border: 1px solid var(--faint); transform: rotate(0); }
#bar .prog i.done { background: var(--violet); border-color: var(--violet); }
#bar .prog i.now { background: var(--gold); border-color: var(--gold); }
.bar-btn { background: none; border: none; color: var(--dim); font-family: var(--display); font-size: 12px; letter-spacing: .1em; cursor: pointer; padding: 6px; }
.bar-btn:active { color: var(--bone); }

/* ----------------------------------------------------------------- stage */
#stage { position: relative; z-index: 1; flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chamber {
  max-width: 620px; margin: 0 auto; padding: 20px 18px 44px;
  display: flex; flex-direction: column; gap: 15px; animation: enter .34s cubic-bezier(.2,.7,.2,1);
}
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }
.hidden { display: none !important; }
.fine { font-size: 14px; color: var(--faint); }
.fine.center { text-align: center; }
.error { color: var(--rose); }

/* ----------------------------------------------- oracle dialogue + scene */
.dialogue {
  background: var(--room); padding: 14px 16px;
  border: 1px solid var(--rule-faint); border-left: 3px solid var(--gold-dim);
  font-size: 17px;
}
.dialogue .who { font-family: var(--display); color: var(--violet); font-size: 12px; letter-spacing: .22em; text-transform: uppercase; display: block; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--rule-faint); }
.dialogue em, .dialogue .typed { color: var(--bone); font-style: italic; }
.dialogue .plain { display: block; margin-top: 8px; font-style: normal; color: var(--dim); font-size: 15px; }
.typed::after { content: "▏"; color: var(--gold); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* the oracle hero image + live glow */
.oracle-art { position: relative; border: 1px solid var(--rule-faint); overflow: hidden; cursor: pointer; }
.oracle-art img { display: block; width: 100%; image-rendering: pixelated; }
.oracle-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: screen; pointer-events: none; }
.scene { display: flex; justify-content: center; padding: 2px 0; }
.scene img { width: 100%; image-rendering: pixelated; }

/* --------------------------------------------------------------- controls */
.btn {
  font-family: var(--body); font-size: 17px; background: var(--panel); color: var(--bone);
  border: 1px solid var(--line); padding: 13px 16px; cursor: pointer; min-height: 48px; text-align: left;
}
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { font-family: var(--display); font-size: 15px; letter-spacing: .1em; text-transform: uppercase; background: var(--teal-deep); border-color: var(--teal); color: var(--bone); text-align: center; }
.btn.primary:hover:not(:disabled) { background: #2e564a; }
.btn.ghost { color: var(--dim); background: transparent; }
.btn.wide { width: 100%; text-align: center; }
.menu { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { flex: 1; }

/* home doors: glyph + title + subtitle */
.door { display: flex; align-items: center; gap: 14px; padding: 15px 16px; border: 1px solid var(--line); background: rgba(26,20,23,0.4); cursor: pointer; }
.door:hover { border-color: var(--gold); }
.door.primary { border-color: var(--rule); background: rgba(94,155,132,0.07); border-left: 2px solid var(--teal); }
.door .g { font-size: 22px; color: var(--gold); width: 26px; text-align: center; }
.door.primary .g { color: var(--teal); }
.door .t { font-family: var(--display); font-size: 15px; letter-spacing: .04em; color: var(--bone); }
.door .s { font-size: 14px; color: var(--dim); margin-top: 2px; }

label.fld { display: flex; flex-direction: column; gap: 5px; font-size: 15px; color: var(--dim); }
input.tin, select.tin, textarea.tin {
  font-family: var(--body); font-size: 17px; background: var(--panel); color: var(--bone);
  border: 1px solid var(--line); padding: 12px; outline: none; width: 100%;
}
input.tin:focus, select.tin:focus, textarea.tin:focus { border-color: var(--gold); }
textarea.tin { resize: vertical; min-height: 96px; line-height: 1.6; }
select.tin { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%), linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
select.tin option { background: var(--panel); color: var(--bone); }

.prompt-line { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); padding: 4px 10px; }
.prompt-line .caret { color: var(--gold); }
.prompt-line input { flex: 1; background: none; border: none; outline: none; color: var(--bone); font-family: var(--body); font-size: 17px; padding: 9px 0; }

.pill { display: inline-block; font-family: var(--body); font-size: 14px; padding: 3px 9px; border: 1px solid var(--line); color: var(--dim); }
.pill.gold { border-color: var(--gold); color: var(--gold); }
.pill.teal { border-color: var(--teal); color: var(--teal); }
.pill.rose { border-color: var(--rose); color: var(--rose); }
.pill.violet { border-color: var(--violet); color: var(--violet); }

/* ------------------------------------------------------ recollection phases */
.phase-block { border: 1px solid var(--line); background: rgba(26,20,23,0.5); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.phase-block .head { display: flex; align-items: center; gap: 8px; }
.phase-tag { font-family: var(--display); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 8px; border: 1px solid; }
.pt-onset { color: var(--onset); border-color: var(--onset); }
.pt-peak { color: var(--peak); border-color: var(--peak); }
.pt-plateau { color: var(--plateau); border-color: var(--plateau); }
.pt-comedown { color: var(--comedown); border-color: var(--comedown); }
.pt-afterglow { color: var(--afterglow); border-color: var(--afterglow); }
.pt-presession { color: #b08a6a; border-color: #b08a6a; }

/* ------------------------------------------------------------- review grid */
.reading-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.grid { display: flex; flex-direction: column; gap: 8px; }
.cand { border: 1px solid var(--line); background: var(--panel); padding: 11px 13px; display: flex; flex-direction: column; gap: 6px; }
.cand.confirmed { border-color: var(--teal); }
.cand.rejected { opacity: .45; }
.cand.recalled { border-style: dashed; border-color: var(--rose); opacity: .8; }
.cand .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cand .code { font-family: var(--display); color: var(--bone); font-size: 15px; letter-spacing: .02em; }
.cand .conf { font-size: 14px; color: var(--dim); margin-left: auto; }
.cand .bar { height: 5px; background: var(--panel); border: 1px solid var(--line); }
.cand .bar > i { display: block; height: 100%; background: var(--gold); }
.cand .quote { font-size: 16px; color: var(--bone); border-left: 3px solid var(--violet); padding-left: 10px; font-style: italic; }
.cand .quote mark { background: rgba(224,178,74,0.25); color: var(--gold); }
.cand .acts { display: flex; gap: 6px; }
.cand .acts button { font-family: var(--body); font-size: 15px; padding: 7px 12px; border: 1px solid var(--line); background: var(--room); color: var(--dim); cursor: pointer; }
.cand .acts button.on { border-color: var(--teal); color: var(--teal); }
.cand .acts button.off.on { border-color: var(--rose); color: var(--rose); }
.ambig { font-size: 14px; color: var(--rose); }

.section-h { font-family: var(--display); font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); padding-bottom: 4px; margin-top: 6px; border-bottom: 1px solid var(--rule-faint); }

/* what a candidate code means, shown inline in Review so a confirm is informed */
.cand-def { font-size: 15px; color: var(--dim); font-style: italic; border-left: 2px solid var(--rule-faint); padding-left: 10px; }

/* ------------------------------------------------------------- codebook */
.cb-list { display: flex; flex-direction: column; gap: 8px; }
.cb-book { font-family: var(--display); font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--violet); margin-top: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.cb-book:first-child { margin-top: 4px; }
.cb-code { border: 1px solid var(--line); background: var(--panel); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.cb-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cb-head .code { font-family: var(--display); color: var(--bone); font-size: 15px; letter-spacing: .02em; }
.cb-head .pill { font-size: 12px; padding: 2px 7px; }
.cb-def { font-size: 15px; color: var(--dim); line-height: 1.5; }
.cb-cues > summary { cursor: pointer; color: var(--faint); font-size: 14px; list-style: none; }
.cb-cues > summary::before { content: "⌵ "; color: var(--gold-dim); }
.cb-cues[open] > summary::before { content: "⌃ "; }
.cb-cuelist, .cb-catrow { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-top: 7px; }
.cb-cats { display: flex; flex-direction: column; gap: 7px; }
.cb-catrow { margin-top: 0; }
.cb-catrow .pill.gold { text-transform: capitalize; }
.cb-dis { font-size: 14px; color: var(--faint); border-left: 2px solid var(--rule-faint); padding-left: 9px; line-height: 1.45; }
.cb-dis b { color: var(--dim); font-style: normal; font-weight: 400; letter-spacing: .04em; }

/* -------------------------------------------------------------- bottom nav */
#nav { position: relative; z-index: 2; display: flex; gap: 8px; padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule); background: var(--room); }
#nav .btn { flex: 1; text-align: center; min-height: 44px; font-size: 15px; }

/* ---------------------------------------------------------------- trials */
.trial-clock { font-family: var(--display); font-size: 44px; text-align: center; letter-spacing: .08em; color: var(--gold); font-variant-numeric: tabular-nums; }
.trial-words { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tword { font-size: 14px; padding: 3px 8px; border: 1px solid var(--line); color: var(--dim); background: var(--panel); animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.digit-show { font-family: var(--display); font-size: 62px; text-align: center; color: var(--teal); letter-spacing: .1em; font-variant-numeric: tabular-nums; min-height: 90px; display: flex; align-items: center; justify-content: center; animation: dfade .2s ease; }
@keyframes dfade { from { opacity: .2; } }

/* ---------------------------------------------------------------- tarot */
.tarot-wrap { perspective: 1100px; display: flex; justify-content: center; }
.tarot { width: min(280px, 78%); aspect-ratio: 3/4; position: relative; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.4,0,.2,1); }
.tarot.flipped { transform: rotateY(180deg); }
.tarot .face, .tarot .back { position: absolute; inset: 0; backface-visibility: hidden; }
.tarot .back { background: var(--room); }
.tarot .face { transform: rotateY(180deg); }
.tarot img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: pixelated; }
.tarot .numeral { position: absolute; top: 2.4%; left: 0; right: 0; text-align: center; font-family: var(--display); font-size: 12px; letter-spacing: .14em; color: var(--gold-cap); text-shadow: 0 1px 2px #000, 0 0 5px rgba(224,178,74,.5); }
.tarot-name { text-align: center; margin-top: 12px; font-family: var(--display); font-size: 17px; letter-spacing: .08em; color: var(--gold-cap); text-shadow: 0 0 8px rgba(224,178,74,.28); }

.mark { border-radius: 0; padding: 0 1px; }

/* ------------------------------------------------------- the lantern (prep) */
.prep-block { margin-bottom: 14px; }
.prep-title { font-family: var(--display); font-size: 14px; letter-spacing: .05em; color: var(--bone); text-transform: uppercase; }
.prep-prompt { display: block; font-size: 15px; color: var(--dim); margin: 4px 0 8px; line-height: 1.45; }
.lantern-list { display: flex; flex-direction: column; gap: 10px; }
.lantern-line { display: flex; gap: 10px; font-size: 16px; color: var(--bone); line-height: 1.5; }
.lantern-line .g { color: var(--gold); flex: none; }
.reach { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); padding: 11px 13px; }
.reach b { color: var(--teal); font-weight: 400; font-size: 15px; }
.reach span { color: var(--dim); font-size: 14px; }
a.reach.link { text-decoration: none; }
a.reach.link:hover { border-color: var(--gold); }

/* --------------------------------------------------------------- responsive */
/* Phone is the base (single column). Desktop widens the reading measure and
   the type, keeps the instrument centred like a document — never stretched. */
@media (min-width: 760px) {
  body { font-size: 18px; }
  .chamber { max-width: 720px; padding: 30px 26px 64px; gap: 18px; }
  #bar { padding: 13px 24px; }
  .dialogue { padding: 16px 20px; font-size: 18px; }
  .door { padding: 17px 18px; }
  .oracle-art { max-width: 460px; margin: 0 auto; }
  .scene { max-width: 520px; margin: 0 auto; }
  /* the doors fan into two columns on a wide screen */
  .menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .menu .door.primary { grid-column: 1 / -1; }
  .menu .btn { grid-column: 1 / -1; }
  #nav { justify-content: center; }
  #nav .btn { max-width: 280px; }
}
@media (min-width: 1180px) {
  .chamber { max-width: 780px; }
}
