/* Landing page sections. Mobile-first; layout widens at 720px / 960px / 1280px. */

/* ---------- Hero ---------- */

.hero {
  position: relative;
  padding-block: clamp(2.5rem, 1rem + 6vw, 6rem) var(--space-section);
  overflow: hidden;
}

/* Faint engineering grid behind the hero, fading toward the bottom. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(var(--color-surface) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, var(--color-surface) 1px, transparent 1px) 0 0 / 56px 56px;
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 95%);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 95%);
}

.hero__grid {
  display: grid;
  gap: var(--space-2xl);
  align-items: center;
}

.hero-content {
  display: grid;
  gap: var(--space-lg);
  justify-items: start;
}

.hero-badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px var(--space-sm);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-soft);
}

.hero-badge .icon {
  color: var(--color-primary);
}

.hero h1 {
  max-width: 13ch;
  font-size: var(--text-hero);
  font-weight: 800;
}

.hero-lede {
  max-width: 34rem;
  font-size: var(--text-md);
  color: var(--color-muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.hero-account {
  margin-top: var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-text-soft);
}

.hero-account a {
  color: var(--color-primary);
}

.hero-specs {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: var(--space-lg);
  margin-top: var(--space-md);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.hero-specs dt {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-faint);
}

.hero-specs dd {
  font-weight: 600;
  font-stretch: var(--stretch-display);
}

.hero-product-preview {
  display: flex;
  justify-content: center;
}

.hero-device {
  display: grid;
  justify-items: center;
  gap: var(--space-md);
  width: 100%;
}

.hero-device .phone-frame {
  width: min(100%, 300px);
}

.hero-device__caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--color-faint);
  text-align: center;
}

@media (min-width: 760px) {
  .hero__grid {
    grid-template-columns: 1.15fr 0.85fr;
  }

  .hero-device .phone-frame {
    width: min(100%, 330px);
  }
}

/* ---------- App preview ---------- */

.preview-rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(78%, 280px);
  gap: var(--space-lg);
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
  padding-bottom: var(--space-sm);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: thin;
}

.preview-rail__item {
  display: grid;
  gap: var(--space-sm);
  align-content: start;
  scroll-snap-align: start;
}

.preview-rail__item .phone-frame {
  width: min(100%, 260px);
  margin-bottom: var(--space-sm);
}

.preview-rail__item h3 {
  font-size: var(--text-md);
}

.preview-rail__item p {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (min-width: 900px) {
  .preview-rail {
    grid-auto-flow: row;
    grid-template-columns: repeat(4, 1fr);
    row-gap: var(--space-2xl);
    margin-inline: 0;
    padding-inline: 0;
    overflow: visible;
  }
}

/* ---------- Live telemetry ---------- */

.telemetry__grid,
.diagnostics__grid,
.reports__grid,
.export__grid,
.local-first__grid {
  display: grid;
  gap: var(--space-2xl);
  align-items: center;
}

/* Let grid children shrink below their content width (e.g. the scrollable CSV table). */
.hero__grid > *,
.telemetry__grid > *,
.diagnostics__grid > *,
.reports__grid > *,
.export__grid > *,
.local-first__grid > *,
.tuner__grid > *,
.faq-layout > * {
  min-width: 0;
}

.telemetry__grid .section-header,
.diagnostics__grid .section-header,
.reports__grid .section-header,
.export__grid .section-header,
.local-first__grid .section-header {
  margin-bottom: 0;
}

.telemetry__grid .feature-list,
.diagnostics__grid .feature-list,
.reports__grid .feature-list,
.local-first__grid .feature-list {
  margin-top: var(--space-md);
}

.telemetry__tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xs);
  padding: var(--space-xs);
}

.telemetry-tile--wide {
  grid-column: 1 / -1;
}

.telemetry-tile--wide .telemetry-tile__value {
  font-size: var(--text-telemetry);
}

