/* Lou's web style: base.css
   Source of truth for tokens. Copy into a project and override tokens, not component rules.
   Theme: follows the device; dark when the device reports nothing; [data-theme] (the toggle) wins.
   After changing any color, run: node scripts/contrast.mjs base.css */

:root {
  /* Color: dark (default) */
  --bg: #1a1719;          /* near-black with a faint rose bias */
  --surface: #221e21;     /* the one panel that sets off a working area */
  --fg: #ece5e8;
  --muted: #a39a9f;
  --rule: #3a3337;        /* hairlines and dividers */
  --field: #786d73;       /* input borders; must stay 3:1 against bg and surface */
  --accent: #f2a7bf;      /* cherry blossom: links, one primary button, focus, small marks */
  --accent-ink: #2a1a20;  /* text on accent fills */
  --petal: #f6c3d3;       /* decoration only, never text */
  --good: #86d19f;
  --warn: #e6c36a;
  --bad: #ff8f6b;

  /* Type */
  --font-read: "Literata", Georgia, "Times New Roman", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: "Fraunces", Georgia, serif;
  --font-hand: "Caveat", "Bradley Hand", cursive;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --title-fvs: "SOFT" 100, "WONK" 1;
  --title-weight: 700;
  --read-size: 19px;
  --read-leading: 1.65;
  --ui-size: 16px;
  --ui-leading: 1.5;

  /* Space and shape */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --column: 760px;
  --measure: 66ch;
  --gutter: 20px;
  --radius: 8px;
  --radius-panel: 14px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --fast: 150ms;
  --slow: 300ms;

  color-scheme: dark;
}

/* Light: keep these two blocks identical (contrast.mjs checks). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fbf8f8;
    --surface: #ffffff;
    --fg: #261f23;
    --muted: #6e6267;
    --rule: #e8dde1;
    --field: #958a8f;
    --accent: #b1385f;
    --accent-ink: #ffffff;
    --petal: #f1a9bf;
    --good: #1b7340;
    --warn: #85600a;
    --bad: #c0392b;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #fbf8f8;
  --surface: #ffffff;
  --fg: #261f23;
  --muted: #6e6267;
  --rule: #e8dde1;
  --field: #958a8f;
  --accent: #b1385f;
  --accent-ink: #ffffff;
  --petal: #f1a9bf;
  --good: #1b7340;
  --warn: #85600a;
  --bad: #c0392b;
  color-scheme: light;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--ui-size) / var(--ui-leading) var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
hr { border: 0; border-top: 1px solid var(--rule); margin-block: var(--space-7); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Layout: one column, left-aligned */
.page {
  max-width: var(--column);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: var(--space-6) var(--space-9);
}
.page-top { display: flex; justify-content: flex-end; gap: var(--space-2); margin-bottom: var(--space-4); }

/* Titles: Fraunces only for the site name, the page h1, and a level 2 hero */
h1, .site-name, .display {
  font-family: var(--font-title);
  font-variation-settings: var(--title-fvs);
  font-weight: var(--title-weight);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 6vw, 3.25rem); margin: 0 0 var(--space-3); }
.display { font-size: clamp(4rem, 15vw, 7rem); line-height: 0.9; margin: 0; }
h2, h3 { font-weight: 650; line-height: 1.2; text-wrap: balance; margin: 1.6em 0 0.5em; }

.meta { font: 14px/1.4 var(--font-ui); color: var(--muted); font-variant-numeric: tabular-nums; }
.eyebrow {
  font: 600 12px/1.2 var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--space-3);
}

/* Site header (content sites) */
.site-header { display: grid; gap: var(--space-2); margin-bottom: var(--space-8); }
.site-name { font-size: clamp(2rem, 5vw, 2.75rem); color: var(--fg); text-decoration: none; }
.site-name:hover { color: var(--fg); }
.site-nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: 15px; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }

/* Post list: date and title, nothing else */
.post-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-5); }
.post-list time { display: block; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.post-list a { font-family: var(--font-read); font-size: 1.25rem; font-weight: 600; line-height: 1.3; color: var(--fg); text-decoration: none; }
.post-list a:hover { color: var(--accent); }

/* Prose */
.prose {
  font-family: var(--font-read);
  font-size: var(--read-size);
  line-height: var(--read-leading);
  max-width: var(--measure);
  min-width: 0;
}
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose figure { margin: 0 0 1em; }
.prose h2 { font-size: 1.35em; }
.prose h3 { font-size: 1.12em; }
.prose li + li { margin-top: 0.3em; }
.prose blockquote { margin-inline: 0; padding-left: 1em; border-left: 2px solid var(--rule); color: var(--muted); font-style: italic; }
.prose code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface); padding: 0.1em 0.35em; border-radius: 4px; }
.prose pre {
  font: 14px/1.6 var(--font-mono);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--space-4);
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose img { border-radius: var(--radius); }
.prose figcaption { font: 14px/1.4 var(--font-ui); color: var(--muted); margin-top: var(--space-2); }
.footnotes { font-size: 0.85em; color: var(--muted); border-top: 1px solid var(--rule); padding-top: var(--space-4); margin-top: var(--space-7); }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font: 500 15px/1 var(--font-ui);
  padding: 10px 16px;
  border: 1px solid var(--field);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); border-color: transparent; }
.btn-pill { border-radius: var(--radius-pill); }
.btn-quiet { border-color: transparent; color: var(--muted); padding-inline: var(--space-3); }
.btn-quiet:hover { color: var(--fg); border-color: transparent; }

.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.input {
  font: 16px/1.4 var(--font-ui);   /* 16px stops iOS zooming on focus */
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--field);
  border-radius: var(--radius);
  padding: 9px 12px;
  min-width: 0;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: 14px; }

/* Panel: one per screen, to set off the working area. Not a card grid. */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-panel);
  padding: var(--space-5);
  min-width: 0;
}

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.table th {
  text-align: left; font-weight: 500; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 0 0 var(--space-2); border-bottom: 1px solid var(--rule);
}
.table td { padding: var(--space-3) 0; border-bottom: 1px solid var(--rule); }
.table th + th, .table td + td { padding-left: var(--space-4); }
.table .num { text-align: right; white-space: nowrap; }
.table tfoot td { border-bottom: 0; font-weight: 600; }

.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.empty-state { color: var(--muted); text-align: center; padding: var(--space-7) var(--space-4); }

/* Whimsy (level 1 and 2) */
.hand { font-family: var(--font-hand); font-size: 1.35em; color: var(--accent); display: inline-block; transform: rotate(-2deg); }

.petal {
  position: fixed; z-index: 100; pointer-events: none;
  width: 10px; height: 8px; margin: -4px 0 0 -5px;
  background: var(--petal);
  border-radius: 0 100% 0 100%;
  animation: petal-drift 1.1s cubic-bezier(0.15, 0.7, 0.35, 1) forwards;
}
@keyframes petal-drift {
  0%   { transform: translate(0, 0) rotate(0deg) scale(0.6); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}

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