@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600;1,700&family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --cream:   #faf7f0;
  --paper:   #f2ede3;
  --ink:     #1c1a16;
  --ink2:    #3d3a33;
  --muted:   #8a8070;
  --rule:    #d4cdc0;
  --accent:  #9b4a1e;
  --serif:   'EB Garamond', Georgia, serif;
  --sans:    'Inter', system-ui, sans-serif;
}

/* Dark mode */
[data-theme="dark"] {
  --cream:  #141210;
  --paper:  #1e1b17;
  --ink:    #f0ece3;
  --ink2:   #c8c0b0;
  --muted:  #6a6258;
  --rule:   #2e2b25;
  --accent: #c8602e;
}
[data-theme="dark"] .article-nav {
  background: rgba(20,18,16,0.95);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--serif);
  background: var(--cream);
  color: var(--ink);
  font-size: 19px;
  line-height: 1.75;
}

/* Reading progress bar */
#progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--accent);
  z-index: 200;
  width: 0%;
  transition: width 0.1s linear;
}

/* Nav */
.article-nav {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  background: rgba(250,247,240,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  z-index: 100;
  font-family: var(--sans);
}
.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: color 0.2s;
}
.back-link:hover { color: var(--ink); }
.issue-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: 1px solid rgba(155,74,30,0.3);
  padding: 3px 12px;
  border-radius: 999px;
}

/* Masthead */
.masthead {
  text-align: center;
  padding: 48px 32px 0;
  border-bottom: 1px solid var(--rule);
}
.masthead-top {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.masthead-rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 36px;
}
.article-category {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}
.masthead h1 {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  max-width: 780px;
  margin: 0 auto 20px;
  color: var(--ink);
}
.masthead-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink2);
  max-width: 600px;
  margin: 0 auto 24px;
  line-height: 1.55;
}
.masthead-byline {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.masthead-byline span { color: var(--ink2); }
.byline-dot { color: var(--rule); }
.share-btn {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: none;
  border: 1px solid rgba(155,74,30,0.3);
  padding: 3px 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.share-btn:hover { background: var(--accent); color: var(--cream); }

/* Dark toggle in article nav */
.art-dark-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.35s;
  padding: 0;
  line-height: 1;
}
.art-dark-btn:hover { opacity: 1; transform: rotate(20deg); }

/* Prev / Next pagination */
.article-pagination {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--rule);
  margin-top: 40px;
}
.article-pagination a {
  padding: 24px 28px;
  text-decoration: none;
  color: var(--ink2);
  transition: background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--rule);
}
.article-pagination a:last-child { border-right: none; }
.article-pagination a.next { text-align: right; border-right: none; }
.article-pagination a:hover { background: var(--paper); }
.pagination-label {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.pagination-title {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

/* Text selection quote tooltip */
.selection-tooltip {
  position: absolute;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  cursor: pointer;
  z-index: 500;
  white-space: nowrap;
  display: none;
  border-radius: 2px;
  transform: translateX(-50%);
  transition: opacity 0.15s;
}
.selection-tooltip::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}

.masthead-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0 32px;
  color: var(--accent);
  font-size: 1rem;
}
.masthead-divider::before,
.masthead-divider::after {
  content: '';
  flex: 1;
  max-width: 80px;
  height: 1px;
  background: var(--rule);
}

/* Article body */
.article-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 52px 32px 100px;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 64px;
  align-items: start;
}

.article-body { max-width: 680px; }

.article-body p {
  margin-bottom: 24px;
  color: var(--ink2);
  font-size: 1.05rem;
  line-height: 1.8;
}

/* Drop cap */
.article-body p:first-of-type::first-letter {
  font-family: var(--serif);
  font-size: 5.2rem;
  font-weight: 800;
  line-height: 0.78;
  float: left;
  margin: 6px 10px 0 0;
  color: var(--ink);
}

.article-body h2 {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 52px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.article-body strong { color: var(--ink); font-weight: 600; }

/* Pull quote */
.pull-quote {
  margin: 48px 0;
  padding: 28px 0;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  text-align: center;
}
.pull-quote p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.45;
  color: var(--ink);
  margin: 0 !important;
}

