/* ---------------------------------------------------------------------------
   Tokens. Light is the base; dark redefines only the values, never the rules,
   so nothing can be defined in one theme and missing in the other.
   --------------------------------------------------------------------------- */

:root {
  --bg: #fbfbf9;
  --bg-raised: #ffffff;
  --bg-sunken: #f2f2ee;
  --border: #e2e2dc;
  --border-strong: #cdcdc4;
  --text: #16160f;
  --text-muted: #5f5f57;
  --text-faint: #8c8c82;
  --accent: #b4441f;
  --accent-soft: #f6e4dc;
  --grid-0: #ebebe4;
  --grid-1: #dfd0c0;
  --grid-2: #d09a72;
  --grid-3: #bd6a3a;
  --grid-4: #a5401a;

  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;

  --measure: 68ch;
  --radius: 6px;
  --shell: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #100f0d;
    --bg-raised: #1a1917;
    --bg-sunken: #080807;
    --border: #2b2a26;
    --border-strong: #3d3b36;
    --text: #f0efe9;
    --text-muted: #a5a29a;
    --text-faint: #6f6d66;
    --accent: #e07a4e;
    --accent-soft: #2e1d14;
    --grid-0: #1e1d1a;
    --grid-1: #452b1c;
    --grid-2: #7a4526;
    --grid-3: #b1642f;
    --grid-4: #e6884d;
  }
}

:root[data-theme='dark'] {
  --bg: #100f0d;
  --bg-raised: #1a1917;
  --bg-sunken: #080807;
  --border: #2b2a26;
  --border-strong: #3d3b36;
  --text: #f0efe9;
  --text-muted: #a5a29a;
  --text-faint: #6f6d66;
  --accent: #e07a4e;
  --accent-soft: #2e1d14;
  --grid-0: #1e1d1a;
  --grid-1: #452b1c;
  --grid-2: #7a4526;
  --grid-3: #b1642f;
  --grid-4: #e6884d;
}

/* --------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

/* `.card` sets display:flex, which beats the user-agent rule for [hidden].
   Filtering sets el.hidden, so this has to win. */
[hidden] { display: none !important; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.shell {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: 24px;
}

@media (max-width: 640px) {
  .shell { padding-inline: 18px; }
}

/* --- top bar --------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
}

.brand {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 1px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a, .theme-toggle {
  padding: 7px 11px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.nav a:hover, .theme-toggle:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

@media (max-width: 620px) {
  .nav a[data-optional] { display: none; }
}

/* --- hero ------------------------------------------------------------------ */

.hero { padding-block: clamp(56px, 11vw, 116px) clamp(40px, 7vw, 72px); }

.hero__eyebrow {
  margin: 0 0 20px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.hero h1 {
  margin: 0 0 24px;
  max-width: 19ch;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6.2vw, 4.1rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.022em;
}

.hero p {
  margin: 0;
  max-width: var(--measure);
  font-size: clamp(1.02rem, 1.9vw, 1.17rem);
  color: var(--text-muted);
}

.hero__links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 32px;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.button:hover { border-color: var(--accent); color: var(--accent); }

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button--primary:hover { color: #fff; filter: brightness(1.08); }

/* --- sections -------------------------------------------------------------- */

.section { padding-block: clamp(44px, 7vw, 76px); border-top: 1px solid var(--border); }

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 30px;
}

.section__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.1vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.018em;
}

.section__note {
  margin: 0;
  max-width: 46ch;
  font-size: 14px;
  color: var(--text-faint);
}

/* --- stat strip ------------------------------------------------------------ */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat { background: var(--bg-raised); padding: 18px 20px; }

.stat__value {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3.4vw, 1.95rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--text-faint);
}

/* --- project cards --------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 24px;
}

.chip {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  text-decoration: none;
  transition: border-color 0.14s ease, transform 0.14s ease;
}

.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.card__name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.card__stars {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.card__desc {
  margin: 0 0 16px;
  flex: 1;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: -1px;
}

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 14px; }

.tag {
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--bg-sunken);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.empty {
  padding: 40px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-faint);
  font-size: 14.5px;
}

/* --- dashboard ------------------------------------------------------------- */

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.panel {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.panel__title {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.panel--wide { grid-column: 1 / -1; }

.heatmap-scroll { overflow-x: auto; padding-bottom: 6px; }

.heatmap { display: block; min-width: 660px; }

.heatmap rect { rx: 2; }

.heatmap__legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-faint);
}

.heatmap__swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
}

.bars { display: flex; flex-direction: column; gap: 11px; }

.bar__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 13px;
}

.bar__name { font-weight: 500; }

.bar__value {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.bar__track {
  height: 6px;
  border-radius: 100px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.bar__fill { height: 100%; border-radius: 100px; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
  padding: 0 10px 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: left;
}

.table td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.table td:first-child { color: var(--text); font-weight: 500; }

.table .num {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding-right: 0;
}

/* --- prose ----------------------------------------------------------------- */

.prose { max-width: var(--measure); }

.prose p { margin: 0 0 17px; color: var(--text-muted); }

.prose strong { color: var(--text); font-weight: 600; }

.prose a { color: var(--accent); text-underline-offset: 3px; }

/* --- footer ---------------------------------------------------------------- */

.footer {
  padding-block: 34px 46px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-faint);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer a { color: var(--text-muted); }

.mono { font-family: var(--font-mono); }

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

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

/* --- provenance ------------------------------------------------------------
   Marks a project the forge pipeline produced. Quiet by design: it is a fact
   the reader should have, not a disclaimer that shouts over the work.
   --------------------------------------------------------------------------- */

.provenance {
  margin: 0 0 11px;
  padding: 3px 9px;
  align-self: flex-start;
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-faint);
}

/* A five-column table does not fit a 400px phone. It gets its own scroll
   container so the table scrolls sideways and the page body never does. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll .table { min-width: 420px; }
