/* Phase F — Premium desktop polish for product pages.
   All rules scoped to (min-width:1024px) so mobile is untouched.
   Added in commit Phase F (May 2026).
*/

/* ============================================================
   0. iOS Safari viewport stability fix (Phase F.3)
   Prevents header/chip-rail/sticky-cta from "jumping" or detaching
   when Safari's dynamic URL bar collapses/expands on scroll.
   The fix: promote these fixed elements to their own compositor
   layer so Safari moves them in sync with the address bar.
   ============================================================ */
.topbar,
.chip-rail,
.sticky-cta {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  will-change: transform;
}
/* Belt and suspenders: also use dynamic viewport units where supported
   so the page measures against the visible viewport, not the largest. */
html, body {
  min-height: 100vh;
  min-height: 100dvh;
}
/* The sticky-cta uses translateY for hide/show. We override with translate3d
   to force GPU compositing — use !important because style.css loads async
   and would otherwise win the cascade. */
.sticky-cta.sticky-cta.is-visible {
  -webkit-transform: translate3d(0, 0, 0) !important;
  transform: translate3d(0, 0, 0) !important;
}
.sticky-cta.sticky-cta:not(.is-visible) {
  -webkit-transform: translate3d(0, 110%, 0) !important;
  transform: translate3d(0, 110%, 0) !important;
}
/* Note: NOT adding padding-top: safe-area-inset to .topbar here — in iOS Safari
   (the bug context), this returns 0 anyway, and changing box-sizing would break
   the existing fixed 56px / 64px height that chip-rail offsets against. The
   GPU compositing fix above is the actual remedy. */


/* ============================================================
   1. PRODUCT HERO — 2-column desktop layout (media + sticky booking)
   ============================================================ */
@media (min-width: 1024px) {
  /* Use !important because style.css loads async (preload->stylesheet) and applies
     AFTER phase-f.css, overriding our grid layout with its earlier flex rule. */
  body.booking-page .product-hero .container {
    max-width: 1240px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 380px !important;
    column-gap: 40px !important;
    row-gap: 0 !important;
    align-items: start !important;
    flex-direction: initial !important;
  }
  /* Left column wraps media + title + philosophy by document order */
  .booking-page .product-hero .container > .product-hero-card,
  .booking-page .product-hero .container > .product-thumbs,
  .booking-page .product-hero .container > .product-title-block,
  .booking-page .product-hero .container > .product-philosophy {
    grid-column: 1 / 2;
  }
  /* Right column reserved for the sticky booking card (inserted via JS or HTML) */
  .booking-page .product-hero .container > .pf-book-rail {
    grid-column: 2 / 3;
    grid-row: 1 / 5;          /* span across all left-column rows */
    position: sticky;
    top: calc(64px + 42px + 20px); /* header + chip rail + gutter */
    align-self: start;
    z-index: 5;
  }
  /* Hero card stays a tasteful size */
  .booking-page .product-hero .product-hero-card {
    aspect-ratio: 3 / 2;
    max-height: 540px;
    border-radius: 22px;
  }
  .booking-page .product-hero .product-thumbs {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 14px;
  }
  /* Tighter title block on the left column */
  .booking-page .product-hero .product-title-block {
    text-align: left;
    align-items: flex-start;
    margin-top: 28px;
  }
  .booking-page .product-hero .product-title-block h1 {
    max-width: 22ch;
    margin-inline: 0;
    font-size: clamp(2rem, 3vw, 2.6rem);
  }
  .booking-page .product-hero .product-tags {
    justify-content: flex-start;
  }
  .booking-page .product-hero .product-actions {
    justify-content: flex-start;
    margin-top: 6px;
  }
  /* Philosophy directly under title, still left-aligned for cohesion */
  .booking-page .product-hero .product-philosophy {
    text-align: left;
    align-items: flex-start;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
  }
  .booking-page .product-hero .product-philosophy .product-blurb {
    margin-inline: 0;
    max-width: 60ch;
  }
  /* Desktop legacy #book hide handled globally below via off-screen technique */
}

/* Hide the legacy inline #book card on ALL viewports — we already have the
   bottom sticky CTA + drawer flow. The #book section stays in the DOM so
   booking.js, PayPal mount points, calendar IDs and hidden fields keep working.
   We position it off-screen ONLY when it is still in its original location
   (not when the drawer has portaled it into .st-drawer__content). */
body.booking-page > #book,
body.booking-page main > #book,
body.booking-page > * > #book:not(.st-drawer__content #book) {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  pointer-events: none !important;
  visibility: visible; /* must stay visible for JS to read inputs */
}
/* When the drawer pulls #book into .st-drawer__content, fully restore it */
.st-drawer__content #book,
.st-drawer__content #book * {
  position: static !important;
  left: auto !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  pointer-events: auto !important;
}

/* ============================================================
   2. Sticky Booking Rail — premium card (desktop only)
   ============================================================ */
