/* The product page (/produkt/<slug>/), with its own narrower-screen blocks. */

@layer pages {
  /* The warm tone above 768px, the cool tone up to 768px, where every accent but the buy button turns link blue by the
     tone alone. The narrower-screen blocks at the end hold the carousel (below 1024px) and the whole phone variant. */

  .kl__product { padding: 8px 0 24px; }
  .kl__product-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(40px, 4.4vw, 64px); align-items: start; }

  /* Gallery: 4:5 photos two by two, 6px apart; below 1024px the same slides become a swiped carousel with dots. */
  /* --slide-aspect is width over height; the landscape-tablet carousel width multiplies by it (never divides: the
     value is the two tokens "4 / 5"). */
  .kl__product-gallery { --slide-aspect: 4 / 5; position: relative; min-width: 0; }
  .kl__product-slides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .kl__product-slide { position: relative; margin: 0; aspect-ratio: var(--slide-aspect); overflow: hidden; border-radius: var(--radius-media); background: var(--sky); }
  .kl__product-img, .kl__product-gift { display: block; width: 100%; height: 100%; object-fit: cover; }
  /* Each photo is a link that photo_zoom_controller.js opens full screen; the slide clips an outline drawn outside. */
  .kl__photo-zoom { display: block; height: 100%; cursor: zoom-in; }
  .kl__photo-zoom:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
  /* PhotoSwipe's viewer lies in <body>, outside .kl — the reset of .kl (img { max-width: 100% }) would cut its zoomed
     photo — so it takes no brand token and its counter would otherwise fall back to the browser's serif. */
  .pswp { font-family: system-ui, sans-serif; } /* literal: PhotoSwipe's viewer lies outside the brand's roots */
  /* A product without a photo: the placeholder of its catalogue tile, filling the slide. */
  .kl__product-slide .kl__tile-placeholder { height: 100%; }
  .kl__product-dots { display: none; }
  /* Rendered hidden: gallery_controller.js shows the dots, which do nothing without it (the track still swipes). */
  .kl__product-dots[hidden] { display: none; }

  /* The purchase column stays 24px under the top of the window while it is shorter than the window. */
  .kl__product-info { position: sticky; top: calc(var(--nav-stuck) + 24px); display: flex; flex-direction: column; min-width: 0; padding-top: 8px; }
  .kl__product-head { display: flex; flex-direction: column; }
  .kl__product-heading { display: flex; flex-direction: column; gap: 8px; }
  .kl__product-eyebrow { font-size: var(--text-xs); color: var(--link); }
  .kl__product-title { margin: 0; font-family: var(--font-display); font-weight: var(--weight-regular); font-size: var(--heading-3xl); line-height: 1.1; color: var(--ink); text-wrap: balance; }
  /* „z kamieniem księżycowym” — the stones of the bracelet (Product#subtitle). */
  .kl__product-subtitle { margin: 0; font-size: var(--text-base); line-height: normal; color: var(--muted); }
  .kl__product-price { margin: 26px 0 0; font-size: var(--heading-xl); line-height: normal; color: var(--ink); }
  /* The automatic promotion that lowered the price, named under the Omnibus line. */
  .kl__product-promotion { margin: 6px 0 0; font-size: var(--text-sm); color: var(--accent); }

  /* The product's series (products/_series): its name and story over a row of 4:5 thumbnails of its bracelets, the
     product's own ringed in ink. Wraps to more rows rather than scrolling: a series is a handful of bracelets. */
  .kl__product-family { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
  .kl__product-family-head { display: flex; align-items: baseline; gap: 8px; margin: 0; }
  .kl__product-family-label { font-size: var(--text-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--muted); }
  .kl__product-family-name { font-family: var(--font-serif); font-size: var(--heading-sm); line-height: 1.2; color: var(--ink); }
  .kl__product-family-text { margin: 6px 0 0; font-size: var(--text-md); line-height: 1.5; color: var(--muted); }
  .kl__product-family-list { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 0; padding: 0; }
  .kl__product-family-item { display: block; width: 64px; padding: 2px; border: 1px solid transparent; border-radius: var(--radius-media); transition: border-color var(--duration-base) var(--ease-standard); }
  .kl__product-family-item:hover { border-color: var(--line); }
  .kl__product-family-item[aria-current="page"] { border-color: var(--ink); }
  .kl__product-family-item:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
  .kl__product-family-img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius-media); background: var(--sky); }

  /* The buy button (or the note why it is missing) across the column, the designer's link centred under it. The price
     inside the buy button shows on a phone only; the button is a block, so the label and the price run as one line of
     text instead of two flex items apart. */
  .kl__product-cta { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 24px; }
  .kl__product-cta .ms-button { display: block; width: 100%; line-height: normal; }
  .kl__product-cta .ms-button--primary { padding: 18px; font-size: var(--text-lg); letter-spacing: var(--tracking-wide); }
  .kl__product-buy-price { display: none; }
  .kl__product-designer { font-size: var(--text-md); text-underline-offset: 4px; }
  /* The payment marks between the highlights and the sections (products/_payment_logos), under a small caps label, on
     one line aligned left with the highlights' text. Equal heights would not look equal: the Visa wordmark is a thin,
     wide line beside the BLIK tile and the Mastercard circles, so it is lower. */
  .kl__product-payments { margin-top: 28px; }
  .kl__product-payments-label { margin: 0 0 12px; font-size: var(--text-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--muted); }
  .kl__product-payments-list { list-style: none; display: flex; align-items: center; justify-content: flex-start; gap: 20px; margin: 0; padding: 0; }
  .kl__product-payments-list li { display: flex; }
  .kl__product-payment { display: block; width: auto; height: 24px; }
  .kl__product-payment--visa { height: 15px; }
  .kl__product-note {
    align-self: stretch;
    margin: 0;
    padding: 14px 18px;
    border-radius: var(--radius-panel);
    border: 1px solid color-mix(in srgb, var(--tone) 18%, transparent);
    background: var(--mist);
    font-size: var(--text-base);
    line-height: 1.55;
    color: var(--ink-soft);
  }

  /* The highlights: rows between hairlines, each a button opening its popup (products/_highlights). */
  .kl__product-perks { list-style: none; margin: 28px 0 0; padding: 0; border-top: 1px solid var(--line); }
  .kl__product-perks > li { border-bottom: 1px solid var(--line); }
  .kl__product-perk { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 15px 0; border: 0; background: none; font: inherit; font-size: var(--text-base); line-height: normal; text-align: left; color: var(--ink); cursor: pointer; transition: color var(--duration-fast) var(--ease-standard); }
  .kl__product-perk::after {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-top: 1.5px solid var(--tone);
    border-right: 1.5px solid var(--tone);
    transform: rotate(45deg);
    transition: transform var(--duration-base) var(--ease-standard);
  }
  .kl__product-perk:hover { color: var(--tone); }
  .kl__product-perk:hover::after { transform: translateX(2px) rotate(45deg); }

  /* A highlight's popup: a sheet in the middle of the window over a scrim; the browser keeps it in the top layer. */
  .kl__product-popup {
    width: min(480px, calc(100vw - 32px));
    max-height: min(80vh, 640px);
    margin: auto;
    padding: 24px 28px 28px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    background: var(--paper);
    box-shadow: var(--shadow-xl);
    color: var(--ink);
  }
  .kl__product-popup::backdrop { background: var(--scrim); }
  .kl__product-popup-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
  .kl__product-popup-title { margin: 0; font-family: var(--font-sans); font-weight: var(--weight-regular); font-size: var(--heading-sm); line-height: 1.3; }
  .kl__product-popup-close {
    flex: none;
    width: 36px;
    height: 36px;
    margin: -6px -10px 0 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: none;
    font: inherit;
    font-size: var(--heading-md);
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
  }
  .kl__product-popup-close:hover { color: var(--tone); }
  .kl__product-popup-body { display: flex; flex-direction: column; gap: 12px; }
  .kl__product-popup-body p { margin: 0; font-weight: var(--weight-light); font-size: var(--text-base); line-height: 1.7; color: var(--ink-soft); text-wrap: pretty; }
  .kl__product-shipping { margin: 0; padding-left: 1.2em; font-weight: var(--weight-light); font-size: var(--text-base); line-height: 1.7; color: var(--ink-soft); }

  /* Details: an accordion of <details> sharing one name, so opening one closes the others (no JS needed;
     accordion_controller.js animates the switch). */
  .kl__product-details { margin-top: 32px; border-top: 1px solid var(--line); }
  .kl__disclosure { border-bottom: 1px solid var(--line); }
  .kl__disclosure-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 20px 0;
    list-style: none;
    cursor: pointer;
    font-size: var(--text-sm);
    line-height: normal;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--ink);
  }
  .kl__disclosure-summary::-webkit-details-marker { display: none; }
  .kl__disclosure-summary::after {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    border-right: 1.5px solid var(--ink);
    border-bottom: 1.5px solid var(--ink);
    transform: rotate(45deg);
    /* In step with the section sliding open and shut (accordion_controller.js). */
    transition: transform var(--duration-slow) var(--ease-decelerate);
  }
  /* A section sliding shut keeps [open] until it is closed, without its name meanwhile (accordion_controller.js). */
  .kl__disclosure[open]:not([data-accordion-name]) > .kl__disclosure-summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
  .kl__disclosure-summary:hover { color: var(--tone); }
  .kl__disclosure-body { display: flex; flex-direction: column; gap: 14px; padding: 0 0 22px; container-type: inline-size; }
  .kl__disclosure-body p { margin: 0; font-weight: var(--weight-light); font-size: var(--text-base); line-height: 1.75; color: var(--ink-soft); text-wrap: pretty; }
  /* The owner's safety warnings are long sentences that read ragged at the right edge, so they are justified,
     hyphenated to keep the word gaps even. A column narrower than about 50 characters (a phone's, the tablet's
     two-column layout) gapes even with hyphens: there they stay ragged. So does the manufacturer's line — a company
     name in capitals hyphenates and gapes. */
  .kl__safety-bullet { display: inline-block; width: 0.9em; }
  @container (min-width: 400px) {
    .kl__safety-information { text-align: justify; -webkit-hyphens: auto; hyphens: auto; }
  }

  /* The composition: the cord, then every part with its count — two columns, the counts in the narrow second one,
     which is as wide as the cord's description (the rows share the columns as subgrids). */
  .kl__product-data { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; margin: 0; font-size: var(--text-md); line-height: normal; }
  .kl__product-data-row { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; }
  .kl__product-data-row dt, .kl__product-data-row dd { margin: 0; }
  .kl__product-data-row dd, .kl__product-data-row--cord dt { color: var(--muted); }
  .kl__product-data-row--cord dd { color: var(--ink); }

  /* „O kamieniach”: each stone's name over its facts, two by two, their labels in the link's small caps. */
  .kl__product-stone-facts { display: flex; flex-direction: column; gap: 10px; }
  .kl__product-stone-name { font-family: var(--font-display); font-size: var(--text-lg); color: var(--ink); }
  .kl__disclosure-body .kl__product-stone-name { font-weight: var(--weight-regular); color: var(--ink); }
  .kl__product-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 20px; margin: 0; line-height: normal; }
  .kl__product-fact { display: flex; flex-direction: column; gap: 4px; }
  .kl__product-fact dt { font-size: var(--text-2xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--link); }
  .kl__product-fact dd { margin: 0; font-size: var(--text-base); color: var(--ink-soft); }

  /* A stone of the bracelet (Product#stones, the shop's stone cards): a mist band across the page — its name in the
     serif capitals (ms-title) on the left, its story on the right. A template
     that keeps the cards in the purchase column gets them stacked: the band is laid out by its own width. */
  .kl__product > .kl__wrap { container: product-page / inline-size; }
  .kl__stone {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    margin-top: 96px;
    padding: clamp(28px, 5vw, 72px);
    background: var(--mist);
  }
  @container product-page (min-width: 860px) {
    .kl__stone { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr); gap: 56px; }
  }
  .kl__stone + .kl__stone { margin-top: 6px; }
  .kl__stone-head { display: flex; flex-direction: column; gap: 14px; }
  .kl__stone-body { display: flex; flex-direction: column; }
  .kl__stone .ms-eyebrow { font-size: var(--text-xs); color: var(--link); }
  .kl__stone-body { gap: 28px; }
  .kl__stone-story { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
  .kl__stone-text { margin: 0; max-width: 62ch; font-weight: var(--weight-light); font-size: var(--text-lg); line-height: 1.75; color: var(--ink-soft); text-wrap: pretty; }
  /* Cut to six lines by expandable_controller.js, which only sets the attribute when the text is longer. */
  .kl__stone-text[data-clamped] { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; line-clamp: 6; overflow: hidden; }
  .kl__stone-more { font-size: var(--text-md); text-underline-offset: 3px; }
  .kl__product-info .kl__stone { grid-template-columns: minmax(0, 1fr); gap: 16px; margin-top: 24px; padding: 24px; }
  .kl__product-info .kl__stone-name { font-size: var(--heading-md); }

  /* Below the stones, „Może Ci się też spodobać” lies on the page's grid already. */
  .kl__product .kl__related { margin-top: 96px; padding: 0; }

  /* Below 1024px the photos no longer fit side by side next to the purchase column: they become a carousel of one
     photo at a time in the left column, which stays in view instead of the purchase column — swiped, scroll-snapped,
     with dots under it that gallery_controller.js keeps in step. */
  @media (max-width: 1023px) {
    .kl__product-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; }
    .kl__product-gallery { position: sticky; top: calc(var(--nav-stuck) + 24px); }
    .kl__product-info { position: static; }
    .kl__product-slides {
      display: flex;
      gap: 0;
      overflow-x: auto;
      overscroll-behavior-x: contain;
      scroll-snap-type: x mandatory;
      scrollbar-width: none;
    }
    .kl__product-slides::-webkit-scrollbar { display: none; }
    .kl__product-slide { flex: 0 0 100%; scroll-snap-align: start; }
    .kl__product-dots { display: flex; justify-content: center; align-items: center; gap: 0; margin-top: 12px; }
    /* A fixed 24px target, whatever the width of the pill drawn inside it. */
    .kl__product-dot {
      display: grid;
      place-items: center;
      width: 24px;
      height: 24px;
      padding: 0;
      border: 0;
      background: none;
      cursor: pointer;
    }
    /* The inactive dot is a lighter shade of the tone at 3:1 against every background of the page; the current one is
       a pill. */
    .kl__product-dot::before {
      content: "";
      display: block;
      width: 6px;
      height: 6px;
      border-radius: var(--radius-pill);
      background: color-mix(in srgb, var(--tone) 65%, var(--white));
      transition: width var(--duration-base) var(--ease-standard), background-color var(--duration-base) var(--ease-standard);
    }
    .kl__product-dot[aria-current="true"]::before { width: 18px; background: var(--tone); }
  }

  /* A landscape tablet or phone is shorter than the 4:5 photo: the stuck carousel and its dots must fit under the bar
     (24px sticky offset + 12px gap + 24px dots + 16px air), so the height left over sets the width through the slide's
     proportion. svh: the viewport with the browser toolbar shown. */
  @media (min-width: 769px) and (max-width: 1023px) {
    .kl__product-slides { width: min(100%, (100svh - var(--nav-stuck) - 76px) * var(--slide-aspect)); margin-inline: auto; }
  }

  @media (max-width: 860px) {
    .kl__product { padding-top: 14px; }
    .kl__product-title { font-size: var(--heading-xl); }
    .kl__product-price { margin-top: 16px; font-size: var(--heading-lg); }
  }

  /* Phone: the cool tone; one column, the carousel across the whole screen with its
     dots over the photo. */
  @media (max-width: 768px) {

    .kl__product {
      --tone: var(--link);
      --tone-strong: var(--link-hover);
      --tone-pale: color-mix(in srgb, var(--link) 30%, transparent);
      padding: 4px 0 36px;
    }
    .kl__product .kl__crumbs { margin-bottom: 10px; font-size: var(--text-xs); }
    .kl__product .kl__crumbs-list { gap: 6px; }
    .kl__product .kl__crumbs-item { gap: 6px; }

    .kl__product-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .kl__product-gallery { position: relative; top: auto; margin: 0 calc(-1 * var(--gutter)); }
    /* The dots lie over the bottom of the photo as a decoration: pills 6px tall, 5px apart — far too small to tap, so
       they take no pointer (gallery_controller.js also hides them from assistive technology and the keyboard); swiping
       the photo is the control. */
    .kl__product-dots { position: absolute; left: 0; right: 0; bottom: 12px; gap: 5px; margin: 0; pointer-events: none; }
    .kl__product-dot {
      display: block;
      width: 6px;
      height: 6px;
      border-radius: var(--radius-pill);
      background: color-mix(in srgb, var(--tone) 22%, var(--white));
      transition: width var(--duration-base) var(--ease-standard), background-color var(--duration-base) var(--ease-standard);
    }
    .kl__product-dot::before { content: none; }
    .kl__product-dot[aria-current="true"] { width: 18px; background: var(--tone); }

    .kl__product-head { gap: 10px; }
    .kl__product-heading { gap: 4px; }
    .kl__product-title { font-size: var(--heading-xl); line-height: 1.15; }
    .kl__product-subtitle { font-size: var(--text-md); }
    .kl__product-price { margin-top: 4px; font-size: var(--heading-md); }

    .kl__product-family { margin-top: 16px; padding-top: 16px; }
    .kl__product-family-item { width: 56px; }

    .kl__product-cta { margin-top: 16px; }
    .kl__product-cta .ms-button--primary { padding: 15px 18px; font-size: var(--text-base); }
    .kl__product-buy-price { display: inline; }

    .kl__product-perks { margin-top: 20px; }
    .kl__product-perk { padding: 13px 0; font-size: var(--text-md); }

    .kl__stone { margin: 48px calc(-1 * var(--gutter)) 0; padding: 32px var(--gutter); }
    .kl__stone-text { font-size: var(--text-base); }
    .kl__product .kl__related { margin-top: 56px; gap: 20px; }
    /* The cards run to the window's edges, swiped like the landing's newest. */
    .kl__related .kl__newest-row { margin: 0 calc(-1 * var(--gutter)); }

    .kl__product-details { margin-top: 24px; }
    .kl__disclosure-summary { padding: 16px 0; }
    .kl__disclosure-body { padding-bottom: 16px; }
    .kl__disclosure-body p { font-size: var(--text-md); line-height: 1.6; }
    .kl__product-data { gap: 6px 12px; font-size: var(--text-md); }
    /* The counts form a narrow column at the end of the rows: the cord's description no longer shares
       (and widens) it — its row is a grid of its own, the description at the row's end. */
    .kl__product-data-row--cord { grid-template-columns: minmax(0, 1fr) auto; column-gap: inherit; }
  }
}
