/* ------------------------------------------------------------------
   Feedback — "warm paper" theme
   Override --accent (or anything else) from the form's theme block.
------------------------------------------------------------------ */

/* Self-hosted variable fonts, subset to Latin. Licenses in fonts/OFL-*.txt.
   Italics are only fetched when something actually renders in italic. */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/fraunces-italic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-italic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

:root {
  --accent: #d4531e;
  --accent-ink: #fff;
  --paper: #f5f0e6;
  --paper-2: #ece5d7;
  --ink: #1d1a15;
  --ink-2: #6f685b;
  --ink-3: #a39b8c;
  --line: rgba(29, 26, 21, .16);
  --line-strong: rgba(29, 26, 21, .4);
  --danger: #b4321f;
  --ok: #2f7a4f;
  --wash: color-mix(in oklab, var(--accent) 14%, transparent);
  --wash-2: color-mix(in oklab, var(--accent) 7%, transparent);
  --shadow: 0 1px 0 rgba(0,0,0,.08), 0 10px 30px -14px rgba(29,26,21,.35);
  --radius: 12px;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Instrument Sans", "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(.2, .7, .15, 1);
  --dur: 420ms;
  --maxw: 44rem;
}

html[data-scheme="dark"] {
  --paper: #171511;
  --paper-2: #211e18;
  --ink: #efe8da;
  --ink-2: #a79e8d;
  --ink-3: #6e6757;
  --line: rgba(239, 232, 218, .16);
  --line-strong: rgba(239, 232, 218, .45);
  --accent-ink: #171511;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.8);
  --wash: color-mix(in oklab, var(--accent) 22%, transparent);
  --wash-2: color-mix(in oklab, var(--accent) 11%, transparent);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(60rem 40rem at -10% -10%, var(--wash) 0%, transparent 60%),
    radial-gradient(50rem 35rem at 110% 110%, var(--wash-2) 0%, transparent 60%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Paper grain. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
html[data-scheme="dark"] body::before { mix-blend-mode: screen; opacity: .35; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------------- shell */

.progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--line);
  z-index: 20;
}
.progress i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform 600ms var(--ease);
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.brand {
  position: fixed;
  top: 1.2rem; left: 1.5rem;
  z-index: 10;
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 500;
  letter-spacing: .01em;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.brand::before {
  content: "";
  width: .55rem; height: .55rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--wash);
}

.stage {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  padding: 6rem 1.5rem 7rem;
  overflow: hidden;
}

.step {
  width: min(100%, var(--maxw));
  grid-area: 1 / 1;
  display: none;
}
.step.is-active { display: block; }
.step:focus { outline: none; }

.step.enter-up   { animation: stepInUp   var(--dur) var(--ease) both; }
.step.enter-down { animation: stepInDown var(--dur) var(--ease) both; }
.step.leave-up   { display: block; animation: stepOutUp   calc(var(--dur) * .7) var(--ease) both; pointer-events: none; }
.step.leave-down { display: block; animation: stepOutDown calc(var(--dur) * .7) var(--ease) both; pointer-events: none; }
.step.shake      { animation: shake 420ms var(--ease); }

@keyframes stepInUp   { from { opacity: 0; transform: translateY(42px); } to { opacity: 1; transform: none; } }
@keyframes stepInDown { from { opacity: 0; transform: translateY(-42px); } to { opacity: 1; transform: none; } }
@keyframes stepOutUp   { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-42px); } }
@keyframes stepOutDown { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(42px); } }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* Staggered reveal of the parts of a step. */
.step.is-active > * { animation: rise 520ms var(--ease) both; }
.step.is-active > :nth-child(2) { animation-delay: 50ms; }
.step.is-active > :nth-child(3) { animation-delay: 100ms; }
.step.is-active > :nth-child(4) { animation-delay: 150ms; }
.step.is-active > :nth-child(5) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- question */

.q-num {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 14;
  font-size: .95rem;
  color: var(--accent);
  margin-bottom: .9rem;
  font-variant-numeric: tabular-nums;
}
.q-num::after {
  content: "";
  width: 1.6rem;
  height: 1px;
  background: currentColor;
  opacity: .7;
}
.q-num svg { width: .9rem; height: .9rem; }

