/* ============================================================
   THE GRADE - Parent Survey
   Brand: cream #FFFCCB · vermilion #E64B27 · ink near-black
   Headlines: Bricolage Grotesque · Body: Geist Mono
   ============================================================ */

:root {
  --cream: #FFFCCB;
  --cream-deep: #F6F1B8;     /* slightly deeper cream for subtle fills */
  --orange: #E64B27;
  --orange-dark: #C73C1C;    /* hover/active */
  --orange-tint: #FBE3D9;    /* faint orange wash for selected bg */
  --ink: #1A1813;            /* near-black, warm */
  --ink-soft: #5A564A;       /* muted body */
  --line: #1A1813;           /* borders use ink */
  --white: #FFFEF4;          /* warm white card */

  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 660px;

  --font-head: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --shadow: 0 2px 0 0 var(--ink);
  --shadow-press: 0 0 0 0 var(--ink);

  --bar-h: 64px;     /* top bar height */
  --nav-h: 78px;     /* bottom nav height */
}

* { box-sizing: border-box; }

/* Ensure the `hidden` attribute wins over display:flex on .topbar/.navbar */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;          /* never allow horizontal scroll on mobile */
  max-width: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Top bar + progress ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--cream);
  border-bottom: 2px solid var(--ink);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: var(--bar-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.wordmark {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.12em;
  color: var(--orange);
  white-space: nowrap;
}
.wordmark-img {
  display: block;
  height: 16px;
  width: auto;
  flex: none;
}
.progress-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
@media (max-width: 420px) {
  .progress-label { font-size: 10px; letter-spacing: 0.08em; }
}
.progress-track {
  height: 6px;
  background: var(--cream-deep);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--orange);
  transition: width 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Stage / screen ---------- */
.stage {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 36px 20px calc(var(--nav-h) + 40px);
}
.screen { animation: rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .progress-fill { transition: none; }
}

/* ---------- Section header ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--orange);
  display: inline-block;
}
.section-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(30px, 7vw, 46px);
  line-height: 0.98;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
.section-intro {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 8px;
  max-width: 52ch;
}

/* ---------- Questions ---------- */
.questions { margin-top: 30px; }
.q {
  padding: 26px 0;
  border-top: 1.5px solid rgba(26, 24, 19, 0.14);
}
.q:first-child { border-top: none; padding-top: 6px; }

.q-prompt {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  display: flex;
  gap: 10px;
  overflow-wrap: anywhere;
}
.q-prompt > span { min-width: 0; }
.opt, .scale-text, .rank-label { overflow-wrap: anywhere; }
.q-num {
  color: var(--orange);
  font-weight: 700;
  flex: none;
}
.q-hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 6px 0 0 28px;
}
.q-tag {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 8px 0 0 28px;
}
.q-body { margin: 16px 0 0 28px; }
@media (max-width: 520px) {
  .q-hint, .q-tag, .q-body { margin-left: 0; }
}

/* ---------- Option cards (radio / multi) ---------- */
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.opt:hover { transform: translateY(-1px); box-shadow: 0 2px 0 0 var(--ink); }
.opt:active { transform: translateY(0); box-shadow: none; }
.opt:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.opt .marker {
  flex: none;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--ink);
  display: grid;
  place-items: center;
  background: var(--cream);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.opt[data-shape="radio"] .marker { border-radius: 50%; }
.opt[data-shape="check"] .marker { border-radius: 5px; }
.opt .marker svg { width: 13px; height: 13px; opacity: 0; transform: scale(0.6); transition: opacity 0.12s ease, transform 0.12s ease; }

.opt[aria-checked="true"] {
  background: var(--orange-tint);
  border-color: var(--orange);
  color: var(--ink);
}
.opt[aria-checked="true"] .marker { background: var(--orange); border-color: var(--orange); }
.opt[aria-checked="true"] .marker svg { opacity: 1; transform: scale(1); stroke: var(--cream); }

