/* =========================================
   HERO SLIDER CORE
   ========================================= */

.gn-hero-slider {
    position: relative;
    width: 100%;
    min-height: 400px;
    max-height: 900px;
    overflow: hidden;
    background: transparent;
}

/* Keep desktop data-height feature */
@media (min-width: 1200px) {
    .gn-hero-slider[data-height="300"] {
        height: 300px;
    }

    .gn-hero-slider[data-height="310"] {
        height: 310px;
    }

    .gn-hero-slider[data-height="320"] {
        height: 320px;
    }

    .gn-hero-slider[data-height="330"] {
        height: 330px;
    }

    .gn-hero-slider[data-height="340"] {
        height: 340px;
    }

    .gn-hero-slider[data-height="350"] {
        height: 350px;
    }

    .gn-hero-slider[data-height="360"] {
        height: 360px;
    }

    .gn-hero-slider[data-height="370"] {
        height: 370px;
    }

    .gn-hero-slider[data-height="380"] {
        height: 380px;
    }

    .gn-hero-slider[data-height="390"] {
        height: 390px;
    }

    .gn-hero-slider[data-height="400"] {
        height: 400px;
    }

    .gn-hero-slider[data-height="410"] {
        height: 410px;
    }

    .gn-hero-slider[data-height="420"] {
        height: 420px;
    }

    .gn-hero-slider[data-height="430"] {
        height: 430px;
    }

    .gn-hero-slider[data-height="440"] {
        height: 440px;
    }

    .gn-hero-slider[data-height="450"] {
        height: 450px;
    }

    .gn-hero-slider[data-height="460"] {
        height: 460px;
    }

    .gn-hero-slider[data-height="470"] {
        height: 470px;
    }

    .gn-hero-slider[data-height="480"] {
        height: 480px;
    }

    .gn-hero-slider[data-height="490"] {
        height: 490px;
    }

    .gn-hero-slider[data-height="500"] {
        height: 500px;
    }

    .gn-hero-slider[data-height="510"] {
        height: 510px;
    }

    .gn-hero-slider[data-height="520"] {
        height: 520px;
    }

    .gn-hero-slider[data-height="530"] {
        height: 530px;
    }

    .gn-hero-slider[data-height="540"] {
        height: 540px;
    }

    .gn-hero-slider[data-height="550"] {
        height: 550px;
    }

    .gn-hero-slider[data-height="560"] {
        height: 560px;
    }

    .gn-hero-slider[data-height="570"] {
        height: 570px;
    }

    .gn-hero-slider[data-height="580"] {
        height: 580px;
    }

    .gn-hero-slider[data-height="590"] {
        height: 590px;
    }

    .gn-hero-slider[data-height="600"] {
        height: 600px;
    }

    .gn-hero-slider[data-height="610"] {
        height: 610px;
    }

    .gn-hero-slider[data-height="620"] {
        height: 620px;
    }

    .gn-hero-slider[data-height="630"] {
        height: 630px;
    }

    .gn-hero-slider[data-height="640"] {
        height: 640px;
    }

    .gn-hero-slider[data-height="650"] {
        height: 650px;
    }

    .gn-hero-slider[data-height="660"] {
        height: 660px;
    }

    .gn-hero-slider[data-height="670"] {
        height: 670px;
    }

    .gn-hero-slider[data-height="680"] {
        height: 680px;
    }

    .gn-hero-slider[data-height="690"] {
        height: 690px;
    }

    .gn-hero-slider[data-height="700"] {
        height: 700px;
    }

    .gn-hero-slider[data-height="710"] {
        height: 710px;
    }

    .gn-hero-slider[data-height="720"] {
        height: 720px;
    }

    .gn-hero-slider[data-height="730"] {
        height: 730px;
    }

    .gn-hero-slider[data-height="740"] {
        height: 740px;
    }

    .gn-hero-slider[data-height="750"] {
        height: 750px;
    }

    .gn-hero-slider[data-height="760"] {
        height: 760px;
    }

    .gn-hero-slider[data-height="770"] {
        height: 770px;
    }

    .gn-hero-slider[data-height="780"] {
        height: 780px;
    }

    .gn-hero-slider[data-height="790"] {
        height: 790px;
    }

    .gn-hero-slider[data-height="800"] {
        height: 800px;
    }

    .gn-hero-slider[data-height="810"] {
        height: 810px;
    }

    .gn-hero-slider[data-height="820"] {
        height: 820px;
    }

    .gn-hero-slider[data-height="830"] {
        height: 830px;
    }

    .gn-hero-slider[data-height="840"] {
        height: 840px;
    }

    .gn-hero-slider[data-height="850"] {
        height: 850px;
    }

    .gn-hero-slider[data-height="860"] {
        height: 860px;
    }

    .gn-hero-slider[data-height="870"] {
        height: 870px;
    }

    .gn-hero-slider[data-height="880"] {
        height: 880px;
    }

    .gn-hero-slider[data-height="890"] {
        height: 890px;
    }

    .gn-hero-slider[data-height="900"] {
        height: 900px;
    }
}

