/* SF Halloween quiz — mobile-first, desktop-compatible */

:root {
  --bg: #f3efe4;
  --bg-2: #eae5d8;
  --ink: #171614;
  --muted: #3d3a34;
  --line: #d9d3c4;
  --card: #ffffff;
  --accent: #8ea489;      /* dusty sage, matches the card art */
  --accent-ink: #171614;
  --focus: #171614;
  --radius: 14px;
  --maxw: 540px;
  font-size: 17px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  line-height: 1.35;
}

.skip-link {
  position: absolute; left: -999px; top: 8px;
  background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 10;
}
.skip-link:focus { left: 8px; }

.app {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: fade .18s ease-out;
}
.screen[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

/* ---------- type ---------- */
.eyebrow {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: var(--muted);
}
.title {
  font-size: clamp(1.9rem, 8vw, 2.7rem);
  line-height: 1.05;
  letter-spacing: -.025em;
  margin: 0 0 32px;
  font-weight: 800;
}
.title .pre {
  display: block;
  font-size: .6em;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -.01em;
  margin-bottom: .5em;
}

/* ---------- intro ---------- */
.screen-intro { justify-content: center; padding-bottom: 10vh; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1.5px solid transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border-color: var(--line);
  border-radius: 999px;
  padding: 13px 20px;
  min-height: 48px;
  text-align: center;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: #000; }
.btn-secondary { background: var(--card); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: transparent; }
.btn-x { background: var(--card); }
.btn-big { font-size: 1.05rem; padding: 16px 30px; align-self: flex-start; }
.btn[disabled] { opacity: .45; cursor: default; }

.btn-play { gap: 10px; }
.btn-play svg { width: 14px; height: 14px; fill: currentColor; }

/* ---------- question ---------- */
.q-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 26px;
}
.btn-back { padding: 10px 10px 10px 2px; min-height: 44px; }
.btn-back[disabled] { visibility: hidden; }
.progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.progress-label { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 1rem; min-width: 2.4em; text-align: right; }
.progress-track { flex: 1; height: 3px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 12.5%; background: var(--ink); border-radius: 99px; transition: width .25s ease; }

.q-text {
  font-size: clamp(1.45rem, 6vw, 1.9rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  font-weight: 700;
  margin: 0 0 22px;
  outline: none;
}

.answers { display: grid; gap: 10px; }
.answer {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  border-radius: var(--radius);
  padding: 15px 16px 15px 14px;
  min-height: 58px;
  display: flex; align-items: flex-start; gap: 12px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
  overflow-wrap: anywhere;
}
.answer:hover { border-color: var(--ink); }
.answer:active { transform: scale(.99); }
.answer:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.answer[aria-checked="true"] { border-color: var(--ink); background: var(--bg-2); }
.answer-key {
  flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line);
  font-weight: 600; font-size: .85rem; color: var(--muted);
  margin-top: 1px;
}
.answer[aria-checked="true"] .answer-key { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.answer-text { flex: 1; }

.hint { color: var(--muted); font-size: .9rem; margin: 20px 0 0; text-align: center; }
@media (hover: none) { .hint { display: none; } }

/* ---------- result ---------- */
.screen-result { align-items: stretch; }
.result-title {
  font-size: clamp(1.6rem, 6.5vw, 2.1rem);
  line-height: 1.05; letter-spacing: -.025em; font-weight: 800;
  margin: 0 0 18px; outline: none;
}
.card {
  position: relative;
  margin: 0 auto 14px;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-2);
}
.card-canvas { width: 100%; height: 100%; display: block; }

.result-tagline { color: var(--muted); text-align: center; margin: 0 0 22px; font-size: 1.1rem; }
.result-tagline:empty { display: none; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn { padding-left: 12px; padding-right: 12px; white-space: nowrap; }
.toast { min-height: 1.4em; text-align: center; color: var(--muted); font-size: 1rem; margin: 12px 0 0; }

/* internal review mode (tests/contact_sheet.html): show only the card */
body.cardonly .app { padding: 0; max-width: none; min-height: 0; }
body.cardonly .screen-result > :not(.card) { display: none; }
body.cardonly .card { max-width: none; border-radius: 0; margin: 0; }

/* ---------- desktop ---------- */
@media (min-width: 720px) {
  :root { font-size: 18px; }
  .app { padding-top: 48px; }
  .answers { gap: 12px; }
  .answer { padding: 17px 20px; }
  .actions { grid-template-columns: repeat(4, 1fr); }
}
