/* ============================================================================
   Pathlight Playbook — Editorial Documentation Styles
   ----------------------------------------------------------------------------
   Design principles applied:
   - Restraint (impeccable): hierarchy via size + weight + space, not color
   - Invisible details (Emil Kowalski): tight tracking on headings, considered
     focus states, exit-faster-than-enter on hover transitions
   - Anti-slop (design-taste-frontend): real design tokens, no generic borders,
     editorial typography scale
   Palette is the Pathlight brand brief locked tokens — no new colors.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Design tokens ---------- */
:root {
  /* Pathlight palette (verbatim from brand-brief.md) */
  --brand-navy:        #0F172A;
  --brand-blue-500:    #3B82F6;
  --brand-blue-700:    #1D4ED8;
  --brand-blue-300:    #60A5FA;
  --brand-slate-700:   #334155; /* extension token for body copy */
  --brand-slate-600:   #475569;
  --brand-slate-400:   #94A3B8;
  --brand-slate-300:   #CBD5E1;
  --brand-slate-200:   #E2E8F0;
  --brand-slate-100:   #F1F5F9;
  --brand-slate-50:    #F8FAFC; /* extension token for very subtle bg */
  --brand-white:       #FFFFFF;

  /* Type */
  --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Monaco, monospace;

  /* Spacing scale (8-point) */
  --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;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Reading container */
  --reading-width: 720px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 120ms;
}

/* ---------- Reset + base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.7;
  color: var(--brand-slate-700);
  background: var(--brand-white);
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--brand-blue-500); color: var(--brand-white); }

/* ---------- Page chrome ---------- */
.brand-band {
  border-bottom: 1px solid var(--brand-slate-200);
  background: var(--brand-white);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(10px);
  background: rgba(255,255,255,0.85);
}
.brand-band-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5);
}
.brand-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--brand-navy);
  font-size: 15px;
}
.brand-name .dot {
  color: var(--brand-blue-500);
  margin: 0 var(--space-1);
}
.brand-tagline {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--brand-slate-400);
}

/* ---------- Layout: article + TOC sidebar ---------- */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-5);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: var(--space-8);
}
@media (max-width: 960px) {
  .page { grid-template-columns: 1fr; padding: var(--space-6) var(--space-4); }
}
.article {
  max-width: var(--reading-width);
  min-width: 0;
}

/* ---------- Pandoc TOC sidebar ---------- */
#TOC {
  position: sticky;
  top: var(--space-9);
  align-self: start;
  font-size: 13px;
  border-left: 1px solid var(--brand-slate-200);
  padding-left: var(--space-5);
  max-height: calc(100vh - var(--space-9) - var(--space-5));
  overflow-y: auto;
}
@media (max-width: 960px) {
  #TOC {
    position: static;
    border-left: none;
    border-top: 1px solid var(--brand-slate-200);
    padding-left: 0;
    padding-top: var(--space-4);
    margin-top: var(--space-6);
    max-height: none;
  }
}
#TOC::before {
  content: "On this page";
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--brand-slate-400);
  margin-bottom: var(--space-3);
}
#TOC ul { list-style: none; padding-left: 0; margin: 0; }
#TOC > ul > li { margin: var(--space-2) 0; }
#TOC ul ul { padding-left: var(--space-4); margin: var(--space-1) 0; }
#TOC a {
  color: var(--brand-slate-600);
  text-decoration: none;
  display: block;
  padding: var(--space-1) 0;
  transition: color var(--duration-fast) var(--ease-out);
}
#TOC a:hover { color: var(--brand-blue-700); }

/* ---------- Typography ---------- */
.article h1, .article h2, .article h3, .article h4 {
  color: var(--brand-navy);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: var(--space-7) 0 var(--space-4);
}
.article > h1:first-child { margin-top: 0; }
.article h1 { font-size: 38px; letter-spacing: -0.03em; }
.article h2 { font-size: 26px; padding-bottom: var(--space-3); border-bottom: 1px solid var(--brand-slate-200); margin-top: var(--space-8); }
.article h3 { font-size: 19px; margin-top: var(--space-6); }
.article h4 {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand-slate-600);
  font-weight: 700;
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
}

.article p { margin: var(--space-4) 0; }

/* Anchor links from auto-generated heading IDs */
.article h2 a, .article h3 a, .article h4 a {
  color: inherit;
  text-decoration: none;
}