.gn-hero-slides {
    position: relative;
    width: 100%;
    height: 100%;
}

/* =========================================
   SLIDE TRANSITIONS
   ========================================= */

.gn-hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(1.02);
    transition: opacity .6s cubic-bezier(.25, .46, .45, .94), transform .6s cubic-bezier(.25, .46, .45, .94);
    z-index: 1;
    pointer-events: none;
}

.gn-hero-slide.active {
    opacity: 1;
    transform: scale(1);
    z-index: 3;
    pointer-events: auto;
}

/* Disable transitions during initialization to prevent layout shift */
.gn-hero-slider.gn-hero-loading .gn-hero-slide,
.gn-hero-slider.gn-hero-loading .gn-hero-slides,
.gn-hero-slider.gn-hero-loading .gn-hero-inner,
.gn-hero-slider.gn-hero-loading .gn-hero-bg {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
}

/* Reduced motion support (accessibility) */
@media (prefers-reduced-motion: reduce) {

    .gn-hero-slide,
    .gn-hero-bg,
    .gn-hero-inner,
    .gn-hero-title a {
        transition: none !important;
        transform: none !important;
    }
}

/* =========================================
   LAYOUT & ITEMS
   ========================================= */

.gn-hero-row {
    display: flex;
    width: 100%;
    height: 100%;
    flex-wrap: nowrap;
}

.gn-hero-item {
    position: relative;
    height: 100%;
    overflow: hidden;
    min-width: 0;
    --gn-hero-scale: 1;
}

/* Default flex layouts */
.gn-hero-layout-1 .gn-hero-item {
    flex: 0 0 100%;
    max-width: 100%;
}

.gn-hero-layout-2 .gn-hero-item {
    flex: 0 0 50%;
    max-width: 50%;
    --gn-hero-scale: .90;
}

.gn-hero-layout-3 .gn-hero-item {
    flex: 0 0 33.3333%;
    max-width: 33.3333%;
    --gn-hero-scale: .88;
}

.gn-hero-layout-4 .gn-hero-item {
    flex: 0 0 25%;
    max-width: 25%;
    --gn-hero-scale: .86;
}

/* =========================================
   ITEM CONTENT
   ========================================= */

.gn-hero-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    transition: transform .6s ease;
}

.gn-hero-item:hover .gn-hero-bg {
    transform: scale(1.03);
}

.gn-hero-img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center;
}

.gn-hero-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .3) 50%, rgba(0, 0, 0, .85) 100%);
    will-change: opacity;
    backface-visibility: hidden;
    transition: opacity .3s ease;
}

.gn-hero-item:hover .gn-hero-overlay {
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .4) 50%, rgba(0, 0, 0, .95) 100%);
}

.gn-hero-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 10px 25px;
    z-index: 11;
    pointer-events: none;
}

.gn-hero-inner {
    width: 100%;
    color: #fff;
    transform: translateY(0);
    transition: transform .4s ease;
    pointer-events: none;
    /* Let overlay link handle interaction */
}

