/* Product pages */
.product-hero .split { align-items: center; }
.product-hero h1 { font-size: var(--fs-hero); margin-bottom: 0.2em; }
.h1sub { font: 500 var(--fs-xl)/1.35 var(--font-body); color: var(--text); margin-bottom: 12px; }

/* Joystick-board hero (productHero() in templates/tseries.mjs): board left, name and buy box right.
   Phones read: name, board, lead, buy box. The spec table and shipping follow in .pd-facts. */
.pd { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 14px clamp(28px, 4vw, 48px); }
.pd__title { grid-column: 2; grid-row: 1; }
.pd__title .h1sub { font-weight: 400; color: var(--text-2); margin: 0; }
.pd__left { grid-column: 1; grid-row: 1 / span 2; display: grid; gap: 16px; align-content: start; }
.pd__right { grid-column: 2; grid-row: 2; display: grid; gap: 14px; align-content: start; }
.pd__right .lead { margin: 0; font-size: var(--fs-md); }
.pd .hotspot-img { max-width: none; }
.pd--tall .hotspot-img { max-width: 430px; margin-inline: auto; }
/* The one spec table, with shipping, returns and support beside it (specsRow() in templates/tseries.mjs). */
.pd-facts { padding-top: clamp(20px, 3vw, 32px); }
.pd-facts__grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.pd-facts .table-wrap { min-width: 0; }
.pd-facts #trust { scroll-margin-top: calc(var(--header-h) + 56px); }
@media (max-width: 960px) { .pd-facts__grid { grid-template-columns: minmax(0, 1fr); } }
.pd__docs { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 10px 0 0; padding: 0; list-style: none; font-size: var(--fs-sm); }
.pd__docs a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
@media (max-width: 960px) {
  .pd { display: flex; flex-direction: column; gap: 16px; }
  .pd__left { display: contents; }
  .pd__title { order: 1; }
  .pd__board { order: 2; }
  .pd__right { order: 3; }
  .pd .hotspot-img { max-width: 600px; margin-inline: auto; }
  .pd--tall .hotspot-img { max-width: 430px; }
}

/* Hero board picture */
.hotspot-stage { position: relative; }
.hotspot-img { position: relative; max-width: 600px; margin: 0 auto; }
.hotspot-img img { width: 100%; height: auto; }