/* ---------- Scale ---------- */
.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.scale-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  cursor: pointer;
  font-family: var(--font-mono);
  text-align: center;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.scale-opt:hover { transform: translateY(-1px); }
.scale-opt:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.scale-num {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--cream);
}
.scale-text {
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--ink-soft);
}
.scale-opt[aria-checked="true"] { background: var(--orange-tint); border-color: var(--orange); }
.scale-opt[aria-checked="true"] .scale-num { background: var(--orange); border-color: var(--orange); color: var(--white); }
.scale-opt[aria-checked="true"] .scale-text { color: var(--ink); }
/* Scale becomes a vertical stack on small screens for readability (CSS-only) */
@media (max-width: 560px) {
  .scale { grid-template-columns: 1fr; }
  .scale-opt { flex-direction: row; justify-content: flex-start; gap: 14px; text-align: left; padding: 12px 14px; }
  .scale-text { font-size: 14px; }
}

/* ---------- Rank (drag to reorder) ---------- */
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 12px 12px 14px;
  font-size: 14.5px;
  line-height: 1.35;
  cursor: grab;
  transition: box-shadow 0.12s ease, background 0.12s ease, transform 0.08s ease;
}
.rank-item.dragging { opacity: 0.5; cursor: grabbing; }
.rank-item.drop-target { box-shadow: 0 -3px 0 0 var(--orange); }
.rank-rankno {
  flex: none;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  color: var(--orange);
  width: 22px;
  text-align: center;
}
.rank-label { flex: 1; }
.rank-handle {
  flex: none;
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  width: 22px;
}
.rank-arrows { flex: none; display: flex; flex-direction: column; gap: 2px; }
.rank-arrows button {
  width: 30px;
  height: 22px;
  border: 1.5px solid var(--ink);
  background: var(--cream);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
}
.rank-arrows button:hover { background: var(--orange); color: var(--white); border-color: var(--orange); }
.rank-arrows button:disabled { opacity: 0.3; cursor: default; }
.rank-arrows button:disabled:hover { background: var(--cream); color: var(--ink); border-color: var(--ink); }

/* ---------- Text input ---------- */
textarea.text-input,
input.text-field {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 16px;          /* 16px stops iOS Safari from auto-zooming on focus */
  line-height: 1.5;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  resize: vertical;
}
textarea.text-input { min-height: 110px; }
textarea.text-input:focus,
input.text-field:focus { outline: 3px solid var(--orange); outline-offset: 1px; }
textarea.text-input::placeholder,
input.text-field::placeholder { color: #9a9482; }

/* ---------- Welcome screen ---------- */
.welcome { text-align: center; padding-top: 4px; }
.welcome .monogram {
  width: 66px;
  height: auto;
  margin: 0 auto 10px;
  display: block;
}
.welcome .welcome-wordmark-img {
  display: block;
  width: 200px;
  max-width: 66%;
  height: auto;
  margin: 0 auto 16px;
}
.welcome h1 {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(30px, 7.5vw, 56px);
  line-height: 0.95;
  letter-spacing: -0.015em;
  text-transform: uppercase;
  margin: 0 0 12px;
}
.welcome h1 .accent { color: var(--orange); }
.welcome .tagline {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange);
  margin: 0 0 14px;
}
.welcome .lede {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  max-width: 46ch;
  margin: 0 auto 16px;
}
.welcome .meta-row {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 14px 0 18px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.welcome .meta-row span { display: flex; align-items: center; gap: 7px; }
.welcome .meta-row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }

