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

/* ===== FOUNDATIONS ===== */
:root {
  --bg-deep: #07070c;
  --bg-primary: #0b0b12;
  --bg-inset: #0e0e16;
  --bg-card: #12121c;
  --bg-card-hover: #171722;
  --bg-code: #0a0e14;
  --accent: #c9a84c;
  --accent-soft: #c9a84c60;
  --accent-dim: #c9a84c25;
  --accent-glow: #c9a84c15;
  --text-hero: #f2eee6;
  --text-primary: #dad6ce;
  --text-secondary: #8e8a82;
  --text-tertiary: #555250;
  --border: #1e1e2a;
  --border-light: #2a2a38;
  --serif: "Georgia", "Times New Roman", "Noto Serif", serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", "SF Mono", "Consolas", "JetBrains Mono", "Fira Code", monospace;
}

html { scroll-behavior: smooth; scrollbar-color: #2a2a38 var(--bg-deep); }
body {
  font-family: var(--serif);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.72;
  font-size: 17px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== GRAIN OVERLAY ===== */
.grain {
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none; opacity: 0.02;
}
.grain svg { width: 100%; height: 100%; }

/* ===== ACCENT RULE ===== */
.accent-rule {
  height: 1px; border: none; margin: 0;
  background: linear-gradient(90deg, transparent, var(--accent-soft), var(--accent), var(--accent-soft), transparent);
  opacity: 0.4;
}

/* ===== HERO ===== */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 55% 50% at 30% 45%, var(--accent-dim), transparent),
    radial-gradient(ellipse 55% 50% at 70% 55%, var(--accent-glow), transparent),
    radial-gradient(ellipse 80% 60% at 50% 80%, transparent, var(--bg-deep));
  z-index: 0;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 200px;
  background: linear-gradient(to top, var(--bg-deep), transparent);
  z-index: 1;
}
.hero-content { position: relative; z-index: 2; max-width: 860px; }
.hero-pub {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 2.5rem;
}
.hero-pub span { color: var(--text-secondary); }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.8rem, 7vw, 5.2rem);
  font-weight: 400;
  line-height: 1.08;
  color: var(--text-hero);
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}
.hero h1 em {
  font-style: italic;
  background: linear-gradient(135deg, var(--accent), #e2c97d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-sub {
  font-family: var(--serif);
  font-size: clamp(1.02rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 660px;
  margin: 0 auto 2.5rem;
  font-style: italic;
}
.hero-meta {
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-meta .dot { color: var(--border-light); }

/* ===== SCROLL HINT ===== */
.scroll-hint {
  position: absolute; bottom: 2.5rem; left: 50%;
  transform: translateX(-50%); z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.scroll-hint span {
  font-family: var(--sans); font-size: 0.62rem;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-tertiary);
}
.scroll-arrow {
  width: 1px; height: 28px;
  background: linear-gradient(to bottom, var(--text-tertiary), transparent);
  animation: scrollPulse 2s ease-in-out infinite;
}
@keyframes scrollPulse {
  0%, 100% { opacity: 0.3; transform: scaleY(1); }
  50% { opacity: 0.8; transform: scaleY(1.3); }
}

/* ===== TOC NAV ===== */
.toc-nav {
  position: fixed; top: 50%; right: 1.5rem;
  transform: translateY(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 0.4rem;
  opacity: 0; transition: opacity 0.6s;
}
.toc-nav.visible { opacity: 1; }
.toc-dot {
  display: block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--border-light);
  border: none; cursor: pointer; transition: all 0.3s; position: relative;
}
.toc-dot:hover { background: var(--text-secondary); transform: scale(1.3); }
.toc-dot.active { background: var(--accent); transform: scale(1.5); box-shadow: 0 0 8px var(--accent-dim); }
.toc-dot::after {
  content: attr(data-label);
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  font-family: var(--sans); font-size: 0.65rem; letter-spacing: 0.05em;
  color: var(--text-secondary); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.toc-dot:hover::after { opacity: 1; }

/* ===== HOME NAV ===== */
.home-nav {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.6s;
}
.home-nav.visible { opacity: 1; }
.home-nav a {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.2s;
}
.home-nav a:hover { color: var(--accent); }

/* ===== BACK TO TOP ===== */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--sans);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s, border-color 0.3s, color 0.3s;
  pointer-events: none;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { border-color: var(--accent); color: var(--accent); }

/* ===== MOBILE HOME BUTTON ===== */
.home-btn {
  display: none;
  position: fixed;
  right: 1.5rem;
  bottom: 2rem;
  z-index: 100;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.4s, border-color 0.3s, color 0.3s;
  pointer-events: none;
  text-decoration: none;
}
.home-btn svg { width: 18px; height: 18px; }
.home-btn.visible { opacity: 1; pointer-events: auto; }
.home-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== MAIN LAYOUT ===== */
main { max-width: 720px; margin: 0 auto; padding: 0 2rem; }
.section {
  padding: 5rem 0;
  opacity: 0; transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.section.in-view { opacity: 1; transform: translateY(0); }
.section-label {
  font-family: var(--sans); font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--text-tertiary); margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.8rem;
}
.section-label::before { content: ''; width: 24px; height: 1px; background: var(--border-light); }
.section h2 {
  font-family: var(--serif); font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  font-weight: 400; line-height: 1.15; color: var(--text-hero);
  letter-spacing: -0.02em; margin-bottom: 1.8rem;
}
.section h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text-hero);
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.01em;
}

/* ===== TYPOGRAPHY ===== */
p { margin-bottom: 1.25rem; }
p + p { text-indent: 1.5em; }

/* ===== FOOTER ===== */
footer {
  text-align: center; padding: 4rem 2rem;
  font-family: var(--sans); font-size: 0.72rem;
  color: var(--text-tertiary); letter-spacing: 0.04em;
}
footer a {
  color: var(--text-secondary); text-decoration: none;
  transition: color 0.2s;
}
footer a:hover { color: var(--accent); }
footer .footer-nav {
  display: flex; justify-content: center; gap: 1.5rem;
  margin-bottom: 1.2rem; flex-wrap: wrap;
}
footer .footer-nav a {
  font-family: var(--mono); font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-tertiary);
}
footer .footer-brand {
  font-family: var(--serif); font-size: 0.88rem;
  color: var(--text-secondary); margin-bottom: 0.5rem;
  font-style: italic;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
  main { padding: 0 1.2rem; }
  .toc-nav { display: none; }
  .section { padding: 3rem 0; }
  .hero h1 { font-size: 2.4rem; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .home-nav { display: none; }
  .back-to-top { bottom: 4.25rem; right: 1rem; }
  .home-btn { display: flex; bottom: 1.5rem; right: 1rem; }
}
