/* ==========================================================================
   VELUNE — product.css
   Product detail page. Loads after style.css and reuses its tokens,
   navbar, switch, product card, footer and reveal styles.
   ========================================================================== */

.page-product {
  --bar-h: 64px;
  --nav-offset: 0px;            /* becomes the nav height while the nav is shown */
  --stick: calc(var(--nav-offset) + var(--bar-h));
}
html.nav-shown .page-product { --nav-offset: var(--nav-h); }

@media (min-width: 900px) {
  .page-product { --bar-h: 84px; }
}

/* ---------- 1. Hero (pinned behind the content that follows) ---------- */
.pd-stack { position: relative; }

.pd-hero {
  position: sticky;
  top: 0;
  z-index: 0;
  height: calc(100vh - var(--bar-h));
  height: calc(100svh - var(--bar-h));
  padding-top: var(--nav-h);
  background: var(--bg);
  transition: background-color 1.4s var(--ease-soft);
}
.pd-hero__media {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #E9E4D8;
}
.pd-hero__frame {
  position: absolute;
  inset: 0;
  transform: scale(var(--cover, 1));
  transform-origin: 50% 40%;
  will-change: transform;
}
.pd-hero__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, 50% 50%);
}

/* Fades toward the page colour as the details slide over it (driven by JS) */
.pd-hero__shade {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--bg);
  opacity: var(--shade, 0);
  pointer-events: none;
}

/* Night view: the lit photo crossfades over the day photo */
.pd-hero__frame picture { display: contents; }
.pd-hero.is-lit { background: var(--night); }
.js .pd-hero__frame img.pd-hero__night,
.pd-hero__night {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1.4s var(--ease-soft), transform 2.6s var(--ease-out);
}
.pd-hero.is-lit .pd-hero__frame img.pd-hero__night { opacity: 1; }

/* Switch sits inside the hero instead of being fixed to the screen */
.switch--hero {
  position: absolute;
  z-index: 4;
  top: auto;
  right: 0;
  bottom: 16px;
}
@media (min-width: 900px) {
  .switch--hero {
    top: 50%;
    bottom: auto;
    margin-top: -30px;
  }
}

/* ---------- 2. Product bar ---------- */
.pd-bar {
  position: sticky;
  top: var(--nav-offset);
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto;
  height: var(--bar-h);
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  transition: top 0.7s var(--ease-io);
}
.pd-bar__title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-left: var(--gutter);
}
.pd-bar__back {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: -6px;
  transition: transform 0.6s var(--ease-out);
}
.pd-bar__back svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
}
.pd-bar__back:hover { transform: translateX(-4px); }

.pd-bar__name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 3vw, 44px);
  line-height: 1;
  white-space: nowrap;
}

.pd-bar__mid {
  display: none;
}
.pd-bar__price {
  font-family: var(--serif);
  font-size: clamp(20px, 2.2vw, 32px);
  line-height: 1;
}

.pd-bar__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--serif);
  font-size: clamp(13px, 1.4vw, 20px);
  text-transform: uppercase;
  white-space: nowrap;
  transition: background-color 0.6s ease;
}
.pd-bar__cta:hover { background: #3a3835; }
.pd-bar__cta:focus-visible { outline-color: var(--cream); outline-offset: -6px; }

/* + icon that turns into a check when added */
.pd-bar__cta-icon {
  position: relative;
  width: 14px;
  height: 14px;
}
.pd-bar__cta-icon::before,
.pd-bar__cta-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 1px;
  background: currentColor;
  transition: transform 0.6s var(--ease-io), width 0.6s var(--ease-io);
}
.pd-bar__cta-icon::before { transform: translate(-50%, -50%); }
.pd-bar__cta-icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.pd-bar__cta.is-added .pd-bar__cta-icon::before {
  width: 6px;
  transform: translate(-90%, 60%) rotate(45deg);
}
.pd-bar__cta.is-added .pd-bar__cta-icon::after {
  width: 12px;
  transform: translate(-35%, -20%) rotate(-50deg);
}

