/* ==========================================================================
   Sigil — marketing site
   Tokens mirror the app's Theme.swift (single source of truth for the look).
   Two-tier type: Instrument Sans for prose/chrome, IBM Plex Mono for DATA
   (frequencies, dB, hex, versions, protocol names) — never mono body copy.
   ========================================================================== */

@font-face {
  font-family: "Instrument Sans";
  src: url("../assets/fonts/instrument-sans-latin-wght.woff2") format("woff2-variations");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/ibm-plex-mono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/ibm-plex-mono-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  /* Background layers, deepest → surface (Theme.swift) */
  --bg-deep: #141418;
  --bg-mid: #1c1c24;
  --bg-surface: #26262e;
  --bg-overlay: rgba(12, 12, 16, 0.78);

  /* Accent & status */
  --accent: #4d8cff;
  --accent-dim: rgba(77, 140, 255, 0.22);
  --ok: #5bc97e;
  --warn: #e6b84d;
  --err: #ff6b6b;
  --amber: #ffb84d;

  /* Text */
  --text-1: rgba(255, 255, 255, 0.87);
  --text-2: rgba(255, 255, 255, 0.6);
  --text-3: rgba(255, 255, 255, 0.4);

  /* Lines */
  --grid: rgba(255, 255, 255, 0.08);
  --divider: rgba(255, 255, 255, 0.12);
  --hover: rgba(255, 255, 255, 0.06);

  /* Type */
  --sans: "Instrument Sans", -apple-system, "SF Pro Text", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Radii (app: 6 / 3) */
  --r: 6px;
  --r-chip: 3px;
  --r-window: 10px;

  /* Spacing rhythm */
  --space-section: clamp(72px, 12vw, 148px);
  --space-block: clamp(40px, 7vw, 88px);

  color-scheme: dark;
}

/* ------------------------------------------------------------- base */

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
}

body {
  background: var(--bg-deep);
  color: var(--text-1);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* grid/flex children may never widen the page past the viewport */
.hero__grid > *, .feature > *, .cli__grid > *, .pricing__grid > * { min-width: 0; }

img, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

.container {
  max-width: 1140px;
  margin-inline: auto;
  padding-inline: clamp(20px, 5vw, 48px);
}

/* Data values — always mono, always tabular */
.data {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.08;
  text-wrap: balance;
}
h1 { font-size: clamp(2.7rem, 6.4vw, 4.4rem); font-weight: 650; letter-spacing: -0.035em; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.45rem); margin-bottom: 14px; }

p { color: var(--text-2); }

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 18px;
}

/* ---------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 12px 22px;
  border-radius: var(--r);
  font-size: 15px;
  font-weight: 550;
  line-height: 1.25;
  letter-spacing: -0.01em;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out,
              transform 0.15s ease-out;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--accent);
  color: #0d1526;
}
.btn--primary:hover { background: #6b9eff; }

.btn--ghost {
  border: 1px solid var(--divider);
  color: var(--text-1);
}
.btn--ghost:hover { background: var(--hover); border-color: rgba(255, 255, 255, 0.2); }

.btn--small { padding: 7px 16px; font-size: 13.5px; }
.btn--wide { width: 100%; }

.btn__meta {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  opacity: 0.72;
  letter-spacing: 0;
}

/* -------------------------------------------------------------- nav */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(20, 20, 24, 0.92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--grid);
}
.nav__inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 60px;
}
.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
  margin-right: auto;
}
.nav__brand img { border-radius: 6px; }
.nav__links { display: flex; gap: 24px; }
.nav__links a {
  font-size: 14px;
  color: var(--text-2);
  transition: color 0.15s ease-out;
}
.nav__links a:hover { color: var(--text-1); }
@media (max-width: 640px) { .nav__links { display: none; } }

/* ------------------------------------------------------------- hero */

