/* ==========================================================================
   Booking Modal Component
   ========================================================================== */

/* Body scroll lock when modal is open */
body.modal-open {
  overflow: hidden;
  touch-action: none;
}

/* ── Modal wrapper ──────────────────────────────────────────────────────────
   Lives in the DOM at all times.
   Default state: invisible but not removed so transitions are possible.
   visibility is delayed on close (0s on open, delay on close) so the
   modal stays interactive during the entire fade-out.
   ─────────────────────────────────────────────────────────────────────────── */
.booking-modal {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: grid;
  place-items: center;
  padding: var(--space-4, 16px);
  /* Start invisible */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* On close: fade opacity, then collapse visibility and push to back after the fade */
  transition:
    opacity var(--duration-base, 320ms) ease,
    visibility 0s linear var(--duration-base, 320ms),
    z-index 0s linear var(--duration-base, 320ms);
}

.booking-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 9999;
  /* On open: show visibility and pull to front immediately, then fade opacity in */
  transition:
    opacity var(--duration-base, 320ms) ease,
    visibility 0s linear 0s,
    z-index 0s linear 0s;
}

/* ── Overlay ────────────────────────────────────────────────────────────────
   The tinted / blurred backdrop.
   CRITICAL: backdrop-filter, background-color, and opacity ALL start at
   their "zero" values so nothing is visible before .is-open is applied.
   ─────────────────────────────────────────────────────────────────────────── */
.booking-modal__overlay {
  position: absolute;
  inset: 0;
  /* Fully transparent starting values */
  background: rgba(16, 36, 23, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  opacity: 0;
  transition:
    opacity var(--duration-base, 320ms) ease,
    background var(--duration-base, 320ms) ease,
    backdrop-filter var(--duration-base, 320ms) ease,
    -webkit-backdrop-filter var(--duration-base, 320ms) ease;
}

.booking-modal.is-open .booking-modal__overlay {
  opacity: 1;
  background: rgba(16, 36, 23, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ── Panel ──────────────────────────────────────────────────────────────────
   Glass panel that slides/scales/blurs in.
   z-index: 2 ensures it sits above the absolute overlay.
   ─────────────────────────────────────────────────────────────────────────── */
.booking-modal__panel {
  position: relative;
  z-index: 2;
  width: calc(100vw - 4rem);
  height: calc(100vh - 4rem);
  max-height: calc(100vh - 4rem);
  background-color: rgba(22, 27, 22, 0.65);
  /* Dark green translucent */
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(250, 248, 243, 0.1);
  border-radius: var(--radius-lg, 24px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* Starting state */
  opacity: 0;
  transform: translateY(28px) scale(0.96);
  filter: blur(8px);
  will-change: opacity, transform, filter;
  transition:
    opacity var(--duration-base, 320ms) ease,
    transform var(--duration-modal, 560ms) var(--ease-premium, cubic-bezier(0.22, 1, 0.36, 1)),
    filter var(--duration-base, 320ms) ease;
}

.booking-modal.is-open .booking-modal__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

/* Close Button */
.booking-modal__close {
  position: absolute;
  top: 28px;
  right: 28px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-bg);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    transform 360ms var(--ease-premium),
    background-color 220ms ease,
    color 220ms ease,
    opacity 220ms ease;
}

.booking-modal__close:hover {
  transform: rotate(90deg) scale(1.05);
  background: rgba(247, 244, 238, 0.08);
}

.booking-modal__close:active {
  transform: rotate(90deg) scale(0.96);
}

.booking-modal__close:focus-visible {
  outline: 2px solid var(--color-bg);
  outline-offset: 2px;
}

/* Views */
.booking-modal__view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 64px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  filter: blur(6px);
  transition: opacity var(--duration-base) var(--ease-premium), transform var(--duration-base) var(--ease-premium), filter var(--duration-base) var(--ease-premium), visibility var(--duration-base) var(--ease-premium);
}

.booking-modal.is-open .booking-modal__view--active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  filter: blur(0);
}

/* Layout Structure for Options View */
.booking-modal__options-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
  /* Vertically center the layout */
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* Header area inside Options */
.booking-modal__header {
  text-align: left;
  max-width: 650px;
}

/* Header area inside Calendar (mobile/tablet only — hidden on desktop) */
#bookingModalCalendar {
  overflow: visible;
}

#bookingModalCalendar > .booking-modal__header {
  max-width: none;
  margin-bottom: 20px;
  flex-shrink: 0;
}

/* ── Split layout: passthrough on mobile/tablet ───────────────────────────── */
/* display:contents makes the div invisible to layout — children behave as     */
/* direct children of the flex column view, preserving the existing mobile UX. */
.booking-modal__calendar-layout {
  display: contents;
}

