/* ============================================================
   rampant.io — baseline UI
   Subsites inherit this and add only what's specific to them.
   ============================================================ */

/* --- Tokens ------------------------------------------------
   One definition per token via light-dark(); the theme toggle
   only ever changes `color-scheme`. Needs Chrome 123+,
   Safari 17.5+, Firefox 120+.
   ----------------------------------------------------------- */
:root {
  color-scheme: light dark;

  --bg:          light-dark(#faf9f7, #121319);
  --surface:     light-dark(#ffffff, #191a21);
  --surface-2:   light-dark(#f3f1ed, #202129);
  --text:        light-dark(#1b1b20, #e9e7e2);
  --muted:       light-dark(#64646e, #9b9ba5);
  --line:        light-dark(#e4e1db, #292a33);
  --line-strong: light-dark(#cbc7bf, #3b3c47);
  --accent:      light-dark(#a8561f, #e3a367);
  --accent-soft: light-dark(#f7ece2, #2a2018);
  --stripe:      light-dark(rgb(27 27 32 / .035), rgb(255 255 255 / .035));
  --shadow:      0 1px 2px light-dark(rgb(27 27 32 / .05), rgb(0 0 0 / .3));

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;

  --measure: 62ch;
  --page:    72rem;
  --radius:  10px;
  --gap:     clamp(1rem, 0.6rem + 1.6vw, 1.75rem);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* --- Reset -------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--font-sans);
  font-synthesis-weight: none;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

main { flex: 1; outline: none; }
img, svg { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; font-weight: 600; }
h1 { font-size: clamp(1.8rem, 1.4rem + 1.8vw, 2.6rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem); letter-spacing: -0.01em; }
h3 { font-size: 1rem; }
p  { margin: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

/* --- Layout primitives -------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: clamp(1rem, 0.5rem + 2vw, 2rem);
}

/* The house micro-label: mono, uppercase, muted. Every small metadata tag in
   the system is this one recipe — reuse `.label` rather than restating it. */
.label, .kicker, .card__go, .count, th {
  font: 500 0.7rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.lede { color: var(--muted); font-size: 1.05rem; max-width: var(--measure); }
.meta { font-size: 0.85rem; color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: absolute; left: 0.5rem; top: -3rem;
  z-index: 10; padding: 0.5rem 0.9rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--accent); border-radius: var(--radius);
  transition: top 0.15s;
}
.skip:focus { top: 0.5rem; }

/* --- Site chrome -------------------------------------------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-header__inner { display: flex; align-items: center; gap: 0.75rem; min-height: 3.5rem; }

.wordmark {
  font: 600 1.05rem/1 var(--font-mono);
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark__dot { color: var(--accent); }
.wordmark:hover { color: var(--accent); }

.crumb { font-size: 0.9rem; color: var(--muted); display: flex; gap: 0.6rem; min-width: 0; }
.crumb__sep { color: var(--line-strong); }
.crumb span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mode {
  margin-left: auto;
  flex: none;
  font: 500 0.68rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.mode:hover { color: var(--accent); border-color: var(--accent); }

.site-footer { border-top: 1px solid var(--line); margin-top: 4rem; font-size: 0.85rem; color: var(--muted); }
.site-footer__inner {
  display: flex; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; padding-block: 1.25rem;
}

/* --- Page furniture ----------------------------------------- */
.page-head {
  padding-block: clamp(2rem, 1.2rem + 3vw, 3.5rem) 1.5rem;
  display: grid;
  gap: 0.6rem;
  justify-items: start;
}

/* A titled block with an optional note under the heading. */
.section { padding-block: 2rem 0.5rem; }
.section > h2 { margin-bottom: 0.25rem; }
.section__note {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: var(--measure);
  margin-bottom: 1rem;
}

/* --- Cards / index grid -------------------------------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: var(--gap);
  padding: 0 0 1rem;
  list-style: none;
  margin: 0;
}

.card {
  position: relative;
  display: grid;
  gap: 0.5rem;
  align-content: start;
  padding: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card:has(a:focus-visible) { border-color: var(--accent); }

.card h2 { font-size: 1.15rem; }
.card h2 a { color: inherit; text-decoration: none; }
/* Whole card is the hit target. */
.card h2 a::after { content: ""; position: absolute; inset: 0; }
.card p { color: var(--muted); font-size: 0.92rem; }
.card__go { color: var(--accent); margin-top: 0.25rem; }

/* --- Forms --------------------------------------------------- */
.field {
  width: 100%;
  font: 1rem/1.4 var(--font-sans);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field::placeholder { color: var(--muted); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-block: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.toolbar .field { flex: 1; }

.count { white-space: nowrap; flex: none; }

/* The input matters more than the count once space runs short. The unit word
   is demoted to screen-reader-only, not removed — #count is an aria-live
   region, and the announcement should stay whole. */
@media (max-width: 34rem) {
  .toolbar { gap: 0.6rem; }
  .count { letter-spacing: 0.04em; }
  .count__unit {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
}

/* --- Tables -------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; vertical-align: top; }
th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  line-height: 1.4;
  letter-spacing: 0.08em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
tbody tr { border-top: 1px solid var(--line); }
tbody tr:first-child { border-top: none; }
tbody tr:hover { background: var(--surface-2); }

/* --- Empty state --------------------------------------------- */
.empty { color: var(--muted); padding: 3rem 0; text-align: center; }

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