/* ==========================================================================
   Bass Daddy Devices — site.css
   Layout and page-level composition. Loads AFTER bass-daddy.css.

   Rules for this file:
   - It may only compose. It never redefines a token or a .bdd-* component.
   - Every value comes from a var(--…). No raw hex, no magic pixel sizes
     outside the 4px space scale.
   - bass-daddy.css ships no layout primitives (.row and .grid don't exist),
     so the shared ones live here.
   ========================================================================== */

/* ---------- Shared layout ---------- */
:root {
  --measure: 68ch;
  --page-max: 1200px;
}

body {
  /* Stops the hero's pulse ring from widening the page on small screens. */
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(var(--space-4) * -4);
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  background: var(--pink);
  color: var(--on-pink);
  text-decoration: none;
  transition: top var(--dur-16th) var(--ease-out);
}
.skip-link:focus {
  top: var(--space-4);
  color: var(--on-pink);
}

.section {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--space-24) var(--space-4);
  box-sizing: border-box;
}

.section__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-12);
}
.section__title {
  margin: 0;
}
.section__lede {
  margin: 0;
  max-width: var(--measure);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  box-sizing: border-box;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-4); /* the mark's required clear space */
  text-decoration: none;
  color: var(--ink);
}
.site-header__brand:hover {
  color: var(--ink);
}

.site-header__nav {
  display: flex;
  gap: var(--space-6);
  margin-left: auto;
}
.site-header__link {
  color: var(--ink-muted);
  text-decoration: none;
  padding-block: var(--space-2);
  border-bottom: 2px solid transparent;
  transition:
    color var(--dur-16th) var(--ease-out),
    border-color var(--dur-16th) var(--ease-out);
}
.site-header__link:hover {
  color: var(--ink);
  border-bottom-color: var(--pink);
}

/* ---------- Logo pair ---------- */
.bdd-logo-pair {
  display: block;
  flex: none;
}
.bdd-logo-pair .bdd-logo {
  width: auto;
  height: var(--logo-h);
}

/* ---------- Hero ---------- */
.home-hero {
  max-width: var(--page-max);
  margin-inline: auto;
  /* Fill the viewport minus the sticky header rather than overflowing past it. */
  min-height: calc(100svh - 76px);
  padding-top: var(--space-16);
}

.home-hero__logo {
  /* The pulse ring is drawn from the wrap, so the wrap must match the mark.
     Width-driven here (the header is height-driven) so it can shrink. */
  width: 132px;
  margin-bottom: var(--space-6);
}
.home-hero__logo .bdd-logo {
  width: 100%;
  height: auto;
}

.home-hero__title {
  margin: 0;
}

.home-hero__lede {
  margin: 0;
  max-width: var(--measure);
}

.home-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: center;
}

/* ---------- Stat band ---------- */
.stat-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--space-12) var(--space-4);
  box-sizing: border-box;
  border-block: 1px solid var(--line);
}

.stat-band__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-16);
  margin: 0;
}

.stat-band__item {
  display: flex;
  flex-direction: column-reverse; /* number above its label */
  gap: var(--space-2);
}

.stat-band__value {
  margin: 0;
  color: var(--pink-ink);
  font-variant-numeric: tabular-nums;
}

/* The scrubbed meter is driven by GSAP, so the looping CSS keyframe is off.
   Sized up from the 32px default so it reads as a deliberate level meter
   rather than a stray mark at the edge of the band. */
.stat-band__meter {
  height: 56px;
}
.stat-band__meter > i {
  width: 8px;
  animation: none;
}

/* ---------- Filter chips ---------- */
/* .bdd-card sets display:flex, which outranks the UA rule for [hidden]. */
[hidden] {
  display: none !important;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: transparent;
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-none);
  cursor: pointer;
  transition:
    color var(--dur-16th) var(--ease-out),
    border-color var(--dur-16th) var(--ease-out),
    background var(--dur-16th) var(--ease-out),
    transform var(--dur-16th) var(--ease-thump),
    box-shadow var(--dur-16th) var(--ease-thump);
}

