/* Products pages (/products/ and /product/). Minimal: quiet, spacious, almost empty.
   Colors: Parchment page, Espresso text, Walnut secondary text, hairlines at 15% Espresso. Nothing else.
   Type: Manrope throughout, like the header; three sizes (36px names and titles, 17px body, 13px labels).
   Spacing: 8, 16, 32, 64, 96px only.
   No animation, except the Sort by list's FAQ-style slide and the Parts exploded view (scroll-driven). The header and footer come from legal.css. */

:root {
  --hairline: color-mix(in srgb, var(--espresso) 15%, transparent);
}

/* Everything instant on these pages, including the shared header and footer */
html {
  scroll-behavior: auto;
}

*,
*::before,
*::after {
  transition: none !important;
  animation: none !important;
}

[hidden] {
  display: none !important;
}

.site-header :focus-visible,
.shop :focus-visible,
.zoom-dialog :focus-visible {
  outline: 2px solid var(--espresso);
  outline-offset: 4px;
}

/* ---------- Page ---------- */
.shop {
  min-height: 100svh;
  padding: calc(56px + 32px) 16px 64px; /* 56px: the fixed header */
  background: var(--parchment);
  color: var(--espresso);
  font-size: 17px;
  line-height: 1.6;
}

@media (min-width: 768px) {
  .shop {
    padding: calc(56px + 32px) 64px 96px;
  }
}

/* :where() keeps this reset weaker than any class below */
:where(.shop) :where(p, h1, h2, ul, dl, dd) {
  margin: 0;
}

:where(.shop) a {
  color: inherit;
  text-underline-offset: 4px;
}

.shop-note {
  max-width: 60ch;
}

.shop-note p + p,
.shop-note h1 + p {
  margin-top: 16px;
}

.shop-note .back {
  display: inline-block;
  margin-top: 32px;
}

.name {
  font-size: 36px;
  font-weight: 400; /* the header's weight; headings would otherwise be bold */
  line-height: 1.15;
}

.small {
  font-size: 13px;
  line-height: 1.6;
  color: var(--walnut);
}

/* ---------- Catalog: toolbar ---------- */
/* One quiet row: result count on the left; Filters and Sort by on the right */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 32px;
  margin-bottom: 32px;
  padding-bottom: 16px; /* the hairline sits a little below the count and the Sort by box */
  border-bottom: 1px solid var(--hairline);
}

.toolbar-count {
  font-size: 13px;
  color: var(--walnut);
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 32px;
}

.tool {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--espresso);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* Sort: a box that reads "Sort by" until a choice is made, then shows that choice.
   It opens a list of choices with thin radio buttons, attached under the box. */
.sort {
  position: relative;
}

.sort-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 184px; /* fits the longest choice, "Alphabetically, Z to A" */
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--hairline);
  text-align: left;
}

.sort-toggle::after {
  content: '';
  position: absolute;
  inset: -2px 0; /* 44px tall to tap, though the box looks 40px */
}

/* The list glides open and shut like the home page FAQ answers (height over .25s, chevron turning over .2s).
   The only motion on these pages; reduced motion turns it off. */
.sort-toggle .chevron {
  transition: transform .2s cubic-bezier(.4, 0, .2, 1) !important;
}

.sort-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.sort-panel {
  position: absolute;
  top: calc(100% - 1px); /* shares the box's bottom line */
  right: 0;
  z-index: 10;
  width: 184px;
  display: grid;
  grid-template-rows: 0fr;
  border: 1px solid transparent;
  background: var(--parchment);
  background-clip: padding-box; /* while closed, paints nothing over the box's bottom line */
  transition: grid-template-rows .25s ease, border-color .25s ease !important;
}

.sort-panel.is-open {
  grid-template-rows: 1fr;
  border-color: var(--hairline);
}

.sort-panel-inner {
  min-height: 0;
  overflow: hidden;
}

.sort-panel fieldset {
  margin: 0;
  padding: 8px 0;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .sort-toggle .chevron,
  .sort-panel {
    transition: none !important;
  }
}

.sort-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.sort-option input {
  appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--espresso);
  border-radius: 50%;
  background-clip: content-box;
  cursor: pointer;
}

/* The chosen order's dot: Faded Copper, like the header's "Join the waitlist" button */
.sort-option input:checked {
  background-color: var(--faded-copper);
}

/* Filters panel: opens in place under the toolbar */
.filters-panel {
  margin: 0 0 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--hairline);
}

