/* ── Design tokens — antennas theme ── */
:root {
  --bg: #0c0d0f;
  --panel: #111214;
  --panel2: #15171a;
  --text: #f5f6f7;
  --dim: #9aa3b2;
  --muted: #6b7280;
  --border: #2a2a2a;
  --line: #1e1e1e;
  --accent: #7dd3fc;
  --accent2: #bae6fd;
  --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;
  --lab-bg: #0a1018;
}

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.3rem;
  border: 2px 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: 2px 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: 800;
  color: var(--accent); white-space: nowrap;
}

/* ── Intro ── */
.intro { margin-bottom: 1.5rem; }
.intro-title {
  font-size: 1.6rem; font-weight: 800; 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: 2px solid var(--border);
  border-radius: 0.35rem; 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 / Radiation Pattern Lab ── */
.hero-card {
  text-align: center;
  padding: 1.5rem 1.5rem;
}
.hero-label {
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 1rem;
}

.pattern-lab {
  display: flex; flex-direction: column; gap: 1rem;
}
.pattern-canvas {
  width: 100%; height: 400px;
  background: var(--lab-bg);
  border: 2px solid var(--border);
  border-radius: 0.3rem;
  display: block;
}
.pattern-readouts {
  display: flex; justify-content: center; gap: 1.5rem;
  flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.82rem;
}
.readout { color: var(--accent); font-weight: 600; }
.readout-gain { color: var(--accent); }
.readout-beamwidth { color: var(--accent2); }
.readout-ftb { color: var(--dim); }

.pattern-controls {
  display: flex; flex-direction: column; gap: 1rem;
  align-items: center;
}
.pattern-palette {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
  justify-content: center;
}
.pattern-btn {
  font-size: 0.78rem; font-weight: 600;
  padding: 0.3rem 0.75rem; border-radius: 0.2rem;
  background: var(--panel); border: 2px solid var(--border);
  color: var(--dim); cursor: pointer;
  font-family: var(--sans);
  transition: color 0.15s, border-color 0.15s;
}
.pattern-btn:hover { color: var(--text); border-color: var(--accent); }
.pattern-btn.active {
  color: var(--accent); border-color: var(--accent);
  background: rgba(125, 211, 252, 0.08);
}

.pattern-toggles {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  justify-content: center;
}
.toggle-label {
  font-size: 0.78rem; font-weight: 600; color: var(--dim);
  display: flex; align-items: center; gap: 0.35rem;
  cursor: pointer;
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── 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: 2px 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(125, 211, 252, 0.08);
}

.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: 2px solid var(--border);
  border-radius: 0.3rem; padding: 1rem;
  cursor: pointer; transition: border-color 0.25s;
  display: flex; flex-direction: column; gap: 0.5rem;
  min-height: 120px;
}
.artifact-card:hover { border-color: var(--accent); }
.artifact-card:active { background: rgba(125, 211, 252, 0.04); }

.artifact-title {
  font-size: 0.95rem; font-weight: 650; color: var(--text);
  margin: 0 0 0.15rem;
}
.artifact-year {
  font-size: 0.75rem; font-weight: 600; color: var(--muted);
  font-family: var(--mono);
}
.artifact-desc {
  font-size: 0.8rem; color: var(--dim); line-height: 1.5;
  margin: 0; flex: 1;
}
.artifact-funfact {
  font-size: 0.75rem; color: var(--muted); line-height: 1.45;
  margin: 0; padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}