.chip:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.chip.is-active {
  background: var(--pink);
  border-color: var(--pink);
  color: var(--on-pink);
  box-shadow: var(--shadow-hit-cyan);
  transform: translate(-2px, -2px);
}

.chip:active:not(.is-disabled) {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-none);
  transition-duration: 40ms;
}

/* Adding this chip to the current selection would empty the grid. Still
   focusable and still announced — just not worth clicking. The border carries
   the state so the label keeps its 4.5:1 contrast. */
.chip[aria-disabled='true'] {
  border-style: dashed;
  border-color: var(--line);
  cursor: not-allowed;
}
.chip[aria-disabled='true']:hover {
  color: var(--ink-muted);
  border-color: var(--line);
}

/* The count rides along in the button label. Set apart by weight only — an
   opacity knock-back here drops it under 4.5:1 against both surfaces. */
.chip__count {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.chips__status {
  margin: var(--space-4) 0 0;
}

/* ---------- Device grid ---------- */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
  align-items: stretch;
}

.device-card {
  /* The hover lift needs room so it isn't clipped by the grid gap. */
  height: 100%;
  box-sizing: border-box;
}

.device-card__spec {
  margin: 0;
}

/* Neither half of the footer may wrap, or the row heights go ragged. */
.device-card__price {
  font-size: 14px;
  white-space: nowrap;
}

.device-card__cta {
  white-space: nowrap;
  flex: none;
}

/* ---------- Shelf (horizontal device carousel) ----------
   A real scroll container, so it works before JS and without a pointer.
   GSAP only adds drag momentum on top. */
.shelf {
  position: relative;
}

.shelf__track {
  display: flex;
  gap: var(--space-6);
  margin: 0;
  padding: 0 0 var(--space-4);
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  /* Room for the card's hover lift and hard shadow, which sit outside its box. */
  padding-top: var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.shelf__track::-webkit-scrollbar {
  height: 8px;
}
.shelf__track::-webkit-scrollbar-thumb {
  background: var(--line-strong);
}
.shelf__track::-webkit-scrollbar-track {
  background: transparent;
}

.shelf__item {
  flex: 0 0 320px;
  max-width: 85vw;
  scroll-snap-align: start;
  display: flex;
}

/* The card fills its slot so every shelf item is the same height. */
.shelf__item > .bdd-card {
  width: 100%;
}

/* Draggable used to set these; the shelf manages its own cursor now. */
@media (hover: hover) and (pointer: fine) {
  .shelf__track {
    cursor: grab;
  }
  .shelf__track.is-dragging {
    cursor: grabbing;
    /* Stops text selecting across cards mid-drag. */
    user-select: none;
  }
}

.shelf__nav {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.shelf__arrow {
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  line-height: 1;
}

.shelf__arrow:disabled {
  border-color: var(--line);
  color: var(--ink-muted);
  cursor: not-allowed;
}

.section__more {
  margin-top: var(--space-8);
}

/* ---------- Band (the free section) ---------- */
.section--band {
  max-width: none;
  padding-inline: 0;
}

.band {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-6);
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--space-16) var(--space-8);
  box-sizing: border-box;
  background: var(--surface-raised);
  border: 1px solid var(--line);
}

.band__title {
  margin: 0;
}

.band__body {
  margin: 0;
  max-width: var(--measure);
}

/* ---------- Post / playground grid ----------
   auto-fill, not auto-fit: a teaser often holds a single card, and auto-fit
   collapses the empty tracks so that one card stretches the full width. */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

/* ---------- Blog ---------- */
.post-card {
  overflow: hidden;
}

.post-card__media {
  display: block;
  margin: calc(var(--space-6) * -1) calc(var(--space-6) * -1) 0;
}
.post-card__media img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.post-card__link {
  color: inherit;
  text-decoration: none;
}
.post-card__link:hover {
  color: var(--pink-ink);
}
/* Expand the title link to the whole card so the hit area matches the shape. */
.post-card__link::after {
  content: '';
  position: absolute;
  inset: 0;
}
.post-card {
  position: relative;
}