/* Hidden until ≥1200px — the aside is desktop-only */
.booking-modal__service-summary {
  display: none;
}

/* Desktop-only back button inside aside — hidden until aside is shown */
#bookingModalBackDesktop {
  display: none;
}

/* Summary text elements — hidden until ≥1200px */
.booking-modal__summary-title,
.booking-modal__summary-desc,
.booking-modal__summary-meta,
.booking-modal__summary-divider,
.booking-modal__summary-note {
  display: none;
}

.booking-modal__eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(250, 248, 243, 0.6);
  /* Cream translucent */
  margin-bottom: 16px;
  text-transform: uppercase;
}

.booking-modal__title {
  font-family: var(--font-heading);
  font-size: clamp(2.5rem, 4vw, 3.5rem);
  color: var(--color-bg);
  /* Cream */
  line-height: 1.1;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.booking-modal__title--small {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  margin-bottom: 0;
}

.booking-modal__desc {
  font-size: var(--text-md);
  color: rgba(250, 248, 243, 0.8);
  line-height: 1.5;
  margin: 0;
}

/* Back Button */
.booking-modal__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: rgba(250, 248, 243, 0.7);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 20px;
  transition: color var(--transition-fast) ease;
}

.booking-modal__back:hover {
  color: var(--color-bg);
}

/* Options Grid */
.booking-modal__grid {
  display: grid;
  grid-template-columns: 1fr;
  /* Single column on right side */
  gap: 16px;
  width: 100%;
  max-width: 600px;
  margin-left: auto;
}

/* Option Card */
.booking-option-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background-color: rgba(250, 248, 243, 0.95);
  /* Mostly solid cream for readability */
  border: 1px solid rgba(250, 248, 243, 0.1);
  border-radius: 16px;
  padding: 24px;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1);
}

.booking-option-card:hover {
  transform: translateY(-4px);
  background-color: #ffffff;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
}

.booking-option-card__title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-green-dark);
  margin-bottom: 8px;
}

.booking-option-card__desc {
  font-size: var(--text-sm);
  color: rgba(46, 65, 46, 0.7);
  line-height: 1.4;
  margin: 0;
}

.booking-option-card__arrow {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: rgba(46, 65, 46, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-green-dark);
  transition: background-color var(--transition-fast) ease, transform var(--transition-fast) ease;
}

.booking-option-card:hover .booking-option-card__arrow {
  background-color: var(--color-green-dark);
  color: #ffffff;
  transform: translateX(4px);
}

/* Calendar Embed Container */
.booking-modal__embed-wrapper {
  margin: auto 0;
  width: 100%;
  min-width: 0;
  min-height: 480px;
  max-height: 70vh;
  height: auto;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  background-color: #ffffff;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* For custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(46, 65, 46, 0.3) transparent;
}

.booking-modal__embed-wrapper::-webkit-scrollbar {
  width: 6px;
}

.booking-modal__embed-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.booking-modal__embed-wrapper::-webkit-scrollbar-thumb {
  background-color: rgba(46, 65, 46, 0.3);
  border-radius: 20px;
}

/* Loading State */
.booking-modal__loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #ffffff;
  z-index: 99;
  /* Ensure it stays above any Cal.com injected overlays */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-premium), visibility var(--duration-base) var(--ease-premium);
}

.booking-modal.is-open .booking-modal__loading.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.booking-modal__spinner {
  width: 48px;
  height: 48px;
  margin-bottom: 24px;
  animation: rotate 2s linear infinite;
}

.booking-modal__spinner .path {
  stroke: var(--color-green-dark);
  stroke-linecap: round;
  animation: dash 1.5s ease-in-out infinite;
}

@keyframes rotate {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes dash {
  0% {
    stroke-dasharray: 1, 150;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -35;
  }

  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -124;
  }
}

.booking-modal__loading-text {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-green-dark);
  margin-bottom: 8px;
}

.booking-modal__loading-subtext {
  font-size: var(--text-sm);
  color: rgba(46, 65, 46, 0.6);
}

.booking-modal__embed-container {
  width: 100%;
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-premium), visibility var(--duration-slow) var(--ease-premium);
}