/* Mobile bar: name | price | compact button */
@media (max-width: 699px) {
  .pd-bar { grid-template-columns: minmax(0, 1fr) auto auto; }
  .pd-bar__mid {
    display: flex;
    align-items: center;
    padding: 0 14px;
  }
  .pd-bar__material { display: none; }
  .pd-bar__cta { gap: 10px; padding: 0 16px; }
}

@media (min-width: 700px) {
  .pd-bar {
    grid-template-columns: 450fr 670fr 300fr;
  }
  .pd-bar__mid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-right: var(--gutter);
  }
  .pd-bar__material {
    font-size: var(--fs-small);
    color: var(--muted);
  }
  .pd-bar__cta-icon,
  .pd-bar__cta-icon::before,
  .pd-bar__cta-icon::after { width: 16px; }
}

/* ---------- 3. Details: text locked, gallery scrolls ---------- */
.pd-detail {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 40px;
  padding: 24px 0 clamp(100px, 14vw, 200px);
  background: var(--bg);
}

/* Mobile: gallery is a horizontal swipe, info sits below */
.pd-gallery {
  order: -1;
  display: flex;
  gap: 10px;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--gutter);
  scrollbar-width: none;
}
.pd-gallery::-webkit-scrollbar { display: none; }
.pd-shot {
  flex: 0 0 82%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  scroll-snap-align: start;
  background: #D9D9D9;
}
.pd-shot--placeholder { background: #DCD8CF; }

.pd-info {
  display: grid;
  gap: 40px;
  padding: 0 var(--gutter);
}
.pd-desc p {
  max-width: 350px;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--muted);
}
.pd-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 20px;
  margin: 0;
}
.pd-specs dt { margin-bottom: 8px; }
.pd-specs dd {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink);
}

/* Tablet: gallery left, info locked on the right */
@media (min-width: 700px) {
  .pd-detail {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 0 clamp(32px, 5vw, 64px);
    padding: clamp(48px, 5.9vw, 85px) var(--gutter) clamp(120px, 14vw, 200px);
  }
  .pd-gallery {
    order: 0;
    grid-column: 1;
    grid-row: 1;
    display: grid;
    gap: 12px;
    padding: 0;
    overflow: visible;
  }
  .pd-shot { aspect-ratio: auto; }
  .pd-shot--tall { aspect-ratio: 500 / 585; }
  .pd-shot--wide { aspect-ratio: 500 / 352; }

  .pd-info {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: calc(var(--stick) + 40px);
    padding: 0;
    transition: top 0.7s var(--ease-io);
  }
  .pd-specs { grid-template-columns: 1fr; }
}

/* Desktop: description left (centred in the locked view), gallery centre, specs right */
@media (min-width: 1100px) {
  .pd-detail {
    grid-template-columns: 450fr 500fr 100fr 350fr;
    gap: 0;
  }
  .pd-info { display: contents; }
  .pd-gallery { grid-column: 2; }

  .pd-desc {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: var(--stick);
    display: flex;
    align-items: center;
    height: calc(100vh - var(--stick));
    height: calc(100svh - var(--stick));
    margin-top: calc(-1 * clamp(48px, 5.9vw, 85px));
    transition: top 0.7s var(--ease-io), height 0.7s var(--ease-io);
  }
  .pd-specs {
    grid-column: 4;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: var(--stick);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 22px;
    height: calc(100vh - var(--stick));
    height: calc(100svh - var(--stick));
    margin-top: calc(-1 * clamp(48px, 5.9vw, 85px));
    transition: top 0.7s var(--ease-io), height 0.7s var(--ease-io);
  }
  .pd-specs dd { font-size: 14px; }
}

