/**
 * wave1-pilots.css — layout for the Wave-1 reference pilots (B1 bpmandkey, B2 songchop, B5 albumn).
 * Loads AFTER tier1-hardware-skins.css and uses only its tokens: no new colours, fonts or radii.
 *
 *   <link rel="stylesheet" href=".../tier1-hardware-skins.css">
 *   <link rel="stylesheet" href=".../wave1-pilots.css">
 *
 * Contract notes
 *   - Every readout chip, waveform stage and photo stage has its size reserved before the first
 *     paint (fixed `aspect-ratio`, `min-width` in `ch`), so results appearing cause no layout shift.
 *   - skin-te-field: orange is the LED only. Accent and pressed-pad colours are remapped to ink here.
 *   - `.ph-primary` is 48px tall on mobile (`mobile-compact` and under 768px) and full width.
 *   - Motion: none. Nothing here animates, so `prefers-reduced-motion` needs no override.
 */

/* ---- chassis: single column, rail on top, body below (beats the per-mode grid in the skin sheet) ---- */
.ph-w1[data-ph-mode] {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  min-height: 0;
  text-align: start;
}

.ph-w1 .ph-w1-body {
  display: grid;
  gap: 0.75rem;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  min-width: 0;
}

.ph-w1 .ph-w1-rail__title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.ph-w1 [hidden] {
  display: none !important;
}

/* skin-te-field: LED stays orange, nothing else does */
.ph-w1[data-ph-skin="skin-te-field"] {
  --ph-skin-accent: var(--ph-skin-ink);
  --ph-skin-pad-active: var(--ph-skin-ink);
}

.ph-w1[data-ph-skin="skin-te-field"] .ph-primary,
.ph-w1[data-ph-skin="skin-te-field"] .ph-pad[aria-pressed="true"] {
  color: var(--ph-skin-surface);
}

/* ---- type ---- */
.ph-w1 .ph-w1-h1 {
  margin: 0;
  font-family: var(--ph-skin-font-sans);
  font-size: clamp(2rem, 5vw, 3rem); /* 32px on phones, 48px on desktop */
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: var(--ph-skin-tracking-display);
  text-wrap: balance;
}

.ph-w1 .ph-w1-sub,
.ph-w1 .ph-w1-note,
.ph-w1 .ph-w1-status,
.ph-w1 .ph-w1-source,
.ph-w1 .ph-w1-micro {
  margin: 0;
  color: var(--ph-skin-ink-muted);
  font-size: 0.875rem;
  line-height: 1.45;
  letter-spacing: var(--ph-skin-tracking-body);
  overflow-wrap: anywhere;
}

.ph-w1 .ph-w1-sub {
  max-width: 62ch;
  font-size: 1rem;
}

.ph-w1 ul.ph-w1-proof {
  display: grid;
  gap: 0.35rem;
  padding: 0;
  list-style: none;
}

.ph-w1 ul.ph-w1-proof li {
  padding-inline-start: 1.1rem;
  position: relative;
}

.ph-w1 ul.ph-w1-proof li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0.6em;
  inline-size: 0.4rem;
  block-size: 0.4rem;
  border-radius: 999px;
  background: var(--ph-skin-led);
}

.ph-w1 .ph-w1-status {
  min-height: 2.9em; /* two lines reserved: status text changing never shifts what is below */
  color: var(--ph-skin-ink);
}