.post-card__date {
  margin: 0;
}

/* ---------- Single post ---------- */
.post {
  max-width: 820px;
}

.post__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.post__back {
  text-decoration: none;
}

.post__title,
.post__summary {
  margin: 0;
}

.post__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}
.post__meta p {
  margin: 0;
}

.post__hero {
  display: block;
  width: 100%;
  /* Reserve the box before the file arrives. Keystatic stores a path, not
     dimensions, so without a declared ratio the whole article jumps down the
     moment the image loads. 16:9 matches the card crop, so one upload serves
     both places and is cropped the same way in each. */
  aspect-ratio: 16 / 9;
  object-fit: cover;
  margin-bottom: var(--space-12);
  border: 1px solid var(--line);
}

/* ---------- Prose ----------
   Markdoc renders bare elements with no classes, so this maps them onto the
   brand type scale. Keep it in step with the .h2/.h3/.body-lg classes. */
.prose {
  max-width: 68ch;
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 28px;
  color: var(--ink);
}

.prose > * + * {
  margin-top: var(--space-6);
}

.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}
.prose h2 {
  font-size: 32px;
  line-height: 38px;
}
.prose h3 {
  font-size: 22px;
  line-height: 28px;
}
.prose h4 {
  font-size: 18px;
  line-height: 24px;
}

.prose a {
  color: var(--pink-ink);
}

.prose strong {
  font-weight: 700;
}

.prose ul,
.prose ol {
  padding-left: var(--space-6);
}
.prose li + li {
  margin-top: var(--space-2);
}

.prose blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: var(--space-6);
  border-left: 2px solid var(--pink);
  color: var(--ink-muted);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 2px var(--space-2);
  background: var(--surface-raised);
  border: 1px solid var(--line);
}

.prose pre {
  padding: var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  overflow-x: auto;
}
/* The <pre> already carries the frame; the inner <code> must not repeat it. */
.prose pre code {
  padding: 0;
  background: none;
  border: 0;
  font-size: 13px;
  line-height: 20px;
}

.prose img,
.prose video,
.prose iframe {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}
.prose th,
.prose td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  text-align: left;
}
.prose th {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ---------- Playground ---------- */
.playground {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-12);
  padding: var(--space-8);
  background: var(--surface-raised);
  border: 1px solid var(--line);
}

.playground__title,
.playground__note,
.playground__status {
  margin: 0;
}

.playground__rack {
  width: 100%;
  margin-top: var(--space-4);
}

/* ---------- Product embed dialog ---------- */
.embed {
  /* This codebase sets box-sizing per component rather than globally, so a
     dialog without it adds its padding and border on top of the width and
     overflows a narrow screen. */
  box-sizing: border-box;
  width: min(640px, calc(100vw - var(--space-8)));
  max-height: calc(100vh - var(--space-16));
  padding: var(--space-6);
  background: var(--surface-raised);
  color: var(--ink);
  border: 2px solid var(--pink);
  border-radius: var(--radius-none);
  overflow-y: auto;
}

