/*
 * Product page (product.html) — gallery, buying panel, size guide,
 * "Wear it with" and the phone-only add-to-bag bar.
 * Shared components (buttons, chips, care label, accordion, modal) live in styles.css.
 *
 * Layout
 *   < 600px    photos are a swipeable strip, edge to edge; panel underneath
 *   600–899px  photos two-up; panel underneath
 *   900px +    photos stacked on the left (7/12), panel sticky on the right (5/12)
 */

body[data-page='product'] {
  --pdp-bar-h: calc(73px + env(safe-area-inset-bottom, 0px));
}

.pdp__layout {
  display: grid;
  gap: var(--s-5);
  align-items: start;
}

/* ---------------------------------------------------------------- gallery */

.pdp-gallery {
  position: relative;
  min-width: 0;
}
.pdp-gallery__track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pdp-gallery__track::-webkit-scrollbar {
  display: none;
}
.pdp-gallery__track:focus-visible {
  outline-offset: -3px;
}
.pdp-gallery__slide {
  position: relative;
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.pdp-gallery__frame {
  display: block;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--stone);
}
.pdp-gallery__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pdp-gallery__index {
  display: none;
}

/* Counter and arrows sit over the bottom of the photo. */
.pdp-gallery__controls {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: var(--s-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  pointer-events: none;
}
.pdp-gallery__controls > * {
  pointer-events: auto;
}
.pdp-gallery__count {
  padding: 6px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--chalk) 88%, transparent);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}
.pdp-gallery__nav {
  display: flex;
  gap: var(--s-2);
}
.pdp-gallery__btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--chalk) 88%, transparent);
  color: var(--ink);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.pdp-gallery__btn:hover {
  background: var(--white);
}
.pdp-gallery__btn:disabled {
  opacity: 0.38;
  cursor: default;
  background: color-mix(in srgb, var(--chalk) 88%, transparent);
}
.pdp-gallery__btn .icon {
  width: 18px;
  height: 18px;
}

/* Phones: the strip runs edge to edge. */
@media (max-width: 599.98px) {
  .pdp-gallery {
    margin-inline: calc(var(--gutter) * -1);
  }
}

/* Tablets: two-up, nothing to swipe. */
@media (min-width: 600px) {
  .pdp-gallery__track {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-2);
    overflow: visible;
  }
  .pdp-gallery__slide:only-child {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 560px;
    justify-self: center;
  }
  .pdp-gallery__controls {
    display: none;
  }
  .pdp__layout {
    padding-top: var(--s-5);
    gap: var(--s-6);
  }
}

/* --------------------------------------------------------------- 900px + */

@media (min-width: 900px) {
  .pdp__layout {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    column-gap: clamp(32px, 4.5vw, 72px);
  }
  .pdp-gallery__track {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-2);
  }
  .pdp-gallery__slide:only-child {
    max-width: none;
  }
  /* A small mono number in the corner of each photo, like a swing tag. */
  .pdp-gallery__index {
    display: block;
    position: absolute;
    left: var(--s-4);
    bottom: var(--s-4);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--graphite);
  }
  /*
   * Sticky beside the photos. If the panel is taller than the screen, the
   * negative top (from --pdp-info-h, set by product.js) makes it scroll first
   * and then stick by its bottom edge.
   */
  .pdp-info {
    position: sticky;
    top: calc(var(--header-h) + 24px);
    top: min(calc(var(--header-h) + 24px), calc(100vh - var(--pdp-info-h, 0px) - 24px));
  }
}

/* ------------------------------------------------------------ info panel */

