/* ============================================================
GLOBAL RESET & BASE LAYOUT
============================================================ */

/* Universal Selector: Resets default browser spacing and ensures padding/border 
   are included in element's total width and height */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #1a1a1a;
  color: #1e1e2a;
  line-height: 1.6;
  scroll-behavior: smooth;
  max-width: 100%;
  margin: 0;
  /* Matches index.html padding precisely to ensure aligned side distances */
  padding: 2rem max(20px, 5%);
}

/* ============================================================
BACKGROUND VIDEO LAYER
============================================================ */

/* Fixed video container that sits behind all content */
#video-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
}

/* Video element styling to ensure it covers the screen without distortion */
#intro-video {
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  object-fit: cover;
  background-color: #000;
}

/* ============================================================
STRUCTURAL CONTENT CONTAINERS
============================================================ */

/* Main content wrapper that centers the article and limits maximum width */
.container, main {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 0;
}

/* ============================================================
NAVIGATION HEADER
============================================================ */

/* Top navigation bar with frosted glass effect */
.top-header {
  position: relative;
  background: rgba(255, 255, 255, 0.73);
  backdrop-filter: blur(4px);
  border-radius: 3rem;
  padding: 1rem 2rem;
  margin-bottom: 2rem;
  border: 1px solid rgba(235, 233, 228, 0.8);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.nav-links a {
  text-decoration: none;
  color: #4a3f2e;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.nav-links a:hover {
  color: #b2773c;
}

/* Circular button for toggling dark/light mode */
.theme-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #e2d9cd;
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  transition: transform 0.2s;
}

.theme-toggle-btn:hover {
  transform: scale(1.05);
}

/* ============================================================
MONOGRAPH FRAMEWORK LAYOUT
============================================================ */

/* The main white card containing the article content */
.chapter-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(2px);
  border-radius: 2rem;
  padding: 3rem;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(235, 233, 228, 0.8);
  margin-bottom: 2rem;
  width: 100%;
}

h1.chapter-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #1e1e2a;
  line-height: 1.2;
  margin-bottom: 1.5rem;
}

.article-subtitle {
  font-size: 1.2rem;
  font-weight: 500;
  color: #7b6b54;
  border-left: 3px solid #c9ad7a;
  padding-left: 1rem;
  margin-bottom: 2.5rem;
}

.article-meta {
  margin-bottom: 3.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ============================================================
ARTICLE CONTENT TYPOGRAPHY
============================================================ */

/* Ensures all text elements use the Inter font family */
.prose-section, .prose-section p, .prose-section li, .prose-section ul, .prose-section ol {
  font-family: 'Inter', sans-serif;
}

.prose-section {
  font-size: 1.05rem;
  color: #2e2d2c;
  margin-bottom: 2rem;
}

/* Justifies all paragraph text for a clean, book-like appearance */
.prose-section p {
  margin-bottom: 1.5rem;
  text-align: justify;
}

/* Section headings with bottom border separator */
h2.section-heading {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  color: #1e1e2a;
  border-bottom: 1px solid #e4dbcf;
  padding-bottom: 0.4rem;
}

/* Justifies list items to match paragraph alignment */
.prose-section li {
  margin-bottom: 0.5rem;
  text-align: justify;
}

.prose-section ul,
.prose-section ol {
  margin: 1rem 0 1rem 2rem;
}

/* ============================================================
IMAGES & FIGURES
============================================================ */

/* 
   IMAGE CONTAINER SETTINGS 
   To test left/right margins: 
   1. Change 'width' to less than 100% (e.g., 90% or 83%).
   2. Keep 'margin: 2rem auto;' to ensure it stays centered.
*/
.captioned-image-container, figure, .image2-inset, .image-link, .main-article-image {
  display: block;
  width: 100%;       /* Full size by default. Change to 90% or 83% to test margins. */
  margin: 2rem auto; /* Centers the image block if width is less than 100% */
  clear: both;
}

/* Image element styling within the containers */
.captioned-image-container img, figure img, .image2-inset img, .main-article-image img {
  width: 100%;       /* Forces image to fill its container completely */
  max-width: 100%;
  height: auto;      /* Maintains aspect ratio */
  border-radius: 12px;
  display: block;
  object-fit: cover;
  margin: 0;
}

/* ============================================================
SPECIAL CONTENT BLOCKS
============================================================ */

/* Container for mathematical formulas and code blocks */
.math-container {
  background: rgba(250, 247, 242, 0.85);
  border: 1px solid #e7dfd2;
  border-radius: 1rem;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  width: 100%;
}

.math-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #7b6b54;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.canonical-box {
  border-left: 4px solid #c6a15b;
  background: rgba(255, 255, 255, 0.95);
  padding: 1rem;
  border-radius: 0.5rem;
  margin-top: 0.5rem;
}

