/**
 * carousel — copy beside a set of options.
 *
 * The track is a scroll-snap row. That is the whole carousel: it swipes on
 * touch, scrolls with a trackpad, and takes keyboard arrows because the track
 * is focusable. The dots and arrows the script adds are a convenience on top,
 * not the mechanism.
 */

.carousel__inner {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 56px;
  align-items: center;
}
/* Pastel #129 and #133, raised separately by Zach and Cooper about the same
   tile: the dining rail's cards were smaller than the lodging rail's above it.
   The cause is that `order` moves the two children between the columns but
   leaves the column widths where they are, so a left-media carousel put its
   photos in the 5fr column and its copy in the 7fr one — the opposite of what
   every right-media carousel does. Measured at 1440px: 537px wide against
   lodging's 752px, which is 5/7 of it exactly.

   Swapping the template as well as the order keeps the media column at 7fr
   whichever side it sits on. Below 900px the grid is a single column and the
   order reset already handles it. */
.carousel--left .carousel__inner { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.carousel--left .carousel__text  { order: 2; }
.carousel--left .carousel__stage { order: 1; }

/* Bare: no copy column, so the rail takes the whole width and bleeds off both
   edges — cards leaving the frame on either side is what tells a reader there
   is more to scroll to. Scroll padding keeps the first and last card clear of
   the edge once you get there, so nothing is stranded half out of view. */
.carousel--bare .carousel__inner {
  grid-template-columns: minmax(0, 1fr);
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
.carousel--bare .carousel__track {
  scroll-padding-inline: var(--margin);
  padding-inline: var(--margin);
}

/* 4:3 is the right shape for a card sitting beside copy; run full width it is
   1009px tall at a 1440 viewport, taller than the screen it is meant to lead.
   A bare rail is a hero, so it takes a hero's proportions -- but only where
   there is width to spend. On a phone the full-width card is ~343px across and
   16:9 would leave a 193px letterbox, so the card shape goes back to 4:3. */
.carousel--bare .carousel__card { aspect-ratio: 16 / 9; }
@media (max-width: 899px) {
  .carousel--bare .carousel__card { aspect-ratio: 4 / 3; }
}

.carousel__text { display: flex; flex-direction: column; align-items: flex-start; }
.carousel__body { color: var(--text-muted); max-width: 46ch; text-wrap: pretty; }
.carousel__cta  { margin-top: 24px; }

.carousel__stage { min-width: 0; }

.carousel__track {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  border-radius: var(--radius-card);
}
.carousel__track::-webkit-scrollbar { display: none; }
.carousel__track:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 4px; }

.carousel__slide { scroll-snap-align: start; min-width: 0; }

.carousel__card {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-card);
  background: var(--gray-200) center / cover no-repeat;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

/* The caption sits on the photo, so it needs its own ground rather than
   relying on the image being dark enough — placeholder images are not, and
   neither is every photograph. */
.carousel__caption {
  width: 100%;
  padding: 24px;
  background: linear-gradient(#0000, #000000b8 55%);
  color: var(--color-white);
}
.carousel__name { margin: 0 0 14px; font-size: clamp(22px, 2.2vw, 30px); line-height: 1.1; }
.carousel__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 14px;
  border-top: 1px solid #ffffff3d;
}
.carousel__meta { margin: 0; color: #ffffffd9; }

.carousel__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
}
.carousel__dots { display: flex; gap: 8px; }
.carousel__dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--rule);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.carousel__dot[aria-selected="true"] { background: var(--accent); }
.carousel__dot:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 3px; }

