/* ==========================================================
   Carousel (CSS scroll-snap). Load AFTER styles.css:
   <link rel="stylesheet" href="styles.css">
   <link rel="stylesheet" href="carousel.css">

   Works without JavaScript (swipe, scroll, or use the keyboard).
   The small script on the page only adds the previous/next buttons.
   ========================================================== */

/* Heading on the left, arrow buttons on the right */
.carousel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.carousel-header h2 {
  margin: 0;
}

.carousel-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.carousel-btn {
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.carousel-btn:hover:not(:disabled),
.carousel-btn:focus-visible {
  background: var(--color-accent);
}

.carousel-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.carousel-btn:focus-visible,
.carousel-track:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* The scrolling strip */
.carousel-track {
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0 0 0.75rem;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

/* One prize card. Phones: one card with a peek at the next one. */
.carousel-item {
  flex: 0 0 85%;
  scroll-snap-align: start;
  border: 1px solid rgba(31, 58, 95, 0.3);
  border-radius: var(--radius);
  padding: 1rem;
}

.carousel-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;       /* every photo gets the same box, any shape of image */
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.carousel-item h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.carousel-item p {
  margin: 0;
}

/* Card count follows the width of the carousel's own box, not the screen,
   so it also looks right in the narrower column next to the side menu. */
.carousel {
  container-type: inline-size;
}

.carousel-track {
  min-width: 0;
  max-width: 100%;
}

/* Two cards at a time once the box is wide enough */
@container (min-width: 460px) {
  .carousel-item {
    flex-basis: calc((100% - 1rem) / 2);
  }
}

/* Three at a time when it is wider still (a full-width page) */
@container (min-width: 720px) {
  .carousel-item {
    flex-basis: calc((100% - 2rem) / 3);
  }
}


/* Let long web addresses wrap instead of stretching the card */
.carousel-item {
  min-width: 0;
  overflow-wrap: anywhere;
}