/**
 * site.css — Shared dark theme for the Hex Path Tiles explainer site.
 *
 * Palette (from PLAN.md):
 *   --bg       #0f1117   page background
 *   --surface  #1a1d27   card / widget surfaces
 *   --border   #2a2d3a   borders / dividers
 *   --text     #e2e4ea   body text
 *   --muted    #9a9caa   secondary / caption text
 *   --accent   #6c8aff   primary accent (blue-violet)
 *   --accent2  #b06cff   secondary accent (violet)
 *
 * Path-type fixed colours (used in diagrams):
 *   --path-red   #ee4036   arc type 0↔1 (adjacent)
 *   --path-green #33c057   arc type 2↔4 (skip-one)
 *   --path-blue  #3a6fe8   arc type 3↔5 (skip-one)
 */

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

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #141720;   /* slightly darker surface for nested cards */
  --border:    #2a2d3a;
  --text:      #e2e4ea;
  --muted:     #9a9caa;
  --accent:    #6c8aff;
  --accent2:   #b06cff;

  /* Path-type colours (fixed, from PLAN.md) */
  --path-red:   #ee4036;
  --path-green: #33c057;
  --path-blue:  #3a6fe8;

  /* Layout */
  --nav-h:      52px;
  --content-w:  860px;
  --wide-w:     1100px;
  --radius:     8px;
  --radius-lg:  12px;

  /* Typography */
  --font-ui:   "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Mono", ui-monospace, monospace;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

/* ── Top navigation bar ────────────────────────────────────────────────── */
#site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.nav-inner {
  width: 100%;
  max-width: var(--wide-w);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-brand {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
  margin-right: 12px;
  flex-shrink: 0;
}

.nav-brand:hover { color: var(--accent2); }

.nav-links {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-wrap: wrap;
  overflow: hidden;
}

.nav-link {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: var(--accent);
  background: rgba(108, 138, 255, 0.1);
}

/* ── Prev/next footer navigation ───────────────────────────────────────── */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  max-width: var(--content-w);
  margin: 4rem auto 0;
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-nav-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-decoration: none;
  color: var(--text);
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
  max-width: 240px;
}

.page-nav-link:hover {
  border-color: var(--accent);
  background: rgba(108, 138, 255, 0.06);
}

.page-nav-link.prev { text-align: right; }
.page-nav-link.next { text-align: left;  }

.page-nav-direction {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-nav-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.page-nav-spacer { flex: 1; }

/* ── Main content container ─────────────────────────────────────────────── */
.container {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 2rem 6rem;
}

.container.wide {
  max-width: var(--wide-w);
}

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header {
  text-align: center;
  padding: 4rem 2rem 3rem;
  background: linear-gradient(180deg, #161824 0%, var(--bg) 100%);
}

.page-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.page-header .subtitle {
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── Sections ───────────────────────────────────────────────────────────── */
section {
  margin-top: 4rem;
}

.section-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: rgba(108, 138, 255, 0.1);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

section h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

section h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--text);
}

section p {
  color: var(--muted);
  margin-bottom: 1rem;
  font-size: 1rem;
}

section p strong { color: var(--text); }

section a {
  color: var(--accent);
  text-decoration: none;
}
section a:hover { text-decoration: underline; }

/* ── Figure / figure-caption ─────────────────────────────────────────────── */
figure {
  margin: 1.5rem 0 2rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

figure img,
figure video,
figure canvas,
figure svg {
  display: block;
  width: 100%;
  height: auto;
}

figcaption {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  text-align: center;
  line-height: 1.5;
}

/* Responsive: on small screens figures get tighter padding */
@media (max-width: 600px) {
  figure { border-radius: var(--radius); }
  figcaption { font-size: 0.8rem; padding: 0.6rem 0.8rem; }
}

/* ── Key-idea callout ───────────────────────────────────────────────────── */
.key-idea {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
  font-size: 0.95rem;
  color: var(--text);
}

.key-idea strong { color: var(--accent); }

/* ── Formula block ──────────────────────────────────────────────────────── */
.formula {
  text-align: center;
  font-family: "Cambria Math", "Latin Modern Math", Georgia, serif;
  font-size: 1.1rem;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 1.5rem 0;
  overflow-x: auto;
  color: var(--text);
}

/* ── Widget card ("widget chrome") ─────────────────────────────────────── */
/*
 * Usage:
 *   <div class="widget">
 *     <div class="widget-header">
 *       <span class="widget-title">Title</span>
 *       <div class="widget-controls">  ...sliders/buttons...  </div>
 *     </div>
 *     <div class="widget-body">   ...canvas or SVG...   </div>
 *     <div class="widget-footer"> ...stats / caption...  </div>
 *   </div>
 */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 1.5rem 0;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.widget-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.widget-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.widget-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.widget-body canvas,
.widget-body svg {
  display: block;
  max-width: 100%;
  border-radius: var(--radius);
}

.widget-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

/* Stat display inside widget footer */
.widget-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.widget-stat-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(154, 156, 170, 0.6);
}

.widget-stat-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Control UI primitives ──────────────────────────────────────────────── */

/* Slider row: label + value + <input type=range> */
.ctrl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.ctrl-label {
  min-width: 4ch;
}

.ctrl-val {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  min-width: 3ch;
  text-align: right;
  color: var(--text);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  outline: none;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

/* Button variants */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
  font-family: var(--font-ui);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}

.btn.btn-primary {
  border-color: var(--accent);
  color: var(--accent);
}
.btn.btn-primary:hover {
  background: rgba(108,138,255,0.12);
}

.btn.btn-active,
.btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(108,138,255,0.12);
  color: var(--accent);
}

.btn.btn-accent2 {
  border-color: var(--accent2);
  color: var(--accent2);
}
.btn.btn-accent2:hover {
  background: rgba(176,108,255,0.12);
}

/* ── Typography utilities ───────────────────────────────────────────────── */
code, kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(255,255,255,0.06);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--accent);
}

/* ── Site footer ────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .page-header           { padding: 2.5rem 1.25rem 2rem; }
  .container             { padding: 0 1.25rem 4rem; }
  section h2             { font-size: 1.25rem; }
  .page-nav              { flex-direction: column; align-items: stretch; padding: 1rem; }
  .page-nav-link.prev    { text-align: left; }
  .widget-header         { padding: 10px 12px; }
  .widget-body           { padding: 12px; }
  .nav-brand             { font-size: 0.75rem; margin-right: 6px; }
  .nav-link              { font-size: 0.72rem; padding: 4px 7px; }
}