.q-label {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 48, "SOFT" 40;
  font-weight: 450;
  font-size: clamp(1.65rem, 1.1rem + 2.4vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -.012em;
  margin: 0 0 .6rem;
  text-wrap: balance;
}
.q-label .req { color: var(--accent); margin-left: .15em; font-weight: 300; }

.q-help {
  color: var(--ink-2);
  font-size: 1.02rem;
  margin: 0 0 1.6rem;
  max-width: 38rem;
}
.q-help a { color: var(--accent); }

.q-input { margin-bottom: 1.4rem; }

.q-error {
  display: none;
  align-items: center;
  gap: .45rem;
  color: var(--danger);
  font-size: .92rem;
  font-weight: 500;
  margin: -.6rem 0 1.2rem;
}
.q-error.show { display: flex; }
.q-error svg { width: 1rem; height: 1rem; flex: none; }

.q-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.hint {
  font-size: .82rem;
  color: var(--ink-3);
}
.hint kbd {
  font: inherit;
  font-weight: 600;
  color: var(--ink-2);
}

/* ------------------------------------------------------------ text input */

.field {
  width: 100%;
  font: inherit;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 24, "SOFT" 20;
  font-size: clamp(1.3rem, 1rem + 1.4vw, 1.75rem);
  line-height: 1.3;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--line-strong);
  border-radius: 0;
  padding: .45em 0 .35em;
  outline: none;
  caret-color: var(--accent);
  transition: border-color 160ms, box-shadow 160ms;
  resize: none;
  overflow: hidden;
}
.field::placeholder { color: var(--ink-3); opacity: 1; font-style: italic; }
.field:focus { border-bottom-color: var(--accent); box-shadow: 0 2px 0 0 var(--accent); }
.field.is-invalid { border-bottom-color: var(--danger); }
textarea.field { min-height: 3.2em; }

.field-row { position: relative; }
.counter {
  position: absolute;
  right: 0; bottom: -1.4rem;
  font-size: .75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- options */

.opts {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  max-width: 30rem;
}
.opts.is-wide { max-width: none; flex-direction: row; flex-wrap: wrap; }
.opts.is-wide .opt { flex: 1 1 12rem; }

.opt {
  --i: 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: .85rem;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: color-mix(in oklab, var(--paper) 80%, transparent);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem .85rem .7rem .7rem;
  cursor: pointer;
  transition: transform 140ms var(--ease), border-color 140ms, background 140ms, box-shadow 140ms;
  animation: rise 480ms var(--ease) both;
  animation-delay: calc(120ms + var(--i) * 45ms);
  -webkit-tap-highlight-color: transparent;
}
.opt:hover, .opt:focus-visible {
  border-color: var(--accent);
  background: var(--wash-2);
  transform: translateX(3px);
  outline: none;
}
.opt.is-selected {
  border-color: var(--accent);
  background: var(--wash);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.opt.is-selected .key { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.opt .key {
  flex: none;
  width: 1.75rem; height: 1.75rem;
  display: grid; place-items: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--ink-2);
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  transition: background 140ms, color 140ms;
  font-variant-numeric: tabular-nums;
}
.opt .lbl { flex: 1; }
.opt .emoji { font-size: 1.4rem; line-height: 1; }
.opt .check {
  width: 1.1rem; height: 1.1rem;
  flex: none;
  opacity: 0;
  transform: scale(.6);
  transition: opacity 140ms, transform 200ms var(--ease);
  color: var(--accent);
}
.opt.is-selected .check { opacity: 1; transform: none; }

.other-row { margin-top: .6rem; }
.other-row .field { font-size: 1.15rem; }

/* ------------------------------------------------------------- scale */

.scale { max-width: 40rem; }
.scale-row {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 4.25rem));
  gap: .4rem;
}
.scale-ends { max-width: calc(var(--n) * 4.25rem + (var(--n) - 1) * .4rem); }
.cell {
  --i: 0;
  aspect-ratio: 1 / 1;
  min-height: 2.8rem;
  display: grid; place-items: center;
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  background: color-mix(in oklab, var(--paper) 80%, transparent);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 140ms var(--ease), border-color 140ms, background 140ms, color 140ms;
  animation: rise 480ms var(--ease) both;
  animation-delay: calc(120ms + var(--i) * 35ms);
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
.cell:hover, .cell:focus-visible { border-color: var(--accent); transform: translateY(-3px); outline: none; }
.cell.is-selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); transform: translateY(-3px); }
.scale-ends {
  display: flex;
  justify-content: space-between;
  margin-top: .6rem;
  font-size: .85rem;
  color: var(--ink-2);
}

/* ------------------------------------------------------------- rating */

