/* ============================================================
   havn-pdp — components.css (shared component norms, PAGE-SCAFFOLD)
   Sections may USE these classes and add scoped overrides in css/sections/<slug>.css;
   they never edit this file.
   ============================================================ */

/* Icons can never balloon to the broken-image 300x150 default */
.icon {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

/* Primary CTA pill — brief-page §4.3/§4.4: fill #26352B, white Poppins 500 --text-cta,
   lh 1.25, radius 1000, padding-block 18 / padding-inline 24 → height --btn-h (D 61 / M 54).
   Used by: Add to Bag, See The Klar Difference, Try It Risk-Free, Begin My Morning Reset.
   Section CSS sets width (full / hug) and any per-section override. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--btn-h);
  padding-inline: 24px;
  border: 0;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: var(--text-cta);
  font-weight: 500;
  line-height: var(--lh-ui);
  text-align: center;
  white-space: nowrap;
  transition: background-color .2s ease, color .2s ease, opacity .2s ease;
}
.btn--primary {
  background: var(--color-brand);
  color: var(--color-white);
}
@media (hover: hover) {
  .btn--primary:hover { opacity: 0.9; }
}

/* ---- Scroll reveal (post-delivery, user request) = Shopify Dawn `animations.js` as on
   thestrom.co: `.scroll-trigger.animate--slide-in` rises 2rem + fades in, `.animate--fade-in` fades
   in, 0.6s cubic-bezier(0,0,.3,1); `[data-cascade]` siblings stagger by 75ms (--animation-order set
   by js/main.js). Off-screen elements wait at opacity .01 (`.scroll-trigger--offscreen`, added by
   JS) until they enter the viewport. Reduced motion / no JS: nothing is hidden. ---- */
:root {
  --animation-slide-in: slideIn 0.6s cubic-bezier(0, 0, 0.3, 1) forwards;
  --animation-fade-in: fadeIn 0.6s cubic-bezier(0, 0, 0.3, 1);
}
@media (prefers-reduced-motion: no-preference) {
  .scroll-trigger.animate--fade-in,
  .scroll-trigger.animate--slide-in {
    opacity: 0.01;
  }
  .scroll-trigger.animate--slide-in {
    transform: translateY(2rem);
  }
  /* Below the fold, fully transparent rather than .01: contrast checkers (axe, Lighthouse) skip
     opacity 0 but measured every waiting heading and paragraph at .01 as near-invisible text. */
  .scroll-trigger.scroll-trigger--offscreen.animate--fade-in,
  .scroll-trigger.scroll-trigger--offscreen.animate--slide-in {
    opacity: 0;
  }
  .scroll-trigger:not(.scroll-trigger--offscreen).animate--fade-in {
    opacity: 1;
    animation: var(--animation-fade-in);
  }
  .scroll-trigger:not(.scroll-trigger--offscreen).animate--slide-in {
    animation: var(--animation-slide-in);
    animation-delay: calc(var(--animation-order, 0) * 75ms);
  }
  .scroll-trigger:not(.scroll-trigger--offscreen).scroll-trigger--cancel {
    opacity: 1;
    animation: none;
    transition: none;
    transform: none;
  }
  @keyframes slideIn {
    from { transform: translateY(2rem); opacity: 0.01; }
    to { transform: translateY(0); opacity: 1; }
  }
  @keyframes fadeIn {
    from { opacity: 0.01; }
    to { opacity: 1; }
  }
}

/* ---- Page rhythm (ASSEMBLE, brief-page §1 "Vertical rhythm") ----
   The main wrapper's gap between sections is --section-gap (D 120 / M 60), except clinical→delivery
   and why-klar→founder (D) which touch. Each builder owned one side of its gap; these four sections'
   top gap had no owner (difference→clinical, delivery→clarity, clarity→plan, plan→why-klar). */
main > .clinical,
main > .clarity,
main > .plan,
main > .why-klar {
  margin-top: var(--section-gap);
}

/* ---- Deferred rendering (post-delivery performance pass) ----
   Everything below the product section skips style, layout and paint until it nears the viewport.
   Laying out all 900-odd elements up front took ~350 ms on a mid-range phone, all of it before the
   first frame. The heights are placeholders measured at 412 and 1440 px wide; `auto` swaps in the
   real height once a section has rendered, so the scrollbar settles after the first pass.
   content-visibility clips paint to the section box; the clip margin leaves room for the 2rem
   scroll-reveal rise, which would otherwise be cut off at a section's bottom edge. */
main > section:not(.product),
body > .footer {
  content-visibility: auto;
  contain-intrinsic-size: auto var(--cv-h, 800px);
  overflow-clip-margin: 40px;
}
.ingredients { --cv-h: 850px; }
.difference { --cv-h: 1060px; }
.clinical { --cv-h: 800px; }
.delivery { --cv-h: 1180px; }
.clarity { --cv-h: 510px; }
.plan { --cv-h: 1390px; }
.why-klar { --cv-h: 530px; }
.founder { --cv-h: 900px; }
.testimonials { --cv-h: 530px; }
.guarantee { --cv-h: 580px; }
.faq { --cv-h: 670px; }
.footer { --cv-h: 745px; }
@media (min-width: 1024px) {
  .ingredients { --cv-h: 550px; }
  .difference { --cv-h: 790px; }
  .clinical { --cv-h: 620px; }
  .delivery { --cv-h: 610px; }
  .clarity { --cv-h: 330px; }
  .plan { --cv-h: 820px; }
  .why-klar { --cv-h: 620px; }
  .founder { --cv-h: 530px; }
  .testimonials { --cv-h: 680px; }
  .guarantee { --cv-h: 520px; }
  .faq { --cv-h: 410px; }
  .footer { --cv-h: 625px; }
}

/* Background photos wait for js/main.js to see the block coming (data-defer-bg). Without JS the
   `js` class is never set and the photo loads as usual. */
.js [data-defer-bg]:not(.is-near) {
  background-image: none;
}
