/* Shared design system — mobile-first, keyboard-friendly, print-aware.
   Pages may add page-specific rules in their own <style> block, but colors,
   spacing, and components come from here. */

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #26221c;
  --muted: #6f6a60;
  --line: #e4dfd5;
  --accent: #4a5fc1;        /* single accent hue — colorblind-safe */
  --accent-soft: #e6e9f8;
  --accent-ink: #354490;
  --gold: #7d5b13;  /* WCAG-AA 5.29:1 on the gold badge background (was #b98a2e, 2.65:1) */
  --radius: 14px;
  --shadow: 0 1px 3px rgba(30, 25, 15, .08), 0 6px 24px rgba(30, 25, 15, .06);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 880px; margin: 0 auto; padding: 16px 16px 80px; }
h1 { font-size: 1.7rem; line-height: 1.2; margin: .8em 0 .4em; }
h2 { font-size: 1.25rem; margin: 1.2em 0 .4em; }
h3 { font-size: 1.05rem; margin: 1em 0 .3em; }
p { margin: .5em 0; }
a { color: var(--accent-ink); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* top navigation */
.topnav {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.05rem; }
.navlinks { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.navlinks a {
  text-decoration: none; padding: 8px 12px; border-radius: 8px; color: var(--ink);
  min-height: 44px; display: inline-flex; align-items: center;
}
.navlinks a.active, .navlinks a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.linkbtn {
  background: none; border: none; font: inherit; color: var(--muted);
  cursor: pointer; padding: 8px 12px; border-radius: 8px; min-height: 44px;
}
.linkbtn:hover { background: var(--line); }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  font: inherit; font-weight: 600; padding: 12px 20px; cursor: pointer;
  min-height: 44px; text-decoration: none;
}
.btn:hover { background: var(--accent-ink); }
.btn.secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn.secondary:hover { background: var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, label:focus-within {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* forms */
input[type="text"], input[type="password"], input[type="number"] {
  font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  width: 100%; background: #fff; color: var(--ink);
}
label { font-weight: 600; display: block; margin: 12px 0 4px; }
.error { color: #a33b3b; font-weight: 600; margin: 8px 0; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }

/* score bars (see app.js scoreBar) */
.scorebar { margin: 10px 0; }
.scorebar-head { display: flex; justify-content: space-between; font-size: .95rem; }
.scorebar-label { font-weight: 600; }
.scorebar-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.scorebar-track {
  position: relative; height: 12px; border-radius: 6px; background: var(--line);
  overflow: hidden; margin-top: 4px;
}
.scorebar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.scorebar-marker { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); }
.scorebar-poles { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }

/* badges */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 600;
}
.badge.done { background: #e7f0e3; color: #3c6633; }
.badge.gold { background: #f5ecd7; color: var(--gold); }

/* skip link for keyboard users */
.skiplink {
  position: absolute; left: -9999px; top: 0; background: var(--card); padding: 10px 16px;
  z-index: 100; border-radius: 0 0 10px 0;
}
.skiplink:focus { left: 0; }

@media (max-width: 600px) {
  main { padding: 12px 12px 70px; }
  h1 { font-size: 1.45rem; }
}

@media print {
  .topnav, .noprint { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: none; }
}
