/* ==================================
   1. CSS VARIABLES & THEME
   ================================== */
:root {
  /* Palette */
  --bg-body: #2f0607;         
  --bg-surface: #5e0c0f;      
  --bg-code: #110505;         
  
  --text-primary: #f5ecd9;    
  --text-secondary: #c4b5a2;  
  --text-heading: #eeffff;    
  
  --gold-primary: #d4af37;    
  --gold-light: #ebd67c;      
  --gold-muted: #9e8228;      
  
  --red-accent: #8d1217;      
  --red-deep: #bc181f;        

  /* Typography */
  --font-serif: 'Lora', 'Georgia', 'Times New Roman', serif;
  --font-display: 'Playfair Display', 'Didot', 'Bodoni MT', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Fira Code', 'Consolas', monospace;
}

/* ==================================
   2. BASE & RESET
   ================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.125rem; /* 18px base for readability */
  line-height: 1.75;   /* Generous line height for long reading */
  padding: 2rem 1.5rem;
}

/* ==================================
   3. ARTICLE CONTAINER & LAYOUT
   ================================== */
article {
  max-width: 68ch; /* The golden rule for line length (65-75 chars) */
  margin: 0 auto;
  padding: 2rem 0 4rem;
  font-family: var(--font-mono);
}

/* ==================================
   4. TYPOGRAPHY & HEADINGS
   ================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--gold-primary);
  font-weight: 600;
  line-height: 1.2;
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  letter-spacing: 0.01em;
}

h1 {
  font-size: 2.75rem;
  color: var(--text-heading);
  margin-top: 0;
  margin-bottom: 0.5em;
  line-height: 1.15;
  border-bottom: 2px solid var(--gold-muted);
  padding-bottom: 0.5em;
}

h2 {
  font-size: 2rem;
  border-left: 4px solid var(--gold-primary);
  padding-left: 0.6em;
}

h3 {
  font-size: 1.5rem;
  color: var(--gold-light);
}

h4 {
  font-size: 1.25rem;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

p {
  margin-bottom: 1.5em;
  text-rendering: optimizeLegibility;
}

/* Elegant Drop Cap for the first paragraph */
article > p:first-of-type::first-letter {
  float: left;
  font-family: var(--font-display);
  font-size: 4.5rem;
  line-height: 0.8;
  padding-right: 0.12em;
  padding-top: 0.08em;
  color: var(--gold-primary);
  font-weight: 700;
}

/* ==================================
   5. LINKS & EMPHASIS
   ================================== */
a {
  color: var(--gold-light);
  text-decoration: underline;
  text-decoration-color: var(--red-accent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: all 0.2s ease;
}

a:hover {
  color: var(--gold-primary);
  text-decoration-color: var(--gold-primary);
  text-decoration-thickness: 2px;
}

strong, b {
  color: var(--text-heading);
  font-weight: 700;
}

em, i {
  color: var(--gold-light);
  font-style: italic;
}

/* ==================================
   6. BLOCKQUOTES & CITATIONS
   ================================== */
blockquote {
  background-color: var(--bg-surface);
  border-left: 4px solid var(--gold-primary);
  margin: 2.5rem 0;
  padding: 1.5rem 2rem;
  font-style: italic;
  color: var(--text-secondary);
  border-radius: 0 8px 8px 0;
  font-size: 1.2rem;
  line-height: 1.6;
  position: relative;
}

blockquote::before {
  content: '"';
  position: absolute;
  top: -10px;
  left: 15px;
  font-family: var(--font-display);
  font-size: 4rem;
  color: var(--gold-muted);
  opacity: 0.5;
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote cite {
  display: block;
  margin-top: 1rem;
  font-size: 0.9rem;
  font-style: normal;
  font-family: var(--font-sans);
  color: var(--gold-muted);
}

/* ==================================
   7. LISTS & TABLES
   ================================== */
ul, ol {
  margin-bottom: 1.5em;
  padding-left: 1.5em;
}

li {
  margin-bottom: 0.5em;
}

ul li::marker {
  color: var(--gold-primary);
}

ol li::marker {
  color: var(--gold-primary);
  font-weight: 700;
  font-family: var(--font-display);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--red-deep);
}

th {
  background-color: var(--bg-surface);
  color: var(--gold-primary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

tr:hover td {
  background-color: rgba(212, 175, 55, 0.05);
}

/* ==================================
   8. MEDIA & FIGURES
   ================================== */
img, video {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--red-deep);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
  margin: 2rem 0;
  display: block;
}

figure {
  margin: 2.5rem 0;
}

figcaption {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 0.75rem;
  font-family: var(--font-sans);
}

/* ==================================
   9. CODE & PRE-FORMATTED
   ================================== */
code {
  font-family: var(--font-mono);
  background-color: var(--bg-code);
  color: var(--gold-light);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
  border: 1px solid var(--red-deep);
}

pre {
  background-color: var(--bg-code);
  border: 1px solid var(--red-deep);
  border-left: 3px solid var(--gold-primary);
  padding: 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 2rem 0;
  line-height: 1.5;
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-primary);
}

/* ==================================
   10. DIVIDERS & UTILITIES
   ================================== */
hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold-primary), transparent);
  margin: 3.5rem 0;
  opacity: 0.6;
}

/* Article Meta (Author, Date, Tags) */
.article-meta {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.article-meta span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.article-meta .tag {
  background: var(--bg-surface);
  color: var(--gold-primary);
  padding: 0.2em 0.6em;
  border-radius: 20px;
  border: 1px solid var(--gold-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* Selection Color */
::selection {
  background-color: var(--red-accent);
  color: var(--gold-light);
}