/* Real photos, photo slots, box contents */
.pd-photos { padding-top: clamp(20px, 3vw, 32px); }
.pd-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pd-gallery .photo { align-self: stretch; }
.pd-gallery .photo img { aspect-ratio: 1; object-fit: cover; }
.pd-gallery .photo-slot { aspect-ratio: auto; min-height: 200px; }
.pd-gallery--tall > .photo:first-child { grid-row: span 2; }
/* Tall boards: the top view keeps its whole frame, so every label stays in the picture. */
.pd-gallery--tall > .photo:first-child { display: flex; flex-direction: column; }
.pd-gallery--tall > .photo:first-child img { flex: 1 1 auto; aspect-ratio: auto; object-fit: cover; }
.pd-gallery--tall > .photo:not(:first-child) img { aspect-ratio: 4 / 3; }
.pd-box { grid-column: span 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.pd-gallery--1k .pd-box, .pd-gallery--tall .pd-box { grid-column: span 3; }
.pd-gallery > .pd-box:only-child { grid-column: 1 / -1; }  /* no photos yet (the public build hides empty photo boxes) */
.pd-box h2 { margin: 0 0 8px; font: 600 var(--fs-md)/1.35 var(--font-body); letter-spacing: 0; }
.pd-box__list { margin: 0 0 8px; padding-left: 1.1em; font-size: var(--fs-sm); color: var(--text-2); }
.pd-box__list li { margin-bottom: 4px; }
.pd-box__list a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
@media (max-width: 960px) {
  .pd-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pd-box, .pd-gallery--1k .pd-box, .pd-gallery--tall .pd-box { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .pd-box { grid-template-columns: minmax(0, 1fr); }
  .pd-gallery .photo-slot { grid-column: 1 / -1; min-height: 0; }
  .pd-gallery--tall > .photo:first-child { grid-column: 1 / -1; grid-row: auto; }
}

/* Section head with a real photo beside it */
.pd-headsplit { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); align-items: start; margin-bottom: clamp(20px, 3vw, 32px); }
.pd-headsplit > header { margin-bottom: 0 !important; }
@media (max-width: 960px) { .pd-headsplit { grid-template-columns: minmax(0, 1fr); } }

/* Wiring: terminal layout, the two wiring drawings, video */
.pd-wirespec { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 2.4vw, 24px); margin-top: clamp(24px, 3vw, 32px); align-items: stretch; }
.pd-wirespec--media > .photo { display: flex; flex-direction: column; align-self: stretch; }
.pd-wirespec--media .photo img { flex: 1 1 0; min-height: 0; width: 100%; object-fit: cover; }
.pd-wirespec--media > :only-child { grid-column: 1 / -1; width: 100%; max-width: 720px; }  /* the video alone, when its photo is hidden */
.pd-fig { margin: 0; padding: 14px; height: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.pd-fig__t { font-size: var(--fs-sm); margin: 0 0 10px; }
.pd-fig__c { margin-top: 10px; }
.pd-wirelink { margin: 12px 0 0; }
.pd-wirespec .photo-slot { aspect-ratio: var(--ratio, 16 / 9); }
@media (max-width: 960px) {
  .pd-wirespec { grid-template-columns: minmax(0, 1fr); }
}

/* Product cards on these pages: every image stays inside its 4:3 stage. */
.pd-cards .pcard__media { display: block; }
.pd-cards .pcard__media img { position: absolute; inset: 18px; width: calc(100% - 36px); height: calc(100% - 36px); max-height: none; object-fit: contain; }
@media (max-width: 600px) {
  .pd-cards.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pd-cards .pcard__media img { inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); }
  .pd-cards .pcard__body { padding: 12px; gap: 4px; }
  .pd-cards .pcard__title { font-size: 1rem; }
  .pd-cards .pcard .spec-pills { display: none; }
  .pd-cards .pcard__foot { flex-wrap: wrap; gap: 4px; padding-top: 8px; }
}

.pd-works { margin-top: clamp(24px, 3vw, 32px); }
.pd-stack { display: grid; gap: 18px; }

/* 1000T: encoders.js writes the flip label in capitals. */
.t1k-flip__hint span { display: inline-block; text-transform: lowercase; }
.t1k-flip__hint span::first-letter { text-transform: uppercase; }

/* Feature demos (small) */
.feature-demos h3 { margin-bottom: 6px; }
@media (min-width: 961px) {
  .feature-demos > div { display: flex; flex-direction: column; }
  .feature-demos > div > .demo { flex: 1; }
}
.demo--sm .demo__body { padding: 18px 14px; }
.demo--sm .demo__bar { padding: 10px 12px; }
.demo--sm .btn-grid { grid-template-columns: repeat(4, 44px); gap: 10px; }
.demo--sm .btn-grid .ab { width: 44px; height: 44px; font-size: 0.75rem; }
.demo--sm .trace { height: 70px; }
.feature-demos .how { margin-top: 12px; }
.feature-demos .how kbd { font-size: 0.9em; }

/* Device frame for app screenshots */
.split--top { align-items: start; }
.sticky-frame { position: sticky; top: calc(var(--header-h) + 64px); }
@media (max-width: 960px) { .sticky-frame { position: relative; top: 0; } }
.device-frame { position: relative; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-2); }
.device-frame img { border-radius: 5px; width: 100%; }

table.spec--tight th, table.spec--tight td { padding: 8px 12px; font-size: 0.875rem; }

