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

/* Tokens */
:root {
  --color-bg: #faf8f5;
  --color-text: #1a1a1a;
  --color-muted: #666;
  --color-accent: #8b1a1a;
  --color-accent-hover: #6a1414;
  --color-border: #ddd;
  --color-tag-bg: #f0e8e8;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: system-ui, -apple-system, sans-serif;
  --max-width: 72ch;
  --space: 1rem;
}

/* Base */
html {
  font-size: 18px;
  background: var(--color-bg);
  color: var(--color-text);
}

body {
  font-family: var(--font-sans);
  line-height: 1.6;
}

/* Layout */
.container {
  max-width: calc(var(--max-width) + 4rem);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 0;
  background: #fff;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-accent);
  text-decoration: none;
  flex-shrink: 0;
}

.site-title:hover {
  color: var(--color-accent-hover);
}

/* Nav */
.site-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-nav a {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--color-muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--color-accent);
}

/* Breadcrumb */
.breadcrumb {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--color-muted);
  font-family: var(--font-sans);
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.breadcrumb li+li::before {
  content: "›";
  margin-right: 0.25rem;
}

.breadcrumb a {
  color: var(--color-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--color-accent);
}

/* Main */
main.container {
  padding-top: 1.5rem;
  padding-bottom: 3rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1rem 0;
  color: var(--color-muted);
  font-family: var(--font-sans);
}

.site-footer p {
  font-size: 0.8rem;
}

/* Links */
a {
  color: var(--color-accent);
}

a:hover {
  color: var(--color-accent-hover);
}

/* Headings */
h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem;
}

/* Story list (used on homepage, /stories/, author pages, year pages) */
.story-list {
  list-style: none;
  margin-top: 1rem;
}

.story-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
}

.story-item:last-child {
  border-bottom: none;
}

.story-item a {
  font-family: var(--font-sans);
  font-weight: 600;
  text-decoration: none;
}

.story-item a:hover {
  text-decoration: underline;
}

.byline {
  display: block;
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
  font-family: var(--font-sans);
}

/* Article (single story) */
article.story {
  max-width: var(--max-width);
}

article.story h1 {
  margin-bottom: 0.5rem;
}

.story-meta {
  font-size: 0.85rem;
  color: var(--color-muted);
  font-family: var(--font-sans);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

.story-body {
  font-family: var(--font-serif);
  line-height: 1.8;
  margin-top: 1.5rem;
}

.story-body p {
  margin-bottom: 1rem;
}

.story-body em {
  font-style: italic;
}

.story-body strong {
  font-weight: bold;
}

/* Story summary */
.story-summary {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--color-muted);
  font-style: italic;
  border-left: 3px solid var(--color-accent);
  padding: 0.5rem 0.85rem;
  margin: 1rem 0;
  line-height: 1.5;
}

/* Tags */
.tags,
.story-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tag {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  background: var(--color-tag-bg);
  color: var(--color-accent);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid #d9c8c8;
}

.tag:hover {
  background: #e0d0d0;
  color: var(--color-accent-hover);
}

/* Chapter TOC */
.chapter-toc {
  margin: 1.5rem 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.chapter-toc h2 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.chapter-toc nav,
#TableOfContents {
  margin: 0;
  padding: 0;
}

.chapter-toc ul,
#TableOfContents ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapter-toc li {
  margin: 0.25rem 0;
}

.chapter-toc a {
  color: var(--color-accent);
  text-decoration: none;
}

.chapter-toc a:hover {
  text-decoration: underline;
}

/* Source link */
.source-link {
  font-size: 0.8rem;
  font-family: var(--font-sans);
  margin-top: 2rem;
  color: var(--color-muted);
}

.source-link a {
  color: var(--color-muted);
}

.source-link a:hover {
  color: var(--color-accent);
}

/* Button */
.btn {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  padding: 0.5rem 1.25rem;
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  margin-top: 0.5rem;
}

.btn:hover {
  background: var(--color-accent-hover);
  color: #fff;
}

/* Section header (for list pages) */
.section-header {
  margin-bottom: 1.5rem;
}

.section-header h1 {
  margin-bottom: 0.25rem;
}

.section-header p {
  font-size: 0.9rem;
  color: var(--color-muted);
  font-family: var(--font-sans);
}

/* Tag list page */
.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.tag-list li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tag-count {
  font-size: 0.75rem;
  color: var(--color-muted);
  font-family: var(--font-sans);
}

/* Year list page */
.year-list {
  list-style: none;
  margin-top: 1rem;
}

.year-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
}

.year-list li:last-child {
  border-bottom: none;
}

.year-list a {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
}

.year-list a:hover {
  text-decoration: underline;
}

/* Home section */
.home-intro {
  font-family: var(--font-sans);
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.recent-stories {
  margin-top: 2rem;
}

.recent-stories h2 {
  font-size: 1.1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.4rem;
}

/* Reading time */
.reading-time {
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* Related stories */
.related-stories {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--color-border);
  max-width: var(--max-width);
}

.related-stories h2 {
  font-size: 1.1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

/* Author list */
.author-list {
  list-style: none;
  margin-top: 1rem;
}

.author-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

.author-item:last-child {
  border-bottom: none;
}

.author-item > a {
  font-family: var(--font-sans);
  font-weight: 600;
  text-decoration: none;
}

.author-item > a:hover {
  text-decoration: underline;
}

.author-bio {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-top: 0.3rem;
}

/* 404 page */
.not-found {
  padding: 3rem 0;
}

.not-found h1 {
  margin-bottom: 0.5rem;
}

.not-found p {
  font-family: var(--font-sans);
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

.not-found-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.not-found-links a {
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .site-header .container {
    gap: 0.75rem;
  }
}