/* ═══════════════════════════════════════════════════════════
   Self-Organization — 秩序はどこから来るのか  (Explorables)
   Dark minimal theme, sibling to the Curves / Weaire–Phelan
   explorables. Accent: emerald (order/life) + amber (energy).
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0a0d0f;
  --bg-2: #0c1013;
  --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: #e8f0ec;
  --text-2: #a6b4ad;
  --text-3: #6a7872;
  --acc: #34d399;      /* emerald — order */
  --amber: #fbbf24;    /* amber — energy / food scent */
  --blue: #60a5fa;     /* blue — home scent / info */
  --red: #f87171;
  --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(52, 211, 153, 0.35); }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 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, 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); letter-spacing: 0.04em; white-space: nowrap; transition: color 0.2s; }
.topnav-home:hover { color: var(--text); text-decoration: none; }
.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); 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); text-decoration: none; }
.topnav-links a.active { color: #08110d; 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%, #0e1a16 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.8rem, 5vw, 3rem); font-weight: 700; letter-spacing: 0.04em; line-height: 1.45; margin-bottom: 1.6rem; }
.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); 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); text-decoration: none; }

/* ── 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; }
.inline-note { color: var(--text-3); font-size: 0.9em; }

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

/* 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.8rem;
  border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: top;
}
.tool-table th { color: var(--text-3); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
.tool-table td:first-child { color: var(--text); white-space: nowrap; }

/* ── Demos ──────────────────────────────────────────────── */
.demo { margin: 2.2rem 0; }
.demo-stage {
  position: relative; aspect-ratio: 16 / 9; max-height: 560px;
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border); background: #070a0c;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}
.demo-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.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; }

/* 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: #08110d; font-weight: 600; }
.chip.amber.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.4em; text-align: right; white-space: nowrap; }
.ctl-sep { width: 1px; height: 1.1rem; background: var(--border-2); margin: 0 0.2rem; }

input[type="range"].ctl-slider {
  -webkit-appearance: none; appearance: none; width: 108px; 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; }

.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; }

/* order-parameter meter */
.meter { display: flex; align-items: center; gap: 0.5rem; padding: 0.22rem 0.75rem 0.22rem 0.85rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.meter-label { font-size: 0.72rem; color: var(--text-3); white-space: nowrap; }
.meter-track { position: relative; width: 84px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.12); overflow: hidden; }
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; border-radius: 3px; background: linear-gradient(90deg, var(--blue), var(--acc)); transition: width 0.15s linear; }
.meter-val { font-family: var(--mono); font-size: 0.72rem; color: var(--acc); min-width: 2.6em; text-align: right; }

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

/* ── Cases ──────────────────────────────────────────────── */
.cases { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
.case-card { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 1.2rem 1.3rem; }
.case-card h3 { font-size: 0.98rem; font-weight: 700; line-height: 1.5; }
.case-meta { font-size: 0.74rem; color: var(--amber); margin: 0.25rem 0 0.6rem; }
.case-card p:last-child { font-size: 0.82rem; color: var(--text-2); margin: 0; }

/* ── Timeline ───────────────────────────────────────────── */
.timeline { list-style: none; margin: 1.8rem 0 1rem; border-left: 2px solid rgba(52, 211, 153, 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: 3.4em; flex-shrink: 0; }
.tl-body { 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(--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); }

/* ── 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); }
.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; }
  .chapter { padding-top: 4rem; }
  input[type="range"].ctl-slider { width: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .chapter { opacity: 1; transform: none; transition: none; }
}
