/* SB'Labs : palette gruvbox (spt-gruvbox de SB'Music), angles droits, monospace. */

:root {
  --bg: #1d2021;
  --bg-2: #282828;
  --bg-3: #32302f;
  --line: #3c3836;
  --line-2: #504945;
  --ink: #ebdbb2;
  --ink-2: #bdae93;
  --muted: #928374;
  --accent: #fabd2f;
  --accent-ink: #1d2021;
  --red: #fb4934;

  --st-stable: #b8bb26;
  --st-experimental: #fe8019;
  --st-planned: #83a598;
  --st-archived: #928374;

  --font: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --wrap: 1180px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fbf1c7;
    --bg-2: #f2e5bc;
    --bg-3: #ebdbb2;
    --line: #d5c4a1;
    --line-2: #bdae93;
    --ink: #282828;
    --ink-2: #504945;
    --muted: #7c6f64;
    --accent: #b57614;
    --accent-ink: #fbf1c7;
    --red: #9d0006;
    --st-stable: #79740e;
    --st-experimental: #af3a03;
    --st-planned: #076678;
    --st-archived: #7c6f64;
    color-scheme: light;
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Scanlines discrètes, rappel du thème SB'Music. */
.scan {
  position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0,0,0,.08) 2px 3px);
  mix-blend-mode: multiply;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

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

/* ── En-tête ─────────────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }

.brand { display: inline-flex; align-items: center; font-weight: 800; font-size: 20px; color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-avatar { width: 36px; height: 36px; border: 2px solid var(--accent); margin-right: 10px; object-fit: cover; }


/* ── Hero ────────────────────────────────────────────── */
.hero { padding-top: 32px; padding-bottom: 24px; }
@media (min-width: 720px) { .hero { padding-top: 48px; } }

/* Compteurs = filtres d'état */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border: 1px solid var(--line); }
.stat:first-child { grid-column: span 2; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(5, 1fr); } .stat:first-child { grid-column: auto; } }

.stat {
  appearance: none; border: 0; background: transparent; color: inherit; font: inherit;
  text-align: left; cursor: pointer; padding: 18px 20px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  position: relative; transition: background .15s;
}
.stat:hover { background: var(--bg-2); }
.stat[aria-pressed="true"] { background: var(--bg-3); }
.stat[aria-pressed="true"]::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--accent));
}
.stat-n { display: block; font-size: 32px; font-weight: 800; line-height: 1.1; color: var(--c, var(--ink)); font-variant-numeric: tabular-nums; }
.stat-l { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--ink-2); margin-top: 4px; }

/* ── Contrôles ───────────────────────────────────────── */
.controls {
  display: flex; flex-direction: column; gap: 12px;
  padding: 24px 0 8px; border-top: 1px dashed var(--line); margin-top: 8px;
}
@media (min-width: 860px) { .controls { flex-direction: row; align-items: center; } }

.search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line-2); background: var(--bg-2); padding: 0 14px; height: 44px;
}
.search:focus-within { border-color: var(--accent); }
.prompt { color: var(--accent); font-weight: 700; }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; outline: none; height: 100%;
}
.search input::placeholder { color: var(--muted); }

.selects { display: flex; gap: 12px; }
.selects label { flex: 1; }
select {
  width: 100%; height: 44px; padding: 0 36px 0 12px; font: inherit; font-size: 13px;
  color: var(--ink); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 0;
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--accent) 50%), linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
select:focus { border-color: var(--accent); outline: none; }
@media (min-width: 860px) { select { min-width: 190px; } }

.count { color: var(--muted); font-size: 12px; margin: 12px 0 16px; text-transform: uppercase; letter-spacing: .16em; }

/* ── Grille de projets ───────────────────────────────── */
.grid { display: grid; grid-template-columns: 1fr; gap: 16px; padding-bottom: 80px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  --c: var(--st-stable);
  appearance: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-top: 3px solid var(--c);
  padding: 20px; min-height: 230px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  animation: rise .35s both;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-2); border-top-color: var(--c); box-shadow: 6px 6px 0 var(--bg-3); }
.card:focus-visible { outline-offset: 3px; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.card[data-status="experimental"] { --c: var(--st-experimental); }
.card[data-status="planned"] { --c: var(--st-planned); }
.card[data-status="archived"] { --c: var(--st-archived); }
.card[data-status="archived"] .card-name { color: var(--ink-2); }

.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--c); font-weight: 700;
}
.badge::before { content: ""; width: 7px; height: 7px; background: var(--c); }
.card[data-status="planned"] .badge::before { background: transparent; outline: 1px solid var(--c); outline-offset: -1px; }

.cat { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }

.card-name { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
.card-name small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.card-tag { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.55; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: auto 0 0; padding: 0; }
.tags li { font-size: 11px; padding: 2px 8px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }

.card-next {
  font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin: 0;
}
.card-next b { color: var(--c); font-weight: 500; }

.empty { color: var(--ink-2); padding: 40px 0 120px; text-align: center; }
.link { appearance: none; background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }

/* ── Fiche détaillée ─────────────────────────────────── */
dialog {
  --c: var(--accent);
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line-2); border-top: 4px solid var(--c);
  background: var(--bg-2); color: var(--ink);
  box-shadow: 10px 10px 0 rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(29, 32, 33, .78); backdrop-filter: blur(3px); }
dialog[open] { animation: rise .2s both; }

.sheet { padding: 24px; }
@media (min-width: 640px) { .sheet { padding: 32px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.sheet-meta { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--c); font-weight: 700; }
.sheet h2 { margin: 0; font-size: 30px; letter-spacing: -.03em; line-height: 1.1; }
.sheet h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); margin: 28px 0 10px; font-weight: 500; }
.sheet-tag { color: var(--ink-2); margin: 14px 0 0; }
.sheet-list { margin: 0; padding: 0; list-style: none; }
.sheet-list li { padding-left: 20px; position: relative; margin-bottom: 6px; }
.sheet-list li::before { content: "▸"; position: absolute; left: 0; color: var(--c); }
.sheet-next { margin: 0; padding: 12px 14px; background: var(--bg-3); border-left: 3px solid var(--c); }
.sheet .tags { margin: 0; }
.sheet-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.sheet-links:empty { display: none; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px;
  border: 1px solid var(--accent); color: var(--accent); font-size: 12px;
  text-transform: uppercase; letter-spacing: .16em; font-weight: 700;
}
.btn:hover { background: var(--accent); color: var(--accent-ink); text-decoration: none; }

.close {
  appearance: none; border: 1px solid var(--line-2); background: transparent; color: var(--ink-2);
  width: 36px; height: 36px; font-size: 22px; line-height: 1; cursor: pointer; flex: none;
}
.close:hover { color: var(--ink); border-color: var(--ink-2); }

/* ── Pied de page ────────────────────────────────────── */
.foot { border-top: 1px solid var(--line); padding: 24px 0; font-size: 12px; color: var(--ink-2); }
.foot-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