/* Folded detail: native <details>, same pattern as .at-fold on the ATLAS pages and .cfg-fold on /configurator/. fold() in templates/tseries.mjs, /js/folds.js. */
.pd-folds { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: clamp(16px, 2.4vw, 24px); }
.pd-fold { min-width: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); scroll-margin-top: calc(var(--header-h) + 56px); }
.pd-fold[open] { border-color: var(--line-2); }
.pd-fold__sum { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 't plus' 's plus'; column-gap: 16px; row-gap: 2px; padding: 12px clamp(14px, 2vw, 20px); }
.pd-fold__sum::-webkit-details-marker { display: none; }
.pd-fold__sum::after { content: '+'; grid-area: plus; align-self: center; font: 400 1.5rem/1 var(--font-body); color: var(--muted); }
.pd-fold[open] > .pd-fold__sum::after { content: '−'; }
.pd-fold__sum:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: var(--r-lg); }
.pd-fold__t { grid-area: t; font: 600 var(--fs-md)/1.35 var(--font-body); color: var(--text); }
.pd-fold__s { grid-area: s; font-size: var(--fs-sm); line-height: 1.4; color: var(--muted); }
.pd-fold__sum:hover .pd-fold__t { color: var(--cyan-hi); }
.pd-fold__body { padding: 16px clamp(14px, 2vw, 20px) clamp(16px, 2.4vw, 22px); border-top: 1px solid var(--line); }
.pd-fold__body > :last-child { margin-bottom: 0; }
@media (max-width: 600px) { .pd-fold__body--flush { padding-inline: 8px; } }
/* data-open-wide: on desktop it is simply open and reads as a plain block. Only while JS is on and it is open, so it can never get stuck shut. */
@media (min-width: 961px) {
  .js .pd-fold[data-open-wide][open] { border: 0; background: none; border-radius: 0; }
  .js .pd-fold[data-open-wide][open] > .pd-fold__sum { padding: 0 0 8px; pointer-events: none; }
  .js .pd-fold[data-open-wide][open] > .pd-fold__sum::after, .js .pd-fold[data-open-wide][open] > .pd-fold__sum > .pd-fold__s { display: none; }
  .js .pd-fold[data-open-wide][open] > .pd-fold__body { padding: 0; border: 0; }
  .js .pd-fold--bare[data-open-wide][open] > .pd-fold__sum { display: none; }
}

/* Every mode in one table (modeTable() in templates/tseries.mjs): what it does, its 8-second hold and its pin. */
table.spec.pd-mt tbody th { white-space: normal; }
@media (min-width: 761px) {
  table.spec.pd-mt tbody th { width: 15%; }
  table.spec.pd-mt td:nth-child(2) { width: 44%; }
  table.spec.pd-mt.pd-mt--instant td:nth-child(2) { width: 36%; }
  table.spec.pd-mt.pd-mt--instant td:nth-child(3), table.spec.pd-mt.pd-mt--instant td:nth-child(4) { width: 16%; }
}
.pd-mt tr[id] { scroll-margin-top: calc(var(--header-h) + 64px); }
.pd-mt__code { display: block; font: 500 var(--fs-sm)/1.3 var(--font-mono); color: var(--text-2); }
.pd-mt .badge { margin-left: 2px; }
.pd-mt kbd { font-size: 0.9em; white-space: nowrap; }
.pd-mt code { white-space: nowrap; }
.pd-mt__notes { margin: 14px 0 0; max-width: 92ch; }
.pd-mt__notes b { color: var(--text); }
/* Phones: each mode becomes a small card: the mode, what it does, then its labelled hold and pin. */
@media (max-width: 760px) {
  .pd-mt__wrap { overflow: visible; border: 0; background: none; }
  table.spec.pd-mt, table.spec.pd-mt tbody { display: block; width: 100%; min-width: 0; }
  table.spec.pd-mt thead { display: none; }
  table.spec.pd-mt tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin-bottom: 10px; padding: 12px 14px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); }
  table.spec.pd-mt.pd-mt--instant tr > td:nth-child(5) { grid-column: 1 / -1; }
  table.spec.pd-mt tr > th { grid-column: 1 / -1; width: auto; padding: 0; border: 0; background: none; font-size: 0.9375rem; }
  table.spec.pd-mt tr > td { display: block; width: auto; padding: 0; border: 0; background: none; min-width: 0; }
  table.spec.pd-mt tr > td:nth-child(2) { grid-column: 1 / -1; }
  table.spec.pd-mt tr > td:nth-child(n + 3)::before { content: attr(data-l); display: block; margin-bottom: 3px; font: 400 var(--fs-xs)/1.2 var(--font-body); color: var(--muted); }
  table.spec.pd-mt tbody tr:hover > * { background: none; }
  .pd-mt__code { display: inline; margin-left: 6px; }
}
/* Keyboard keys: all four player columns fit on a phone, no sideways scrolling inside the table. */
@media (max-width: 600px) {
  table.spec.pd-keys th, table.spec.pd-keys td { padding: 7px 6px; font-size: var(--fs-xs); }
  table.spec.pd-keys tbody th { white-space: normal; }
}

