/*
 * URPD design tokens — the custom properties every other stylesheet (and the
 * report agent's inlined CSS) references for color, spacing, and radius.
 *
 * The :root token block below is GENERATED from app/design_tokens.py, the
 * single source of truth shared with the report agent (app/domain/report/
 * html_spec.py). Do not hand-edit between the @generated markers — change the
 * values in design_tokens.py and run `python -m app.design_tokens --write`.
 * tests/test_design_tokens.py fails if this file drifts. Everything outside the
 * markers (body, gradients, theme toggle, landing fixes) is hand-written.
 *
 * Theming: light is the default :root palette; dark is the
 * :root[data-theme="dark"] override. The theme attribute is set synchronously
 * in base.html's <head> (see the no-flash setter), so the whole app re-themes
 * through these variables.
 */

/* @generated tokens — source: app/design_tokens.py · regenerate: python -m app.design_tokens --write */
:root{
  color-scheme: light;
  /* scale — spacing & radius (theme-independent) */
  --space-1:4px; --space-2:8px; --space-3:12px; --space-4:18px; --space-5:28px; --space-6:44px; --space-7:72px; --radius:2px;
  /* paper / linen — backgrounds */
  --paper:#f3ecdc; --paper-warm:#ede4ce; --linen:#fbf6ea; --linen-shade:#f7efde;
  /* pine — primary accent */
  --pine-light:#e2bf8a; --pine:#c89461; --pine-deep:#8a5a30; --pine-knot:#5d3a1c;
  /* ink — text */
  --ink:#1f1812; --ink-soft:#3a2e22; --ink-mute:#6b5a47; --ink-faint:#9a886e;
  /* moss — positive values · rust — negative values */
  --moss:#5a6f4a; --moss-deep:#3f5132; --rust:#a8431f; --rust-deep:#7a2f15;
  /* rules — hairline borders */
  --rule:#d5c7a8; --rule-soft:#e2d6b8;
  /* semantic — roles a straight lightness-flip would break */
  --field-bg:#ffffff; --on-accent:#fbf6ea; --error:#c62828; --error-bg:#fbe9e7; --success:#2e7d32;
}
:root[data-theme="dark"]{
  color-scheme: dark;
  /* paper / linen — backgrounds */
  --paper:#17120e; --paper-warm:#1e1812; --linen:#241d16; --linen-shade:#2c241b;
  /* pine — primary accent */
  --pine-light:#e7c794; --pine:#d8a972; --pine-deep:#c2884f; --pine-knot:#a8763f;
  /* ink — text */
  --ink:#f1e8d6; --ink-soft:#ddd2bd; --ink-mute:#b6a78c; --ink-faint:#97876c;
  /* moss — positive values · rust — negative values */
  --moss:#8fb06f; --moss-deep:#7a9a5c; --rust:#df6b41; --rust-deep:#c25636;
  /* rules — hairline borders */
  --rule:#3a3026; --rule-soft:#2a2219;
  /* semantic — roles a straight lightness-flip would break */
  --field-bg:#2a2219; --on-accent:#1c1611; --error:#ef6b6b; --error-bg:#3a201c; --success:#6fc77a;
}
/* @end generated tokens */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); }
html { overflow-x: hidden; }

body {
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background-image:
    repeating-linear-gradient(92deg,
      rgba(138,90,48,0.018) 0px, rgba(138,90,48,0.018) 1px,
      transparent 1px, transparent 7px),
    repeating-linear-gradient(88deg,
      rgba(93,58,28,0.012) 0px, rgba(93,58,28,0.012) 2px,
      transparent 2px, transparent 19px);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Sticky footer: lay the page out as a column and let the main content grow
     so the shared footer sits at the bottom of the viewport on short pages
     (and after the content, keeping its own top margin, on long ones).
     Tool pages render their own document and don't load this stylesheet, so
     they're unaffected; agent_workspace overrides body in its own head block. */
  display: flex;
  flex-direction: column;
}

/* The single content element on every base.html page. Growing it is what
   pushes the footer down. */
body > main { flex: 1 0 auto; }

/* The light body uses dark-brown gradient overlays; on dark they vanish or
   muddy, so re-tint them as very faint warm-light hairlines. */
:root[data-theme="dark"] body {
  background-image:
    repeating-linear-gradient(92deg, rgba(231,199,148,0.014) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(88deg, rgba(231,199,148,0.010) 0 2px, transparent 2px 19px);
}

::selection { background: var(--pine-light); color: var(--ink); }
:root[data-theme="dark"] ::selection { background: var(--pine-deep); color: var(--on-accent); }
a { color: inherit; text-decoration: none; }

/* Native <select> popups render washed-out in dark unless the control carries a
   dark color-scheme and the options get explicit colors. */
:root[data-theme="dark"] select { color-scheme: dark; }
:root[data-theme="dark"] option { background-color: var(--field-bg); color: var(--ink); }

/* Theme toggle (button lives in _topbar.html). Moon shows in light mode
   ("switch to dark"); sun shows in dark mode ("switch to light"). */
.theme-icon-sun  { display: none; }
.theme-icon-moon { display: inline-flex; }
:root[data-theme="dark"] .theme-icon-sun  { display: inline-flex; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme-toggle]:hover { color: var(--ink); }

/* ── Landing page (landing.html) dark fixes ──────────────────────────────
   landing.html declares its own :root with light values; the global
   :root[data-theme="dark"] block (higher specificity) overrides those, so
   most of the page re-themes for free. Two things still need help: */
/* Hero primary CTA sits on var(--pine-light), which stays light in both
   themes, so its label must read dark in both — flip to on-accent in dark. */
:root[data-theme="dark"] .btn-primary { color: var(--on-accent); }
/* The "live tools" micro-charts use hardcoded light hex presentation
   attributes (fill="..."/stroke="...") that var() can't reach. Author CSS
   beats presentation attributes, so retint them to the brightened dark
   tokens via attribute selectors, scoped to the chart cards only. */
:root[data-theme="dark"] .entry-side svg [fill="#a8431f"]   { fill: var(--rust); }
:root[data-theme="dark"] .entry-side svg [fill="#5a6f4a"]   { fill: var(--moss); }
:root[data-theme="dark"] .entry-side svg [fill="#c89461"]   { fill: var(--pine); }
:root[data-theme="dark"] .entry-side svg [stroke="#d5c7a8"] { stroke: var(--rule); }
:root[data-theme="dark"] .entry-side svg [stroke="#8a5a30"] { stroke: var(--pine-deep); }
