/* ==========================================================================
   Beach Pass KSA — booking UI (loaded on every page)
   Calendar, popovers, guest steppers, beach-page booking widget, availability section,
   access legend / notes, price lines. Checkout page layout lives in pages/book.css.
   ========================================================================== */

/* ----- Calendar (BP.Calendar in assets/js/calendar.js) ----- */
.cal {
  --cal-cell: 42px;
  --cal-gap: 2px;
  position: relative;
  font-family: var(--ff-body);
  color: var(--c-ink);
  -webkit-user-select: none;
  user-select: none;
}
.cal--compact { --cal-cell: 38px; }
.cal__nav { position: absolute; inset: 0 0 auto 0; height: 0; z-index: 2; }
.cal__arrow {
  position: absolute; top: 0; width: 36px; height: 36px;
  display: grid; place-items: center; border: 1px solid #e3e3df; border-radius: 50%;
  background: var(--c-white); color: var(--c-ink);
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), opacity var(--t-fast);
}
.cal__arrow::before { content: ""; position: absolute; inset: -4px; } /* 44px hit area */
.cal__arrow--prev { left: 0; }
.cal__arrow--next { right: 0; }
.cal__arrow .icon { width: 12px; height: 12px; stroke-width: 1.8; }
.cal__arrow:hover:not(:disabled) { border-color: var(--c-lagoon); color: var(--c-lagoon); }
.cal__arrow:disabled { opacity: 0.3; cursor: default; }

.cal__months { display: grid; grid-template-columns: max-content; justify-content: center; gap: 40px; }
.cal--double .cal__months { grid-template-columns: max-content max-content; }
.cal__title {
  display: flex; align-items: center; justify-content: center; height: 36px; margin-bottom: 8px;
  font-family: var(--ff-heading); font-size: 18px; line-height: 1; color: var(--c-ink);
}
.cal__grid {
  /* explicit width keeps min-content sizing exact for popovers and the 2-month grid */
  width: calc(7 * var(--cal-cell) + 8 * var(--cal-gap));
  border-collapse: separate; border-spacing: var(--cal-gap); margin: 0 auto; table-layout: fixed;
}
.cal__grid th {
  width: var(--cal-cell); height: 28px; padding: 0;
  font-size: 11px; font-weight: 500; line-height: 1; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--c-muted); text-align: center;
}
.cal__grid td { width: var(--cal-cell); height: var(--cal-cell); padding: 0; }