/* FAQ: two columns on desktop. */
@media (min-width: 961px) {
  .pd-faq { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(20px, 3vw, 36px); align-items: start; border-top: 0; }
  .pd-faq > details { border-top: 1px solid var(--line); border-bottom: 0; }
}

/* Gamepads: text beside the photo. */
.pd-headsplit > div > header { margin-bottom: clamp(14px, 2vw, 20px) !important; }
.pd-gp h3 { margin-bottom: 8px; }

/* Dimensions beside compatibility on desktop. */
.pd-specs2 { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 36px); align-items: start; }
.pd-specs2 .pd-works { margin-top: 0; }
@media (max-width: 960px) { .pd-specs2 { grid-template-columns: minmax(0, 1fr); } }
.pd-specs2--dims > * { min-width: 0; }
@media (min-width: 961px) { .pd-specs2--dims { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); } }
/* 1000T: the flip board sits above compatibility. */
.pd-specs2.t1k-specs { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; gap: clamp(20px, 3vw, 36px); }
.pd-specs2 .t1k-flip { width: min(56%, 220px); }
.pd-rs { align-items: start; }
.pd-rs + * { min-width: 0; }
/* 1000T: the SHIFT demo keeps a demo's width above the full-width modes table. */
.pd-shdemo { max-width: 640px; }
.pd-nd { max-width: 520px; margin-inline: auto; }
@media (max-width: 960px) { .pd-specs2.t1k-specs { grid-template-columns: minmax(0, 1fr); } }
/* 1000T stick routing: the demo beside the text. On a phone the lead comes before the demo. */
@media (min-width: 961px) { .rs-split.pd-rs { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } }
@media (max-width: 960px) {
  .pd-rs { display: flex; flex-direction: column; gap: 16px; }
  .pd-rs > .demo { min-width: 0; }
  .pd-rs .rs-text { display: contents; }
  .pd-rs .rs-text > .lead { order: -1; margin: 0; }
}

/* Parts list: one line per part, in place of rows of product cards. */
.pd-parts__h { margin-bottom: 12px; }
.pd-parts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(20px, 3vw, 36px); }
.pd-part { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); color: var(--text); }
.pd-part:hover b { color: var(--cyan-hi); }
/* A row is the link plus its Add button. .buybox is only there so the cart script finds the row's quantity. */
.pd-parts li.pd-partrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 0; margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; }
.pd-partrow .pd-part { border-top: 0; }
.pd-partrow .price { font-size: 1rem; }
.pd-part__each { color: var(--text-2); font-size: var(--fs-xs); }
@media (max-width: 600px) { .pd-partrow .pd-part { grid-template-columns: minmax(0, 1fr) auto; } .pd-partrow .pd-part__img, .pd-part__each { display: none; } }
.pd-part__img { display: block; width: 60px; height: 45px; padding: 3px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); }
.pd-part__img img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pd-part__txt { min-width: 0; }
.pd-part__txt b { display: block; font-weight: 600; font-size: 0.9375rem; line-height: 1.3; }
.pd-part__txt small { display: block; font-size: var(--fs-xs); line-height: 1.35; color: var(--text-2); }
@media (max-width: 600px) { .pd-part__txt small { display: none; } .pd-part { padding: 7px 0; } }
.pd-part__buy { display: flex; align-items: center; gap: 8px; }
.pd-part__buy .price { font-size: 1rem; white-space: nowrap; }
@media (max-width: 760px) { .pd-parts { grid-template-columns: minmax(0, 1fr); } }
.pd-gp__hook { margin-top: clamp(22px, 3vw, 32px); }

