/*
 * Hero — block styles.
 *
 * Loaded by WordPress only on pages where this block is present.
 * Tailwind utilities (layout, spacing, colour) live in render.php class attrs.
 * This file handles: frosted glass, typography sizing, load animation,
 * button transitions, and parallax preparation.
 */

/* ── Full-width breakout ─────────────────────────────────────────────────── */
/*
 * Two layers of defence:
 *
 * 1. alignfull — when the block is set to Full Width in the editor WordPress
 *    adds .alignfull to the ACF wrapper div. Ensure our section fills it.
 *
 * 2. Constrained-layout escape — if the hero ever ends up inside a
 *    is-layout-constrained container (e.g. the default page template), this
 *    rule uses the classic negative-margin / 100vw trick to break out.
 *    The page-hero.html template avoids this entirely, but the fallback is
 *    here in case the hero is placed on a page using the standard template.
 */

.wp-block-acf-hero.alignfull,
.wp-block-acf-hero.alignfull .ble-hero {
  width: 100%;
  max-width: none;
}

/* Remove any max-width the ACF wrapper might inherit */
.wp-block-acf-hero {
  width: 100%;
  max-width: none !important;
}

/* Strip padding/margin that TT5 applies to constrained post-content */
.wp-block-post-content.is-layout-constrained:has(.wp-block-acf-hero) {
  padding-inline: 0;
}

/* ── Minimum height ──────────────────────────────────────────────────────── */

.ble-hero {
  /* svh accounts for mobile browser chrome. The rem floor keeps the heading,
     tagline and buttons clear of the header in short windows. */
  min-height: max(72svh, 34rem);
}

@media (min-width: 1024px) {
  .ble-hero {
    min-height: max(84svh, 38rem);
  }
}

/* ── Background / parallax layer ─────────────────────────────────────────── */
/*
 * The parallax element is translated on scroll by view.js.
 * It starts slightly oversized (110%) so there's room to move without
 * exposing the edges of the image.
 *
 * Explicit fill rules here mirror the Tailwind utility classes used in
 * render.php (absolute, inset-0, w-full, h-full, object-cover). This ensures
 * the editor preview renders correctly even before theme.css loads, and acts
 * as a reliable fallback.
 */

.ble-hero__bg {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.ble-hero__bg img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform-origin: center center;
}

.ble-hero__overlay {
  position: absolute;
  inset: 0;
  /* background-color set via inline style from ACF overlay_color + overlay_opacity fields */
}

/* ── Frosted glass container ─────────────────────────────────────────────── */

.ble-hero__glass {
  background: rgba(80, 76, 60, 0.2);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: clamp(2rem, 5vw, 4rem);
}

/* ── Typography ──────────────────────────────────────────────────────────── */
/*
 * Heading font-size is set via inline style in render.php using the
 * user-controlled ACF field. Only non-size properties live here.
 */

.ble-hero__heading {
  font-size: var(--ble-hero-h1, clamp(2.5rem, 8vw, 6rem));
  letter-spacing: -0.02em;
  text-shadow: 0 2px 32px rgba(0, 0, 0, 0.4);
  line-height: 1.05;
}

.ble-hero__tagline {
  font-size: clamp(1rem, 2vw, 1.25rem);
  letter-spacing: 0.04em;
}

/* ── Desktop: compact panel anchored bottom-left ────────────────────────── */
/*
 * The panel sizes from the viewport's width AND height, so on shorter or
 * mid-size screens (1024, 1440×900, 1680, 1920) it stays small and low and
 * leaves the image/video visible. It reaches its full 48rem only on large
 * screens like 2560×1328. The heading is capped to the panel width (cqi) and
 * the viewport height so it stays on one line and never overpowers the panel.
 */

@media (min-width: 1024px) {
  .ble-hero__content {
    padding-left: max(1.5rem, 6vw);
    padding-right: 1.5rem;
    padding-bottom: clamp(2.5rem, 9vh, 7.5rem);
  }

  .ble-hero__glass {
    container-type: inline-size;
    width: clamp(30rem, min(37vw, 62vh), 48rem);
    max-width: 100%;
    margin-left: 0;
    padding: clamp(1.75rem, 2.4vw, 3.5rem);
    background: rgba(44, 40, 34, 0.16);
    backdrop-filter: blur(10px) saturate(1.1);
    -webkit-backdrop-filter: blur(10px) saturate(1.1);
  }

  .ble-hero__heading {
    font-size: min(var(--ble-hero-h1, 6rem), 13cqi, 9vh);
    margin-bottom: 0.5rem;
  }

  .ble-hero__tagline {
    font-size: clamp(1rem, 0.6rem + 0.5vw, 1.25rem);
    margin-bottom: clamp(1.25rem, 3.2vh, 2.5rem);
  }

  .ble-hero__actions {
    gap: 0.875rem;
  }

  .ble-hero__btn {
    padding-inline: clamp(1.25rem, 1.6vw, 3rem);
    padding-block: clamp(0.8rem, 1.6vh, 1rem);
    letter-spacing: 0.16em;
  }
}

/* ── Load animation — initial state ─────────────────────────────────────── */
/*
 * The glass container fades and lifts in on page load.
 * view.js adds .is-loaded to the section after a short delay,
 * giving the image time to begin rendering first.
 */