.filter-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 32px 96px;
}

.filter-group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.filter-group legend {
  padding: 0;
  font-size: 13px;
  color: var(--walnut);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 13px;
  cursor: pointer;
}

.filter-option input {
  appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--espresso);
  background-clip: content-box;
  cursor: pointer;
}

.filter-option input:checked {
  background-color: var(--espresso);
}

.panel-actions {
  display: flex;
  gap: 32px;
  margin-top: 16px;
}

/* ---------- Catalog: grid ---------- */
.catalog-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 64px 32px;
}

@media (min-width: 768px) {
  .catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 96px 32px;
  }
}

/* Desktop: three columns, whatever the number of products */
@media (min-width: 1024px) {
  .catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card {
  display: block;
  text-decoration: none;
}

/* Second photo, shown instantly on hover or keyboard focus */
.photos {
  position: relative;
}

.hover-photo {
  position: absolute;
  inset: 0;
  visibility: hidden;
}

.card:hover .hover-photo,
.card:focus-visible .hover-photo {
  visibility: visible;
}

.card img,
.gallery-main img,
.thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 4px;
}

/* Card names use the body size; the large size is for the product page title */
.card .name {
  margin-top: 16px;
  font-size: 17px;
}

/* ---------- Catalog: closing line and waitlist button, below the grid ---------- */
.closing {
  margin-top: 64px;
  padding-top: 64px;
  border-top: 1px solid var(--hairline);
  text-align: center;
}

.closing-line {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: 36px;
  line-height: 1.15;
}

/* The home page carousel's "Join the waitlist" button: same shape and size, colors swapped for this page */
.waitlist-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 32px;
  text-decoration: none;
}

.waitlist-link::after {
  content: '';
  position: absolute;
  inset: -7px 0; /* 44px tall to tap, like the carousel's button */
}

.waitlist-label,
.waitlist-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  border-radius: 3px;
  background: var(--espresso);
  color: var(--parchment);
}

.waitlist-label {
  padding: 0 12px;
  font-size: 16px;
  font-weight: 500;
}

.waitlist-arrow {
  width: 30px;
}

.waitlist-link:hover .waitlist-arrow {
  transform: translateX(4px);
}

@media (min-width: 768px) {
  .closing {
    margin-top: 96px;
    padding-top: 96px;
  }
}

/* ---------- Product page ---------- */
.product {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 64px;
}

@media (min-width: 1024px) {
  .product {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 96px;
    align-items: start;
  }
}

/* Back arrow to the Products page, above the gallery */
.back-arrow {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -8px 0 -32px -14px; /* the arrow lines up with the content's left edge; 32px above the gallery */
  color: var(--espresso);
}

@media (min-width: 1024px) {
  /* Gallery and details sit side by side here, so the row gap only spaces the back arrow from them */
  .product {
    row-gap: 32px;
  }

  .back-arrow {
    margin-bottom: 0;
  }
}

/* Previous and next arrows on the big image */
.gallery-stage {
  position: relative;
}

.stage-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--espresso);
  cursor: pointer;
}

.stage-arrow span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 3px;
  background: var(--parchment);
}

.stage-prev {
  left: 8px;
}

.stage-next {
  right: 8px;
}

.gallery-main {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* A video sits in the same square as the photos, at its own shape, centered on the Parchment background
   (so its controls sit on the picture, not on an empty band) */
.gallery-video {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
}

.gallery-video video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  border-radius: 4px;
}

.thumb-video {
  position: relative;
}

.thumb-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--espresso);
}

.thumb-play svg {
  box-sizing: content-box;
  padding: 6px 5px 6px 7px;
  border-radius: 3px;
  background: var(--parchment);
}

.drawing {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  padding: 32px;
}

.bp {
  display: block;
  width: 100%;
  height: auto;
}