.pdp-info {
  min-width: 0;
}
.pdp-crumbs {
  margin-top: -4px;
  margin-bottom: var(--s-3);
}
/* A taller hit area for the small mono links, kept on one baseline. */
.pdp-crumbs a,
.pdp-crumbs [aria-current='page'] {
  display: inline-block;
  padding-block: 4px;
}
.pdp-crumbs [aria-current='page'] {
  color: var(--ink);
}
.pdp-badge {
  margin-bottom: var(--s-3);
}
/* Product names run long, so a little narrower than the page titles. */
.pdp-title {
  font-size: clamp(1.75rem, 1.15rem + 1.6vw, 2.5rem);
  font-stretch: 116%;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.012em;
  line-height: 1;
  text-wrap: balance;
}
.pdp-price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  margin-top: var(--s-4);
}
.pdp-price {
  font-size: var(--fs-lg);
  line-height: 1.2;
}
.pdp-spec {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
}
.pdp-summary {
  margin-top: var(--s-3);
  max-width: 48ch;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* ------------------------------------------------------------ buying form */

.pdp-buy {
  display: grid;
  gap: var(--s-5);
  margin-top: var(--s-5);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
}
.pdp-option {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
/* Floated so it lays out like a normal block (a rendered legend sits on the
   fieldset border, which throws off the size guide button beside it). */
.pdp-option__legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: var(--s-2);
  font-size: var(--fs-sm);
  line-height: 24px;
}
.pdp-option__label {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
}
.pdp-option__value {
  margin-left: 2px;
  font-weight: 600;
  color: var(--ink);
}

/* Colour */
.pdp-swatches {
  clear: both;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-left: -6px; /* line the swatch, not its 44px ring, up with the text */
}
.pdp-swatch {
  position: relative;
  display: inline-grid;
}
.pdp-swatch input:checked + .swatch-btn,
.pdp-swatch--static {
  border-color: var(--ink);
}
.pdp-swatch input:focus-visible + .swatch-btn {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}
.pdp-swatch .swatch-btn:hover {
  border-color: var(--graphite);
}
.pdp-swatch--static {
  cursor: default;
}

/* Size */
.pdp-guide-btn {
  position: absolute;
  z-index: 1;
  top: -10px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.pdp-guide-btn:hover {
  color: var(--cobalt);
}
.pdp-guide-btn .icon {
  width: 18px;
  height: 18px;
}
.pdp-size-error {
  clear: both;
}
.pdp-size-error .field__error {
  margin-bottom: var(--s-3);
  font-weight: 600;
}
.pdp-size-error .field__error .icon {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}
.pdp-size-grid {
  clear: both;
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  gap: var(--s-2);
}
.pdp-size {
  position: relative;
  display: grid;
  min-width: 0;
}
.pdp-size .chip {
  min-width: 0;
  width: 100%;
  min-height: 48px;
  padding: 0 4px;
}
.pdp-size input:checked + .chip {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}
.pdp-size input:focus-visible + .chip {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}
.pdp-size input:disabled + .chip {
  color: var(--graphite);
  background: var(--chalk);
  background-image: linear-gradient(to top right, transparent calc(50% - 0.5px), var(--line) 50%, transparent calc(50% + 0.5px));
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.7;
}
.pdp-sizes.is-invalid .pdp-size input:not(:disabled) + .chip {
  border-color: var(--error);
}
.pdp-fitnote {
  margin-top: var(--s-3);
  font-size: var(--fs-sm);
  color: var(--graphite);
  text-wrap: pretty;
}

/* Quantity + add to bag, then save */
.pdp-cta {
  display: grid;
  gap: var(--s-2);
}
.pdp-actions {
  display: flex;
  gap: var(--s-2);
}
.pdp-qty {
  flex: none;
}
.pdp-qty button {
  width: 44px;
  height: 54px;
}
.pdp-qty .qty__value {
  min-width: 28px;
}
.pdp-add {
  flex: 1 1 auto;
  min-width: 0;
}
.pdp-add__label {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.pdp-add.is-added,
.pdp-bar__btn.is-added {
  --btn-bg: var(--cobalt);
  --btn-border: var(--cobalt);
}
.pdp-soldout-note {
  font-size: var(--fs-sm);
  color: var(--graphite);
}
.pdp-save .icon {
  transition: fill var(--dur-fast) var(--ease);
}
.pdp-save[aria-pressed='true'] .icon {
  fill: currentColor;
}
.pdp-save[aria-pressed='true']:not(:hover) {
  color: var(--cobalt);
}

/* ----------------------------------------------- delivery, care, details */

.pdp-facts {
  display: grid;
  margin-top: var(--s-5);
  padding: 0;
  list-style: none;
}
.pdp-fact {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: var(--s-3);
  align-items: start;
  padding-block: 8px;
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.pdp-fact .icon {
  color: var(--graphite);
}
.pdp-fact__title {
  display: block;
  font-weight: 600;
}
.pdp-fact__text {
  display: block;
  color: var(--graphite);
}
.pdp-fact a {
  color: var(--ink);
}
.pdp-fact a:hover {
  color: var(--cobalt);
}

.pdp-care {
  margin-top: var(--s-6);
}
.pdp-care__list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.pdp-care__fabric {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
  font-weight: 500;
}
.pdp-care__style {
  margin-top: var(--s-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
}

.pdp-desc {
  margin-top: var(--s-6);
  color: var(--ink-soft);
  text-wrap: pretty;
}
.pdp-accordions {
  margin-top: var(--s-5);
}
.pdp-guide-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-top: var(--s-1);
  font-weight: 600;
}
.pdp-guide-link .icon {
  width: 18px;
  height: 18px;
}
.pdp-acc-ship > * + * {
  margin-top: var(--s-3);
}
.pdp-ship__head {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
}
.pdp-acc-ship .pdp-ship {
  margin-top: var(--s-2);
  padding: 0;
  list-style: none;
  font-size: var(--fs-sm);
}
.pdp-acc-ship .pdp-ship li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px var(--s-4);
  margin: 0;
  padding-block: 8px;
  border-top: 1px solid var(--line);
}
.pdp-acc-ship .pdp-ship li:last-child {
  border-bottom: 1px solid var(--line);
}
.pdp-ship__method {
  font-weight: 600;
  color: var(--ink);
}

/* ------------------------------------------------------------- size guide */

.pdp-guide .modal__body {
  gap: var(--s-5);
}
.pdp-guide .table caption {
  caption-side: top;
  padding-bottom: var(--s-3);
  text-align: left;
  font-weight: 700;
  color: var(--ink);
}
.pdp-guide__unit {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite);
}
.pdp-guide .table th,
.pdp-guide .table td {
  padding: 10px;
}
.pdp-guide .table tbody tr {
  background: var(--white);
}
.pdp-guide .table tbody tr.is-selected {
  background: var(--cobalt-tint);
}
.pdp-guide .table tbody tr.is-selected th {
  color: var(--cobalt-deep);
}
.pdp-guide__note {
  margin-top: calc(var(--s-3) - var(--s-5));
  font-size: var(--fs-sm);
  color: var(--graphite);
}
.pdp-guide__block {
  display: grid;
  gap: var(--s-2);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}
.pdp-guide__h {
  font-size: var(--fs-base);
  color: var(--ink);
}

/* ---------------------------------------------------------- wear it with */

.pdp-related {
  padding-bottom: 0; /* the footer's top margin does the spacing */
}

.pdp-related__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-2) var(--s-5);
  margin-bottom: var(--s-6);
}
.pdp-related__head .eyebrow {
  flex: 1 0 100%;
}
.pdp-more {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 44px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.pdp-more span {
  display: inline-grid;
}
.pdp-more .icon {
  width: 18px;
  height: 18px;
  transition: transform var(--dur-fast) var(--ease);
}
.pdp-more:hover .icon {
  transform: translateX(3px);
}

/* Phones: a swipeable row that peeks the next card. */
@media (max-width: 599.98px) {
  .pdp-related__cards {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 44%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    overscroll-behavior-x: contain;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    scrollbar-width: none;
  }
  .pdp-related__cards::-webkit-scrollbar {
    display: none;
  }
  .pdp-related__cards > * {
    scroll-snap-align: start;
  }
}
@media (min-width: 600px) and (max-width: 899.98px) {
  .pdp-related__cards {
    grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  }
}
/* 900px +: the heading takes the first column, the cards fill the rest. */
@media (min-width: 900px) {
  .pdp-related__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s-7) var(--s-5);
    align-items: start;
  }
  .pdp-related__cards {
    display: contents;
  }
  .pdp-related__head {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: var(--s-3);
    margin: 0;
    padding-right: var(--s-5);
  }
  .pdp-related__head .eyebrow {
    flex: none;
  }
}

