/* ─────────────────────────────────────────
   Chion · 启元 — chion.studio
   Production site · multi-section + i18n + manual theme
   ───────────────────────────────────────── */

:root {
  /* Brand */
  --chion-black: #0A0A0A;
  --chion-white: #FAFAFA;
  --chion-blue: #2D5BFF;
  --chion-mint: #4ADE80;

  /* Neutrals */
  --gray-100: #E4E4E7;
  --gray-300: #A1A1AA;
  --gray-500: #71717A;
  --gray-700: #3F3F46;
  --gray-800: #27272A;
  --gray-900: #18181B;

  /* Type stacks */
  --font-en: 'Geist', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-cn: 'PingFang SC', 'Source Han Sans CN', 'Microsoft YaHei', sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;

  /* Layout */
  --container: 1200px;
  --gutter: 2rem;
  --section-y: 8rem;
}

/* ─── Theme tokens ─── */
:root[data-theme="dark"] {
  --bg: var(--chion-black);
  --fg: var(--chion-white);
  --fg-muted: var(--gray-500);
  --fg-dim: var(--gray-700);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --grid-dot: rgba(255, 255, 255, 0.05);
  --bg-elevated: rgba(255, 255, 255, 0.025);
  --nav-bg: rgba(10, 10, 10, 0.6);
  --footer-bg: rgba(0, 0, 0, 0.3);
  --accent: var(--chion-blue);
}

:root[data-theme="light"] {
  --bg: var(--chion-white);
  --fg: var(--chion-black);
  --fg-muted: var(--gray-500);
  --fg-dim: var(--gray-300);
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --grid-dot: rgba(0, 0, 0, 0.06);
  --bg-elevated: rgba(0, 0, 0, 0.02);
  --nav-bg: rgba(250, 250, 250, 0.7);
  --footer-bg: rgba(255, 255, 255, 0.4);
  --accent: var(--chion-blue);
}

/* ─── Language visibility ─── */
:root[data-lang="en"] [lang="zh"] { display: none !important; }
:root[data-lang="zh"] [lang="en"] { display: none !important; }

/* When in ZH mode, prefer Chinese font on body */
:root[data-lang="zh"] body {
  font-family: var(--font-cn);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px; /* offset for sticky nav when jumping to anchors */
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-en);
  font-feature-settings: 'ss01', 'ss03', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  position: relative;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font: inherit; background: none; border: none; cursor: pointer; }

/* ─── Background layers ─── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, var(--grid-dot) 1px, transparent 1.2px);
  background-size: 32px 32px;
}

.bg-gradient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 30% 10%, rgba(45, 91, 255, 0.20), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 60%, rgba(45, 91, 255, 0.10), transparent 60%);
  animation: gradient-drift 24s ease-in-out infinite alternate;
}

@keyframes gradient-drift {
  0%   { transform: translate(0, 0)    scale(1); }
  50%  { transform: translate(2%, -1%) scale(1.05); }
  100% { transform: translate(-2%, 1%) scale(0.98); }
}

.bg-noise {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.nav, .hero, .section, .footer { position: relative; z-index: 1; }

/* ─── Navigation ─── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem var(--gutter);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.nav.scrolled { border-bottom-color: var(--line); }

.nav-brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-weight: 500;
}

.nav-brand-en {
  font-family: var(--font-en);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.nav-brand-cn {
  font-family: var(--font-cn);
  font-size: 0.9rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  color: var(--fg-muted);
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  transition: color 0.2s ease;
}

:root[data-lang="zh"] .nav-link {
  font-family: var(--font-cn);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: none;
}

.nav-link:hover { color: var(--fg); }

/* Cross-domain link variant */
.nav-divider {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
  margin: 0 0.25rem;
  display: inline-block;
  align-self: center;
}

