/* story.css — Shared styles for LITF article pages */

:root {
  --bg: #ffffff; --bg-alt: #f8f9fa; --text: #1a1a2e; --text-muted: #6c757d;
  --accent: #6c5ce7; --accent-hover: #5a4bd1; --accent-light: rgba(108,92,231,0.1);
  --border: #e9ecef; --card-bg: #ffffff; --font: 'Inter', -apple-system, sans-serif;
}
html.dark {
  --bg: #0f0f1a; --bg-alt: #1a1a2e; --text: #e8e8f0; --text-muted: #9090a8;
  --accent: #a29bfe; --accent-hover: #b8b2ff; --accent-light: rgba(162,155,254,0.15);
  --border: #2d2d44; --card-bg: #1a1a2e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; -webkit-font-smoothing: antialiased; transition: background 0.3s, color 0.3s; }
a { color: var(--accent); text-decoration: none; }

/* Layout */
.story-page { max-width: 720px; margin: 0 auto; padding: 32px 24px 64px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; margin-bottom: 24px; color: var(--text-muted); }
.back-link:hover { color: var(--accent); }

/* Header */
.story-kicker { display: inline-block; padding: 3px 12px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; background: var(--accent-light); color: var(--accent); margin-bottom: 12px; }
.story-title { font-size: 2rem; font-weight: 800; line-height: 1.2; margin-bottom: 12px; }
.story-deck { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 16px; }
.story-byline { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 32px; }
.story-byline strong { color: var(--text); }
.story-hero { width: 100%; border-radius: 12px; margin-bottom: 24px; overflow: hidden; max-width: 100%; height: auto; display: block; object-fit: cover; }
.story-hero img { width: 100%; height: auto; display: block; object-fit: cover; border-radius: 12px; }
.story-hero-img { width: 100%; max-height: 400px; object-fit: cover; border-radius: 12px; margin-bottom: 24px; }

/* Body */
.story-body { font-size: 1.05rem; line-height: 1.75; }
.story-body h2 { font-size: 1.4rem; font-weight: 700; margin: 32px 0 12px; }
.story-body p { margin-bottom: 16px; }
.story-body table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.9rem; }
.story-body th { text-align: left; padding: 10px 12px; background: var(--accent-light); color: var(--accent); font-weight: 600; border-bottom: 2px solid var(--accent); }
.story-body td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.story-body blockquote { border-left: 3px solid var(--accent); padding: 12px 20px; margin: 20px 0; background: var(--accent-light); border-radius: 0 8px 8px 0; font-style: italic; }
.story-body ul, .story-body ol { margin: 16px 0; padding-left: 24px; }
.story-body li { margin-bottom: 8px; }

/* Bottom Line / Closing */
.bottom-line { background: var(--accent-light); padding: 20px; border-radius: 12px; margin: 32px 0; border-left: 4px solid var(--accent); }
.bottom-line h3 { margin-top: 0; color: var(--accent); margin-bottom: 8px; font-size: 1.1rem; }

/* Related */
.related { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.related h3 { font-size: 1.1rem; margin-bottom: 16px; }
.related a { display: block; margin-bottom: 8px; }

/* Share bar */
.share-bar { display: flex; align-items: center; gap: 10px; margin: 32px 0; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.share-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.share-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; background: var(--bg-alt); color: var(--text); text-decoration: none; font-weight: 700; font-size: 0.9rem; border: 1px solid var(--border); cursor: pointer; transition: all 0.2s; font-family: var(--font); }
.share-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); transform: translateY(-1px); }
.share-copy { font-size: 1rem; }

/* Reading progress bar */
.reading-progress { position: fixed; top: 0; left: 0; width: 0; height: 3px; background: var(--accent); z-index: 9999; transition: width 0.1s; }

/* Sources section */
.sources { margin-top: 48px; padding: 24px; background: var(--bg-alt); border-radius: 12px; border: 1px solid var(--border); }
.sources h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; color: var(--accent); }
.sources ol { padding-left: 24px; margin: 0; font-size: 0.85rem; line-height: 1.6; }
.sources li { margin-bottom: 8px; color: var(--text-muted); }
.sources li a { color: var(--accent); word-break: break-word; }
.sources li a:hover { text-decoration: underline; }

/* Theme toggle button */
.theme-toggle { position: fixed; top: 12px; right: 12px; z-index: 9998; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem; transition: all 0.2s; }
.theme-toggle:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Table scroll wrapper (injected by story.js for mobile) */
.table-scroll-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 20px -12px; padding: 0 12px; }
.table-scroll-wrapper table { margin: 0; min-width: 480px; }

