/* Study Destinations flag marquee
   Plain CSS. Speeds, size, gap, and how many flags are visible
   are all variables so they can be tuned in one place. */

.study-destinations {
  --flag-size: 80px;
  --flag-gap: 22px;
  --flags-visible: 6; /* desktop: about 5–6 flags in view */
  --row-speed-1: 30s;
  --row-speed-2: 38s;
  --row-speed-3: 34s;

  background: linear-gradient(180deg, #0b5e5e 0%, #129696 55%, #168f8f 100%);
  color: #fff;
  padding: 56px 16px 64px;
  text-align: center;
  overflow: hidden;
}

.study-destinations h2 {
  margin: 0;
  font-family: Poppins, Inter, sans-serif;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.study-destinations .study-destinations-lead {
  margin: 8px 0 28px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1rem;
}

/* Each row is a window. Only --flags-visible circles show; the rest sit outside and slide in. */
.marquee-row {
  display: flex;
  justify-content: center;
  margin: 0 auto 18px;
}

.marquee-row:last-child {
  margin-bottom: 0;
}

.marquee-viewport {
  width: calc(
    var(--flags-visible) * var(--flag-size) +
    (var(--flags-visible) - 1) * var(--flag-gap)
  );
  max-width: 100%;
  overflow: hidden;
  /* Room so the hover scale and tooltip are not clipped */
  padding: 36px 0 8px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 10%, #000 90%, transparent);
}

.marquee-track {
  display: flex;
  width: max-content;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  will-change: transform;
}

/* Direction and speed. Row 1 and 3 go left, row 2 goes right. */
.marquee-row:nth-child(1) .marquee-track {
  animation-name: marquee-left;
  animation-duration: var(--row-speed-1);
}
.marquee-row:nth-child(2) .marquee-track {
  animation-name: marquee-right;
  animation-duration: var(--row-speed-2);
}
.marquee-row:nth-child(3) .marquee-track {
  animation-name: marquee-left;
  animation-duration: var(--row-speed-3);
}

.marquee-row:hover .marquee-track {
  animation-play-state: paused;
}

/* One set plus its trailing gap. Two identical sets make translateX(-50%) seamless. */
.marquee-set {
  display: flex;
  align-items: center;
  gap: var(--flag-gap);
  padding-right: var(--flag-gap);
  flex: none;
}

.flag-item {
  position: relative;
  width: var(--flag-size);
  height: var(--flag-size);
  flex: none;
}

.flag-item img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
  background: #fff;
  transition: transform 0.25s ease;
}

.flag-item:hover img {
  transform: scale(1.15);
}

.flag-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #fff;
  color: #0b5e5e;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.flag-item:hover .flag-tip {
  opacity: 1;
}

@keyframes marquee-left {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@keyframes marquee-right {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

/* Tablet: 3–4 flags visible */
@media (max-width: 1024px) {
  .study-destinations {
    --flags-visible: 4;
    --flag-gap: 18px;
  }
}

/* Mobile: 2–3 flags visible, smaller circles */
@media (max-width: 640px) {
  .study-destinations {
    --flag-size: 60px;
    --flags-visible: 3;
    --flag-gap: 14px;
  }

  .study-destinations h2 {
    font-size: 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .marquee-track {
    animation: none;
    transform: none;
  }
}
