/* CSS Variables for Theme Support */
:root {
  /* Light theme (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --bg-code: #f4f4f5;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a68;
  --text-muted: #6c757d;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --code-text: #e83e8c;
  --link-color: #6366f1;
  --link-hover: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --table-stripe: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-code: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent-primary: #818cf8;
  --accent-secondary: #a78bfa;
  --accent-gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 100%);
  --border-color: #334155;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --code-text: #f472b6;
  --link-color: #818cf8;
  --link-hover: #a5b4fc;
  --table-stripe: rgba(255, 255, 255, 0.02);
}

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
}

/* Temporary Notice Banner */
.temp-notice {
  background: var(--accent-gradient);
  color: white;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.025em;
}

/* Navigation */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.125rem;
}

.nav-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-link {
  display: block;
  padding: 0.5rem 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.nav-link.active {
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

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

/* Theme Toggle */
.theme-toggle {
  position: relative;
  width: 56px;
  height: 28px;
  background: var(--bg-tertiary);
  border-radius: 14px;
  cursor: pointer;
  border: none;
  padding: 2px;
  transition: background-color 0.3s ease;
}

.theme-toggle-track {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.theme-toggle-icon {
  font-size: 14px;
  z-index: 1;
  transition: opacity 0.3s ease;
}

.theme-toggle-icon.sun {
  opacity: 1;
}

.theme-toggle-icon.moon {
  opacity: 0.5;
}

[data-theme="dark"] .theme-toggle-icon.sun {
  opacity: 0.5;
}

[data-theme="dark"] .theme-toggle-icon.moon {
  opacity: 1;
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s ease;
}

[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(28px);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text-primary);
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: all 0.3s ease;
}

/* Main Content */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 4rem 0;
  margin-bottom: 3rem;
}

.hero-badge {
  display: inline-block;
  padding: 0.375rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-primary);
}

.card-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Article Content */
article {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.5rem;
  margin-bottom: 2rem;
}

article h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

article h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
}

article h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text-primary);
}

article h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-primary);
}

article p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

article a {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

article a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Lists */
article ul, article ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

article li {
  margin-bottom: 0.5rem;
}

article li::marker {
  color: var(--accent-primary);
}

/* Blockquotes */
blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.5rem;
  background: var(--bg-tertiary);
  border-left: 4px solid var(--accent-primary);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-secondary);
}

blockquote p {
  margin: 0;
}

/* Code Blocks */
pre {
  margin: 1.5rem 0;
  padding: 1.25rem;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.875rem;
  line-height: 1.6;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.875em;
}

:not(pre) > code {
  background: var(--bg-code);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  color: var(--code-text);
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

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

th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
}

tr:nth-child(even) {
  background: var(--table-stripe);
}

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

/* Info Box */
.info-box {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.info-box.tip {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.info-box.warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.info-box.danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.info-box-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.info-box-content {
  flex: 1;
}

.info-box-content p {
  margin: 0;
  font-size: 0.9rem;
}

/* Navigation Between Pages */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.page-nav-link {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  max-width: 45%;
}

.page-nav-link:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.page-nav-link.prev {
  align-items: flex-start;
}

.page-nav-link.next {
  align-items: flex-end;
  margin-left: auto;
}

.page-nav-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.page-nav-title {
  font-weight: 600;
  color: var(--accent-primary);
}

/* Footer */
.footer {
  border-top: 1px solid var(--border-color);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.footer a {
  color: var(--accent-primary);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* TL;DR Box */
.tldr-box {
  background: var(--accent-gradient);
  color: white;
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 2rem;
}

.tldr-box h3 {
  color: white;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.tldr-box p {
  color: rgba(255, 255, 255, 0.9);
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Update Notice */
.update-notice {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 2rem;
}

.update-notice h3 {
  color: var(--success);
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.update-notice ul {
  margin: 0;
  padding-left: 1.25rem;
}

.update-notice li {
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

/* Defense Table */
.defense-table {
  margin: 1.5rem 0;
}

/* Responsive Design */
@media (max-width: 900px) {
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    padding: 1rem;
    gap: 0.25rem;
  }

  .nav-menu.active {
    display: flex;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .nav-actions {
    gap: 0.5rem;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 1.5rem 1rem;
  }

  article {
    padding: 1.5rem;
    border-radius: 12px;
  }

  article h1 {
    font-size: 1.5rem;
  }

  article h2 {
    font-size: 1.25rem;
  }

  .hero {
    padding: 2rem 0;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .page-nav {
    flex-direction: column;
  }

  .page-nav-link {
    max-width: 100%;
  }

  .page-nav-link.next {
    align-items: flex-start;
  }

  pre {
    padding: 1rem;
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.625rem 0.75rem;
  }
}

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

.main-content {
  animation: fadeIn 0.4s ease-out;
}

/* Scroll to top button */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.scroll-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-top:hover {
  transform: translateY(-3px);
}
