.sgg-main-container {
    padding: 0;
}

.sgg-gallery {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    /* Standard gap for desktop */
    padding: 20px 0;
    margin-bottom: 30px;
}

/* -- Styling for overskrifter -- */
.sgg-section-header {
    width: 100%;
    text-align: center;
    margin-top: 30px;
    margin-bottom: 15px;
}

.sgg-section-title {
    /* Hovedtittel */
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 700;
}

.sgg-section-separator {
    /* Skillelinje */
    border: 0;
    margin: 8px auto 8px auto;
    /* Vertikal og horisontal sentrering */
    width: 100px;
    /* Standard bredde */
    max-width: 80%;
}

.sgg-section-subtitle {
    /* Undertittel */
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 400;
    /* Litt lettere */
}


/* ---------------------------------- */
/* Basis Layout og Desktop */
/* ---------------------------------- */
.sgg-gallery {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--sgg-gap, 40px);
    padding: 20px 0;
    margin-bottom: 30px;
    /* Standard kolonne antall for desktop hvis ikke overstyrt av PHP */
    --sgg-cols: var(--sgg-cols-desktop, 5);
}

/* ---------------------------------- */
/* Layout: Carousel */
/* ---------------------------------- */
.sgg-layout-carousel {
    scroll-behavior: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.sgg-layout-carousel::-webkit-scrollbar {
    height: 8px;
}

.sgg-layout-carousel::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

.sgg-layout-carousel .sgg-track {
    margin-inline: auto;
}

@supports (width: 100cqi) {
    .sgg-layout-carousel .sgg-track {
        --sgg-track-logo-width: 100cqi;
        --sgg-track-image-width: 100%;
    }
}

.sgg-carousel-controls {
    gap: 0.375rem;
}

.sgg-carousel-controls button {
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem 0.375rem;
}

.sgg-carousel-controls [aria-disabled="true"] {
    opacity: 0.5;
    cursor: default;
}

.sgg-carousel-controls:dir(rtl) button span {
    display: inline-block;
    transform: scaleX(-1);
}

/* ---------------------------------- */
/* Layout: Ticker (Infinite Scroll) */
/* ---------------------------------- */
:is(.sgg-layout-carousel, .sgg-layout-ticker) {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    position: relative;
    padding-bottom: 15px;
    overscroll-behavior-x: contain;
    container-type: inline-size;
}

.sgg-layout-ticker {
    padding-bottom: 20px;
}

.sgg-layout-ticker:not([data-sgg-running]) {
    scroll-snap-type: x proximity;
}

.sgg-layout-ticker:not([data-sgg-running]) .sgg-track {
    margin-inline: auto;
}

:is(.sgg-layout-carousel, .sgg-layout-ticker) .sgg-track,
.sgg-ticker-items {
    display: flex;
    flex: none;
    gap: var(--sgg-gap, 40px);
    width: max-content;
}

:is(.sgg-carousel-controls, .sgg-ticker-controls) {
    display: flex;
    justify-content: flex-end;
}

:is(.sgg-carousel-controls, .sgg-ticker-controls) button {
    min-inline-size: 44px;
    min-block-size: 44px;
    margin-block-end: 0.5rem;
    touch-action: manipulation;
    cursor: pointer;
}

.sgg-ticker-controls button {
    padding: 0.4em 0.85em;
}

.sgg-carousel-controls[hidden],
.sgg-ticker-controls [hidden],
.sgg-ticker-copy {
    display: none;
}

.sgg-main-container a:focus-visible,
.sgg-layout-carousel:focus-visible,
:is(.sgg-carousel-controls, .sgg-ticker-controls) button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

@media (prefers-reduced-motion: no-preference) {
    .sgg-layout-ticker[data-sgg-running]:not(:focus-within) {
        overflow-x: hidden;
    }

    .sgg-layout-ticker[data-sgg-running]:not(:focus-within) .sgg-track {
        animation: sggTickerScroll var(--sgg-ticker-speed, 30s) linear infinite;
        animation-duration: max(var(--sgg-ticker-speed, 30s), var(--sgg-ticker-min-duration, 0s));
    }

    .sgg-layout-ticker[data-sgg-running]:not(:focus-within) .sgg-ticker-copy {
        display: flex;
    }

    .sgg-layout-ticker[data-sgg-paused] .sgg-track {
        animation-play-state: paused !important;
    }
}

@media (hover: hover) {
    .sgg-layout-ticker:hover .sgg-track {
        animation-play-state: paused !important;
    }
}

:is(.sgg-layout-carousel, .sgg-layout-ticker) .sgg-logo-wrapper {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 0;
    max-width: var(--sgg-track-logo-width, none) !important;
    height: var(--sgg-track-logo-height, var(--sgg-logo-max-width, 100px)) !important;
    min-height: 0 !important;
    aspect-ratio: auto !important;
    scroll-snap-align: start;
}

:is(.sgg-layout-carousel, .sgg-layout-ticker) .sgg-logo-wrapper a,
:is(.sgg-layout-carousel, .sgg-layout-ticker) .sgg-logo-wrapper .sgg-no-link {
    width: auto !important;
    min-width: 0;
    max-width: var(--sgg-track-image-width, none);
    height: 100% !important;
}

:is(.sgg-layout-carousel, .sgg-layout-ticker) .sgg-logo {
    height: 100% !important;
    width: auto !important;
    min-width: 0;
    max-height: 100% !important;
    max-width: var(--sgg-track-image-width, none) !important;
    object-fit: contain;
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    :is(.sgg-layout-carousel, .sgg-layout-ticker) .sgg-track {
        --sgg-track-logo-height: clamp(44px, var(--sgg-logo-max-width, 100px), 88px);
        --sgg-track-logo-width: min(64vw, 208px);
        --sgg-track-image-width: 100%;
    }
}

@container (max-width: 580px) {
    :is(.sgg-layout-carousel, .sgg-layout-ticker) .sgg-track {
        --sgg-track-logo-height: clamp(44px, var(--sgg-logo-max-width, 100px), 88px);
        --sgg-track-logo-width: min(64cqi, 208px);
        --sgg-track-image-width: 100%;
    }
}

.sgg-layout-ticker:dir(rtl) {
    --sgg-ticker-direction: -1;
}

@keyframes sggTickerScroll {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(calc((-50% - (var(--sgg-gap, 40px) / 2)) * var(--sgg-ticker-direction, 1)));
    }
}

