/* ═══════════════════════════════════════════════════════════
   3D Gaussian Splatting (Explorables)
   Dark minimal theme, cohesive with the WebGL2 viewer (blue accent)
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #08090f;
  --bg-2: #0d1119;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(140, 195, 255, 0.13);
  --border-2: rgba(140, 195, 255, 0.28);
  --text: #e6edf7;
  --text-2: #a7b4c8;
  --text-3: #6a778c;
  --accent: #8cc3ff;
  --gold: #f3d27a;
  --violet: #b49bff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(140, 195, 255, 0.32); }

/* ── Top navigation ─────────────────────────────────────── */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1.2rem;
  background: rgba(8, 9, 15, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.topnav-home {
  color: var(--text-2);
  text-decoration: none;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: color 0.2s;
}
.topnav-home:hover { color: var(--text); }
.topnav-title {
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
  font-size: 0.7rem;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topnav-links { display: flex; gap: 0.3rem; }
.topnav-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem; height: 1.7rem;
  border-radius: 50%;
  color: var(--text-3);
  text-decoration: none;
  font-size: 0.72rem;
  font-family: var(--mono);
  border: 1px solid transparent;
  transition: all 0.2s;
}
.topnav-links a:hover { color: var(--text); border-color: var(--border-2); }
.topnav-links a.active {
  color: #08090f;
  background: var(--accent);
  font-weight: 700;
}

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 8%, rgba(140, 195, 255, 0.15), transparent 34%),
    radial-gradient(circle at 82% 88%, rgba(180, 155, 255, 0.10), transparent 30%),
    radial-gradient(130% 90% at 50% 0%, #0e1524 0%, var(--bg) 62%);
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 800px;
  padding: 6rem 1.5rem 4rem;
  text-align: center;
}
.hero-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.4rem;
}
.hero h1 {
  font-size: clamp(1.7rem, 4.6vw, 2.9rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.45;
  margin-bottom: 1.6rem;
}
.hero-dash { margin: 0 0.35em; color: var(--text-3); font-weight: 300; }
.hero-lead {
  font-size: 0.95rem;
  color: var(--text-2);
  text-align: left;
  margin-bottom: 2.4rem;
}
.hero-lead strong { color: var(--gold); font-weight: 600; }
.hero-cta {
  display: inline-block;
  padding: 0.75rem 2.2rem;
  border: 1px solid var(--border-2);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  background: var(--surface);
  transition: all 0.25s;
}
.hero-cta:hover { background: var(--surface-2); border-color: var(--accent); }

/* ── Chapters ───────────────────────────────────────────── */
.content { max-width: 880px; margin: 0 auto; padding: 0 1.4rem; }

.chapter {
  padding: 5.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
}
.js .chapter {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.js .chapter.visible { opacity: 1; transform: none; }
.chapter:last-of-type { border-bottom: none; }

.ch-head { margin-bottom: 2rem; }
.ch-index {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
.ch-head h2 {
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.5;
  margin: 0.5rem 0 0.4rem;
}
.ch-sub { font-size: 0.9rem; color: var(--text-3); }

.ch-prose p { margin-bottom: 1.3rem; font-size: 0.95rem; color: var(--text-2); }
.ch-prose strong { color: var(--text); font-weight: 600; }
.ch-prose .accent { color: var(--accent); font-weight: 600; }

/* formulas / inline code */
.eq {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--gold);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.2rem;
  margin: 0 0 1.3rem;
  text-align: center;
  overflow-x: auto;
  white-space: nowrap;
}
.eq-inline {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--gold);
  white-space: nowrap;
}

/* step lists (numbered process) */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0.4rem 0 1.5rem;
  display: grid;
  gap: 0.7rem;
}
.steps li {
  position: relative;
  padding: 0.15rem 0 0 3rem;
  font-size: 0.92rem;
  color: var(--text-2);
  min-height: 2rem;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
}
.steps strong { color: var(--text); }

/* note (comparison / aside) */
.note {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.1rem 1.3rem 1rem;
  margin: 1.6rem 0;
  border-left: 3px solid var(--accent);
}
.note p { margin: 0.35rem 0 0; font-size: 0.88rem; color: var(--text-2); }
.note p:first-child { margin-top: 0; }
.note-tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.18rem 0.7rem;
  border-radius: 999px;
  background: rgba(140, 195, 255, 0.13);
  color: var(--accent);
}
.note.gold { border-left-color: var(--gold); }
.note.gold .note-tag { background: rgba(243, 210, 122, 0.15); color: var(--gold); }
.note strong { color: var(--text); }