.gn-hero-item:hover .gn-hero-inner {
    transform: translateY(-5px);
}

.gn-hero-cat {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 12;
    display: inline-block;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
    color: #fff !important;
    text-decoration: none;
    background-color: #45278e;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
    transition: transform .3s ease, box-shadow .3s ease;
    pointer-events: auto;
}

.gn-hero-cat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

.gn-hero-overlay-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    cursor: pointer;
    display: block;
    pointer-events: auto !important;
}

/* --- Responsive typography (big + small tiles) --- */
.gn-hero-title {
    /* Base fluid title size */
    font-size: calc(clamp(15px, 1.05vw + 12px, 22px) * var(--gn-hero-scale));
    line-height: 1.25;
    font-weight: 700;
    margin: 0 0 10px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}

.gn-hero-title a {
    color: #fff;
    text-decoration: none;
    background-image: linear-gradient(to right, #fff 0%, #fff 100%);
    background-size: 0% 2px;
    background-repeat: no-repeat;
    background-position: left bottom;
    transition: background-size .3s ease;
    padding-bottom: 2px;
}

:dir(rtl) .gn-hero-title a {
    background-image: linear-gradient(to left, #fff 0%, #fff 100%);
    background-position: right bottom;
}

.gn-hero-item:hover .gn-hero-title a {
    background-size: 100% 2px;
}

.gn-hero-meta {
    font-size: calc(clamp(10px, 0.35vw + 10px, 12px) * var(--gn-hero-scale));
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, .8);
    font-weight: 500;
}

.gn-hero-excerpt {
    font-size: calc(clamp(11px, 0.35vw + 11px, 13px) * var(--gn-hero-scale));
    line-height: 1.6;
    color: rgba(255, 255, 255, .85);
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0;
    max-height: 0;
    transition: all .6s ease;
}

.gn-hero-item:hover .gn-hero-excerpt {
    opacity: 1;
    max-height: 100px;
}

/* Extra scaling for known small-tile contexts (style-2, style-3) */
.gn-hero-style-2 .gn-hero-item:nth-child(n+2) {
    --gn-hero-scale: .78;
}

.gn-hero-style-3 .gn-hero-small-grid .gn-hero-item {
    --gn-hero-scale: .78;
}

/* =========================================
   CONTROLS
   ========================================= */

.gn-hero-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: transparent;
    font-size: 46px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .2s ease, opacity .2s ease;
    z-index: 20;
    opacity: 0;
}

.gn-hero-slider:hover .gn-hero-nav {
    opacity: 1;
}

.gn-hero-nav:hover {
    transform: translateY(-50%) scale(1.06);
}

.gn-hero-prev {
    left: 20px;
}

.gn-hero-next {
    right: 20px;
}

.gn-hero-dots {
    position: absolute;
    left: 50%;
    bottom: 25px;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.gn-hero-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .4);
    cursor: pointer;
    transition: all .3s cubic-bezier(.25, .46, .45, .94);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.gn-hero-dot.active {
    width: 30px;
    border-radius: 4px;
    background: #fff;
}

/* =========================================
   STYLE 2: MOSAIC GRID (desktop)
   ========================================= */

.gn-hero-style-2 .gn-hero-slide,
.gn-hero-style-2 .gn-hero-slides {
    height: 100%;
}

.gn-hero-style-2 .gn-hero-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: var(--gn-hero-gap, 0);
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.gn-hero-style-2 .gn-hero-item {
    flex: none;
    width: auto;
    max-width: none;
    margin: 0;
}

.gn-hero-style-2 .gn-hero-item:nth-child(1) {
    grid-column: 1 / 3;
    grid-row: 1 / 3;
}

.gn-hero-style-2 .gn-hero-item:nth-child(2) {
    grid-column: 3 / 5;
    grid-row: 1 / 2;
}

.gn-hero-style-2 .gn-hero-item:nth-child(3) {
    grid-column: 3 / 4;
    grid-row: 2 / 3;
}

