/* ---------------------------------------------------------------
   iTallin Flat Vote — shared design
   Ground:  sage-tinted paper, white cards
   Accent:  pine (Felix, primary actions) · rose (Van) · gold (top picks)
   Display: Fraunces 600 (self-hosted) · UI/body: system sans
----------------------------------------------------------------*/

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fraunces.woff2') format('woff2');
}

:root {
  --paper: #f2f5ef;
  --card: #ffffff;
  --card-soft: #fbfcfa;
  --ink: #17241c;
  --muted: #5c6b61;
  --faint: #9aa79f;
  --line: #dee5da;
  --pine: #2e6b4f;
  --pine-strong: #235741;
  --pine-soft: #e4efe7;
  --rose: #a34d6d;
  --rose-soft: #f5e7ec;
  --gold: #c29a3b;
  --gold-deep: #8a6b1e;
  --gold-soft: #f6eedb;
  --danger: #b23b3b;
  --btn-fg: #ffffff;
  --hud-bg: rgba(242, 245, 239, 0.92);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 36, 28, 0.04), 0 8px 24px rgba(23, 36, 28, 0.06);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111814;
    --card: #1a231c;
    --card-soft: #1f2921;
    --ink: #e7ede6;
    --muted: #9bab9e;
    --faint: #6d7d70;
    --line: #2b372e;
    --pine: #6fb292;
    --pine-strong: #8ac4a8;
    --pine-soft: #22352a;
    --rose: #c97e9b;
    --rose-soft: #372430;
    --gold: #d3ac55;
    --gold-deep: #d3ac55;
    --gold-soft: #383019;
    --danger: #e07b7b;
    --btn-fg: #0e1511;
    --hud-bg: rgba(17, 24, 20, 0.92);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 26px 20px 84px;
}
/* Vote page: wide, so flats sit side by side for comparing */
.wrap.wide { max-width: 1160px; }

a { color: var(--pine-strong); }

/* ---------- Masthead ---------- */
.masthead { margin-bottom: 20px; }
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pine);
  font-weight: 600;
  margin: 0 0 8px;
}
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(28px, 6vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  text-wrap: balance;
}
.subtitle { color: var(--muted); margin: 0; font-size: 15px; }
.me-line { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.me-line a { color: var(--pine-strong); }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--muted); text-decoration: none; margin-bottom: 14px;
}
.back-link:hover { color: var(--ink); }

.egg { cursor: pointer; user-select: none; display: inline-block; transition: transform .12s ease; }
.egg:hover { transform: rotate(-8deg) scale(1.12); }
.egg:focus-visible { outline: 3px solid var(--pine); outline-offset: 3px; border-radius: 6px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 15px;
  padding: 12px 18px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: background 0.12s ease, opacity 0.12s ease;
}
.btn:focus-visible { outline: 3px solid var(--pine); outline-offset: 3px; }
.btn-primary { background: var(--pine); color: var(--btn-fg); }
.btn-primary:hover { background: var(--pine-strong); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--card); border-color: var(--faint); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- Sign-in ---------- */
.login-card h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0 0 4px; }
.code-row { display: flex; gap: 10px; }
.code-input {
  flex: 1; font: inherit; font-size: 18px; letter-spacing: .12em; text-transform: uppercase;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card-soft); color: var(--ink); min-width: 0;
}
.code-input:focus { outline: none; border-color: var(--pine); background: var(--card); }
.login-error { color: var(--danger); font-size: 14px; margin: 10px 0 0; min-height: 18px; }
@media (max-width: 420px) { .code-row { flex-direction: column; } }

/* ---------- Explainer ---------- */
.explainer summary {
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
}
.explainer summary::-webkit-details-marker { display: none; }
.explainer summary::after { content: '+'; margin-left: auto; color: var(--muted); font-family: var(--sans); font-size: 20px; }
.explainer[open] summary::after { content: '–'; }
.explainer p { margin: 12px 0; color: var(--muted); font-size: 14.5px; }
.explainer p:last-child { margin-bottom: 0; }
.explainer strong { color: var(--ink); }

