/* Home hero slider (patient + clinician home, desktop + mobile hero sections).
 *
 * Layout never changes between slides: all slides sit in ONE grid cell, so
 * the hero is always as tall as its tallest slide, and every animation uses
 * only opacity / transform (compositor-only, no reflow). Slide 1 is the
 * original hero markup (client copy updates + hook classes); every slide's
 * photo is a full-bleed .rt-bg on desktop and an .rt-media-photo on mobile.
 * Slide 1's photo is set inline (it is the LCP image), slides 2-3 use
 * data-bg and are fetched by hero_slider.js after page load.
 *
 * Hooks: .rt-slider (section) > .rt-slides > [.rt-bgs > .rt-bg] + .rt-slide
 *        .rt-text (block whose children animate in), .rt-media (picture)
 */

.rt-slides {
  --rt-ease: cubic-bezier(.22, .61, .36, 1);
  --rt-fade: .9s;
  --rt-pad-top: 100px;            /* = section padding-top (Bricks rule) */
  position: relative;
  isolation: isolate;             /* own stacking context, z-index 0 level */
  display: grid;
  overflow-x: clip;               /* entrance offsets never cause h-scroll;
                                     y stays visible for the bg overhang */
}
/* Variant switch. Bricks swaps the desktop (.hide-mobile) and mobile
 * (.hide-desktop) hero sections at 767px; for the sliders the swap is at
 * 991px instead: between 768 and 991px a full-bleed 2.29:1 photo ends up
 * under the text, so the mobile hero (centred text, photo at the bottom) is
 * used there. Its <=767px Bricks layout rules are repeated for 768-991px in
 * each page's <style id="rt-hero-tablet">. */
@media (min-width: 768px) and (max-width: 991px) {
  .rt-slider.hide-mobile { display: none !important; }
  .rt-slider.hide-desktop { display: block !important; }
}
/* Desktop hero: the track fills the whole section, so the photo reaches the
 * section bottom when the section is taller than the slides (clinician home
 * has min-height: 785px). Bricks' .hide-mobile forces display:block !important,
 * hence the !important here, scoped to where the desktop hero is visible. */
@media (min-width: 992px) {
  .rt-slider.hide-mobile { display: flex !important; flex-direction: column; }
  .rt-slider.hide-mobile > .rt-slides { flex-grow: 1; align-self: stretch; }
}

/* ---- slides ------------------------------------------------------------ */
.rt-slide {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--rt-fade) var(--rt-ease), visibility 0s linear var(--rt-fade);
}
.rt-slide.is-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
  transition: opacity var(--rt-fade) var(--rt-ease), visibility 0s;
}
.rt-slide > .brxe-container { flex: 1 1 auto; }
/* Picture always sits on the slide's bottom edge, whatever the text height. */
.rt-slide .rt-media { margin-top: auto; }
/* Desktop slides 2-3 keep slide 1's picture column as an invisible spacer,
 * so their text column has exactly slide 1's width at every viewport. */
.rt-slide .rt-spacer { visibility: hidden; }

/* Slides 2-3 repeat "(Thyroid Tablets, USP)" as an <h2> (one <h1> per page);
 * it must look exactly like slide 1's <h1> (same rule as the theme's h1). */
.rt-slide .rt-h1 {
  margin: 0;
  font-size: clamp(1.875rem, 1.5rem + 1.2vw, 3.75rem);
  line-height: 1.4;
}
/* Mobile slides 2-3: photo cropped from the wide slide image, in the same
 * 440x235 box as slide 1's mobile picture (so the hero height is identical).
 * The whole box is used for the photo (a plain crop of the right side of the
 * wide image, export_heroes.py); its top edge is faded into the section.
 * Used up to 991px (see the variant switch above). */
.rt-slide .rt-media-photo {
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 440 / 235;
  background-repeat: no-repeat;
  background-position: right bottom;
  background-size: cover;
  /* soften the photo's top edge into the section background */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 15%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 15%);
}

/* ---- text + picture entrance (staggered) --------------------------------- */
.rt-text > :not(.rt-media),
.rt-slide .rt-media {
  transition: opacity .7s var(--rt-ease), transform 1s var(--rt-ease);
}
/* Leaving / hidden slide: hold the visible state while the slide fades out,
 * then snap to the start position (no visible movement). */
.rt-slide:not(.is-active) .rt-text > :not(.rt-media) {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  transition-duration: 0s;
  transition-delay: var(--rt-fade);
}
.rt-slide:not(.is-active) .rt-media {
  opacity: 0;
  transform: translate3d(28px, 0, 0);
  transition-duration: 0s;
  transition-delay: var(--rt-fade);
}
.rt-slide.is-active .rt-text > :not(.rt-media) {
  opacity: 1;
  transform: none;
  transition-delay: calc(.12s + var(--rt-i, 0) * 80ms);
}
.rt-slide.is-active .rt-media { transition-delay: .1s; }
.rt-text > :nth-child(2) { --rt-i: 1; }
.rt-text > :nth-child(3) { --rt-i: 2; }
.rt-text > :nth-child(4) { --rt-i: 3; }
.rt-text > :nth-child(5) { --rt-i: 4; }
.rt-text > :nth-child(6) { --rt-i: 5; }
.rt-text > :nth-child(7) { --rt-i: 6; }
.rt-text > :nth-child(n+8) { --rt-i: 7; }