.epistemic-note {
  background: rgba(255, 246, 234, 0.95);
  padding: 1.2rem 1.5rem;
  border-radius: 1rem;
  margin: 2rem 0;
  font-size: 0.95rem;
  border-left: 4px solid #c6a15b;
  width: 100%;
}

/* ============================================================
TABLES
============================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 1rem;
  overflow: hidden;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e7dfd2;
}

th {
  background: rgba(168, 113, 58, 0.15);
  color: #a8713a;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: none;
}

/* ============================================================
METRIC GRID
============================================================ */

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 2rem 0;
  width: 100%;
}

.metric-card {
  background: rgba(254, 252, 247, 0.95);
  border: 1px solid #eee7df;
  border-radius: 1rem;
  padding: 1.5rem;
}

.metric-card h3 {
  font-size: 1.1rem;
  color: #a8713a;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.metric-card p {
  font-size: 0.95rem;
  color: #2e2d2c;
  text-align: left !important;
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
FOOTER ELEMENTS
============================================================ */

/* Original Article Link: Left-aligned, large font, white/orange colors */
.original-link {
  text-align: left;
  font-size: 1.7rem; /* Double the size of the footer text */
  color: #ffffff;
  margin: 1.5rem 0;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.original-link a {
  color: #f0b86e;
  text-decoration: none;
}

.original-link:hover {
  font-size: 3.4rem; /* Doubles the base size on hover */
}

/* Contact Mini: Centered contact information bar */
.contact-mini {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
  color: #e0e0e0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  padding: 0.8rem 1.5rem;
  border-radius: 2rem;
  width: fit-content;
  margin: 2rem auto 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.contact-mini a {
  color: #e0e0e0;
  text-decoration: none;
  font-weight: 500;
}

.contact-mini a:hover {
  color: #f0b86e;
  text-decoration: underline;
}

/* Copyright Footer: Centered, small white text at the very bottom */
.copyright {
  text-align: center;
  color: #ffffff;
  font-size: 0.85rem;
  margin-top: 2rem;
  padding-bottom: 2rem;
  opacity: 0.8;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
DARK MODE OVERRIDES
============================================================ */

[data-theme="dark"] body {
  background: transparent;
}

[data-theme="dark"] .top-header,
[data-theme="dark"] .chapter-card {
  background: rgba(30, 41, 59, 0.85) !important;
  border-color: #475569 !important;
  color: #e5e7eb;
}

[data-theme="dark"] h1.chapter-title,
[data-theme="dark"] h2.section-heading {
  color: #f8fafc;
}

[data-theme="dark"] h2.section-heading {
  border-bottom-color: #334155;
}

[data-theme="dark"] .article-subtitle {
  color: #cbd5e1;
  border-left-color: #f0b86e;
}

[data-theme="dark"] .prose-section {
  color: #d1d5db;
}

[data-theme="dark"] .math-container {
  background: rgba(15, 23, 42, 0.6);
  border-color: #334155;
}

[data-theme="dark"] .math-label {
  color: #94a3b8;
}

[data-theme="dark"] .canonical-box {
  background: rgba(30, 41, 59, 0.95);
  border-left-color: #f0b86e;
}

[data-theme="dark"] .epistemic-note {
  background: rgba(30, 42, 58, 0.95);
  color: #e2e8f0;
  border-left-color: #f0b86e;
}

[data-theme="dark"] .nav-links a {
  color: #cbd5e1;
}

[data-theme="dark"] .nav-links a:hover {
  color: #f0b86e;
}

[data-theme="dark"] .theme-toggle-btn {
  background: rgba(21, 27, 43, 0.9);
  border-color: #475569;
  color: #cbd5e1;
}

[data-theme="dark"] .contact-mini {
  background: rgba(0, 0, 0, 0.8);
  border-color: #475569;
}

[data-theme="dark"] .metric-card {
  background: rgba(15, 23, 42, 0.5);
  border-color: #334155;
}

[data-theme="dark"] .metric-card h3 {
  color: #f0b86e;
}

[data-theme="dark"] .metric-card p {
  color: #cbd5e1;
}

[data-theme="dark"] table {
  background: rgba(30, 41, 59, 0.95);
}

[data-theme="dark"] th,
[data-theme="dark"] td {
  border-bottom-color: #334155;
  color: #cbd5e1;
}

[data-theme="dark"] th {
  background: rgba(240, 184, 110, 0.15);
  color: #f0b86e;
}

[data-theme="dark"] .original-link {
  color: #ffffff;
}

[data-theme="dark"] .original-link a {
  color: #f0b86e;
}

[data-theme="dark"] .copyright {
  color: #ffffff;
  opacity: 0.8;
}