/* Product page: top panel, all offers with their fold-outs, price history, specifications + FAQ, about, blog, related, phone buy bar.
   The breadcrumb, panels, FAQ items and blog list are in sections.css */

.product {
  display: flex;
  flex-direction: column;
  gap: 48px;
  padding-top: 20px;
  padding-bottom: 64px;
}

/* Titles keep the room beside the filters and period buttons; long intros wrap instead of pushing them down */
.product .section-head__text { flex: 1 1 320px; min-width: 0; }

/* ============================================================
   TOP
   ============================================================ */
.ptop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 36px;
  padding: 28px;
  background: var(--surface);
  border-radius: var(--r-2xl);
}

/* The image fills whatever height the right column needs */
.ptop__media {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  background: var(--image-bg);
  border-radius: 18px;
}

.ptop__media img {
  position: absolute;
  inset: 40px;
  width: calc(100% - 80px);
  height: calc(100% - 80px);
  object-fit: contain;
}

.ptop__media .badge { position: absolute; top: 14px; left: 14px; }

.ptop__info { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
/* Meta line and share button on one row, the title and intro under them (phones move the button to the title, see below) */
.ptop__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "meta  share"
    "title title";
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}

.ptop__eyebrow { grid-area: meta; }
.ptop__share { grid-area: share; }
.ptop__title { grid-area: title; }
.ptop__intro { grid-column: 1 / -1; }

/* Theme · number · pieces · age, as in the front-page hero: only the theme gives way (…) when the line is too long */
.ptop__eyebrow {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 22px;
  color: var(--ink-3);
  white-space: nowrap;
}

.ptop__eyebrow > span { flex-shrink: 0; }
.ptop__eyebrow-theme { overflow: hidden; text-overflow: ellipsis; font-weight: 700; color: var(--ink); text-decoration: none; }
.ptop__eyebrow-theme:hover { color: var(--cta); }

.ptop__share { width: 40px; min-height: 40px; height: 40px; }

.ptop__title {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.ptop__intro { margin: 0; font-size: 16px; line-height: 1.5; color: var(--ink-2); }

.ptop__price { display: flex; flex-direction: column; gap: 4px; }
.ptop__label { font-size: 14px; color: var(--ink-3); }
.ptop__amount-row { display: flex; align-items: center; gap: 10px; white-space: nowrap; }

.ptop__amount {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.ptop__shop { font-size: 15px; }
.ptop__rrp { font-size: 14px; color: var(--ink-3); }

.ptop .card-actions { margin-top: 0; }

.ptop__levels {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

/* The card's meters, a size up */
.meters--lg {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  column-gap: 12px;
  row-gap: 12px;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
  font-size: 14px;
  line-height: 18px;
}

.meters--lg .meters__value { height: 18px; }
.meters--lg .level, .meters--lg .stockbar { height: 6px; }
.meters--lg .level > span:nth-child(1) { border-radius: 4px 0 0 4px; }
.meters--lg .level > span:nth-child(3) { border-radius: 0 4px 4px 0; }
.meters--lg .stockbar { border-radius: 4px; }
.meters--lg .level__marker { width: 14px; height: 14px; margin: -7px 0 0 -7px; border-width: 3px; }

.ptop__range { font-size: 12px; color: var(--ink-3); }

.stock-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--ink-3);
}

.stock-legend li { display: inline-flex; align-items: center; gap: 5px; }
.stock-legend__key { width: 9px; height: 9px; border-radius: 2px; }
.stock-legend__key--never { background: var(--empty); box-shadow: inset 0 0 0 1px var(--line-strong); }

.ptop__compare {
  display: block;
  margin-top: auto;
  font-size: 15px;
  line-height: 22px;
  font-weight: 700;
  color: var(--cta);
  text-decoration: none;
}

/* ============================================================
   OFFERS
   ============================================================ */
.offers { display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 16px; }
.offers__tools { display: flex; flex-wrap: wrap; gap: 8px; }
.offers__tools .pill { padding: 0 16px; font-size: 14px; }

.offers__sort {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 700;
}

.offers__sort select { border: 0; background: transparent; font-weight: 700; }

.offers__table {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
}

/* logo · shop and title · stock · price · button · fold-out */
.offers__head, .offer__row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 120px 170px 150px 44px;
  gap: 16px;
  padding: 14px 16px;
}

.offers__head {
  padding-top: 12px;
  padding-bottom: 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
}

.offers__list { margin: 0; padding: 0; list-style: none; }
.offer { border-bottom: 1px solid var(--line); }
.offer--cheapest { background: var(--red-tint-3); }
.offer__row { align-items: center; }

/* Logos come from the 40 px sprite, one square per shop id */
.offer__logo {
  justify-self: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff url('/images/logos/logo-sprite-40px.png') no-repeat;
  background-size: 40px auto;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.offer__main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.offer__name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.offer__name strong { font-size: 16px; }

.offer__pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--page);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
}

