/**
 * Home Slider Module
 *
 * Styles for template-parts/modules/home_slider_module.php
 *
 * Collage sizing uses one unit (--hs-u) for every width, height, offset
 * and gap. It's the smaller of 1vw and the viewport height left under the
 * fixed header (113px, see .hidden-height in header.css) after reserving
 * room for the heading row — so the collage keeps the design's
 * proportions at any width AND the heading/arrows always stay on screen.
 * At the 1440 × 860 design size both sides are ~14px.
**/

.home_slider_module {
  --hs-edge: 30px; /* left/right inset of the track start + footer */
  --hs-text: 0px;  /* strip reserved above the collage for tile text (set below) */
  --hs-u: min(1vw, calc((100svh - 113px - 150px - var(--hs-text)) / 50));

  background: var(--farani-burgundy, #401115);
  color: var(--white, #fff);
  padding: calc(var(--hs-u) * 3.6) 0 calc(var(--hs-u) * 3);
  overflow: hidden;
}

/* Track — bleeds off the right edge, scrolls horizontally with 5+ items */
.home-slider__track {
  display: flex;
  align-items: flex-start;
  gap: calc(var(--hs-u) * 1.9);
  list-style: none;
  margin: 0;
  padding: 0 var(--hs-edge);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--hs-edge);
  scrollbar-width: none;
}
.home-slider__track::-webkit-scrollbar { display: none; }

.home-slider__item {
  position: relative; /* anchors .home-slider__tile-text */
  flex: 0 0 auto;
  scroll-snap-align: start;
}

/* Tile Heading / Tile Subheading — pinned just above each image, so the
   collage sizes and offsets are untouched. The track reserves a strip at
   the top (--hs-text) for the tiles that start at the very top; it's also
   subtracted in --hs-u so the hero still fits the screen. Longer text
   wraps upwards; keep it to a line each. */
.home-slider--tile-text { --hs-text: 64px; }
.home-slider--tile-text .home-slider__track { padding-top: var(--hs-text); }

.home-slider__tile-text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  padding-bottom: 10px;
}

/* Like .home-slider__heading, at 18px */
.home-slider__tile-heading {
  font-family: var(--farani-heading-font);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.15;
  color: var(--white, #fff);
  margin: 0 0 4px;
}
.home-slider__tile-heading:last-child { margin-bottom: 0; }

/* Like .home-slider__subheading, at 16px */
.home-slider__tile-subheading {
  font-family: var(--farani-body-font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--farani-orange, #e95a3a);
  margin: 0;
}

/* 4 or fewer items — centre the collage when it fits. Auto margins (not
   justify-content) so nothing gets clipped if it overflows instead. */
.home_slider_module:not(.home-slider--slider) .home-slider__item:first-child { margin-left: auto; }
.home_slider_module:not(.home-slider--slider) .home-slider__item:last-child { margin-right: auto; }

/* Mouse drag (main.js) — grab cursor, no native image dragging, and no
   snapping while the pointer is down */
.home-slider--scrollable .home-slider__track { cursor: grab; }
.home-slider__track.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  user-select: none;
}
.home-slider__img {
  -webkit-user-drag: none;
  user-select: none;
}

/* Repeating 4-image collage — sizes from the design (in --hs-u units) */
.home-slider__item:nth-child(4n+1) {
  width: calc(var(--hs-u) * 11.6);
  height: calc(var(--hs-u) * 16.2);
  margin-top: calc(var(--hs-u) * 12.6);
}
.home-slider__item:nth-child(4n+2) {
  width: calc(var(--hs-u) * 33.4);
  height: calc(var(--hs-u) * 46.4);
}
.home-slider__item:nth-child(4n+3) {
  width: calc(var(--hs-u) * 26.4);
  height: calc(var(--hs-u) * 36.8);
}
.home-slider__item:nth-child(4n+4) {
  width: calc(var(--hs-u) * 18.7);
  height: calc(var(--hs-u) * 26);
  margin-top: calc(var(--hs-u) * 20.4); /* bottom-aligned with the large image */
}

.home-slider__media {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: #d9d9d9;
  overflow: hidden;
  color: inherit;
}
button.home-slider__media,
a.home-slider__media { cursor: pointer; }

.home-slider__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s ease;
}
/* Muted inline loop ("Autoplay in Tile") — sits over the image, which
   stays as the poster until the clip has frames to show. Click-through so
   the button (popup) and the track's drag-scroll still get the pointer. */
.home-slider__inline-video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  transition: opacity .6s ease, transform .6s ease;
}
.home-slider__inline-video.is-playing { opacity: 1; }

.home-slider__media--video:hover .home-slider__img,
.home-slider__media--video:hover .home-slider__inline-video,
.home-slider__media--link:hover .home-slider__img { transform: scale(1.04); }

