/* Editorial Serif — Premium print magazine and science journal featuring archival cream paper, elegant serifs, drop caps, and delicate hairline rules. */

/* --- CSS Variables & Palettes --- */
:root {
  --font-display: "Didot", "Bodoni MT", "Cinzel", "Baskerville", "Playfair Display", Georgia, serif;
  --font-body: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Courier New", Courier, monospace;

  /* Cream archival paper palette (Light Mode) */
  --bg: #faf7f0;
  --bg-subtle: #f2ede0;
  --surface: #ffffff;
  --surface-alt: #f5efe2;

  --border: #dfd5c4;
  --border-strong: #221c17;
  --border-focus: #8b251e;

  --text: #1d1814;
  --text-muted: #53483e;
  --text-dim: #7d6f62;

  --accent: #8b251e; /* Classic oxblood journal red (Contrast 6.4:1) */
  --accent-hover: #631812;
  --accent-soft: rgba(139, 37, 30, 0.08);

  --link: #8b251e;
  --link-hover: #4e120d;

  --card-bg: #ffffff;
  --card-border: #dfd5c4;
  --card-shadow: 0 2px 6px rgba(34, 28, 23, 0.04), 0 1px 2px rgba(34, 28, 23, 0.03);
  --card-shadow-hover: 0 10px 24px rgba(34, 28, 23, 0.09);

  /* Academic tags */
  --tag-bg: #f2ece0;
  --tag-text: #611e19;
  --tag-border: #d4c7b2;

  --max-width: 1140px;
  --read-width: 760px;
  --container-pad: 20px;
}

[data-theme="dark"] {
  /* Antique library / Midnight binding (Dark Mode) */
  --bg: #14110e;
  --bg-subtle: #1c1814;
  --surface: #1e1a16;
  --surface-alt: #27221d;

  --border: #3b332b;
  --border-strong: #dfd3c3;
  --border-focus: #e27a60;

  --text: #f3ede2;
  --text-muted: #b5a796;
  --text-dim: #887a6a;

  --accent: #e27a60; /* Terracotta editorial accent (Contrast 5.9:1) */
  --accent-hover: #f39c85;
  --accent-soft: rgba(226, 122, 96, 0.12);

  --link: #e27a60;
  --link-hover: #fcd5cb;

  --card-bg: #1b1713;
  --card-border: #342c23;
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --card-shadow-hover: 0 12px 28px rgba(0, 0, 0, 0.7);

  --tag-bg: #28211b;
  --tag-text: #e8a593;
  --tag-border: #4a3c30;
}

/* --- Base Resets & Layout --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--bg);
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[data-theme="dark"] body {
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
}

/* Links */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(139, 37, 30, 0.4);
}

[data-theme="dark"] a {
  text-decoration-color: rgba(226, 122, 96, 0.4);
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

p, h1, h2, h3, h4, h5, h6, li, a, span, time {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

img, video, iframe {
  max-width: 100%;
}

.site-header,
main,
.site-footer {
  width: 100%;
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--container-pad);
  padding-right: var(--container-pad);
}

main {
  flex: 1 0 auto;
}

main > article {
  max-width: var(--read-width);
  margin-left: auto;
  margin-right: auto;
}

/* --- Header & Academic Masthead --- */
.site-header {
  padding-top: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header::after {
  content: "";
  display: block;
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-strong);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 44px;
}

.site-brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  position: relative;
}

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

/* --- Theme Toggle Button --- */
.theme-toggle {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--surface-alt);
  border-color: var(--border-focus);
  color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* --- Site Intro: Print Edition Frontispiece --- */
.site-intro {
  padding: 4.5rem 0 3rem 0;
  text-align: center;
  position: relative;
  margin-bottom: 3.5rem;
}

.site-intro::before {
  content: "THE SCIENTIFIC DISPATCH";
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

.site-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 6.5vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 auto 1.25rem auto;
  color: var(--text);
  max-width: 900px;
}

.site-description {
  font-family: var(--font-body);
  font-size: clamp(1.15rem, 2.2vw, 1.4rem);
  font-style: italic;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 660px;
  margin: 0 auto;
}

.site-intro::after {
  content: "";
  display: block;
  width: 140px;
  height: 2px;
  background: var(--accent);
  margin: 2.5rem auto 0 auto;
}

/* --- Article Grid: Print Gazette Spread --- */
.article-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  margin-bottom: 6rem;
}

@media (min-width: 640px) {
  .article-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    column-gap: 2.5rem;
    row-gap: 3.5rem;
  }
}

@media (min-width: 1024px) {
  .article-list {
    grid-template-columns: repeat(3, 1fr);
    column-gap: 2.5rem;
    row-gap: 4rem;
  }

  .article-card.card-featured {
    grid-column: span 3;
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 3rem;
    align-items: center;
    padding-bottom: 3.5rem;
    border-bottom: 2px solid var(--border-strong);
  }

  .article-card.card-featured .card-thumb {
    margin-bottom: 0;
    height: 100%;
  }

  .article-card.card-featured .card-title {
    font-size: clamp(2rem, 3.2vw, 2.85rem);
  }
}

/* --- Article Card --- */
.article-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--card-shadow);
  position: relative;
  padding: 1.25rem;
}

.article-card::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  right: 4px;
  bottom: 4px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  pointer-events: none;
}

[data-theme="dark"] .article-card::before {
  border-color: rgba(255, 255, 255, 0.04);
}

