/* ============================================================
   Tour Packages — GetYourGuide-style "choose from N options"
   Only loaded on trip pages that have active packages defined.
   Palette deliberately matches the GetYourGuide reference (blue
   accent, not the site's amber) rather than reusing --accent —
   this is a self-contained "product variant picker" pattern, not
   a themed marketing section.
   ============================================================ */

.v3-pkg {
  --pkg-navy: #14233D;
  --pkg-text: #1F2937;
  --pkg-muted: #6B7280;
  --pkg-border: #E3E7ED;
  --pkg-bg-pill: #F1F3F6;
  --pkg-green: #1E8E3E;
  --pkg-red: #C5221F;
}

.v3-pkg-heading {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--pkg-navy, #14233D);
  margin: 0 0 20px;
  letter-spacing: -0.3px;
}

/* ── Option cards — a horizontal row of tall, narrow cards (GYG pattern),
   wrapping to fewer columns as the main content column narrows. ── */
.v3-pkg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); align-items: start; gap: 16px; }

.v3-pkg-card {
  border: 1px solid var(--pkg-border, #E3E7ED);
  border-radius: 12px;
  padding: 22px 24px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.v3-pkg-card:hover:not(.v3-pkg-card--sel) { border-color: var(--accent-blue, #1B75E8); }
.v3-pkg-card:focus-visible { outline: 2px solid var(--accent-blue, #1B75E8); outline-offset: 2px; }
.v3-pkg-card--sel {
  border: 2px solid var(--accent-blue, #1B75E8);
  padding: 21px 23px; /* compensate for the +1px border so content doesn't jump */
  box-shadow: 0 1px 3px rgba(27,117,232,0.12);
}

.v3-pkg-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.v3-pkg-name { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--pkg-navy, #14233D); margin: 0; line-height: 1.3; }

.v3-pkg-radio {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid #C7CFDA; display: flex; align-items: center; justify-content: center;
  margin-top: 2px; color: #fff; background: transparent;
}
.v3-pkg-radio--sel { border-color: var(--accent-blue, #1B75E8); background: var(--accent-blue, #1B75E8); }

.v3-pkg-desc { font-size: 14px; color: var(--pkg-muted, #6B7280); line-height: 1.55; margin: 0 0 14px; }
.v3-pkg-readmore { display: inline; background: none; border: none; padding: 0; margin: 0; color: var(--accent-blue, #1B75E8); font-size: 14px; font-weight: 500; text-decoration: underline; cursor: pointer; }

.v3-pkg-rows { display: flex; flex-direction: column; gap: 9px; margin-bottom: 16px; }
.v3-pkg-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; color: var(--pkg-text, #1F2937); line-height: 1.4; }
.v3-pkg-row-icon { flex-shrink: 0; color: var(--pkg-navy, #14233D); margin-top: 1px; }

.v3-pkg-divider { border-top: 1px solid var(--pkg-border, #E3E7ED); margin: 16px 0; }

.v3-pkg-date-label { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--pkg-navy, #14233D); margin-bottom: 4px; }
.v3-pkg-date-value { font-size: 14px; color: var(--pkg-muted, #6B7280); }

.v3-pkg-price-block { margin-bottom: 16px; }
.v3-pkg-price-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.v3-pkg-price-total { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--pkg-navy, #14233D); line-height: 1.2; }
.v3-pkg-price-total--discount { color: var(--pkg-red, #C5221F); }
.v3-pkg-price-compare { font-size: 15px; color: var(--pkg-muted, #6B7280); text-decoration: line-through; }
.v3-pkg-price-discount-badge { font-size: 14px; font-weight: 700; color: var(--pkg-red, #C5221F); }
.v3-pkg-price-pax { font-size: 13px; color: var(--pkg-muted, #6B7280); margin-top: 4px; }
.v3-pkg-price-taxnote { font-size: 12px; color: var(--pkg-muted, #6B7280); margin-top: 2px; }

.v3-pkg-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 13px 20px;
  background: #fff; color: var(--accent-blue, #1B75E8);
  border: 1.5px solid var(--accent-blue, #1B75E8); border-radius: 6px;
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background 0.15s, color 0.15s;
}
.v3-pkg-btn:hover { background: #EFF5FE; text-decoration: none; color: var(--accent-blue, #1B75E8); }
.v3-pkg-btn--continue { background: var(--accent-blue, #1B75E8); color: #fff; }
.v3-pkg-btn--continue:hover { background: var(--accent-blue-dark, #1461C4); color: #fff; }

/* Reveals the options that don't fit on one row. The visible count is measured
   in TourPackages.tsx against this grid's own track sizing, so it always shows
   whole cards — 3 on desktop, fewer on narrower screens — never a clipped one. */
.v3-pkg-more {
  display: block;
  margin: 16px auto 0;
  padding: 10px 22px;
  background: #fff;
  color: var(--accent-blue, #3860f4);
  border: 1.5px solid var(--border, #e7e9ee);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.v3-pkg-more:hover { border-color: var(--accent-blue, #3860f4); background: #EFF5FE; }

/* ── Sidebar ── */
.v3-pkg-booking-card { border: 1px solid var(--pkg-border, #E3E7ED); border-radius: 16px; padding: 16px; box-sizing: border-box; box-shadow: 0 6px 24px rgba(16,24,40,0.07); }
/* Override the shared .v3-booking-card's overflow:hidden (for its rounded
   corners) — it has no bleeding content to clip here, but it was clipping
   the calendar popover, a descendant positioned outside the card's bounds. */
.v3-booking-card.v3-pkg-booking-card { overflow: visible; }
/* Match the price/booking card shell (border, radius, soft shadow) + gap below it */
.v3-pkg-sidebar .v3-team-card {
  margin-top: 16px;
  border: 1px solid var(--pkg-border, #E3E7ED);
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(16,24,40,0.07);
  padding: 14px 16px;
}

.v3-pkg-price-header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; margin-bottom: 16px; }
.v3-pkg-from { font-size: 13px; color: var(--pkg-muted, #6B7280); }
.v3-pkg-header-compare { font-size: 15px; color: var(--pkg-muted, #6B7280); text-decoration: line-through; }
.v3-pkg-header-price { width: 100%; font-family: var(--font-display); font-size: 28px; font-weight: 800; letter-spacing: -0.5px; color: var(--pkg-navy, #14233D); }
.v3-pkg-price-header:has(.v3-pkg-header-compare) .v3-pkg-header-price { color: var(--pkg-red, #C5221F); }
.v3-pkg-header-label { font-size: 13px; color: var(--pkg-muted, #6B7280); }

/* Controls: single bordered box with dividers (GYG design) */
.v3-pkg-ctrl { display: flex; flex-direction: column; border: 1px solid var(--pkg-border, #E3E7ED); border-radius: 12px; margin-bottom: 12px; }
.v3-pkg-ctrl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 11px 14px; box-sizing: border-box; }
.v3-pkg-ctrl > .v3-pkg-ctrl-row { border-bottom: 1px solid var(--pkg-border, #E3E7ED); }
.v3-pkg-ctrl-label { font-size: 14px; font-weight: 700; color: var(--pkg-navy, #14233D); }
.v3-pkg-ctrl-date { position: relative; }
.v3-pkg-ctrl-datebtn { background: none; border: none; cursor: pointer; font-family: var(--font-body); font-size: 14px; font-weight: 600; color: var(--pkg-navy, #14233D); }
.v3-pkg-ctrl-dateval { display: flex; align-items: center; gap: 8px; }

.v3-pkg-total-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.v3-pkg-total-label { font-size: 14px; font-weight: 600; color: var(--pkg-muted, #6B7280); }
.v3-pkg-total-val { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -0.4px; color: var(--pkg-navy, #14233D); }

/* Group pricing toggle inside the packages sidebar */
.v3-pkg-gp { margin-bottom: 14px; }

.v3-pkg-check-btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 13px 20px; margin-bottom: 16px;
  background: var(--accent-blue, #1B75E8); color: #fff; border: none; border-radius: 12px;
  font-family: var(--font-body); font-size: 16px; font-weight: 800;
  cursor: pointer; text-decoration: none; transition: background 0.15s;
}
.v3-pkg-check-btn:hover { background: var(--accent-blue-dark, #1461C4); color: #fff; text-decoration: none; }

.v3-pkg-trust { display: flex; flex-direction: column; }
.v3-pkg-trust-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: #3f4453; line-height: 1.5; }
.v3-pkg-trust-icon { flex-shrink: 0; color: var(--pkg-green, #1E8E3E); margin-top: 1px; }
.v3-pkg-trust-text strong { font-weight: 700; color: var(--pkg-navy, #14233D); }
.v3-pkg-trust-line { height: 1px; background: var(--pkg-border, #E3E7ED); margin: 13px 0; }
.v3-pkg-trust-link { color: var(--accent-blue, #1B75E8); text-decoration: underline; }

/* ── Calendar popover ── */
.v3-pkg-cal-backdrop { position: fixed; inset: 0; z-index: 940; background: transparent; }
.v3-pkg-cal-popover {
  position: absolute; top: calc(100% + 8px); right: 0; left: auto; z-index: 950;
  width: 640px; max-width: calc(100vw - 32px);
  background: #fff; border: 1px solid var(--pkg-border, #E3E7ED); border-radius: 16px;
  box-shadow: 0 16px 44px rgba(20,35,61,0.18); padding: 24px 28px;
}
.v3-pkg-cal-header { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 4px; }
.v3-pkg-cal-nav, .v3-pkg-cal-close { background: none; border: none; padding: 7px; border-radius: 8px; cursor: pointer; color: var(--pkg-navy, #14233D); }
.v3-pkg-cal-nav:hover, .v3-pkg-cal-close:hover { background: var(--pkg-bg-pill, #F1F3F6); }
.v3-pkg-cal-nav--next { margin-left: auto; }
.v3-pkg-cal-months { display: flex; gap: 44px; }
.v3-pkg-cal-month { flex: 1; min-width: 0; }
.v3-pkg-cal-month-title { font-family: var(--font-display); font-size: 19px; font-weight: 800; letter-spacing: -0.3px; color: var(--pkg-navy, #14233D); text-align: center; margin-bottom: 14px; }
.v3-pkg-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 6px; }
.v3-pkg-cal-weekdays span { font-size: 13px; color: var(--pkg-muted, #6B7280); text-align: center; }
.v3-pkg-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.v3-pkg-cal-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 500; border: 1.5px solid transparent; background: none; border-radius: 10px; cursor: pointer; color: var(--pkg-text, #1F2937); transition: background 0.12s, border-color 0.12s; }
.v3-pkg-cal-cell:hover:not(:disabled) { background: var(--pkg-bg-pill, #F1F3F6); }
.v3-pkg-cal-cell:disabled { color: rgba(0,0,0,0.22); cursor: default; text-decoration: line-through; }
.v3-pkg-cal-cell--empty { visibility: hidden; cursor: default; }
.v3-pkg-cal-cell--sel { border-color: var(--pkg-navy, #14233D); background: #fff; color: var(--pkg-navy, #14233D); font-weight: 700; }
.v3-pkg-cal-cell--sel:hover:not(:disabled) { background: #fff; }

@media (max-width: 991px) {
  .v3-pkg-cal-popover { width: 560px; }
}
@media (max-width: 767px) {
  .v3-pkg-cal-backdrop { background: rgba(20,35,61,0.4); }
  .v3-pkg-cal-popover {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none;
    border-radius: 16px 16px 0 0; max-height: 82vh; overflow-y: auto; padding: 20px;
  }
  .v3-pkg-cal-months { flex-direction: column; gap: 20px; }
  .v3-pkg-grid { grid-template-columns: 1fr; }
}

/* Chevron indicator on option cards — mobile only; desktop keeps the radio. */
.v3-pkg-chevron { display: none; color: var(--accent-blue, #3860f4); flex-shrink: 0; transition: transform 0.18s ease; }
.v3-pkg-chevron--open { transform: rotate(180deg); }

@media (max-width: 767px) {
  /* Cards collapse to a summary; the selected one is the expanded one, which is
     the same interaction as the reference (tapping a card selects + expands). */
  .v3-pkg-card:not(.v3-pkg-card--sel) .v3-pkg-date-block,
  .v3-pkg-card:not(.v3-pkg-card--sel) .v3-pkg-date-block + .v3-pkg-divider,
  .v3-pkg-card:not(.v3-pkg-card--sel) .v3-pkg-btn { display: none; }

  .v3-pkg-radio { display: none; }
  .v3-pkg-chevron { display: inline-flex; }
}

/* Mobile: hoist the booking card above the content.
   The sidebar is a sibling *after* .v3-main, so once .v3-layout collapses to one
   column the card would land past the options, quick facts, itinerary and FAQ —
   far beyond the point it's useful. Dissolving the sidebar box makes its two
   cards grid items of .v3-layout, so each can be placed independently around
   .v3-main (default order 0). Reordering rather than rendering a phone-specific
   copy keeps a single #booking and one set of pax/date controls, so the two can
   never disagree. */
/* screen-only: @media print already forces .v3-layout to display:block, where
   `order` does nothing — and A4 renders around 794px, so an unscoped max-width
   query would dissolve these boxes mid-print for no benefit. */
@media screen and (max-width: 991px) {
  .v3-pkg-sidebar { display: contents; }

  /* Dissolve the main column too. The booking card lives in the sidebar and the
     sections live in .v3-main, so they can only be interleaved once both sets
     are items of the same container. */
  .v3-main { display: contents; }

  /* .v3-main used to be the single grid item and carried min-width: 0, which
     capped the track. Its children become the items now, and `1fr` means
     minmax(auto, 1fr) — so the widest section's min-content stretched the
     column to ~1086px inside a 390px screen (clipped, so it still *looked*
     fine). Restore the floor on both the track and the items. */
  .v3-layout { grid-template-columns: minmax(0, 1fr); }
  .v3-layout > *,
  .v3-main > *,
  .v3-pkg-sidebar > * { min-width: 0; }

  /* Only the blocks that move *ahead* of the card need an explicit order.
     Everything else keeps the default 0 and falls in DOM order, which already
     gives packages -> map -> altitude -> equipment -> video -> faq -> stories. */
  .v3-tour-short-desc   { order: -6; }
  .v3-quick-facts       { order: -5; }
  .v3-layout #overview  { order: -4; }
  .v3-layout #itinerary { order: -3; }
  .v3-layout #includes  { order: -2; }

  .v3-pkg-sidebar .v3-booking-card-wrap {
    order: -1;               /* directly below cost includes / excludes */
    padding-top: 0;
    margin-bottom: 22px;     /* .v3-layout sets gap: 0 */
  }

  /* On #booking, not the wrapper: the sticky bar's CTA scrolls to the card
     itself, so margin on the wrapper is ignored and the card lands flush
     against the top edge. */
  .v3-pkg-sidebar .v3-booking-card { scroll-margin-top: 16px; }

  .v3-pkg-sidebar .v3-team-card { order: 1; }
}
