/* RxHealing bottle: scroll-driven 3D prescription bottle mounted in the
   homepage device slot. Page styling (including .device-section,
   .device-stage, .device-placeholder and .device-ground) is owned by the
   page's embedded stylesheet. This file adds the stage that holds the WebGL
   canvas, and the program cards that fade in under it.

   States, set by js/hero.js on #bottle-stage:
   - no data-mode (JS off)      -> the placeholder card shows
   - data-mode="webgl"          -> canvas is live; the placeholder stays
                                   visible until the first frame is drawn
   - data-mode="fallback"       -> placeholder shows (WebGL, three.js or the
                                   label art failed)
   - data-state="idle"          -> waiting for the section to come near view
   - data-state="loading"       -> three.js and the label art loading
   - data-state="ready"         -> first frame drawn, canvas fades in,
                                   placeholder fades out
   and on the enclosing .device-section:
   - data-peel="on"             -> peel-to-cards mode is running: the cards
                                   start hidden and JS fades them in
                                   (without it, the cards render in place:
                                   no JS, reduced motion, fallback)
   - is-cards-live              -> the cards have started to appear

   The stage always has the bottle's aspect and centers the placeholder card
   inside it, so the placeholder-to-canvas swap causes no layout shift. */

.bottle-stage {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin-bottom: 8px;
  aspect-ratio: 4 / 5;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Own stacking context so the page-owned .device-glow (z-index -1) sits
     between the stage background and the placeholder/canvas. */
  isolation: isolate;
}

/* Desktop: match the page stylesheet's .device-stage so the bottle is not
   small in empty space at 1440. Phones keep 420px. */
@media (min-width: 1024px) {
  .bottle-stage {
    max-width: 640px;
  }
}

.bottle-stage .device-placeholder {
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.bottle-stage[data-mode="webgl"][data-state="ready"] .device-placeholder {
  opacity: 0;
  visibility: hidden;
}

.bottle-stage:not([data-mode="webgl"]) .bottle-canvas-wrap {
  display: none;
}

/* Canvas: hidden until the first frame renders, then a short fade in. */

.bottle-canvas-wrap {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.bottle-stage[data-state="ready"] .bottle-canvas-wrap {
  opacity: 1;
}

.bottle-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

/* Program cards (#cards, three .peel-card links in the device section), in
   the site's glass card style. Copied from the page stylesheet in
   index.html: the panel from .result-card (background, border,
   backdrop-filter, border-radius, padding; the Proven Results cards have no
   shadow and no hover state), the grid gap from .result-cards, the eyebrow
   from .eyebrow (the "PROVEN RESULTS" line), the body color from
   .result-stat .stat-label. The markup is unchanged from the earlier
   PNG-style cards: the band span now carries the eyebrow, whose text comes
   from CSS (the span is aria-hidden, so a screen reader still reads each
   program's name once, from the headline), and the lockup is not shown. A
   div rather than a nav: the page stylesheet styles bare nav and nav a for
   the header. */

.peel-cards {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
  align-items: stretch;
  width: 100%;
  max-width: 640px;
  margin: 48px auto 0;
  text-align: left;
}

.peel-card {
  display: block;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 30px 28px;
  color: var(--text-dim);
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
  /* transform only: js/hero.js moves the cards with the translate property,
     so the hover lift and the scroll-driven rise never fight. */
  transition: transform 150ms ease, border-color 150ms ease;
}

/* The Proven Results cards have no hover treatment, so: the border shifts to
   cyan and the card lifts 2px. */
.peel-card:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}

.peel-card:focus-visible {
  outline: 3px solid var(--cyan-title);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .peel-card {
    transition: none;
  }

  .peel-card:hover {
    transform: none;
  }
}

/* Eyebrow, as .eyebrow. */
.peel-card__band {
  display: block;
  margin-bottom: 18px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan-bright);
  opacity: 0.85;
}

.peel-card:nth-child(1) .peel-card__band::before {
  content: "Remote Patient Monitoring";
}

.peel-card:nth-child(2) .peel-card__band::before {
  content: "Chronic Care Management";
}

.peel-card:nth-child(3) .peel-card__band::before {
  content: "Become a Rep";
}

.peel-card__logo {
  display: none;
}

.peel-card__title {
  margin: 0 0 14px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  color: var(--cyan-title);
}

.peel-card p,
.peel-card ul {
  margin: 0 0 1em;
}

.peel-card > :last-child {
  margin-bottom: 0;
}

.peel-card ul {
  list-style: "\2022  " outside;
  padding-left: 1.05em;
}

.peel-card li {
  margin: 0;
}

.peel-card li::marker {
  color: var(--cyan);
}

@media (min-width: 768px) {
  .peel-card__title {
    font-size: 26px;
  }
}

/* Three across from 1024 up, equal height per row. The cards end 80px above
   the next section's eyebrow: the device section's bottom padding goes and
   the next section's top padding (14vh in the page stylesheet) becomes
   80px, only where the cards exist. js/hero.js finishes the last card's
   fade as that eyebrow reaches the bottom of the viewport. On a viewport
   taller than about 900px that leaves too little scroll for three fades of
   100px or more, so the gap above the cards grows with the height. */
@media (min-width: 1024px) {
  .peel-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 1100px;
    margin-top: max(48px, calc(50vh - 455px));
  }

  .device-section:has(.peel-cards) {
    padding-bottom: 0;
  }

  .device-section:has(.peel-cards) + section {
    padding-top: 80px;
  }
}

/* Peel mode: the cards start hidden and JS fades them in one by one, the first
   card's slot. Never applies without JS or under reduced motion. */
.device-section[data-peel="on"] .peel-cards {
  visibility: hidden;
}

.device-section[data-peel="on"].is-cards-live .peel-cards {
  visibility: visible;
}

.device-section[data-peel="on"] .peel-card {
  opacity: 0;
  will-change: transform, opacity;
}