.nav-link-ext {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.ext-arrow {
  font-size: 0.85em;
  color: var(--fg-dim);
  transition: transform 0.2s ease, color 0.2s ease;
  display: inline-block;
}

.nav-link-ext:hover .ext-arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

/* ─── Toggles ─── */
.nav-toggles {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.toggle-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.toggle-btn:hover {
  color: var(--fg);
  border-color: var(--line-strong);
  background: var(--bg-elevated);
}

.toggle-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.toggle-icon { display: block; }

/* Toggle visibility (show what user will switch TO) */
.toggle-show-when-en, .toggle-show-when-zh,
.toggle-show-when-dark, .toggle-show-when-light {
  display: none;
}

:root[data-lang="en"] .toggle-show-when-en { display: inline; }
:root[data-lang="zh"] .toggle-show-when-zh { display: inline; }
:root[data-theme="dark"] .toggle-show-when-dark { display: block; }
:root[data-theme="light"] .toggle-show-when-light { display: block; }

/* ─── Hero ─── */
.hero {
  min-height: calc(100vh - 4rem);
  min-height: calc(100dvh - 4rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem var(--gutter) 4rem;
  gap: 3rem;
  text-align: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  text-transform: uppercase;
  animation: fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eyebrow-bracket, .eyebrow-divider { color: var(--fg-dim); }

[data-stagger] {
  opacity: 0;
  animation: fade-up 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
[data-stagger="1"] { animation-delay: 0.2s; }
[data-stagger="2"] { animation-delay: 0.6s; }
[data-stagger="3"] { animation-delay: 1.0s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.title {
  font-family: var(--font-en);
  font-size: clamp(5rem, 14vw, 10rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.95;
  color: var(--fg);
  text-shadow:
    0 0 40px rgba(45, 91, 255, 0.25),
    0 0 120px rgba(45, 91, 255, 0.15);
  min-height: 1em;
}

.subtitle {
  font-family: var(--font-cn);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 300;
  letter-spacing: 0.5em;
  padding-left: 0.5em;
  color: var(--fg);
  opacity: 0.85;
}

.tagline {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 32rem;
}

.tagline-primary {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 400;
  color: var(--fg);
}

.tagline-primary[lang="zh"] {
  font-family: var(--font-cn);
  letter-spacing: 0.04em;
}

.hero-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--fg-muted);
}

.cta-line {
  width: 1px;
  height: 32px;
  background: linear-gradient(to bottom, transparent, var(--fg-muted));
  animation: cta-pulse 2s ease-in-out infinite;
}

@keyframes cta-pulse {
  0%, 100% { opacity: 0.5; transform: scaleY(1); }
  50% { opacity: 1; transform: scaleY(1.1); }
}

/* Crosshairs */
.crosshair {
  position: absolute;
  width: 24px; height: 24px;
  color: var(--fg-dim);
  pointer-events: none;
  opacity: 0;
  animation: fade-in 1s ease-out 1.4s forwards;
}
@keyframes fade-in { to { opacity: 1; } }
.crosshair-tl { top: 24px; left: 24px; }
.crosshair-tr { top: 24px; right: 24px; }
.crosshair-bl { bottom: 24px; left: 24px; }
.crosshair-br { bottom: 24px; right: 24px; }

/* ─── Sections ─── */
.section {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--section-y) var(--gutter);
  border-top: 1px solid var(--line);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 3rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.section-num { color: var(--fg-muted); }

.section-label {
  color: var(--fg);
  position: relative;
  padding-left: 0.75rem;
}

.section-label[lang="zh"] {
  font-family: var(--font-cn);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: none;
}

.section-label::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 50%;
  width: 1.5rem;
  height: 1px;
  background: var(--line-strong);
  transform: translateY(-50%);
}

.section-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 3rem;
  max-width: 26ch;
  color: var(--fg);
}

.section-title [lang="zh"] {
  font-family: var(--font-cn);
  letter-spacing: -0.01em;
}

.section-body { max-width: 64rem; }

/* ─── Manifesto ─── */
.prose {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 50ch;
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--fg);
}

.prose strong {
  font-weight: 500;
  color: var(--fg);
}

.prose p[lang="zh"] {
  font-family: var(--font-cn);
  font-weight: 300;
  font-size: 1.05rem;
  line-height: 1.8;
  letter-spacing: 0.02em;
}

/* ─── Approach ─── */
.principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.principle {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 2rem;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.principle:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.principle-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

.principle-title {
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--fg);
}

.principle-title [lang="zh"] {
  font-family: var(--font-cn);
  font-weight: 300;
  font-size: 2.5rem;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.principle-body {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--fg-muted);
}

.principle-body[lang="zh"] {
  font-family: var(--font-cn);
  line-height: 1.85;
  letter-spacing: 0.02em;
}

@media (max-width: 880px) { .principles { grid-template-columns: 1fr; } }

/* ─── Contact ─── */
.contact-body { max-width: none; }

.contact-title { margin-bottom: 4rem; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  border-top: 1px solid var(--line);
  padding-top: 3rem;
}

.contact-cell {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.contact-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.contact-link {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  width: fit-content;
  transition: color 0.2s ease;
}

.email-arrow {
  display: inline-block;
  color: var(--accent);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.email-text {
  border-bottom: 1px solid var(--fg-dim);
  padding-bottom: 0.15rem;
  transition: border-color 0.2s ease;
}

.contact-link:hover { color: var(--accent); }
.contact-link:hover .email-arrow { transform: translateX(4px); }
.contact-link:hover .email-text { border-bottom-color: var(--accent); }

@media (max-width: 720px) { .contact-grid { grid-template-columns: 1fr; } }

/* ─────────────────────────────────────────
   Verses (inter-section poetic dividers)
   起 · 静 · 作 · 久
   ───────────────────────────────────────── */
.verse {
  position: relative;
  z-index: 1;
  max-width: var(--container);
  margin: 0 auto;
  padding: 4.5rem var(--gutter);
  text-align: center;
  border-top: 1px solid var(--line);
}

.verse::before {
  content: '·';
  position: absolute;
  top: -0.5em;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--fg-dim);
  background: var(--bg);
  padding: 0 0.6rem;
  line-height: 1;
}

.verse-line {
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--fg);
  line-height: 1.5;
  max-width: 32ch;
  margin: 0 auto;
}

.verse-line[lang="zh"] {
  font-family: var(--font-cn);
  letter-spacing: 0.18em;
  font-size: clamp(1.4rem, 3.2vw, 2.1rem);
}

.verse-line[lang="en"] {
  font-family: var(--font-en);
  font-weight: 400;
  font-style: italic;
  color: var(--fg-muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  letter-spacing: 0.01em;
}

/* When both EN and CN are visible (no lang attribute filtering),
   stack them with smaller EN below.
   Currently they're toggled by lang, so only one shows at a time. */

/* Final verse before footer — slightly more emphasis */
.verse-final {
  padding: 5.5rem var(--gutter);
}

@media (max-width: 720px) {
  .verse { padding: 3.5rem var(--gutter); }
  .verse-final { padding: 4.5rem var(--gutter); }
}

/* ─── Footer ─── */
.footer {
  border-top: 1px solid var(--line);
  background: var(--footer-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0 var(--gutter);
}

.footer-top {
  max-width: var(--container);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 4rem;
  padding: 4rem 0 3rem;
}

.footer-brand-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.footer-brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.footer-brand-en {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--fg);
}

.footer-brand-cn {
  font-family: var(--font-cn);
  font-size: 1.05rem;
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--fg-muted);
}

.footer-tagline {
  font-size: 0.95rem;
  color: var(--fg-muted);
  max-width: 24rem;
  line-height: 1.5;
}

.footer-tagline[lang="zh"] {
  font-family: var(--font-cn);
  letter-spacing: 0.04em;
}

.footer-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem 2rem;
  align-content: start;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.footer-meta-label {
  color: var(--fg-muted);
  font-size: 0.65rem;
}

.footer-meta-value {
  color: var(--fg);
  letter-spacing: 0.05em;
}

.footer-bottom {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}

.footer-domains, .footer-legal {
  display: flex;
  gap: 1.5rem;
}

.footer-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  transition: color 0.2s ease;
}

.footer-link:hover { color: var(--fg); }

/* ─── Mobile ─── */
@media (max-width: 720px) {
  :root { --gutter: 1.25rem; --section-y: 5rem; }
  .nav-links { gap: 1rem; }
  .footer-top {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    padding: 3rem 0 2rem;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .crosshair { width: 16px; height: 16px; }
  .crosshair-tl, .crosshair-tr { top: 16px; }
  .crosshair-bl, .crosshair-br { bottom: 16px; }
  .crosshair-tl, .crosshair-bl { left: 16px; }
  .crosshair-tr, .crosshair-br { right: 16px; }
}

@media (max-width: 480px) {
  .nav-link { font-size: 0.7rem; }
  .nav-brand-cn { display: none; }
}

/* ─────────────────────────────────────────
   Interactive animations
   1. Reading progress bar
   2. Scroll-triggered reveals
   3. Verse line grow + dot pop
   4. Principle card 3D tilt
   ───────────────────────────────────────── */

/* 1. Reading progress bar */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 1px;
  width: 0;
  background: linear-gradient(90deg, transparent, var(--accent) 80%, var(--accent));
  z-index: 200;
  pointer-events: none;
  transition: width 0.08s linear;
  box-shadow: 0 0 8px rgba(45, 91, 255, 0.5);
}

/* 2. Scroll reveals */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger for siblings inside a parent */
.principles .principle.reveal:nth-child(1) { transition-delay: 0.05s; }
.principles .principle.reveal:nth-child(2) { transition-delay: 0.18s; }
.principles .principle.reveal:nth-child(3) { transition-delay: 0.32s; }

.contact-grid .contact-cell.reveal:nth-child(1) { transition-delay: 0.05s; }
.contact-grid .contact-cell.reveal:nth-child(2) { transition-delay: 0.15s; }
.contact-grid .contact-cell.reveal:nth-child(3) { transition-delay: 0.25s; }

.prose p.reveal:nth-of-type(1) { transition-delay: 0.05s; }
.prose p.reveal:nth-of-type(2) { transition-delay: 0.15s; }
.prose p.reveal:nth-of-type(3) { transition-delay: 0.25s; }
.prose p.reveal:nth-of-type(4) { transition-delay: 0.35s; }

/* 3. Verse animations — line grow + dot pop */
.verse {
  /* Override existing border-top so we control it via ::after */
  border-top: none;
}

.verse::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 0;
  height: 1px;
  background: var(--line-strong);
  transition:
    width 1.4s cubic-bezier(0.22, 1, 0.36, 1),
    left 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.verse.in-view::after {
  width: 100%;
  left: 0;
}

.verse::before {
  /* Existing dot — make it scale-pop on enter */
  transform: translateX(-50%) scale(0);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.7s;
}

.verse.in-view::before {
  transform: translateX(-50%) scale(1);
}

.verse .verse-line {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 1s cubic-bezier(0.22, 1, 0.36, 1) 0.4s,
    transform 1s cubic-bezier(0.22, 1, 0.36, 1) 0.4s;
}

.verse.in-view .verse-line {
  opacity: 1;
  transform: translateY(0);
}

/* 4. Principle card 3D tilt — JS sets transform on mousemove */
.principle {
  transform-origin: center center;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.3s ease,
    background 0.3s ease;
  will-change: transform;
  /* Re-establish hover effect now that JS controls transform */
}
.principle:hover {
  border-color: var(--line-strong);
  background: var(--bg-elevated);
}

/* ─────────────────────────────────────────
   Phase 2 interactions
   5. Mouse-follow ambient glow
   6. Section-aware nav highlight
   7. Magnetic contact links
   ───────────────────────────────────────── */

/* 5. Mouse-follow glow — a soft radial gradient that trails the cursor */
.mouse-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 480px;
  height: 480px;
  margin-left: -240px;
  margin-top: -240px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.4s ease;
  opacity: 1;
  will-change: transform;
}