.home-slider__media:focus-visible {
  outline: 2px solid var(--farani-orange, #e95a3a);
  outline-offset: 3px;
}

/* Play button / link badge */
.home-slider__play,
.home-slider__arrow-badge {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--farani-orange, #e95a3a);
  color: var(--white, #fff);
  transition: transform .3s ease, background-color .3s ease;
}

.home-slider__play {
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 20px;
  transform: translate(-50%, -50%) scale(.9);
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
}
.home-slider__play i { margin-left: 3px; } /* optical centring of the play glyph */

/* Hidden until hover — also shown on keyboard focus */
.home-slider__media--video:hover .home-slider__play,
.home-slider__media--video:focus-visible .home-slider__play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Autoplay-in-tile videos — the clip is already playing, so no play
   badge on hover. Still shown on keyboard focus, on touch (below) and
   under reduced motion (the inline clip never plays there). */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .home-slider__media--autoplay:hover:not(:focus-visible) .home-slider__play {
    opacity: 0;
    transform: translate(-50%, -50%) scale(.9);
  }
}

/* Touch devices can't hover — keep the play button visible so it's
   clear the image opens a video */
@media (hover: none) {
  .home-slider__play {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.home-slider__arrow-badge {
  right: 0;
  bottom: 0;
  width: 44px;
  height: 44px;
  font-size: 15px;
}
.home-slider__media--link:hover .home-slider__arrow-badge { background: var(--farani-burgundy, #401115); }

/* Smaller collage positions get a smaller play button */
.home-slider__item:nth-child(4n+1) .home-slider__play,
.home-slider__item:nth-child(4n+4) .home-slider__play {
  width: 48px;
  height: 48px;
  font-size: 15px;
}

/* Heading row + arrows */
.home-slider__footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: calc(var(--hs-u) * 1.7);
  padding: 0 var(--hs-edge);
}

.home-slider__heading {
  font-family: var(--farani-heading-font);
  font-weight: 400;
  font-size: clamp(28px, calc(var(--hs-u) * 2.8), 48px);
  line-height: 1.15;
  color: var(--white, #fff);
  margin: 0 0 8px;
}

.home-slider__subheading {
  font-family: var(--farani-body-font);
  font-size: 18px;
  line-height: 1.4;
  color: var(--farani-orange, #e95a3a);
  margin: 0;
}

/* Centred 4-item collage — line the heading row up with the collage
   (total collage width = the 4 widths + 3 gaps, in --hs-u) */
.home_slider_module:not(.home-slider--slider):not(.home-slider--scrollable) .home-slider__footer {
  max-width: calc(var(--hs-u) * 95.8 + var(--hs-edge) * 2);
  margin-left: auto;
  margin-right: auto;
}

/* Arrows only while the track overflows (class toggled by main.js) */
.home-slider__nav {
  display: none;
  gap: 18px;
  flex-shrink: 0;
}
.home-slider--scrollable .home-slider__nav { display: flex; }

.home-slider__prev,
.home-slider__next {
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--farani-orange, #e95a3a); /* SVG strokes use currentColor */
  line-height: 0;
  cursor: pointer;
  transition: opacity .3s ease, transform .3s ease;
}
.home-slider__prev svg,
.home-slider__next svg {
  display: block;
  width: 43px;
  height: 31px;
  overflow: visible; /* stroke sits on the viewBox edge — don't clip it */
}
.home-slider__next:hover:not(:disabled) { transform: translateX(4px); }
.home-slider__prev:hover:not(:disabled) { transform: translateX(-4px); }
.home-slider__prev:disabled,
.home-slider__next:disabled {
  opacity: .3;
  cursor: default;
}
.home-slider__prev:focus-visible,
.home-slider__next:focus-visible {
  outline: 2px solid var(--white, #fff);
  outline-offset: 2px;
}

/* Video popup (native <dialog>) */
.home-slider__dialog {
  width: min(1100px, calc(100vw - 32px));
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}
.home-slider__dialog::backdrop { background: rgba(29, 8, 10, .88); }

.home-slider__dialog-close {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px auto;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--white, #fff);
  font-family: var(--farani-body-font);
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  float: right;
}
.home-slider__dialog-close:hover { color: var(--farani-orange, #e95a3a); }

.home-slider__dialog-body {
  clear: both;
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}
.home-slider__dialog-body iframe,
.home-slider__dialog-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Shown instead of a Cookiebot-blocked YouTube/Vimeo iframe */
.home-slider__dialog-consent {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  color: var(--white, #fff);
  font-family: var(--farani-body-font);
}
.home-slider__dialog-consent p {
  max-width: 420px;
  margin: 0;
}
.home-slider__dialog-consent-btn {
  padding: 12px 24px;
  border: 0;
  background: var(--farani-orange, #e95a3a);
  color: var(--white, #fff);
  font-family: var(--farani-body-font);
  font-weight: 500;
  cursor: pointer;
}
.home-slider__dialog-consent-btn:hover,
.home-slider__dialog-consent-btn:focus-visible {
  background: var(--farani-burgundy, #401115);
  outline: 2px solid var(--white, #fff);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .home-slider__inline-video { display: none; } /* image only — main.js never plays it either */
  .home-slider__img,
  .home-slider__play,
  .home-slider__prev,
  .home-slider__next { transition: none; }
}

@media (max-width: 1536px) {

}

@media (max-width: 1366px) {

}

@media (max-width: 1280px) {

}

@media (max-width: 992px) {
  .home_slider_module {
    --hs-u: min(1.45vw, calc((100svh - 96px - 170px - var(--hs-text)) / 50));
  }
}

@media (max-width: 768px) {
  /* ~1.5 images visible; heading row still reserved on screen */
  .home_slider_module {
    --hs-edge: 20px;
    --hs-u: min(2.1vw, calc((100svh - 96px - 200px - var(--hs-text)) / 50));
    padding: 24px 0 32px;
  }
  .home-slider__footer {
    margin-top: 20px;
  }
  .home-slider--scrollable .home-slider__nav { display: none; } /* swipe only on mobile */
  .home-slider__subheading { font-size: 16px; }
}

@media (max-width: 600px) {
  .home_slider_module { --hs-edge: 16px; }
  .home-slider__play { width: 48px; height: 48px; font-size: 15px; }
  .home-slider__item:nth-child(4n+1) .home-slider__play,
  .home-slider__item:nth-child(4n+4) .home-slider__play {
    width: 36px;
    height: 36px;
    font-size: 12px;
  }
  .home-slider__arrow-badge { width: 34px; height: 34px; font-size: 12px; }
}
