/* ============================================
   Trek Booking — Single Trek Template Styles
   --------------------------------------------
   Loaded only on single trek pages (handle: tb-single-trek), enqueued
   alongside frontend.css. Covers the 2:1 layout, accordions, sidebar and the
   inline gallery / "What's included" / itinerary-meal blocks. Shared booking
   form, notice, archive and search styles stay in frontend.css.
   ============================================ */

/* ============================================
   Single trek layout
   --------------------------------------------
   All design tokens (--tb-*) are defined in frontend.css :root, which is
   enqueued as this stylesheet's dependency. No page-builder variables are
   referenced, so the layout renders consistently under any theme / builder.
   ============================================ */

/* ---------- 2 : 1 grid (content | sidebar) ---------- */
.tb-trek-layout {
  display: grid;
  grid-template-columns: var(--tb-grid-2-1);
  column-gap: var(--tb-space-3xl);
  row-gap: var(--tb-container-gap);
  align-items: start;
}
/* Gallery is its own grid item (top of the content column) rather than nested
   inside .tb-trek-main, so that on mobile the sidebar can slot directly below
   it, ahead of the long-form content. The sidebar spans both content rows. */
.tb-trek-main {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--tb-container-gap);
}
.tb-trek-sidebar {
  grid-column: 2;
  grid-row: 1 / 3;
}

/* ---------- Badge ---------- */
.tb-trek-badge {
  width: fit-content;
  color: var(--tb-light);
  font-size: var(--tb-text-s);
  padding: var(--tb-space-3xs) var(--tb-space-2xl);
  border-radius: var(--tb-radius-full);
  background-color: var(--tb-primary);
}

/* ---------- Breadcrumbs ---------- */
.tb-trek-gallery-block {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: var(--tb-content-gap);
}
.tb-breadcrumbs {
  font-size: var(--tb-text-xs);
}
.tb-breadcrumbs a {
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.2s ease;
}
.tb-breadcrumbs a:hover {
  color: var(--tb-primary);
}
.tb-breadcrumbs__sep {
  margin: 0 0.4em;
}

/* ---------- Content sections ---------- */
.tb-trek-section {
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-xl);
}
.tb-trek-section__title {
  color: var(--tb-primary);
  margin: 0;
}
.tb-trek-overview h2,
.tb-trek-overview h3 {
  margin-block: var(--tb-space-m);
}
.tb-trek-overview p {
  margin-bottom: var(--tb-space-xs);
}
.tb-trek-overview > *:first-child {
  margin-top: 0;
}
.tb-trek-overview > *:last-child {
  margin-bottom: 0;
}

/* ---------- Read more (overview) ---------- */
.tb-readmore {
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-s);
  align-items: flex-start;
}
/* Clamp to N lines with a trailing ellipsis while collapsed. */
.tb-readmore__content {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}
.tb-readmore.is-expanded .tb-readmore__content {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}
/* Scoped to beat theme rules on links/buttons (specificity 0,3,0 > 0,2,1). */
.tb-single-trek .tb-readmore .tb-readmore__toggle {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--tb-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.tb-readmore__toggle:hover {
  opacity: 0.8;
}

/* ---------- Divider ---------- */
.tb-divider {
  border: 0;
  border-top: 1px solid var(--tb-light-d-2);
  margin: 0;
}

/* ---------- Map ---------- */
.tb-trek-map iframe {
  display: block;
  border: 0;
  border-radius: var(--tb-radius-m);
}

/* ---------- Accordion (itinerary + FAQs) ---------- */
.tb-accordion {
  display: flex;
  flex-direction: column;
}
.tb-accordion__title {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--tb-content-gap);
  padding: var(--tb-space-m) 0;
  color: var(--tb-primary);
  border-bottom: 1px solid var(--tb-primary);
}
.tb-accordion--faqs .tb-accordion__title {
  color: var(--tb-secondary);
}
.tb-accordion__title::-webkit-details-marker {
  display: none;
}
.tb-accordion__title::after {
  content: "+";
  margin-left: auto;
  font-size: var(--tb-text-2xl);
  font-weight: 400;
  line-height: 1;
  color: var(--tb-secondary);
}
.tb-accordion__item[open] > .tb-accordion__title::after {
  content: "\2212"; /* minus */
}
.tb-accordion__title--itinerary .trek-day {
  flex: 0 0 auto; /* don't shrink — keeps "Day N:" on one line */
  white-space: nowrap;
  color: var(--tb-secondary);
}
/* Let the title take the remaining width and wrap instead of the day label. */
.tb-accordion__title .tb-accordion__heading {
  flex: 1 1 auto;
  min-width: 0;
}
/* Headings inside a summary keep the row layout — no default h3 margin/size. */
.tb-accordion__content {
  padding: var(--tb-space-m) 0;
}
.tb-accordion__content p:not(:last-child) {
  margin-bottom: var(--tb-space-xs);
}