.artifact-meta {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Timeline ── */
.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: 2px solid var(--border);
  border-radius: 0.3rem; 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: 800; 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(125, 211, 252, 0.06), rgba(125, 211, 252, 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.3rem;
  background: var(--panel2); border: 2px 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(125, 211, 252, 0.08);
}
.tab-panel[hidden] { display: none; }

/* ── Wavelength Calculator ── */
.wavelength-layout {
  display: flex; flex-direction: column; gap: 1rem;
}
.wavelength-inputs {
  display: flex; flex-direction: column; gap: 1rem;
}
.band-chips {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.band-chip {
  font-size: 0.75rem; font-weight: 600;
  padding: 0.25rem 0.7rem; border-radius: 999px;
  background: var(--panel2); border: 2px solid var(--border);
  color: var(--dim); cursor: pointer;
  font-family: var(--sans);
  transition: color 0.15s, border-color 0.15s;
}
.band-chip:hover { color: var(--text); border-color: var(--accent); }
.band-chip.active {
  color: var(--accent); border-color: var(--accent);
  background: rgba(125, 211, 252, 0.08);
}
.wavelength-results {
  display: grid; grid-template-columns: 1fr;
  gap: 0.35rem;
}
.wavelength-row {
  display: grid; grid-template-columns: 180px 1fr;
  align-items: center; gap: 0.5rem;
  font-size: 0.82rem; padding: 0.5rem 0.7rem;
  background: var(--panel2); border-radius: 0.25rem;
}
.wavelength-label {
  font-weight: 600; color: var(--dim);
}
.wavelength-value {
  font-family: var(--mono); color: var(--accent);
}
.wavelength-note {
  font-size: 0.75rem; color: var(--muted); line-height: 1.5;
  padding: 0.5rem 0.7rem; border-left: 3px solid var(--accent);
  background: var(--panel2); border-radius: 0 0.2rem 0.2rem 0;
  margin-top: 0.35rem;
}

/* ── Friis Link Budget ── */
.friis-layout {
  display: flex; flex-direction: column; gap: 1rem;
}
.friis-inputs {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.friis-results {
  display: grid; grid-template-columns: 1fr;
  gap: 0.35rem;
}
.friis-row {
  display: grid; grid-template-columns: 200px 1fr;
  align-items: center; gap: 0.5rem;
  font-size: 0.82rem; padding: 0.4rem 0.6rem;
  background: var(--panel2); border-radius: 0.25rem;
}
.friis-label {
  font-weight: 600; color: var(--dim);
}
.friis-value {
  font-family: var(--mono); color: var(--accent);
}
.friis-verdict {
  font-size: 0.82rem; padding: 0.6rem 0.8rem;
  background: var(--panel2); border-radius: 0.3rem;
  border-left: 3px solid var(--good);
  color: var(--dim); line-height: 1.5;
  margin-top: 0.25rem;
}
.friis-verdict.warning {
  border-left-color: var(--bad);
}
.friis-verdict strong {
  color: var(--text);
}

/* ── Gain Reference ── */
.gain-layout {
  display: flex; flex-direction: column; gap: 0.75rem;
}
.gain-intro {
  font-size: 0.82rem; color: var(--dim); margin: 0 0 0.25rem;
  line-height: 1.55;
}
.gain-reference {
  display: flex; flex-direction: column; gap: 0.35rem;
}
.gain-row {
  display: grid; grid-template-columns: 170px 60px 1fr;
  align-items: center; gap: 0.6rem;
  font-size: 0.8rem; padding: 0.4rem 0.6rem;
  background: var(--panel2); border-radius: 0.25rem;
}
.gain-name {
  font-weight: 600; color: var(--text);
}
.gain-db {
  font-family: var(--mono); color: var(--accent);
  text-align: right;
}
.gain-bar-wrap {
  height: 6px; background: var(--border); border-radius: 3px;
  overflow: hidden; position: relative;
}
.gain-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  border-radius: 3px;
}

/* ── Shared controls ── */
.control-group {
  display: flex; flex-direction: column; gap: 0.25rem;
  min-width: 120px; 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;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(1rem);
  padding: 0.5rem 1.2rem; border-radius: 0.3rem;
  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 ── */
.fineprint {
  margin-top: 2rem; padding-top: 1rem;
  border-top: 2px 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; }
  .pattern-canvas { height: 300px; }
  .friis-inputs { grid-template-columns: 1fr; }
  .gain-row { grid-template-columns: 130px 50px 1fr; font-size: 0.75rem; }
}

@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .pattern-readouts { gap: 0.75rem; font-size: 0.72rem; }
  .wavelength-row { grid-template-columns: 140px 1fr; font-size: 0.75rem; }
  .friis-row { grid-template-columns: 160px 1fr; font-size: 0.75rem; }
}

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