.gn-hero-style-2 .gn-hero-item:nth-child(4) {
    grid-column: 4 / 5;
    grid-row: 2 / 3;
}

/* =========================================
   STYLE 3: MAGAZINE (desktop)
   ========================================= */

.gn-hero-style-3 .gn-hero-slide,
.gn-hero-style-3 .gn-hero-slides {
    height: 100%;
}

.gn-hero-style-3 .gn-hero-row {
    display: flex;
    gap: var(--gn-hero-gap, 0);
    height: 100%;
    width: 100%;
}

.gn-hero-style-3 .gn-hero-big-col {
    flex: 0 0 54%;
    height: 100%;
    min-width: 0;
}

.gn-hero-style-3 .gn-hero-big-col .gn-hero-item {
    height: 100%;
    margin: 0;
    --gn-hero-scale: 1;
}

/* Big tile shows excerpt by default */
.gn-hero-style-3 .gn-hero-big-col .gn-hero-excerpt {
    opacity: 1;
    max-height: 100px;
}

.gn-hero-style-3 .gn-hero-small-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: var(--gn-hero-gap, 0);
    height: 100%;
    min-width: 0;
}

.gn-hero-style-3 .gn-hero-small-grid .gn-hero-item {
    height: 100%;
    margin: 0;
    flex: none;
    width: auto;
    max-width: none;
}

/* =========================================
   RESPONSIVE (matches your JS)
   JS forces:
     <=1024: height=500, viewItems=3 (style-1 only)
     <=600 : height=250, viewItems=2 (style-1 only)
   ========================================= */

@media (max-width: 1024px) {
    .gn-hero-nav {
        opacity: 1;
        width: 36px;
        height: 36px;
        font-size: 34px;
    }

    .gn-hero-prev {
        left: 10px;
    }

    .gn-hero-next {
        right: 10px;
    }

    .gn-hero-content {
        padding: 10px 16px;
    }

    /* Style-2: 2x2 Grid at 1024px */
    .gn-hero-style-2 .gn-hero-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: repeat(2, minmax(0, 1fr));
        gap: var(--gn-hero-gap, 10px);
    }

    .gn-hero-style-2 .gn-hero-item:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    .gn-hero-style-2 .gn-hero-item:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .gn-hero-style-2 .gn-hero-item:nth-child(3) {
        grid-column: 1;
        grid-row: 2;
    }

    .gn-hero-style-2 .gn-hero-item:nth-child(4) {
        grid-column: 2;
        grid-row: 2;
    }

    .gn-hero-style-2 .gn-hero-item {
        height: 250px !important;
        display: block !important;
    }

    .gn-hero-style-2.gn-hero-slider,
    .gn-hero-style-2 .gn-hero-slides,
    .gn-hero-style-2 .gn-hero-slide {
        height: auto !important;
        max-height: 500px !important;
    }
}

/* New Tablet Tier: Style 3 Stacking at 768px */
@media (max-width: 768px) {
    .gn-hero-style-3 .gn-hero-row {
        flex-direction: column !important;
        gap: var(--gn-hero-gap, 4px) !important;
    }

    .gn-hero-style-3 .gn-hero-big-col {
        flex: 0 0 auto !important;
        width: 100% !important;
        height: 250px !important;
    }

    .gn-hero-style-3 .gn-hero-small-grid {
        flex: 0 0 auto !important;
        width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        grid-template-rows: repeat(2, minmax(0, 1fr)) !important;
        gap: var(--gn-hero-gap, 4px) !important;
        height: 304px !important;
    }

    .gn-hero-style-3 .gn-hero-small-grid .gn-hero-item {
        display: block !important;
        height: 150px !important;
    }

    .gn-hero-style-3.gn-hero-slider,
    .gn-hero-style-3 .gn-hero-slides,
    .gn-hero-style-3 .gn-hero-slide {
        height: auto !important;
        min-height: 558px !important;
    }

    .gn-hero-content {
        padding: 10px 40px !important;
    }

    .gn-hero-nav {
        width: 32px !important;
        height: 32px !important;
        font-size: 28px !important;
    }
}

