.top-gallery-wrapper {
    width: 100%; /* Fill the rst-content parent */
    box-sizing: border-box; /* Ensure padding doesn't add to width */
    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;
}

/* 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;
}

.top-card-title {
  display: none;
}

/* NEW: Selected title bar (left-aligned to header text, right below the header) */
.top-gallery-selected-title-wrap {
  margin: 0;
  display: none;
}

.top-gallery-selected-title {
  /* Align to the start of the H2 text */
  margin-left: 0;
  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; }

/* 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: var(--xl-main-width);
  max-width: var(--xl-main-max-width);
  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: 0px;
  overflow: hidden;

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

@media (max-width: 1200px) {
    .top-gallery-wrapper {
        padding: 0 0;
        box-sizing: border-box;
    }

    /* [JITTER FIX] Add perspective to create a 3D rendering context for smoother animation */
    .top-gallery-container {
        display: block;
        overflow: hidden;
        perspective: 1000px; /* Jitter Fix */
        width: 100%;
        left: auto;
        transform: none;
        padding: 0;
        --card-gap: 0px;
        height: auto;
        margin-bottom: 0;
    }

    /* [JITTER FIX] Add backface-visibility to stabilize the moving track */
    .top-gallery-track {
        backface-visibility: hidden;
    }

    .top-gallery-selected-title {
        font-size: 0.95rem;
        margin-bottom: 0.35rem;
    }

    .top-gallery-nav {
        margin: 1rem -1.25rem 0;
        padding-bottom: 1rem;

        /* Add Flexbox to center the buttons themselves */
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .top-gallery-nav button {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;

        /* --- ADD THESE LINES --- */
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1; /* Reset line-height to avoid conflicts */
    }

    .top-gallery-mobile-content {
        display: block;
        background-color: #ffffff;
        padding: 0;
        margin: 1rem 0;
        box-sizing: border-box;
    }

    .top-gallery-mobile-content h3 {
        color: #212529 !important;
        border-left: 3px solid #0068B6;
        padding-left: 1rem;
        font-size: 1.3rem;
        margin-top: 0;
        margin-bottom: 0.75rem;
    }
    
    .top-gallery-mobile-content p {
        color: #6c757d !important;
        margin-bottom: 0;
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .top-card .top-card-content {
        display: none !important;
    }

    .top-card {
        width: 100%;
        flex-shrink: 0;
        height: auto;
        aspect-ratio: 16 / 9;
        margin: 0;
        border-radius: 0;
        padding: 0;
    }
}