.bp path,
.bp circle {
  fill: none;
  stroke: var(--walnut);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.gallery-caption {
  margin-top: 8px;
}

/* Thumbnails, as in the reference: every one at full strength, the chosen one framed by a thin Espresso line.
   They aren't scrolled by hand: choosing one glides the strip so it sits in the middle (product.js).
   Phones: a row under the photo. Tablets and up: a column on the left, as tall as the main photo. */
.thumbs {
  position: relative; /* measuring point for centering the chosen thumbnail */
  display: flex;
  gap: 8px;
  margin: 8px -8px 0;
  padding: 8px; /* room for the focus outline */
  list-style: none;
  overflow: hidden;
}

.thumbs li {
  flex: 0 0 56px;
}

.thumb {
  display: block;
  width: 100%;
  padding: 3px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
}

.thumb[aria-pressed="true"] {
  border-color: var(--espresso);
}

.thumb .drawing {
  padding: 8px;
}

@media (min-width: 768px) {
  .gallery {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    column-gap: 16px;
    align-items: start;
  }

  .gallery-stage,
  .gallery-caption {
    grid-column: 2;
  }

  .gallery-stage {
    grid-row: 1;
  }

  /* As tall as the main photo: the row's height comes from the photo; extra thumbnails stay hidden below */
  .thumbs {
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    height: 0;
    min-height: 100%;
    margin: 0 0 0 -8px;
    padding-top: 0;
  }

  .thumbs li {
    flex: none;
  }
}
.back {
  display: inline-block;
  margin-bottom: 16px;
}

.product-desc {
  max-width: 60ch;
  margin-top: 32px;
}

/* One sentence per line, with space between them */
.product-desc p + p {
  margin-top: 16px;
}

/* Tabs below the photos: one row of text tabs between two hairlines; the chosen tab has a Faded Copper line
   under it (its text stays Espresso, which reads better than Faded Copper at this size). Instant switching. */
.product-tabs {
  grid-column: 1 / -1;
  margin-top: 32px;
}

@media (min-width: 1024px) {
  .product-tabs {
    margin-top: 64px; /* with the 32px row gap: 96px under the photos */
  }
}

.tablist {
  display: flex;
  gap: 64px;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto; /* phones: the row scrolls sideways if the tabs don't fit */
  scrollbar-width: none;
}

.tablist::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  flex: none;
  min-height: 64px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--espresso);
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}

.tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--faded-copper);
}

.shop .tab:focus-visible {
  outline-offset: -2px;
}

.tabpanel {
  padding-top: 64px;
}

.tabpanel:focus-visible {
  outline-offset: 8px;
}

.tabpanel-body {
  max-width: 60ch;
  margin-top: 32px;
}

.tabpanel-body ul,
.tabpanel-body ol {
  margin: 0;
  padding-left: 1.25em;
}

.tabpanel-body li + li {
  margin-top: 8px;
}

@media (max-width: 767px) {
  .tablist {
    gap: 32px;
  }
}

/* ---------- Full-size image ---------- */
.zoom-dialog {
  width: calc(100vw - 32px);
  max-width: 1200px;
  max-height: calc(100vh - 32px);
  padding: 16px;
  border: 0;
  background: var(--parchment);
  color: var(--espresso);
}

.zoom-dialog::backdrop {
  background: var(--parchment);
}

.zoom-head {
  display: flex;
  justify-content: flex-end;
}

.zoom-close {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
}

.zoom-body {
  display: grid;
  place-items: center;
  margin-top: 16px;
}

.zoom-body img {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 32px - 32px - 44px - 16px);
  border-radius: 4px;
}

.zoom-body .drawing {
  aspect-ratio: auto;
  width: 100%;
  padding: 0;
}

.zoom-body .bp {
  max-height: calc(100vh - 32px - 32px - 44px - 16px);
}

/* ---------- Waitlist popup: a plain-CSS copy of the home page's, so it looks and moves the same ---------- */
.waitlist-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(460px, calc(100vw - 32px));
  padding: 44px 40px 40px;
  border: 0;
  border-radius: 8px;
  background: var(--parchment);
  color: var(--espresso);
  box-shadow: 0 24px 60px rgb(31 21 17 / .35);
}

.waitlist-dialog::backdrop {
  background: rgb(31 21 17 / .6);
  backdrop-filter: blur(3px);
}

.waitlist-dialog[open] {
  animation: waitlist-in .3s cubic-bezier(.16, 1, .3, 1) !important;
}

.waitlist-dialog[open]::backdrop {
  animation: waitlist-fade .3s ease !important;
}

@keyframes waitlist-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.98);
  }
}

@keyframes waitlist-fade {
  from {
    opacity: 0;
  }
}

.waitlist-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}

.waitlist-close::after {
  content: '';
  position: absolute;
  inset: -4px; /* 44px to tap */
}

.waitlist-close:hover {
  background: rgb(31 21 17 / .06);
}

.waitlist-title {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.01em;
}