.ladder { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 4px; max-width: 560px; }
.rung {
  display: flex; flex-direction: column; align-items: center;
  min-width: 64px; padding: 8px 6px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card-soft);
  flex: 1;
}
.rung .n { font-size: 12px; color: var(--muted); white-space: nowrap; }
.rung .c { font-family: var(--serif); font-weight: 600; font-size: 18px; font-variant-numeric: tabular-nums; }
.rung .m { font-size: 11px; color: var(--pine); font-variant-numeric: tabular-nums; }

/* ---------- Your picks overview ---------- */
.overview h2 {
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  margin: 0 0 6px; display: flex; align-items: baseline; gap: 10px;
}
.ov-hint { font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--faint); }
.ov-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 0; border-top: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
#overviewRows .ov-row:first-child { border-top: none; }
.ov-row:focus-visible { outline: 3px solid var(--pine); outline-offset: 2px; border-radius: 6px; }
.ov-votes {
  font-family: var(--serif); font-weight: 600; font-size: 17px;
  color: var(--pine); min-width: 34px; font-variant-numeric: tabular-nums;
}
.ov-street { flex: 1; font-weight: 600; }
.ov-row:hover .ov-street { color: var(--pine-strong); }
.ov-cost { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-total {
  border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px;
  font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
}

/* ---------- Credits HUD (sticky) ---------- */
.hud {
  position: sticky; top: 0; z-index: 5;
  background: var(--hud-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px 12px;
  margin: 0 -20px 18px;
}
.hud-inner { max-width: 1160px; margin: 0 auto; }
.hud-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hud-label { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.hud-count { font-family: var(--serif); font-weight: 600; font-size: 24px; font-variant-numeric: tabular-nums; }
.hud-count small { font-weight: 400; color: var(--muted); font-size: 13px; font-family: var(--sans); }
.meter { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--pine); transition: width 0.18s ease; }
.meter.low > span { background: var(--gold); }
.hud.low .hud-count { color: var(--gold-deep); }

/* ---------- Flat cards ---------- */
/* 1 column on phones, 2-3 side by side on wider screens */
#list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
#list .card { margin-bottom: 0; }

.apt { display: flex; flex-direction: column; gap: 10px; }
.apt .note-field { margin-top: auto; }
.apt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.apt-title { font-family: var(--serif); font-size: 19px; font-weight: 600; line-height: 1.2; }
.apt-title a { color: inherit; text-decoration: none; border-bottom: 2px solid var(--pine-soft); }
.apt-title a:hover { border-bottom-color: var(--pine); }
.apt-title .ext { font-size: 13px; color: var(--pine); }
.apt-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.chip-price { background: var(--gold-soft); color: var(--gold-deep); font-variant-numeric: tabular-nums; }
.chip-price[title] { cursor: help; }
.fee { font-size: 11.5px; border-bottom: 1px dotted currentColor; opacity: .9; }
.where .fee { color: var(--gold-deep); }
.chip-area { background: var(--pine-soft); color: var(--pine-strong); font-weight: 500; }
.chip-both { background: var(--pine-soft); color: var(--pine-strong); }
.chip-photos { background: var(--paper); color: var(--muted); font-weight: 500; }

/* ---------- Photo strip (vote cards) ---------- */
.strip {
  display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  margin: 2px 0; scrollbar-width: thin;
}
.strip a { flex: none; scroll-snap-align: start; border-radius: var(--radius-sm); }
.strip a:focus-visible { outline: 3px solid var(--pine); outline-offset: 2px; }
.strip img {
  height: 168px; width: auto; max-width: 100%;
  object-fit: cover; display: block;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--paper);
}

/* ---------- Result thumbnails ---------- */
.thumb-link { flex: none; border-radius: 10px; }
.thumb-link:focus-visible { outline: 3px solid var(--pine); outline-offset: 2px; }
.thumb {
  width: 48px; height: 48px; object-fit: cover; display: block;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--paper);
}

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: center; gap: 12px; }
.step-btn {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font-size: 24px; line-height: 1; color: var(--ink);
  display: grid; place-items: center; flex: none;
  transition: background .12s ease, border-color .12s ease;
}
.step-btn:hover:not([disabled]) { background: var(--pine-soft); border-color: var(--pine); }
.step-btn:focus-visible { outline: 3px solid var(--pine); outline-offset: 2px; }
.step-btn[disabled] { opacity: .35; cursor: not-allowed; }
.votes { flex: 1; text-align: center; }
.votes .v { font-family: var(--serif); font-size: 27px; font-weight: 600; display: block; line-height: 1.1; font-variant-numeric: tabular-nums; }
.votes .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.step-hint { text-align: center; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 18px; }
.step-hint .cost { color: var(--pine); font-weight: 600; }
.step-hint.maxed { color: var(--faint); }

