/* ==========================================================================
   FrugalMind EvalHub — styled to the GAIA HazLab design system
   (tokens mirrored from gaia-hazlab.github.io: UW Husky Purple on lavender)
   ========================================================================== */

:root {
  --ink: #2a1a4f;          /* deep purple ink / dark sections */
  --purple: #4b2e83;       /* UW Husky Purple */
  --purple-deep: #341f63;
  --peri: #6d5bd0;         /* periwinkle accent */
  --peri-light: #c3b8f0;   /* accent on dark bg */
  --stone: #6f6890;        /* muted purple-gray text */
  --lav: #f5f3fb;          /* light lavender page */
  --lav-2: #ece8f7;        /* lavender tint sections */
  --paper: #ffffff;
  --line: rgba(42, 26, 79, 0.10);

  /* categorical series — distinct in light mode */
  --c1: #4b2e83;  /* husky purple */
  --c2: #1b7f79;  /* teal */
  --c3: #c2571a;  /* burnt orange */
  --c4: #2f6fb2;  /* blue */
  --c5: #8a1f5e;  /* magenta */

  --shadow: 0 10px 30px rgba(42, 26, 79, 0.08);
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  line-height: 1.65;
  color: var(--ink);
  background: var(--lav);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand {
  font-family: 'Montserrat', 'Inter', system-ui, sans-serif;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

/* ---------- nav ---------- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0; gap: 16px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; color: var(--purple); text-decoration: none; font-size: 1.05rem;
}
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--purple); color: #fff; font-weight: 800; font-size: 0.85rem;
}
.nav-links { display: flex; gap: 20px; flex-wrap: wrap; }
.nav-links a {
  color: var(--stone); text-decoration: none; font-weight: 500; font-size: 0.94rem;
}
.nav-links a:hover { color: var(--purple); }

/* ---------- hero ---------- */
.hero {
  background: linear-gradient(160deg, var(--ink) 0%, var(--purple-deep) 55%, var(--purple) 100%);
  color: #fff;
  border-radius: 0 0 28px 28px;
  padding: 0 0 56px;
  margin-bottom: 48px;
}
.hero .nav { border-bottom: 1px solid rgba(255,255,255,0.12); }
.hero .brand, .hero .nav-links a { color: #fff; }
.hero .brand-mark { background: rgba(255,255,255,0.16); }
.hero .nav-links a:hover { color: var(--peri-light); }

.hero-inner { padding-top: 52px; max-width: 62ch; }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 0.72rem; font-weight: 700; color: var(--peri-light); margin-bottom: 14px;
}
.hero h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); font-weight: 800; margin-bottom: 18px; }
.hero p { color: #ded8f2; font-size: 1.06rem; }
.hero-actions { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }

.button {
  display: inline-block; padding: 11px 20px; border-radius: 999px;
  font-weight: 600; font-size: 0.94rem; text-decoration: none;
  border: 1px solid transparent; cursor: pointer;
}
.button.primary { background: #fff; color: var(--purple); }
.button.primary:hover { background: var(--peri-light); }
.button.secondary { border-color: rgba(255,255,255,0.35); color: #fff; }
.button.secondary:hover { border-color: #fff; }

/* ---------- sections ---------- */
section { margin-bottom: 56px; }
.section-head { max-width: 70ch; margin-bottom: 26px; }
.section-head .eyebrow { color: var(--peri); }
.section-head h2 { font-size: clamp(1.4rem, 2.8vw, 2rem); font-weight: 700; margin-bottom: 10px; }
.lede { color: var(--stone); font-size: 1.02rem; }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px;
}

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-3 h3 { font-size: 1.05rem; margin-bottom: 8px; color: var(--purple); }
.grid-3 p { color: var(--stone); font-size: 0.94rem; }

/* ---------- categories ---------- */
.cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cat .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.cat h3 { display: flex; align-items: center; font-size: 1.05rem; margin-bottom: 8px; }
.cat p { color: var(--stone); font-size: 0.93rem; margin-bottom: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.74rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--lav-2); color: var(--purple); border: 1px solid var(--line);
}
.tag.soon { background: transparent; color: var(--stone); border-style: dashed; }

/* ---------- chart ---------- */
.chart-card { padding: 22px 22px 14px; }
.chart-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 0.82rem; font-weight: 600; padding: 6px 13px; border-radius: 999px;
  background: var(--lav-2); color: var(--purple); border: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.chip[aria-pressed="true"] { background: var(--purple); color: #fff; border-color: var(--purple); }
.downloads { display: flex; gap: 8px; }
.btn-sm {
  font-size: 0.82rem; font-weight: 600; padding: 6px 13px; border-radius: 8px;
  background: var(--paper); color: var(--purple); border: 1px solid var(--peri);
  cursor: pointer;
}
.btn-sm:hover { background: var(--lav-2); }

#chart { width: 100%; height: auto; display: block; }
.chart-note { color: var(--stone); font-size: 0.86rem; margin-top: 8px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 0.85rem; color: var(--stone); }
.legend-swatch { width: 11px; height: 11px; border-radius: 50%; }

.axis line, .axis path { stroke: var(--line); }
.axis text { fill: #6f6890; font-size: 11px; font-family: 'Inter', sans-serif; }
.axis-label { fill: #2a1a4f; font-size: 12px; font-weight: 600; font-family: 'Inter', sans-serif; }
.gridline { stroke: rgba(42,26,79,0.06); }
.lift-line { stroke-width: 1.6; opacity: 0.5; }
.pt { cursor: pointer; }
.pt:hover { stroke: #2a1a4f; stroke-width: 2; }

#tooltip {
  position: fixed; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: var(--ink); color: #fff; padding: 10px 12px; border-radius: 10px;
  font-size: 0.82rem; line-height: 1.55; max-width: 300px; z-index: 50;
  box-shadow: 0 10px 26px rgba(0,0,0,0.25);
}
#tooltip b { color: var(--peri-light); }
#tooltip .kv { color: #cfc7ea; }

/* ---------- callout ---------- */
.callout {
  background: var(--lav-2); border-left: 4px solid var(--peri);
  border-radius: 12px; padding: 20px 22px;
}
.callout h3 { font-size: 1.02rem; margin-bottom: 8px; color: var(--purple-deep); }
.callout p { color: var(--ink); font-size: 0.95rem; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em; background: rgba(75,46,131,0.08);
  padding: 1px 5px; border-radius: 5px; color: var(--purple-deep);
}

/* ---------- contribute ---------- */
.steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.step { display: flex; gap: 14px; }
.step-n {
  flex: 0 0 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--purple); color: #fff; font-weight: 700; font-size: 0.85rem;
}
.step h3 { font-size: 1rem; margin-bottom: 5px; }
.step p { color: var(--stone); font-size: 0.92rem; }

pre {
  background: var(--ink); color: #e8e3f6; padding: 14px 16px; border-radius: 12px;
  overflow-x: auto; font-size: 0.83rem; line-height: 1.6; margin-top: 14px;
}
pre code { background: none; color: inherit; padding: 0; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line); padding: 26px 0 44px; margin-top: 40px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--stone); font-size: 0.9rem;
}
.site-footer a { color: var(--purple); text-decoration: none; }
.meta-line { color: var(--stone); font-size: 0.85rem; }

@media (max-width: 900px) {
  .grid-3, .cats, .steps { grid-template-columns: 1fr; }
  .chart-toolbar { flex-direction: column; align-items: flex-start; }
}

.errbar { stroke-linecap: round; }

/* Legend: two independent encodings (colour = model, shape = task) plus the
   skill fill. Grouping them is what makes the chart readable without prose. */
.legend { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 14px; align-items: flex-start; }
.legend-group { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.legend-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--purple); white-space: nowrap;
}
.legend-shape { flex: 0 0 14px; overflow: visible; }

/* ---------- data table (mobile-first read + screen-reader path) ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.data-table-wrap { margin-top: 16px; }
.data-table-wrap > summary {
  cursor: pointer; font-size: 0.86rem; font-weight: 600; color: var(--purple);
  padding: 6px 0; user-select: none;
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th, .data-table td {
  padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th[scope="col"] { color: var(--purple); font-weight: 700; }
.data-table th[scope="row"], .data-table td:nth-child(2) {
  text-align: left; font-weight: 600;
}
.data-table tbody tr:hover { background: var(--lav-2); }

/* ==========================================================================
   Mobile — the chart is an SVG that downscales; the JS also switches to a
   narrower viewBox with larger type under 700px. These rules handle the rest of
   the page furniture so nothing overflows a phone screen.
   ========================================================================== */
@media (max-width: 700px) {
  .shell { width: calc(100% - 24px); }

  .hero { border-radius: 0 0 20px 20px; padding-bottom: 36px; margin-bottom: 32px; }
  .hero-inner { padding-top: 32px; }
  .nav-links { gap: 12px; font-size: 0.86rem; }
  .nav-links a:nth-child(n+4) { display: none; }  /* keep nav to one line */

  .grid-3, .cats, .steps { grid-template-columns: 1fr; }
  section { margin-bottom: 40px; }

  .chart-card { padding: 14px 12px 10px; }
  .chart-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .filters { gap: 6px; }
  .chip, .btn-sm { font-size: 0.78rem; padding: 7px 12px; }  /* >=44px tap target height with line-box */
  .downloads { justify-content: flex-end; }

  /* Legend: stack the encoding groups vertically so labels never truncate. */
  .legend { flex-direction: column; gap: 10px; }
  .legend-group { gap: 10px; }

  /* On a phone the table is the PRIMARY read, so open it by default. */
  .data-table-wrap[open] > summary { margin-bottom: 4px; }
}

/* The whole point of the tooltip is touch reachability; make sure it can never
   sit off-screen or overflow on a narrow viewport. */
@media (max-width: 700px) {
  #tooltip { max-width: min(300px, calc(100vw - 24px)); font-size: 0.8rem; }
}
