.grid-gallery-carousel {
    position: relative;
    overflow: hidden;
    width: 100%;
    display: flex;
    gap: 40px;
    flex-direction: column;
}

.grid-gallery-container[data-theme="light"] {
    background: var(--gg-theme-light-bg);
}

.grid-gallery-container[data-theme="dark"] {
    background: var(--gg-theme-dark-bg);
}

.grid-gallery-container[data-theme="nline"] {
    background: var(--gg-theme-nline-bg);
}

.grid-gallery-container {
    display: grid;
    align-items: center;
    align-self: stretch;
    background: #fff;
    max-width: 1912px;
    margin: 0 auto;
}

.grid-gallery-container.padding-small {
    padding: 64px 80px;
}

.grid-gallery-container.padding-large {
    padding: 64px 0 64px 80px;
}

.grid-gallery-track {
    display: flex;
    transition: transform 0.4s ease;
    width: 100%;
}

.grid-gallery-page {
    flex: 0 0 95%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 24px;
    padding-left: 24px;
    transition: transform 0.4s ease;
    box-sizing: border-box;
}

.grid-gallery-track .grid-gallery-page:first-child {
    padding-left: 0;
}

.grid-gallery-track .grid-gallery-page.no-padding {
    padding-left: 0;
}

.grid-gallery-modal-track .grid-gallery-media {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1; /* below caption */
    margin: 0;
    padding: 0;
}

/* Ensure video source fills container */
.grid-gallery-modal-track .grid-gallery-media video source {
    width: 100%;
    height: 100%;
}

.grid-gallery-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.grid-gallery-media-third {
    flex: 1;
    height: 100%;
}

.grid-gallery-media img {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
}

.grid-third-img {
    object-fit: cover !important;
}

.grid-gallery-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgb(0 44 95 / 50%);
    z-index: 0;
    touch-action: auto;
    -webkit-overflow-scrolling: touch;
  }
  
.grid-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: linear-gradient(
        0deg,
        rgba(0 0 0 / 75%) 0%,
        rgba(0 0 0 / 50%) 100%
    );
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Always show overlay if .show-overlay */
.grid-gallery-overlay.show-overlay {
    opacity: 1;
    visibility: visible;
}

/* Update hover effect for card */
.grid-gallery-card:hover .grid-gallery-media::before {
    background-color: rgba(0 0 0 / 54%);
}

/* Show overlay on hover with proper timing */
.grid-gallery-card:hover .grid-gallery-overlay {
    opacity: 1;
    visibility: visible;
}

