/* ============================================================
   Youth Committee form — warm editorial theme
   ============================================================ */

:root {
  --paper:      #fbf6ec;   /* cream canvas               */
  --ink:        #1f1b16;   /* near-black warm text       */
  --ink-soft:   #6b6358;   /* muted text                 */
  --line:       #e4dccb;   /* hairline borders           */
  --accent:     #ef5a2a;   /* vivid coral                */
  --accent-ink: #fff4ee;   /* text on accent             */
  --accent-soft:#fbe2d6;   /* tinted fill                */
  --ok:         #2f7d52;

  --shadow: 0 1px 2px rgba(31,27,22,.04), 0 12px 32px -12px rgba(31,27,22,.18);
  --radius: 16px;

  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Hanken Grotesk", -apple-system, system-ui, sans-serif;

  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

button { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  position: relative;
}

/* warm radial atmosphere behind everything */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(120% 80% at 85% -10%, rgba(239,90,42,.10), transparent 55%),
    radial-gradient(90% 70% at -10% 110%, rgba(239,90,42,.06), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* subtle film grain */
.grain {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .45;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
}

/* ---------- progress ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 4px; z-index: 5;
  background: var(--line);
}
.progress__bar {
  display: block; height: 100%; width: 0%;
  background: var(--accent);
  transition: width .55s var(--ease);
}

/* ---------- stage ---------- */
.stage {
  position: relative; z-index: 2;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;              /* horizontal centering */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* extra bottom padding clears the fixed nav so tall screens (e.g. the rank
     question with a write-in) can scroll their last element into view */
  padding: clamp(24px, 6vw, 64px) clamp(20px, 6vw, 64px) 120px;
}

.screen {
  width: min(680px, 100%);
  position: absolute;
  opacity: 0;
  transform: translateY(28px);
  pointer-events: none;
  transition: opacity .45s var(--ease), transform .55s var(--ease);
}
.screen.is-active {
  position: relative;
  /* auto vertical margins center short screens, but collapse when the screen
     is taller than the viewport — so the top is never clipped and it scrolls */
  margin: auto 0;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.screen.is-leaving {
  opacity: 0;
  transform: translateY(-24px);
}

/* staggered children reveal */
.screen.is-active .reveal {
  animation: rise .6s var(--ease) backwards;
}
.screen.is-active .reveal:nth-child(1) { animation-delay: .05s; }
.screen.is-active .reveal:nth-child(2) { animation-delay: .13s; }
.screen.is-active .reveal:nth-child(3) { animation-delay: .21s; }
.screen.is-active .reveal:nth-child(4) { animation-delay: .29s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- typography ---------- */
.eyebrow {
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
  display: inline-flex; align-items: center; gap: 10px;
}
.eyebrow::before {
  content: ""; width: 28px; height: 2px; background: var(--accent); display: inline-block;
}

.q-index {
  font-family: var(--font-ui);
  font-size: .85rem; font-weight: 600;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.q-index svg { width: 13px; height: 13px; transform: rotate(90deg); }

.title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 560;
  font-size: clamp(1.9rem, 4.6vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -.015em;
  margin-bottom: 14px;
}
.title em { font-style: italic; color: var(--accent); }

.desc {
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  color: var(--ink-soft);
  max-width: 46ch;
  margin-bottom: 26px;
  line-height: 1.5;
}

/* ---------- welcome / thankyou ---------- */
.lede {
  font-size: clamp(1.05rem, 1.6vw, 1.22rem);
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 48ch;
  margin-bottom: 30px;
}

.btn {
  font-family: var(--font-ui);
  font-size: 1.02rem; font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: none; cursor: pointer;
  padding: 15px 28px;
  border-radius: 999px;
  display: inline-flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s;
}
@media (hover: hover) {
  .btn:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -12px rgba(239,90,42,.6); }
}
.btn:active { transform: translateY(0); }
.btn svg { width: 16px; height: 16px; }
.btn .key {
  font-size: .72rem; font-weight: 600; opacity: .8;
  padding: 3px 7px; border-radius: 6px;
  background: rgba(255,255,255,.22);
}

/* secondary / outline button (e.g. "keep going" at the checkpoint) */
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}
@media (hover: hover) {
  .btn--ghost:hover { border-color: var(--accent); color: var(--accent); box-shadow: none; transform: translateY(-2px); }
}

/* checkpoint actions — both clearly tappable, finish is the primary */
.cp-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.cp-actions .btn { justify-content: center; }
@media (max-width: 560px) {
  .cp-actions { flex-direction: column; align-items: stretch; }
}

/* ---------- inputs ---------- */
.field { margin-bottom: 8px; }

.input,
.textarea {
  width: 100%;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  font-weight: 440;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--line);
  padding: 10px 2px;
  transition: border-color .25s var(--ease);
}
.input::placeholder,
.textarea::placeholder { color: #b8ad99; font-style: italic; }
.input:focus,
.textarea:focus { outline: none; border-bottom-color: var(--accent); }
.textarea { resize: none; line-height: 1.4; min-height: 1.4em; overflow: hidden; }

/* choices */
.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  --i: " ";
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  font-family: var(--font-ui); font-size: 1.05rem; font-weight: 500;
  color: var(--ink);
  background: rgba(255,255,255,.55);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 15px 18px;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .12s var(--ease);
}
@media (hover: hover) {
  .option:hover { border-color: var(--accent); }
}
.option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.option__key {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  font-size: .82rem; font-weight: 700;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  transition: inherit;
}
.option.is-selected .option__key {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.option__check { margin-left: auto; opacity: 0; transition: opacity .15s; color: var(--accent); }
.option.is-selected .option__check { opacity: 1; }

/* disabled (e.g. rank list once the top N is full) */
.option.is-disabled { opacity: .4; cursor: default; }
@media (hover: hover) {
  .option.is-disabled:hover { border-color: var(--line); transform: none; }
}

/* write-in "Other…" row for choice / multichoice */
.option--other { cursor: text; }
.option--other .option__key { font-weight: 700; color: var(--ink-soft); }
.option__other {
  flex: 1; border: none; background: transparent;
  font-family: var(--font-ui); font-size: 1.05rem; color: var(--ink);
  padding: 0;
}
.option__other:focus { outline: none; }
.option__other::placeholder { color: #b8ad99; }

/* rank widget */
.rank .option__key { font-variant-numeric: tabular-nums; }
.rank__hint {
  margin-top: 4px; font-size: .9rem; color: var(--ink-soft);
}
.rank__add { display: flex; gap: 10px; margin-top: 12px; }
.rank__input {
  flex: 1;
  font-family: var(--font-ui); font-size: 1.02rem; color: var(--ink);
  background: rgba(255,255,255,.55);
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 13px 16px;
}
.rank__input:focus { outline: none; border-color: var(--accent); }
.rank__input::placeholder { color: #b8ad99; }
.rank__addbtn {
  flex: none;
  font-family: var(--font-ui); font-weight: 600; font-size: 1rem;
  color: var(--accent-ink); background: var(--accent);
  border: none; border-radius: 12px; padding: 0 20px; cursor: pointer;
}

/* rating */
.rating { display: flex; gap: 10px; }
.star {
  width: clamp(46px, 11vw, 58px); height: clamp(46px, 11vw, 58px);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.55);
  cursor: pointer;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 600;
  color: var(--ink-soft);
  transition: transform .14s var(--ease), border-color .15s, background .15s, color .15s;
}
@media (hover: hover) {
  .star:hover { transform: translateY(-4px) scale(1.04); border-color: var(--accent); }
}
.star.is-on {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

/* validation message */
.err {
  margin-top: 16px;
  font-size: .92rem; font-weight: 500;
  color: var(--accent);
  display: none;
}
.err.show { display: block; }

/* ---------- footer nav ---------- */
.nav {
  position: fixed; z-index: 5;
  bottom: clamp(18px, 4vw, 34px);
  right: clamp(18px, 4vw, 40px);
  display: flex; align-items: center; gap: 14px;
}
/* the [hidden] attribute must win over the .nav display rule above,
   otherwise the footer leaks onto the welcome & thank-you screens */
.nav[hidden] { display: none; }
.nav__hint {
  font-size: .82rem; color: var(--ink-soft);
  margin-right: 4px;
}
.nav__hint kbd {
  font-family: var(--font-ui); font-size: .76rem; font-weight: 600;
  background: var(--paper); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 6px;
  padding: 2px 7px; color: var(--ink);
}
.nav__back, .nav__next {
  font-family: var(--font-ui); cursor: pointer;
  border-radius: 999px; border: none;
  transition: transform .16s var(--ease), box-shadow .16s, background .16s, opacity .16s;
}
.nav__back {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--line);
}
@media (hover: hover) {
  .nav__back:hover { border-color: var(--accent); color: var(--accent); }
}
.nav__back:disabled { opacity: 0; pointer-events: none; }
.nav__next {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: .98rem; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  padding: 13px 22px;
  box-shadow: var(--shadow);
}
@media (hover: hover) {
  .nav__next:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -12px rgba(239,90,42,.6); }
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  body { overflow: auto; }

  /* top-align content (centered looks too low next to the bottom nav),
     leave room under the progress bar and above the fixed nav */
  .stage {
    justify-content: flex-start;
    min-height: 100dvh;
    height: auto;
    padding: 56px 20px 132px;
    overflow-y: visible;
  }
  .screen { transform: translateY(18px); }
  .screen.is-active { margin: 0 auto; }   /* top-align; horizontal centre */

  .title { font-size: clamp(1.7rem, 7.4vw, 2.25rem); line-height: 1.12; }
  .desc  { font-size: 1rem; margin-bottom: 22px; }
  .lede  { font-size: 1.05rem; margin-bottom: 26px; }
  .eyebrow { margin-bottom: 14px; }
  .q-index { margin-bottom: 12px; }

  .input, .textarea { font-size: 1.2rem; }
  .option { padding: 14px 16px; font-size: 1rem; }
  .options { gap: 10px; }

  /* full-width bottom bar, sits above the keyboard / safe area */
  .nav {
    left: 16px; right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    justify-content: space-between;
  }
  .nav__hint { display: none; }
}

/* very short / landscape phones: don't waste vertical space */
@media (max-height: 560px) {
  .stage { place-items: start center; align-content: start; padding-top: 48px; }
}

/* touch devices have no Enter key — drop the keyboard hint on the button */
@media (hover: none) and (pointer: coarse) {
  .btn .key { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, .screen, .screen .reveal { animation: none !important; transition-duration: .01ms !important; }
}

/* sending spinner */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: var(--accent-ink);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
