/* =============================================================================
   booking.css — modal shell for the Calendly booking widget
   -----------------------------------------------------------------------------
   Paired with assets/booking.js. Visual rules:
     • Backdrop is a soft, blurred dim — never pure black.
     • Panel matches the project's dark cinematic palette.
     • Inline Calendly iframe gets a transparent background so it inherits the
       panel surface; we set its theme + brand color via Calendly query params
       (booking.js builds the URL).
     • Reduced-motion users get an instant fade-in instead of a slide.

   Selector contract (mirrors booking.js):
     .booking-modal[data-open="true"]
       .booking-modal__panel        — sized container
         .booking-modal__head        — title + close button
         .booking-modal__embed       — Calendly inline-widget mount (≥520px)
         .booking-modal__fallback    — shown when Calendly fails / opt-out
   ========================================================================== */

.booking-modal {
  position: fixed;
  inset: 0;
  z-index: 200;                       /* above chatbot (90) and cookie banner (80) */
  display: none;
  align-items: stretch;
  justify-content: center;
  background: color-mix(in oklab, var(--bg-0) 70%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: clamp(12px, 3vw, 32px);
  overflow-y: auto;
  /* Use overscroll-behavior so scroll inside the panel doesn't bubble. */
  overscroll-behavior: contain;
}
.booking-modal[data-open="true"] {
  display: flex;
  animation: booking-fade .25s ease-out both;
}
@keyframes booking-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.booking-modal__panel {
  position: relative;
  width: min(960px, 100%);
  max-height: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
  animation: booking-rise .3s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes booking-rise {
  from { transform: translateY(12px); }
  to   { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .booking-modal[data-open="true"] { animation: none; }
  .booking-modal__panel             { animation: none; }
}

/* Header --------------------------------------------------------------- */
.booking-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg-1) 92%, transparent);
}
.booking-modal__head__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.booking-modal__head__title strong {
  font-size: 16px;
  color: var(--fg-0);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.booking-modal__head__title span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.booking-modal__close {
  width: 36px; height: 36px;
  border-radius: 999px;
  display: grid; place-items: center;
  color: var(--fg-1);
  border: 1px solid var(--line);
  background: transparent;
  transition: color .2s, background .2s, border-color .2s;
  flex: none;
}
.booking-modal__close:hover {
  color: var(--fg-0);
  background: var(--line);
  border-color: var(--line-strong);
}
.booking-modal__close svg { width: 14px; height: 14px; }

/* Embed mount ---------------------------------------------------------- */
/* Calendly's inline widget injects an <iframe>; we set min-height so it
 * never collapses while loading. The actual content gets a transparent
 * background via the &embed_domain & &background_color query params built
 * in booking.js — those are critical for the embed to feel native.
 */
.booking-modal__embed {
  flex: 1 1 auto;
  /* Adapt to viewport: tall enough for desktop, compact enough that
   * iPhone SE (667px viewport - chrome ≈ 90px) doesn't get a double
   * scrollbar. dvh handles dynamic mobile chrome correctly. */
  min-height: clamp(420px, 70dvh, 620px);
  background: var(--bg-1);
  position: relative;
}
.booking-modal__embed iframe {
  width: 100%; height: 100%;
  min-height: clamp(420px, 70dvh, 620px);
  border: 0;
  display: block;
}

/* Loading state — shimmer behind the iframe until Calendly paints */
.booking-modal__loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px;
  color: var(--fg-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(110deg,
    color-mix(in oklab, var(--bg-1) 70%, transparent) 30%,
    color-mix(in oklab, var(--bg-2) 90%, transparent) 50%,
    color-mix(in oklab, var(--bg-1) 70%, transparent) 70%);
  background-size: 200% 100%;
  animation: booking-shimmer 1.4s linear infinite;
  pointer-events: none;
}
.booking-modal[data-loaded="true"] .booking-modal__loading { display: none; }
@keyframes booking-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .booking-modal__loading { animation: none; }
}

/* Fallback panel — shown when Calendly fails or the user opts out of
 * the marketing-cookies category. Always present in the DOM so we can
 * focus it on error.                                                       */
.booking-modal__fallback {
  display: none;
  padding: clamp(28px, 4vw, 48px);
  text-align: center;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  color: var(--fg-1);
}
.booking-modal__fallback h3 {
  font-size: 22px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--fg-0);
}
.booking-modal__fallback p { max-width: 52ch; line-height: 1.5; }
.booking-modal[data-fallback="true"] .booking-modal__embed   { display: none; }
.booking-modal[data-fallback="true"] .booking-modal__fallback{ display: flex; }


/* Standalone /book.html embed (no modal chrome — the page is the surface).
 * Same height-clamp rationale as the modal: cap at 720px on desktop,
 * collapse to ~85% of viewport height on phones so the embed never
 * exceeds the screen and forces the page to scroll past it. */
.booking-page-embed {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  min-height: min(720px, 85dvh);
  background: var(--bg-1);
  position: relative;
}
.booking-page-embed iframe { width: 100%; height: 100%; min-height: min(720px, 85dvh); border: 0; display: block; }