.ble-hero__glass {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 1.1s cubic-bezier(0.25, 0.1, 0.25, 1) 0.2s,
    transform 1.1s cubic-bezier(0.25, 0.1, 0.25, 1) 0.2s;
}

.ble-hero[data-ble-hero].is-loaded .ble-hero__glass {
  opacity: 1;
  transform: translateY(0);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
/*
 * All visual button properties live here, NOT in Tailwind utility classes.
 * style.css is enqueued after theme.css so these always win without !important.
 * Tailwind classes on the element handle layout only (padding, flex, tracking).
 */

.ble-hero__btn {
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition:
    background-color 0.45s cubic-bezier(0.25, 0.1, 0.25, 1),
    color 0.45s cubic-bezier(0.25, 0.1, 0.25, 1),
    transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* Primary — champagne */
.ble-hero__btn.ble-hero__btn--primary {
  background-color: #ddc7a9;
  color: #2c2a27;
}

.ble-hero__btn.ble-hero__btn--primary:hover {
  background-color: #ebd9bf;
}

/* Secondary — white */
.ble-hero__btn.ble-hero__btn--secondary {
  background-color: #ffffff;
  color: #2c2a27;
}

.ble-hero__btn.ble-hero__btn--secondary:hover {
  background-color: #f5f0ea;
}

.ble-hero__btn:active {
  transform: scale(0.97);
}

/* ── Scroll-down arrow (hidden on desktop) ─────────────────────────────── */

.ble-hero__scroll-arrow {
  display: none;
}

/* ── Background video (desktop only) ───────────────────────────────────── */

.ble-hero__video {
  display: none;
}

.ble-hero__video-toggle {
  display: none;
}

@media (min-width: 1024px) {
  .ble-hero__video {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity 0.8s ease;
  }

  .ble-hero__video.is-playing {
    opacity: 1;
  }

  /* Final play: fade back to the hero image underneath. */
  .ble-hero__video.is-playing.is-fading {
    opacity: 0;
    transition: opacity 1.5s ease;
  }

  .ble-hero__video-toggle:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 20;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.55);
    background: rgba(20, 18, 15, 0.35);
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease;
  }

  .ble-hero__video-toggle:hover {
    background: rgba(20, 18, 15, 0.6);
  }

  .ble-hero__video-toggle:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
  }

  .ble-hero__video-toggle .ble-hero__icon-play,
  .ble-hero__video-toggle .ble-hero__icon-replay,
  .ble-hero__video-toggle[aria-pressed="true"] .ble-hero__icon-pause,
  .ble-hero__video-toggle[data-mode="replay"] .ble-hero__icon-pause {
    display: none;
  }

  .ble-hero__video-toggle[aria-pressed="true"]:not([data-mode="replay"]) .ble-hero__icon-play,
  .ble-hero__video-toggle[data-mode="replay"] .ble-hero__icon-replay {
    display: block;
  }
}

/* ── Mobile: remove glass, full height, scroll arrow ───────────────────── */

@media (max-width: 767px) {
  .ble-hero {
    min-height: max(100svh, 34rem);
  }

  .ble-hero__bg img {
    object-position: center 30%;
  }

  .ble-hero__glass {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    padding: 0;
  }

  .ble-hero__content {
    padding-bottom: 5rem;
  }

  .ble-hero__btn {
    white-space: normal;
  }

  .ble-hero__scroll-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    margin-left: -1.2rem;
    z-index: 20;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    background: rgba(20, 18, 15, 0.35);
    color: #ffffff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: ble-hero-bounce 2s ease-in-out infinite;
  }

  .ble-hero__scroll-arrow:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
  }
}

@keyframes ble-hero-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ble-hero__glass {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .ble-hero__bg {
    will-change: auto;
  }

  .ble-hero__btn {
    transition:
      background-color 0.2s linear,
      color 0.2s linear;
  }

  .ble-hero__scroll-arrow {
    animation: none;
  }

  .ble-hero__video {
    display: none !important;
  }
}

/* ── Admin bar: push hero down so it doesn't peek above the header ──────── */

.admin-bar .ble-hero {
  margin-top: 32px;
}

@media (max-width: 782px) {
  .admin-bar .ble-hero {
    margin-top: 46px;
  }
}

/* ── Block editor overrides ───────────────────────────────────────────────── */
/*
 * WordPress wraps the editor canvas in .editor-styles-wrapper.
 * These rules ensure the hero preview displays correctly inside the editor
 * iframe, where TT5's layout constraints and reset styles are also active.
 */

.editor-styles-wrapper .wp-block-acf-hero,
.editor-styles-wrapper .ble-hero {
  width: 100% !important;
  max-width: none !important;
}

/* Keep the glass visible at all times in editor (no view.js animation) */
.editor-styles-wrapper .ble-hero__glass {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

/* Ensure button colours survive editor resets */
.editor-styles-wrapper .ble-hero__btn.ble-hero__btn--primary {
  background-color: #ddc7a9 !important;
  color: #2c2a27 !important;
}

.editor-styles-wrapper .ble-hero__btn.ble-hero__btn--secondary {
  background-color: #ffffff !important;
  color: #2c2a27 !important;
}

.editor-styles-wrapper .ble-hero__btn {
  font-weight: 500 !important;
}