.offer__pill svg { margin-left: -3px; }
.offer__pill--cheapest { background: var(--cta); color: #fff; font-weight: 800; }

.offer__title {
  overflow: hidden;
  font-size: 14px;
  color: var(--ink-2);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.offer__stock { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--green); }
.offer__stock svg { flex-shrink: 0; }
.offer--unavailable .offer__stock { color: var(--ink-3); }

.offer__price { display: flex; flex-direction: column; gap: 2px; }
.offer__amount-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.offer__amount {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.offer--unavailable .offer__amount { color: var(--ink-3); }

.offer__discount {
  padding: 2px 6px;
  background: var(--ink-3);
  border-radius: var(--r-xs);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.offer--cheapest .offer__discount { background: var(--cta); }
.offer__per-brick { font-size: 12px; color: var(--ink-3); }

.offer__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.offer__cta:hover { background: var(--ink); color: #fff; }
.offer--cheapest .offer__cta { background: var(--cta); border-color: var(--cta); color: #fff; }
.offer--cheapest .offer__cta:hover { filter: brightness(0.95); }

.offer__more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--ink);
}

.offer__more svg { transition: transform 0.15s; }
.offer__more[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Icon only on wide screens; "Mere info" on phones */
.offer__more-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Fold-out: price history at this shop · the offer · the shop */
.offer__panel {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  padding: 0 16px 20px 80px;
}

.offer__box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.offer__box-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.offer__box-head strong, .offer__box-title { font-size: 15px; }
.offer__box-head span { font-size: 12px; color: var(--ink-3); }

.offer__ptitle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.offer__ptitle span:first-child { font-size: 12px; color: var(--ink-3); }
.offer__ptitle span:last-child { font-size: 14px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }

.offer__facts { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.offer__facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.offer__facts dt { color: var(--ink-3); }
.offer__facts dd { margin: 0; font-weight: 700; text-align: right; }

.offer__shop-link { font-size: 14px; font-weight: 700; color: var(--cta); text-decoration: none; }
.offer__go { margin-top: auto; min-height: 48px; }

/* The fold-out's chart: the market's lowest price, red dots on the days this shop was cheapest */
.mini-chart { position: relative; aspect-ratio: 600 / 140; }
.mini-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.mini-chart line { stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.mini-chart polyline { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.mini-chart .is-gap { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 3 3; }

.mini-chart__dot {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -7px 0 0 -7px;
  background: var(--cta);
  border: 2px solid #fff;
  border-radius: 50%;
  box-sizing: content-box;
}

.mini-chart__empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-3);
}

.mini-chart__axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }

.mini-chart__legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.mini-chart__legend li { display: flex; align-items: center; gap: 8px; }
/* Both keys take 18 px, so the texts line up */
.mini-chart__key { flex-shrink: 0; }
.mini-chart__key--line { width: 18px; height: 3px; background: var(--ink); border-radius: 2px; }
.mini-chart__key--dot { width: 10px; height: 10px; margin: 0 4px; background: var(--cta); border-radius: 50%; }

.offers__foot { display: flex; justify-content: center; padding: 14px 16px; }

/* ============================================================
   PRICE HISTORY
   ============================================================ */
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--page); border-radius: var(--r-md); }

.segmented button {
  min-height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
}

.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.history__stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.history__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}

.history__stat > span { font-size: 13px; color: var(--ink-3); }
.history__stat > span + strong + span { font-size: 12px; }

.history__stat strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.history__chart { display: flex; gap: 12px; }

/* Amounts at the top, middle and bottom of the plot (product.js sets their top) */
.history__y { position: relative; flex-shrink: 0; width: 54px; height: 274px; font-size: 12px; color: var(--ink-3); }
.history__y span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; }

.history__plot-wrap { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.history__plot {
  position: relative;
  height: 274px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  touch-action: pan-y;
}

.history__plot::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--line); }
.history__plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.history__plot polyline { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
/* Days no shop had it in stock: a dotted bridge */
.history__plot .is-gap { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 3 3; }

.history__today {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--cta);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--cta);
}

.history__today-label {
  position: absolute;
  right: 12px;
  transform: translateY(-130%);
  padding: 2px 6px;
  background: var(--surface);
  border-radius: var(--r-xs);
  color: var(--cta);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

/* Hover read-out */
.history__guide { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-strong); pointer-events: none; }

.history__point {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -7px 0 0 -7px;
  background: var(--ink);
  border: 2px solid #fff;
  border-radius: 50%;
  box-sizing: content-box;
  pointer-events: none;
}

