/* ═══════════════════════════════════════════════════════════
   Camera & Perspective — カメラと透視投象  (Explorables)
   Dark minimal theme, echoing the Digital / Curves explorables
   Accent: violet (optics) × amber (light rays)
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0d13;
  --bg-2: #0c1018;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.16);
  --text: #e8ecf4;
  --text-2: #a9b3c6;
  --text-3: #6b7688;
  --acc: #a78bfa;
  --amber: #fbbf24;
  --red: #ef4444;
  --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(167, 139, 250, 0.35); }

/* ── 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(10, 13, 19, 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: #0a0d13;
  background: var(--acc);
  font-weight: 700;
}

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #12101f 0%, var(--bg) 65%);
}
#heroCanvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0.9;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 780px;
  padding: 6rem 1.5rem 4rem;
  text-align: center;
}
.hero-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--acc);
  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(--amber); 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(--acc); }

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

.chapter {
  padding: 5.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.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(--acc);
}
.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 code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--acc);
  background: rgba(167, 139, 250, 0.09);
  border: 1px solid rgba(167, 139, 250, 0.18);
  border-radius: 5px;
  padding: 0.05em 0.36em;
}

/* formulas */
.eq {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--amber);
  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(--amber);
  white-space: nowrap;
}

/* 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); }

/* ── Demos ──────────────────────────────────────────────── */
.demo { margin: 2.2rem 0; }
.demo-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 540px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #080b10;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.demo-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
.demo-stage.tall { aspect-ratio: 16 / 10; }
.demo-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.8rem;
  min-height: 2rem;
}
.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); }

/* control chips */
.chip {
  appearance: none;
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  padding: 0.34rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); }
.chip.on {
  background: var(--acc);
  border-color: var(--acc);
  color: #0a0d13;
  font-weight: 600;
}
.chip.gold.on { background: var(--amber); border-color: var(--amber); }

.ctl-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.ctl-label {
  font-size: 0.72rem;
  color: var(--text-3);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ctl-value {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--amber);
  min-width: 2.6em;
  text-align: right;
  white-space: nowrap;
}
.ctl-sep { width: 1px; height: 1.1rem; background: var(--border-2); margin: 0 0.2rem; }
.ctl-break { flex-basis: 100%; height: 0; }

input[type="range"].ctl-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}
input[type="range"].ctl-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
input[type="range"].ctl-slider::-moz-range-thumb {
  width: 13px; height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
input[type="range"].ctl-slider:disabled { opacity: 0.35; cursor: default; }

.readout {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--text-2);
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px dashed var(--border-2);
  white-space: nowrap;
}
.readout b { color: var(--acc); font-weight: 600; }

/* ── Takeaway box ───────────────────────────────────────── */
.takeaway {
  margin-top: 2.4rem;
  border: 1px solid rgba(167, 139, 250, 0.25);
  background: rgba(167, 139, 250, 0.045);
  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(--acc);
  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); }

/* ── Timeline ───────────────────────────────────────────── */
.timeline {
  list-style: none;
  margin: 1.8rem 0 2.2rem;
  border-left: 2px solid rgba(167, 139, 250, 0.3);
  padding-left: 0;
}
.timeline li {
  position: relative;
  display: flex;
  gap: 1.1rem;
  padding: 0 0 1.05rem 1.6rem;
  font-size: 0.88rem;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px; top: 0.5em;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--acc);
}
.tl-year {
  font-family: var(--mono);
  color: var(--amber);
  min-width: 4.6em;
  flex-shrink: 0;
}
.tl-body { color: var(--text-2); }
.tl-body strong { color: var(--text); }

/* ── 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(--acc);
  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); }

/* next-content card */
.nextcard {
  display: block;
  margin-top: 2.2rem;
  border: 1px solid var(--border-2);
  border-radius: 14px;
  background: var(--surface);
  padding: 1.2rem 1.5rem;
  text-decoration: none;
  transition: all 0.25s;
}
.nextcard:hover { border-color: var(--acc); background: var(--surface-2); }
.nextcard .nc-eyebrow {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--acc);
}
.nextcard .nc-title { color: var(--text); font-weight: 700; font-size: 1.02rem; margin: 0.25rem 0 0.2rem; }
.nextcard .nc-desc { color: var(--text-2); font-size: 0.82rem; }

/* ── 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; }
  .demo-stage { aspect-ratio: 4 / 3; }
  .demo-stage.tall { aspect-ratio: 4 / 3.4; }
  .chapter { padding-top: 4rem; }
  input[type="range"].ctl-slider { width: 90px; }
}

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