.stars { display: flex; gap: .3rem; }
.star {
  --i: 0;
  font: inherit;
  width: clamp(2.6rem, 8vw, 3.6rem);
  height: clamp(2.6rem, 8vw, 3.6rem);
  padding: .35rem;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--line-strong);
  transition: transform 160ms var(--ease), color 120ms;
  animation: rise 480ms var(--ease) both;
  animation-delay: calc(120ms + var(--i) * 50ms);
  -webkit-tap-highlight-color: transparent;
}
.star svg { width: 100%; height: 100%; display: block; }
.star svg path { fill: transparent; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; transition: fill 120ms; }
.star.is-lit { color: var(--accent); }
.star.is-lit svg path { fill: currentColor; }
.star:hover { transform: scale(1.15) rotate(-6deg); }
.star:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.star.pop { animation: pop 320ms var(--ease); }
@keyframes pop { 40% { transform: scale(1.3) rotate(8deg); } }
.rating-caption {
  margin-top: .5rem;
  min-height: 1.5em;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--ink-2);
}

/* ------------------------------------------------------------- yes/no */

.yesno { display: flex; gap: .6rem; max-width: 24rem; }
.yesno .opt { justify-content: flex-start; }

/* ------------------------------------------------------------- buttons */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  padding: .72em 1.25em;
  cursor: pointer;
  box-shadow: 0 2px 0 color-mix(in oklab, var(--accent) 70%, black), var(--shadow);
  transition: transform 120ms var(--ease), box-shadow 120ms, filter 120ms;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: 0 0 0 color-mix(in oklab, var(--accent) 70%, black), var(--shadow); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.btn svg { width: 1.1em; height: 1.1em; }
.btn.is-busy { pointer-events: none; color: transparent; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.1em; height: 1.1em;
  border: 2px solid var(--accent-ink);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  color: var(--ink-2);
  background: none;
  border: 0;
  padding: .4em .6em;
  cursor: pointer;
  border-radius: 8px;
}
.btn-ghost:hover { color: var(--ink); background: var(--wash-2); }

/* ------------------------------------------------------------- footer */

.nav {
  position: fixed;
  right: 1.25rem; bottom: 1.25rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.nav .count {
  font-size: .8rem;
  color: var(--ink-2);
  margin-right: .5rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.nav button {
  width: 2.5rem; height: 2.5rem;
  display: grid; place-items: center;
  background: var(--paper);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 120ms, transform 120ms var(--ease), opacity 120ms;
  box-shadow: var(--shadow);
}
.nav button:hover { border-color: var(--accent); transform: translateY(-1px); }
.nav button:disabled { opacity: .35; pointer-events: none; }
.nav button svg { width: 1.1rem; height: 1.1rem; }

/* ------------------------------------------------------------- thanks */

.thanks { text-align: center; }
.thanks .tick {
  width: 5.5rem; height: 5.5rem;
  margin: 0 auto 1.5rem;
  color: var(--accent);
}
.thanks .tick circle {
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-dasharray: 170; stroke-dashoffset: 170;
  animation: draw 700ms var(--ease) forwards;
}
.thanks .tick path {
  fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: draw 450ms var(--ease) 500ms forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
.thanks .q-label { font-style: italic; font-variation-settings: "opsz" 72, "SOFT" 100; }
.thanks .q-help { margin-inline: auto; }

/* ------------------------------------------------------------- page mode */

.page { width: min(100%, var(--maxw)); padding: 5rem 1.5rem 6rem; margin: 0 auto; }
.page .step { display: block; margin-bottom: 3.2rem; animation: none; }
.page .step > * { animation: none; }
.page .step.is-hidden { display: none; }
.page .q-label { font-size: clamp(1.35rem, 1rem + 1.4vw, 1.9rem); }
.page .opt, .page .cell, .page .star { animation: none; }
.page .q-actions { margin-top: 1rem; }
.page .page-head { margin-bottom: 3rem; }
.page .page-head .q-label { font-size: clamp(2rem, 1.3rem + 2.8vw, 3.2rem); font-style: italic; }
.page .submit-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
html[data-mode="page"] .progress { display: none; }

/* ------------------------------------------------------------- misc */

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.toast {
  position: fixed;
  left: 50%; bottom: 1.5rem;
  transform: translate(-50%, 20px);
  z-index: 30;
  background: var(--ink);
  color: var(--paper);
  padding: .7rem 1.1rem;
  border-radius: 10px;
  font-size: .95rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 240ms, transform 240ms var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .stage { padding: 4.5rem 1.2rem 6rem; align-items: start; }
  .brand { left: 1.2rem; top: 1rem; }
  .btn { width: 100%; justify-content: center; }
  .hint { display: none; }
  .nav { right: 1rem; bottom: 1rem; }
  .yesno { flex-direction: column; }
  .scale-row { gap: .3rem; }
  .cell { min-height: 2.3rem; font-size: .95rem; border-radius: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
