/* ── Design tokens — identical to /cipher and /radio ── */
:root {
  --bg: #0c0d0f;
  --panel: #111214;
  --panel2: #15171a;
  --text: #f5f6f7;
  --dim: #9aa3b2;
  --muted: #6b7280;
  --border: #2a2a2a;
  --line: #1e1e1e;
  --accent: #c7d2fe;
  --accent2: #e0e7ff;
  --shadow: rgba(0, 0, 0, 0.35);
  --good: #34d399;
  --bad: #fb7185;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

html, body { min-height: 100%; }
html { scrollbar-gutter: stable both-edges; overflow-y: scroll; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.45;
  overflow-x: hidden;
}

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

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 18px 54px;
}

/* ── Skip link ── */
.skip-link {
  position: absolute; left: 12px; top: 10px;
  padding: 0.5rem 0.7rem; border-radius: 0.6rem;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  transform: translateY(-140%); transition: transform 0.15s ease; z-index: 20000;
}
.skip-link:focus { transform: translateY(0); }

/* ── Header ── */
.site-header {
  display: flex; flex-direction: column; gap: 0.65rem;
  padding-top: calc(3.2rem + env(safe-area-inset-top, 0px));
}
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9000; padding-top: env(safe-area-inset-top, 0px);
  background: rgba(12, 13, 15, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-content {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 18px; gap: 1rem;
}
.brand {
  font-family: var(--mono); font-size: 1.1rem; font-weight: 700;
  color: var(--accent); white-space: nowrap;
}

/* ── Intro ── */
.intro { margin-bottom: 1.5rem; }
.intro-title {
  font-size: 1.6rem; font-weight: 700; margin: 0 0 0.4rem;
  color: var(--text);
}
.intro-subtitle {
  font-size: 0.95rem; color: var(--dim); margin: 0;
  max-width: 640px; line-height: 1.5;
}

/* ── Sections (shared card style) ── */
.section-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 0.9rem; padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.section-heading {
  font-size: 1.15rem; font-weight: 650; margin: 0 0 0.3rem;
  color: var(--accent);
}
.section-desc {
  font-size: 0.88rem; color: var(--dim); margin: 0 0 1rem;
  line-height: 1.55;
}
.section-desc strong { color: var(--text); font-weight: 600; }

/* ── Hero Canvas (Persistence of Vision) ── */
.hero-card {
  text-align: center;
  padding: 1.5rem 1.5rem 1rem;
}
.hero-controls {
  display: flex; gap: 1.5rem; align-items: flex-end;
  justify-content: center; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.hero-controls .control-group {
  text-align: left;
}
.hero-controls label {
  font-size: 0.78rem; font-weight: 600; color: var(--dim);
  display: flex; align-items: center; gap: 0.4rem; cursor: pointer;
}
.hero-controls input[type="checkbox"] {
  accent-color: var(--accent);
}
.hero-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto 1rem;
}
.hero-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 400px;
  border-radius: 0.5rem;
  background: var(--panel2);
  border: 1px solid var(--border);
}
.hero-stats {
  display: flex; gap: 1.5rem; justify-content: center;
  margin-top: 0.5rem; flex-wrap: wrap;
}
.hero-stat {
  font-size: 0.78rem; color: var(--dim);
}
.hero-hint {
  font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem;
}

/* ── Gallery ── */
.filter-chips {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-bottom: 1rem;
}
.filter-chip {
  font-size: 0.78rem; font-weight: 600;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--dim); cursor: pointer;
  font-family: var(--sans);
  transition: color 0.15s, border-color 0.15s;
}
.filter-chip:hover { color: var(--text); border-color: var(--accent); }
.filter-chip.active {
  color: var(--accent); border-color: var(--accent);
  background: rgba(199, 210, 254, 0.08);
}
.filter-chip .chip-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 0.3rem;
  vertical-align: middle;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.gallery-empty {
  text-align: center; padding: 2rem;
  color: var(--muted); font-size: 0.88rem;
}
.gallery-empty[hidden] { display: none; }