:root[data-theme="dark"] .mouse-glow {
  background: radial-gradient(circle, rgba(45, 91, 255, 0.10), rgba(45, 91, 255, 0.03) 40%, transparent 70%);
  mix-blend-mode: screen;
}

:root[data-theme="light"] .mouse-glow {
  background: radial-gradient(circle, rgba(45, 91, 255, 0.10), rgba(45, 91, 255, 0.03) 40%, transparent 70%);
  mix-blend-mode: multiply;
}

.mouse-glow-hidden { opacity: 0; }

/* 6. Active nav link — small accent dot below the matched link */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transform: translateX(-50%) scale(0.4);
  transition:
    opacity 0.3s ease,
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.nav-link-active {
  color: var(--fg);
}

.nav-link-active::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* 7. Magnetic links — set up smooth return on mouse leave */
.contact-link {
  display: inline-flex;
  transition:
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    color 0.2s ease;
  will-change: transform;
}

/* ─────────────────────────────────────────
   Phase 3 interactions
   8. Verse word / character reveal
   9. Parallax hero crosshair
   10. Principle hover scrub
   ───────────────────────────────────────── */

/* 8. Verse tokens (word for EN, char for ZH).
   Replaces the line-level reveal: in-view triggers each token sequentially.
*/
.verse .verse-line {
  /* Override Phase 1 line-level animation; tokens animate now */
  opacity: 1 !important;
  transform: none !important;
}