.form-card {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 0 var(--ink);
  padding: 26px 24px;
  max-width: 460px;
  margin: 0 auto;
  text-align: left;
}
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 7px;
  color: var(--ink);
}
.field .req { color: var(--orange); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* ---------- Completion screen ---------- */
.done { text-align: center; padding-top: 30px; }
.done .monogram { width: 96px; height: auto; margin: 0 auto 28px; display: block; }
.done h1 {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(34px, 9vw, 60px);
  line-height: 0.95;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}
.done h1 .accent { color: var(--orange); }
.done p { font-size: 15.5px; line-height: 1.65; color: var(--ink); max-width: 44ch; margin: 0 auto 14px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 13px 30px;
  cursor: pointer;
  border: 1.5px solid var(--ink);
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.btn:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.btn-primary { background: var(--orange); color: var(--white); border-color: var(--orange); box-shadow: 0 2px 0 0 var(--orange-dark); }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--cream-deep); }
.btn-ghost:disabled { opacity: 0; pointer-events: none; }
.btn-block { width: 100%; display: block; margin-top: 6px; }
.btn-lg { padding: 16px 34px; font-size: 15px; }

/* ---------- Bottom nav ---------- */
.navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--cream);
  border-top: 2px solid var(--ink);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px calc(env(safe-area-inset-bottom, 0px));
}
.navbar > * { }
.navbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- Validation / error ---------- */
.q.invalid .q-prompt { color: var(--orange); }
.q.invalid .options .opt,
.q.invalid .scale .scale-opt,
.q.invalid textarea.text-input { border-color: var(--orange); }
.error-flag {
  font-size: 12px;
  color: var(--orange);
  font-weight: 600;
  margin: 10px 0 0 28px;
  display: none;
}
.q.invalid .error-flag { display: block; }
@media (max-width: 520px) { .error-flag { margin-left: 0; } }

.field-error {
  color: var(--orange);
  font-size: 12px;
  margin-top: 6px;
  display: none;
}
.field.invalid .field-error { display: block; }
.field.invalid input.text-field { border-color: var(--orange); }

/* ---------- Submit / status banners ---------- */
.banner {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 auto 18px;
  max-width: 460px;
  border: 1.5px solid var(--ink);
}
.banner-warn { background: #FFF6DA; }
.banner-err { background: var(--orange-tint); border-color: var(--orange); color: var(--orange-dark); }

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.config-note {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 20px;
  font-size: 12px;
  color: var(--orange-dark);
  background: var(--orange-tint);
  border-bottom: 1.5px solid var(--orange);
  text-align: center;
}

/* ============================================================
   Display headlines use the exact variable cut from Figma:
   Bricolage Grotesque · wght 686 · opsz 80 · wdth 75 (condensed).
   Placed last so it governs weight + variation over earlier rules.
   Smaller Bricolage text (question prompts, badges) intentionally
   stays at normal width with optical sizing auto for readability.
   ============================================================ */
.wordmark,
.welcome h1,
.section-title,
.done h1 {
  font-weight: 686;
  font-stretch: 75%;
  font-variation-settings: "wght" 686, "wdth" 75, "opsz" 80;
}

/* ============================================================
   Mobile compaction - keep name/email + submit within the
   welcome viewport. Placed last so it overrides base rules.
   ============================================================ */
@media (max-width: 560px) {
  .stage { padding-top: 18px; }
  .welcome .monogram { width: 54px; margin-bottom: 10px; }
  .welcome .welcome-wordmark-img { width: 176px; margin-bottom: 14px; }
  .welcome h1 { font-size: clamp(28px, 9.5vw, 42px); margin-bottom: 12px; }
  .welcome .tagline { font-size: 11px; margin-bottom: 12px; }
  .welcome .lede { font-size: 13.5px; line-height: 1.6; margin-bottom: 16px; }
  .welcome .meta-row { gap: 14px; margin: 12px 0 16px; font-size: 10px; }
  .form-card { padding: 20px 18px; box-shadow: 3px 3px 0 0 var(--ink); }
  .field { margin-bottom: 13px; }
  .field-row { gap: 10px; }
}

/* On the welcome screen there is no top bar or navbar, so let the content
   fill and vertically center within the viewport instead of sitting up top. */
body.on-welcome .stage {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: 24px;
  padding-bottom: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.welcome { width: 100%; }