.ph-w1 .ph-w1-source,
.ph-w1 .ph-w1-micro {
  font-family: var(--ph-skin-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  min-height: 1.45em;
}

.ph-w1 .ph-w1-micro {
  color: var(--ph-skin-ink);
}

/* ---- drop zone ---- */
.ph-w1 .ph-w1-file {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.ph-w1 .ph-w1-drop {
  position: relative;
  display: grid;
  gap: 0.25rem;
  place-content: center;
  text-align: center;
  min-height: 96px;
  padding: 1rem;
  background: var(--ph-skin-surface-inset);
  border: 2px dashed var(--ph-skin-bezel);
  border-radius: var(--ph-skin-radius);
  cursor: pointer;
}

.ph-w1 .ph-w1-drop--slim {
  min-height: 64px;
  padding: 0.6rem 1rem;
}

.ph-w1 .ph-w1-drop:hover,
.ph-w1 .ph-w1-drop:focus-within,
.ph-w1 .ph-w1-drop[data-drag="true"] {
  border-color: var(--ph-skin-ink);
}

.ph-w1 .ph-w1-drop__title {
  font-weight: 700;
  font-size: 1rem;
}

.ph-w1 .ph-w1-drop__hint {
  font-size: 0.8125rem;
  color: var(--ph-skin-ink-muted);
}

/* ---- demo picker ---- */
.ph-w1 .ph-w1-demos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.ph-w1 .ph-w1-demo {
  display: grid;
  gap: 0.15rem;
  min-height: 56px;
  min-width: 0;
  text-align: center;
  align-content: center;
}

.ph-w1 .ph-w1-demo__name {
  font-family: var(--ph-skin-font-sans);
  font-weight: 700;
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.ph-w1 .ph-w1-demo__meta {
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

/* ---- readout chips: width reserved, tabular numbers ---- */
.ph-w1 .ph-w1-readouts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.ph-w1 .ph-w1-readouts--grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.ph-w1 .ph-readout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-width: 0;
  min-height: 3.1rem;
}

.ph-w1 .ph-readout__value {
  display: block;
  min-width: 7ch;
  font-size: 1.125rem;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- actions ---- */
.ph-w1 .ph-w1-actions,
.ph-w1 .ph-w1-handoff,
.ph-w1 .ph-w1-lengths,
.ph-w1 .ph-w1-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.ph-w1 .ph-w1-controls {
  align-items: end;
}

.ph-w1 .ph-w1-field {
  display: grid;
  gap: 0.25rem;
  flex: 1 1 12rem;
  min-width: 0;
}

.ph-w1 .ph-w1-field__label {
  font-family: var(--ph-skin-font-mono);
  font-size: 0.75rem;
  color: var(--ph-skin-ink-muted);
  font-variant-numeric: tabular-nums;
}

.ph-w1 .ph-w1-range {
  width: 100%;
  min-height: 44px;
  accent-color: var(--ph-skin-ink);
}

.ph-w1 .ph-w1-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  font-size: 0.875rem;
  color: var(--ph-skin-ink-muted);
}

.ph-w1 .ph-w1-check input {
  inline-size: 1.25rem;
  block-size: 1.25rem;
}

.ph-w1 .ph-primary:disabled,
.ph-w1 .ph-pad:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ph-w1 .ph-w1-camera {
  position: relative;
}

.ph-w1 .ph-w1-camera:focus-within,
.ph-w1 .ph-w1-drop:focus-within {
  outline: 2px solid var(--ph-skin-ink);
  outline-offset: 2px;
}

/* ---- waveform stage (B2): aspect reserved, canvas fills it ---- */
.ph-w1 .ph-w1-stage {
  position: relative;
  width: 100%;
  background: var(--ph-skin-surface-inset);
  border: var(--ph-skin-border-width) solid var(--ph-skin-bezel);
  overflow: hidden;
}

.ph-w1 .ph-w1-stage--wave {
  aspect-ratio: 960 / 200;
  border-radius: var(--ph-skin-radius);
}

.ph-w1 .ph-w1-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- photo stage + 14px photo cards (B5): 4:5 reserved ---- */
.ph-w1 .ph-w1-stage--photo {
  aspect-ratio: 4 / 5;
  max-width: 420px;
  margin-inline: auto;
  border-radius: var(--ph-skin-radius-card);
}

.ph-w1 .ph-w1-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 0.625rem;
}

.ph-w1 .ph-w1-card {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--ph-skin-surface-inset);
  border: var(--ph-skin-border-width) solid var(--ph-skin-bezel);
  border-radius: var(--ph-skin-radius-card);
  box-shadow: var(--ph-skin-shadow);
}

.ph-w1 .ph-w1-card__canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ph-w1 .ph-w1-card__label {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.25rem 0.6rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent);
}

/* ---- modes ----
   inline  (<= 260px in the skin sheet): demos + readouts + one primary row; no drop zone, stage, status or secondary links.
   card    (<= 160px): rail + demos + readouts only (first three chips, one row).
   compact (< 768px): the full tool, stacked, thumb-first. */
.ph-w1[data-ph-mode="inline"] .ph-w1-body {
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
}

.ph-w1[data-ph-mode="inline"] .ph-w1-stage,
.ph-w1[data-ph-mode="inline"] .ph-w1-cards,
.ph-w1[data-ph-mode="inline"] .ph-w1-controls,
.ph-w1[data-ph-mode="inline"] .ph-w1-note,
.ph-w1[data-ph-mode="inline"] .ph-w1-source,
.ph-w1[data-ph-mode="inline"] .ph-w1-micro,
.ph-w1[data-ph-mode="inline"] .ph-w1-check,
.ph-w1[data-ph-mode="inline"] .ph-w1-drop,
.ph-w1[data-ph-mode="inline"] .ph-w1-status,
.ph-w1[data-ph-mode="inline"] .ph-w1-sub,
.ph-w1[data-ph-mode="inline"] .ph-w1-h1,
.ph-w1[data-ph-mode="inline"] .ph-w1-share,
.ph-w1[data-ph-mode="inline"] .ph-w1-handoff .ph-pad,
.ph-w1[data-ph-mode="inline"] .ph-w1-readouts--grid .ph-readout:nth-child(n + 4) {
  display: none;
}

