/* ── Tokens ─────────────────────────────────────────── */
:root {
  --teal:   #1B4D5C;
  --teal-light: #2A6B7F;
  --cream:  #F7F2E8;
  --rose:   #D4846A;
  --sage:   #8BAF8D;
  --ink:    #1A1A1A;
  --muted:  #6B6B6B;
  --border: #DDD8CC;
  --card-bg: #FFFFFF;

  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;

  --radius: 12px;
  --max-w:  1080px;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
.is-hidden { display: none !important; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Nav ────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: var(--teal);
}
.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
}
.nav-logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--cream);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav-link {
  color: rgba(247, 242, 232, 0.8);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}
.nav-link:hover { color: var(--cream); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-user {
  color: rgba(247, 242, 232, 0.75);
  font-size: 0.9rem;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-primary { background: var(--rose); color: var(--ink); }
.btn-ghost   { background: transparent; color: var(--cream); border: 1.5px solid rgba(247,242,232,0.4); }
.btn-outline { background: transparent; color: var(--teal); border: 1.5px solid var(--teal); }

/* ── Banners ────────────────────────────────────────── */
.banner {
  max-width: var(--max-w);
  margin: 1.5rem auto 0;
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.92rem;
}
.banner-notice {
  background: #FBF0DE;
  border: 1px solid #E8CE9C;
  color: #6B4E1E;
}

/* ── Error page ─────────────────────────────────────── */
.error-page {
  max-width: 520px;
  margin: 4rem auto;
  text-align: center;
}
.error-page h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--teal);
  margin-bottom: 0.75rem;
}
.error-page p { color: var(--muted); margin-bottom: 1.5rem; }

/* ── Pattern picker ─────────────────────────────────── */
.pattern-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.pattern-picker-row { display: flex; flex-direction: column; gap: 0.4rem; flex: 1 1 220px; }
.pattern-picker-row label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.pattern-picker-row select {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--ink);
}
.pattern-picker-actions { display: flex; gap: 0.75rem; }

/* ── Pattern results ────────────────────────────────── */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.pattern-card {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s;
}
.pattern-card:hover { transform: translateY(-2px); }
.pattern-card-link { display: flex; flex-direction: column; flex: 1; text-decoration: none; color: inherit; }
.colorway-edit-link {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal);
  text-decoration: none;
}
.colorway-edit-link:hover { text-decoration: underline; }
.pattern-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--cream); }
.pattern-thumb-placeholder { display: block; }
.pattern-card-body { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.9rem 1rem 1.1rem; }
.pattern-name { font-weight: 600; font-size: 0.95rem; }
.pattern-badge {
  align-self: flex-start;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: var(--teal);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

/* ── Hero ───────────────────────────────────────────── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 5rem 2rem 4rem;
  max-width: var(--max-w);
  margin: 0 auto;
}
.yarn-ball {
  width: 96px;
  height: 96px;
  margin-bottom: 2rem;
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  color: var(--teal);
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}
.hero-title em {
  font-style: italic;
  color: var(--rose);
}
.hero-subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  line-height: 1.7;
  max-width: 560px;
  margin-bottom: 2.25rem;
}
.hero-note {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Feature cards ──────────────────────────────────── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  max-width: var(--max-w);
  margin: 0 auto 5rem;
  padding: 0 2rem;
}
.feature-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
}
.feature-icon { font-size: 1.75rem; margin-bottom: 0.75rem; }
.feature-card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--teal);
  margin-bottom: 0.5rem;
}
.feature-card p { font-size: 0.9rem; color: var(--muted); line-height: 1.6; }

/* ── Dashboard ──────────────────────────────────────── */
.dashboard {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}
.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}
.dashboard-header h1 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  color: var(--teal);
  letter-spacing: -0.02em;
}
.dashboard-subtitle { color: var(--muted); margin-top: 0.4rem; }

/* Stat row */
.stat-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--teal);
  color: var(--cream);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 140px;
}
.stat-number {
  font-family: var(--font-display);
  font-size: 2.25rem;
  line-height: 1;
}
.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.stat-fun-fact {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}
.stat-fun-fact-link {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}
.stat-fun-fact-link:hover {
  opacity: 1;
}