.pf-book-rail {
  display: none;             /* hidden on mobile; opt-in on desktop */
}
@media (min-width: 1024px) {
  .pf-book-rail {
    display: block;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 22px;
    box-shadow:
      0 2px 4px rgba(10,31,44,.04),
      0 18px 40px -12px rgba(10,31,44,.16);
  }
  .pf-book-rail__price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
  }
  .pf-book-rail__price b {
    font-family: var(--font-display);
    font-size: 1.85rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.015em;
  }
  .pf-book-rail__price span {
    font-size: 0.85rem;
    color: var(--muted);
  }
  .pf-book-rail__rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--ink-2);
    margin-bottom: 16px;
  }
  .pf-book-rail__rating .star {
    color: var(--accent);
  }
  .pf-book-rail__fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 14px;
  }
  .pf-book-rail__field {
    padding: 10px 12px;
    background: #fff;
    cursor: pointer;
    border: 0;
    text-align: left;
    font: inherit;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 120ms var(--ease);
  }
  .pf-book-rail__field + .pf-book-rail__field {
    border-left: 1px solid var(--line);
  }
  .pf-book-rail__field:hover,
  .pf-book-rail__field:focus-visible {
    background: var(--paper);
    outline: 0;
  }
  .pf-book-rail__field-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
  }
  .pf-book-rail__field-value {
    font-size: 0.92rem;
    color: var(--ink-2);
  }
  .pf-book-rail__cta {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    background: var(--accent);
    color: var(--ink);
    font-weight: 700;
    font-size: 1rem;
    border: 0;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(10,31,44,.08);
    transition: background 120ms var(--ease), transform 120ms var(--ease);
  }
  .pf-book-rail__cta:hover {
    background: var(--accent-h);
    transform: translateY(-1px);
  }
  .pf-book-rail__fineprint {
    margin-top: 14px;
    font-size: 0.78rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
  }
  .pf-book-rail__trust {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .pf-book-rail__trust-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--ink-2);
  }
  .pf-book-rail__trust-item svg {
    width: 14px;
    height: 14px;
    color: var(--teal);
    flex-shrink: 0;
  }

  /* Also hide the desktop sticky bottom bar on product pages — the rail replaces it */
  .booking-page .sticky-cta { display: none !important; }
}

/* ============================================================
   3. GALLERY — 2-column collage that fits one screen
   ============================================================ */
@media (min-width: 1024px) {
  .gallery-section .photo-grid {
    grid-template-columns: 1.4fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    max-width: 1240px;
    max-height: 580px;
  }
  .gallery-section .photo-card:nth-child(1) {
    grid-row: 1 / 3;
    grid-column: 1 / 2;
  }
  .gallery-section .photo-card:nth-child(n+2):nth-child(-n+5) {
    grid-row: auto;
    grid-column: auto;
  }
  .gallery-section .photo-card:nth-child(n+6) {
    display: none; /* show only 5 in the collage to fit one screen */
  }
  .gallery-section .photo-card .card-media {
    aspect-ratio: auto;
    height: 100%;
  }
  .gallery-section .photo-card {
    min-height: 0;
  }
  .gallery-section .photo-card .card-body {
    padding: 12px 16px 14px;
  }
  .gallery-section .photo-card h3 {
    font-size: 1.05rem;
  }
  .gallery-section .photo-card p {
    font-size: 0.82rem;
    -webkit-line-clamp: 1;
  }
}

/* ============================================================
   4. WHY CARDS — true 4-up with clamped responsive text
   ============================================================ */
@media (min-width: 1100px) {
  .why-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 18px;
  }
  .why-card {
    padding: 22px 20px;
  }
  .why-card h3 {
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.25;
  }
  .why-card p {
    font-size: clamp(0.82rem, 0.95vw, 0.9rem);
    line-height: 1.55;
  }
  .why-card .why-icon {
    margin-bottom: 10px;
  }
}

/* ============================================================
   5. SECTION HEIGHT CLAMPS — desktop only
   ============================================================ */
@media (min-width: 1024px) {
  /* Hero stays cinematic */
  .hero {
    min-height: 80vh;
  }
  /* Content sections get a sane vertical clamp */
  .booking-page section:not(.product-hero):not(.hero):not(#book):not(.gallery-section) {
    min-height: 480px;
  }
  /* Gallery section caps its own height via the grid above */
  .booking-page .gallery-section {
    min-height: 480px;
    max-height: 760px;
  }
}

/* ============================================================
   6. VIDEO LIGHTBOX — compact centered modal w/ fullscreen toggle
   ============================================================ */
.video-lightbox {
  background: rgba(5, 12, 20, 0.78) !important;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 24px !important;
}
.video-lightbox-stage {
  width: min(92vw, 960px) !important;
  height: auto !important;
  max-height: min(80vh, 540px) !important;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 80px -20px rgba(0,0,0,.6);
  background: #000;
}
.video-lightbox-stage video {
  border-radius: 20px !important;
  width: 100% !important;
  height: 100% !important;
}
.video-lightbox-close {
  top: 16px !important;
  right: 16px !important;
  width: 44px !important;
  height: 44px !important;
  background: rgba(255,255,255,.95) !important;
  color: var(--ink) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.video-lightbox-close:hover {
  background: #fff !important;
}
/* Fullscreen toggle button — injected by JS */
.video-lightbox-fullscreen {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  opacity: 0;
  transition: opacity 180ms var(--ease), background 120ms var(--ease);
}
.video-lightbox-stage:hover .video-lightbox-fullscreen,
.video-lightbox-fullscreen:focus-visible {
  opacity: 1;
}
.video-lightbox-fullscreen:hover {
  background: rgba(0,0,0,.85);
}
.video-lightbox-fullscreen svg {
  width: 18px;
  height: 18px;
}
@media (max-width: 1023px) {
  /* Mobile keeps a roomy stage but no longer truly fullscreen */
  .video-lightbox-stage {
    width: 100% !important;
    max-height: 70vh !important;
    border-radius: 14px;
  }
  .video-lightbox-fullscreen {
    opacity: 1; /* always visible on touch */
  }
}