/* Section divider */
.section-break {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 40px 0;
  color: var(--accent);
  font-size: 0.9rem;
}
.section-break::before,
.section-break::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* Source note */
.source-note {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  letter-spacing: 0.03em;
}

/* Sidebar */
.article-sidebar {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar-box {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  padding: 24px;
}
.sidebar-label {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}
.sidebar-box p {
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink2);
  margin-bottom: 14px;
}
.sidebar-box p:last-child { margin-bottom: 0; }
.sidebar-stat {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 4px;
}
.sidebar-stat-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* Article subscribe block */
.article-subscribe {
  grid-column: 1 / -1;
  background: var(--ink);
  padding: 52px;
  margin-top: 56px;
  text-align: center;
  border-top: 2px solid var(--ink);
}
.article-subscribe-label {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #9b4a1e;
  margin-bottom: 14px;
  display: block;
}
.article-subscribe h3 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--cream);
  margin-bottom: 10px;
  line-height: 1.2;
}
.article-subscribe p {
  font-family: var(--serif);
  font-style: italic;
  color: rgba(250,247,240,0.5);
  font-size: 1rem;
  margin-bottom: 28px;
}
.article-subscribe-btn {
  display: inline-block;
  padding: 12px 36px;
  background: #9b4a1e;
  color: var(--cream);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  transition: opacity 0.2s;
}
.article-subscribe-btn:hover { opacity: 0.82; }

/* Article footer */
.article-footer {
  grid-column: 1 / -1;
  margin-top: 20px;
  padding-top: 40px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}
.article-footer p {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
}
.btn-home {
  font-family: var(--sans);
  display: inline-block;
  padding: 10px 24px;
  border: 1px solid var(--rule);
  color: var(--ink2);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background 0.2s, border-color 0.2s;
}
.btn-home:hover {
  background: var(--paper);
  border-color: var(--ink2);
}

/* ══ ARTICLE UPGRADES ════════════════════════════════ */

/* TOC */
.article-toc {
  background: var(--paper); border: 1px solid var(--rule);
  border-top: 3px solid var(--ink); padding: 20px 24px;
}
.article-toc ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.article-toc li a {
  font-family: var(--sans); font-size: 0.74rem; color: var(--ink2);
  text-decoration: none; display: block; padding: 5px 0 5px 10px;
  border-left: 2px solid transparent; line-height: 1.4;
  transition: color 0.2s, border-color 0.2s;
}
.article-toc li a:hover,
.article-toc li a.toc-active { color: var(--accent); border-left-color: var(--accent); }

/* Reading info */
.reading-info {
  font-family: var(--sans); font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}

/* Title in sticky nav */
.article-nav { position: relative; overflow: hidden; }
.nav-article-title {
  font-family: var(--serif); font-size: 0.88rem; font-weight: 600;
  color: var(--ink2); position: absolute; left: 50%;
  transform: translateX(-50%) translateY(10px); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 340px;
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s;
}
.article-nav.show-title .nav-article-title { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Reading mode button */
.reading-mode-btn {
  font-family: var(--sans); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; background: none;
  border: 1px solid var(--rule); color: var(--muted); padding: 3px 10px;
  cursor: pointer; transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.reading-mode-btn:hover { color: var(--ink); border-color: var(--ink2); }
.reading-mode-btn.active { background: var(--ink); color: var(--cream); border-color: var(--ink); }
body.reading-mode .article-sidebar,
body.reading-mode .article-pagination,
body.reading-mode .article-subscribe { display: none !important; }
body.reading-mode .article-wrap { grid-template-columns: 1fr !important; gap: 0 !important; }
body.reading-mode .article-body { max-width: 680px; margin: 0 auto; }

/* Responsive */
@media (max-width: 860px) {
  .article-wrap {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  .article-sidebar { position: static; }
  .article-body { max-width: 100%; }
  .article-footer { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .masthead { padding: 32px 20px 0; }
  .article-wrap { padding: 36px 20px 80px; }
  .article-nav { padding: 12px 20px; }
}
