/* Lethean Age rulebooks — shared stylesheet (Relic-Tech Atmospheric).
   Visual language derived from Stitch "Relic-Tech Atmospheric" design system.
   Dark mode only; per-chapter overrides live alongside each HTML file. */

@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&display=swap");

:root {
  color-scheme: dark;

  /* Surfaces — tonal ladder from background up */
  --surface: #0b1326;
  --surface-dim: #0b1326;
  --surface-bright: #31394d;
  --surface-container-lowest: #060e20;
  --surface-container-low: #131b2e;
  --surface-container: #171f33;
  --surface-container-high: #222a3d;
  --surface-container-highest: #2d3449;
  --surface-variant: #2d3449;
  --background: #0b1326;

  /* On-surface text colors */
  --on-surface: #dae2fd;
  --on-surface-variant: #bccbb9;
  --on-background: #dae2fd;
  --outline: #869585;
  --outline-variant: #3d4a3d;

  /* Accents — Verdant / Signal / Strange */
  --primary: #4be277;
  --primary-container: #22c55e;
  --on-primary: #003915;
  --secondary: #adc6ff;
  --secondary-container: #0566d9;
  --on-secondary: #002e6a;
  --tertiary: #deb8ff;
  --tertiary-container: #cb94ff;
  --on-tertiary: #490080;
  --error: #ffb4ab;

  /* Translucent accent variants for borders & glows */
  --primary-05: rgba(75, 226, 119, 0.05);
  --primary-10: rgba(75, 226, 119, 0.10);
  --primary-20: rgba(75, 226, 119, 0.20);
  --primary-30: rgba(75, 226, 119, 0.30);
  --primary-60: rgba(75, 226, 119, 0.60);

  /* Chapter accent — defaults to primary, chapters override */
  --chapter-accent: var(--primary);
  --chapter-accent-soft: var(--primary-20);
  --chapter-accent-bg: var(--primary-05);

  /* Typography stacks */
  --font-headline: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Source Serif 4", Georgia, "Iowan Old Style", serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Spacing scale */
  --margin-page: 2rem;
  --column-gap: 1.5rem;
  --gutter-grid: 1rem;
  --block-padding: 1.25rem;

  /* Radii — industrial, tight */
  --radius-sm: 0.125rem;
  --radius: 0.25rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 3rem 1rem 6rem;
}

::selection {
  background: var(--primary-30);
  color: var(--primary);
}

article {
  max-width: 56rem;
  margin: 0 auto;
  padding: 4rem 3rem 5rem;
  background: var(--surface);
  border: 1px solid var(--primary-10);
  border-radius: var(--radius-sm);
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

/* Subtle radial atmospheric haze */
article::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--primary-05) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}

article > * { position: relative; z-index: 1; }

/* Headings — Space Grotesk, uppercase */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-headline);
  color: var(--on-surface);
  line-height: 1.25;
  text-transform: uppercase;
  margin: 2.5rem 0 1rem;
}

h1 {
  font-size: 48px;
  font-weight: 700;
  line-height: 56px;
  letter-spacing: -0.02em;
  margin: 0 0 2rem;
  padding-left: 1.5rem;
  border-left: 4px solid var(--chapter-accent);
}

h2 {
  font-size: 28px;
  font-weight: 600;
  line-height: 36px;
  color: var(--chapter-accent);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--chapter-accent-soft);
}

h3 {
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  color: var(--on-surface);
  letter-spacing: 0.02em;
}

h4 {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1em;
  color: var(--on-surface-variant);
}

/* Body text — Source Serif 4 */
p {
  margin: 0 0 1rem;
  font-size: 16px;
  line-height: 26px;
  color: rgba(218, 226, 253, 0.92);
}

strong {
  color: var(--on-surface);
  font-weight: 600;
}

em { font-style: italic; }