.note-field textarea {
  width: 100%; resize: vertical; min-height: 0; height: 42px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--card-soft);
}
.note-field textarea::placeholder { color: var(--faint); }
.note-field textarea:focus { outline: none; border-color: var(--pine); background: var(--card); }

/* ---------- Bottom action bar ---------- */
.actions {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--hud-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  margin: 18px -20px -84px;
}
.actions-inner { max-width: 480px; margin: 0 auto; display: flex; gap: 10px; }
.actions-inner .btn { flex: 1; }
.save-hint { text-align: center; font-size: 13px; color: var(--muted); margin: 8px 0 0; min-height: 18px; }
.save-hint.ok { color: var(--pine-strong); }

/* ---------- Dashboard: people ---------- */
.people { display: grid; gap: 12px; }
@media (min-width: 520px) { .people { grid-template-columns: 1fr 1fr; } }

.person-card { display: flex; flex-direction: column; gap: 12px; margin-bottom: 0; }
.person-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 24px;
  background: var(--pine-soft);
  flex: none;
}
.person-name { font-family: var(--serif); font-size: 22px; font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px;
  width: fit-content;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pill.open { background: var(--paper); color: var(--muted); }
.pill.open .dot { background: var(--faint); }
.pill.done { background: var(--pine-soft); color: var(--pine-strong); }
.pill.done .dot { background: var(--pine); }

/* ---------- Results ---------- */
.banner {
  text-align: center;
  background: var(--pine); color: var(--btn-fg);
  border-color: var(--pine-strong);
}
.banner p { margin: 0; }
.banner .big { font-family: var(--serif); font-size: 20px; }
.banner .sub { margin-top: 6px; opacity: .9; font-size: 14px; }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin: 2px 0 6px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.result-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }
.result-row:first-child { border-top: none; }
.rank {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  font-family: var(--serif); font-weight: 600; font-size: 15px;
  background: var(--paper); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.result-row.top .rank { background: var(--gold-soft); color: var(--gold-deep); }
.result-head { display: flex; align-items: center; gap: 12px; }
.result-name { font-family: var(--serif); font-size: 18px; font-weight: 600; flex: 1; min-width: 0; }
.result-name a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
.result-name a:hover { border-bottom-color: var(--pine); }
.result-name .where { display: block; font-family: var(--sans); font-weight: 400; font-size: 12.5px; color: var(--muted); }
.result-total { font-family: var(--serif); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.result-total small { font-family: var(--sans); font-weight: 400; font-size: 12px; color: var(--muted); }

.bar { height: 10px; border-radius: 999px; background: var(--paper); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }

.result-notes { font-size: 13.5px; color: var(--muted); display: grid; gap: 4px; }
.result-notes b { color: var(--ink); font-weight: 600; }
.breakdown { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.cutline {
  text-align: center; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold-deep); margin: 6px 0 2px; font-weight: 600;
}
.spent-line { font-size: 13px; color: var(--muted); margin-top: 14px; font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 20; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); color: #fff; }

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