.waitlist-intro {
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.625;
  color: rgb(31 21 17 / .72);
}

.waitlist-form {
  margin-top: 32px;
}

.popup-fields {
  display: flex;
  align-items: center;
  gap: 5px;
}

.popup-input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--espresso);
  background: transparent;
  color: var(--espresso);
  font: inherit;
  font-size: 16px; /* under 16px, iPhones zoom in on focus */
}

.popup-input:focus {
  outline: none;
}

.popup-input::placeholder {
  color: rgb(31 21 17 / .55);
}

.popup-submit {
  flex-shrink: 0;
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.popup-submit span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 3px;
  background: var(--espresso);
  color: var(--sand);
  transition: transform .15s cubic-bezier(.4, 0, .2, 1) !important;
}

.popup-submit:hover span {
  transform: translateX(4px);
}

.popup-submit:disabled {
  opacity: .5;
  cursor: progress;
}

.popup-consent {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.625;
  color: rgb(31 21 17 / .7);
}

.popup-consent a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.popup-consent a:hover {
  color: var(--espresso);
}

.popup-message {
  font-size: 15px;
}

.popup-message:focus {
  outline: none;
}

@media (min-width: 768px) {
  .waitlist-title {
    font-size: 40px;
  }
}

@media (max-width: 480px) {
  .waitlist-dialog {
    padding: 40px 24px 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .waitlist-dialog[open],
  .waitlist-dialog[open]::backdrop,
  .popup-submit span {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Parts (product page): an exploded view of the product ----------
   The one scroll animation on these pages: while the visitor scrolls through a tall "runway", the drawing stays
   pinned under the header and the product photo comes apart into its parts (transform and opacity only), driven by native CSS
   scroll-driven animations. No JavaScript, normal scrolling. Without support, or with reduced motion,
   there is no runway or pinning and the photo shows still, already apart. */
.parts {
  grid-column: 1 / -1;
  margin-top: 32px;
}

@media (min-width: 1024px) {
  .parts {
    margin-top: 64px; /* with the 32px row gap: 96px under the tabs */
  }
}

.parts-runway {
  margin-top: 32px;
}

.parts-stage {
  display: grid;
  place-items: center;
}

/* As wide as fits: the full width, or less, so the whole drawing fits under the header */
.parts-figure {
  width: min(100%, calc((100svh - 56px - 64px) * var(--ratio, 1)));
}

/* The product photo, cut into layers that stack back into the photo. Each layer sits where it was in the photo
   and, by default (no animation), where it ends up when apart; the animation starts it in place. */
.xp {
  position: relative;
  container-type: inline-size; /* cqw below: % of this stage's width */
}

.xp-layer {
  position: absolute;
  height: auto;
  max-width: none;
  user-select: none;
  pointer-events: none;
  transform: translate(calc(var(--dx) * 1cqw), calc(var(--dy) * 1cqw));
}

/* Hover label: the piece's letter and name from the manual's parts list, beside the pointer (exploded.js) */
.xp-label {
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--hairline);
  border-radius: 4px;
  background: var(--parchment);
  color: var(--espresso);
  font-size: 13px;
  line-height: 16px;
  white-space: nowrap;
  pointer-events: none;
}

.xp-label[hidden] {
  display: none;
}

.xp-count {
  color: var(--walnut);
}

.xp-count[hidden] {
  display: none;
}

.xp-letter {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--espresso);
  color: var(--sand);
  font-weight: 600;
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* The runway: its extra height is the scrolling during which the drawing stays pinned */
    .parts-runway {
      height: 180vh;
      view-timeline: --parts block;
      view-timeline-inset: 56px 0; /* the fixed header */
    }

    .parts-stage {
      position: sticky;
      top: 56px;
      height: calc(100svh - 56px);
    }

    /* Assembled at the start, apart by about 85% of the pinned scrolling; parts start a little one after another */
    .parts .xp-layer {
      animation: xp-apart cubic-bezier(.45, 0, .25, 1) both !important;
      animation-timeline: --parts !important;
      animation-range: contain calc(8% + var(--start)) contain calc(72% + var(--start)) !important;
    }
  }

  @media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
    .parts-runway {
      height: 140vh;
    }
  }
}

@keyframes xp-apart {
  from {
    transform: translate(0, 0);
  }

  to {
    transform: translate(calc(var(--dx) * 1cqw), calc(var(--dy) * 1cqw));
  }
}