.booking-modal.is-open .booking-modal__embed-container.is-loaded {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Ensure Cal.com iframes fill and stabilize */
.booking-modal__embed-container iframe {
  width: 100% !important;
  min-width: 0 !important;
  border: none !important;
}

/* Responsive */
@media (max-width: 1024px) {
  .booking-modal__options-layout {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 40px;
  }

  .booking-modal__header,
  .booking-modal__grid {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
  }

  .booking-modal__desc {
    font-size: var(--text-base);
  }
}

@media (max-width: 768px) {
  .booking-modal {
    padding: 0;
    /* Full edge-to-edge on mobile */
  }

  .booking-modal__panel {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .booking-modal__view {
    padding: 32px 24px;
    padding-top: 80px;
    /* Space for close button */
  }

  .booking-modal__close {
    top: 18px;
    right: 18px;
  }

  .booking-modal__options-layout {
    gap: 24px;
    align-content: start;
  }

  .booking-modal__header {
    margin-bottom: 0;
  }

  .booking-modal__title {
    font-size: clamp(2rem, 8vw, 2.5rem);
    margin-bottom: 12px;
  }

  .booking-option-card {
    padding: 16px 20px;
    gap: 16px;
  }

  .booking-option-card__title {
    font-size: var(--text-base);
    margin-bottom: 4px;
  }

  .booking-modal__grid {
    gap: 12px;
  }

  .booking-modal__embed-wrapper {
    align-items: flex-start;
    padding: 16px;
  }

  /* Mobile Service Summary styling */
  #bookingModalCalendar > .booking-modal__header #bookingModalEmbedTitle {
    display: none;
  }

  .booking-modal__calendar-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
  }

  .booking-modal__service-summary {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 8px;
    text-align: center;
    align-items: center;
  }

  .booking-modal__summary-title {
    display: block;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-bg);
    line-height: 1.2;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
  }

  .booking-modal__summary-desc {
    display: block;
    font-size: var(--text-xs);
    color: rgba(250, 248, 243, 0.65);
    line-height: 1.4;
    max-width: 480px;
    margin: 0 auto 12px auto;
  }

  .booking-modal__summary-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
  }

  .booking-modal__summary-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(247, 244, 238, 0.06);
    border: 1px solid rgba(247, 244, 238, 0.1);
    font-size: var(--text-xs);
    color: rgba(250, 248, 243, 0.85);
  }

  .booking-modal__summary-meta-item svg {
    flex-shrink: 0;
    opacity: 0.7;
    color: var(--color-bg);
  }

  .booking-modal__summary-divider,
  .booking-modal__summary-note,
  #bookingModalBackDesktop {
    display: none !important;
  }
}

@media (max-width: 480px) {
  .booking-modal__view {
    padding: 24px 16px;
    padding-top: 72px;
  }

  .booking-modal__close {
    top: 12px;
    right: 12px;
  }

  .booking-option-card__desc {
    display: none;
    /* Hide descriptions to keep options screen compact on small phones */
  }

  .booking-option-card {
    align-items: center;
  }
}

/* Tablet Specific Overrides (768px to 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  .booking-modal__panel {
    min-width: 720px;
    max-height: 90vh;
    overflow: hidden;
  }

  .booking-modal__view {
    padding: 40px 24px;
    padding-top: 80px;
  }

  #bookingModalCalendar {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .booking-modal__calendar-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    height: auto;
  }

  /* Hide the mobile compact header on tablet, as summary details row replaces it */
  #bookingModalCalendar > .booking-modal__header {
    display: none;
  }

  /* Show and style summary above the calendar */
  .booking-modal__service-summary {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border: 0;
    text-align: center;
    align-items: center;
  }

  #bookingModalBackDesktop {
    display: inline-flex;
    margin-bottom: 16px;
    align-self: center;
  }

  .booking-modal__summary-title {
    display: block;
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    font-weight: 600;
    color: var(--color-bg);
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: 8px;
    text-align: center;
  }

  .booking-modal__summary-desc {
    display: block;
    font-size: var(--text-sm);
    color: rgba(250, 248, 243, 0.68);
    line-height: 1.5;
    max-width: 580px;
    margin: 0 auto 16px auto;
    text-align: center;
  }

  .booking-modal__summary-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
    margin-bottom: 0;
  }

  .booking-modal__summary-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(247, 244, 238, 0.08);
    border: 1px solid rgba(247, 244, 238, 0.12);
    font-size: var(--text-xs);
    color: rgba(250, 248, 243, 0.8);
  }

  .booking-modal__summary-meta-item svg {
    flex-shrink: 0;
    opacity: 0.7;
    color: var(--color-bg);
  }

  .booking-modal__summary-divider,
  .booking-modal__summary-note {
    display: none !important;
  }

  /* Wide calendar shell centering */
  .booking-modal__embed-wrapper {
    width: 100%;
    max-width: 900px;
    min-width: 0;
    margin: 0 auto;
    padding: 16px;
    border-radius: 20px;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
  }

  .booking-modal__embed-container {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .booking-modal__embed-container iframe {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 520px !important;
    height: min(560px, calc(100vh - 320px)) !important;
    border: 0 !important;
    border-radius: 10px;
  }

  .booking-modal__close {
    top: 24px;
    right: 24px;
  }
}