.embed[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.embed::backdrop {
  background: rgb(0 0 0 / 0.75);
}

.embed__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.embed__title {
  margin: 0;
}

.embed__close {
  flex: none;
  padding: var(--space-2) var(--space-3);
  font-size: 16px;
  line-height: 1;
}

/* Gumroad replaces the div with an iframe it sizes itself; this just stops a
   collapsed frame before the first resize message arrives. */
.embed__slot {
  min-height: 160px;
}

.embed__slot iframe {
  display: block;
  width: 100%;
  border: 0;
}

.embed__fallback {
  margin: 0;
}

/* ---------- Volume warning ---------- */
.warn {
  box-sizing: border-box;
  width: min(460px, calc(100vw - var(--space-8)));
  padding: var(--space-8);
  background: var(--surface-raised);
  color: var(--ink);
  border: 2px solid var(--pink);
  border-radius: var(--radius-none);
}

/* A closed <dialog> is display:none by default; this only styles the open one. */
.warn[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.warn::backdrop {
  background: rgb(0 0 0 / 0.7);
}

.warn__title,
.warn__body,
.warn__note {
  margin: 0;
}

.warn__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

/* ---------- Playground stage ---------- */
.playground__stage {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  width: 100%;
}

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  border: 2px solid var(--pink);
}

.stepper__title,
.stepper__body {
  margin: 0;
  max-width: 60ch;
}

.stepper__nav {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.stepper__nav .bdd-btn:disabled {
  border-color: var(--line);
  color: var(--ink-muted);
  background: transparent;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

/* ---------- Oscilloscope ---------- */
.scope {
  margin: 0;
}

.scope__canvas {
  display: block;
  width: 100%;
  height: 180px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.scope__caption {
  margin-top: var(--space-2);
}

/* ---------- Keyboard bar ---------- */
.keyboard-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.keyboard-bar__hint {
  margin: 0;
}

/* ---------- Keyboard ----------
   Flat row rather than overlapping black keys: at this size an authentic
   piano layout would give fingers targets a few pixels wide. */
.keyboard {
  display: flex;
  gap: 2px;
  width: 100%;
  overflow-x: auto;
}

.key {
  flex: 1 1 0;
  min-width: 34px;
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: var(--space-2);
  border: 2px solid var(--line-strong);
  border-radius: var(--radius-none);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background var(--dur-16th) var(--ease-out),
    transform var(--dur-16th) var(--ease-thump);
}

.key--white {
  background: var(--surface-raised);
  color: var(--ink);
}

.key--black {
  background: var(--surface);
  color: var(--ink-muted);
  height: 90px;
  align-self: flex-start;
}

.key:hover {
  border-color: var(--ink);
}

.key.is-held {
  background: var(--pink);
  border-color: var(--pink);
  color: var(--on-pink);
  transform: translateY(3px);
}

.key__label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* ---------- Post navigation ---------- */
.post__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  margin-top: var(--space-16);
  padding-top: var(--space-8);
  border-top: 1px solid var(--line);
}

.post__nav-link {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1 1 260px;
  padding: var(--space-4);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform var(--dur-8th) var(--ease-thump),
    box-shadow var(--dur-8th) var(--ease-thump),
    border-color var(--dur-16th) var(--ease-out);
}
.post__nav-link:hover {
  transform: translate(-4px, -4px);
  border-color: var(--ink);
  box-shadow: var(--shadow-hit);
  color: var(--ink);
}
.post__nav-link--next {
  text-align: right;
}

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-6);
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding: var(--space-12) var(--space-4);
  box-sizing: border-box;
  border-top: 1px solid var(--line);
}

.site-footer__brand {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  margin-left: auto;
}
.site-footer__nav a {
  color: var(--ink-muted);
  text-decoration: none;
}
.site-footer__nav a:hover {
  color: var(--ink);
}

.site-footer__fine {
  flex-basis: 100%;
  margin: 0;
}

/* ---------- Narrow screens ---------- */
@media (max-width: 760px) {
  .display {
    font-size: 48px;
  }
  .h1 {
    font-size: 32px;
    line-height: 38px;
  }
  .section,
  .stat-band,
  .site-footer {
    padding-block: var(--space-16);
  }
  .band {
    padding: var(--space-12) var(--space-4);
  }
  .stat-band__list {
    gap: var(--space-8);
  }
  /* Too narrow for one row: brand takes the first, nav and theme share the
     second rather than leaving the theme button stranded on a third. */
  .site-header {
    flex-wrap: wrap;
    gap: var(--space-3);
  }
  .site-header__brand {
    flex: 1 0 100%;
    order: 1;
  }
  .site-header__nav {
    order: 2;
    margin-left: 0;
    gap: var(--space-4);
  }
  .site-header__theme {
    order: 3;
    margin-left: auto;
  }
  .home-hero__logo {
    width: 100px;
  }
}