/* --------------------------------------------- phone add-to-bag bar */

.pdp-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: var(--s-3) var(--gutter) calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--chalk) 95%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--line);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
}
.pdp-bar.is-visible {
  transform: none;
  visibility: visible;
  transition: transform var(--dur) var(--ease), visibility 0s;
}
.pdp-bar__inner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.pdp-bar__text {
  flex: 1 1 auto;
  min-width: 0;
}
.pdp-bar__name {
  overflow: hidden;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.pdp-bar__meta {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite);
  white-space: nowrap;
}
.pdp-bar__btn {
  flex: none;
}
body.pdp-has-bar {
  padding-bottom: var(--pdp-bar-h);
}
body.pdp-has-bar .toast-region {
  bottom: calc(var(--pdp-bar-h) + 12px);
}
@media (min-width: 900px) {
  .pdp-bar {
    display: none;
  }
}

/* --------------------------------------------------------------- loading */

.pdp-skel {
  display: grid;
}
.pdp-skel__line {
  display: block;
}
.pdp-skel__title {
  height: 34px;
  margin-top: var(--s-4);
}
.no-js .pdp .skeleton {
  animation: none;
}
.pdp-noscript {
  margin-top: var(--s-5);
  color: var(--graphite);
}

/* ------------------------------------------------------------- not found */

.pdp-missing {
  padding-top: clamp(40px, 6vw, 80px);
}
.pdp-missing__head {
  display: grid;
  justify-items: start;
  gap: var(--s-4);
  padding-bottom: clamp(40px, 6vw, 72px);
  border-bottom: 1px solid var(--line);
}
.pdp-missing__head > * {
  max-width: 680px;
}
.pdp-missing__head .lede {
  margin: 0;
}
.pdp-missing__head .btn {
  margin-top: var(--s-2);
}
.pdp-missing__label {
  margin: var(--s-6) 0 var(--s-5);
}