.artifact-card {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 0.6rem; padding: 1rem;
  cursor: pointer; transition: border-color 0.25s;
  display: flex; flex-direction: column; gap: 0.5rem;
  min-height: 100px;
}
.artifact-card:hover { border-color: var(--accent); }
.artifact-card:active { background: rgba(199, 210, 254, 0.04); }

.artifact-card-header {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
}
.artifact-name {
  font-size: 0.92rem; font-weight: 650; color: var(--text);
}
.artifact-era {
  font-size: 0.75rem; font-weight: 600;
  padding: 0.1rem 0.45rem; border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.artifact-cat-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}

.artifact-desc {
  font-size: 0.8rem; line-height: 1.5; color: var(--dim);
}
.artifact-year {
  font-family: var(--mono); font-size: 0.72rem;
  color: var(--muted);
}

/* ── Timeline (identical to /cipher) ── */
.timeline-strip {
  display: flex; gap: 1rem; overflow-x: auto;
  scroll-snap-type: x mandatory; padding: 0.5rem 0 1rem;
  -webkit-overflow-scrolling: touch;
}
.timeline-strip::-webkit-scrollbar { height: 6px; }
.timeline-strip::-webkit-scrollbar-track { background: var(--panel2); border-radius: 3px; }
.timeline-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.timeline-card {
  flex: 0 0 260px; scroll-snap-align: start;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 0.6rem; padding: 1rem 1.1rem;
  transition: border-color 0.25s;
  cursor: pointer;
}
.timeline-card.active {
  border-color: var(--accent);
}
.timeline-year {
  font-size: 1.3rem; font-weight: 700; color: var(--accent);
  font-family: var(--mono); margin: 0 0 0.2rem;
}
.timeline-title {
  font-size: 0.92rem; font-weight: 650; color: var(--text);
  margin: 0 0 0.4rem;
}
.timeline-blurb {
  font-size: 0.8rem; color: var(--dim); line-height: 1.5;
  margin: 0;
}
.timeline-narrative {
  flex: 0 0 320px; cursor: default;
  background: linear-gradient(135deg, rgba(199, 210, 254, 0.06), rgba(199, 210, 254, 0.02));
  border-color: var(--accent); border-style: dashed;
}
.narrative-title {
  font-size: 0.85rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 0.5rem;
}
.narrative-text {
  font-size: 0.78rem; color: var(--dim); line-height: 1.6; margin: 0;
  font-style: italic;
}

/* ── Playground ── */
.playground-tabs {
  display: flex; gap: 0.4rem; margin-bottom: 1rem;
  flex-wrap: wrap;
}
.tab-btn {
  font-size: 0.78rem; font-weight: 600;
  padding: 0.4rem 0.85rem; border-radius: 0.5rem;
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--dim); cursor: pointer;
  font-family: var(--sans);
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text); border-color: var(--accent); }
.tab-btn.active {
  color: var(--accent); border-color: var(--accent);
  background: rgba(199, 210, 254, 0.08);
}
.tab-panel[hidden] { display: none; }

.text-input, .text-area {
  width: 100%; box-sizing: border-box;
  padding: 0.5rem 0.7rem; border-radius: 0.5rem;
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: 0.88rem;
  outline: none; transition: border-color 0.15s;
}
.text-input:focus, .text-area:focus { border-color: var(--accent); }
.text-input::placeholder, .text-area::placeholder { color: var(--muted); }
.text-area { resize: vertical; min-height: 80px; }

select.text-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa3b2' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.control-group {
  display: flex; flex-direction: column; gap: 0.25rem;
  min-width: 140px; flex: 1;
}
.control-group label {
  font-size: 0.78rem; font-weight: 600; color: var(--dim);
  margin: 0; padding: 0;
}
.control-value {
  font-size: 0.78rem; color: var(--accent); font-family: var(--mono);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--border); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel);
  cursor: pointer;
}