/* ---- backgrounds (desktop) ----------------------------------------------- */
.rt-bgs {
  position: absolute;
  top: calc(-1 * var(--rt-pad-top));   /* cover the section's top padding */
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
  overflow: hidden;                    /* clip the slow zoom */
  pointer-events: none;
}
.rt-bg {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.06);
  /* Zoom anchored at head height, not the bottom: from the bottom the photo
   * grew 6% upward and the top ~5.7% (where the hair is) left the frame.
   * At 75% 35% the top moves out ~2%, hair (>= 3.8% down) stays in, and the
   * bottom-right "Actor Portrayal" label stays in (0.95 -> 0.99). */
  transform-origin: 75% 35%;
  --rt-wash: 255, 255, 255;            /* left edge colour of the photo (r, g, b);
                                          set inline where a photo differs */
  background-color: rgb(var(--rt-wash));
  background-repeat: no-repeat;
  background-position: right bottom;   /* keeps the person + "Actor Portrayal" */
  /* Fit to height: never crops the top (heads) on heroes wider than the
   * photo's 2.29:1 (wide monitors); the extra width on the left is the
   * background colour = the photo's left edge (--rt-wash). On narrower
   * heroes it behaves like cover (crops the left). A photo whose left edge
   * is not one flat colour sets background-size: cover inline. */
  background-size: auto 100%;
  transition: opacity 1.1s var(--rt-ease), transform 0s linear 1.1s;
}
.rt-bg.is-active {
  opacity: 1;
  transform: scale(1);
  transition: opacity 1.1s var(--rt-ease), transform 8s cubic-bezier(.25, .1, .25, 1);
}
/* The photos fade to their edge colour on the left ~40%, which is where the
 * text sits at >= 1600px. Narrower heroes are taller than 2.29:1, so "cover"
 * crops the left of the photo and its colour shapes slide under the text;
 * a wash in the photo's own edge colour keeps the text column readable.
 * .rt-wash-all: photos whose text side is NOT light (request-samples: solid
 * pink) get the wash at every desktop width. */
.rt-bg.rt-wash-all::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(var(--rt-wash), .92) 0,
    rgba(var(--rt-wash), .85) clamp(340px, 40vw, 640px),
    rgba(var(--rt-wash), 0) clamp(500px, 62vw, 960px));
}
@media (max-width: 1599px) {
  .rt-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg,
      rgba(var(--rt-wash), .92) 0,
      rgba(var(--rt-wash), .85) clamp(340px, 40vw, 640px),
      rgba(var(--rt-wash), 0) clamp(500px, 62vw, 960px));
  }
}

/* ---- dots ------------------------------------------------------------------ */
.rt-dots {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 3;
  display: flex;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transform: translateX(-50%);
}
.rt-dot {
  position: relative;
  width: 34px;
  height: 24px;                        /* touch target >= 24px (WCAG 2.5.8) */
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rt-dot::before,
.rt-dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  height: 8px;
  margin-top: -4px;
  border-radius: 4px;
  transition: opacity .45s var(--rt-ease), transform .45s var(--rt-ease);
}
.rt-dot::before {                      /* idle dot */
  width: 8px;
  margin-left: -4px;
  background: rgba(47, 41, 81, .28);
}
.rt-dot::after {                       /* active pill */
  width: 26px;
  margin-left: -13px;
  background: linear-gradient(90deg, #E51945, #FD6C3C);
  opacity: 0;
  transform: scaleX(.3);
}
.rt-dot:hover::before { background: rgba(47, 41, 81, .5); }
.rt-dot[aria-current="true"]::before { opacity: 0; }
.rt-dot[aria-current="true"]::after { opacity: 1; transform: none; }
.rt-dot:focus-visible {
  outline: 2px solid #FA2468;
  outline-offset: -2px;
  border-radius: 12px;
}

/* ---- reduced motion: plain cross-fade, no movement, no autoplay (JS) ---- */
@media (prefers-reduced-motion: reduce) {
  .rt-slides { --rt-fade: .3s; }
  .rt-text > :not(.rt-media),
  .rt-slide .rt-media,
  .rt-slide:not(.is-active) .rt-text > :not(.rt-media),
  .rt-slide:not(.is-active) .rt-media { transform: none; transition: none; opacity: 1; }
  .rt-bg, .rt-bg.is-active { transform: none; transition: opacity .3s linear; }
}