.hero {
  padding-block: clamp(64px, 10vh, 128px) var(--space-block);
  background:
    radial-gradient(90rem 40rem at 78% -10%, rgba(77, 140, 255, 0.07), transparent 60%),
    var(--bg-deep);
  overflow: hidden;
}
.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}
@media (max-width: 960px) {
  .hero__grid { grid-template-columns: 1fr; }
}

.lede {
  font-size: clamp(1.02rem, 1.4vw, 1.16rem);
  margin-top: 20px;
  max-width: 46ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}
.hero__fine {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-3);
}

/* let the window drift past the container edge on wide screens */
@media (min-width: 1240px) {
  .hero__viz { margin-right: -84px; }
}

/* --------------------------------------------------- app window mock */

.appwin {
  background: var(--bg-mid);
  border: 1px solid var(--grid);
  border-radius: var(--r-window);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 80px -24px rgba(0, 0, 0, 0.7),
    0 8px 28px -8px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  font-size: 11px;
}

.appwin__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px; /* Theme.commandBarHeight */
  padding-inline: 14px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--grid);
}
.traffic { display: inline-flex; gap: 7px; }
.traffic i {
  width: 11px; height: 11px; border-radius: 50%;
  background: #3a3a42;
}
.traffic i:nth-child(1) { background: #ff5f57; }
.traffic i:nth-child(2) { background: #febc2e; }
.traffic i:nth-child(3) { background: #28c840; }
.traffic--dim i { background: #3a3a42 !important; }

/* command bar: centered source title + small mono readout (mirrors CommandBarView) */
.appwin__title {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-1);
  white-space: nowrap;
}
.appwin__readout { font-size: 10px; font-weight: 400; color: var(--text-3); }
.appwin__spacer { flex: 1; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--r-chip);
  background: var(--bg-surface);
  border: 1px solid var(--grid);
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
}
.chip--quiet { background: transparent; }
.chip--mode { padding: 2px; gap: 0; }
.chip--mode b, .chip--mode span {
  padding: 2px 8px;
  border-radius: 2px;
  font-weight: 400;
  color: var(--text-3);
}
.chip--mode b { background: var(--accent-dim); color: var(--text-1); }
.chip--lock { color: var(--ok); border-color: rgba(91, 201, 126, 0.3); font-size: 9px; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); display: inline-block; }
.dot--ok { background: var(--ok); }

.appwin__body {
  display: grid;
  grid-template-columns: 148px 1fr;
}
@media (max-width: 560px) {
  .appwin__body { grid-template-columns: 1fr; }
  .appwin__side { display: none; }
  .chip--mode { display: none; }
}

.appwin__side {
  background: var(--bg-deep);
  border-right: 1px solid var(--grid);
  padding: 10px;
}
.side__head {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin: 10px 0 4px;
}
.side__head:first-child { margin-top: 0; }
.side__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: var(--r-chip);
  font-size: 10.5px;
  color: var(--text-2);
}
.side__row .data { color: var(--text-1); font-size: 10px; }
.side__row--on { background: var(--accent-dim); color: var(--text-1); }

.appwin__center { background: var(--bg-deep); min-width: 0; }
.appwin__spectrum { width: 100%; height: auto; }
.appwin__waterfall { width: 100%; height: auto; image-rendering: auto; }
.appwin__freqaxis {
  display: flex;
  justify-content: space-between;
  padding: 2px 10px;
  font-size: 8.5px;
  color: var(--text-3);
  border-block: 1px solid var(--grid);
  background: var(--bg-mid);
}

.appwin__dock { border-top: 1px solid var(--grid); background: var(--bg-mid); }
.dock__tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px 0;
}
.dock__tab {
  padding: 4px 10px 6px;
  font-size: 10.5px;
  color: var(--text-3);
  border-radius: var(--r-chip) var(--r-chip) 0 0;
}
.dock__tab--on {
  color: var(--text-1);
  background: var(--bg-surface);
  box-shadow: 0 1px 0 var(--bg-surface);
}
.dock__tabs .chip { margin-bottom: 4px; }