/* Default hidden overlay for cards without caption */
.grid-gallery-overlay.hide-overlay-on-hover {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Keep expand icon and text visible */
.grid-gallery-overlay .grid-expand-container,
.grid-gallery-overlay p {
    opacity: 1 !important;
    color: #fff !important;
    z-index: 3;
}

/* Reveal overlay on hover of card */
.grid-gallery-card:hover .grid-gallery-overlay.hide-overlay-on-hover {
    opacity: 1;
    visibility: visible;
}

.grid-expand-container {
    display: flex;
    padding: 8px;
    align-items: center;
    gap: 8px;
    border-radius: 4px;
    background: rgba(0 0 0 / 60%);
    opacity: 1 !important;
}

.grid-expand-container .icon-icon-expand {
    opacity: 1 !important;
    color: #fff !important;
}

.grid-gallery-overlay h3 {
    font-family: "HyundaiSansHead-Medium";
    font-size: 18px;
    margin: 0 0 8px;
}

.grid-gallery .icon-icon-expand,
.grid-gallery-modal .icon-icon-expand {
    display: inline-block;
    width: 16px;
    height: 16px;
}

.grid-gallery-overlay p {
    font-family: "HyundaiSansHead-Medium";
    font-size: 16px;
    margin: 0;
    opacity: 0.8;
    overflow: hidden;
    color: #fff;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: normal;
    font-weight: 500;
    line-height: 20px;
    z-index: 2;
}

.grid-gallery-carousel .carousel-control-container {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 95%;
}

.grid-gallery-carousel .carousel-indicator {
    flex: 1;
    height: 1px;
    background: #5d5d5c;
    position: relative;
}

.grid-gallery-carousel .carousel-active-line {
    position: absolute;
    height: 3px;
    background: var(--gg-theme-light-active-line) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transition: transform 0.4s ease, width 0.4s ease;
    bottom: 1px;
}

[data-theme="dark"] .grid-gallery-carousel .carousel-active-line {
    background: var(--gg-theme-dark-active-line) !important;
}

[data-theme="nline"] .grid-gallery-carousel .carousel-active-line {
    background: var(--gg-theme-nline-active-line) !important;
}

.grid-gallery-carousel .control-arrow {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Navigation Buttons */
.grid-gallery-nav {
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: #fff;
    border: 1px solid var(--gg-theme-light-arrow-border);
    padding: 0;
}

/* CHANGE: Theme-based arrow borders */
[data-theme="dark"] .grid-gallery-nav {
    background: transparent;
    border-color: var(--gg-theme-dark-arrow-border);
}

[data-theme="dark"] .grid-gallery-nav.disabled {
    border-color: var(--gg-theme-dark-arrow-border-disabled);
}

[data-theme="nline"] .grid-gallery-nav {
    border-color: var(--gg-theme-nline-arrow-border);
}

[data-theme="nline"] .grid-gallery-nav.disabled {
    border-color: var(--gg-theme-nline-arrow-border-disabled);
}

.grid-gallery-nav.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #909090;
}

.grid-gallery-nav .icon-chevron-forward-light::before {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    stroke-width: 1.5px;
    margin: auto;
}

/* CHANGE: Theme-based arrow icon colors */
[data-theme="dark"] .grid-gallery-nav .icon-chevron-forward-light::before {
    color: var(--gg-theme-dark-arrow-border);
}

[data-theme="dark"]
    .grid-gallery-nav.disabled
    .icon-chevron-forward-light::before {
    color: var(--gg-theme-dark-arrow-border-disabled);
}

.grid-gallery-nav.disabled .icon-chevron-forward-light {
    color: #909090;
    stroke-width: 1.5px;
    margin: auto;
}

/* Rotate prev icon while maintaining center alignment */
.grid-gallery-modal-prev .icon-chevron-forward-light,
.grid-gallery-nav.prev .icon-chevron-forward-light {
    transform: rotate(180deg);
    transform-origin: center; /* Ensure rotation happens from center */
}

.grid-gallery-card,
.grid-gallery-media,
.horizontal-content-media-video-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    cursor: pointer;
}

/* Make sure media wrapper is positioned */
.grid-gallery-media {
    position: relative;
    overflow: hidden;
    flex: 1;
    height: 100%;
}

.horizontal-content-media-video-wrapper {
    position: relative;
    overflow: hidden;
    height: 100%;
}

/* Overlay (default transparent) */
.grid-gallery-card:not(.grid-gallery-modal *) .grid-gallery-media::before,
.grid-gallery-card:not(.grid-gallery-modal *)
    .horizontal-content-media-video-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: rgba(0 0 0 / 0%);
    transition: background-color 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

/* On hover → dim media only */
.grid-gallery-card:not(.grid-gallery-modal *):hover .grid-gallery-media::before,
.grid-gallery-card:not(.grid-gallery-modal *):hover
    .horizontal-content-media-video-wrapper::before {
    background-color: rgba(0 0 0 / 54%);
}

.grid-gallery-modal .grid-gallery-media::before,
.grid-gallery-modal .horizontal-content-media-video-wrapper::before {
    display: none;
}

.horizontal-content-media-video-wrapper.no-hover::before {
    background-color: transparent !important;
}

.horizontal-content-media-video-wrapper.no-hover:hover::before {
    background-color: transparent !important;
}

/* Keep media elements below overlay */
.grid-gallery-media video,
.horizontal-content-media-video-wrapper iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
}

/* Captions & icons always above everything */
.grid-gallery-card .caption,
.grid-gallery-card .icon {
    position: relative;
    z-index: 2;
}

.grid-gallery-modal .horizontal-content-media-video-wrapper .video-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.grid-gallery-modal .icon-video-play-circle {
    opacity: 1; /* ensure it's visible */
}

.grid-gallery.static {
    display: grid;
    gap: 16px;
    align-items: stretch;
}

/* ===== DESKTOP GRID LAYOUT (Carousel + Static) ===== */
.grid-gallery-page.cards-3,
.grid-gallery.static.cards-3 {
    grid-template-columns: 1fr 2fr;
    grid-template-rows: 1fr 1fr;
    gap: 24px;
}

