html {
    overscroll-behavior: contain;
}

/* WCAG 2.4.1 - Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #004A7F;
    color: #ffffff;
    padding: 8px 16px;
    z-index: 9999;
    transition: top 0.3s;
    text-decoration: none;
}
.skip-link:focus {
    top: 0;
    color: #ffffff;
}

/* WCAG 2.4.7 - Focus indicators for custom-styled elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid #004A7F;
    outline-offset: 2px;
}

img { border: 0; }

a {
    color:#004A7F;
    text-decoration:none;
}

h4
{
    display: inline;
}

body .galleria-container{ background:#F5F5F5; }

.pagination > .active > a
{
    color: white;
    background-color: #004A7F !Important;
    border: solid 1px #004A7F !Important;
}

.splide__slide img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: auto;
    transform: translateZ(0);
    will-change: transform;
    image-rendering: crisp-edges;
}

/* Main gallery slide container styling */
.splide__slide {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    background-color: #f8f9fa !important;
    overflow: hidden;
    position: relative;
}

.thumbnails {
    display: flex;
    margin: 1rem auto 0;
    padding: 0;
    justify-content: center;
}

.thumbnail {
    width: 70px;
    height: 70px;
    overflow: hidden;
    list-style: none;
    margin: 0 0.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    position: relative;
}

.thumbnail img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    display: block;
    transform: translateZ(0);
    image-rendering: crisp-edges;
}

/* Lightbox styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    overflow: auto;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    margin: 2% auto;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-close {
    position: absolute;
    top: 10px;
    right: 25px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-image-container {
    width: 100%;
    height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    background-color: transparent;
    position: relative;
    overflow: hidden;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    display: block;
    margin: auto;
    transform: translateZ(0);
    will-change: transform;
    image-rendering: crisp-edges;
}

.lightbox-ad-slot {
    width: 100%;
    max-width: 728px;
    height: 90px;
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
}

.lightbox-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    max-width: 100%;
    justify-content: center;
}

.lightbox-thumb {
    min-width: 80px;
    height: 60px;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.lightbox-thumb:hover {
    opacity: 1;
    border-color: #007bff;
}

.lightbox-thumb.active {
    opacity: 1;
    border-color: #007bff;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    user-select: none;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

@media (max-width: 768px) {
    .lightbox-content {
        max-width: 95%;
        margin: 1% auto;
    }

    .lightbox-image-container {
        height: 60vh;
    }

    .lightbox-ad-slot {
        height: 50px;
        font-size: 12px;
    }

    .lightbox-nav {
        font-size: 24px;
        width: 40px;
        height: 40px;
    }

    .lightbox-close {
        font-size: 30px;
        width: 40px;
        height: 40px;
    }

    .semi-sticky-mobile {
        position: sticky !important;
        top: 90px;
    }

    .splide__slide {
        display: block !important;
        text-align: center !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: visible !important;
    }
    .splide__slide img {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        object-position: center !important;
        margin-left: auto !important;
        margin-right: auto !important;
        display: block !important;
    }
    #main-slider, .splide__track, .responsive-gallery {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
}

@media (min-width: 768px) {
    .billboard_container {
        min-height: 300px !important;
        display: flex !important;
        justify-content: center;
        align-items: center;
    }
}

@media (max-width: 1024px) {
    .billboard-interscroller-height {
        margin-top: 150px;
    }
}

@media (min-width: 1024px) {
    .billboard-interscroller-height {
        min-height: 250px !important;
        display: flex !important;
        justify-content: center;
        align-items: center;
    }
}

@media (min-width: 1200px) {
    .sticky {
        position: sticky !important;
        top: 55px;
    }
}

/* Gallery and image placeholder responsive styles */
@media (max-width: 480px) {
    .row[style*="min-height: 650px"] {
        min-height: 450px !important;
    }
    .no-image-placeholder {
        height: 340px !important;
    }
}

@media (max-width: 768px) {
    .row[style*="min-height: 650px"] {
        min-height: 525px !important;
    }
    .no-image-placeholder {
        height: 425px !important;
    }
    .thumbnails {
        padding-bottom: 5px;
    }
}

