/* @seth house style v4.1: one token file for the whole site.
   Imported once by src/layouts/Layout.astro, and served to the static pages in
   public/ at /tokens.css (src/pages/tokens.css.ts), so there is one source.

   Two surfaces, chosen with html[data-theme]:
     obsidian  (default)  dark
     monograph            warm paper, like an exhibition catalogue
   /assets/theme.js sets the attribute before first paint and saves the choice
   in localStorage under "seth-theme".

   Never declare tokens in a scoped .astro <style> :root block: Astro scopes the
   selector and it stops matching <html>. Every token lives here.

   The selectors carry extra weight on purpose (html:root...), so these values
   win over the older palettes in public/assets/style.css and
   src/styles/studio.css whatever order the files load in. */

/* ---------- Obsidian (default) ---------- */
html:root:not([data-theme="monograph"]) {
  color-scheme: dark;
  --color-bg: #000000;
  --color-surface: #0B0B0B;
  --color-surface-2: #151515;
  --color-border: #2A2A2A;
  --color-border-strong: #4A4A4A;
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #D6D6D6;
  --color-text-muted: #A3A3A3;
  --color-accent: #FFFFFF;
  --color-accent-text: #FFFFFF;
  --color-accent-ink: #000000;
  --color-accent-soft: rgba(255, 255, 255, 0.1);
  --color-phosphor: #5CE69B;
  --color-mineral: #E09879;
  --color-amber: #F2BE5C;
}

/* ---------- Monograph (warm paper) ---------- */
html:root[data-theme="monograph"] {
  color-scheme: light;
  --color-bg: #F4F1EA;
  --color-surface: #EAE5DA;
  --color-surface-2: #E0DACC;
  --color-border: #D2CBB9;
  --color-border-strong: #A69E8B;
  --color-text-primary: #121417;
  --color-text-secondary: #2E333B;
  --color-text-muted: #5B6270;
  --color-accent: #1D4ED8;
  --color-accent-text: #1E40AF;
  --color-accent-ink: #FFFFFF;
  --color-accent-soft: rgba(29, 78, 216, 0.08);
  --color-phosphor: #0F766E;
  --color-mineral: #9A3412;
  --color-amber: #92580A;
}

/* ---------- Shared tokens and the older names, mapped onto v4 ----------
   :root is written twice so this block outranks the older dark-mode rules
   (":root:not([data-theme=light])" inside a prefers-color-scheme query).
   Without it, a visitor whose system is in dark mode gets the old dark
   values for --bg, --paper and --ink under the Paper theme. */
html:root:root {
  /* The CRT sub-theme (the /basel panel pages), available everywhere. */
  --crt-bg: #050a05;
  --crt-fg: #7fff9f;

  /* Type */
  --font-serif: var(--font-sans);
  --font-sans: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono: var(--font-sans);
  --font-code: 'SF Mono', 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --font-display: var(--font-sans);
  --font-body: var(--font-sans);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 3rem;
  --text-4xl: 4rem;

  /* Space */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;
  --grid-max: 1200px;

  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
  --border-width: 1px;
  --border-color: var(--color-border);
  --color-accent-hover: var(--color-text-primary);

  /* Names used by the professional pages (public/assets/style.css) */
  --bg: var(--color-bg);
  --surface: var(--color-surface);
  --surface-2: var(--color-surface-2);
  --text: var(--color-text-primary);
  --text-2: var(--color-text-secondary);
  --muted: var(--color-text-muted);
  --rule: var(--color-border);
  --rule-strong: var(--color-border-strong);
  --accent: var(--color-accent-text);
  --accent-ink: var(--color-accent-ink);
  --accent-soft: var(--color-accent-soft);
  --poster-a: var(--color-surface);
  --poster-b: var(--color-surface-2);

  /* Names used by the studio pages (src/styles/studio.css) */
  --paper: var(--color-bg);
  --paper-soft: var(--color-surface);
  --ink: var(--color-text-primary);
  --ink-soft: var(--color-text-secondary);
  --live: var(--color-phosphor);
  --oxide: var(--color-mineral);
}

/* ---------- Base ---------- */
body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Square image corners everywhere. */
html:root img,
html:root video { border-radius: 0; }