.dock__table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface);
  font-size: 10px;
}
.dock__table td {
  padding: 5px 10px;
  border-top: 1px solid var(--grid);
  color: var(--text-2);
  white-space: nowrap;
}
.dock__table td:first-child { color: var(--text-3); }
.dock__table td:nth-child(2) { color: var(--accent); }
.dock__table .msg {
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
  width: 60%;
}

/* --------------------------------------------- hardware / formats */

.hardware, .formats { border-block: 1px solid var(--grid); background: var(--bg-mid); }
.hardware__inner, .formats__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 24px;
  padding-block: 22px;
}
.hardware__note {
  width: 100%;
  font-size: 12px;
  color: var(--text-3);
}
.hardware__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-3);
  flex-shrink: 0;
}
.hardware__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  font-size: 13px;
  color: var(--text-1);
}
.hardware__list span { color: var(--text-3); font-size: 11px; margin-left: 4px; }
@media (max-width: 640px) {
  .hardware__inner, .formats__inner { flex-direction: column; gap: 12px; }
}

/* ---------------------------------------------------------- features */

.features { padding-block: var(--space-section); }
.features > .container > h2 { margin-bottom: var(--space-block); }

.feature {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
}
.feature + .feature { margin-top: var(--space-block); }
.feature--flip .feature__copy { order: 2; }
.feature--flip .feature__viz { order: 1; }
@media (max-width: 880px) {
  .feature { grid-template-columns: 1fr; }
  .feature--flip .feature__copy { order: 1; }
  .feature--flip .feature__viz { order: 2; }
}

.feature__copy p { max-width: 52ch; }

.speclist { margin-top: 18px; display: grid; gap: 8px; }
.speclist li {
  position: relative;
  padding-left: 18px;
  font-size: 14px;
  color: var(--text-2);
}
.speclist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 8px;
  height: 1.5px;
  background: var(--accent);
}
.speclist .data { color: var(--text-1); font-size: 13px; }

.feature__viz figcaption {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-3);
}

/* mini waterfall with capture selection */
.minifall {
  position: relative;
  border: 1px solid var(--grid);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--bg-deep);
}
.minifall canvas { width: 100%; height: auto; }
/* geometry matches the deterministic burst site.js injects into the mini scene:
   burst center x=0.553, rows 60–104 of 230 → tag reads 434.45 MHz · 500 kHz · 1.7 s */
.minifall__selection {
  position: absolute;
  left: 52.8%;
  top: 26%;
  width: 5%;
  height: 19%;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 2px;
}
.minifall__tag {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--text-1);
  background: var(--bg-overlay);
  padding: 3px 7px;
  border-radius: var(--r-chip);
  white-space: nowrap;
}

/* analysis panels */
.panelpair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panelpair > * { min-width: 0; }
@media (max-width: 480px) { .panelpair { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-mid);
  border: 1px solid var(--grid);
  border-radius: var(--r);
  padding: 10px;
}
.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 8px;
}
.panel canvas { width: 100%; height: auto; border-radius: var(--r-chip); }

/* bit workbench */
.bitgrid {
  display: grid;
  grid-template-columns: repeat(32, 1fr);
  gap: 1px 0;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-3);
  background: var(--bg-deep);
  border-radius: var(--r-chip);
  padding: 8px 10px;
  user-select: none;
}
.bitgrid b { font-weight: 400; color: var(--text-2); text-align: center; }
.bitgrid b.on {
  color: #cfe0ff;
  background: var(--accent-dim);
}
.bitgrid b.on--first { border-radius: 3px 0 0 3px; }
.bitgrid b.on--last { border-radius: 0 3px 3px 0; }

