/* ==========================================================================
   Key2magic.cl - Unified Aesthetics & Core Design System
   Theme: Dark Forest Obsidian (#07130D), Mahogany Wood (#3D271D), Brass Gold (#D4AF37)
   Mode Support: Dark Forest (Default) & Aged Parchment (Light)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600&display=swap');

:root {
  /* Dark Forest Theme (Default) */
  --bg-obsidian: #07130D;
  --bg-card: #0E2419;
  --bg-card-hover: #143323;
  --bg-drawer: #091A12;
  --border-forest: #1A4331;
  --border-gold: rgba(212, 175, 55, 0.35);
  
  --wood-dark: #2A1A12;
  --wood-accent: #3D271D;
  --wood-warm: #7A5230;

  --brass-gold: #D4AF37;
  --brass-bright: #F3E5AB;
  --emerald-glow: #4ADE80;

  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-gold: #F3E5AB;
  --text-dark: #111827;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-display: 'Cinzel', serif;

  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.7), 0 0 15px rgba(212, 175, 55, 0.08);
  --shadow-drawer: -15px 0 40px rgba(0, 0, 0, 0.85);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --transition-smooth: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Parchment Theme Overrides */
[data-theme="light"] {
  --bg-obsidian: #F7F4EA;
  --bg-card: #EFE8D6;
  --bg-card-hover: #E7DECA;
  --bg-drawer: #F3ECE0;
  --border-forest: #C8BD9E;
  --border-gold: rgba(184, 134, 11, 0.4);

  --wood-dark: #3D271D;
  --wood-accent: #8C6239;
  --wood-warm: #C69255;

  --brass-gold: #B8860B;
  --brass-bright: #8B6508;
  --emerald-glow: #166534;

  --text-main: #1C1917;
  --text-muted: #57534E;
  --text-gold: #78350F;

  --shadow-card: 0 10px 30px -10px rgba(120, 80, 20, 0.15);
  --shadow-drawer: -15px 0 40px rgba(60, 40, 10, 0.25);
}

/* CSS Reset & General Rules */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--bg-obsidian);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* Wood Grain Header & Accent Strips */
.wood-strip {
  background: linear-gradient(90deg, var(--wood-dark) 0%, var(--wood-accent) 50%, var(--wood-dark) 100%);
  border-bottom: 1px solid var(--border-gold);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Main Container Layout */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Top Navigation Bar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(7, 19, 13, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-forest);
  transition: var(--transition-smooth);
}

[data-theme="light"] .navbar {
  background-color: rgba(247, 244, 234, 0.92);
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}

.brand-emblem {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-emblem .key-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 8px rgba(212, 175, 55, 0.5));
  transition: transform 0.4s ease;
}

.brand-emblem:hover .key-icon {
  transform: rotate(-15deg) scale(1.15);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--brass-bright) 0%, var(--brass-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Mode Switches & Controls */
.view-switcher {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-forest);
  border-radius: 30px;
  padding: 4px;
}

.btn-switch {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: 24px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.btn-switch.active {
  background: linear-gradient(135deg, var(--wood-accent) 0%, var(--wood-dark) 100%);
  color: var(--brass-bright);
  border: 1px solid var(--border-gold);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* Section Titles */
.section-header {
  text-align: center;
  margin-bottom: 3.5rem;
}

.section-header .sub-tag {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--brass-gold);
  margin-bottom: 0.5rem;
  display: block;
}

.section-header h2 {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Decorative Brass Divider */
.filigree-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 1.5rem 0;
  color: var(--brass-gold);
  opacity: 0.7;
}

.filigree-divider::before,
.filigree-divider::after {
  content: '';
  height: 1px;
  width: 80px;
  background: linear-gradient(90deg, transparent, var(--brass-gold), transparent);
}

/* Footer Styling */
footer {
  background-color: var(--wood-dark);
  border-top: 2px solid var(--border-gold);
  padding: 4rem 0 2rem;
  margin-top: 6rem;
  color: var(--text-muted);
}

.footer-content {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-brand p {
  margin-top: 1rem;
  font-size: 0.95rem;
  max-width: 420px;
}

.footer-links h4 {
  color: var(--brass-bright);
  font-family: var(--font-display);
  margin-bottom: 1.2rem;
}

.footer-links ul {
  list-style: none;
}

.footer-links li {
  margin-bottom: 0.6rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--brass-bright);
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
}

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

.animate-fade {
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   Component Styles
   Magazine Spreads, Library Cards, Reader Drawer, Canvas Graph Frame
   ========================================================================== */

/* 1. MAGAZINE EDITORIAL VIEW */
.magazine-hero {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-gold);
  background: var(--bg-card);
  margin-bottom: 4rem;
  box-shadow: var(--shadow-card);
}

.hero-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0.25;
  background: radial-gradient(circle at 70% 30%, rgba(212, 175, 55, 0.4), transparent 60%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  min-height: 520px;
  position: relative;
  z-index: 2;
}

.hero-content {
  padding: 4rem 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.issue-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--wood-accent);
  color: var(--brass-bright);
  border: 1px solid var(--border-gold);
  padding: 4px 14px;
  border-radius: 20px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 2px;
  width: fit-content;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 3.2rem;
  line-height: 1.15;
  font-weight: 700;
  margin-bottom: 1.2rem;
  color: var(--text-main);
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  max-width: 580px;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 1.8rem;
  font-size: 0.9rem;
  color: var(--brass-gold);
}