/* mode legend for the playground */
.legend {
  list-style: none;
  display: grid;
  gap: 0.6rem;
  margin: 0.4rem 0 1.4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1.1rem 1.3rem;
}
.legend li {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-size: 0.88rem;
  color: var(--text-2);
}
.legend .tag {
  flex-shrink: 0;
  min-width: 3.4em;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(140, 195, 255, 0.14);
  color: var(--accent);
  border: 1px solid var(--border-2);
}
.legend strong { color: var(--text); font-weight: 600; }

/* comparison table */
.tool-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0 0 1.5rem;
}
.tool-table th, .tool-table td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
}
.tool-table thead th {
  color: var(--text-3);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.tool-table th:nth-child(2) { color: var(--gold); }
.tool-table th:nth-child(3) { color: var(--accent); }
.tool-table td:first-child, .tool-table tbody th:first-child {
  color: var(--text);
  white-space: nowrap;
  font-weight: 600;
}

/* generic lists */
.glist { margin: 0 0 1.3rem 1.2rem; }
.glist li { font-size: 0.92rem; color: var(--text-2); margin-bottom: 0.55rem; }
.glist strong { color: var(--text); }

/* ── Takeaway box ───────────────────────────────────────── */
.takeaway {
  margin-top: 2.4rem;
  border: 1px solid rgba(140, 195, 255, 0.25);
  background: rgba(140, 195, 255, 0.05);
  border-radius: 14px;
  padding: 1.3rem 1.6rem 1.1rem;
}
.takeaway h3 {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.7rem;
}
.takeaway ul { margin-left: 1.2rem; }
.takeaway li { font-size: 0.88rem; color: var(--text-2); margin-bottom: 0.4rem; }
.takeaway strong { color: var(--text); }

/* ── Playground (the WebGL2 viewer) ─────────────────────── */
.playground-window {
  position: relative;
  width: 100%;
  height: min(78vh, 680px);
  min-height: 480px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0a14;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
#program-container-gaussian_splatting {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* ミニデモ用ウィンドウ（S2 粒の積み上げ / S3 一粒の解剖 / S5 微分と学習） */
.playground-window.mini { height: min(64vh, 540px); min-height: 420px; }
.playground-window.mini.short { height: min(58vh, 470px); min-height: 400px; }
.playground-window > [id^="program-container-"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* 学習デモは中身の高さで決まるフロー配置 */
.playground-window.flow { height: auto; min-height: 0; }
.playground-window.flow > [id^="program-container-"] {
  position: relative;
  inset: auto;
  height: auto;
}
.demo-lead {
  font-size: 0.95rem;
  color: var(--text-2);
  margin: 0.4rem 0 1.2rem;
}
.demo-lead strong { color: var(--text); font-weight: 600; }
.demo-hint {
  margin-top: 0.7rem;
  font-size: 0.78rem;
  color: var(--text-3);
  line-height: 1.7;
}
.demo-hint strong { color: var(--text-2); }

/* ── Q&A ────────────────────────────────────────────────── */
.qa {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 0.8rem;
  overflow: hidden;
}
.qa summary {
  cursor: pointer;
  padding: 1rem 1.3rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  position: relative;
  padding-right: 3rem;
  transition: background 0.2s;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::after {
  content: "+";
  position: absolute;
  right: 1.2rem; top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 400;
  transition: transform 0.25s;
}
.qa[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.qa summary:hover { background: var(--surface-2); }
.qa-body { padding: 0 1.3rem 1.1rem; }
.qa-body p { font-size: 0.88rem; color: var(--text-2); margin: 0 0 0.6rem; }
.qa-body strong { color: var(--text); }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  margin-top: 4rem;
  padding: 2.4rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-3);
}
.site-footer nav { margin-top: 0.6rem; display: flex; gap: 1.4rem; justify-content: center; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 15px; }
  .topnav { padding: 0.5rem 0.8rem; gap: 0.6rem; }
  .topnav-title { display: none; }
  .chapter { padding-top: 4rem; }
  .playground-window { height: 82vh; min-height: 440px; }
  .playground-window.mini { height: 72vh; min-height: 420px; }
  .playground-window.mini.short { height: 66vh; min-height: 400px; }
  .playground-window.flow { height: auto; min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .chapter { opacity: 1; transform: none; transition: none; }
}