.cal__day {
  --a: var(--c-lagoon);
  position: relative; display: flex; align-items: center; justify-content: center;
  width: var(--cal-cell); height: var(--cal-cell); padding: 0;
  border: 1px solid transparent; border-radius: 2px; background: transparent; color: var(--c-ink);
  font-size: 14px; line-height: 1; font-variant-numeric: tabular-nums;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.cal__num { position: relative; }
.cal__day:not(.is-disabled):hover { border-color: var(--a); }
.cal__day:focus-visible { outline: 2px solid var(--c-lagoon); outline-offset: 1px; z-index: 1; }

/* Access colours (only on bookable days of a beach calendar) */
.cal--beach .cal__day:not(.is-disabled) { padding-bottom: 9px; }
.cal__day--family { --a: var(--access-family); background: rgba(15, 110, 118, 0.05); }
.cal__day--ladies { --a: var(--access-ladies); background: var(--access-ladies-bg); }
.cal__day--women_kids { --a: var(--access-women_kids); background: var(--access-women_kids-bg); }
.cal__day--closed { --a: var(--access-closed); background: var(--access-closed-bg); color: var(--access-closed); }
.cal__day--closed .cal__num { text-decoration: line-through; text-decoration-thickness: 1px; }
.cal__icon {
  position: absolute; left: 50%; bottom: 5px; width: 12px; height: 12px; margin-left: -6px;
  color: var(--a); stroke-width: 1.6; pointer-events: none;
}

/* Unavailable (outside the booking window / past) */
.cal__day.is-disabled { cursor: default; }
.cal__day.is-disabled:not(.cal__day--closed) { color: #c4c6c1; }
.cal__day.is-today .cal__num::after {
  content: ""; position: absolute; left: -3px; right: -3px; bottom: -5px; height: 1px; background: currentColor; opacity: 0.7;
}

/* Selected */
.cal__day.is-selected,
.cal__day.is-selected:hover {
  --a: var(--c-white);
  background: var(--c-lagoon); border-color: var(--c-lagoon); color: var(--c-white);
}

/* Month change: short fade + slide (skipped with reduced motion) */
.cal__months.is-anim-next .cal__month { animation: bp-cal-next 0.22s var(--ease-out) both; }
.cal__months.is-anim-prev .cal__month { animation: bp-cal-prev 0.22s var(--ease-out) both; }
@keyframes bp-cal-next { from { opacity: 0; transform: translateX(10px); } }
@keyframes bp-cal-prev { from { opacity: 0; transform: translateX(-10px); } }

/* Legend */
.cal__legend { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--c-line); }
.cal__legend .access-legend { justify-content: center; }
.access-legend { list-style: none; margin: 0; padding: 0; }
.access-legend__item { --a: var(--access-family); --a-bg: rgba(15, 110, 118, 0.08); line-height: 1.4; }
.access-legend__item--family { --a: var(--access-family); --a-bg: rgba(15, 110, 118, 0.08); }
.access-legend__item--ladies { --a: var(--access-ladies); --a-bg: var(--access-ladies-bg); }
.access-legend__item--women_kids { --a: var(--access-women_kids); --a-bg: var(--access-women_kids-bg); }
.access-legend__item--closed { --a: var(--access-closed); --a-bg: var(--access-closed-bg); }
.access-legend__swatch {
  position: relative; display: grid; place-items: center; flex: none;
  width: 20px; height: 20px; border-radius: 2px; background: var(--a-bg); color: var(--a);
}
.access-legend__swatch .icon { width: 13px; height: 13px; stroke-width: 1.6; }
.access-legend__item--closed .access-legend__swatch::after { content: ""; width: 11px; height: 1px; background: var(--a); }

/* ----- Popovers (search bar, booking widget) ----- */
.search-popover,
.bp-popover {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: max-content; min-width: 100%; max-width: calc(100vw - 24px);
  padding: 20px; background: var(--c-white); color: var(--c-text);
  border: 1px solid #e6e6e6; box-shadow: 0 18px 50px rgba(17, 17, 17, 0.14);
  font-size: 15px; line-height: 1.5; text-align: left;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.search-popover.is-open,
.bp-popover.is-open { opacity: 1; transform: none; }
.search-popover:focus,
.bp-popover:focus { outline: none; }
.search-popover :focus-visible,
.bp-popover :focus-visible { outline-color: var(--c-lagoon); }
.search-field.is-open,
.bw-field.is-open { z-index: 40; }
.search-popover--date,
.bp-popover--date { width: min-content; }
.search-popover--guests { width: 380px; }
.search-form--stacked .search-popover--guests { width: 100%; }
.search-popover__note {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--c-line);
  font-size: 13px; line-height: 1.5; color: var(--c-muted);
}
.search-popover__note .icon { width: 15px; height: 15px; margin-top: 2px; color: var(--c-lagoon); }
.search-popover__actions { display: flex; align-items: center; justify-content: flex-end; gap: 22px; padding-top: 18px; }
.search-popover__actions .btn { width: auto; height: 44px; padding: 0 30px; }
.search-popover__link {
  position: relative; padding: 12px 2px; font-family: var(--ff-heading); font-size: 15px; line-height: 1; color: var(--c-ink);
}
.search-popover__link::after {
  content: ""; position: absolute; left: 2px; right: 2px; bottom: 8px; height: 1px; background: var(--c-lagoon);
  transform: scaleX(0); transform-origin: right; transition: transform var(--t) var(--ease);
}
.search-popover__link:hover::after { transform: scaleX(1); transform-origin: left; }

/* Sheet heading and backdrop (only used when the popover becomes a bottom sheet) */
.popover-head { display: none; }
.sheet-backdrop { display: none; }

/* ----- Guest rows + steppers ----- */
.guest-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--c-line);
}
.search-popover > .guest-row:first-child,
.popover-head + .guest-row { padding-top: 2px; }
.guest-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.guest-row__label { font-family: var(--ff-heading); font-size: 17px; line-height: 1.3; color: var(--c-ink); }
.guest-row__hint { font-size: 13px; line-height: 1.4; color: var(--c-muted); }
.guest-row__hint:empty { display: none; } /* rows without a hint (e.g. Adults) keep their label centred */
.stepper { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.stepper__btn {
  position: relative; display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid #cfd2cc; border-radius: 50%; background: var(--c-white); color: var(--c-ink);
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease), opacity var(--t-fast);
}
.stepper__btn::before { content: ""; position: absolute; inset: -4px; } /* 44px hit area */
.stepper__btn .icon { width: 12px; height: 12px; stroke-width: 1.8; }
.stepper__btn:hover:not(.is-disabled) { border-color: var(--c-lagoon); color: var(--c-lagoon); }
.stepper__btn:active:not(.is-disabled) { background: var(--c-foam); }
.stepper__btn.is-disabled { opacity: 0.35; cursor: not-allowed; }
.stepper__input {
  width: 42px; height: 36px; padding: 0; border: 0; border-radius: 2px; background: transparent;
  font-size: 16px; font-weight: 500; line-height: 1; text-align: center; color: var(--c-ink);
  -moz-appearance: textfield; appearance: textfield;
}
.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__input:focus { outline: none; }
.stepper__input:focus-visible { outline: 2px solid var(--c-lagoon); outline-offset: 0; }
@media (pointer: coarse) {
  .stepper__btn { width: 44px; height: 44px; }
  .stepper__btn::before { display: none; }
}