.history__tip {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px;
  background: var(--ink);
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.history__tip strong { font-size: 15px; line-height: 20px; }
.history__x { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }

/* ============================================================
   SPECIFICATIONS + FAQ, ABOUT, BLOG, RELATED
   ============================================================ */
.product__two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.product__two-col .panel { gap: 12px; }

.specs { display: flex; flex-direction: column; margin: 0; }
.specs > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; }
.specs > div:last-child { border-bottom: 0; }
.specs dt { flex-shrink: 0; color: var(--ink-3); }
.specs dd { margin: 0; font-weight: 600; text-align: right; }
.specs a { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

.specs__badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  background: var(--green-tint);
  border-radius: var(--r-pill);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

/* LEGO's full text, folded to a few lines by product.js */
.about { gap: 12px; }
.about__body { max-width: 760px; font-size: 16px; line-height: 1.6; color: var(--ink-2); }
.about__body.is-folded { max-height: 180px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.about__body p { margin: 0 0 12px; }
.about__body ul, .about__body ol { margin: 0 0 12px; padding-left: 20px; }
.about__body > :last-child { margin-bottom: 0; }
.about__lead { font-weight: 700; color: var(--ink); }

.about__more {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--cta);
  font-size: 15px;
  font-weight: 700;
}

.about__more[aria-expanded="true"] svg { transform: rotate(180deg); }

.product__related { display: flex; flex-direction: column; gap: 16px; }

/* Phones only: the cheapest offer at the bottom of the screen */
.buybar { display: none; }

/* ============================================================
   TABLETS AND PHONES
   ============================================================ */
@media (max-width: 1023px) {
  .offers__head, .offer__row { grid-template-columns: 48px minmax(0, 1fr) 110px 150px 120px 44px; gap: 12px; }
  .offer__panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-left: 16px; }
  .offer__box--chart { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  .product { gap: 28px; padding-top: 14px; padding-bottom: 32px; }


  .ptop { display: flex; flex-direction: column; gap: 16px; padding: 12px; border-radius: var(--r-xl); }
  .ptop__media { min-height: 0; height: 260px; }
  .ptop__media img { inset: 20px; width: calc(100% - 40px); height: calc(100% - 40px); }
  .ptop__info { padding: 4px 6px 8px; }
  .ptop__title { font-size: 32px; }
  /* The share button moves up beside the title, so the meta line gets the full width */
  .ptop__head {
    grid-template-areas:
      "meta  meta"
      "title share";
  }
  .ptop__share { align-self: start; }
  .ptop__amount { font-size: 36px; }

  .offers__tools { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter) 2px; scrollbar-width: none; }
  .offers__tools::-webkit-scrollbar { display: none; }
  .offers__tools > * { flex-shrink: 0; }
  .offers__head { display: none; }

  /* logo · shop and title · price / stock and price per brick / button · fold-out */
  .offer__row {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    grid-template-areas:
      "logo main price"
      ".    avail avail"
      "cta  cta  more";
    align-items: start;
    gap: 10px 12px;
    padding: 14px;
  }

  .offer__logo { grid-area: logo; }
  .offer__main { grid-area: main; }
  .offer__name { gap: 6px; }
  .offer__pill { padding: 2px 7px; font-size: 11px; line-height: 16px; }
  .offer__pill svg { display: none; }
  .offer__title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 13px; line-height: 1.35; white-space: normal; }

  .offer__price { grid-area: price; align-items: flex-end; }
  .offer__amount-row { flex-direction: column; align-items: flex-end; gap: 4px; }
  .offer__amount { font-size: 19px; }
  .offer__discount { font-size: 11px; }

  .offer__avail { grid-area: avail; display: flex; align-items: center; gap: 12px; font-size: 13px; }
  .offer__stock { font-size: 13px; font-weight: 700; }
  .offer__stock svg { width: 14px; height: 14px; }

  .offer__cta { grid-area: cta; }
  .offer__more { grid-area: more; width: auto; padding: 0 14px; font-size: 14px; font-weight: 700; }
  .offer__more-text { position: static; width: auto; height: auto; overflow: visible; clip: auto; }

  .offer__panel { display: flex; flex-direction: column; gap: 10px; padding: 0 14px 16px; }

  /* Five rows until "Vis alle" */
  .offers:not(.is-all) .offer.is-beyond-narrow { display: none; }

  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .history__stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .history__y { display: none; }
  .history__plot { height: 174px; }

  .product__two-col { display: flex; flex-direction: column; gap: 20px; }


  .buybar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.08);
  }

  .buybar__price { display: flex; flex-direction: column; min-width: 0; }
  .buybar__price strong { font-family: var(--font-display); font-size: 22px; font-weight: 800; line-height: 1.1; white-space: nowrap; }
  .buybar__price span { overflow: hidden; font-size: 13px; color: var(--ink-3); white-space: nowrap; text-overflow: ellipsis; }
  .buybar__cta { flex: 1; min-height: 50px; border-radius: 14px; font-size: 16px; font-weight: 800; }
}

/* The "Vis alle" button when only phones hide rows (6–10 offers) */
@media (min-width: 768px) {
  .offers__foot--narrow { display: none; }
}