/* ---------- Header: name, a short menu, the Paper / Dark switch ---------- */
html:root .sg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 24px; flex-wrap: wrap; }
.sg-menu { display: flex; align-items: center; gap: 6px 20px; flex-wrap: wrap; font-family: var(--font-sans); font-size: var(--text-sm); }
.sg-menu a { color: var(--color-text-secondary); text-decoration: none; }
.sg-menu a:hover, .sg-menu a[aria-current="page"] { color: var(--color-text-primary); text-decoration: underline; text-underline-offset: 0.25em; text-decoration-thickness: 1px; }
.sg-theme { display: inline-flex; border: 1px solid var(--color-border-strong); margin-left: 4px; }
.sg-theme button {
  appearance: none; background: transparent; border: 0; margin: 0; cursor: pointer;
  padding: 5px 9px; font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1;
  color: var(--color-text-muted);
}
.sg-theme button + button { border-left: 1px solid var(--color-border-strong); }
.sg-theme button[aria-pressed="true"] { background: var(--color-text-primary); color: var(--color-bg); }
.sg-theme button:focus-visible, .sg-menu a:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* ---------- Footer: the two agent-readable addresses ---------- */
.sg-foot .sg-agents { grid-column: 1 / -1; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-muted); }
.sg-foot .sg-agents a { color: var(--color-text-secondary); }

/* ---------- Status pills (mono, used for LIVE / EXHIBITED / ACQUIRED / FORMING) ---------- */
.status-pill {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1; letter-spacing: 0.04em;
  padding: 4px 7px; border: 1px solid var(--color-border-strong); color: var(--color-text-secondary);
}
.status-pill[data-state="live"] { color: var(--color-phosphor); border-color: var(--color-phosphor); }
.status-pill[data-state="exhibited"] { color: var(--color-mineral); border-color: var(--color-mineral); }
.status-pill[data-state="acquired"] { color: var(--color-accent-text); border-color: var(--color-accent-text); }
.status-pill[data-state="forming"] { color: var(--color-amber); border-color: var(--color-amber); }

/* ---------- House type: one typeface, four sizes ----------
   Helvetica everywhere (code stays monospace).
   Page titles, section labels, names and menus are bold capitals.
   Item titles are bold in sentence case. Sentences are regular. */
html:root body, html:root body *:not(code, pre, code *, pre *) { font-family: var(--font-sans) !important; }
html:root :is(code, pre, code *, pre *) { font-family: var(--font-code) !important; }

html:root :is(h1, .page-title):not(.name-band-row) {
  font-size: clamp(2rem, 1.35rem + 2.6vw, 3.5rem) !important;
  font-weight: 700 !important; line-height: 1.04 !important;
  letter-spacing: -0.005em !important; text-transform: uppercase;
}
html:root .home h1:not(.name-band-row) { font-size: clamp(1.625rem, 7vw, 3.5rem) !important; }
@media (min-width: 860px) { html:root .home h1:not(.name-band-row) { font-size: clamp(2.25rem, calc(5.2vw - 8px), 3.5rem) !important; } }
html:root :is(.kicker, h2.kicker, .fn-kicker, .fact dt, .press-year-label, .sg-mark, .sg-menu a, .sg-foot-line a, .sg-foot-line span, .home-record strong, .home-record a, .home-year, .home-work figcaption, .fn-btn, .copy-btn) {
  font-weight: 700 !important; letter-spacing: 0.02em !important; text-transform: uppercase;
}
html:root :is(.kicker, h2.kicker, .fn-kicker, .fact dt, .press-year-label) { font-size: var(--text-xs) !important; }
html:root :is(.essay-title, .talk-event, .press-title, .now-list strong) {
  font-size: 1.125rem !important; font-weight: 700 !important; line-height: 1.3 !important;
  letter-spacing: 0 !important; text-transform: none !important;
}
html:root :is(article, .prose) :is(h2, h3):not(.essay-title) { font-weight: 700 !important; text-transform: none; letter-spacing: 0 !important; }
html:root .mono { font-size: 0.8125rem; letter-spacing: 0; text-transform: none; color: var(--color-text-muted); }
html:root .sg-theme button { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; }
html:root .essay-link:hover .essay-title { color: var(--color-text-primary); text-decoration: underline; text-underline-offset: 0.2em; }

/* ---------- One-line footer ---------- */
.sg-foot.sg-foot-min { border-top: 1px solid var(--color-border); background: var(--color-bg); }
.sg-foot-line {
  box-sizing: border-box; max-width: var(--grid-max); margin: 0 auto; padding: 20px 16px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px;
  font-family: var(--font-sans); font-size: var(--text-xs); color: var(--color-text-secondary);
}
.sg-foot-line a { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.sg-foot-line a:hover { color: var(--color-text-primary); text-decoration: underline; text-underline-offset: 0.25em; }
.sg-foot-line span { margin-left: auto; color: var(--color-text-muted); }
@media (min-width: 720px) { .sg-foot-line { padding: 20px 32px; } }
html:root:not([data-theme="monograph"]) article :is(h1, h2, h3) { font-family: var(--font-sans); font-weight: 700; }
