/* Treatments Showcase - layout, paging affordances and the persistent CTA.
   Like blocks/treatments/style.css this is structure only: colour and type
   come from the theme through --bodysoul-* tokens, with self-contained
   fallbacks so the block still reads correctly on a theme that has none. */
.wp-block-bodysoul-treatments-showcase {
  position: relative;
  /* Named container so the side-gutter rules below can ask how wide THIS BLOCK
     is rather than how wide the window is. The block can sit in a column, a
     sidebar or a narrow theme container, and only its own width decides whether
     the arrow lanes fit. Descendant unnamed container queries (blocks/treatments
     queries .treatments) still bind to their own nearest container, not this. */
  container: bs-showcase / inline-size;
  --bs-sc-cols: 2;
  --bs-sc-gap: 2.4rem;
  /* Phone panel width. The remainder is the peek of the next panel: a clean
     edge reads as "that is everything", a sliced panel reads as "swipe". */
  --bs-sc-peek: 85%;
  /* Palette Kit first, then the theme token, then a literal - the block must
     render identically where palette-kit is not installed. */
  --bs-teal: var(--pal-action, var(--bodysoul-action-book, #1E7A6B));
  /* Same palette-first chain as the treatments block's token set (2026-09-02). */
  --bs-teal-dark: var(--pal-action-hover, var(--bodysoul-action-book-hover, #16685B));
  --bs-teal-tint: var(--pal-today-highlight, var(--bodysoul-tint-book, #E9F3F0));
  --bs-sc-surface: var(--bodysoul-surface-raised, #FFFFFF);
  --bs-sc-fade: var(--pal-surface, var(--bodysoul-surface-page, #FFFFFF));
  --bs-sc-line: var(--bodysoul-border-subtle, rgba(0, 0, 0, 0.12));
  --bs-sc-muted: var(--bodysoul-text-muted, #8F8F8F);
  --bs-sc-faint: #CCCCCC;
}

.wp-block-bodysoul-treatments-showcase.bs-showcase--cols-1 {
  --bs-sc-cols: 1;
}

.bs-showcase__heading {
  margin: 0 0 1.6rem;
}

/* Core's class names, redefined here so alignment survives on a site that does
   not load the block-library stylesheet. No rule for the unset case: that is
   what lets the theme's own heading alignment stand. */
.bs-showcase__heading.has-text-align-left {
  text-align: left;
}

.bs-showcase__heading.has-text-align-center {
  text-align: center;
}

.bs-showcase__heading.has-text-align-right {
  text-align: right;
}

.bs-showcase__viewport {
  position: relative;
}

/* The rail is a real overflow container, so touch swipe and keyboard scrolling
   are the browser's, not ours. Nothing here is ever display:none - every panel
   stays in the document and reachable with the script module disabled. */
.bs-showcase__rail {
  display: flex;
  gap: var(--bs-sc-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* Load-bearing. The theme lays the page out with `body { display: grid }`,
     so <main> is a grid item at min-width:auto and its min-content width is
     whatever its widest descendant needs. Without size containment the four
     off-screen panels set that figure and the WHOLE PAGE scrolls sideways
     (measured: 500px of document on a 480px phone) - the rail's own
     overflow:auto does not stop the contribution. blocks/treatments does the
     same job one level down with container-type on .treatments. */
  contain: inline-size;
}

.bs-showcase__rail::-webkit-scrollbar {
  display: none;
}

.bs-showcase__rail:focus-visible {
  outline: 2px solid var(--bs-teal);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ---- Panels per view follow the block's OWN width ------------------------
   cols-2 is "as many as fit, up to four"; cols-1 is the author's explicit one
   and never grows. The count is a custom property on the RAIL (a container
   query cannot style the container, and the rail is its descendant), read by
   the panel width rule below, by the editor's wrapping preview, and
   re-measured by view-module.js - nothing in PHP or JS names these widths.

   Thresholds are derived: the narrowest panel the 2-up layout already ships
   is ~390px (880px window, 803px block), and the card internals (bs-rows
   40rem / 55rem) were designed for 390-640px. N panels + (N-1) 24px gaps at
   ~480px each:
     three: 3 x 480 + 2 x 24 -> 1488 -> 1500px
     four : 4 x 480 + 3 x 24 -> 1992 -> 2000px
   Below 1500px nothing here matches, so every block narrower than that is
   byte-for-byte the 2-up layout it was. The phone rule (<= 720px window)
   cannot meet these: a block is never wider than its window. */
@container bs-showcase (min-width: 1500px) {
  .bs-showcase--cols-2 .bs-showcase__rail {
    --bs-sc-cols: 3;
  }
}

@container bs-showcase (min-width: 2000px) {
  .bs-showcase--cols-2 .bs-showcase__rail {
    --bs-sc-cols: 4;
  }
}

/* Any direct child is a panel, whatever block produced it. Widths subtract the
   gutters so N panels plus N-1 gaps land exactly on the rail width - which is
   also why view-module.js pages by measured panel stride and not clientWidth. */
.bs-showcase__rail > * {
  flex: 0 0 calc((100% - (var(--bs-sc-cols) - 1) * var(--bs-sc-gap)) / var(--bs-sc-cols));
  min-width: 0;
  scroll-snap-align: start;
  /* Panels stretch to the tallest on the page (flex default) and lay their own
     contents out in a column, so the list below takes the slack and each
     panel's see-all link lands on its own bottom edge. Left alone the links
     float wherever each list happens to end and the rail bottom reads ragged -
     which also makes "vertically centred" gutter arrows ambiguous. Scoped to
     the rail: .treatment-group renders standalone on 17 pages and must not
     become a flex container there. */
  display: flex;
  flex-direction: column;
}

.bs-showcase__rail > * > .treatments {
  flex: 1 1 auto;
}

/* Blockified as a flex item it would otherwise stretch to the panel width,
   turning a text link into a full-width hit area. */
.bs-showcase__rail > * > .bs-seeall {
  align-self: flex-start;
}

/* Edge fades mirror scroll position; the classes come from measured overflow
   (view-module.js), the server only seeds the right-hand one. */
.bs-showcase__viewport::before,
.bs-showcase__viewport::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 3.2rem;
  pointer-events: none;
  opacity: 0;
}

.bs-showcase__viewport::before {
  left: 0;
  background: linear-gradient(to right, var(--bs-sc-fade), transparent);
}

.bs-showcase__viewport::after {
  right: 0;
  background: linear-gradient(to left, var(--bs-sc-fade), transparent);
}

.bs-showcase__viewport.has-fade-l::before,
.bs-showcase__viewport.has-fade-r::after {
  opacity: 1;
}

/* Controls row: paging cluster left, persistent CTA right. */
.bs-showcase__foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.2rem 2.4rem;
  margin-top: 1.6rem;
}

.bs-showcase__nav {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.bs-showcase__cta {
  margin-left: auto;
}

.bs-showcase__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  padding: 0;
  border: 1px solid var(--bs-sc-line);
  border-radius: 50%;
  background: var(--bs-sc-surface);
  color: inherit;
  cursor: pointer;
}

.bs-showcase__arrow:hover,
.bs-showcase__arrow:focus-visible {
  border-color: var(--bs-teal);
  background: var(--bs-teal-tint);
  color: var(--bs-teal-dark);
}

/* aria-disabled, not disabled: the button keeps focus and keeps announcing
   itself at the ends, it just has nowhere to go. */
.bs-showcase__arrow.is-disabled {
  opacity: 0.35;
  cursor: default;
}

.bs-showcase__arrow.is-disabled:hover {
  border-color: var(--bs-sc-line);
  background: var(--bs-sc-surface);
  color: inherit;
}

/* ---- controlsPosition: side-gutters -------------------------------------
   The arrows sit in grid TRACKS either side of the rail, reserved out of the
   section's own width. They are not offset into the page's margins: on this
   theme the content column is the viewport less ~16px, so there is no outside
   space to reach into and a negative offset would hang the buttons off the
   screen edge - the one thing they must never do. Tracks make "outside the
   rail, never over a panel, never off-screen" a property of the layout instead
   of arithmetic that has to be re-checked at every width, and `align-items:
   center` on the rail row is what centres them ON THE RAIL rather than on the
   section (whose box also holds the heading and the controls row).

   This is the FALLBACK template: the arrows share the controls row with the
   dots and the CTA, exactly as bottom-left does, because the lanes have not
   been granted yet. The container query at the end of this block is the only
   thing that grants them. */
.bs-showcase--controls-side-gutters .bs-showcase__inner {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-areas:
    "hd hd hd"
    "rl rl rl"
    "pv nx ft";
  column-gap: 1.2rem;
  /* Row spacing stays on the children's margins so the heading row costs
     nothing when there is no heading. */
  row-gap: 0;
  align-items: center;
}

.bs-showcase--controls-side-gutters .bs-showcase__inner > .bs-showcase__heading {
  grid-area: hd;
}

.bs-showcase--controls-side-gutters .bs-showcase__inner > .bs-showcase__viewport {
  grid-area: rl;
}

.bs-showcase--controls-side-gutters .bs-showcase__inner > .bs-showcase__arrow--prev {
  grid-area: pv;
}

.bs-showcase--controls-side-gutters .bs-showcase__inner > .bs-showcase__arrow--next {
  grid-area: nx;
}

.bs-showcase--controls-side-gutters .bs-showcase__inner > .bs-showcase__foot {
  grid-area: ft;
}

.bs-showcase--controls-side-gutters .bs-showcase__foot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.bs-showcase--controls-side-gutters .bs-showcase__nav {
  grid-column: 1;
}

.bs-showcase--controls-side-gutters .bs-showcase__cta {
  grid-column: 2;
  justify-self: end;
  margin-left: 0;
}

/* Is there room for the lanes? This is the only switch. Failing it leaves the
   template above in place, so the fallback is a layout that already works
   rather than a broken version of this one.

   Thresholds are derived, not picked: a lane pair costs 2 x (4rem button +
   1.2rem gap) = 104px, and below ~380px a panel is narrower than the phone
   layout already gives it, so paying for the lanes would make the content worse
   than it is on a phone.
     one column : 104 + 380            -> 500px
     two columns: 104 + 380 + 24 + 380 -> 900px
   These ask how wide THIS BLOCK is, not the window, so a showcase in a narrow
   column falls back on its own merits. The outer media query is the "no gutter
   arrows on phones" rule: under 720px the rail is one-panel-plus-peek and
   swiping is the interaction, so lanes would cost panel width to display
   buttons that are hidden anyway. */
@media (min-width: 721px) {
  @container bs-showcase (min-width: 500px) {
    .bs-showcase--cols-1.bs-showcase--controls-side-gutters .bs-showcase__inner {
      grid-template-columns: auto minmax(0, 1fr) auto;
      grid-template-areas:
        "hd hd hd"
        "pv rl nx"
        "ft ft ft";
    }
    .bs-showcase--cols-1.bs-showcase--controls-side-gutters .bs-showcase__foot {
      grid-template-columns: 1fr auto 1fr;
    }
    .bs-showcase--cols-1.bs-showcase--controls-side-gutters .bs-showcase__nav {
      grid-column: 2;
      justify-content: center;
    }
    .bs-showcase--cols-1.bs-showcase--controls-side-gutters .bs-showcase__cta {
      grid-column: 3;
    }
  }
  @container bs-showcase (min-width: 900px) {
    .bs-showcase--cols-2.bs-showcase--controls-side-gutters .bs-showcase__inner {
      grid-template-columns: auto minmax(0, 1fr) auto;
      grid-template-areas:
        "hd hd hd"
        "pv rl nx"
        "ft ft ft";
    }
    .bs-showcase--cols-2.bs-showcase--controls-side-gutters .bs-showcase__foot {
      grid-template-columns: 1fr auto 1fr;
    }
    .bs-showcase--cols-2.bs-showcase--controls-side-gutters .bs-showcase__nav {
      grid-column: 2;
      justify-content: center;
    }
    .bs-showcase--cols-2.bs-showcase--controls-side-gutters .bs-showcase__cta {
      grid-column: 3;
    }
  }
}

.bs-showcase__dots {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.bs-showcase__dot {
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bs-sc-faint);
  cursor: pointer;
}

.bs-showcase__dot.is-current {
  background: var(--bs-teal);
  transform: scale(1.4);
}

.bs-showcase__dot:focus-visible {
  outline: 2px solid var(--bs-teal);
  outline-offset: 3px;
}

/* Dots past the last page. Rendered from the server's DESKTOP page count, so
   the phone breakpoint below puts them back - there, every panel is its own
   page and all of them are real. */
.bs-showcase__dot.is-beyond {
  display: none;
}

/* Every panel is on screen at once (view-module.js sets context.fit from the
   measured page count), so paging has nothing to do: no dots, no arrows, no
   empty controls row gap. The CTA stays. Never display:none on the PANELS -
   only on controls that would be permanently inert. */
.bs-showcase.is-single-page .bs-showcase__nav,
.bs-showcase.is-single-page .bs-showcase__arrow {
  display: none;
}

/* Side-gutter lanes collapse to 0 with their arrows; the track gap would not. */
.bs-showcase--controls-side-gutters.is-single-page .bs-showcase__inner {
  column-gap: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .bs-showcase__viewport::before,
  .bs-showcase__viewport::after {
    transition: opacity 150ms ease;
  }
  .bs-showcase__arrow {
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  }
  .bs-showcase__dot {
    transition: background 150ms ease, transform 150ms ease;
  }
}

@media (max-width: 720px) {
  .wp-block-bodysoul-treatments-showcase {
    --bs-sc-gap: 1.6rem;
  }
  .bs-showcase__rail > * {
    flex-basis: var(--bs-sc-peek);
  }
  /* Swipe is the affordance on touch; the dots stay as the position readout. */
  .bs-showcase__arrow {
    display: none;
  }
  .bs-showcase__dot.is-beyond {
    display: block;
  }
  .bs-showcase__cta {
    margin-left: 0;
  }
  /* Side-gutters on a phone is dots-centred with the CTA under them: the arrows
     are hidden, so the lane tracks would only add leading gaps, and a
     right-aligned CTA below centred dots reads as a mistake at this width. */
  .bs-showcase--controls-side-gutters .bs-showcase__inner {
    display: block;
  }
  .bs-showcase--controls-side-gutters .bs-showcase__foot {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .bs-showcase--controls-side-gutters .bs-showcase__nav,
  .bs-showcase--controls-side-gutters .bs-showcase__cta {
    grid-column: 1;
    justify-self: center;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wp-block-bodysoul-treatments-showcase {
    --bs-sc-surface: var(--bodysoul-surface-raised, #272221);
    --bs-sc-fade: var(--bodysoul-surface-page, #1E1A19);
    --bs-sc-line: rgba(255, 255, 255, 0.14);
    --bs-sc-faint: #6F6663;
  }
}

:root[data-theme="dark"] .wp-block-bodysoul-treatments-showcase {
  --bs-sc-surface: var(--bodysoul-surface-raised, #272221);
  --bs-sc-fade: var(--bodysoul-surface-page, #1E1A19);
  --bs-sc-line: rgba(255, 255, 255, 0.14);
  --bs-sc-faint: #6F6663;
}