/* ----- Access notes + price lines (widget, checkout summary) ----- */
.access-note {
  --a: var(--access-family); --a-bg: var(--access-family-bg);
  padding: 16px 18px; background: var(--a-bg); border-left: 3px solid var(--a);
}
.access-note--ladies { --a: var(--access-ladies); --a-bg: var(--access-ladies-bg); }
.access-note--women_kids { --a: var(--access-women_kids); --a-bg: var(--access-women_kids-bg); }
.access-note--closed { --a: var(--access-closed); --a-bg: var(--access-closed-bg); }
.access-note__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.access-note .access-badge { background: var(--c-white); }
.access-note__date { font-size: 13px; font-weight: 500; color: var(--c-ink); }
.access-note__rules { margin-top: 10px; font-size: 14px; line-height: 1.6; color: var(--c-text); }
/* Small print under day types: the venue schedules are confirmed per booking. */
.access-fine { font-size: 13px; line-height: 1.5; color: #585c56; } /* muted, still ≥ 5.5:1 on the access tints */
.access-note .access-fine { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0, 0, 0, 0.07); }

.price-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 15px; line-height: 1.45; color: var(--c-text); }
.price-lines__item { display: flex; justify-content: space-between; gap: 12px; }
.price-lines__item > span:last-child { white-space: nowrap; color: var(--c-ink); }
.price-lines__item--muted { color: var(--c-muted); }
.price-lines__unit { font-size: 13px; color: var(--c-muted); white-space: nowrap; }
.price-total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--c-line);
}
.price-total__label { font-family: var(--ff-heading); font-size: 17px; color: var(--c-ink); }
.price-total__value { font-family: var(--ff-heading); font-size: 24px; line-height: 1.2; color: var(--c-ink); white-space: nowrap; }
.price-box__note { margin-top: 6px; font-size: 13px; line-height: 1.5; color: var(--c-muted); }

/* ----- Beach page booking widget ----- */
/* Stickiness is up to the page layout (beach.css makes .beach-aside sticky); booking.js publishes the
   measured height as --bp-widget-h on the widget's parent for that calculation. */
.booking-widget { position: relative; z-index: 5; align-self: start; scroll-margin-top: 110px; }
.booking-widget__card {
  display: flex; flex-direction: column; gap: 22px;
  padding: 32px 30px; background: var(--c-white); border: 1px solid #e6e6e6; box-shadow: var(--shadow-soft);
  transition: box-shadow 0.6s var(--ease);
}
.booking-widget.is-updated .booking-widget__card { animation: bp-widget-flash 1.4s var(--ease) both; }
@keyframes bp-widget-flash {
  0% { box-shadow: 0 0 0 0 rgba(15, 110, 118, 0.45), var(--shadow-soft); }
  35% { box-shadow: 0 0 0 4px rgba(15, 110, 118, 0.25), var(--shadow-soft); }
  100% { box-shadow: 0 0 0 0 rgba(15, 110, 118, 0), var(--shadow-soft); }
}
.booking-widget__head { padding-bottom: 20px; border-bottom: 1px solid var(--c-line); }
.booking-widget__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0; color: var(--c-ink); }
.booking-widget__from {
  flex-basis: 100%; font-size: 12px; font-weight: 500; line-height: 1.2; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-lagoon);
}
.booking-widget__amount { font-family: var(--ff-heading); font-size: 32px; line-height: 1.15; }
.booking-widget__unit { font-size: 15px; color: var(--c-muted); }

