/* ═══════════════════════════════════════════════════════════════
   Interior — shared design system for csmusic docs
   Aeon/New Yorker inspired: Source Serif 4 + Inter
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  --text-body: 1.125rem;
  --text-lead: 1.25rem;
  --text-small: 0.8125rem;
  --text-xs: 0.6875rem;

  --h1-size: 2.75rem;
  --h2-size: 1.875rem;
  --h3-size: 1.375rem;
  --h4-size: 1.125rem;

  --line-height-body: 1.45;
  --line-height-heading: 1.15;
  --line-height-tight: 1.3;

  --measure: min(80ch, calc(100vw - 2rem));

  --space-paragraph: 1.75rem;
  --space-section: 3.5rem;

  --bg: #fafaf8;
  --text: #1a1a1a;
  --text-secondary: #555555;
  --text-tertiary: #999999;
  --border: #e5e5e5;
  --border-light: #f0f0f0;
  --accent: #1a1a1a;
  --accent-underline: rgba(0,0,0,0.15);
  --selection-bg: #d4d4d4;
  --card-bg: #ffffff;
  --code-bg: #f4f4f2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --text: #e8e8e8;
    --text-secondary: #888888;
    --text-tertiary: #555555;
    --border: #282828;
    --border-light: #1e1e1e;
    --accent: #ffffff;
    --accent-underline: rgba(255,255,255,0.15);
    --selection-bg: #333333;
    --card-bg: #181818;
    --code-bg: #181818;
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 100%;
}

body {
  font-family: var(--font-serif);
  font-size: var(--text-body);
  line-height: var(--line-height-body);
  color: var(--text);
  background: var(--bg);
  transition: background 0.3s, color 0.3s;
}

::selection { background: var(--selection-bg); color: var(--text); }

/* ── Shared Nav ── */

nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2.5rem;
  font-family: var(--font-sans);
  font-size: var(--text-small);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: linear-gradient(180deg, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}
nav a:hover { color: var(--text); }

.nav-links { display: flex; gap: 2rem; }
.nav-links a.active { color: var(--text); font-weight: 600; }

/* ── Page wrapper ── */

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* ── Headers ── */

.page-header {
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.page-category {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.page-title {
  font-family: var(--font-serif);
  font-size: var(--h1-size);
  font-weight: 700;
  line-height: var(--line-height-heading);
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  color: var(--text);
}

.page-subtitle {
  font-family: var(--font-serif);
  font-size: var(--text-lead);
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Body ── */

.page p {
  margin-bottom: var(--space-paragraph);
  orphans: 3;
  widows: 3;
}
.page p:last-child { margin-bottom: 0; }

.page h2 {
  font-family: var(--font-serif);
  font-size: var(--h2-size);
  font-weight: 700;
  line-height: var(--line-height-heading);
  letter-spacing: -0.01em;
  margin-top: 3.5rem;
  margin-bottom: 1.25rem;
  padding-top: 0.5rem;
}

.page h3 {
  font-family: var(--font-serif);
  font-size: var(--h3-size);
  font-weight: 600;
  line-height: var(--line-height-tight);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.page a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-underline);
  transition: border-color 0.2s;
}
.page a:hover { border-bottom-color: var(--text); }

.page hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 3.5rem 0;
}

/* ── Lists ── */

.page ul, .page ol {
  margin: 1.5rem 0;
  padding-left: 1.75rem;
}
.page li { margin-bottom: 0.5rem; }
.page li:last-child { margin-bottom: 0; }

/* ── Blockquote ── */

blockquote {
  margin: 2.5rem 0;
  padding: 0 0 0 2rem;
  border-left: 3px solid var(--text);
  font-style: italic;
  color: var(--text-secondary);
}
blockquote p {
  font-size: var(--text-lead);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}
blockquote cite {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-small);
  font-style: normal;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
}

/* ── Code ── */

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

pre {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--code-bg);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85em;
  line-height: 1.6;
  border: 1px solid var(--border-light);
}
pre code { background: none; padding: 0; }

/* ── Cards (for index, timeline) ── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  margin: 2rem 0;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, background 0.2s;
}
.card:hover {
  border-color: var(--text);
  background: var(--selection-bg);
}

.card .card-category {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 0.5rem;
}

.card .card-title {
  font-family: var(--font-serif);
  font-size: var(--h4-size);
  font-weight: 600;
  line-height: var(--line-height-tight);
  color: var(--text);
  margin-bottom: 0.5rem;
}

.card .card-excerpt {
  font-family: var(--font-serif);
  font-size: var(--text-small);
  color: var(--text-secondary);
  line-height: 1.5;
}

.card .card-meta {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 0.75rem;
}

/* ── Timeline (for story page) ── */

.timeline {
  position: relative;
  padding-left: 2.5rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 2.5rem;
  padding-left: 0.5rem;
}
.timeline-item:last-child { margin-bottom: 0; }

.timeline-item::before {
  content: '';
  position: absolute;
  left: -2.25rem;
  top: 0.6rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--bg);
}

.timeline-date {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 0.25rem;
}

.timeline-title {
  font-family: var(--font-serif);
  font-size: var(--h4-size);
  font-weight: 600;
  line-height: var(--line-height-tight);
  margin-bottom: 0.5rem;
}

.timeline-body {
  font-size: var(--text-body);
  color: var(--text-secondary);
  line-height: var(--line-height-body);
}
.timeline-body p { margin-bottom: 0.75rem; }
.timeline-body p:last-child { margin-bottom: 0; }

/* ── Stats / progress counters ── */

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin: 2rem 0;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stat {
  text-align: center;
  min-width: 100px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
}

/* ── Tags ── */

.tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
}
.tag:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ── Site footer ── */

.site-footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  font-family: var(--font-sans);
  font-size: var(--text-small);
  color: var(--text-tertiary);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: none;
}
.site-footer a:hover { color: var(--text); }

/* ── Responsive ── */

@media (max-width: 640px) {
  :root {
    --text-body: 1rem;
    --text-lead: 1.0625rem;
    --h1-size: 1.875rem;
    --h2-size: 1.5rem;
    --h3-size: 1.25rem;
    --measure: 100%;
  }

  nav {
    padding: 1rem 1.25rem;
    font-size: 0.75rem;
  }
  .nav-links { gap: 1rem; }
  .page { padding: 2rem 1.25rem 4rem; }
  .page-header { margin-bottom: 2rem; padding-bottom: 1.5rem; }
  blockquote { padding-left: 1.25rem; }
  .stats { flex-direction: column; gap: 1rem; }
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  :root { --h1-size: 1.875rem; }
}

/* ── Print ── */

@media print {
  nav, .site-footer { display: none; }
  body { font-size: 12pt; line-height: 1.6; color: #000; background: #fff; }
  .page { max-width: 100%; padding: 0; }
  a { border-bottom: none !important; }
}
