/* ============================================================
   TEST OF FAITH — Dark Divine Rose
   ============================================================ */

/* ---------- TOKENS: DARK (default) ---------- */
:root {
  --bg:         #1a121c;
  --bg-2:       #150e17;
  --surface:    #241827;
  --surface-2:  #2e2032;
  --text:       #efe4e8;   /* warm near-white, never pure white */
  --text-dim:   #c3aeb8;

  --rose:       #ee8fb4;   /* primary accent */
  --lavender:   #b79cd4;   /* secondary accent */
  --blush:      #e0a9a0;   /* bridge / gradient midpoint */
  --gold:       #b8985a;   /* the bioluminescence */

  --on-accent:  #1a121c;   /* text that sits on a rose fill */

  --line:       rgba(238,143,180,.45);   /* crisp luminous edge, resting */
  --line-2:     rgba(183,156,212,.35);   /* secondary edge */
  --line-hot:   var(--rose);             /* active edge */

  --glow:       rgba(184,152,90,.30);    /* ambient gold */
  --glow-soft:  rgba(184,152,90,.14);
  --rose-glow:  rgba(238,143,180,.40);

  --shadow:     0 10px 40px rgba(0,0,0,.55);
  --radius:     18px;
  --radius-sm:  12px;

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
             Georgia, "Times New Roman", serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, system-ui, sans-serif;
}

/* ---------- TOKENS: LIGHT (warm sand, not white) ---------- */
:root[data-theme="light"] {
  --bg:         #cdbba0;   /* warm sand */
  --bg-2:       #c2ae8f;
  --surface:    #d7c7ae;
  --surface-2:  #e0d2bc;
  --text:       #2c1f2e;
  --text-dim:   #5b4a54;

  --rose:       #c25c86;   /* accents deepened for contrast on sand */
  --lavender:   #7d5fa6;
  --blush:      #b76d5e;
  --gold:       #8a6a38;

  --on-accent:  #fbf4ee;   /* warm near-white on the deeper rose */

  --line:       rgba(194,92,134,.55);
  --line-2:     rgba(125,95,166,.45);
  --line-hot:   var(--rose);

  --glow:       rgba(138,106,56,.26);
  --glow-soft:  rgba(138,106,56,.12);
  --rose-glow:  rgba(194,92,134,.30);

  --shadow:     0 10px 34px rgba(80,55,30,.28);
}

/* ---------- RESET ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;                 /* no document scroll: we drive screens */
  overscroll-behavior: none;
  touch-action: pan-y;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
input, textarea { font-family: inherit; }

/* ---------- APP SHELL ---------- */
#app {
  position: fixed;
  inset: 0;
  height: 100dvh;                   /* survives iOS address-bar collapse */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--glow-soft), transparent 60%),
    radial-gradient(90% 60% at 85% 110%, var(--rose-glow), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  overflow: hidden;
}

/* wispy smoke layer */
#app::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(35% 25% at 20% 30%, var(--glow), transparent 70%),
    radial-gradient(30% 22% at 78% 65%, rgba(183,156,212,.18), transparent 70%),
    radial-gradient(28% 20% at 55% 88%, rgba(224,169,160,.14), transparent 70%);
  filter: blur(30px);
  opacity: .8;
  pointer-events: none;
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(-3%, 2%, 0) scale(1.08); }
}

/* ---------- HEADER (persistent eyes + progress + toggle) ---------- */
.header {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 18px 10px;
}
.eyes { display: flex; align-items: center; gap: 10px; opacity: .9; }
.eyes svg { width: 58px; height: 20px; display: block; }
.eyes .lid { fill: none; stroke: var(--gold); stroke-width: 1.4; opacity: .85; }
.eyes .iris { fill: var(--rose); filter: drop-shadow(0 0 5px var(--rose-glow)); }
.eyes .pupil { fill: var(--bg); }
.eyes.blink .iris, .eyes.blink .pupil { animation: blink .18s ease; }
@keyframes blink { 50% { transform: scaleY(.05); transform-origin: center; } }

.toggle {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surface);
  display: grid; place-items: center;
  transition: border-color .2s, transform .2s;
}
.toggle:hover { border-color: var(--line-hot); }
.toggle:active { transform: scale(.94); }
.toggle svg { width: 20px; height: 20px; stroke: var(--gold); fill: none; stroke-width: 1.6; }

/* progress */
.progress-wrap {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--rose), var(--blush) 60%, var(--lavender));
  box-shadow: 0 0 12px var(--rose-glow);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.header.hide-progress .progress-wrap { visibility: hidden; }

