/* ==========================================================================
   TRiON standalone-page kit  —  /trion-page.css
   --------------------------------------------------------------------------
   For hand-built HTML pages attached to a post through the `fullPage` field
   (see docs/CUSTOM_PAGES.md). Astro does not process these pages, so they
   cannot import src/styles/global.css. This file carries the SAME design
   tokens so a standalone page reads as part of the same site.

   KEEP IN SYNC with src/styles/global.css:
     --bg --bg-raised --ink --ink-muted --line --signal --signal-dim
     --signal-ink --glass-bg --glass-border --grain-opacity (dark + light)
   Kit-only tokens (not in global.css): --ink-2 --ok --warn --violet --info
     --on-signal --bar-h

   Theme: reads/writes the same localStorage key ("trion-theme") as the site,
   so dark/light carries across pages. Pair this file with /trion-page.js and
   the pre-paint snippet from docs/custom-page-template.html.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  /* dark — the "case file at night" (mirrors global.css) */
  --bg: #0b0b0c;
  --bg-raised: #131315;
  --ink: #ededea;
  --ink-muted: #8f8d88;
  --line: #2a2a2b;
  --signal: #c62f2f;
  --signal-dim: #7a1f1f;
  --signal-ink: #e5504b;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --grain-opacity: 0.05;

  /* kit-only: AA-safe secondary text + restrained status colours */
  --ink-2: #8f8d88;
  --ok: #52b788;
  --warn: #f77f00;
  --violet: #c77dff;
  --info: #4cc9f0;
  --on-signal: #ffffff;

  --measure: 68ch;
  --bar-h: 2.75rem;
  color-scheme: dark;
}

[data-theme='light'] {
  /* light — manila-folder toned, not a generic inverted theme */
  --bg: #e7e2d3;
  --bg-raised: #ddd6c2;
  --ink: #201d18;
  --ink-muted: #5f594c;
  --line: #c9c0a8;
  --signal: #a92424;
  --signal-dim: #d99a9a;
  --signal-ink: #9c2020;
  --glass-bg: rgba(20, 18, 12, 0.04);
  --glass-border: rgba(20, 18, 12, 0.1);
  --grain-opacity: 0.035;

  --ink-2: #5a5447;
  --ok: #1b6040;
  --warn: #7d4300;
  --violet: #5f3592;
  --info: #085f7d;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 400;
  line-height: 1.65;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* film-grain texture — same overlay as the main site */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.5em;
}
p { margin: 0 0 1em; }
a { color: var(--signal-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
strong, b { font-weight: 700; }
::selection { background: var(--signal); color: var(--on-signal); }
:focus-visible { outline: 2px solid var(--signal-ink); outline-offset: 2px; }

main, .tp-bar, .tp-footer { position: relative; z-index: 2; }

/* ---- accessibility helpers ---- */
.tp-skip {
  position: absolute; left: -9999px; top: 0; z-index: 3000;
  background: var(--signal); color: var(--on-signal);
  padding: 0.5rem 0.9rem; font-size: 0.8rem;
}
.tp-skip:focus { left: 0.75rem; top: 0.75rem; text-decoration: none; }
.tp-sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- site bar: brand + breadcrumb + theme toggle ---- */
.tp-bar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  min-height: var(--bar-h);
  padding: 0.4rem 1rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tp-crumbs {
  display: flex; align-items: center; gap: 0.5rem;
  min-width: 0; font-size: 0.75rem; color: var(--ink-2);
  white-space: nowrap; overflow: hidden;
}
.tp-crumbs a { color: var(--ink-2); }
.tp-crumbs a:hover { color: var(--ink); }
.tp-crumbs .tp-brand {
  font-family: var(--font-display); font-weight: 700; font-size: 0.95rem;
  letter-spacing: 0.02em; color: var(--ink);
}
.tp-crumbs [aria-current='page'] {
  color: var(--ink); overflow: hidden; text-overflow: ellipsis;
}
.tp-theme-toggle {
  flex: none;
  background: transparent; border: 1px solid var(--line); color: var(--ink-2);
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0.35rem 0.6rem; border-radius: 3px; cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.tp-theme-toggle:hover { border-color: var(--signal); color: var(--ink); }

/* ---- shared surfaces ---- */
.tp-eyebrow {
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--signal-ink);
}
.tp-card {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 4px; padding: 1.25rem;
}

/* ---- footer ---- */
.tp-footer {
  border-top: 1px solid var(--line);
  padding: 2.5rem 1.5rem calc(2.5rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
}
.tp-footer-inner { max-width: 44rem; margin: 0 auto; }
.tp-wordmark {
  background: none; border: 0; padding: 0; margin: 0 0 0.9rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.75rem;
  letter-spacing: 0.08em; color: var(--ink); cursor: pointer;
  transition: color 0.2s ease;
}
.tp-wordmark:hover { color: var(--signal-ink); }
.tp-copy {
  margin: 0 0 0.35rem; font-weight: 500; font-size: 0.8rem; letter-spacing: 0.06em; color: var(--ink);
}
.tp-legal {
  margin: 0 auto 1.25rem; max-width: 36rem; font-size: 0.75rem; line-height: 1.7; color: var(--ink-2);
}
.tp-footer-links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 1.5rem;
  padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body, .tp-theme-toggle, .tp-wordmark { transition: none; }
}
