/* ============================================================
   The Ballroom · Guestbook — shared tokens & primitives
   Light, bright, print-like. Warm paper base, felt-green accent.
   ============================================================ */
:root {
  --bg: #f7f5ef;
  --bg-2: #efece3;
  --surface: #ffffff;
  --surface-2: #f2f0e9;
  --line: #e4e0d5;
  --line-strong: #cfc9bb;
  --text: #17191c;
  --text-2: #474c53;
  --text-3: #6f757d;
  --accent: #128449;
  --accent-2: #0d6b3a;
  --accent-soft: #e2f3e8;
  --accent-ink: #0b4a2a;
  --on-accent: #ffffff;
  --danger: #c43d33;
  --danger-soft: #fbe8e6;
  --warn: #9a6b00;
  --warn-soft: #fdf1cf;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --font-display: "Cabinet Grotesk", "Satoshi", system-ui, sans-serif;
  --font-body: "Satoshi", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 1px 2px rgba(23, 25, 28, 0.06), 0 12px 32px -16px rgba(23, 25, 28, 0.22);
  --tap: 56px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; margin: 0; }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: #cdeedb; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- Inputs ---------- */
.field { display: grid; gap: 8px; }
.field > label, .field-label { font-size: 14px; font-weight: 700; color: var(--text); }
.field .hint { font-size: 13px; color: var(--text-3); }
.field .error { font-size: 13px; color: var(--danger); display: none; }
.field.is-invalid .error { display: block; }
.field.is-invalid .input { border-color: var(--danger); }
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 1.3;
  box-shadow: inset 0 1px 2px rgba(23,25,28,0.04);
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder { color: #a3a8ae; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 96px; resize: vertical; }
.input-wrap { position: relative; }
.input-wrap .prefix { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 18px; pointer-events: none; }
.input-wrap .input.has-prefix { padding-left: 52px; }
.input-wrap .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--accent); font-weight: 600; display: none; align-items: center; gap: 6px; background: var(--surface); padding-left: 8px; }
.input-wrap .suffix svg { width: 16px; height: 16px; }
.input-wrap.is-known .suffix { display: inline-flex; color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 22px;
  border-radius: var(--radius); border: 1px solid transparent;
  font-weight: 600; font-size: 17px;
  transition: transform 120ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease), opacity 160ms;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 0 rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.12); }
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover { border-color: var(--text-3); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-3); background: var(--surface); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #f0c4bf; }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: 15px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: 0.7; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); border-top-color: currentColor; animation: spin 800ms linear infinite; }
.btn-ghost .spinner, .btn-secondary .spinner { border-color: rgba(23,25,28,0.15); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Choice tiles (big tap targets) ---------- */
.choices { display: grid; gap: 12px; }
.choices.cols-2 { grid-template-columns: repeat(2, 1fr); }
.choices.cols-3 { grid-template-columns: repeat(3, 1fr); }
.choices.cols-5 { grid-template-columns: repeat(5, 1fr); }
.choice {
  position: relative;
  min-height: 64px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-weight: 500; font-size: 17px; color: var(--text);
  box-shadow: 0 1px 0 rgba(23,25,28,0.04);
  transition: transform 120ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease), color 160ms;
  -webkit-tap-highlight-color: transparent; user-select: none; text-align: center;
}
.choice:hover { border-color: var(--text-3); }
.choice:active { transform: translateY(1px); }
.choice svg { width: 26px; height: 26px; flex: none; color: var(--text-2); transition: color 160ms; }
.choice[aria-pressed="true"], .choice[aria-checked="true"] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.choice[aria-pressed="true"] svg, .choice[aria-checked="true"] svg { color: var(--accent); }
.choice.tile { flex-direction: column; min-height: 104px; gap: 10px; }
.choice.tile svg { width: 30px; height: 30px; }
.choice .check { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: none; align-items: center; justify-content: center; }
.choice .check svg { width: 12px; height: 12px; color: var(--on-accent); }
.choice[aria-pressed="true"] .check { display: inline-flex; }

/* Source buttons */
.choice.src { flex-direction: column; gap: 8px; min-height: 84px; }
.choice.src svg { width: 24px; height: 24px; }

/* Rating scale: one colour per score */
.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.rating .choice { flex-direction: column; gap: 4px; min-height: 92px; --rc: var(--text-3); --rc-soft: var(--surface-2); --rc-ink: var(--text); }
.rating .rate-1 { --rc: #c4573d; --rc-soft: #fbe8e6; --rc-ink: #7a2c20; }
.rating .rate-2 { --rc: #e0a63a; --rc-soft: #fdf1cf; --rc-ink: #6b4a00; }
.rating .rate-3 { --rc: #8a8f96; --rc-soft: #eeefef; --rc-ink: #3c4046; }
.rating .rate-4 { --rc: #4a9ea8; --rc-soft: #e3f3f5; --rc-ink: #1f5a61; }
.rating .rate-5 { --rc: #128449; --rc-soft: #e2f3e8; --rc-ink: #0b4a2a; }
.rating .stars { display: flex; gap: 1px; color: var(--rc); }
.rating .stars svg { width: 14px; height: 14px; }
.rating .choice .num { font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1; }
.rating .choice .lbl { font-size: 12px; color: var(--text-3); }
.rating .choice[aria-checked="true"] { background: var(--rc-soft); border-color: var(--rc); box-shadow: inset 0 0 0 1px var(--rc); color: var(--rc-ink); }
.rating .choice[aria-checked="true"] .lbl { color: var(--rc-ink); }

/* Switch */
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--tap); padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.switch .sw-text { display: grid; gap: 2px; }
.switch .sw-text strong { font-weight: 500; }
.switch .sw-text span { font-size: 13px; color: var(--text-3); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { flex: none; width: 52px; height: 30px; border-radius: 999px; background: #d8d4c9; position: relative; transition: background 200ms var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 200ms var(--ease); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(22px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Layout helpers ---------- */
.section { display: grid; gap: 18px; }
.section-head { display: flex; align-items: baseline; gap: 12px; padding-bottom: 4px; }
.section-head .step { font-family: var(--font-mono); font-size: 12px; color: var(--accent); letter-spacing: 0.08em; }
.section-head h2 { font-size: 26px; }
.section-head .opt { font-size: 13px; color: var(--text-3); margin-left: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.divider { height: 1px; background: var(--line); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: 12px; font-size: 15px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
  z-index: 60; max-width: min(92vw, 520px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* Skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 8px; color: transparent !important; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7), transparent); transform: translateX(-100%); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

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