.verse-tok {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.4em);
  filter: blur(2px);
  transition:
    opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.verse.in-view .verse-tok {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* Chinese tokens get tighter spacing — each char as a token */
.verse-line[lang="zh"] .verse-tok {
  margin-right: 0.04em;
}

/* 9. Hero parallax crosshair —
   JS sets the transform; we just need a smooth ride */
.crosshair {
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

/* 10. Principle hover scrub — bottom 1px progress line that follows cursor X */
.principle::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: var(--scrub, 0%);
  background: var(--accent);
  transition: width 0.12s linear;
  pointer-events: none;
}

.principle {
  position: relative;
  overflow: hidden; /* contain the scrub bar */
}

/* ─────────────────────────────────────────
   Phase 4 interactions
   11. Splash intro curtain
   12. Wordmark hover wave
   13. Nav link underline draw
   ───────────────────────────────────────── */

/* 11. Splash curtain — covers viewport, then slides up to reveal page */
.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chion-black);
  pointer-events: none;
  animation: splash-rise 1.4s cubic-bezier(0.7, 0, 0.3, 1) 0.6s forwards;
}

:root[data-theme="light"] .splash {
  background: var(--chion-white);
}

.splash-mark {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 0 0 rgba(45, 91, 255, 0.6),
    0 0 30px rgba(45, 91, 255, 0.4);
  animation:
    splash-pulse 1.2s cubic-bezier(0.22, 1, 0.36, 1) infinite,
    splash-mark-fade 0.6s cubic-bezier(0.7, 0, 0.3, 1) 0.7s forwards;
  /* Render as a tiny dot, not the literal "·" character */
  font-size: 0;
}