/* ---------- STAGE + CARDS ---------- */
#stage {
  position: relative;
  z-index: 4;
  flex: 1 1 auto;
  overflow: hidden;
}
.card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 8px clamp(18px, 5vw, 40px) max(18px, env(safe-area-inset-bottom));
  opacity: 0;
  transform: translateX(0) scale(.985);
  will-change: opacity, transform;
  transition: opacity .5s ease, transform .5s cubic-bezier(.22,.61,.36,1);
}
.card.enter-from-right { transform: translateX(6%) scale(.985); }
.card.enter-from-left  { transform: translateX(-6%) scale(.985); }
.card.active { opacity: 1; transform: translateX(0) scale(1); }
.card.exit-left  { opacity: 0; transform: translateX(-6%) scale(.985); }
.card.exit-right { opacity: 0; transform: translateX(6%) scale(.985); }

.card-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 12px 2px 8px;
  scrollbar-width: thin;
}
.card-scroll::-webkit-scrollbar { width: 6px; }
.card-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }

/* typography */
.kicker {
  font-family: var(--body);
  text-transform: lowercase;
  letter-spacing: .28em;
  font-size: .72rem;
  color: var(--gold);
  opacity: .85;
}
.prompt {
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: .01em;
  font-size: clamp(1.7rem, 6.2vw, 2.5rem);
  color: var(--text);
  text-shadow: 0 0 22px var(--glow-soft);
}
.sub {
  color: var(--text-dim);
  font-size: clamp(.95rem, 3.6vw, 1.05rem);
  line-height: 1.5;
}
.body-copy {
  color: var(--text);
  font-size: clamp(1rem, 3.9vw, 1.12rem);
  line-height: 1.6;
}
.body-copy.dim { color: var(--text-dim); }

/* ---------- OPTIONS (single / multi) ---------- */
.options { display: flex; flex-direction: column; gap: 12px; }
.opt {
  position: relative;
  text-align: left;
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 15px 46px 15px 17px;
  font-size: clamp(.98rem, 3.9vw, 1.06rem);
  line-height: 1.4;
  transition: border-color .2s, background .2s, transform .12s, box-shadow .25s;
}
.opt:hover { border-color: var(--line-hot); }
.opt:active { transform: scale(.99); }
.opt .mark {
  position: absolute;
  right: 15px; top: 50%;
  transform: translateY(-50%);
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line-2);
  display: grid; place-items: center;
  transition: border-color .2s, background .2s;
}
.opt[data-multi="true"] .mark { border-radius: 6px; }
.opt[data-multi="false"] .mark { border-radius: 50%; }
.opt .mark svg { width: 12px; height: 12px; opacity: 0; transform: scale(.6); transition: .2s; }
.opt.selected {
  border-color: var(--rose);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: 0 0 0 1px var(--rose) inset;
}
.opt.selected .mark { background: var(--rose); border-color: var(--rose); }
.opt.selected .mark svg { opacity: 1; transform: scale(1); stroke: var(--on-accent); fill: none; stroke-width: 2.4; }

/* ignite variant (Q9) */
.opt.ignite.selected {
  border-color: var(--rose);
  box-shadow:
    0 0 0 1px var(--rose) inset,
    0 0 18px var(--rose-glow),
    0 0 40px var(--rose-glow);
  animation: ignite .5s ease;
}
@keyframes ignite {
  0%   { box-shadow: 0 0 0 1px var(--rose) inset, 0 0 0 var(--rose-glow); }
  55%  { box-shadow: 0 0 0 1px var(--rose) inset, 0 0 26px var(--rose-glow), 0 0 60px var(--rose-glow); }
  100% { box-shadow: 0 0 0 1px var(--rose) inset, 0 0 18px var(--rose-glow), 0 0 40px var(--rose-glow); }
}

/* ---------- TEXT INPUT ---------- */
.field {
  width: 100%;
  min-height: 120px;
  resize: none;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 16px;
  font-size: 1.05rem;   /* >=16px stops iOS zoom-on-focus */
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s;
}
.field::placeholder { color: var(--text-dim); opacity: .8; }
.field:focus {
  outline: none;
  border-color: var(--rose);
  box-shadow: 0 0 0 1px var(--rose), 0 0 16px var(--rose-glow);
}