.grid-gallery-page.cards-3 .grid-gallery-card:nth-child(1),
.grid-gallery.static.cards-3 .grid-gallery-card:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.grid-gallery-page.cards-3 .grid-gallery-card:nth-child(2),
.grid-gallery.static.cards-3 .grid-gallery-card:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.grid-gallery-page.cards-3 .grid-gallery-card:nth-child(3),
.grid-gallery.static.cards-3 .grid-gallery-card:nth-child(3) {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.grid-gallery-page.cards-4,
.grid-gallery.static.cards-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 24px;
}

.grid-gallery-page.cards-4 .grid-gallery-card:nth-child(1),
.grid-gallery.static.cards-4 .grid-gallery-card:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.grid-gallery-page.cards-4 .grid-gallery-card:nth-child(2),
.grid-gallery.static.cards-4 .grid-gallery-card:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.grid-gallery-page.cards-4 .grid-gallery-card:nth-child(3),
.grid-gallery.static.cards-4 .grid-gallery-card:nth-child(3) {
    grid-column: 1 / span 2;
    grid-row: 2;
}

.grid-gallery-page.cards-4 .grid-gallery-card:nth-child(4),
.grid-gallery.static.cards-4 .grid-gallery-card:nth-child(4) {
    grid-column: 3;
    grid-row: 1 / span 2;
}

.grid-gallery-page.cards-5,
.grid-gallery.static.cards-5 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
    gap: 24px;
}

.grid-gallery-page.cards-5 .grid-gallery-card:nth-child(1),
.grid-gallery.static.cards-5 .grid-gallery-card:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.grid-gallery-page.cards-5 .grid-gallery-card:nth-child(2),
.grid-gallery.static.cards-5 .grid-gallery-card:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
}

.grid-gallery-page.cards-5 .grid-gallery-card:nth-child(3),
.grid-gallery.static.cards-5 .grid-gallery-card:nth-child(3) {
    grid-column: 1 / span 2;
    grid-row: 2;
}

.grid-gallery-page.cards-5 .grid-gallery-card:nth-child(4),
.grid-gallery.static.cards-5 .grid-gallery-card:nth-child(4),
.grid-gallery-page.cards-5 .grid-gallery-card:nth-child(5),
.grid-gallery.static.cards-5 .grid-gallery-card:nth-child(5) {
    grid-column: 3;
}

.grid-gallery-page.cards-5 .grid-gallery-card:nth-child(4),
.grid-gallery.static.cards-5 .grid-gallery-card:nth-child(4) {
    grid-row: 1;
}

.grid-gallery-page.cards-5 .grid-gallery-card:nth-child(5),
.grid-gallery.static.cards-5 .grid-gallery-card:nth-child(5) {
    grid-row: 2;
}

.grid-gallery-modal {
    position: fixed;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 4px 45px 0 rgba(0 0 0 / 15%);
    background: rgba(255 255 255 / 90%);
    padding: 20px;
    box-sizing: border-box;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.grid-gallery-modal.open {
    display: flex;
}

.grid-gallery-modal-content {
    position: relative;
    background: #000;
    width: 100%;
    height: 100%;
    max-width: min(1120px, calc(100vw - 40px));
    max-height: min(775px, calc(100vh - 40px));
    min-width: 320px;
    min-height: 400px;
    border-radius: 0;
    overflow: hidden;
    box-sizing: border-box;
    overscroll-behavior: contain;
}

.grid-gallery-display-none {
    display: none;
}

.grid-gallery-modal-description-sub {
    display: flex;
    align-items: flex-start;
    gap: 66px;
}

.grid-gallery-modal-description-sub-content {
    display: flex;
    width: auto;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    position: relative;
    overflow-y: auto !important;
    scrollbar-gutter: stable;
    max-height: 15vh;
    min-height: 15vh;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #5d5d5c #909090;
    padding-right: 10px;
    -webkit-overflow-scrolling: touch;
}

.grid-gallery-modal-description-sub-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    display: block !important;
    appearance: none !important;
    background-color: transparent;
}

.grid-gallery-modal-description-sub-content::-webkit-scrollbar-track {
    background: #e0e0e0;
    border-radius: 4px;
    display: block !important;
    box-shadow: inset 0 0 6px rgb(0 0 0 / 10%);
}

.grid-gallery-modal-description-sub-content::-webkit-scrollbar-thumb {
    background: #5d5d5c;
    border-radius: 3px;
    min-height: 30px;
    opacity: 1;
    box-shadow: inset 0 0 6px rgb(0 0 0 / 20%);
}

.grid-gallery-modal-description-sub-content::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