/* Responsive — Tablet */
@media (max-width: 768px) {
  .story-title { font-size: 1.5rem; line-height: 1.25; }
  .story-page { padding: 20px 16px 48px; }
  .article-nav { flex-direction: column; }
  .nav-link { max-width: 100%; }
  .story-body { font-size: 1rem; line-height: 1.75; }
  .story-body h2 { font-size: 1.2rem; margin: 28px 0 10px; }
  .story-body h3 { font-size: 1.1rem; }
  .story-deck { font-size: 1rem; }
  .story-hero-img { max-height: 240px; border-radius: 8px; }
  .story-hero { border-radius: 8px; }
  .bottom-line { padding: 16px; }
  .sources { padding: 16px; }
  .share-bar { gap: 8px; padding: 12px 0; }
  .story-body blockquote { padding: 10px 16px; margin: 16px 0; font-size: 0.95rem; }
  .story-body ul, .story-body ol { padding-left: 20px; }
  .story-body img { width: 100%; height: auto; border-radius: 8px; }
  .story-body pre { overflow-x: auto; font-size: 0.8rem; padding: 12px; }
  .story-body code { font-size: 0.85em; }
  .story-body table { font-size: 0.85rem; }
  .story-body td, .story-body th { padding: 6px 8px; }
}

/* Responsive — Phone */
@media (max-width: 480px) {
  .story-title { font-size: 1.3rem; line-height: 1.3; letter-spacing: -0.01em; }
  .story-page { padding: 16px 12px 40px; }
  .story-body { font-size: 0.95rem; line-height: 1.7; }
  .story-body h2 { font-size: 1.1rem; margin: 24px 0 8px; }
  .story-deck { font-size: 0.9rem; line-height: 1.5; }
  .story-byline { font-size: 0.8rem; }
  .story-kicker { font-size: 0.7rem; }
  .story-hero-img { max-height: 200px; }
  .sources { padding: 12px; }
  .sources ol { font-size: 0.8rem; }
  .sources li { margin-bottom: 6px; }
  .bottom-line { padding: 12px; margin: 24px 0; }
  .bottom-line h3 { font-size: 1rem; }
  .share-bar { flex-wrap: wrap; gap: 6px; padding: 10px 0; }
  .share-btn { width: 32px; height: 32px; font-size: 0.8rem; }
  .back-link { font-size: 0.8rem; margin-bottom: 16px; }
  .story-body blockquote { padding: 8px 12px; margin: 12px 0; font-size: 0.9rem; }
  .story-body table { font-size: 0.8rem; }
  .story-body td, .story-body th { padding: 5px 6px; white-space: normal; }
  .reading-progress { height: 2px; }
  .theme-toggle { width: 32px; height: 32px; font-size: 0.85rem; top: 8px; right: 8px; }
  /* Hero full-bleed on small screens */
  .story-hero { border-radius: 0; margin-left: -12px; margin-right: -12px; width: calc(100% + 24px); }
}

/* Responsive — Small phone */
@media (max-width: 360px) {
  .story-title { font-size: 1.15rem; }
  .story-page { padding: 12px 10px 36px; }
  .story-body { font-size: 0.9rem; }
  .story-deck { font-size: 0.85rem; }
  .story-hero { margin-left: -10px; margin-right: -10px; width: calc(100% + 20px); }
}

/* Code blocks */
.story-body pre { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px; padding: 16px; overflow-x: auto; margin: 16px 0; }
.story-body code { font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; background: var(--bg-alt); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.story-body pre code { background: none; padding: 0; font-size: 0.85rem; }

/* Images in body */
.story-body img { max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; }
.story-body figure { margin: 24px 0; }
.story-body figcaption { font-size: 0.8rem; color: var(--text-muted); text-align: center; margin-top: 8px; }

/* Prev/Next Article Nav */
.article-nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.nav-link { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); padding: 16px; border-radius: 12px; background: var(--bg-alt); border: 1px solid var(--border); max-width: 48%; transition: all 0.2s; }
.nav-link:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.nav-dir { font-size: 0.75rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.nav-title { font-size: 0.85rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nav-newer { text-align: right; margin-left: auto; }
.nav-placeholder { flex: 1; }

/* Better heading anchors */
.story-body h2 { scroll-margin-top: 24px; }
.story-body h3 { font-size: 1.2rem; font-weight: 600; margin: 28px 0 10px; }

/* Smoother link underlines */
.story-body a { text-decoration-thickness: 1px; text-underline-offset: 2px; transition: color 0.2s; }
.story-body a:hover { text-decoration-thickness: 2px; }

/* Superscript reference links */
.ref-link { font-size: 0.75em; vertical-align: super; line-height: 0; }
.ref-link a { text-decoration: none; }

/* Better blockquote style */
.story-body blockquote p { margin-bottom: 8px; }
.story-body blockquote p:last-child { margin-bottom: 0; }