/* ---------- Sidebar ---------- */
.tb-trek-sidebar__inner {
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-l);
}
/* Desktop: stretch the sidebar to the full content-column height and let its
   inner wrapper fill it, so the booking card (position: sticky in frontend.css)
   has room to travel and actually sticks as the page scrolls. The layout's
   align-items: start otherwise collapses the sidebar to content height, leaving
   the sticky card nowhere to move. The bottom book bar is mobile-only. */
@media (min-width: 769px) {
  .tb-trek-sidebar {
    align-self: stretch;
  }
  .tb-trek-sidebar__inner {
    height: 100%;
  }
}
.tb-trek-destination {
  margin: 0;
}
.tb-trek-title {
  margin: 0;
  color: var(--tb-secondary);
}

/* ---------- Trek detail rows ---------- */
.tb-trek-details {
  display: flex;
  flex-direction: column;
  gap: var(--tb-space-xs);
}
.tb-trek-detail {
  display: flex;
  flex-direction: row;
  align-items: center;
  column-gap: var(--tb-content-gap);
}
.tb-trek-detail__icon {
  flex: 0 0 auto;
  display: inline-flex;
  width: 20px;
  height: 20px;
}
.tb-trek-detail__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 768px) {
  .tb-trek-layout {
    grid-template-columns: 1fr;
    row-gap: var(--tb-space-xl);
  }
  /* Stack order: gallery → sidebar (title, price, booking) → long-form content. */
  .tb-trek-gallery-block {
    grid-column: 1;
    grid-row: 1;
  }
  .tb-trek-sidebar {
    grid-column: 1;
    grid-row: 2;
    position: static;
  }
  .tb-trek-main {
    grid-column: 1;
    grid-row: 3;
  }
  /* Booking card flows inline on mobile — the sticky bottom book bar is the
     persistent CTA there instead. */
  .tb-trek-sidebar .tb-booking-card {
    position: static;
    max-width: none;
  }
}

/* ---------- Trek locations ---------- */
.tb-trek-locations {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin: 0 0 24px;
}
.tb-trek-locations > div {
  flex: 1;
  min-width: 200px;
  background: #f3f4f6;
  padding: 10px 14px;
  border-radius: 6px;
}
.tb-trek-locations dt {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin: 0 0 2px;
}
.tb-trek-locations dd {
  font-weight: 600;
  margin: 0;
}