.grid-gallery-modal-description-sub-content:hover::-webkit-scrollbar,
.grid-gallery-modal-description-sub-content:active::-webkit-scrollbar,
.grid-gallery-modal-description-sub-content:focus::-webkit-scrollbar {
    opacity: 1 !important;
    display: block !important;
}

@supports (-webkit-appearance: none) {
    .grid-gallery-modal-description-sub-content {
        &::-webkit-scrollbar {
            opacity: 1 !important;
            appearance: none !important;
            width: 8px;
        }

        &::-webkit-scrollbar:vertical {
            width: 8px;
        }

        &::-webkit-scrollbar-track {
            opacity: 1 !important;
            visibility: visible !important;
        }

        &::-webkit-scrollbar-thumb {
            opacity: 1 !important;
            visibility: visible !important;
        }
    }
}

.grid-gallery-modal-legal a {
    color: #002c5f;
    font-family: "HyundaiSansText-Medium";
    font-size: 16px;
    font-weight: 500;
    line-height: 20px;
    text-decoration: none;
}

.grid-legal-text-link {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.grid-gallery-modal-legal {
    color: #002c5f;
    font-family: "HyundaiSansText-Medium";
    font-size: 16px;
    font-style: normal;
    font-weight: 500;
    line-height: 20px;
}

.grid-gallery-modal-close {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 16px;
    right: 16px;
    background: rgba(0 0 0 / 60%);
    border: none;
    cursor: pointer;
    z-index: 1001;
    padding: 8px;
    gap: 8px;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    flex-shrink: 0;
}

.grid-gallery-modal-close .icon-close-light {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    stroke: #fff;
    stroke-width: 1.8px;
    width: 20px;
    height: 20px;
}

/* Ensure proper hover state and focus outline for accessibility */
.grid-gallery-modal-close:hover {
    background: rgba(0 0 0 / 50%);
}

.grid-gallery-modal-close:focus {
    outline: none;
}

/* CHANGE: Add focus-visible for keyboard navigation only */
.grid-gallery-modal-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Special case: When only 2 cards are present, display in single column */
.grid-gallery-page.cards-2,
.grid-gallery.static.cards-2 {
    grid-template-rows: repeat(2, 1fr);
    gap: 24px;
}

.grid-gallery-page.cards-2 .grid-gallery-card:nth-child(1),
.grid-gallery.static.cards-2 .grid-gallery-card:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
}

.grid-gallery-page.cards-2 .grid-gallery-card:nth-child(2),
.grid-gallery.static.cards-2 .grid-gallery-card:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
}

.grid-legal-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.grid-legal-content.expanded {
    max-height: 300px;
    overflow-y: auto;
}

.grid-gallery-modal-description {
    display: flex;
    flex-direction: column;
    padding: 24px 16px 16px;
    background: rgba(255 255 255 / 90%);
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    gap: 16px;
    height: 35%;
    flex: 0 0 35%;
    min-height: 0;
    max-height: 35%;
    position: relative;
    z-index: 10;
}

.grid-legal-content-text {
    color: #5d5d5c;
    font-family: "HyundaiSansText-Regular";
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 16px;
}

.grid-legal-content.error .grid-legal-content-text {
    color: #d32f2f;
}

.grid-legal-inline-loader {
    display: flex;
    justify-content: center;
    padding: 12px;
}

.grid-legal-inline-loader .grid-legal-loader-spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #002c5f;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.grid-gallery-modal-legal-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.grid-gallery-modal-legal-link:hover {
    text-decoration: underline;
}

.grid-gallery-modal-content-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 24px; /* From layout_CKQ3EL */
    width: 100%;
    padding: 0; /* Add padding for button spacing */
}

.grid-gallery-modal-title {
    color: #000;
    font-family: "HyundaiSansHead-Medium";
    font-size: 24px;
    font-style: normal;
    font-weight: 500;
    line-height: 32px;
}

.grid-gallery-modal-text {
    color: #000;
    font-family: "HyundaiSansText-Regular";
    font-size: 18px;
    font-style: normal;
    font-weight: 400;
    line-height: 24px;
}

