/* Custom Typography & Theme Variables */
:root {
  /* Default Light Theme Palette */
  --bg-color: #faf9f6; /* Warm off-white / alabaster */
  --text-color: #1c1c1e; /* Deep charcoal */
  --text-muted: #5e5e62; /* Slate gray */
  --accent-color: #8c6239; /* Rich editorial bronze */
  --accent-light: #f3ece4; /* Warm bronze tint */
  --border-color: #e5e5ea; /* Subtle separator */
  --code-bg: #f4f4f6; /* Subtle code container */
  --code-color: #b84335; /* Editorial brick red for inline code */
  --card-bg: #ffffff;
  --transition-speed: 0.25s;
  
  --font-serif: 'Lora', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

/* System Dark Mode (default active when no explicit light override is set) */
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    --bg-color: #0d0e10; /* Deep charcoal black */
    --text-color: #e5e5e7; /* Clean light gray */
    --text-muted: #9a9a9f; /* Muted gray */
    --accent-color: #d1b48c; /* Warm light bronze */
    --accent-light: #1e1b18; /* Dark bronze glow */
    --border-color: #242528; /* Deep separator */
    --code-bg: #161719; /* Code container */
    --code-color: #e88574; /* Warm light brick red */
    --card-bg: #131416;
  }
}

/* Explicit Dark Override */
:root.theme-dark {
  --bg-color: #0d0e10; /* Deep charcoal black */
  --text-color: #e5e5e7; /* Clean light gray */
  --text-muted: #9a9a9f; /* Muted gray */
  --accent-color: #d1b48c; /* Warm light bronze */
  --accent-light: #1e1b18; /* Dark bronze glow */
  --border-color: #242528; /* Deep separator */
  --code-bg: #161719; /* Code container */
  --code-color: #e88574; /* Warm light brick red */
  --card-bg: #131416;
}

/* Explicit Light Override */
:root.theme-light {
  --bg-color: #faf9f6; /* Warm off-white / alabaster */
  --text-color: #1c1c1e; /* Deep charcoal */
  --text-muted: #5e5e62; /* Slate gray */
  --accent-color: #8c6239; /* Rich editorial bronze */
  --accent-light: #f3ece4; /* Warm bronze tint */
  --border-color: #e5e5ea; /* Subtle separator */
  --code-bg: #f4f4f6; /* Subtle code container */
  --code-color: #b84335; /* Editorial brick red for inline code */
  --card-bg: #ffffff;
}

/* Global Reset & Styling */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-sans);
  line-height: 1.625;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 0 1.5rem;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.25rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.65rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-top: 3rem;
}

h3 {
  font-size: 1.3rem;
}

p {
  margin-bottom: 1.5rem;
  font-size: 1.05rem;
  color: var(--text-color);
}

a {
  color: var(--text-color);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-color);
  transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

a:hover {
  color: var(--accent-color);
  border-bottom-color: transparent;
  background-color: var(--accent-light);
}

/* Document & Layout Spacing */
.layout-wrapper {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex-grow: 1;
  padding: 3rem 0;
  animation: fadeIn 0.4s ease-out;
}

/* Premium Navigation */
header {
  border-bottom: 1px solid var(--border-color);
  padding: 2rem 0;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-link {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.3rem;
  border-bottom: none;
  letter-spacing: -0.01em;
}

.logo-link:hover {
  background: none;
  color: var(--accent-color);
}

.logo-dot {
  color: var(--accent-color);
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: none;
  padding: 0.25rem 0;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: width var(--transition-speed) ease;
}

.nav-links a:hover {
  background: none;
  color: var(--text-color);
}

.nav-links a:hover::after,
.nav-links a.active::after {
  width: 100%;
}

.nav-links a.active {
  color: var(--text-color);
}

/* Footer Section */
footer {
  border-top: 1px solid var(--border-color);
  padding: 3rem 0;
  margin-top: 4rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.social-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}

.social-links a {
  border-bottom: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0.25rem;
}

.social-links a:hover {
  background: none;
  color: var(--accent-color);
  transform: translateY(-2px);
}

/* Homepage Hero & Content styling */
.hero-intro {
  margin-bottom: 4rem;
}

.hero-intro h1 {
  font-size: 2.75rem;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  font-weight: 700;
}

.hero-intro .subtitle {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.4;
}

.lead {
  font-size: 1.15rem;
  line-height: 1.7;
}

/* Article Lists */
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 4rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.section-title-row h2 {
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.view-all-link {
  font-size: 0.9rem;
  font-weight: 500;
  border-bottom: none;
  color: var(--accent-color);
}

.view-all-link:hover {
  background: none;
  text-decoration: underline;
}

.articles-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.article-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.article-meta {
  font-size: 0.85rem;
  font-family: var(--font-sans);
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.article-date {
  font-weight: 500;
}

.article-title-link {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-color);
  border-bottom: none;
}

.article-title-link:hover {
  background: none;
  color: var(--accent-color);
}

.article-summary {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 0;
}

/* Individual Article Rendering */
.article-header {
  margin-bottom: 3rem;
  text-align: center;
}

.article-header h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.article-header .article-meta {
  justify-content: center;
  font-size: 0.9rem;
  margin-top: 1rem;
}

.article-content {
  line-height: 1.75;
  font-size: 1.1rem;
}

.article-content p {
  margin-bottom: 1.75rem;
}

.article-content blockquote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.25rem;
  border-left: 3px solid var(--accent-color);
  padding-left: 1.5rem;
  margin: 2.5rem 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.article-content pre {
  background-color: var(--code-bg);
  padding: 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border-color);
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background-color: var(--code-bg);
  color: var(--code-color);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.article-content pre code {
  background-color: transparent;
  color: var(--text-color);
  padding: 0;
  border-radius: 0;
}

.article-content ul, .article-content ol {
  margin-bottom: 1.75rem;
  padding-left: 2rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-footer {
  margin-top: 5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
}

.back-link {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--accent-color);
  border-bottom: none;
}

.back-link:hover {
  background: none;
  text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  html {
    font-size: 15px;
  }
  
  body {
    padding: 0 1rem;
  }
  
  header {
    padding: 1.5rem 0;
  }
  
  .hero-intro h1 {
    font-size: 2.25rem;
  }
  
  .article-header h1 {
    font-size: 2rem;
  }
}

/* Theme Switcher Styling */
.theme-toggle-group {
  display: inline-flex;
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 3px;
  gap: 2px;
}

.theme-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed) ease;
}

.theme-btn:hover {
  color: var(--text-color);
}

.theme-btn.active {
  background-color: var(--bg-color);
  color: var(--accent-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