/* Links */
a {
  color: var(--chapter-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 200ms ease;
}

a:hover { color: var(--primary-container); }

/* Lists */
ul, ol {
  margin: 0 0 1.25rem;
  padding-left: 1.75rem;
  color: rgba(218, 226, 253, 0.92);
}

ul { list-style: square; }
ul li::marker { color: var(--chapter-accent); }

ol { list-style: none; counter-reset: gg-step; padding-left: 0; }
ol > li {
  counter-increment: gg-step;
  position: relative;
  padding: 0.25rem 0 0.25rem 2.75rem;
  margin: 0.5rem 0;
  min-height: 1.75rem;
}
ol > li::before {
  content: counter(gg-step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.25rem;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--chapter-accent);
  background: var(--chapter-accent-bg);
  border: 1px solid var(--chapter-accent-soft);
  padding: 0.15rem 0.5rem;
  line-height: 1.2;
}

li { line-height: 24px; }

/* Inline code / mono */
code {
  font-family: var(--font-mono);
  background: var(--surface-container);
  color: var(--on-surface);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  border: 1px solid var(--outline-variant);
}

/* Frontmatter aside — the DATA_NODE manifest */
aside.frontmatter {
  position: relative;
  background: var(--chapter-accent-bg);
  border: 1px solid var(--chapter-accent-soft);
  border-left: 4px solid var(--chapter-accent);
  padding: 1rem 1.25rem;
  margin: 0 0 2.5rem;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  color: var(--on-surface-variant);
}

aside.frontmatter::before {
  content: "DATA_NODE";
  position: absolute;
  top: -0.6rem;
  right: 1rem;
  background: var(--chapter-accent);
  color: var(--on-primary);
  padding: 0.15rem 0.55rem;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

aside.frontmatter p {
  margin: 0.2rem 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  color: var(--on-surface-variant);
}

aside.frontmatter strong { color: var(--chapter-accent); font-weight: 700; }

aside.frontmatter code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--chapter-accent);
}

/* Tables — spec sheet aesthetic */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.75rem 0;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 18px;
  background: rgba(23, 31, 51, 0.4);
  border: 1px solid var(--outline-variant);
}

caption {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--on-surface-variant);
  padding: 0 0 0.5rem;
}

thead { background: var(--chapter-accent-bg); }

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--chapter-accent);
  border-bottom: 2px solid var(--chapter-accent);
  vertical-align: bottom;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(134, 149, 133, 0.15);
  color: var(--on-surface-variant);
  vertical-align: top;
}

tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--chapter-accent-bg); }

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--on-surface);
  white-space: nowrap;
}

td:first-child { color: var(--on-surface); }

/* Horizontal rule with circuit terminals */
hr {
  border: 0;
  height: 1px;
  background: var(--outline-variant);
  margin: 2.5rem 0;
  position: relative;
}

hr::before, hr::after {
  content: "";
  position: absolute;
  top: -3px;
  width: 4px;
  height: 7px;
  background: var(--chapter-accent);
}

hr::before { left: 0; }
hr::after { right: 0; }

/* Images / figures */
img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
}

figure {
  margin: 1.5rem 0;
  border: 1px solid var(--outline-variant);
  background: var(--surface-container-low);
}

figure img { margin: 0; }

figcaption {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--on-surface-variant);
  text-align: center;
  padding: 0.5rem 1rem;
  background: var(--surface-container-low);
  border-top: 1px solid var(--outline-variant);
}

/* Responsive */
@media (max-width: 768px) {
  body { padding: 1rem 0.5rem 3rem; }
  article { padding: 2rem 1.25rem 3rem; }
  h1 { font-size: 32px; line-height: 40px; padding-left: 1rem; margin-bottom: 1.5rem; }
  h2 { font-size: 22px; line-height: 30px; }
  h3 { font-size: 18px; line-height: 26px; }
  table { font-size: 12px; }
  th, td { padding: 0.5rem 0.6rem; }
  ol > li { padding-left: 2.5rem; }
}