.grid-gallery-modal-track {
    position: relative;
    width: 100%;
    height: 65%;
    flex: 0 0 65%;
    min-height: 0;
    max-height: 65%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.grid-gallery-modal-track .grid-gallery-media img {
    width: auto;
    height: auto;
    max-width: 100%;
    background: #000;
}

/* All media elements inside modal fully cover container */
.grid-gallery-modal-track .grid-gallery-modal-slide {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: stretch; /* stretch to fill */
    justify-content: center;
    position: relative;
}

/* Cover images, videos, iframes fully */
.grid-gallery-modal-track .grid-gallery-media video,
.grid-gallery-modal-track .grid-gallery-media iframe,
.grid-gallery-modal-track .grid-gallery-modal-slide video,
.grid-gallery-modal-track .grid-gallery-modal-slide iframe {
    width: 100%;
    height: 100%;
    object-fit: cover; /* cover without gaps */
    margin: 0;
    padding: 0;
}

.grid-gallery-modal-slide video,
.grid-gallery-modal-slide iframe {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    z-index: 1;
}

.grid-gallery-modal-carousel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    overflow: hidden;
}

.grid-gallery-modal-prev,
.grid-gallery-modal-next {
    width: 48px; /* From layout_WMOIRQ */
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #002c5f;
    background: #fff;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: border-color 0.3s ease;
}

/* Update video container styles */
.grid-gallery-modal .horizontal-content-media-video-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    margin: 0;
    padding: 0;
}

/* Update video element styles */
.grid-gallery-modal .horizontal-content-media-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    margin: 0;
    padding: 0;
    background: #000;
}

/* Disabled state for modal navigation */
.grid-gallery-modal-prev.disabled,
.grid-gallery-modal-next.disabled,
.grid-gallery-modal-prev[disabled],
.grid-gallery-modal-next[disabled] {
    border-color: #909090;
    cursor: not-allowed;
    opacity: 0.5;
}

.grid-gallery-modal-prev[disabled] .icon-chevron-forward-light,
.grid-gallery-modal-next[disabled] .icon-chevron-forward-light,
.grid-gallery-modal-prev.disabled .icon-chevron-forward-light,
.grid-gallery-modal-next.disabled .icon-chevron-forward-light {
    stroke: #909090;
}

.grid-gallery-modal-prev {
    left: 16px; /* Adjust as needed for spacing */
}

.grid-gallery-modal-next {
    right: 16px; /* Adjust as needed for spacing */
}

.grid-legal-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255 25 255 70%);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-legal-loader-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #333;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.grid-legal-modal {
    position: fixed;
    inset: 0;
    background: rgba(0 0 0 / 60%);
    justify-content: center;
    align-items: center;
    z-index: 2000; /* higher than the media modal */
    display: flex;
    padding: 40px 32px;
    flex-direction: column;
    gap: 16px;
}

.grid-legal-modal-content {
    position: relative;
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 2100;
}

.grid-legal-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #000;
    z-index: 2200;
}

.grid-legal-modal-text {
    font-family: "HyundaiSansText-Regular";
    font-size: 16px;
    line-height: 1.5;
    color: #333;
}

.grid-gallery-mobile-button {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 72px;
    position: relative;
    z-index: 100;
}

/* Default: hide both to avoid flicker */
.grid-gallery-modal-mobile,
.grid-gallery-modal-desktop {
    display: none;
}

/* Rotate prev chevron */
.grid-gallery-modal-prev .icon-chevron-forward-light {
    transform: rotate(180deg);
    transform-origin: center;
}

/* Icon sizing */
.grid-gallery-modal-prev .icon-chevron-forward-light,
.grid-gallery-modal-next .icon-chevron-forward-light {
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    stroke: #002c5f;
    stroke-width: 1.5px;
    line-height: 1; /* Ensure consistent line height */
    margin: 2px 4px; /* Remove any margin that could affect alignment */
}

/* Icon styling for disabled state */
.grid-gallery-modal-prev[disabled] .icon-chevron-forward-light,
.grid-gallery-modal-next[disabled] .icon-chevron-forward-light {
    stroke: #909090;
}

.grid-gallery-card .video-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-gallery-card .video-controls .icon-video-play-circle {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #fff;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.grid-gallery-card .video-controls:hover .icon-video-play-circle {
    opacity: 0.8;
}

/* Modal specific video controls */
.grid-gallery-modal .video-controls .icon-video-play-circle {
    width: 64px;
    height: 64px;
    font-size: 64px;
}