/* ── Bitrate Calculator ── */
.bitrate-controls {
  display: flex; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.bitrate-results {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 0.5rem; padding: 1rem 1.2rem;
  font-size: 0.85rem; line-height: 1.8;
}
.bitrate-results .result-label {
  color: var(--dim); font-weight: 600; font-size: 0.78rem;
}
.bitrate-results .result-value {
  color: var(--accent); font-family: var(--mono); font-weight: 600;
}
.bitrate-results .result-row {
  display: flex; justify-content: space-between;
  align-items: baseline; gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0;
}
.bitrate-results .result-row:last-child { border-bottom: none; }
.bitrate-results .result-section {
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-top: 0.75rem; margin-bottom: 0.25rem;
}
.bitrate-results .result-section:first-child { margin-top: 0; }

/* ── Codec Comparison ── */
.codec-table-wrap {
  overflow-x: auto; margin: 0 -0.5rem;
  padding: 0 0.5rem;
}
.codec-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.82rem;
}
.codec-table th {
  text-align: left; padding: 0.5rem 0.75rem;
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.codec-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--dim); vertical-align: top;
}
.codec-table tr:hover td {
  background: rgba(199, 210, 254, 0.03);
}
.codec-table .codec-name {
  color: var(--text); font-weight: 650;
  font-family: var(--mono);
}
.codec-table .royalty-free { color: var(--good); font-weight: 600; }
.codec-table .royalty-paid { color: var(--bad); font-weight: 600; }

/* ── Aspect Ratio Explorer ── */
.aspect-controls {
  display: flex; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.aspect-preview-wrap {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}
.aspect-preview-wrap canvas {
  display: block;
  width: 100%;
  height: 340px;
  border-radius: 0.5rem;
  background: var(--panel2);
  border: 1px solid var(--border);
}
.aspect-info {
  margin-top: 0.75rem;
  font-size: 0.82rem; line-height: 1.7; color: var(--dim);
}
.aspect-info .aspect-label {
  color: var(--muted); font-weight: 600; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.aspect-info .aspect-value {
  color: var(--accent); font-family: var(--mono); font-weight: 600;
}

/* ── Buttons (matching cipher/radio) ── */
.btn {
  background: var(--panel2); border: 1px solid var(--border);
  color: var(--dim); border-radius: 0.5rem;
  padding: 0.45rem 1rem; font-size: 0.82rem; cursor: pointer;
  font-family: var(--sans); transition: color 0.15s, border-color 0.15s;
}
.btn:hover { color: var(--text); border-color: var(--accent); }
.btn-sm {
  font-size: 0.78rem; padding: 0.3rem 0.75rem;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--dim); border-radius: 0.4rem; cursor: pointer;
  font-family: var(--sans);
}
.btn-sm:hover { color: var(--text); border-color: var(--accent); }

.dim { color: var(--dim); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(1rem);
  padding: 0.5rem 1.2rem; border-radius: 0.5rem;
  background: var(--accent); color: #0c0d0f;
  font-size: 0.82rem; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10000;
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Footer (identical to /cipher) ── */
.fineprint {
  margin-top: 2rem; padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem; color: var(--muted);
  text-align: center;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .wrap { padding: 14px 14px 40px; }
  .topbar-content { padding: 0.55rem 14px; }
  .intro-title { font-size: 1.3rem; }
  .section-card { padding: 1rem 1.1rem; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .timeline-card { flex: 0 0 220px; }
  .bitrate-controls { flex-direction: column; }
  .aspect-controls { flex-direction: column; }
  .hero-canvas-wrap canvas { height: 320px; }
  .aspect-preview-wrap canvas { height: 280px; }
}

@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .hero-canvas-wrap canvas { height: 260px; }
  .aspect-preview-wrap canvas { height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