.hero-action {
  background: linear-gradient(135deg, var(--brass-gold) 0%, #B8860B 100%);
  color: #07130D;
  font-weight: 700;
  border: none;
  padding: 14px 32px;
  border-radius: 30px;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-smooth);
  width: fit-content;
}

.hero-action:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4);
}

.hero-visual {
  background: linear-gradient(135deg, rgba(7,19,13,0.8) 0%, rgba(61,39,29,0.8) 100%);
  border-left: 1px solid var(--border-forest);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.quote-box {
  background: rgba(14, 36, 25, 0.75);
  border-left: 3px solid var(--brass-gold);
  padding: 2rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  backdrop-filter: blur(8px);
}

.quote-box p {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--brass-bright);
}

.quote-author {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

/* Magazine Grid Articles */
.magazine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 2.5rem;
  margin-bottom: 5rem;
}

.mag-card {
  background: var(--bg-card);
  border: 1px solid var(--border-forest);
  border-radius: var(--radius-md);
  padding: 2.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition-smooth);
  position: relative;
}

.mag-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: var(--transition-smooth);
}

.mag-card:hover {
  transform: translateY(-6px);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-card);
}

.mag-card:hover::after {
  border-color: var(--border-gold);
}

.card-symbol {
  font-size: 2.2rem;
  margin-bottom: 1.2rem;
  display: inline-block;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.8rem;
  color: var(--text-main);
}

.card-excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.8rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-forest);
  padding-top: 1rem;
  font-size: 0.82rem;
  color: var(--brass-gold);
}

/* 2. LIBRARY ARCHIVE VIEW */
.library-search-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: 40px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 680px;
  margin: 0 auto 2.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.library-search-bar input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 1.05rem;
  width: 100%;
  outline: none;
}

.library-search-bar input::placeholder {
  color: var(--text-muted);
}

/* Category Filters Pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 3.5rem;
}

.filter-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-forest);
  color: var(--text-muted);
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.filter-pill:hover,
.filter-pill.active {
  background: var(--wood-accent);
  color: var(--brass-bright);
  border-color: var(--border-gold);
}

/* 3. KNOWLEDGE GRAPH CONTAINER */
.graph-container {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  margin-bottom: 5rem;
  box-shadow: var(--shadow-card);
}

.graph-container canvas {
  width: 100%;
  height: 420px;
  display: block;
  border-radius: var(--radius-md);
}

/* 4. INTERACTIVE CODEX READER DRAWER */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-content {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 820px;
  background: var(--bg-drawer);
  border-left: 2px solid var(--border-gold);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-drawer);
}

.drawer-backdrop.open .drawer-content {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.5rem 2.5rem;
  border-bottom: 1px solid var(--border-forest);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--wood-dark);
}

.drawer-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-forest);
  color: var(--brass-bright);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition-smooth);
}

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

.drawer-body {
  padding: 3rem 3.5rem;
  overflow-y: auto;
  flex: 1;
}

.drawer-body h1 {
  font-family: var(--font-serif);
  font-size: 2.6rem;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.drawer-body .takeaway-box {
  background: rgba(212, 175, 55, 0.08);
  border-left: 3px solid var(--brass-gold);
  padding: 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 2rem 0;
}

.drawer-body .takeaway-box h4 {
  font-family: var(--font-display);
  color: var(--brass-bright);
  margin-bottom: 0.8rem;
}

.drawer-body .article-prose {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  line-height: 1.8;
  color: var(--text-main);
}

.drawer-body .article-prose p {
  margin-bottom: 1.5rem;
}

.drawer-body .article-prose blockquote {
  border-left: 2px solid var(--brass-gold);
  padding-left: 1.5rem;
  font-style: italic;
  color: var(--brass-bright);
  margin: 2rem 0;
}

/* Responsive Rules */
@media (max-width: 900px) {
  .nav-content {
    flex-direction: column;
    height: auto;
    padding: 1rem 0;
    gap: 1rem;
  }
  .footer-content {
    grid-template-columns: 1fr;
  }
  .section-header h2 {
    font-size: 2.1rem;
  }
}

@media (max-width: 768px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
  .hero-visual {
    display: none;
  }
  .drawer-content {
    max-width: 100%;
  }
  .drawer-body {
    padding: 2rem 1.5rem;
  }
}