/* ---------- Included / Excluded lists ---------- */
.tb-included-excluded {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.tb-included,
.tb-excluded {
  flex: 1;
  min-width: 200px;
}
.tb-included h3,
.tb-excluded h3 {
  margin-bottom: 8px;
}
.tb-included ul,
.tb-excluded ul {
  margin: 0;
  padding-left: 1.2em;
}
.tb-included ul li::marker {
  color: #15803d;
}
.tb-excluded ul li::marker {
  color: #dc2626;
}

/* ============================================
   Trek display blocks (gallery / includes / itinerary meals)
   --------------------------------------------
   Previously printed inline by the [trek-gallery], [trek-includes] and
   [trek-itinerary-includes] shortcodes; now rendered directly in
   single-trek.php. Uses the shared --tb-* design tokens from frontend.css.
   ============================================ */

/* ---------- Gallery ---------- */
.trek-gallery {
  display: grid;
  gap: 12px;
}
.trek-gallery__featured {
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
}
.trek-gallery__thumb {
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: none;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border: 3px solid transparent;
  transition: border-color 0.2s ease;
}
.trek-gallery__thumb.is-active {
  border-color: var(--tb-primary);
}
.trek-gallery__featured img,
.trek-gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.trek-gallery__thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.trek-gallery__thumb--more img {
  filter: brightness(0.45);
}
.trek-gallery__more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: clamp(0.9rem, 1.2vw, 1.1rem);
  letter-spacing: 0.02em;
  pointer-events: none;
}
.trek-gallery__lightbox {
  border: 0;
  padding: 0;
  margin: 0;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  background: transparent;
}
.trek-gallery__lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}
.trek-gallery__lightbox::backdrop {
  background: rgba(20, 20, 20, 0.55);
}
.trek-gallery__panel {
  position: relative;
  width: min(720px, 92vw);
  max-height: 86vh;
  background: #fff;
  border-radius: 14px;
  padding: 28px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
.trek-gallery__title {
  margin: 0 0 20px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}
.trek-gallery__scroll {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 8px;
}
.trek-gallery__scroll-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}
.trek-gallery__close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: #333;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}
.trek-gallery__close:hover {
  color: #000;
}
/* ---------- Gallery: custom mobile carousel (<768px) ----------
   Native CSS scroll-snap does the swiping (touch + momentum); JS only adds the
   pagination dots. Hidden on desktop, shown below 768px in place of the grid. */
.trek-gallery__mobile {
  display: none;
}
.trek-carousel__track {
  display: flex;
  gap: 16px;
  position: relative; /* offset reference for the dot/scroll math in JS */
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.trek-carousel__track::-webkit-scrollbar {
  display: none; /* WebKit/Blink */
}
.trek-carousel__slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always; /* land on every image, never skip on a fast swipe */
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
}
.trek-carousel__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Swiper-style dynamic bullets: a fixed-width, clipped window. The strip is
   translated by JS to centre the active dot, and dots scale down by distance
   from the active one, so only ~3–5 dots ever show regardless of image count. */
.trek-carousel__dots {
  width: 64px; /* ~5-dot window (5 x 8px + 4 x 6px gap) */
  max-width: 100%;
  margin: 12px auto 0;
  overflow: hidden;
}
.trek-carousel__dots-track {
  display: flex;
  gap: 6px;
  width: max-content;
  position: relative; /* offset reference for the dot-centring math in JS */
  transition: transform 0.25s ease;
}
.trek-carousel__dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--tb-light-d-2);
  cursor: pointer;
  transform: scale(0); /* default hidden; the modifier classes size visible dots */
  transition: transform 0.25s ease, background 0.25s ease;
}
.trek-carousel__dot.is-far {
  transform: scale(0.45);
}
.trek-carousel__dot.is-near {
  transform: scale(0.7);
}
.trek-carousel__dot.is-active {
  transform: scale(1);
  background: var(--tb-primary);
}
@media (max-width: 768px) {
  .trek-gallery {
    display: block;
  }
  .trek-gallery__featured,
  .trek-gallery__thumbs {
    display: none;
  }
  .trek-gallery__mobile {
    display: block;
  }
}

