/* ==========================================================================
   Layout 2 loading experience (loaded by layout/default2.php, driven by webroot/js/v2-loading.js).
   - images fade in once decoded; a shimmer skeleton holds their place until then
   - carousels show a laid-out preview of their slides before Owl initialises, so nothing jumps in
   - YouTube videos start as a light poster (thumbnail + play button); the heavy player loads on click
   - page-to-page navigation cross-fades, with the header held still
   - the AJAX overlay (.loader2) is a single clean spinner that fades in
   Every rule that depends on JS sits behind html.v2-js (set in the layout's <head>), so a page without JS stays fully visible.
   ========================================================================== */
:root {
  --v2-skel-a: #e8eeec;
  --v2-skel-b: #f6f9f8;
}

@keyframes v2Shimmer { 0% { background-position: 160% 0; } 100% { background-position: -60% 0; } }
@keyframes v2ImgIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes v2Reveal { to { opacity: 1; } }
@keyframes v2Spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes v2FadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes v2PageIn { from { opacity: 0; } to { opacity: 1; } }

/* reusable skeleton block: <div class="v2-skel" style="height:120px"></div> */
.v2-skel,
html.v2-js :is(.v2-product__pic, .v2-cat__media, .v2-slide, .v2-collage > *, .v2-sub__media, .v2-pd__gallery .product__details__pic__item):has(> img.is-loading) {
  background: linear-gradient(100deg, var(--v2-skel-a) 30%, var(--v2-skel-b) 50%, var(--v2-skel-a) 70%) 0 0 / 200% 100%;
  animation: v2Shimmer 1.3s linear infinite;
}
.v2-skel { border-radius: 12px; }

/* ---- images ---- */
/* hidden until loaded; the failsafe reveals it after 6 seconds so a stalled image can never leave a hole */
html.v2-js img.is-loading { opacity: 0; animation: v2Reveal .01s linear 6s forwards; }
/* opacity only, and fill-mode backwards: nothing is left behind to fight a hover transform */
html.v2-js img.is-loaded { animation: v2ImgIn .45s ease backwards; }
/* a banner slide has no height until its picture arrives: hold a sensible one meanwhile */
html.v2-js .v2-slide:has(> img.is-loading) { min-height: clamp(150px, 30vw, 380px); border-radius: inherit; }

/* ---- carousels, before Owl takes over ----
   owl.carousel.css hides an uninitialised carousel (display: none), so the section collapsed and then popped open.
   Show the slides in the same row layout instead; Owl replaces them on init. */
html.v2-js .v2-banner__slider:not(.owl-loaded),
html.v2-js .v2-promo__slider:not(.owl-loaded) { display: block !important; overflow: hidden; border-radius: 22px; }
html.v2-js .v2-banner__slider:not(.owl-loaded) > .v2-slide ~ .v2-slide,
html.v2-js .v2-promo__slider:not(.owl-loaded) > .v2-slide ~ .v2-slide { display: none; }
html.v2-js .v2-catprod__slider:not(.owl-loaded) { display: flex !important; gap: 12px; overflow: hidden; }
html.v2-js .v2-catprod__slider:not(.owl-loaded) > .v2-catprod__slide { flex: 0 0 calc((100% - 12px) / 2); min-width: 0; }
@media (min-width: 768px) { html.v2-js .v2-catprod__slider:not(.owl-loaded) { gap: 16px; } html.v2-js .v2-catprod__slider:not(.owl-loaded) > .v2-catprod__slide { flex-basis: calc((100% - 32px) / 3); } }
@media (min-width: 1200px) { html.v2-js .v2-catprod__slider:not(.owl-loaded) > .v2-catprod__slide { flex-basis: calc((100% - 48px) / 4); } }
html.v2-js .v2-video__slider:not(.owl-loaded) { display: flex !important; overflow: hidden; }
html.v2-js .v2-video__slider:not(.owl-loaded) > .v2-video__item { flex: 0 0 auto; }
/* once ready, the carousel eases in rather than snapping */
html.v2-js .owl-carousel.owl-loaded { animation: v2FadeIn .35s ease backwards; }