/* Chart row */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}
@media (max-width: 600px) { .chart-row { grid-template-columns: 1fr; } }
.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.chart-card h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--teal);
  margin-bottom: 1rem;
}
.chart-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.chart-card-header h2 { margin-bottom: 0; }
.chart-card-stat {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--rose);
  white-space: nowrap;
}
.chart-card-stat-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-canvas-wrap {
  position: relative;
  height: 200px;
}
.chart-canvas-wrap--tall {
  height: 360px;
}
.chart-card--wide { grid-column: 1 / -1; }
.chart-granularity-toggle {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem;
  margin-bottom: 1.25rem;
}
.granularity-btn {
  background: none;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.granularity-btn.is-active { background: var(--teal); color: var(--cream); }
.chart-caveat {
  margin-top: 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.chart-caveat-link {
  background: none;
  border: none;
  padding: 0;
  margin-left: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--teal);
  text-decoration: underline;
  cursor: pointer;
}
.missing-yardage-hint { margin-bottom: 1rem; }
.missing-yardage-list { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.missing-yardage-list a { color: var(--teal); font-weight: 600; text-decoration: none; }
.missing-yardage-list a:hover { text-decoration: underline; }
.chart-empty {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 1.5rem 0;
}

/* Visually hidden until a keyboard user tabs into it — this is how the chart's
   screen-reader text alternative and keyboard-operable drill-down access live
   in the DOM without adding visual clutter for sighted mouse users, who
   already have the chart itself. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  margin: -1px;
  padding: 0;
}
.visually-hidden:focus-within {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
  margin: 0.75rem 0 0;
}
.chart-a11y-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
}
.chart-a11y-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
}
.chart-a11y-btn:hover { background: var(--border); }

/* Drill-down dialog */
.entries-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, 90vw);
  max-height: 80vh;
  margin: auto;
  background: var(--card-bg);
  color: var(--ink);
}
.entries-dialog::backdrop {
  background: rgba(26, 26, 26, 0.45);
}
.entries-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.entries-dialog-header h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--teal);
}
.entries-dialog-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
}
.entries-dialog-body {
  padding: 0.5rem 1.5rem 1.5rem;
  overflow-y: auto;
  max-height: calc(80vh - 4.5rem);
}
.entry-thumb-placeholder {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--cream);
  flex-shrink: 0;
}
.entry-name { font-size: 0.92rem; font-weight: 500; color: inherit; text-decoration: none; }
.entry-meta { font-size: 0.8rem; color: var(--muted); }
.entry-group { padding: 0.85rem 0; border-bottom: 1px solid var(--border); }
.entry-group:last-child { border-bottom: none; }
.entry-group-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.15rem;
  margin-bottom: 0.6rem;
}
.entry-group-title:hover { text-decoration: underline; }
.entry-group-header .entry-meta { grid-column: 1; }
.entry-group-find-btn {
  grid-column: 2;
  grid-row: 1 / 3;
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
}
.entry-group:hover .entry-group-find-btn { opacity: 1; visibility: visible; }
.entry-group-thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.entry-group-thumb-wrap {
  position: relative;
  display: block;
  width: 40px;
  height: 40px;
}
.entry-group-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--cream);
  display: block;
}
.entry-group-thumb-skeins {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(26, 26, 26, 0.75);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 5px;
  opacity: 0;
  transition: opacity 0.1s;
  pointer-events: none;
}
.entry-group-thumb-wrap:hover .entry-group-thumb-skeins { opacity: 1; }

/* Coming soon */
.coming-soon {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.coming-soon h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--teal);
  margin-bottom: 1rem;
}
.coming-soon ul { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; }
.coming-soon li { font-size: 0.95rem; color: var(--muted); }

/* ── Footer ─────────────────────────────────────────── */
.footer {
  margin-top: auto;
  text-align: center;
  padding: 1.5rem 2rem;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.footer a { color: var(--teal); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