/* ---------- 4. More details ---------- */
.pd-more {
  display: grid;
  gap: 48px;
  padding: clamp(80px, 8vw, 115px) var(--gutter) clamp(100px, 13vw, 190px);
  border-top: 1px solid var(--line);
}
.acc { border-top: 1px solid rgba(42, 42, 42, 0.7); }
.acc__item { border-bottom: 1px solid rgba(42, 42, 42, 0.7); }
.acc h3 { margin: 0; font: inherit; }
.acc__btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 22px 0;
  text-align: left;
}
.acc__btn .label { font-size: clamp(14px, 1.25vw, 18px); }

.acc__icon {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  transition: transform 0.7s var(--ease-io);
}
.acc__icon::before,
.acc__icon::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background: currentColor;
}
.acc__icon::after { transform: rotate(90deg); }
.acc__item.is-open .acc__icon { transform: rotate(135deg); } /* plus → × */

.acc__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.8s var(--ease-io);
}
.acc__item.is-open .acc__panel { grid-template-rows: 1fr; }
.acc__inner {
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.acc__item.is-open .acc__inner {
  opacity: 1;
  transition: opacity 0.8s ease 0.2s;
}
.acc__inner ul {
  list-style: disc;
  padding: 0 0 26px 1.7em;
  color: var(--muted);
  font-size: var(--fs-small);
  line-height: 1.6;
}
.acc__link {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-underline-offset 0.4s var(--ease-out);
}
.acc__link:hover { text-underline-offset: 5px; }

@media (min-width: 900px) {
  .pd-more {
    grid-template-columns: 900fr 500fr;
    gap: 0;
    align-items: start;
  }
  /* Repaint fix: solid backgrounds stop ghost lines while the accordion animates */
  .pd-more,
  .pd-also {
    position: relative;
    z-index: 1;
    background: var(--bg);
    transform: translateZ(0);
  }
}

/* ---------- 5. You may also like ---------- */
.pd-also {
  padding: clamp(80px, 13vw, 190px) 0 clamp(60px, 6vw, 90px);
  border-top: 1px solid var(--line);
}
.pd-also__title {
  text-align: center;
  padding: 0 var(--gutter);
}
.pd-also__grid {
  display: flex;
  gap: 10px;
  margin-top: clamp(40px, 5.9vw, 85px);
  padding: 0 var(--gutter);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--gutter);
  scrollbar-width: none;
}
.pd-also__grid::-webkit-scrollbar { display: none; }
.pd-also__grid .product {
  flex: 0 0 78%;
  scroll-snap-align: start;
}
.pd-also__grid .product__media { aspect-ratio: 460 / 600; }
.pd-also__grid .product__meta { padding: 0 clamp(4px, 1.4vw, 20px); }

@media (min-width: 700px) {
  .pd-also__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow: visible;
  }
}

/* ==========================================================================
   6. Motion states
   ========================================================================== */

/* Hero intro after the page transition opens */
.js .pd-hero__frame img {
  transform: scale(1.18);
  transition: transform 2.6s var(--ease-out);
}
.js .pd-bar > * {
  transform: translateY(100%);
  opacity: 0;
  transition: transform 1.2s var(--ease-io), opacity 0.8s ease;
}
.js .pd-bar > :nth-child(2) { transition-delay: 0.1s; }
.js .pd-bar > :nth-child(3) { transition-delay: 0.2s; }

.js.is-loaded .pd-hero__frame img { transform: none; }
.js.is-loaded .pd-bar > * { transform: none; opacity: 1; }

/* Gallery shots rise in from the bottom */
.js [data-reveal="rise"] {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1.8s var(--ease-io);
}
.js [data-reveal="rise"] .zoom {
  transform: scale(1.2);
  transition: transform 2.2s var(--ease-io);
}
.js .is-in[data-reveal="rise"] { clip-path: inset(0 0 0 0); }
.js .is-in[data-reveal="rise"] .zoom { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .pd-hero { position: relative; height: auto; aspect-ratio: 16 / 9; }
}
