/*
 * Legend Tours Popup System — clean rebuild
 * This file is intentionally isolated from the site's historical popup layers.
 */
html.legend-modal-lock,
body.legend-modal-lock {
  overflow: hidden !important;
}

@supports selector(html:has(body)) {
  html:has(.legend-modal:target),
  body:has(.legend-modal:target) {
    overflow: hidden !important;
  }
}

.legend-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2147483500;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 18px;
  align-items: center;
  justify-content: center;
  overflow: auto;
  overscroll-behavior: contain;
}

.legend-modal.is-open,
.legend-modal:target {
  display: flex;
}

.legend-modal__backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(7, 11, 15, .78);
  backdrop-filter: blur(4px);
  cursor: default;
  text-decoration: none;
}

.legend-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: calc(100dvh - 36px);
  margin: auto;
  overflow: auto;
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .38);
  outline: none;
}

.legend-modal__close {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  z-index: 20 !important;
  float: none !important;
  width: 42px !important;
  height: 42px !important;
  display: grid !important;
  place-items: center !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: #fff !important;
  color: #1a1a1a !important;
  box-shadow: 0 7px 24px rgba(0, 0, 0, .16) !important;
  font-size: 26px !important;
  line-height: 1 !important;
  cursor: pointer !important;
}

.legend-modal__close:hover,
.legend-modal__close:focus-visible {
  color: var(--red) !important;
  outline: 3px solid rgba(169, 24, 28, .18) !important;
  outline-offset: 2px;
}

/* Package / flyer popup: flyer on LEFT, details on RIGHT. */
.legend-modal-package .legend-modal__dialog {
  width: min(1240px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: hidden;
}

.legend-package-popup-layout {
  display: grid !important;
  grid-template-columns: minmax(430px, 1.12fr) minmax(370px, .88fr) !important;
  height: min(850px, calc(100dvh - 36px));
  min-height: 620px;
  max-height: none !important;
}

.legend-package-popup-flyer {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  background: #171717 !important;
  padding: 28px 30px 24px !important;
  display: flex !important;
  flex-direction: column;
  align-items: center;
}

.legend-package-popup-flyer .package-popup-flyer-label {
  align-self: flex-start;
}

.legend-package-popup-flyer img {
  width: auto !important;
  max-width: min(100%, 730px) !important;
  height: auto !important;
  max-height: none !important;
}

.legend-package-popup-summary {
  grid-column: 2;
  grid-row: 1;
  min-height: 0;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  padding: 42px 38px 34px !important;
}

.legend-package-popup-actions {
  position: sticky;
  bottom: -1px;
  z-index: 4;
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  margin: 22px -10px -18px !important;
  padding: 16px 10px 18px !important;
  background: linear-gradient(180deg, rgba(251,248,241,0), #fbf8f1 22%, #fbf8f1 100%) !important;
}

.legend-package-popup-actions .btn {
  width: 100%;
  justify-content: center;
  text-align: center;
}

/* Tours */
.legend-modal-tour .legend-modal__dialog {
  width: min(920px, 100%);
}

.legend-modal-tour .modal-head {
  padding-right: 74px;
}

/* Private transfer / private tour */
.legend-modal-private .legend-modal__dialog {
  width: min(860px, 100%);
}

.legend-modal-private .modal-head {
  padding-right: 74px;
}

.legend-modal-private .modal-head h2 {
  font-family: Georgia, serif;
  font-size: 34px;
  margin: 5px 0 8px;
}

.legend-modal-private .modal-head p {
  margin: 0;
  color: #666;
}

.legend-return-fields {
  display: none;
}

.legend-enquiry-form.return-enabled .legend-return-fields {
  display: block;
}

.legend-enquiry-form .form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.legend-enquiry-form .form-actions .btn {
  min-width: 190px;
}

/* Suggested itineraries: retain the previous cinematic itinerary presentation. */
.legend-modal-itinerary .legend-modal__dialog {
  width: min(1040px, 100%);
  overflow: auto;
}

.legend-itinerary-dialog .itinerary-popover-hero {
  border-radius: 22px 22px 0 0;
}

/* Trigger buttons inherit the site's existing link/button appearance. */
.text-button,
.flyer-overlay-btn {
  font-family: inherit;
}

.text-button {
  border: 0;
  background: none;
}

/* Fixed private-service shortcut keeps the current site appearance. */
.private-bubble {
  font-family: inherit;
  text-align: left;
}

@media (max-width: 850px) {
  .legend-modal {
    padding: 8px;
    align-items: flex-start;
  }

  .legend-modal__dialog {
    max-height: calc(100dvh - 16px);
    margin: 8px auto;
    border-radius: 16px;
  }

  .legend-modal-package .legend-modal__dialog {
    overflow-y: auto;
  }

  .legend-package-popup-layout {
    display: flex !important;
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  .legend-package-popup-flyer,
  .legend-package-popup-summary {
    overflow: visible !important;
  }

  .legend-package-popup-flyer {
    padding: 24px !important;
  }

  .legend-package-popup-summary {
    padding: 34px 24px 28px !important;
  }

  .legend-package-popup-actions {
    position: static;
    grid-template-columns: 1fr !important;
    margin: 20px 0 0 !important;
    padding: 0 !important;
    background: none !important;
  }
}

@media (max-width: 600px) {
  .legend-modal {
    padding: 0;
  }

  .legend-modal__dialog {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .legend-modal__close {
    top: 10px !important;
    right: 10px !important;
  }

  .legend-modal-tour .modal-head,
  .legend-modal-private .modal-head {
    padding: 24px 60px 18px 20px;
  }

  .legend-modal-tour .modal-body,
  .legend-modal-private .modal-body {
    padding: 20px;
  }

  .legend-enquiry-form .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .legend-enquiry-form .form-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .legend-itinerary-dialog .itinerary-popover-hero {
    border-radius: 0;
  }
}
