/* ==========================================================================
   OBGNAUH English Learning Lab — base.css
   Design tokens, reset, typography, ambient background, utilities
   ========================================================================== */

:root {
  /* Brand */
  --brand-500: #2b6bff;
  --brand-400: #4f8cff;
  --brand-600: #1d54d8;
  --mint-500: #00bfa5;
  --violet-500: #8b5cf6;
  --amber-500: #f59e0b;
  --rose-500: #f43f7f;

  --grad-brand: linear-gradient(135deg, #2b6bff 0%, #6f8dff 48%, #00c9a7 100%);
  --grad-warm: linear-gradient(135deg, #ff9f45 0%, #f43f7f 100%);
  --grad-violet: linear-gradient(135deg, #8b5cf6 0%, #4f8cff 100%);

  /* Radii */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-pill: 999px;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas,
    "PingFang SC", monospace;

  /* Layout */
  --nav-h: 68px;
  --maxw: 1240px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.42s;
}

/* ---------- Light theme ---------- */
:root,
[data-theme="light"] {
  --bg: #f2f4f8;
  --bg-elev: #ffffff;
  --surface: rgba(255, 255, 255, 0.66);
  --surface-strong: rgba(255, 255, 255, 0.86);
  --surface-soft: rgba(255, 255, 255, 0.42);
  --surface-solid: #ffffff;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --text: #0d1424;
  --text-2: #4a5568;
  --text-3: #7b8496;
  --accent: #2b6bff;
  --accent-soft: rgba(43, 107, 255, 0.1);
  --accent-line: rgba(43, 107, 255, 0.24);
  --ok: #0f9d76;
  --ok-soft: rgba(15, 157, 118, 0.12);
  --warn: #c2790b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #d92d5c;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 32px -12px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 32px 80px -24px rgba(15, 23, 42, 0.28), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
  --glass-blur: blur(28px) saturate(180%);
  --glow-a: rgba(79, 140, 255, 0.5);
  --glow-b: rgba(0, 201, 167, 0.38);
  --glow-c: rgba(139, 92, 246, 0.3);
  --grid-line: rgba(15, 23, 42, 0.05);
  --code-bg: rgba(15, 23, 42, 0.05);
  --nav-bg: rgba(250, 251, 253, 0.72);
  --sheen: rgba(255, 255, 255, 0.9);
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  --bg: #06080f;
  --bg-elev: #0d1119;
  --surface: rgba(24, 29, 41, 0.62);
  --surface-strong: rgba(28, 34, 48, 0.86);
  --surface-soft: rgba(30, 36, 50, 0.4);
  --surface-solid: #121722;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f5fa;
  --text-2: #a9b3c4;
  --text-3: #7c8698;
  --accent: #6d9bff;
  --accent-soft: rgba(109, 155, 255, 0.14);
  --accent-line: rgba(109, 155, 255, 0.32);
  --ok: #2fd6a8;
  --ok-soft: rgba(47, 214, 168, 0.14);
  --warn: #f5b544;
  --warn-soft: rgba(245, 181, 68, 0.16);
  --danger: #ff6b8f;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 16px 40px -16px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, 0.85), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --glass-blur: blur(30px) saturate(160%);
  --glow-a: rgba(64, 118, 255, 0.34);
  --glow-b: rgba(0, 201, 167, 0.2);
  --glow-c: rgba(139, 92, 246, 0.24);
  --grid-line: rgba(255, 255, 255, 0.045);
  --code-bg: rgba(255, 255, 255, 0.06);
  --nav-bg: rgba(10, 13, 21, 0.7);
  --sheen: rgba(255, 255, 255, 0.07);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.62;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.5s var(--ease), color 0.35s var(--ease);
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4 {
  font-weight: 650;
  letter-spacing: -0.022em;
  line-height: 1.18;
  color: var(--text);
}

h1 { font-size: clamp(2rem, 1.5rem + 2.2vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 1.15rem + 1vw, 2rem); }
h3 { font-size: clamp(1.08rem, 1rem + 0.4vw, 1.3rem); }
h4 { font-size: 1.02rem; }

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

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

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

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

::selection {
  background: var(--accent);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- Ambient background ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 12% -8%, var(--glow-a), transparent 62%),
    radial-gradient(900px 520px at 92% 4%, var(--glow-c), transparent 60%),
    radial-gradient(1000px 700px at 68% 102%, var(--glow-b), transparent 62%),
    var(--bg);
  transition: background 0.6s var(--ease);
}

.ambient::before {
  content: "";
  position: absolute;
  inset: -20%;
  background-image:
    radial-gradient(var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 72%);
  animation: gridDrift 60s linear infinite;
}

.ambient::after {
  content: "";
  position: absolute;
  width: 62vw;
  height: 62vw;
  max-width: 820px;
  max-height: 820px;
  right: -14vw;
  top: 24vh;
  border-radius: 50%;
  background: conic-gradient(from 120deg, rgba(43,107,255,0.16), rgba(0,201,167,0.14), rgba(139,92,246,0.16), rgba(43,107,255,0.16));
  filter: blur(80px);
  opacity: 0.7;
  animation: floatSlow 22s ease-in-out infinite;
}

@keyframes gridDrift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-42px, -42px, 0); }
}

@keyframes floatSlow {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-3vw, -4vh, 0) scale(1.06); }
}

/* ---------- Layout helpers ---------- */
.wrap {
  width: min(100% - 48px, var(--maxw));
  margin-inline: auto;
}

.section {
  padding-block: clamp(40px, 4vw, 64px);
  position: relative;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-5);
  margin-bottom: var(--s-5);
}

.section-head .eyebrow {
  margin-bottom: 6px;
}

.section-head p.lede {
  color: var(--text-2);
  font-size: 0.95rem;
  margin-top: 6px;
  max-width: 62ch;
}

.section-link {
  flex: none;
  font-size: 0.9rem;
  font-weight: 560;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap 0.25s var(--ease), opacity 0.25s;
}

.section-link:hover {
  gap: 10px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--grad-brand);
}

.grid {
  display: grid;
  gap: var(--s-4);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 0.86rem; }
.tiny { font-size: 0.78rem; }
.strong { font-weight: 640; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: top 0.25s var(--ease);
}

.skip-link:focus {
  top: 14px;
}

/* ---------- Bilingual visibility ---------- */
html[data-lang="zh"] .t-en,
html[data-lang="en"] .t-zh {
  display: none !important;
}

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: var(--d, 0ms);
  will-change: opacity, transform;
}

.reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Print ---------- */
@media print {
  .ambient, .site-nav, .site-footer, .search-overlay { display: none !important; }
  body { background: #fff; color: #000; }
}