/* Wiring section: pinout and recipes (templates/wiring.mjs; the pinout and recipe styles themselves are in support.css) */
.pd-subh { margin: clamp(36px, 5vw, 56px) 0 6px; font-size: var(--fs-xl); scroll-margin-top: calc(var(--header-h) + 56px); }
.pd-subh__lead { max-width: 72ch; margin: 0 0 20px; }
.pd-fold--names, .pd-fold--recipes { margin-top: 14px; }
.pd-fold--names .ctlnames { margin-top: 0; }
.pd-subh--first { margin-top: clamp(20px, 3vw, 32px); }

/* Turbo, 8-to-6 and interlock: still pictures (tseries.mjs featureCards) */
.ft__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.ft-card { display: flex; flex-direction: column; gap: 12px; padding: clamp(16px, 2vw, 22px); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.ft-card h4 { margin: 0; font-size: var(--fs-lg); }
.ft-card p { margin: 0; }
.ft-card > p:first-of-type { color: var(--text-2); }
.ft-chart { display: grid; gap: 10px; padding: 14px; border-radius: var(--r); background: var(--bg); border: 1px solid var(--line); }
.ft-row { display: grid; gap: 4px; }
.ft-row__l { font-size: var(--fs-xs); color: var(--muted); }
.ft-bar { position: relative; height: 26px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.ft-seg { position: absolute; top: 0; bottom: 0; display: grid; place-items: center; font: 600 var(--fs-xs)/1 var(--font-body); color: var(--on-cyan, #04131a); background: var(--cyan); white-space: nowrap; overflow: hidden; }
.ft-seg + .ft-seg { border-left: 2px solid var(--bg); background: #7fdcf8; }
.ft-seg.is-you { background: var(--line-3); }
.ft-seg.is-warn { background: #e5534b; color: #fff; }
.ft-seg--pulse { background: linear-gradient(90deg, var(--cyan) 30%, transparent 30%) 0 0 / calc(100% / 15) 100% repeat-x; }
.ft-scale { position: relative; display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); }
.ft-scale--mark span[style] { position: absolute; transform: translateX(-50%); }
.ft-e26 { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: end; padding: 14px; border-radius: var(--r); background: var(--bg); border: 1px solid var(--line); }
.ft-e26__l { display: block; margin-bottom: 6px; font-size: var(--fs-xs); color: var(--muted); }
.ft-e26__arrow { align-self: center; padding-top: 18px; color: var(--muted); font-size: 1.2rem; }
.ft-pad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.ft-pad span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--line-3); font: 600 var(--fs-xs)/1 var(--font-mono); color: var(--text-2); }
.ft-pad span.is-moved { border-color: var(--cyan); color: var(--text); background: color-mix(in srgb, var(--cyan) 18%, transparent); }
/* turbo + interlock animation (/js/ftcards.js sets --p, 0..1, and lights the .ft-led chips) */
.ft-chart { position: relative; }
.ft-row__l { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ft-leds { display: flex; gap: 4px; }
.ft-led { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; border: 1px solid var(--line-3); font: 600 10px/1 var(--font-mono); color: var(--muted); transition: background 0.06s, color 0.06s, border-color 0.06s; }
.ft-led.is-on { background: var(--cyan); border-color: var(--cyan); color: var(--on-cyan, #04131a); }
.ft-led.is-you.is-on { background: var(--text-2); border-color: var(--text-2); color: var(--bg); }
.ft-led.is-warn.is-on { background: #e5534b; border-color: #e5534b; color: #fff; }
.ft-bar__in { position: absolute; inset: 0; clip-path: inset(0 calc((1 - var(--p, 1)) * 100%) 0 0); }
.ft-chart.is-anim .ft-bar::after { content: ''; position: absolute; top: 0; bottom: 0; left: calc(var(--p, 1) * 100%); width: 2px; margin-left: -1px; background: var(--text); opacity: 0.85; transition: opacity 0.3s; }
.ft-chart.is-anim.is-resting .ft-bar::after { opacity: 0; }
.ft-scale__note { font-style: italic; }
.ft-chart:not(.is-anim) .ft-leds, .ft-chart:not(.is-anim) .ft-scale__note { display: none; }
@media (max-width: 1000px) { .ft__grid { grid-template-columns: minmax(0, 1fr); max-width: 560px; } }