@media (max-width: 600px) {
  .trek-gallery__thumbs {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- What's included cards ---------- */
.trek-includes-group {
  display: flex;
  flex-direction: column;
  gap: var(--tb-content-gap);
}
.trek-includes {
  display: flex;
  flex-direction: column;
  row-gap: var(--tb-content-gap);
  padding: var(--tb-space-l);
  border: 1px solid var(--tb-light-d-2);
  border-radius: var(--tb-radius-m);
}

.trek-includes--excluded .tb-trek-badge {
  background-color: var(--tb-danger);
}
.trek-includes--free .tb-trek-badge {
  background-color: var(--tb-secondary);
}
.trek-includes__list-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  column-gap: var(--tb-content-gap);
}
.trek-includes__icon {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--tb-primary);
}
.trek-includes--excluded .trek-includes__icon {
  color: var(--tb-danger);
}
.trek-includes--free .trek-includes__icon {
  color: var(--tb-secondary);
}
.trek-includes__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Trek video (What's Included) ---------- */
/* Sit the video the same distance below the includes cards as the cards sit
   from each other. The section lays its children out with the larger
   --tb-space-xl gap; this negative margin trims that down to --tb-content-gap. */
.trek-video {
  margin-top: calc(var(--tb-content-gap) - var(--tb-space-xl));
}
.trek-video__embed {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--tb-radius-m);
  overflow: hidden;
}
.trek-video__embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.trek-video__link {
  font-weight: 600;
  color: var(--tb-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Itinerary day meals ---------- */
.trek-itinerary-includes {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--tb-space-s) var(--tb-space-xl);
  margin-top: var(--tb-space-l); /* separate the facts row from the description */
}
.trek-itinerary-includes__item {
  display: flex;
  flex-direction: row;
  align-items: center;
  column-gap: var(--tb-content-gap);
}
.trek-itinerary-includes__icon {
  flex: 0 0 auto;
  display: inline-flex;
  width: 20px;
  height: 20px;
  color: var(--tb-primary);
}
.trek-itinerary-includes__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ============================================
   Sticky "book bar" (mobile only)
   --------------------------------------------
   Fixed to the bottom of the viewport, revealed by JS once the trek content
   scrolls past the title. Mirrors the booking card's price/date and proxies
   its submit button. Mobile-only: on desktop the sticky booking card in the
   sidebar is the scroll affordance instead (hidden ≥769px below). On mobile it
   collapses to price + button (see the max-width: 768px block at the end).
   ============================================ */
.tb-bookbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 100;
  background: var(--tb-bookbar-bg, #ebebeb);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.tb-bookbar.is-visible {
  transform: translateY(0);
}
.tb-bookbar__inner {
  max-width: var(--tb-container-width);
  margin: 0 auto;
  padding: var(--tb-space-s) var(--tb-space-l);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tb-space-l);
}
.tb-bookbar__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tb-bookbar__destination {
  font-size: var(--tb-text-s);
  color: var(--tb-primary);
}
.tb-bookbar__title {
  font-weight: 700;
  color: var(--tb-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tb-bookbar__action {
  display: flex;
  align-items: center;
  gap: var(--tb-space-l);
  flex: 0 0 auto;
}
.tb-bookbar__price {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  text-align: right;
}
.tb-bookbar__amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tb-secondary);
}
.tb-bookbar__date {
  font-size: var(--tb-text-s);
  color: var(--tb-primary);
}
.tb-bookbar__btn {
  border: 0;
  cursor: pointer;
  white-space: nowrap;
  padding: var(--tb-space-s) var(--tb-space-xl);
  border-radius: var(--tb-radius-full);
  background: var(--tb-secondary);
  color: #fff;
  font: inherit;
  font-weight: 600;
}
.tb-bookbar__btn:hover {
  opacity: 0.92;
}
/* Desktop: no bottom bar — the sticky sidebar booking card takes its place. */
@media (min-width: 769px) {
  .tb-bookbar {
    display: none;
  }
}
/* On mobile the bar stays active (the inline booking card scrolls away with the
   content). It collapses to just the price + book button — the trek
   title/destination block is dropped to save width. */
@media (max-width: 768px) {
  .tb-bookbar__info {
    display: none;
  }
  .tb-bookbar__action {
    flex: 1;
    justify-content: space-between;
  }
  .tb-bookbar__price {
    text-align: left;
  }
}