@media (min-width: 1025px) {
    .grid-gallery-modal-track {
        height: 65%;
        flex: 0 0 65%;
        min-height: 0;
        max-height: 65%;
    }

    .grid-gallery-modal-description {
        height: 35%;
        flex: 0 0 35%;
        min-height: 0;
        max-height: 35%;
    }

    .grid-gallery-modal-content {
        /* CHANGE: Adjust desktop modal sizing */
        max-width: min(1120px, calc(100vw - 80px));
        max-height: min(775px, calc(100vh - 80px));
    }

    .grid-gallery-modal-desktop {
        display: flex;
        gap: 1rem;
        align-items: flex-start;
        justify-content: space-evenly;
    }

    .grid-gallery-page.cards-6,
    .grid-gallery.static.cards-6 {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(2, 1fr);
        gap: 24px;
        height: 800px;
    }

    /* CHANGE: Ensure pages after first 6 cards always use uniform 6-card grid layout */
    .grid-gallery-page.cards-6 .grid-gallery-card {
        /* All cards in pages after first use standard sizing */
        grid-column: auto;
        grid-row: auto;
    }

    /* CHANGE: Column-wise progressive layout - first column fills, then second, then third */
    .grid-gallery-page.cards-6 .grid-gallery-card:nth-child(1),
    .grid-gallery.static.cards-6 .grid-gallery-card:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    .grid-gallery-page.cards-6 .grid-gallery-card:nth-child(2),
    .grid-gallery.static.cards-6 .grid-gallery-card:nth-child(2) {
        grid-column: 1;
        grid-row: 2;
    }

    .grid-gallery-page.cards-6 .grid-gallery-card:nth-child(3),
    .grid-gallery.static.cards-6 .grid-gallery-card:nth-child(3) {
        grid-column: 2;
        grid-row: 1;
    }

    .grid-gallery-page.cards-6 .grid-gallery-card:nth-child(4),
    .grid-gallery.static.cards-6 .grid-gallery-card:nth-child(4) {
        grid-column: 2;
        grid-row: 2;
    }

    .grid-gallery-page.cards-6 .grid-gallery-card:nth-child(5),
    .grid-gallery.static.cards-6 .grid-gallery-card:nth-child(5) {
        grid-column: 3;
        grid-row: 1;
    }

    .grid-gallery-page.cards-6 .grid-gallery-card:nth-child(6),
    .grid-gallery.static.cards-6 .grid-gallery-card:nth-child(6) {
        grid-column: 3;
        grid-row: 2;
    }

    .grid-gallery-modal-text a {
        color: var(--theme-link-color, #002c5f);
        text-decoration: underline;
        transition: color 0.3s ease;
    }

    .grid-gallery.static.cards-3,
    .grid-gallery.static.cards-4,
    .grid-gallery.static.cards-5 {
        display: grid;
        gap: 24px;
    }

    .grid-gallery.static.cards-3 {
        grid-template-columns: 1fr 2fr !important;
        grid-template-rows: 1fr 1fr !important;
    }

    .grid-gallery.static.cards-4 {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: auto auto !important;
    }

    .grid-gallery.static.cards-5 {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: repeat(2, 1fr) !important;
    }

    /* CHANGE: Ensure carousel pages after first 6 use progressive 2-1-1 grid layout */
    .grid-gallery-carousel .grid-gallery-page.cards-6 {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-template-rows: repeat(2, 1fr) !important;
        gap: 24px !important;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .grid-gallery-modal {
        padding: 16px;
    }

    .grid-gallery-modal-content {
        max-width: min(570px, calc(100vw - 32px));
        max-height: min(672px, calc(100vh - 32px));
        width: 100%;
        height: auto;
        overflow-y: hidden;
    }

    .grid-gallery-modal .grid-gallery-modal-track {
        height: 65%;
        flex: 0 0 65%;
        min-height: 0;
        max-height: 65%;
    }

    .grid-gallery-modal-description {
        height: 35%;
        flex: 0 0 35%;
        min-height: 0;
        max-height: 35%;
        padding: 24px 32px;
    }

    .grid-gallery-modal-close {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
    }

    picture[data-automation-ref="AUT_GridGallery_Image"] {
        width: 100%;
        display: block;
    }

    picture[data-automation-ref="AUT_GridGallery_Image"] img {
        width: 100%;
    }

    .grid-gallery-page.cards-3,
    .grid-gallery.static.cards-3 {
        grid-template-rows: auto;
    }

    .grid-gallery-card .grid-gallery-media::before,
    .grid-gallery-card .horizontal-content-media-video-wrapper::before {
        background-color: rgba(0 0 0 / 54%);
    }

    .grid-gallery-card {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .grid-gallery-media {
        position: relative;
        overflow: hidden;
        flex: 1;
        height: 100%;
        display: flex;
    }

    .horizontal-content-media-video-wrapper {
        position: relative;
        overflow: hidden;
        height: 100%;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .grid-gallery-media img,
    .grid-gallery-media video,
    .grid-gallery-media iframe,
    .horizontal-content-media-video-wrapper video,
    .horizontal-content-media-video-wrapper iframe {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .grid-gallery.static[class*="cards-"] {
        display: grid;
        grid-template-columns: 1fr 1fr; /* 2 cards per row */
        grid-auto-rows: 1fr; /* auto grow rows */
        gap: 20px;
    }

    .grid-gallery.static.cards-3,
    .grid-gallery.static.cards-4,
    .grid-gallery.static.cards-5 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-auto-rows: 1fr !important;
        gap: 20px !important;
    }

    /* CHANGE: Ensure tablet carousel pages after first 6 use uniform grid */
    .grid-gallery-carousel .grid-gallery-page.cards-6 {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-auto-rows: 1fr !important;
        gap: 20px !important;
    }

    .grid-gallery.static.cards-3 .grid-gallery-card:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    .grid-gallery.static.cards-3 .grid-gallery-card:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .grid-gallery.static.cards-3 .grid-gallery-card:nth-child(3) {
        grid-column: 1 / span 2;
        grid-row: 2;
    }

    .grid-gallery.static.cards-4 .grid-gallery-card:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    .grid-gallery.static.cards-4 .grid-gallery-card:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .grid-gallery.static.cards-4 .grid-gallery-card:nth-child(3) {
        grid-column: 1;
        grid-row: 2;
    }

    .grid-gallery.static.cards-4 .grid-gallery-card:nth-child(4) {
        grid-column: 2;
        grid-row: 2;
    }

    .grid-gallery.static.cards-5 .grid-gallery-card:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    .grid-gallery.static.cards-5 .grid-gallery-card:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .grid-gallery.static.cards-5 .grid-gallery-card:nth-child(3) {
        grid-column: 1;
        grid-row: 2;
    }

    .grid-gallery.static.cards-5 .grid-gallery-card:nth-child(4) {
        grid-column: 2;
        grid-row: 2;
    }

    .grid-gallery.static.cards-5 .grid-gallery-card:nth-child(5) {
        grid-column: 1 / span 2;
        grid-row: 3;
    }

    .grid-gallery-modal-content-wrapper {
        gap: 16px;
        padding: 0 16px;
    }

    .grid-gallery-modal .horizontal-content-media-video-wrapper {
        height: 100%;
        width: 100%;
    }

    .grid-gallery-modal .horizontal-content-media-video-wrapper iframe {
        height: 100%;
        width: 100%;
        object-fit: contain;
    }

    .grid-gallery-modal .horizontal-content-media-video-wrapper video {
        height: 100%;
        width: 100%;
        object-fit: contain;
    }

    .grid-gallery-modal-description-sub-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
        overflow-y: auto !important;
        max-height: 30vh;
        min-height: 30vh;
        scrollbar-width: thin;
        scrollbar-color: #5d5d5c #e0e0e0;
        -webkit-overflow-scrolling: touch;
    }

    .grid-gallery-modal-legal-container {
        margin-top: 16px;
        position: relative;
        z-index: 1;
    }

    .grid-gallery-container {
        padding: 32px 40px;
        display: grid;
    }

    .grid-gallery-modal-desktop {
        display: flex;
        gap: 1rem;
    }

    .grid-gallery-modal-desktop .grid-gallery-modal-description-sub-content {
        flex: 1;
    }

    .grid-gallery-modal-description-sub {
        gap: 24px;
        padding: 0 16px;
    }

    .grid-gallery-modal-prev,
    .grid-gallery-modal-next {
        width: 40px;
        height: 40px;
    }

    .grid-gallery-modal .grid-gallery-media {
        height: 100%;
        width: 100%;
        background: #000;
    }

    .grid-gallery-modal .grid-gallery-media img {
        height: 100%;
        width: 100%;
        object-fit: contain;
        max-width: none;
        max-height: none;
    }
}

@media (max-width: 767px) {
    .grid-gallery-modal {
       padding: 0;
        justify-content: flex-start;
        align-items: flex-start;
        background: rgba(255 255 255 / 90%) !important;
    }

    .grid-legal-text-link {
        padding-top: 16px;
    }

    .grid-gallery-media img {
        width: 100% !important;
    }

    .grid-legal-content.expanded {
        max-height: unset;
        min-height: 300px;
    }

    .grid-gallery-modal-content {
        max-width: 100vw;
        max-height: 100vh;
        width: 100vw;
        height: 100vh;
        min-width: 100vw;
        min-height: 100vh;
        background: rgba(255 255 255 / 90%) !important;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .grid-gallery-modal-carousel {
        height: 100vh;
        width: 100%;
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        background-color: #fff;
    }

    .grid-gallery-modal-content-wrapper {
        gap: 12px;
    }

    .grid-gallery-modal-track {
        height: auto;
        flex: 0 0 auto;
        min-height: auto;
        max-height: 100%;
        width: 100%;
        background: #000;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        touch-action: auto;
        overscroll-behavior: auto;
        aspect-ratio: 3 / 2;
    }

    /* CHANGE: Ensure modal media fills the track properly */
    .grid-gallery-modal-track .grid-gallery-media {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #000;
    }

    /* CHANGE: Make images responsive while maintaining aspect ratio */
    .grid-gallery-modal-track .grid-gallery-media img {
        width: 100%;
        object-fit: contain;
        max-width: 100%;
        max-height: 100%;
    }

    /* CHANGE: Ensure videos and iframes also fit properly */
    .grid-gallery-modal .horizontal-content-media-video-wrapper {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    .grid-gallery-modal .horizontal-content-media-video-wrapper video,
    .grid-gallery-modal .horizontal-content-media-video-wrapper iframe {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .grid-gallery-modal-description {
        padding: 16px;
        height: auto;
        flex: 0 0 auto;
        min-height: auto;
        max-height: 100%;
        position: relative;
        z-index: 10;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .grid-gallery-modal-description-sub-content {
        width: 100%;
        min-height: 0;
        max-height: 100%;
        flex: 1;
        padding: 0;
        gap: 0;
        overflow: hidden auto !important;
        scrollbar-width: thin;
        scrollbar-color: #5d5d5c #e0e0e0;
        overscroll-behavior: contain;
        touch-action: pan-y;
        -webkit-overflow-scrolling: auto;
        position: relative;
        isolation: isolate;
    }

    /* CHANGE: Fix close button positioning and visibility */
    .grid-gallery-modal-close {
        position: absolute;
        display: flex;
        align-items: center;
        justify-content: center;
        top: 12px;
        right: 12px;
        background: rgba(0 0 0 / 80%);
        border: none;
        cursor: pointer;
        z-index: 1002;
        padding: 8px;
        gap: 8px;
        width: 40px;
        height: 40px;
        border-radius: 4px;
        flex-shrink: 0;
    }

    .grid-gallery-modal-close .icon-close-light {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        color: #fff;
        stroke: #fff;
        stroke-width: 1.8px;
        width: 20px;
        height: 20px;
    }

    .grid-gallery-modal-text {
        font-size: 16px;
        line-height: 22px;
    }

    .grid-gallery-media picture {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .grid-gallery-card .video-controls .icon-video-play-circle {
        width: 32px;
        height: 32px;
        font-size: 32px;
    }

    .grid-gallery-modal .video-controls .icon-video-play-circle {
        width: 48px;
        height: 48px;
        font-size: 48px;
    }

    .grid-gallery.static {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        padding: 0; /* optional padding */
    }

    .grid-gallery.static .grid-gallery-card {
        width: 100% !important;
        height: 263.846px !important;
    }

    .grid-gallery-container {
        padding: 24px 16px;
        display: grid;
    }

    .grid-gallery-modal-mobile {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 16px;
        align-self: stretch;
        height: 100%;
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }

    .grid-gallery-modal-description-sub {
        gap: 16px;
        padding: 24px 16px 0;
        height: auto;
        flex: 1;
        flex-direction: column;
        align-items: center;
        align-self: stretch;
        overflow: hidden;
        display: flex;
    }

    .grid-gallery-modal-prev,
    .grid-gallery-modal-next {
        width: 48px;
        height: 48px;
        font-size: 24px;
        background: rgba(255 255 255 / 80%);
        position: relative;
        z-index: 200;
    }

    .grid-gallery-carousel .grid-gallery-card,
    .grid-gallery.static .grid-gallery-card {
        height: 263.846px !important;
    }
}

.grid-gallery-media:has(video),
.grid-gallery-media:has(iframe),
.grid-gallery-media:has(.horizontal-content-media-video-wrapper) {
    height: 100% !important;
}

.grid-gallery-card:not(.grid-gallery-modal *) .video-controls {
    pointer-events: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-gallery-card:not(.grid-gallery-modal *) {
    cursor: pointer;
}