@media (min-width: 960px) {
  .telemetry__grid,
  .diagnostics__grid,
  .export__grid {
    grid-template-columns: 0.9fr 1.1fr;
  }

  .reports__grid,
  .local-first__grid {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .telemetry__tiles {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Tuner log ---------- */

.tuner__grid {
  display: grid;
  gap: var(--space-xl);
}

.tuner__grid .section-header {
  margin-bottom: 0;
}

.steps {
  display: grid;
  gap: 1px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-border);
  overflow: hidden;
  counter-reset: step;
}

.step {
  display: grid;
  gap: var(--space-xs);
  align-content: start;
  padding: var(--space-lg);
  background: var(--color-surface);
}

.step__index {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  color: var(--color-primary);
}

.step h3 {
  font-size: var(--text-md);
}

.step p {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.tuner__channels {
  display: grid;
  gap: var(--space-sm);
}

.tuner__channels-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.chip__swatch--rpm { --swatch: var(--chart-rpm); }
.chip__swatch--boost { --swatch: var(--chart-boost); }
.chip__swatch--boost-target { --swatch: var(--chart-boost-target); }
.chip__swatch--lambda { --swatch: var(--chart-lambda); }
.chip__swatch--hpfp { --swatch: var(--chart-hpfp); }
.chip__swatch--timing { --swatch: var(--chart-timing); }

@media (min-width: 720px) {
  .steps {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  .steps {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ---------- Tuner log chart ---------- */

.log-chart {
  padding-top: 0;
}

.log-chart__title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  font-stretch: 100%;
  letter-spacing: 0.12em;
  line-height: inherit;
  text-transform: uppercase;
}

.log-chart__toggles {
  margin-bottom: var(--space-md);
}

.log-chart__canvas {
  position: relative;
  height: clamp(280px, 40vw, 440px);
}

.log-chart__canvas canvas {
  position: absolute;
  inset: 0;
}

.log-chart__fallback {
  display: grid;
  place-items: center;
  height: 100%;
  padding: var(--space-lg);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.log-chart__fallback[hidden] {
  display: none;
}

.log-chart__note {
  margin-top: var(--space-md);
  color: var(--color-faint);
  font-size: var(--text-xs);
}

/* ---------- TCU diagram ---------- */

.tcu__grid .section-header {
  margin-bottom: var(--space-xl);
}

.tcu-diagram {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
  align-items: stretch;
}

.tcu-source {
  position: relative;
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.tcu-source__tag {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  padding: 2px var(--space-xs);
  border: 1px solid var(--color-primary-line);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--color-primary);
}

.tcu-source h3 {
  margin-bottom: var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.tcu-source ul {
  display: grid;
  gap: var(--space-2xs);
  font-size: var(--text-lg);
  font-weight: 600;
  font-stretch: var(--stretch-display);
}

.tcu-plus {
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  color: var(--color-faint);
}

.tcu-timeline {
  margin-top: var(--space-sm);
  border: 1px solid var(--color-primary-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  overflow: hidden;
}

.tcu-timeline__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.tcu-timeline__plot {
  width: 100%;
  height: clamp(140px, 22vw, 200px);
}

.tcu-grid line {
  stroke: var(--color-border);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.tcu-trace {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.tcu-trace--rpm { stroke: var(--chart-rpm); }
.tcu-trace--boost { stroke: var(--chart-boost); }
.tcu-trace--gear { stroke: var(--chart-hpfp); }

.tcu-marker {
  stroke: var(--color-faint);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

/* Chart-line reveal: the plot wipes in left-to-right when the diagram scrolls into view. */
.reveal-ready .tcu-timeline__plot {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 1.6s var(--ease-out) 0.25s;
}

.reveal-ready .is-visible .tcu-timeline__plot {
  clip-path: inset(0 0 0 0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal-ready .tcu-timeline__plot {
    clip-path: none;
  }
}

.tcu-timeline__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.tcu-key {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.tcu-key::before {
  content: "";
  width: 14px;
  height: 2px;
  background: var(--key, var(--color-faint));
}

.tcu-key--rpm { --key: var(--chart-rpm); }
.tcu-key--boost { --key: var(--chart-boost); }
.tcu-key--gear { --key: var(--chart-hpfp); }

.tcu-key--marker::before {
  background: repeating-linear-gradient(90deg, var(--color-faint) 0 3px, transparent 3px 6px);
}

@media (min-width: 720px) {
  .tcu-diagram {
    grid-template-columns: 1fr auto 1fr;
  }

  .tcu-timeline {
    grid-column: 1 / -1;
  }
}

/* ---------- Diagnostics + reports ---------- */

.fault-card__meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.fault-card__meta dt {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-faint);
}

.fault-card__meta dd {
  font-size: var(--text-sm);
  color: var(--color-text-soft);
}

.reports {
  padding-top: 0;
}

@media (max-width: 959px) {
  .reports__grid .fault-card {
    order: 2;
  }
}

/* ---------- Export ---------- */

.export .panel__header span:first-child {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ---------- Local-first ---------- */

.local-first__art {
  display: flex;
  justify-content: center;
}

.local-first__art img {
  width: min(100%, 420px);
}

@media (max-width: 959px) {
  .local-first__art {
    order: 2;
  }
}

/* ---------- Compatibility steps ---------- */

.connect-steps {
  display: grid;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.connect-step {
  display: grid;
  gap: var(--space-xs);
  align-content: start;
  padding: var(--space-md) var(--space-md) var(--space-lg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.connect-step img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--color-background);
}

.connect-step h3 {
  font-size: var(--text-md);
}

.connect-step p {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

@media (min-width: 720px) {
  .connect-steps {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- FAQ ---------- */

.faq-layout {
  display: grid;
  gap: var(--space-xl);
}

.faq-layout .section-header {
  margin-bottom: 0;
}

@media (min-width: 960px) {
  .faq-layout {
    grid-template-columns: 0.8fr 1.2fr;
    align-items: start;
  }

  .faq-layout .section-header {
    position: sticky;
    top: calc(var(--header-height) + var(--space-xl));
  }
}

/* ---------- Final CTA ---------- */

.final-cta {
  border-top: 1px solid var(--color-border);
  background:
    linear-gradient(var(--color-surface) 1px, transparent 1px) 0 0 / 56px 56px,
    var(--color-background);
}

.final-cta__inner {
  display: grid;
  justify-items: center;
  gap: var(--space-lg);
  text-align: center;
}

.final-cta__logo {
  width: 88px;
}

.final-cta h2 {
  max-width: 18ch;
  font-size: var(--text-2xl);
}

.final-cta p {
  color: var(--color-muted);
  font-size: var(--text-md);
}

.final-cta .hero-actions {
  justify-content: center;
}

/* ---------- Showcase (section copy + two real app screenshots) ---------- */

.showcase__grid {
  display: grid;
  gap: var(--space-2xl);
  align-items: center;
}

.showcase__grid > * {
  min-width: 0;
}

.showcase__grid .section-header {
  margin-bottom: 0;
}

.showcase__grid .feature-list {
  margin-top: var(--space-md);
}

.shot-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
  max-width: 560px;
  margin: 0;
  justify-self: center;
}

.shot-pair figure {
  display: grid;
  gap: var(--space-sm);
  justify-items: center;
}

.shot-pair .phone-frame {
  width: 100%;
}

.shot-single {
  display: grid;
  gap: var(--space-sm);
  justify-items: center;
  width: min(100%, 280px);
  margin: 0;
  justify-self: center;
}

.shot-single .phone-frame {
  width: 100%;
}

.shot-pair figcaption,
.shot-single figcaption {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
}

.screens-note {
  margin-top: var(--space-lg);
  color: var(--color-muted);
  font-size: var(--text-sm);
  text-align: center;
}

@media (min-width: 960px) {
  .showcase__grid {
    grid-template-columns: 1fr 1fr;
  }

  .showcase--reverse .showcase__grid > .section-header {
    order: 2;
  }
}

/* ---------- Tablet screenshot + small notes ---------- */

.tablet-shot {
  display: grid;
  gap: var(--space-sm);
  justify-items: center;
  margin: var(--space-2xl) 0 0;
}

.tablet-frame {
  width: min(100%, 600px);
  aspect-ratio: 1100 / 1418;
  padding: 10px;
  overflow: hidden;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.tablet-frame .app-screenshot {
  border-radius: calc(var(--radius-lg) - 10px);
}

.tablet-shot figcaption {
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tuner__note {
  max-width: 46rem;
  margin-top: var(--space-md);
  color: var(--color-muted);
  font-size: var(--text-sm);
}