/* ---------- Lead / blockquote (the "> hook" at the top of chapters) ---------- */
.article blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border-left: 3px solid var(--brand-blue-500);
  background: var(--brand-slate-50);
  color: var(--brand-slate-700);
  font-size: 17px;
  font-style: normal;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article blockquote p:first-child { margin-top: 0; }
.article blockquote p:last-child { margin-bottom: 0; }
.article blockquote strong { color: var(--brand-navy); }

/* ---------- Links ---------- */
.article a {
  color: var(--brand-blue-700);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration-fast) var(--ease-out);
}
.article a:hover { border-bottom-color: var(--brand-blue-700); }
.article a:focus-visible {
  outline: 2px solid var(--brand-blue-500);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Lists ---------- */
.article ul, .article ol {
  margin: var(--space-4) 0;
  padding-left: var(--space-5);
}
.article li { margin: var(--space-2) 0; }
.article li > ul, .article li > ol { margin: var(--space-2) 0; }

/* Checklist (definition of done) */
.article input[type="checkbox"] {
  margin-right: var(--space-2);
  accent-color: var(--brand-blue-500);
}

/* ---------- Tables ---------- */
.article table {
  border-collapse: collapse;
  width: 100%;
  margin: var(--space-5) 0;
  font-size: 15px;
  background: var(--brand-white);
  border: 1px solid var(--brand-slate-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.article th {
  background: var(--brand-slate-50);
  color: var(--brand-slate-600);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--brand-slate-200);
}
.article td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--brand-slate-200);
  vertical-align: top;
  color: var(--brand-slate-700);
}
.article tr:last-child td { border-bottom: none; }
.article tr:hover td { background: var(--brand-slate-50); }
.article td strong { color: var(--brand-navy); font-weight: 600; }

/* ---------- Code ---------- */
.article code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--brand-slate-100);
  color: var(--brand-blue-700);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.article pre {
  background: var(--brand-navy);
  color: var(--brand-slate-200);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
  margin: var(--space-5) 0;
  border: 1px solid var(--brand-navy);
}
.article pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  font-weight: 400;
}

/* Pandoc syntax highlighting overrides — restrained palette */
.article pre .kw { color: var(--brand-blue-300); }
.article pre .st, .article pre .vs { color: #A5F3FC; }
.article pre .co { color: var(--brand-slate-400); font-style: italic; }
.article pre .va { color: #F0ABFC; }
.article pre .fu { color: var(--brand-blue-300); }

/* ---------- Horizontal rules ---------- */
.article hr {
  border: none;
  border-top: 1px solid var(--brand-slate-200);
  margin: var(--space-7) 0;
}

/* ---------- Frontmatter (Pandoc renders YAML as a header block) ---------- */
.article > .header, .article > #header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--brand-slate-200);
}

/* ---------- Strong + em ---------- */
.article strong { color: var(--brand-navy); font-weight: 600; }
.article em { font-style: italic; }

/* ---------- Pandoc tightlist class ---------- */
.tightlist { padding-left: var(--space-5); }
.tightlist li { margin: var(--space-1) 0; }

/* ---------- Footer ---------- */
.page-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
  border-top: 1px solid var(--brand-slate-200);
  font-size: 13px;
  color: var(--brand-slate-400);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.page-footer a { color: var(--brand-slate-600); text-decoration: none; }
.page-footer a:hover { color: var(--brand-blue-700); }

/* ---------- Print styles ---------- */
@media print {
  body { font-size: 11pt; line-height: 1.55; color: #000; }
  .brand-band, .page-footer, #TOC { display: none; }
  .page { grid-template-columns: 1fr; padding: 0; }
  .article { max-width: none; }
  .article h1 { font-size: 24pt; }
  .article h2 { font-size: 16pt; border-bottom: 1px solid #ccc; }
  .article h3 { font-size: 13pt; }
  .article pre { background: #f5f5f5; color: #000; border: 1px solid #ddd; }
  .article pre code { color: #000; }
  .article a { color: #000; border-bottom: none; }
  .article a::after { content: " (" attr(href) ")"; font-size: 9pt; color: #666; }
  .article blockquote { background: #f9f9f9; border-left-color: #3B82F6; }
  .article table { font-size: 9pt; page-break-inside: avoid; }
  .article h2, .article h3 { page-break-after: avoid; }
  .article p, .article li { orphans: 3; widows: 3; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
