/* ============================================
   Theme System - Base Styles
   ============================================ */

/* ============================================
   1. Variables System (Light Theme Default)
   ============================================ */

:root {
  /* ============================================
     Color System
     ============================================ */
  --color-bg: #edf3f8;
  --color-bg-secondary: rgba(255, 255, 255, 0.34);
  --color-bg-tertiary: rgba(255, 255, 255, 0.22);
  --color-surface-elevated: rgba(255, 255, 255, 0.6);
  --color-text: #101828;
  --color-text-secondary: #3a4357;
  --color-text-muted: #6d7688;
  --color-text-placeholder: #4b556a;
  --color-border: rgba(15, 23, 42, 0.08);
  --color-accent: #0a84ff;
  --color-accent-hover: #0066cc;
  --color-accent-soft: rgba(10, 132, 255, 0.14);
  --color-shadow: rgba(15, 23, 42, 0.12);
  --color-shadow-strong: rgba(15, 23, 42, 0.2);

  /* ============================================
     Typography System
     ============================================ */
  --font-sans:
    "SF Pro Display", "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif-body: "Lora Variable", "LXGW WenKai", "Shippori Mincho", serif;
  --font-serif-em: "Cormorant Garamond", "LXGW WenKai", "Shippori Mincho", serif;
  --font-strong: "Space Grotesk", "LXGW WenKai", "Shippori Mincho", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Code", "Menlo", "Consolas", monospace;

  /* ============================================
     Font Sizes
     ============================================ */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.92rem;
  --font-size-base: 1rem;
  --font-size-md: 1.125rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: clamp(1.25rem, 1.1rem + 0.5vw, 1.75rem);
  --font-size-3xl: clamp(1.75rem, 1.4rem + 0.9vw, 2.5rem);
  --font-size-4xl: clamp(2.25rem, 1.8rem + 1.4vw, 3.5rem);

  /* ============================================
     Spacing System
     ============================================ */
  --space-2xs: 0.375rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4.5rem;
  --space-4xl: 6rem;

  /* ============================================
     Layout
     ============================================ */
  --max-width: 74rem;
  --max-width-prose: 45rem;

  /* ============================================
     Border Radius
     ============================================ */
  --radius-sm: 12px;
  --radius: 16px;
  --radius-md: 20px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-pill: 999px;
  --radius-panel: 34px;
  --radius-card: 28px;
  --radius-inner: 24px;

  /* ============================================
     Shadows
     ============================================ */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, 0.16);
  --shadow-soft:
    0 18px 48px -28px var(--color-shadow), 0 10px 18px -14px var(--color-shadow);
  --shadow-card:
    0 18px 40px -30px rgba(8, 18, 34, 0.18),
    0 6px 18px -12px rgba(8, 18, 34, 0.12);

  /* ============================================
     Transitions
     ============================================ */
  --transition-fast: 150ms ease;
  --transition-base: 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-slow: 300ms ease;

  /* ============================================
     Theme-specific Variables
     ============================================ */
  --card-surface-rgb: 255, 255, 255;
  --card-sheen-rgb: 255, 255, 255;
}

/* ============================================
   2. Dark Theme Variables
   ============================================ */

[data-theme="dark"] {
  --color-bg: #040d17;
  --color-bg-secondary: rgba(12, 22, 35, 0.38);
  --color-bg-tertiary: rgba(16, 28, 44, 0.24);
  --color-surface-elevated: rgba(15, 27, 43, 0.52);
  --color-text: #eef4ff;
  --color-text-secondary: #cad4e6;
  --color-text-muted: #93a1bc;
  --color-text-placeholder: #b6c4dc;
  --color-border: rgba(147, 161, 188, 0.14);
  --color-accent: #57a6ff;
  --color-accent-hover: #88c0ff;
  --color-accent-soft: rgba(87, 166, 255, 0.16);
  --color-shadow: rgba(0, 0, 0, 0.38);
  --color-shadow-strong: rgba(0, 0, 0, 0.55);
  --card-surface-rgb: 24, 36, 54;
  --card-sheen-rgb: 142, 178, 224;
}

/* ============================================
   3. Global Reset & Base Styles
   ============================================ */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.75;
  color: var(--color-text);
  transition: background-color var(--transition-base), color var(--transition-base);
}

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

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

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

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-placeholder);
  opacity: 1;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background-color: var(--color-accent-soft);
  padding: 0.2em 0.5em;
  border-radius: 6px;
}

/* ============================================
   4. Utility Classes
   ============================================ */

.container {
  width: min(calc(100% - 2rem), var(--max-width));
  margin-inline: auto;
  padding: 0 1rem;
}

.glass-panel {
  position: relative;
  overflow: hidden;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
}

.glass-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(var(--card-surface-rgb), 0.12);
  backdrop-filter: blur(18px) saturate(145%);
  -webkit-backdrop-filter: blur(18px) saturate(145%);
  pointer-events: none;
  z-index: 0;
}

.glass-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg,
    rgba(var(--card-sheen-rgb), 0.12),
    rgba(var(--card-sheen-rgb), 0.03) 22%,
    transparent 100%);
  pointer-events: none;
  opacity: 0.7;
  z-index: 1;
}

.glass-panel > * {
  position: relative;
  z-index: 2;
}

/* ============================================
   5. Scrollbar
   ============================================ */

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: rgba(214, 229, 255, 0.36);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(214, 229, 255, 0.5);
}

/* ============================================
   6. Selection
   ============================================ */

::selection {
  background-color: var(--color-accent-soft);
  color: var(--color-text);
}

/* ============================================
   7. Focus States
   ============================================ */

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-color: var(--color-accent);
}

/* ============================================
   8. Animation Keyframes
   ============================================ */

@keyframes float-glow {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -24px, 0);
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}