@media (max-width: 600px) {
    .gn-hero-slider {
        height: 250px !important;
        min-height: 0 !important;
        max-height: none !important;
    }

    .gn-hero-slides,
    .gn-hero-slide {
        height: 100% !important;
    }

    .gn-hero-content {
        padding: 6px 10px !important;
    }

    .gn-hero-meta span:not(.gn-hero-date) {
        display: none !important;
    }

    .gn-hero-cat {
        top: 6px !important;
        left: 6px !important;
        padding: 2px 6px !important;
        font-size: 8px !important;
    }

    .gn-hero-dots {
        bottom: 5px !important;
    }

    .gn-hero-dot {
        width: 6px;
        height: 6px;
    }

    .gn-hero-dot.active {
        width: 18px;
    }

    .gn-hero-nav {
        opacity: 1 !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 24px !important;
    }

    /* Style-2 & Style-3: Shared Responsive Grid Logic */
    .gn-hero-style-2 .gn-hero-row,
    .gn-hero-style-3 .gn-hero-row {
        flex-direction: column !important;
        display: flex !important;
        gap: var(--gn-hero-gap, 4px) !important;
        height: auto !important;
    }

    /* All items visible, no more display:none */
    .gn-hero-style-2 .gn-hero-item,
    .gn-hero-style-3 .gn-hero-item {
        display: block !important;
    }

    /* Layout stacking */
    .gn-hero-style-2 .gn-hero-item:nth-child(1),
    .gn-hero-style-3 .gn-hero-big-col {
        flex: 0 0 auto !important;
        width: 100% !important;
        height: 230px !important;
    }

    /* Shared Small Grid behavior */
    .gn-hero-style-2 .gn-hero-item:nth-child(n+2),
    .gn-hero-style-3 .gn-hero-small-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: var(--gn-hero-gap, 4px) !important;
    }

    /* Style 2 specific items in grid */
    .gn-hero-style-2 .gn-hero-row {
        display: flex !important;
    }

    .gn-hero-style-2 .gn-hero-item:nth-child(n+2) {
        flex: 0 0 auto !important;
        width: 100% !important;
        /* Turn the rest into a grid wrapper if needed, but easier to just use flex */
    }

    /* Re-stabilizing Style-2 specific logic for 4 items */
    .gn-hero-style-2 .gn-hero-row {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        grid-template-rows: auto auto !important;
    }

    .gn-hero-style-2 .gn-hero-item:nth-child(1) {
        grid-column: 1 / 3 !important;
        height: 230px !important;
    }

    .gn-hero-style-2 .gn-hero-item:nth-child(n+2) {
        grid-column: auto !important;
        height: 150px !important;
    }

    /* Ensure wrappers don't collapse but stay tight */
    .gn-hero-style-2.gn-hero-slider,
    .gn-hero-style-2 .gn-hero-slides {
        height: auto !important;
        min-height: 380px !important;
    }

    .gn-hero-style-3.gn-hero-slider,
    .gn-hero-style-3 .gn-hero-slides {
        height: auto !important;
        min-height: 530px !important;
    }
}

/* =========================================
   EDITOR PREVIEW IMPROVEMENTS
   ========================================= */

.gn-hero-slider-editor-wrapper {
    max-height: 800px !important;
    overflow-y: auto !important;
    border: 1px dashed #ccc;
    background: #f9f9f9;
    padding: 10px;
}

.gn-hero-slider-editor-wrapper .gn-hero-slider {
    overflow: hidden !important;
    max-height: 600px !important;
    height: auto !important;
    min-height: 400px !important;
}

.gn-hero-slider-editor-wrapper .gn-hero-slide {
    position: relative !important;
    width: 100% !important;
    height: 450px !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    margin-bottom: 20px;
    transform: none !important;
}

.gn-hero-slider-editor-wrapper .gn-hero-slide:not(:first-child) {
    display: none !important;
}

.gn-hero-slider-editor-wrapper .gn-hero-nav,
.gn-hero-slider-editor-wrapper .gn-hero-dots {
    display: none !important;
}