.sgg-logo-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--sgg-logo-padding, 5px);
    aspect-ratio: 3 / 2;
    /* Allows height to grow when width grows */
    height: auto;
    min-height: 80px;
    box-sizing: border-box;

    /* Dynamisk bredde: (100% - totalt gap) / antall kolonner */
    width: calc((100% - ((var(--sgg-cols) - 1) * var(--sgg-gap, 40px))) / var(--sgg-cols)) !important;
    max-width: var(--sgg-logo-max-width, 200px) !important;
}

.sgg-logo-wrapper a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.sgg-logo {
    max-height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;

    --current-grayscale: 0%;
    --current-saturate: 100%;
    --current-blur: 0px;
    --current-opacity: 1;

    opacity: var(--hover-opacity, var(--current-opacity));
    filter: grayscale(var(--hover-grayscale, var(--current-grayscale))) saturate(var(--hover-saturate, var(--current-saturate))) blur(var(--hover-blur, var(--current-blur)));
    transform: scale(var(--hover-scale, 1));

    transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.sgg-logo-wrapper:hover .sgg-logo {
    --hover-grayscale: 0%;
    --hover-saturate: 100%;
    --hover-blur: 0px;
    --hover-opacity: 1;
    --hover-scale: var(--sgg-hover-scale, 1.05);
}

/* ---------------------------------- */
/* Dynamiske Effekter */
/* ---------------------------------- */

.sgg-effect-grayscale .sgg-logo {
    --current-grayscale: var(--sgg-base-grayscale, 100%);
}

.sgg-effect-desaturated .sgg-logo {
    --current-saturate: var(--sgg-base-desaturate, 70%);
}

.sgg-effect-transparent .sgg-logo {
    --current-opacity: var(--sgg-base-opacity, 0.7);
}

.sgg-effect-blurry .sgg-logo {
    --current-blur: var(--sgg-base-blur, 1px);
}

/* Skru av hover-effekter på touch-enheter (hvis aktivert i innstillinger) */
@media (hover: none) and (pointer: coarse) {
    .sgg-disable-hover-touch .sgg-logo-wrapper:hover .sgg-logo {
        --hover-grayscale: var(--current-grayscale);
        --hover-saturate: var(--current-saturate);
        --hover-blur: var(--current-blur);
        --hover-opacity: var(--current-opacity);
        --hover-scale: 1;
    }
}

/* ---------------------------------- */
/* Scroll Animations */
/* ---------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    .sgg-animate:focus-within {
        animation: none !important;
    }

    /* Fade In */
    .sgg-animate-fade-in.sgg-animated {
        animation: sggFadeIn 0.8s ease both;
        animation-delay: var(--sgg-delay, 0s);
    }

    @keyframes sggFadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    /* Blur In */
    .sgg-animate-blur-in.sgg-animated {
        animation: sggBlurIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
        animation-delay: var(--sgg-delay, 0s);
    }

    @keyframes sggBlurIn {
        from {
            opacity: 0;
            filter: blur(8px);
        }

        to {
            opacity: 1;
            filter: blur(0);
        }
    }

    /* Slide Up */
    .sgg-animate-slide-up.sgg-animated {
        animation: sggSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
        animation-delay: var(--sgg-delay, 0s);
    }

    @keyframes sggSlideUp {
        from {
            opacity: 0;
            transform: translateY(30px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Zoom In */
    .sgg-animate-zoom-in.sgg-animated {
        animation: sggZoomIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
        animation-delay: var(--sgg-delay, 0s);
    }

    @keyframes sggZoomIn {
        from {
            opacity: 0;
            transform: scale(0.85);
        }

        to {
            opacity: 1;
            transform: scale(1);
        }
    }

    /* Flip In */
    .sgg-animate-flip-in.sgg-animated {
        animation: sggFlipIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
        animation-delay: var(--sgg-delay, 0s);
    }

    @keyframes sggFlipIn {
        from {
            opacity: 0;
            transform: perspective(400px) rotateX(90deg);
        }

        to {
            opacity: 1;
            transform: perspective(400px) rotateX(0deg);
        }
    }

}

/* ---------------------------------- */
/* Tablet Responsivitet (769px til 1024px) */
/* ---------------------------------- */
@media (min-width: 769px) and (max-width: 1024px) {
    .sgg-gallery {
        --sgg-gap: 20px;
        --sgg-cols: var(--sgg-cols-tablet, 4);
    }

    /* aspect-ratio håndterer skalering automatisk nå */

    .sgg-section-title {
        font-size: 1.6rem;
    }

    .sgg-section-subtitle {
        font-size: 1rem;
    }
}

/* ---------------------------------- */
/* Mobil Responsivitet (under 768px) */
/* ---------------------------------- */
@media (max-width: 768px) {
    .sgg-gallery {
        --sgg-gap: 15px;
        --sgg-cols: var(--sgg-cols-mobile, 2);
        padding: 15px 0;
    }

    /* aspect-ratio håndterer skalering automatisk nå */

    .sgg-section-title {
        font-size: 1.4rem;
    }

    .sgg-section-subtitle {
        font-size: 0.9rem;
        margin-top: 5px;
    }

    .sgg-section-separator {
        margin: 5px auto 5px auto;
    }
}
@media (prefers-reduced-motion: reduce) {
    .sgg-main-container .sgg-logo {
        transform: none;
        transition: none;
    }
}

.sgg-layout-featured {
    box-sizing: border-box;
    padding: clamp(1rem, 4vw, 2rem);
    gap: clamp(0.875rem, 3vw, 1.75rem);
    border: 1px solid rgb(127 127 127 / 25%);
    border-radius: 0.75rem;
    background: rgb(127 127 127 / 7%);
}

.sgg-layout-featured:not(:has(.sgg-logo-wrapper)) {
    display: none;
}

.sgg-layout-featured .sgg-logo-wrapper {
    width: clamp(11rem, 40%, 22rem) !important;
    max-width: 100% !important;
    min-height: 6rem;
    aspect-ratio: 5 / 2;
}

.sgg-layout-featured .sgg-logo-wrapper:only-child {
    width: min(100%, 27rem) !important;
}

.sgg-card-trigger {
    position: relative;
}

.sgg-card-indicator {
    position: absolute;
    inset-block-start: 0;
    inset-inline-end: 0;
    display: grid;
    place-items: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    color: #fff;
    background: #273544;
    opacity: 0.5;
    font: 700 0.8rem/1 system-ui, sans-serif;
    z-index: 1;
}

.sgg-gallery[data-sgg-card-dark-background] .sgg-card-indicator {
    color: #273544;
    background: #fff;
}

.sgg-sponsor-dialog:not([open]):not(:target) {
    display: none;
}

.sgg-sponsor-dialog {
    box-sizing: border-box;
    width: min(42rem, calc(100% - 1.5rem));
    max-height: calc(100vh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    padding: 0;
    border: 0;
    border-radius: 0.9rem;
    background: #fff;
    color: #192633;
    box-shadow: 0 18px 60px rgb(12 20 35 / 24%);
    overflow: auto;
    overscroll-behavior: contain;
    overflow-wrap: anywhere;
}

.sgg-sponsor-dialog::backdrop {
    background: rgb(12 20 35 / 64%);
    overflow: hidden;
    overscroll-behavior: contain;
}

.sgg-sponsor-dialog:not([open]):target {
    display: block;
    position: static;
    width: 100%;
    max-height: none;
    margin-block: 1rem;
    scroll-margin-block-start: 1rem;
}

.sgg-card-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem clamp(1rem, 4vw, 1.5rem);
    background: #fff;
    border-block-end: 1px solid #e4e8ec;
}

.sgg-card-header h2 {
    margin: 0;
    font-size: clamp(1.25rem, 4vw, 1.65rem);
    line-height: 1.2;
    color: inherit;
}

.sgg-card-close {
    box-sizing: border-box;
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #d7dee6;
    border-radius: 50%;
    background: #fff;
    color: #192633;
    font: 500 1.5rem/1 system-ui, sans-serif;
    text-decoration: none;
    cursor: pointer;
}

.sgg-card-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.sgg-sponsor-dialog:not([open]) [data-sgg-card-close],
.sgg-sponsor-dialog[open] .sgg-card-fallback-close {
    display: none;
}

.sgg-card-content {
    display: grid;
    gap: 1rem;
    padding: clamp(1rem, 4vw, 1.5rem);
}

.sgg-card-image img,
.sgg-card-gallery img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: 0.5rem;
    background: #f3f5f7;
}

.sgg-card-image img {
    max-height: min(45vh, 22rem);
}

.sgg-card-gallery,
.sgg-card-links {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sgg-card-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr));
    gap: 0.625rem;
}

.sgg-card-gallery img {
    aspect-ratio: 4 / 3;
}

.sgg-card-text > :first-child {
    margin-block-start: 0;
}

.sgg-card-text > :last-child {
    margin-block-end: 0;
}

.sgg-card-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sgg-card-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.75rem;
    border: 1px solid #d7dee6;
    border-radius: 0.4rem;
    color: #192633;
    background: #f4f6f8;
}

.sgg-main-container:has(.sgg-sponsor-dialog[open]) .sgg-layout-ticker .sgg-track {
    animation-play-state: paused !important;
}