/* ----- Reserved ad slot styling to mitigate CLS for lazy combo / interscroller ----- */
#hifitorget_se_lazy_combo,
[id^="hifitorget_se_lazy_combo-"] {
    width: 100%;
    display: block;
    position: relative;
    background: transparent;
    overflow: hidden;
    transition: height .25s ease;
}

@media (min-width:1024px) {
    #hifitorget_se_lazy_combo,
    [id^="hifitorget_se_lazy_combo-"] {
        min-height:300px;
        height:300px;
    }
}
@media (max-width:1023.98px) {
    #hifitorget_se_lazy_combo,
    [id^="hifitorget_se_lazy_combo-"] {
        min-height:520px;
        height:520px;
    }
}
.ad-slot-collapsed { height:0 !important; min-height:0 !important; }

/* Highlighted ad styling - subtle background for paid highlight feature */
.ad-highlighted {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f2ff 100%) !important;
    border-left: 3px solid #4A90D9 !important;
    position: relative;
    padding-bottom: 20px;
    margin-bottom: 16px;
}

.ad-highlighted::before {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    background-color: #4A90D9;
    border-radius: 50%;
    opacity: 0.7;
}

.ad-highlighted + hr {
    margin-top: 16px;
}

/* ============================================
   ANCHOR AD STYLING
   Bottom-fixed display ads styled as anchors
   ============================================ */

/* Spacer to prevent anchor from covering footer content */
.anchor-ad-spacer {
    height: 120px; /* Desktop: ~90px anchor + padding + close btn */
}

@media (max-width: 767px) {
    .anchor-ad-spacer {
        height: 130px; /* Mobile: 320x100 max + padding/close btn */
    }
}

/* Anchor container - fixed to bottom of viewport */
.anchor-ad-container {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 9990;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 5px 0;
    /* Respektera iOS safe-area (home-indicator + dynamisk toolbar) */
    padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px));
    transition: transform 0.3s ease-out;
    /* Ensure fixed positioning works */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Hidden state for close functionality */
.anchor-ad-container.hidden {
    transform: translateY(100%);
    pointer-events: none;
}

/* Close button styling */
.anchor-ad-close {
    position: absolute;
    top: -12px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 9991;
}

.anchor-ad-close:hover {
    background: #f5f5f5;
    color: #333;
    border-color: #999;
}

.anchor-ad-close:focus {
    outline: 2px solid #004A7F;
    outline-offset: 2px;
}

/* Ad slot wrapper inside anchor */
.anchor-ad-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    max-width: 100%;
    overflow: hidden;
}

/* Mobile: constrain ad width */
@media (max-width: 767px) {
    .anchor-ad-container {
        padding: 5px 10px;
    }

    .anchor-ad-slot {
        max-width: 320px;
        min-height: 50px;
    }
}

/* Desktop anchor sizes: 728x90 or 970x90 */
@media (min-width: 768px) {
    .anchor-ad-container {
        padding: 8px 0;
    }

    .anchor-ad-slot {
        min-height: 90px;
        max-width: 970px;
    }

    .anchor-ad-close {
        right: 20px;
    }
}

/* Large desktop: center with max width */
@media (min-width: 1024px) {
    .anchor-ad-close {
        right: calc(50% - 500px);
    }
}

/* ============================================
   Shared "Annons" badge for all ad slots.
   Apply class .ad-slot-labeled and set
   data-sponsored-label="<?= trans('listing.sponsored') ?>"
   on the wrapper around any Google Ad Manager slot.
   ============================================ */
.ad-slot-labeled {
    position: relative;
    padding-top: 22px;
}

.ad-slot-labeled::before {
    content: attr(data-sponsored-label);
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f8f9fa;
    padding: 2px 8px;
    border-radius: 3px;
    z-index: 1;
    line-height: 1.4;
}

@media (max-width: 767px) {
    .ad-slot-labeled::before {
        font-size: 10px;
    }
}

/* Anchor ad variant: badge sits above the fixed bottom bar */
.anchor-ad-container.ad-slot-labeled::before {
    top: -10px;
    left: 10px;
}

@media (min-width: 1024px) {
    .anchor-ad-container.ad-slot-labeled::before {
        left: calc(50% - 500px);
    }
}
