/* =========================================
   1. ROOT VARIABLES (THE BRAND SYSTEM)
   ========================================= */
:root {
  /* Dynamic Backgrounds (Light Mode Default) */
  --bg-color: #ffffff;
  --bg-secondary: #fafafa;

  /* Typography Colors */
  --text-main: #333333;
  --text-meta: #5c6682;
  --code-pink: #d63384;

  /* Accents & Borders */
  --accent-green: #2bbd0f; /* Darker for WCAG contrast on white */
  --border-color: #eaeaea;

  /* Navbar (Stays dark in light mode to pop the Llama logo) */
  --navbar-bg: #1e1e24;
  --navbar-text: #ffffff;

  /* Global Spacing Scale */
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-xxl: 60px;
}

/* =========================================
   2. DARK MODE OVERRIDES
   ========================================= */
html.dark-mode {
  /* Deep dark backgrounds */
  --bg-color: #121215;
  --bg-secondary: #1e1e24; /* Brand Charcoal for cards/code blocks */

  /* Typography swaps */
  --text-main: #f4f4f4;
  --text-meta: #a1a1aa;

  /* Accents & Borders */
  --accent-green: #39ff14; /* True Hacker Green for dark mode */
  --border-color: #333333;

  /* Navbar shifts slightly darker to separate from page */
  --navbar-bg: #0a0a0c;
  --navbar-text: #f4f4f4;
}

/* Default Light Mode: Show Moon (to switch TO dark), Hide Sun */
.sun-icon {
  display: none;
}
.moon-icon {
  display: block;
}

/* Dark Mode: Show Sun (to switch TO light), Hide Moon */
html.dark-mode .sun-icon {
  display: block;
}
html.dark-mode .moon-icon {
  display: none;
}

/* =========================================
   3. GLOBAL RESET & BOX SIZING
   ========================================= */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth; /* Native smooth scrolling */
}

img,
picture,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

/* =========================================
   4. GLOBAL TYPOGRAPHY & TRANSITIONS
   ========================================= */
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* The buttery-smooth color crossfade */
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

h1,
h2,
h3,
h4 {
  color: var(--text-main);
  line-height: 1.2;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.05rem;
  margin-top: 0;
}

h2 {
  font-size: 2rem;
  font-weight: 700;
  border-bottom: 2px solid var(--accent-green);
  padding-bottom: var(--space-sm);
  display: inline-block;
}

h3 {
  font-size: 1.5rem;
  font-weight: 600;
}

p {
  font-size: 1.15rem;
  line-height: 1.8;
  margin-bottom: var(--space-lg);
}

/* Article Metadata */
.article-meta {
  color: var(--text-meta);
  font-size: 0.9rem;
  margin-top: 10px;
  margin-bottom: 2rem;
  font-family: "Courier New", Courier, monospace;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

.meta-divider {
  margin: 0 10px;
}

/* =========================================
   5. STRUCTURAL LAYOUT
   ========================================= */
.article-container {
  max-width: 800px;
  margin: var(--space-xxl) auto;
  padding: 0 var(--space-lg);
}

.hub-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* =========================================
   6. NAVIGATION & HEADER
   ========================================= */
.llama-header {
  background-color: var(--navbar-bg);
  padding: var(--space-md) var(--space-lg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.3s ease;
}

.llama-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent-green);
  font-size: 1.5rem;
  font-weight: bold;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: var(--space-xl);
  align-items: center;
}

.nav-links a {
  color: var(--navbar-text);
  font-weight: 500;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--accent-green);
}

/* Flex the new wrapper on desktop */
.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

/* Ensure the nav-actions don't break the mobile menu styling */
@media (max-width: 768px) {
  .nav-actions {
    gap: var(--space-md); /* Tighter spacing for mobile */
  }
}

/* Theme Toggle Button */
.theme-btn {
  background: transparent;
  color: var(--navbar-text);
  border: 1px solid var(--accent-green);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 8px;
}

.theme-btn:hover {
  background-color: var(--accent-green);
  color: #1e1e24;
}

/* Card Preview Action Button */
.btn-preview {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--accent-green);
  border-radius: 4px;
  padding: 8px 16px;
  font-weight: bold;
  text-align: center;
  transition: all 0.2s ease;
  display: inline-block;
  flex: 1;
}

.btn-preview:hover {
  background-color: var(--accent-green);
  color: #1e1e24;
}

/* Mobile Hamburger Trigger */
.hamburger {
  display: none;
  cursor: pointer;
  background: transparent;
  border: none;
  gap: 5px;
  flex-direction: column;
}

.hamburger .line {
  width: 25px;
  height: 3px;
  background-color: var(--navbar-text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
    position: relative;
    z-index: 101;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 60%;
    background-color: var(--navbar-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 100px;
    transform: translateX(100%);
    transition: transform 0.3s ease-in;
    z-index: 100;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.2);
  }

  .nav-links.nav-active {
    transform: translateX(0%);
  }
}

/* Hamburger "X" Animation */
.hamburger.is-active .line:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.hamburger.is-active .line:nth-child(2) {
  opacity: 0;
}
.hamburger.is-active .line:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* =========================================
   7. CODE BLOCKS
   ========================================= */
pre {
  background-color: #1e1e24 !important; /* Always charcoal */
  padding: var(--space-lg) !important;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: var(--space-xl);
  border-left: 4px solid var(--accent-green);
}

code {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.95rem;
  color: #f4f4f4; /* Light text for dark code blocks */
}

p code {
  background-color: var(--bg-secondary);
  color: var(--code-pink);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* =========================================
   8. COMPONENTS & FOOTER
   ========================================= */
.cta-box {
  background-color: var(--bg-secondary);
  padding: var(--space-lg);
  border-radius: 8px;
  border-left: 4px solid var(--accent-green);
  margin: var(--space-xl) 0;
  border: 1px solid var(--border-color);
}

.cta-box h3 {
  color: var(--accent-green);
  margin-top: 0;
  margin-bottom: var(--space-sm);
  border-bottom: none;
}

.cta-box a.cta-btn {
  color: var(--accent-green);
  font-weight: bold;
  text-decoration: none;
  transition: opacity 0.2s ease;
  display: inline-block;
}

.cta-box a.cta-btn:hover {
  opacity: 0.8;
}

/* Footer & Scroll */
footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-meta);
  font-size: 0.9rem;
  border-top: 1px solid var(--border-color);
  margin-top: var(--space-xxl);
}

.scroll-to-top {
  display: inline-block;
  color: var(--accent-green);
  text-decoration: none;
  font-weight: bold;
  font-family: monospace;
  margin-top: var(--space-md);
}

.scroll-to-top:hover {
  text-decoration: underline;
}

/* =========================================
   9. HUB & HOMEPAGE LAYOUT
   ========================================= */
.hero {
  text-align: center;
  padding: var(--space-xxl) 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-xl);
}

.hero h1 {
  font-size: 3.5rem;
  letter-spacing: -0.05rem;
  margin-bottom: var(--space-md);
}

.hero p {
  font-size: 1.25rem;
  color: var(--text-meta);
  max-width: 600px;
  margin: 0 auto;
}

.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xxl);
}

.article-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: var(--space-lg);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  display: block;
}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.category-tag {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85rem;
  color: var(--accent-green);
  background-color: #1e1e24;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.article-card h3 {
  margin-top: var(--space-md);
  font-size: 1.4rem;
  margin-bottom: var(--space-sm);
  color: var(--text-main);
}

.article-card p {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-meta);
  margin-bottom: var(--space-md);
}

.read-more {
  color: var(--text-main);
  font-weight: bold;
  font-size: 0.95rem;
}