@keyframes splash-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 91, 255, 0.6), 0 0 30px rgba(45, 91, 255, 0.4); }
  50% { box-shadow: 0 0 0 14px rgba(45, 91, 255, 0), 0 0 30px rgba(45, 91, 255, 0.4); }
}

@keyframes splash-mark-fade {
  to { opacity: 0; transform: scale(0.5); }
}

@keyframes splash-rise {
  0%   { transform: translateY(0); }
  100% { transform: translateY(-101%); }
}

.splash-done { display: none; }

/* 12. Wordmark hover wave — letters bob up like a wave on hover */
.nav-brand-en .word-letter {
  display: inline-block;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-brand:hover .word-letter {
  transform: translateY(-3px);
}

.nav-brand:hover .word-letter:nth-child(1) { transition-delay: 0s; }
.nav-brand:hover .word-letter:nth-child(2) { transition-delay: 0.05s; }
.nav-brand:hover .word-letter:nth-child(3) { transition-delay: 0.10s; }
.nav-brand:hover .word-letter:nth-child(4) { transition-delay: 0.15s; }
.nav-brand:hover .word-letter:nth-child(5) { transition-delay: 0.20s; }

/* 13. Nav link underline draw — single line wipes in from left on hover */
.nav-link::before {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  right: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.nav-link:hover::before {
  transform: scaleX(1);
}

/* When link is active (section in view), keep the underline visible */
.nav-link-active::before {
  transform: scaleX(1);
  background: var(--accent);
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .reveal { opacity: 1; transform: none; }
  .verse::after { width: 100%; left: 0; }
  .verse::before { transform: translateX(-50%) scale(1); }
  .verse .verse-line { opacity: 1; transform: none; }
}
