/*
 * Small additions to the compiled CSS (root.css, dynamic-zone.css, site-header.css), LiveLaps layer.
 * Loaded last. Everything here supports behaviour implemented in js/site.js and js/livelaps.js.
 */

/* Scroll reveal: content is hidden only once the script runs (html.js); a failsafe shows it after 3s. */
html.js [data-reveal]:not([data-reveal-ready]) {
  opacity: 0;
  animation: reveal-failsafe 0s linear 3s forwards;
}
@keyframes reveal-failsafe {
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  html.js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Accordion chevrons follow aria-expanded (the original rotated them in React). */
[data-rules-trigger][aria-expanded='true'] > [data-chevron] {
  transform: rotate(180deg);
}

/*
 * Support chat widget (Chatwoot): same rules as the original site. The widget stays hidden while
 * html[data-chatwoot-pending] is set by js/site.js (until the widget reports ready).
 */
html #cw-widget-holder:not(.woot--hide),
html .woot-widget-bubble:not(.woot--close) {
  z-index: 40 !important;
}
html[data-chatwoot-pending] #cw-widget-holder,
html[data-chatwoot-pending] .woot--bubble-holder {
  visibility: hidden !important;
  pointer-events: none !important;
}

/*
 * Studio size controls: the studio stores the desktop size as inline width / height / max-width and the mobile
 * size as the custom properties --w-m / --h-m / --mw-m in the same style attribute. Below the md breakpoint
 * the mobile value overrides the inline desktop size. The compiled Tailwind CSS starts md at (min-width: 48rem),
 * so this is its exact complement ("not all and (min-width: 48rem)"): no gap and no overlap at any width.
 */
@media not all and (min-width: 48rem) {
  [style*='--w-m:'] {
    width: var(--w-m) !important;
  }
  [style*='--h-m:'] {
    height: var(--h-m) !important;
  }
  [style*='--mw-m:'] {
    max-width: var(--mw-m) !important;
  }
}

/*
 * Studio picture alignment: a picture in text is centred or put on the right with the line it sits on
 * (style="text-align: …" on the paragraph). The compiled Tailwind CSS shows every picture as a block, which text
 * alignment does not move, so the margins do it.
 */
:where(p, h2, h3, h4, li, blockquote)[style*='text-align: center'] > img {
  margin-inline: auto;
}
:where(p, h2, h3, h4, li, blockquote)[style*='text-align: right'] > img {
  margin-inline: auto 0;
}

/*
 * Studio section background: "Darken the photo" stores --bg-dim (0 to 0.9) on the section, and the shade laid over
 * the section's photo follows it. 0.6 is the shade the hero was designed with (the compiled bg-black/60 on that
 * layer), so a section nobody touched looks as before and the studio's slider starts at 60%.
 */
[data-cms-section='hero'] {
  --bg-dim: 0.6;
}
[data-cms-section='hero'] > [aria-hidden='true'][class~='bg-black/60'] {
  background-color: rgb(0 0 0 / var(--bg-dim));
}

/*
 * Events carousel rendered by js/livelaps.js (data-livelaps="upcoming-events"). The original used a carousel library;
 * here the viewport scrolls natively (touch, trackpad, the previous/next buttons and the arrow keys), with the
 * scrollbar hidden and the cards snapping to the start, so the look is the same.
 */
[data-livelaps] [data-slot="carousel-content"] {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
[data-livelaps] [data-slot="carousel-content"]::-webkit-scrollbar {
  display: none;
}
/* Snap the card, not its padding box: the item has the card gap as left padding, so the card sits flush. */
[data-livelaps] [data-slot="carousel-item"] > * {
  scroll-snap-align: start;
}

/*
 * Honeypot of the contact form (index.html, input name="__livelaps_hp"; read by js/site.js, sent by js/livelaps.js).
 * People never see or reach it; a bot that fills every input fills it too. Off-screen and out of the flow (no
 * layout shift, no focus: tabindex="-1"), not display:none or visibility:hidden, which some bots skip.
 */
.livelaps-hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
}

/*
 * Pages that open on a full-screen hero running up under the header (the home page): the header is half
 * see-through and blurred over it, and its links drop their own boxes so the bar reads as one surface. A smaller
 * hero keeps the solid header, so it never covers the hero's text. Once the page scrolls (data-scrolled,
 * js/site.js) the header is solid again.
 */
html:has(main > section[class*="-mt-(--site-header-height)"][class*="min-h-svh"]:first-of-type):not([data-scrolled]) [data-site-header] {
  background-color: color-mix(in srgb, var(--background) 50%, transparent);
  border-color: transparent;
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
}
html:has(main > section[class*="-mt-(--site-header-height)"][class*="min-h-svh"]:first-of-type):not([data-scrolled]) [data-site-header] :is([data-slot="navigation-menu-link"], [data-slot="navigation-menu-trigger"], [data-header-nav] .bg-background):not(:hover):not(:focus-visible):not([data-popup-open]) {
  background-color: transparent;
}
[data-site-header] {
  transition: background-color .25s ease;
}

/*
 * A hero whose image is a plain block (not a full-screen cover) with its text laid over it: on narrow screens the
 * text is taller than the image. The image and its overlays share one grid cell, so the hero grows to fit the
 * text and the image crops to fill it.
 */
main > section:first-of-type > .relative.w-full:first-child:has(> img:first-child) {
  display: grid;
}
main > section:first-of-type > .relative.w-full:first-child:has(> img:first-child) > * {
  grid-area: 1 / 1;
}
main > section:first-of-type > .relative.w-full:first-child:has(> img:first-child) > img {
  height: 100%;
  object-fit: cover;
}
main > section:first-of-type > .relative.w-full:first-child:has(> img:first-child) > .absolute.inset-0 {
  position: relative;
  inset: auto;
}
main > section:first-of-type > .relative.w-full:first-child:has(> img:first-child) > .absolute.inset-0.flex {
  padding-block: 2.5rem;
}

/* Compact language control beside the header utilities; comfortable touch targets on phones. */
[data-site-header] .studio-language-switcher summary {
  box-sizing: border-box;
  min-height: 32px;
  padding: .3rem .5rem;
  font-size: .8125rem;
  line-height: 1.25;
  border-color: #8885;
  border-radius: .375rem;
}
[data-site-header] .studio-language-switcher nav {
  min-width: 5rem;
  padding: .2rem;
  border-radius: .4rem;
}
[data-site-header] .studio-language-switcher nav a {
  min-height: 36px;
  padding: .5rem .65rem;
  font-size: .8125rem;
}
@media (pointer: coarse) {
  [data-site-header] .studio-language-switcher summary,
  [data-site-header] .studio-language-switcher nav a { min-height: 44px; }
}

/* Studio sections: the photo gallery, videos in text and the space-or-line divider (as on site-sera). */
a[data-video] {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
a[data-video] img {
  display: block;
  border-radius: var(--radius);
}
a[data-video]::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 4rem;
  height: 4rem;
  margin: -2rem 0 0 -2rem;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.6) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M9 7l9 5-9 5z'/%3E%3C/svg%3E") center / 2rem no-repeat;
}
ul[data-columns],
ol[data-columns] {
  column-gap: 2rem;
}
ul[data-columns='2'],
ol[data-columns='2'] {
  columns: 2 14rem;
}
ul[data-columns='3'],
ol[data-columns='3'] {
  columns: 3 12rem;
}
[data-columns] > li {
  break-inside: avoid;
}
.studio-divider {
  margin: 1.5rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.studio-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.studio-gallery img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

/* Hero background photos (LiveLaps Studio, js/hero-carousel.js): the list and its items add no box,
   so each photo keeps the place the site gives it. Until the script runs only the first photo shows. */
[data-hero-photos], [data-hero-photo] { display: contents; }
[data-hero-photo]:not(:first-child):not([data-hero-wanted]) { display: none; }
