.top-gallery-wrapper {
    position: relative;
}

.top-gallery-header {
  text-align: left;
  margin-bottom: 0.5rem; /* tightened a bit since we add a selected title below */
  padding: 0 1rem;
}


.top-gallery-header h2 {
    font-size: 1.8rem;
    color: #212529;
    margin-top: 0;
    margin-bottom: 0.25rem;
    display: inline-block;
    border-left: 4px solid #0068B6;
    padding: 0.2rem 1rem 0.2rem 1rem;
    background-color: #ffffff;
    border-radius: 4px;
}


/* Container */
.top-gallery-container {
  width: 100vw;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;

  display: flex;
  align-items: center;
  overflow: hidden;

  padding-top: 0.5rem;     
  padding-bottom: 1rem;

  justify-content: flex-start;
  --card-gap: clamp(12px, 2vw, 24px);

  scrollbar-width: none;
}

.top-gallery-container::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.top-gallery-container.correcting .top-card {
  transition: none !important;
}

/* Individual application card */
.top-card {
    flex: 0 0 auto;
    box-sizing: border-box;

    /* Give all cards the same width for deterministic spacing */
    width: clamp(420px, 80vw, 1300px);
    max-width: 1300px;
    aspect-ratio: 21 / 9;


    /* Fixed spacing through margins; consistent across cards */
    margin: 0 var(--card-gap);

    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;

    background-size: cover;
    background-position: center;

    border-radius: 12px;
    overflow: hidden;

    /* Inactive state styles */
    transform: scale(0.85);
    transform-origin: center center;
    opacity: 0.6;
    transition: transform 0.5s ease;
    will-change: transform;
    backface-visibility: hidden; 
}

/* Active card */
.top-card.active {
    transform: scale(1);
    opacity: 1;
    z-index: 2; /* ensure active is layered above */
}

.top-card-content {
    color: #ffffff;
    padding: 1.5rem 2rem;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
}

.top-card-content h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    border-left: 3px solid #0068B6;
    padding-left: 1rem;
    color: #ffffff !important;
    opacity: 1 !important;
}

.top-card-content p {
    margin-bottom: 0;
    font-size: 1rem;
    line-height: 1.6;
    opacity: 0.9;
}

.top-gallery-nav {
    text-align: center;
    margin-top: 1rem;
}

.top-gallery-nav button {
    width: 44px;
    height: 44px;
    margin: 0 0.5rem;
    border-radius: 50%;
    border: 1px solid #0068B6;
    background-color: #ffffff;
    color: #0068B6;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.top-gallery-nav button:hover {
    background-color: #0068B6;
    color: #ffffff;
    border-color: #0068B6;
}



/* Title band tightly above each image (outside cap that travels with the card) */
.top-card-title {
  --card-title-height: 28px;     /* adjust band height */
  --card-title-gap: 0px;         /* vertical gap between title and image; keep 0 for "tight" */
  position: absolute;
  top: calc(-1 * (var(--card-title-height) + var(--card-title-gap)));
  left: 0;
  right: 0;
  height: var(--card-title-height);

  display: none;
  align-items: left;
  justify-content: left;        /* center the text; use flex-start for left-aligned */

  padding: 0 0.9rem;
  background: #ffffff;            /* title background */
  color: #6c757d;
  font-weight: 600;
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  z-index: 3;                     /* sit above card content */
  pointer-events: none;           /* keeps card clicks usable; remove if the title should be interactive */
}


/* NEW: Selected title bar (left-aligned to header text, right below the header) */
.top-gallery-selected-title-wrap {
  padding: 0 1rem;          
  margin: 0;               
}
.top-gallery-selected-title {
  /* Align to the start of the H2 text */
  margin-left: 1rem;
  font-size: 1.05rem;
  color: #6c757d;
  line-height: 1.4;
  font-weight: 500;
  margin-bottom: 0.4rem; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-gallery-container::-webkit-scrollbar { display: none; }


/* Responsive fine-tuning (optional) */
@media (max-width: 768px) {
  .top-gallery-selected-title {
    margin-left: calc(1rem + 1rem + 4px);
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
  }
  .top-gallery-container { padding-top: 0.4rem; }
}


/* Track that we move as a whole */
.top-gallery-track {
  display: flex;
  align-items: center;
  will-change: transform;
  transition: transform 550ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Cards: equal size, no scale/opacity differences */
.top-card {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: clamp(420px, 80vw, 1300px);
  max-width: 1300px;
  aspect-ratio: 21 / 9;
  margin: 0 var(--card-gap);

  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;

  background-size: cover;
  background-position: center;

  border-radius: 12px;
  overflow: hidden;

  /* Remove scale/opacity differences */
  transform: none;
  opacity: 1;
  transition: none; /* animation will be on the track, not on individual cards */
}

