/* Ringwise Phase 0 site. "Sectional" design system (see part107-app/CLAUDE.md). */

/* ---------- Fonts (self-hosted, Latin subset) ---------- */
@font-face { font-family: "Archivo"; src: url("fonts/Archivo-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("fonts/Archivo-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("fonts/Archivo-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("fonts/Archivo-ExtraBold.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Archivo Narrow"; src: url("fonts/ArchivoNarrow-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Archivo Narrow"; src: url("fonts/ArchivoNarrow-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  --paper: #F4F1E8;
  --surface: #FFFDF7;
  --ink: #1B2A3A;
  --ink-soft: #3A4654;
  --muted: #56606B;
  --line: #D9D2BE;
  --strong: #1B2A3A;
  --divider: #E8E1CC;
  --ring-track: #E3DCC7;
  --contour: #DFD3B4;
  --magenta: #A3216F;
  --magenta-tint: #FBEFF5;
  --blue: #1C5A9E;
  --error: #B4521C;
  --error-tint: #FBEDE4;
  --error-text: #8F3E12;
  --btn-bg: #1B2A3A;
  --btn-text: #FFFDF7;
  --on-magenta: #FFFFFF;

  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-narrow: "Archivo Narrow", "Archivo", system-ui, sans-serif;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111A24;
    --surface: #182431;
    --ink: #EDE7D8;
    --ink-soft: #C5CCD4;
    --muted: #A1ACB8;
    --line: #2C3D50;
    --strong: #3C5168;
    --divider: #26374A;
    --ring-track: #26374A;
    --contour: #1F2E3E;
    --magenta: #E86BB3;
    --magenta-tint: #2A1C2A;
    --blue: #7AB2EC;
    /* Dark error colours are not in the approved palette yet: chosen here for contrast. */
    --error: #EE8B52;
    --error-tint: #2E2119;
    --error-text: #F5B48C;
    --btn-bg: #EDE7D8;
    --btn-text: #111A24;
    --on-magenta: #111A24;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 8vw, 2.9rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 800; }
h3 { font-size: 1.125rem; font-weight: 800; }
p { margin: 0; }
a { color: var(--blue); text-underline-offset: 2px; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }

.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }

.label {
  font-family: var(--font-narrow);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 10;
  padding: 10px 14px; border-radius: 12px;
  background: var(--btn-bg); color: var(--btn-text); font-weight: 700;
}
.skip-link:focus { top: 12px; }

/* ---------- Header + logo mark ---------- */
.site-header { padding: 14px 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }

.mark-outer { fill: none; stroke: var(--magenta); stroke-width: 5; stroke-dasharray: 8.5 5.1; }
.mark-inner { fill: none; stroke: var(--blue); stroke-width: 5; }
.mark-dot { fill: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; min-height: 54px; padding: 0 22px;
  border: 0; border-radius: 14px;
  font: 700 1.0625rem/1.2 var(--font);
  cursor: pointer;
  transition: transform .15s var(--ease-out), background-color .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--btn-bg); color: var(--btn-text); }
.btn-primary:hover { background: color-mix(in srgb, var(--btn-bg) 88%, var(--magenta)); }
.btn-magenta { background: var(--magenta); color: var(--on-magenta); }
.btn-magenta:hover { background: color-mix(in srgb, var(--magenta) 88%, #000); }

.btn-text {
  min-height: 44px; padding: 0 4px;
  border: 0; background: none; color: var(--blue);
  font: 600 0.9375rem var(--font); text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px;
}
.card > * + * { margin-top: 10px; }

.screen > * + * { margin-top: 16px; }
main { padding-bottom: 32px; }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 36px 0 8px; isolation: isolate; }
.hero > * + * { margin-top: 14px; }
.hero h1 { margin-top: 8px; max-width: 13ch; }
.lede { font-size: 1.0625rem; color: var(--ink-soft); max-width: 34rem; }
.hero .btn { margin-top: 22px; }
.hero-note { font-size: 0.875rem; color: var(--muted); }
.eyebrow { color: var(--magenta); }

.hero-art {
  position: absolute; z-index: -1;
  top: -34px; right: -16px; width: min(62%, 300px); height: auto;
  opacity: .9;
  pointer-events: none;
}
.contour { fill: none; stroke: var(--contour); stroke-width: 1.5; }
.art-ring-m { fill: none; stroke: var(--magenta); stroke-width: 3; stroke-dasharray: 10 7; opacity: .35; }
.art-ring-b { fill: none; stroke: var(--blue); stroke-width: 3; opacity: .3; }

/* ---------- Waitlist + Kit form (restyled) ---------- */
.waitlist { border-color: var(--strong); }
.waitlist .label:first-child { color: var(--magenta); }
.waitlist > p:not(.label) { color: var(--ink-soft); }

.rw-form { margin-top: 14px; }
.rw-form .formkit-fields { display: grid; gap: 10px; }
.rw-form .formkit-field { display: grid; gap: 6px; }
.rw-form .formkit-input {
  width: 100%; min-height: 52px; padding: 0 14px;
  border: 1.5px solid var(--strong); border-radius: 14px;
  background: var(--paper); color: var(--ink);
  font: 400 1rem var(--font); /* 16px stops iOS zooming in */
}
.rw-form .formkit-input::placeholder { color: var(--muted); opacity: 1; }
.rw-form .formkit-input:focus { outline: 3px solid var(--blue); outline-offset: 1px; }

.rw-form .formkit-submit { position: relative; overflow: hidden; }
.rw-form .formkit-spinner {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; gap: 6px;
}
.rw-form .formkit-spinner > div {
  width: 9px; height: 9px; border-radius: 50%; background: currentColor;
  animation: rw-bounce 1.2s infinite ease-in-out both;
}
.rw-form .formkit-spinner > div:nth-child(1) { animation-delay: -.32s; }
.rw-form .formkit-spinner > div:nth-child(2) { animation-delay: -.16s; }
.rw-form .formkit-submit[data-active] .formkit-spinner { display: flex; }
.rw-form .formkit-submit[data-active] span { visibility: hidden; }
@keyframes rw-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.rw-form .formkit-alert {
  list-style: none; margin: 0 0 10px; padding: 12px 14px;
  border-radius: 12px; border: 1.5px solid; font-weight: 600;
}
.rw-form .formkit-alert:empty { display: none; }
.rw-form .formkit-alert-error { background: var(--error-tint); border-color: var(--error); color: var(--error-text); }
.rw-form .formkit-alert-success { background: var(--magenta-tint); border-color: var(--magenta); color: var(--ink); }

.form-note { margin-top: 10px; font-size: 0.8125rem; color: var(--muted); }
.form-note a { color: var(--muted); white-space: nowrap; }

/* ---------- Quiz ---------- */
.quiz-bar { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; }
.quiz-bar .label { color: var(--ink); }

.dots { display: flex; gap: 5px; margin: 8px 0 0; padding: 0; list-style: none; }
.dots li {
  flex: 1; height: 8px; border-radius: 999px;
  background: var(--divider);
  transition: background-color .2s;
}
.dots li.is-current { background: var(--ink); }
.dots li.is-correct { background: var(--magenta); }
.dots li.is-wrong { background: var(--error); }

.q-card { padding: 18px 16px 16px; }
.topic { color: var(--blue); }
.question { font-size: 1.25rem; font-weight: 700; line-height: 1.3; }

.chart { margin: 14px 0 0; }
.chart-img {
  border: 1.5px solid var(--line); border-radius: 14px; overflow: hidden;
  background: #EEF0DC; /* chart paper: stays light in dark mode, like a real chart */
}
.chart-img svg { display: block; width: 100%; height: auto; }
.chart-img .chart-fallback { padding: 16px; color: #1B2A3A; font-size: .9375rem; }
.chart figcaption { margin-top: 6px; text-align: right; font-size: 0.6875rem; }

.options { display: grid; gap: 12px; margin-top: 16px; }
.option {
  position: relative;
  display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px;
  width: 100%; min-height: 56px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink);
  font: 600 1rem/1.35 var(--font); text-align: left;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, opacity .2s;
}
.option:hover:not([aria-disabled]) { border-color: var(--strong); }
.option[aria-disabled] { cursor: default; }
.opt-letter {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--line);
  font: 700 0.875rem var(--font-narrow); color: var(--muted);
}
.opt-badge {
  grid-column: 2; margin-top: 4px;
  font: 700 0.6875rem var(--font-narrow); letter-spacing: 1.5px; text-transform: uppercase;
}
.opt-badge:empty { display: none; }

.option.is-correct { border-color: var(--magenta); background: var(--magenta-tint); }
.option.is-correct .opt-letter { border-color: var(--magenta); background: var(--magenta); color: var(--on-magenta); }
.option.is-correct .opt-badge { color: var(--magenta); }
/* The signature dashed magenta ring that snaps around the right answer. */
.option.is-correct::after {
  content: ""; position: absolute; inset: -6px;
  border: 2px dashed var(--magenta); border-radius: 19px;
  pointer-events: none;
  animation: ring-snap .5s var(--ease-out) both;
}
.option.is-wrong {
  border-color: var(--error); background: var(--error-tint); color: var(--error-text);
  animation: shake .35s ease-in-out;
}
.option.is-wrong .opt-letter { border-color: var(--error); background: var(--error); color: var(--surface); }
.option.is-wrong .opt-badge { color: var(--error-text); }
.option.is-dim { opacity: .55; }

@keyframes ring-snap {
  0% { opacity: 0; transform: scale(1.06) rotate(-2deg); }
  60% { opacity: 1; transform: scale(.99); }
  100% { opacity: 1; transform: none; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.feedback {
  margin-top: 18px; padding-top: 16px;
  border-top: 1.5px solid var(--divider);
  color: var(--ink-soft); font-size: 0.9375rem;
}
.feedback > * + * { margin-top: 8px; }
.feedback-title { font-size: 1.125rem; font-weight: 800; color: var(--magenta); }
.feedback.is-wrong .feedback-title { color: var(--error-text); }
.feedback-answer { font-weight: 700; color: var(--ink); }
.feedback-answer:empty { display: none; }
.source { font-size: 0.875rem; color: var(--muted); }
.source .label { margin-right: 4px; color: var(--blue); }

/* ---------- Results ---------- */
.result-card { text-align: center; }
.score { position: relative; width: min(100%, 260px); margin: 18px auto 0; }
.score-ring { display: block; width: 100%; height: auto; overflow: visible; }
.ring-track { fill: none; stroke: var(--ring-track); stroke-width: 14; }
.ring-arc {
  fill: none; stroke: var(--magenta); stroke-width: 14;
  stroke-dasharray: 502.65; stroke-dashoffset: 502.65;
  transition: stroke-dashoffset 1.4s var(--ease-out);
}
.ring-inner { fill: none; stroke: var(--blue); stroke-width: 2; }
.ring-inner-dash { stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .6; }
.ring-tick { stroke: var(--ink); stroke-width: 3; }
.ring-tick-label { fill: var(--ink); font: 700 13px var(--font-narrow); text-anchor: middle; }
.ring-score { fill: var(--ink); font: 800 42px var(--font); text-anchor: middle; }
.ring-rule { stroke: var(--ink); stroke-width: 2.5; }
.ring-total { fill: var(--blue); font: 700 26px var(--font-narrow); text-anchor: middle; }

.stamp {
  position: absolute; right: -4px; bottom: 6px;
  padding: 4px 12px;
  border: 3px solid currentColor; border-radius: 6px;
  font: 700 1.375rem/1.1 var(--font-narrow); letter-spacing: 3px;
  background: var(--surface);
  transform: rotate(-10deg);
  opacity: 0;
}
.stamp.is-pass { color: var(--magenta); }
.stamp.is-notyet { color: var(--error-text); font-size: 1.125rem; }
.stamp.is-in { animation: stamp-drop .45s 1.35s var(--ease-out) forwards; }
@keyframes stamp-drop {
  0% { opacity: 0; transform: rotate(-10deg) scale(1.8); }
  100% { opacity: 1; transform: rotate(-10deg) scale(1); }
}

.score-line { color: var(--ink-soft); }

.topics { margin: 4px 0 0; padding: 0; list-style: none; }
.topics li { padding: 12px 0; border-bottom: 1.5px solid var(--divider); }
.topics li:last-child { border-bottom: 0; padding-bottom: 0; }
.topic-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.topic-name { flex: 1; }
.topic-score { font: 700 1rem var(--font-narrow); color: var(--blue); font-variant-numeric: tabular-nums; }
.chip {
  padding: 2px 8px; border-radius: 999px;
  background: var(--magenta); color: var(--on-magenta);
  font: 700 0.6875rem var(--font-narrow); letter-spacing: 1.5px;
}
.bar { height: 8px; margin-top: 8px; border-radius: 999px; background: var(--divider); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--blue); }

/* ---------- Footer ---------- */
.site-footer {
  padding: 24px 0 40px;
  border-top: 1.5px solid var(--line);
  font-size: 0.875rem; color: var(--ink-soft);
}

/* ---------- Entrance motion ---------- */
.rise { animation: rise .45s var(--ease-out) both; }
.rise:nth-child(2) { animation-delay: .08s; }
.rise:nth-child(3) { animation-delay: .16s; }
.rise:nth-child(4) { animation-delay: .24s; }
.q-card.rise { animation-delay: 0s; animation-duration: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- Larger screens ---------- */
@media (min-width: 700px) {
  .hero { padding-top: 56px; }
  .hero .btn, .screen > .btn { width: auto; min-width: 220px; }
  .rw-form .formkit-fields { grid-template-columns: 1fr auto; align-items: end; }
  .card { padding: 22px 22px; }
}

/* ---------- Reduced motion: no animation at all ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .stamp.is-in { opacity: 1; }
}