/* ---------- QUADRANT (Q7) ---------- */
.quad-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.quad-axis-top, .quad-axis-bottom {
  font-size: .8rem; letter-spacing: .12em; text-transform: lowercase;
  color: var(--gold);
}
.quad-row { display: flex; align-items: center; gap: 10px; width: 100%; }
.quad-side {
  font-size: .78rem; letter-spacing: .1em; text-transform: lowercase;
  color: var(--gold);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.quad-side.right { transform: rotate(180deg); }
.quad {
  position: relative;
  flex: 1 1 auto;
  aspect-ratio: 1 / 1;
  max-width: 340px;
  margin: 0 auto;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background:
    radial-gradient(60% 60% at 50% 50%, var(--glow-soft), transparent 70%),
    var(--surface);
  box-shadow: inset 0 0 30px rgba(0,0,0,.25);
  touch-action: none;
}
.quad .grid-line { position: absolute; background: var(--line-2); }
.quad .grid-line.v { left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-.5px); }
.quad .grid-line.h { top: 50%; left: 0; right: 0; height: 1px; transform: translateY(-.5px); }
.quad .dot {
  position: absolute;
  width: 34px; height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--blush), var(--rose) 70%);
  border: 2px solid var(--on-accent);
  box-shadow: 0 0 16px var(--rose-glow), 0 0 32px var(--rose-glow);
  left: 50%; top: 50%;
  touch-action: none;
  transition: box-shadow .2s;
}
.quad .dot.grabbed { box-shadow: 0 0 22px var(--rose-glow), 0 0 50px var(--rose-glow); }
.quad-label { display: flex; justify-content: space-between; width: 100%; max-width: 360px; }
.quad-hint { font-size: .82rem; color: var(--text-dim); text-align: center; }

/* ---------- TITLE + ENDING ---------- */
.card.title-card, .card.ending-card { padding: 0; }
.title-inner, .ending-inner {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 30px clamp(20px, 6vw, 48px);
  overflow: hidden;
}
.full-bleed {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: .5;
  z-index: 0;
}
.full-bleed::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(26,18,28,.35), var(--bg) 92%);
}
:root[data-theme="light"] .full-bleed { opacity: .42; }
:root[data-theme="light"] .full-bleed::after {
  background: linear-gradient(180deg, rgba(205,187,160,.30), var(--bg) 92%);
}
.title-inner > *, .ending-inner > * { position: relative; z-index: 1; }
.title-main {
  font-family: var(--display);
  font-size: clamp(2.4rem, 11vw, 4rem);
  line-height: 1.05;
  text-shadow: 0 0 30px var(--glow);
}
.tap-cue {
  margin-top: 8px;
  font-size: .8rem; letter-spacing: .28em; text-transform: lowercase;
  color: var(--gold);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:.5} 50%{opacity:1} }

.portrait {
  width: 128px; height: 128px; border-radius: 22px;
  object-fit: cover;
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow), 0 0 22px var(--glow-soft);
  background: var(--surface-2);
}
.portrait.inline { width: 84px; height: 84px; border-radius: 16px; align-self: flex-start; }

/* ---------- FOOTER / NAV ---------- */
.nav {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(18px,5vw,40px) max(16px, env(safe-area-inset-bottom));
}
.btn {
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 13px 22px;
  font-size: 1rem;
  letter-spacing: .02em;
  transition: border-color .2s, transform .12s, box-shadow .25s, background .2s;
}
.btn:hover { border-color: var(--line-hot); }
.btn:active { transform: scale(.97); }
.btn.primary {
  margin-left: auto;
  background: linear-gradient(180deg, var(--rose), var(--blush));
  color: var(--on-accent);
  border-color: transparent;
  box-shadow: 0 0 18px var(--rose-glow);
  font-weight: 600;
}
.btn.primary:disabled {
  opacity: .4;
  box-shadow: none;
  cursor: not-allowed;
}
.btn.ghost { background: transparent; }
.btn.back { padding: 13px 18px; }
.btn.full { margin-left: 0; width: 100%; justify-content: center; text-align: center; }

/* focus visibility */
:focus-visible { outline: 2px solid var(--lavender); outline-offset: 3px; }

/* ---------- STATES (sending / error) ---------- */
.state-msg { text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line-2);
  border-top-color: var(--rose);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  #app::before { animation: none; }
  .card { transition: opacity .001s; transform: none !important; }
  .tap-cue { animation: none; }
  .spinner { animation-duration: 2s; }
}

/* ---------- SHORT VIEWPORTS ---------- */
@media (max-height: 620px) {
  .card-scroll { justify-content: flex-start; }
  .prompt { font-size: clamp(1.5rem, 5.5vw, 2rem); }
}