.ph-w1[data-ph-mode="inline"] .ph-w1-readouts--grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ph-w1[data-ph-mode="card"] .ph-w1-body {
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
}

.ph-w1[data-ph-mode="card"] .ph-w1-stage,
.ph-w1[data-ph-mode="card"] .ph-w1-cards,
.ph-w1[data-ph-mode="card"] .ph-w1-controls,
.ph-w1[data-ph-mode="card"] .ph-w1-note,
.ph-w1[data-ph-mode="card"] .ph-w1-source,
.ph-w1[data-ph-mode="card"] .ph-w1-micro,
.ph-w1[data-ph-mode="card"] .ph-w1-check,
.ph-w1[data-ph-mode="card"] .ph-w1-drop,
.ph-w1[data-ph-mode="card"] .ph-w1-status,
.ph-w1[data-ph-mode="card"] .ph-w1-actions,
.ph-w1[data-ph-mode="card"] .ph-w1-handoff,
.ph-w1[data-ph-mode="card"] .ph-w1-share,
.ph-w1[data-ph-mode="card"] .ph-w1-sub,
.ph-w1[data-ph-mode="card"] .ph-w1-h1,
.ph-w1[data-ph-mode="card"] .ph-w1-readouts--grid .ph-readout:nth-child(n + 4) {
  display: none;
}

.ph-w1[data-ph-mode="card"] .ph-w1-readouts--grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ph-w1[data-ph-mode="card"] .ph-w1-demo {
  min-height: 44px;
}

.ph-w1[data-ph-mode="card"] .ph-readout {
  min-height: 2.6rem;
}

.ph-w1[data-ph-mode="mobile-compact"] .ph-w1-readouts--grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ph-w1[data-ph-mode="mobile-compact"] .ph-w1-note {
  display: none;
}

.ph-w1[data-ph-mode="mobile-compact"] .ph-w1-handoff .ph-pad,
.ph-w1[data-ph-mode="mobile-compact"] .ph-w1-actions > *,
.ph-w1[data-ph-mode="mobile-compact"] .ph-w1-share {
  width: 100%;
}

/* ---- mobile: thumb-first, 48px primary ---- */
@media (max-width: 767px) {
  .ph-w1 .ph-primary {
    min-height: 48px;
    width: 100%;
  }

  .ph-w1 .ph-w1-readouts--grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ph-w1 .ph-w1-handoff .ph-pad,
  .ph-w1 .ph-w1-actions > * {
    flex: 1 1 100%;
  }

  .ph-w1 .ph-w1-demo {
    padding-inline: 0.3rem;
  }

  .ph-w1 .ph-w1-demo__name {
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .ph-w1 .ph-w1-demo__meta {
    white-space: nowrap;
  }

  .ph-w1 .ph-readout__value {
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 1rem;
  }
}

/* ---- Wave-2 Boilerplates (B3 AudioEncode, B6 Calculators) ---- */
.ph-w2-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.ph-w2-select,
.ph-w2-input {
  background: var(--ph-surface-2, rgba(255, 255, 255, 0.06));
  color: var(--ph-ink, inherit);
  border: 1px solid var(--ph-border, rgba(128, 128, 128, 0.28));
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  min-height: 38px;
}

.ph-w2-tags {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 0.6fr) minmax(0, 0.7fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ph-w2-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--ph-ink, inherit);
  cursor: pointer;
}

.ph-w2-range {
  flex: 1 1 160px;
  min-width: 120px;
  accent-color: var(--ph-accent, #f25c24);
}

.ph-w2-batch-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  margin: 0.6rem 0;
  border-radius: 10px;
  border: 1px solid var(--ph-accent, #f25c24);
  background: var(--ph-surface-2, rgba(242, 92, 36, 0.08));
  font-size: 0.84rem;
}

.ph-w2-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 0.75rem;
}

.ph-w2-tab {
  appearance: none;
  background: var(--ph-surface-2, rgba(128, 128, 128, 0.1));
  color: var(--ph-ink, inherit);
  border: 1px solid var(--ph-border, rgba(128, 128, 128, 0.25));
  border-radius: 8px;
  padding: 0.42rem 0.75rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}

.ph-w2-tab[aria-selected="true"] {
  border-color: var(--ph-accent, #f25c24);
  background: var(--ph-surface-1, rgba(242, 92, 36, 0.14));
}

.ph-w2-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ph-w2-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--ph-border, rgba(128, 128, 128, 0.22));
  background: var(--ph-surface-2, rgba(128, 128, 128, 0.06));
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}

.ph-w2-cell strong {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.78;
}

@media (max-width: 767px) {
  .ph-w2-tags,
  .ph-w2-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
