/* ============================================
   MAIN.CSS — Global Design System
   ============================================ */

/* — Google Fonts — */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&family=Syne:wght@400;500;600;700;800&display=swap');

/* — CSS Variables (Light Theme Default) — */
:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f7f8fa;
  --color-surface: #f0f2f5;
  --color-surface-hover: #e4e7ec;
  --color-accent: #0fa882;
  --color-accent-dim: rgba(15, 168, 130, 0.1);
  --color-accent-glow: rgba(15, 168, 130, 0.25);
  --color-text: #1a1a2e;
  --color-text-secondary: #4a4a68;
  --color-muted: #8890a4;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-hover: rgba(15, 168, 130, 0.35);

  --font-display: 'Syne', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 30px rgba(15, 168, 130, 0.08);
  --shadow-glow-strong: 0 0 40px rgba(15, 168, 130, 0.15);

  --z-nav: 1000;
  --z-dropdown: 1010;
  --z-mobile-menu: 1020;
  --z-toast: 1100;

  --nav-height: 72px;
  --nav-height-scrolled: 56px;
  --max-width: 1200px;

  --grain-opacity: 0;
  --nav-bg: rgba(255, 255, 255, 0.8);
  --nav-bg-scrolled: rgba(255, 255, 255, 0.95);
  --code-bg: rgba(0, 0, 0, 0.04);
}

/* — Dark Theme — */
[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-bg-alt: #0c1222;
  --color-surface: #1e293b;
  --color-surface-hover: #334155;
  --color-accent: #00FFD1;
  --color-accent-dim: rgba(0, 255, 209, 0.15);
  --color-accent-glow: rgba(0, 255, 209, 0.3);
  --color-text: #ffffff;
  --color-text-secondary: #d1d5db;
  --color-muted: #94a3b8;
  --color-border: #475569;
  --color-border-hover: rgba(0, 255, 209, 0.25);

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(0, 255, 209, 0.12);
  --shadow-glow-strong: 0 0 40px rgba(0, 255, 209, 0.2);

  --grain-opacity: 0.035;
  --nav-bg: rgba(15, 23, 42, 0.7);
  --nav-bg-scrolled: rgba(15, 23, 42, 0.92);
  --code-bg: rgba(255, 255, 255, 0.06);
}

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

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  overflow-x: hidden;
  opacity: 0;
  animation: pageEnter 0.5s ease forwards;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Grain texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* — Base Typography — */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.5rem); }
h4 { font-size: 1.125rem; }

p {
  color: var(--color-text-secondary);
  max-width: 65ch;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-accent);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  list-style: none;
}

/* — Layout Utilities — */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.section {
  padding: 100px 0;
}

.section-header {
  margin-bottom: 60px;
}

.section-header h2 {
  margin-bottom: 16px;
}

.section-header p {
  font-size: 1.1rem;
}

.section-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 12px;
}

/* — Buttons — */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transition: left var(--transition);
  z-index: -1;
}

.btn:hover::before {
  left: 0;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-bg);
}

.btn-primary:hover {
  color: var(--color-bg);
  box-shadow: var(--shadow-glow-strong);
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
}

.btn-outline:hover {
  background: var(--color-accent-dim);
  color: var(--color-accent);
  transform: translateY(-2px);
}

.btn-ghost {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  border-color: var(--color-border-hover);
  color: var(--color-accent);
  transform: translateY(-2px);
}

/* — Tags / Badges — */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--color-accent-dim);
  color: var(--color-accent);
  border: 1px solid var(--color-accent-dim);
  transition: all var(--transition);
}

.tag:hover {
  background: var(--color-accent-dim);
  box-shadow: 0 0 12px var(--color-accent-glow);
}

.language-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
}

.language-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* — Card Base — */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all var(--transition);
}

.card:hover {
  transform: translateY(-6px);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-glow);
}

/* — Toast Notifications — */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-card);
  transform: translateX(120%);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
}

.toast .toast-icon {
  font-size: 1.1rem;
}

/* — Footer — */
.footer {
  padding: 24px 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--color-muted);
  font-size: 0.875rem;
  transition: color var(--transition);
}

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

.footer-copy {
  color: var(--color-muted);
  font-size: 0.8rem;
}

/* — Error & Empty States — */
.error-state,
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.error-state .error-icon,
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.error-state h3,
.empty-state h3 {
  margin-bottom: 8px;
}

.error-state p,
.empty-state p {
  margin: 0 auto 24px;
}

/* — Selection — */
::selection {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* — Scrollbar — */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-surface-hover);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-muted);
}