.carousel__arrows { display: flex; gap: 8px; }
.carousel__arrow {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  color: inherit;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.carousel__arrow:hover:not(:disabled) { border-color: var(--accent-deep); }
.carousel__arrow:disabled { opacity: .35; cursor: default; }

/* Where the rail would be when there is nothing upcoming. Sits in the same
   grid cell as the stage, so the copy column keeps its position and the
   section keeps its shape. */
.carousel__empty {
  margin: 0;
  padding: 28px 0;
  border-top: 1px solid var(--rule);
  color: var(--text-muted);
  align-self: center;
}
.tone--navy .carousel__empty { border-color: rgba(255,255,255,.22); }

/* Band: the head across the top, the options in a row beneath it.
 *
 * For a carousel that has to sit above something more important than itself.
 * The side-by-side arrangement spends its height on one large card and a
 * column of copy next to it, which is right when the module IS the section
 * and wrong when it is a teaser for the section below: on Las Vegas /baseball/
 * that cost 778px before a visitor reached the schedule the page exists for,
 * and the module's own button pointed at it (Pastel #53).
 *
 * Same markup, same fields, same scroll-snap track. Only the arrangement
 * changes, so nothing has to be re-entered to switch between them.
 */
.carousel--band .carousel__inner {
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

/* A wrapping flex row rather than explicit grid placement, because any of
   these four can be absent and placed rows break the moment one is. */
.carousel--band .carousel__text {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 48px;
  width: 100%;
}
.carousel--band .carousel__text > .sec__eyebrow  { flex: 1 0 100%; margin: 0; }
/* Smaller than a section headline on purpose. In this arrangement the module
   is a teaser for the section underneath it, and at the full section size it
   wrapped to two lines of 56px and spent 106px saying so. */
.carousel--band .carousel__text > .sec__headline {
  flex: 1 1 26ch;
  margin: 0;
  font-size: clamp(26px, 2.6vw, 38px);
}
.carousel--band .carousel__text > .carousel__body { flex: 1 1 300px; margin: 0; }
.carousel--band .carousel__text > .carousel__cta  { flex: 0 0 auto; margin: 0; }

/* Three across, sharing the two gaps between them.
   A plain width, NOT minmax(0, ...): the minmax form gives every track a zero
   minimum, so instead of overflowing and scrolling, twelve cards squeezed
   themselves down to 97px each to fit the container. The track is supposed to
   overflow - that is what makes it a carousel. */
.carousel--band .carousel__track {
  grid-auto-columns: calc((100% - 32px) / 3);
}
/* Shorter than the 4:3 a single large card wants. A row of three is read by
   comparison, and comparison does not need the height. */
.carousel--band .carousel__card { aspect-ratio: 3 / 2; }
.carousel--band .carousel__name { font-size: clamp(19px, 1.5vw, 23px); }

@media (max-width: 900px) {
  .carousel--band .carousel__track { grid-auto-columns: calc((100% - 16px) / 2); }
}
@media (max-width: 599px) {
  .carousel--band .carousel__track { grid-auto-columns: 86%; }
  .carousel--band .carousel__text { gap: 12px; }
}

@media (max-width: 900px) {
  .carousel__inner { grid-template-columns: 1fr; gap: 28px; }
  .carousel--left .carousel__text,
  .carousel--left .carousel__stage { order: 0; }

  /* `.carousel--left .carousel__inner` is 0-2-0 and sits outside any media
     query, so the single-column rule above it (0-1-0) never won and a
     left-media carousel kept its two-column grid on a phone. Measured at
     375px: the rail was 128px wide and the card's own caption overflowed it.
     Same trap the aside note in base.css describes, which is now the third
     time it has come up in this theme. The :not() pair carries the weight. */
  .carousel:not(.carousel--band):not(.carousel--bare) .carousel__inner {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
  }

  /* On a phone the rail goes BETWEEN the headline and the paragraph. It is
     the thing the section is introducing, so a reader should meet it before
     the supporting copy rather than after the button, which is where a
     stacked two-column layout leaves it.

     The stage is a SIBLING of the text block, so the only way to interleave
     them is to let the text's children become grid items in their own right.
     Moving the markup instead would break the desktop two-column layout.
     Band and bare are excluded: band lays its own text out with `>` child
     rules that `display: contents` would strip, and bare has no copy. */
  /* NB: these are NOT `.carousel__inner > ...`. `display: contents` changes
     which boxes are generated, not the DOM, and the child combinator matches
     the DOM: the eyebrow, headline, body and button are children of
     .carousel__text however it lays out. Selecting them through the inner
     silently matched nothing and left the rail last. */
  .carousel:not(.carousel--band):not(.carousel--bare) .carousel__text { display: contents; }
  .carousel:not(.carousel--band):not(.carousel--bare) .sec__eyebrow    { order: 1; margin: 0 0 10px; }
  .carousel:not(.carousel--band):not(.carousel--bare) .sec__headline   { order: 2; margin: 0 0 24px; }
  .carousel:not(.carousel--band):not(.carousel--bare) .carousel__stage { order: 3; }
  .carousel:not(.carousel--band):not(.carousel--bare) .carousel__body  { order: 4; margin: 24px 0 0; }
  /* justify-self, because a grid item stretches where a flex item with
     align-items:flex-start did not: without it the button runs the full
     width of the screen. */
  .carousel:not(.carousel--band):not(.carousel--bare) .carousel__cta   { order: 5; margin-top: 24px; justify-self: start; }

  /* Full width, out to both screen edges. The track is padded back to the
     margin so the first card still lines up with the headline above it and
     the next one shows at the edge, which is what tells a reader the rail
     scrolls. Same device the bare variant already uses. */
  .carousel:not(.carousel--band):not(.carousel--bare) .carousel__stage {
    margin-inline: calc(var(--margin) * -1);
  }
  .carousel:not(.carousel--band):not(.carousel--bare) .carousel__track {
    scroll-padding-inline: var(--margin);
    padding-inline: var(--margin);
  }
}