.bitfields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip--field b { font-weight: 500; color: var(--text-1); margin-left: 4px; }
.chip--field-on { border-color: rgba(77, 140, 255, 0.45); color: var(--accent); }
.chip--field-on b { color: #cfe0ff; }
.chip--ok { color: var(--ok); border-color: rgba(91, 201, 126, 0.3); }

/* ---------------------------------------------------------- decoders */

.decoders {
  padding-block: var(--space-section);
  background: var(--bg-mid);
  border-block: 1px solid var(--grid);
}
.decoders__head { max-width: 56ch; margin-bottom: 40px; }
.decoders__head p { margin-top: 14px; }

.tablewrap { overflow-x: auto; }
.dtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 560px;
}
.dtable th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--divider);
}
.dtable td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--grid);
  color: var(--text-2);
}
.dtable td:first-child {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.dtable td:last-child { color: var(--text-1); }
.dtable tbody tr { transition: background-color 0.12s ease-out; }
.dtable tbody tr:hover { background: var(--hover); }

.decoders__foot {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-3);
}
.decoders__foot span { color: var(--amber); }

/* --------------------------------------------------------------- cli */

.cli { padding-block: var(--space-section); }
.cli__grid {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
}
@media (max-width: 880px) { .cli__grid { grid-template-columns: 1fr; } }
.cli__copy p { margin-top: 14px; max-width: 44ch; }

.terminal {
  background: var(--bg-deep);
  border: 1px solid var(--grid);
  border-radius: var(--r-window);
  box-shadow: 0 16px 48px -16px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.terminal__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--grid);
  font-size: 10.5px;
  color: var(--text-3);
}
.terminal pre {
  padding: 18px;
  font-size: 12.5px;
  line-height: 1.85;
  overflow-x: auto;
  color: var(--text-1);
}
.t-p { color: var(--text-3); }
.t-f { color: var(--accent); }
.t-s { color: var(--warn); }
.t-c { color: var(--ok); }

/* ------------------------------------------------------------ pricing */

.pricing {
  padding-block: var(--space-section);
  background:
    radial-gradient(70rem 30rem at 50% 120%, rgba(77, 140, 255, 0.06), transparent 60%),
    var(--bg-mid);
  border-top: 1px solid var(--grid);
}
.pricing h2 { margin-bottom: 40px; }
.pricing__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 880px;
}
@media (max-width: 760px) { .pricing__grid { grid-template-columns: 1fr; } }

.pricecard {
  background: var(--bg-surface);
  border: 1px solid var(--grid);
  border-radius: var(--r-window);
  padding: clamp(22px, 3.5vw, 34px);
  display: flex;
  flex-direction: column;
}
.pricecard--buy { border-color: rgba(77, 140, 255, 0.35); }
.pricecard__label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}
.pricecard__price {
  font-size: clamp(2rem, 4vw, 2.6rem);
  font-weight: 500;
  color: var(--text-1);
  margin: 10px 0 4px;
}
.pricecard__price span {
  font-size: 13px;
  color: var(--text-3);
  margin-left: 8px;
  font-weight: 400;
}
.pricecard .speclist { margin-block: 14px 26px; flex: 1; }
.pricecard__fine {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

/* ------------------------------------------------------------- footer */

.footer { border-top: 1px solid var(--grid); padding-block: 40px; }
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 32px;
}
.footer__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
}
.footer__brand img { border-radius: 5px; }
.footer__tag { color: var(--text-3); font-weight: 400; font-size: 13px; }
.footer__links { display: flex; gap: 20px; font-size: 13.5px; }
.footer__links a { color: var(--text-2); }
.footer__links a:hover { color: var(--text-1); }
.footer__legal {
  width: 100%;
  font-size: 12px;
  color: var(--text-3);
}
.footer__legal .data { font-size: 11px; }

/* -------------------------------------------------------- reveal motion
   Calm: opacity + small translate, ease-out only. JS adds .is-in via
   IntersectionObserver; without JS everything stays visible. */

@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(14px);
  }
  .js .reveal.is-in {
    opacity: 1;
    transform: none;
    transition:
      opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--d, 0s),
      transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) var(--d, 0s);
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-chip);
}

::selection { background: var(--accent-dim); }