.bw-field { position: relative; display: flex; flex-direction: column; gap: 8px; }
.bw-field__label {
  display: block; font-size: 12px; font-weight: 500; line-height: 1.2; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-muted);
}
.bw-field__trigger {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 52px; padding: 0 16px;
  border: 1px solid var(--c-sand); background: var(--c-white); color: var(--c-ink);
  font-size: 16px; line-height: 1; text-align: left;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.bw-field__trigger:hover,
.bw-field__trigger[aria-expanded="true"] { border-color: var(--c-lagoon); }
.bw-field__trigger[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(15, 110, 118, 0.12); }
.bw-field__icon { width: 18px; height: 18px; color: var(--c-lagoon); }
.bw-field__value { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bw-field__chevron { width: 10px; height: 10px; stroke-width: 1.8; transition: transform var(--t) var(--ease); }
.bw-field__trigger[aria-expanded="true"] .bw-field__chevron { transform: rotate(180deg); }
.bp-popover__cal { min-width: 0; }

.bw-guests .bw-field__label { margin-bottom: 2px; }
.bw-guests .guest-row { padding: 12px 0; border-bottom: 0; }
.bw-guests .guest-row + .guest-row { border-top: 1px solid var(--c-line); }
.bw-guests__note { margin-top: 8px; font-size: 13px; color: var(--c-muted); }
.booking-widget__cta { margin-top: 2px; }
.booking-widget__note { display: flex; gap: 10px; align-items: flex-start; margin: -6px 0 0; font-size: 14px; line-height: 1.5; color: var(--c-muted); }
.booking-widget__note .icon { width: 17px; height: 17px; margin-top: 2px; color: var(--c-lagoon); }

/* ----- Availability section (beach page) ----- */
.availability { scroll-margin-top: 110px; }
.availability__title { font-size: clamp(26px, 2.2vw, 30px); line-height: 1.3; }
.availability__summary { margin-top: 12px; max-width: 720px; font-size: 16px; line-height: 1.66; color: var(--c-text); }
.availability__pattern { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; padding: 0; }
.availability__pattern .access-badge { max-width: 100%; white-space: normal; }
.availability .access-fine { margin-top: 12px; }
.availability__calendar {
  margin-top: 28px; padding: 28px 24px 22px; min-height: 430px;
  background: var(--c-white); border: 1px solid #e6e6e6;
}
.availability__calendar.cal { min-height: 0; }
.availability__noscript { font-size: 15px; color: var(--c-muted); }
.availability__noscript a { color: var(--c-lagoon); text-decoration: underline; }
.availability__selection {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  margin-top: 16px; font-size: 15px; color: var(--c-text);
}
.availability__selected { display: inline-flex; align-items: center; gap: 10px; }
.availability__selected .icon { width: 18px; height: 18px; color: var(--c-lagoon); }
.availability__selected strong { font-weight: 500; color: var(--c-ink); }

/* ----- Small screens ----- */
@media (max-width: 480px) {
  .cal { --cal-cell: clamp(34px, calc((100vw - 96px) / 7), 42px); }
  .cal--compact { --cal-cell: clamp(34px, calc((100vw - 96px) / 7), 40px); }
  .availability__calendar { padding: 20px 10px 16px; }
  .booking-widget__card { padding: 26px 20px; }
}

/* Popovers become bottom sheets on phones */
@media (max-width: 599px) {
  .search-popover,
  .bp-popover,
  .search-popover--guests,
  .search-form--stacked .search-popover--guests {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 2600;
    width: auto; min-width: 0; max-width: none; max-height: 88vh; max-height: 88dvh;
    padding: 0 20px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain; border: 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.12);
    transform: translateY(28px);
    transition: opacity 0.22s var(--ease), transform 0.3s var(--ease-out);
  }
  /* Open sheets sit flush with the bottom edge (the stacked Passes selector above outranks the base .is-open rule). */
  .search-popover.is-open,
  .bp-popover.is-open,
  .search-form--stacked .search-popover--guests.is-open { transform: none; }
  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 2599; background: rgba(17, 17, 17, 0.45);
    opacity: 0; transition: opacity 0.22s var(--ease); -webkit-tap-highlight-color: transparent;
  }
  .sheet-backdrop.is-open { opacity: 1; }
  .popover-head {
    position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 0 -20px 16px; padding: 10px 8px 10px 20px; background: var(--c-white); border-bottom: 1px solid var(--c-line);
  }
  .popover-head__title { font-family: var(--ff-heading); font-size: 20px; line-height: 1.2; color: var(--c-ink); }
  .popover-head__close { display: grid; place-items: center; width: 44px; height: 44px; color: var(--c-ink); }
  .popover-head__close .icon { width: 18px; height: 18px; }
  .search-popover .cal,
  .bp-popover .cal { margin: 0 auto; }
  .search-popover__actions { position: sticky; bottom: 0; margin: 0 -20px; padding: 14px 20px; background: var(--c-white); }
  .search-popover__actions .btn { flex: 1; }
  .stepper__btn { width: 44px; height: 44px; }
  .stepper__btn::before { display: none; }
}