.card-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: var(--surface-alt);
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  filter: contrast(1.02) sepia(0.06);
}

.card-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.015em;
  margin: 0 0 0.85rem 0;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

.card-title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* Metadata & Academic Badges */
.card-meta,
.article-meta {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.95rem;
}

.card-meta time,
.article-meta time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--tag-border);
  border-radius: 1px;
  line-height: 1;
}

.card-description {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin: 0;
  margin-top: auto;
}

/* --- Article Detail Page --- */
.article-header {
  margin: 3.5rem 0 2.5rem 0;
  padding-bottom: 2rem;
  border-bottom: 3px double var(--border-strong);
  text-align: center;
}

.article-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 5.2vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.14;
  margin: 0 0 1.5rem 0;
  color: var(--text);
}

.article-header .article-meta {
  justify-content: center;
  font-size: 0.85rem;
}

.article-cover {
  width: 100%;
  margin: 0 0 2.5rem 0;
  border: 1px solid var(--border);
  padding: 6px;
  background: var(--surface);
}

.article-cover img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

/* Video Container */
.video-container {
  aspect-ratio: 9 / 16;
  max-width: 380px;
  width: 100%;
  margin: 3rem auto;
  background: #000;
  border: 2px solid var(--border-strong);
  position: relative;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
}

.video-container iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.video-container .video-lite-link {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  text-decoration: none;
  min-height: 44px;
}

.video-container .video-lite-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-container .video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  padding-left: 4px;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* --- Article Body with Drop Cap --- */
.article-body {
  font-family: var(--font-body);
  font-size: 1.1875rem;
  line-height: 1.85;
  color: var(--text);
}

/* Elegant Magazine Drop Cap */
.article-body > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 4.5rem;
  line-height: 0.8;
  float: left;
  margin: 0.15rem 0.65rem 0 0;
  padding: 0.2rem 0.3rem 0.1rem 0.1rem;
  color: var(--accent);
  font-weight: 700;
}

.article-body > p:first-of-type {
  font-size: 1.3rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 2rem;
}

.article-body p {
  margin: 1.75rem 0;
  text-align: justify;
  text-justify: inter-word;
}

.article-body h2 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3.2vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 3.5rem 0 1.25rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.article-body h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2.5rem 0 0.85rem 0;
  color: var(--text);
}

.article-body strong {
  font-weight: 700;
  color: var(--text);
}

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

.article-body ul {
  margin: 2rem 0;
  padding-left: 2rem;
}

.article-body li {
  margin-bottom: 0.75rem;
  line-height: 1.75;
}

/* --- Medical Disclaimer Notice --- */
.medical-disclaimer {
  margin: 3.5rem 0 2.5rem 0;
  padding: 1.5rem 1.75rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent);
  position: relative;
}

.medical-disclaimer::before {
  content: "§ ADVISORY NOTICE";
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.medical-disclaimer-content {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.medical-disclaimer strong {
  color: var(--text);
  font-weight: 700;
}

/* --- Sources & Bibliography Section --- */
.sources {
  margin-top: 4.5rem;
  padding: 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.sources h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 1.5rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.sources ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sources li {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed var(--border);
  text-indent: -1.25rem;
  padding-left: 1.25rem;
}

.sources li:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.sources strong {
  color: var(--text);
  font-weight: 700;
}

/* --- Static / Legal Pages --- */
main > article > h1 {
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 3.5rem 0 1.5rem 0;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-strong);
  text-align: center;
}

main > article > h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  margin: 3rem 0 1rem 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

main > article p {
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.8;
}

main > article ul {
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.75;
  padding-left: 2rem;
}

main > article li {
  margin-bottom: 0.6rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.2em 0.45em;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

/* --- 404 Page --- */
.not-found {
  text-align: center;
  padding: 6rem 1rem 7rem 1rem;
}

.not-found h1 {
  font-family: var(--font-display);
  font-size: clamp(5.5rem, 14vw, 8.5rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 0;
  line-height: 1;
  color: var(--accent);
}

.not-found h2 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  margin: 1.5rem 0;
}

.not-found p {
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 2.5rem auto;
  font-size: 1.15rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.75rem 2rem;
  background: var(--border-strong);
  color: var(--bg) !important;
  text-decoration: none !important;
  border: 1px solid var(--border-strong);
  border-radius: 0;
}

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

/* --- Site Footer: Academic Colophon --- */
.site-footer {
  margin-top: 6rem;
  padding-top: 3.5rem;
  padding-bottom: 5rem;
  border-top: 3px double var(--border-strong);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-links,
.footer-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem;
  margin-bottom: 1.5rem;
}

.footer-links a,
.footer-socials a {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.footer-links a:hover,
.footer-socials a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-copy {
  margin-top: 2rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-dim);
}

/* --- Motion (Tasteful, Reduced-Motion Protected) --- */
@media (prefers-reduced-motion: no-preference) {
  a, .btn, .theme-toggle, .article-card, .video-play-btn {
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  }

  .article-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--card-shadow-hover);
  }

  .video-container:hover .video-play-btn {
    transform: translate(-50%, -50%) scale(1.08);
  }
}

/* --- Mobile Breakpoint Tweaks --- */
@media (max-width: 600px) {
  .site-intro {
    padding: 3rem 0 2rem 0;
    margin-bottom: 2rem;
  }
  .article-card {
    padding: 1rem;
  }
  .article-body p {
    text-align: left;
  }
}
