/*
  base.css — tokens and shared pieces for Shaking it Up.
  Malted cream and cocoa, strawberry for actions, caramel and pistachio for
  scores. The rating line you drag a bead along is the signature element and
  shows up everywhere: full size when rating, small and read-only in lists.
*/

@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f8f3ea;
  --card: #fffdf9;
  --ink: #2f1f18;
  --ink-soft: #6d5748;
  --line: #e3d6c6;
  --berry: #cf3b57;
  --berry-press: #b22f48;
  --caramel: #b9761f;
  --pistachio: #47795a;
  --malt: #efe3d1;

  --great: #47795a;
  --good: #7a8f3c;
  --fair: #b9761f;
  --poor: #cf3b57;
  --on-accent: #fffdf9;

  --font-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(47, 31, 24, 0.07), 0 8px 20px rgba(47, 31, 24, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17100d;
    --card: #221913;
    --ink: #f4ebdf;
    --ink-soft: #b9a698;
    --line: #3b2c23;
    --berry: #ef6a84;
    --berry-press: #f58197;
    --caramel: #e0a44a;
    --pistachio: #86bb93;
    --malt: #2e231b;

    --great: #86bb93;
    --good: #b7c76a;
    --fair: #e0a44a;
    --poor: #ef6a84;
    --on-accent: #23110f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(1.8rem, 6vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0; }
a { color: var(--berry); text-underline-offset: 3px; }

:focus-visible { outline: 3px solid var(--caramel); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.muted { color: var(--ink-soft); }
.small { font-size: 0.9rem; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 22px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Scores ---------- */
.score {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
}
.score-value { font-size: inherit; }
.score-out { font-size: 0.42em; font-weight: 600; color: var(--ink-soft); letter-spacing: 0; }
.score.big { font-size: clamp(3rem, 14vw, 4.4rem); }
.score.medium { font-size: 2.1rem; }
.score.small { font-size: 1.4rem; }
.score.great .score-value { color: var(--great); }
.score.good .score-value { color: var(--good); }
.score.fair .score-value { color: var(--fair); }
.score.poor .score-value { color: var(--poor); }
.score.none .score-value { color: var(--ink-soft); }

/* ---------- The rating dial: a bead on a line ---------- */
.dial { display: block; }
.dial + .dial { margin-top: 18px; }
.dial-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dial-label { font-weight: 600; }
.dial-read {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.dial-track {
  position: relative;
  height: 44px;
  margin: 2px 0;
  touch-action: pan-y;
  cursor: pointer;
}
.dial-track::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 8px;
  margin-top: -4px;
  border-radius: 999px;
  background: var(--malt);
  box-shadow: inset 0 0 0 1px var(--line);
}
.dial-fill {
  position: absolute;
  left: 0; top: 50%;
  height: 8px;
  margin-top: -4px;
  border-radius: 999px;
  background: var(--caramel);
}
.dial-bead {
  position: absolute;
  top: 50%;
  width: 30px; height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 0 0 3px var(--berry), 0 2px 6px rgba(47, 31, 24, 0.25);
}
.dial-track:active .dial-bead { box-shadow: 0 0 0 4px var(--berry), 0 2px 10px rgba(47, 31, 24, 0.3); }
.dial-sweet {
  position: absolute;
  top: 50%;
  width: 2px; height: 18px;
  margin: -9px 0 0 -1px;
  background: var(--pistachio);
  border-radius: 1px;
}
.dial-ends { display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; color: var(--ink-soft); }
.dial-ends span:last-child { text-align: right; }
.dial.unset .dial-fill { background: var(--line); }
.dial.unset .dial-bead { box-shadow: 0 0 0 2px var(--line); }

.dial.mini .dial-track { height: 14px; }
.dial.mini .dial-track::before, .dial.mini .dial-fill { height: 6px; margin-top: -3px; }
.dial.mini .dial-bead { width: 12px; height: 12px; margin: -6px 0 0 -6px; box-shadow: 0 0 0 2px var(--berry); }
.dial.mini .dial-head { font-size: 0.85rem; }
.dial.mini .dial-ends { display: none; }
.dial.mini + .dial.mini { margin-top: 8px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--r-md);
  background: var(--berry);
  color: var(--on-accent);
  font: 600 1rem/1.2 var(--font-ui);
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { background: var(--berry-press); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--malt); color: var(--ink); }
.btn.secondary:hover { background: var(--line); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { background: var(--malt); }
.btn.danger { background: transparent; color: var(--poor); box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 0.92rem; }
.btn.block { width: 100%; }
.link-btn {
  appearance: none; background: none; border: 0; padding: 0;
  color: var(--berry); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--malt); }
.icon-btn svg, .icon svg { width: 22px; height: 22px; }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 0.95rem; }
.field .hint { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.88rem; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: 1rem/1.4 var(--font-ui);
}
textarea.input { min-height: 90px; resize: vertical; }
.input[aria-invalid] { border-color: var(--poor); }
.input:focus { border-color: var(--caramel); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--caramel) 35%, transparent); }
.fields-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 430px) { .fields-2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 12px; align-items: center; min-height: 46px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--berry); flex: none; }

.choice { display: flex; flex-wrap: wrap; gap: 8px; }
.choice label {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; min-height: 44px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px var(--line);
  cursor: pointer;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label:has(input:checked) { background: var(--berry); color: var(--on-accent); box-shadow: none; }
.choice label:has(input:focus-visible) { outline: 3px solid var(--caramel); outline-offset: 2px; }

/* ---------- Surfaces ---------- */
.card { background: var(--card); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow); }
.notice { border-radius: var(--r-md); padding: 12px 14px; background: var(--malt); }
.notice.warn { background: color-mix(in srgb, var(--poor) 14%, transparent); color: var(--poor); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 10px;
  font-size: 0.85rem; background: var(--malt); color: var(--ink); white-space: nowrap;
}
.chip.good { background: color-mix(in srgb, var(--great) 18%, transparent); color: var(--great); }
.chip.bad { background: color-mix(in srgb, var(--poor) 14%, transparent); color: var(--poor); }

/* ---------- Dialog sheet ---------- */
dialog.sheet {
  border: 0; padding: 0;
  width: min(560px, 100%);
  max-width: 100%;
  max-height: min(92dvh, 900px);
  border-radius: var(--r-lg);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog.sheet::backdrop { background: rgba(23, 16, 13, 0.55); }
.sheet-inner { display: flex; flex-direction: column; max-height: inherit; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; }
.sheet-body { padding: 16px; overflow: auto; }
.sheet-foot {
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
@media (max-width: 640px) {
  dialog.sheet { margin: auto 0 0; width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  dialog.sheet[open] { animation: sheet-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1); }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 900;
  width: min(92vw, 460px); pointer-events: none;
}
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--r-md); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); }
.toast.warn { background: var(--poor); color: #fff; }

.loading { min-height: 60vh; display: grid; place-items: center; color: var(--ink-soft); }

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