/* ---- video poster ---- */
.v2-video__poster {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: #0d1512;
  cursor: pointer;
  overflow: hidden;
}
/* the thumbnail fills the whole box (cover): YouTube's 4:3 thumbnails carry black bars baked in above/below (landscape) or beside (reel) the picture, which cover crops away */
.v2-video__poster > img { position: absolute; inset: 0; display: block; width: 100% !important; height: 100% !important; max-width: none; aspect-ratio: auto !important; object-fit: cover !important; object-position: center; transition: transform .5s ease, opacity .3s; }
.v2-video__poster:hover > img { transform: scale(1.04); }
.v2-video__poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, .05) 40%, rgba(0, 0, 0, .35) 100%);
  pointer-events: none;
}
.v2-video__play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color: var(--v2-primary-dark, #1a5f8a);
  font-size: 22px;
  transform: translate(-50%, -50%);
  transition: transform .25s ease, background .25s ease, color .25s ease;
}
.v2-video__play i { margin-left: 4px; }
.v2-video__poster:hover .v2-video__play,
.v2-video__poster:focus-visible .v2-video__play { background: var(--v2-primary, #1a5f8a); color: #fff; transform: translate(-50%, -50%) scale(1.08); }
.v2-video__poster:focus-visible { outline: 3px solid var(--v2-primary, #1a5f8a); outline-offset: -3px; }
/* the player swapped in on click fades over the poster */
.v2-video__item iframe { animation: v2FadeIn .35s ease backwards; }
@media (max-width: 767.98px) {
  .v2-video__poster { flex: 0 0 auto; width: 100%; height: calc(var(--video-w) * 9 / 16); border-radius: 15px; }
  .v2-video__item--reel .v2-video__poster { width: calc(var(--reel-h) * 9 / 16); height: var(--reel-h); }
  .v2-video__play { width: 56px; height: 56px; font-size: 18px; }
}

/* ---- the AJAX overlay (add to cart, address, coupons, ...): one spinner, fading in ---- */
html.v2-js .loader2 {
  background: rgba(255, 255, 255, .62) !important;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: v2FadeIn .2s ease backwards;
}
html.v2-js .loader2::before { display: none; }
html.v2-js .loader2::after {
  width: 54px;
  height: 54px;
  border: 4px solid color-mix(in srgb, var(--v2-primary, #1a5f8a) 18%, transparent);
  border-top-color: var(--v2-primary, #1a5f8a);
  border-bottom-color: color-mix(in srgb, var(--v2-primary, #1a5f8a) 18%, transparent);
  animation: v2Spin .8s linear infinite;
}

/* ---- navigation ----
   Chrome / Edge / Safari cross-fade between pages and keep the header and the background picture still;
   other browsers get a short fade-in of the page instead. */
@view-transition { navigation: auto; }
.v2-header { view-transition-name: v2-header; }
.v2-page-bg { view-transition-name: v2-bg; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .24s; }
@supports not (view-transition-name: none) {
  html.v2-js .page-container { animation: v2PageIn .35s ease backwards; }
}


/* ---- progress bar: starts on a click, a form submit or an AJAX call ---- */
.v2-loadbar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100001;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--v2-primary, #1a5f8a), color-mix(in srgb, var(--v2-primary, #1a5f8a) 55%, #fff));
  box-shadow: 0 0 10px color-mix(in srgb, var(--v2-primary, #1a5f8a) 55%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: scaleX(0);
  transform-origin: left center;
}
.v2-loadbar.is-active { opacity: 1; transform: scaleX(.82); transition: transform 9s cubic-bezier(.08, .7, .2, 1), opacity .15s; }
.v2-loadbar.is-done { transform: scaleX(1); opacity: 0; transition: transform .2s ease, opacity .3s ease .15s; }

/* ---- a button waiting on the server ---- */
.is-busy { position: relative; pointer-events: none; color: transparent !important; }
.is-busy > * { opacity: 0; }
.is-busy::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2.5px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: v2BtnSpin .7s linear infinite;
}
.is-busy.border-btn::after,
.is-busy.btn-outline::after { border-color: color-mix(in srgb, var(--v2-primary, #1a5f8a) 25%, transparent); border-top-color: var(--v2-primary, #1a5f8a); }
@keyframes v2BtnSpin { to { transform: rotate(360deg); } }

/* ---- small, consistent press / hover feedback ---- */
.v2-product, .v2-cat, .site-btn, .primary-btn, .v2-pill-link { transition: transform .2s ease, box-shadow .25s ease, background-color .2s ease, border-color .2s ease, color .2s ease; }
.site-btn:active, .primary-btn:active, .add_to_cart:active { transform: scale(.97); }

/* ---- reduced motion: no shimmer, no fades, no cross-fade ---- */
@media (prefers-reduced-motion: reduce) {
  .v2-skel,
  html.v2-js :is(.v2-product__pic, .v2-cat__media, .v2-slide, .v2-collage > *, .v2-sub__media, .v2-pd__gallery .product__details__pic__item):has(> img.is-loading),
  html.v2-js img.is-loaded,
  html.v2-js .owl-carousel.owl-loaded,
  html.v2-js .loader2,
  .v2-video__item iframe,
  .is-busy::after { animation: none !important; }
  .v2-loadbar { transition: none !important; }
  html.v2-js img.is-loading { opacity: 1; animation: none; }
  @view-transition { navigation: none; }
}

/* ---- category switch: dim the product area the moment a category is clicked ---- */
html.v2-js .v2-pl__main { transition: opacity .15s ease; }
html.v2-js .v2-pl__main.is-switching {
  opacity: .45;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%) 0 0 / 200% 100%;
  animation: v2Shimmer 1.2s linear infinite;
}
