/*
 * Kol — web presentation
 * Typography, spacing, palette. The bones.
 */

/* ---- Palette ---- */
:root {
  /* Warm neutrals — not clinical, not loud */
  --bg: #faf8f5;
  --bg-subtle: #f3f0eb;
  --text: #2c2825;
  --text-secondary: #6b6560;
  --text-tertiary: #9b9590;

  /* Valence spectrum — warm end */
  --warm: #c4725a;
  --warm-light: #e8c4b8;
  --warm-subtle: #f2e0d8;

  /* Cool end — for contrast, sparingly */
  --cool: #5a7a8a;
  --cool-light: #b8ced8;

  /* Accent — the gap, the space between */
  --gap: #d4a574;

  /* Layout */
  --content-width: 38rem;
  --margin-width: 12rem;
  --gutter: 2rem;

  /* Typography scale */
  --font-body: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --text-base: 1.125rem;    /* 18px — comfortable reading */
  --text-sm: 0.9375rem;     /* 15px — margin notes, captions */
  --text-xs: 0.8125rem;     /* 13px — labels */
  --text-lg: 1.375rem;      /* 22px — section intros */
  --text-h1: 2.25rem;       /* 36px */
  --text-h2: 1.625rem;      /* 26px */
  --text-h3: 1.25rem;       /* 20px */

  --leading: 1.7;           /* generous line height */
  --leading-tight: 1.3;
}

/* ---- Reset ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- Base ---- */
html {
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading);
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
}

/* ---- Page structure ---- */
.page {
  max-width: calc(var(--content-width) + var(--margin-width) + var(--gutter));
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
  padding-left: calc(var(--margin-width) + var(--gutter) + 1.5rem);
  position: relative;
}

/* Main content column */
.content {
  max-width: var(--content-width);
}

/* ---- Lessons sidebar — accumulates on the left ---- */
.lessons-sidebar {
  position: fixed;
  top: 4rem;
  left: max(1.5rem, calc((100vw - var(--content-width) - var(--margin-width) - var(--gutter)) / 2));
  width: var(--margin-width);
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  padding-right: var(--gutter);

  /* Hide scrollbar but allow scrolling */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.lessons-sidebar::-webkit-scrollbar {
  display: none;
}

.lessons-sidebar .lesson {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.5;
  padding: 0.35rem 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  cursor: default;
}

.lessons-sidebar .lesson.visible {
  opacity: 1;
  transform: translateY(0);
}

.lessons-sidebar .lesson:hover {
  color: var(--text-secondary);
}

.lessons-sidebar .lesson-number {
  font-weight: 600;
  color: var(--warm);
  margin-right: 0.25rem;
  display: inline;
}

.lessons-sidebar .lesson-gap {
  font-style: italic;
}

/* ---- Typography ---- */
h1 {
  font-size: var(--text-h1);
  line-height: var(--leading-tight);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--text);
}

h2 {
  font-size: var(--text-h2);
  line-height: var(--leading-tight);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
  color: var(--text);
}

h3 {
  font-size: var(--text-h3);
  line-height: var(--leading-tight);
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  color: var(--text);
}

p {
  margin-bottom: 1.25rem;
}

/* Lead paragraph — section openings */
.lead {
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 1.75rem;
}

/* Subtitle — sits below h1, above attribution */
.subtitle {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-top: -0.5rem;
  margin-bottom: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* Attribution line */
.attribution {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 3rem;
  font-style: italic;
}

/* ---- Blockquotes — process notes from each Claude ---- */
blockquote {
  border-left: 2px solid var(--warm-light);
  padding-left: 1.25rem;
  margin: 2rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

blockquote em {
  font-style: normal;
}

/* ---- Horizontal rules — section breaks ---- */
hr {
  border: none;
  height: 1px;
  background: var(--warm-light);
  margin: 4rem 0;
}

/* ---- Code / data ---- */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-subtle);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

/* ---- Figures — where SVGs and interactive elements live ---- */
figure {
  margin: 2.5rem 0;
  padding: 0;
}

figure svg {
  display: block;
  width: 100%;
  height: auto;
}

figcaption {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 0.75rem;
  line-height: 1.5;
}

/* ---- Margin notes — lessons accumulate here ---- */
.margin-note {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  line-height: 1.5;
  position: absolute;
  right: 0;
  width: var(--margin-width);
  padding-left: var(--gutter);
}

/* On narrow screens, sidebar hides, content takes full width */
@media (max-width: 56rem) {
  .page {
    max-width: var(--content-width);
    padding-left: 1.5rem;
  }

  .lessons-sidebar {
    display: none;
  }

  /* On mobile, the lessons in the Thread section are the only place they appear */

  .margin-note {
    position: static;
    width: 100%;
    padding-left: 1rem;
    border-left: 2px solid var(--warm-subtle);
    margin: 1.5rem 0;
    font-size: var(--text-xs);
  }
}

/* ---- Lesson markers — the 17 lessons accumulating in scroll ---- */
.lesson {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: 1.5;
  padding: 0.5rem 0;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.lesson.visible {
  opacity: 1;
}

.lesson-number {
  font-weight: 600;
  color: var(--warm);
  margin-right: 0.25rem;
}

.lesson-gap {
  color: var(--text-tertiary);
  font-style: italic;
}

/* ---- Interactive elements — containers ---- */
.interactive {
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 2.5rem 0;
}

.interactive-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 1rem;
}

/* ---- Data callouts — key numbers ---- */
.callout {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 1rem 1.25rem;
  border-radius: 4px;
  margin: 1.5rem 0;
}

.callout strong {
  color: var(--text);
}

/* ---- Links ---- */
a {
  color: var(--warm);
  text-decoration: none;
  border-bottom: 1px solid var(--warm-light);
  transition: border-color 0.2s ease;
}

a:hover {
  border-bottom-color: var(--warm);
}

/* ---- Selection ---- */
::selection {
  background: var(--warm-subtle);
  color: var(--text);
}

/* ---- Print ---- */
@media print {
  body {
    font-size: 11pt;
    color: #000;
    background: #fff;
  }

  .margin-note {
    display: none;
  }

  .interactive {
    display: none;
  }
}