/* ── Desktop Split Layout (≥1200px) ──────────────────────────────────────── */
@media (min-width: 1200px) {

  /* Calendar view: tighter padding to give the split grid maximum room */
  #bookingModalCalendar {
    padding: 36px 80px 36px 44px;
    overflow: visible;
  }

  /* Hide the mobile/tablet header (back btn + embed title) — replaced by aside */
  #bookingModalCalendar > .booking-modal__header {
    display: none;
  }

  /* Activate the grid wrapper */
  .booking-modal__calendar-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    height: 100%;
    width: 100%;
  }

  /* ── Left panel: service summary ──────────────────────────────────────── */
  .booking-modal__service-summary {
    display: flex;
    flex-direction: column;
    background: rgba(250, 248, 243, 0.055);
    border: 1px solid rgba(250, 248, 243, 0.11);
    border-radius: 20px;
    padding: 28px 22px;
    min-width: 0;
    overflow: hidden;
  }

  /* Desktop back button inside the aside */
  #bookingModalBackDesktop {
    display: inline-flex;
    margin-bottom: 28px;
  }

  /* Summary heading */
  .booking-modal__summary-title {
    display: block;
    font-family: var(--font-heading);
    font-size: clamp(1.35rem, 1.8vw, 1.7rem);
    font-weight: 600;
    color: var(--color-bg);
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: 12px;
  }

  /* Summary description */
  .booking-modal__summary-desc {
    display: block;
    font-size: var(--text-sm);
    color: rgba(250, 248, 243, 0.68);
    line-height: 1.6;
    margin-bottom: 24px;
  }

  /* Meta rows (clock / video / globe) */
  .booking-modal__summary-meta {
    display: flex;
    flex-direction: column;
    gap: 11px;
    margin-bottom: 22px;
  }

  .booking-modal__summary-meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--text-sm);
    color: rgba(250, 248, 243, 0.58);
  }

  .booking-modal__summary-meta-item svg {
    flex-shrink: 0;
    opacity: 0.55;
  }

  /* Subtle divider */
  .booking-modal__summary-divider {
    display: block;
    height: 1px;
    background: rgba(250, 248, 243, 0.09);
    margin-bottom: 20px;
  }

  /* Helper note — pushed to bottom */
  .booking-modal__summary-note {
    display: block;
    font-size: 0.775rem;
    color: rgba(250, 248, 243, 0.38);
    line-height: 1.6;
    margin-top: auto;
  }

  /* ── Right column: embed wrapper — white padded shell ─────────────────── */
  #bookingModalCalendar .booking-modal__embed-wrapper {
    /* White shell visible on all four sides */
    background: #f7f5f0;
    border-radius: 20px;
    padding: 18px;
    box-sizing: border-box;

    /* Flex column so embed-container fills height naturally */
    display: flex;
    flex-direction: column;
    align-items: stretch;

    /* Sizing */
    min-height: 520px;
    height: 100%;
    max-height: calc(100vh - 180px);

    /* Clip only at the rounded corners — no scroll on the shell itself */
    overflow: hidden;

    /* Reset base rules that would fight us */
    margin: 0;
    justify-content: flex-start;
  }

  /* Embed container fills the shell interior */
  #bookingModalCalendar .booking-modal__embed-container {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    /* No margin:auto — that would collapse the shell padding */
    margin: 0;
  }

  /* iframe fills the container but not the shell padding */
  #bookingModalCalendar .booking-modal__embed-container iframe {
    display: block;
    width: 100% !important;
    /* Subtract 2×shell padding (36px total) from the height so
       top and bottom white frame remains visible */
    min-height: 480px !important;
    height: min(600px, calc(100vh - 220px)) !important;
    max-height: calc(100vh - 220px) !important;
    border: 0 !important;
    border-radius: 10px;
    box-sizing: border-box;
  }
}

/* ── Reduced Motion ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .booking-modal,
  .booking-modal.is-open {
    transition: opacity 0.1ms ease, visibility 0s linear 0s;
  }

  .booking-modal__overlay {
    transition: opacity 0.1ms ease;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .booking-modal__panel {
    transition: opacity 0.1ms ease !important;
    transform: none !important;
    filter: none !important;
    will-change: auto;
  }

  .booking-modal__view {
    transition: opacity 0.1ms ease, visibility 0s linear !important;
    transform: none !important;
    filter: none !important;
  }

  .booking-modal__close,
  .booking-modal__close:hover,
  .booking-modal__close:active {
    transition: none !important;
    transform: none !important;
  }
}
