/* --- Fullscreen Logic --- */
body.is-fullscreen {
    background-color: #000;
}

body.is-fullscreen header,
body.is-fullscreen .thumb-swiper,
body.is-fullscreen .page-indicator,
body.is-fullscreen .nav-hotspot {
    display: none !important;
}

body.is-fullscreen .app-content {
    padding: 0;
    gap: 0;
    justify-content: center;
}

body.is-fullscreen .main-viewer {
    height: 100dvh;
    background-color: #000;
}

body.is-fullscreen .main-image {
    object-fit: contain; /* Ensure full image visibility in fullscreen */
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: #333;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: 'Roboto Condensed', sans-serif;
    transition: background-color 0.3s ease;
}

/* --- Header Section --- */
header {
    background-color: #333;
    padding: 15px 30px;
    color: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 20px;
    z-index: 10;
}

.home-link {
    color: #777;
    display: inline-flex;
    align-items: baseline;
    transition: color 0.3s ease;
    text-decoration: none;
    margin-left: auto;
}

.home-link:hover {
    color: #fff;
}

.home-link i {
    font-size: 24px;
}

header h1 {
    margin: 0;
    font-family: 'Open Sans', sans-serif;
    font-variation-settings: 'wdth' 75;
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: -1.5px;
}

header p {
    margin: 0;
    font-family: 'Open Sans', sans-serif;
    font-variation-settings: 'wdth' 75;
    font-size: 1rem;
    font-weight: 300;
    color: #ccc;
    letter-spacing: 0.2px;
}

@media (max-width: 600px) {
    header {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        gap: 2px 20px;
        padding: 15px 20px;
    }
    header h1 {
        font-size: 1.8rem;
    }
    header p {
        width: 100%;
        order: 3;
    }
    .home-link {
        margin-left: auto;
        order: 2;
    }
    .home-link i {
        font-size: 20px;
    }
}

.app-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    gap: 10px;
}

/* --- Main Viewer (Swiper) --- */
.main-viewer {
    width: 100%;
    /* Leaves room in the 100dvh column for the header and the 16vh thumb strip below */
    height: 62vh;
    flex-shrink: 0;
    background-color: #333;
    position: relative;
}

.main-viewer .swiper-slide {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #333;
}

/* Swiper zooms the <picture>, so it must fill the zoom container */
.swiper-zoom-container > picture {
    display: block;
    width: 100%;
    height: 100%;
}

.main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* --- Missing Image Fallback --- */
.swiper-slide.image-missing .main-image,
.swiper-slide.image-missing .thumb-image {
    visibility: hidden;
}

.swiper-slide.image-missing::before {
    content: "Image unavailable";
    position: absolute;
    color: #999;
    font-size: 13px;
    text-align: center;
}

/* --- Invisible Navigation Hotspots --- */
.nav-hotspot {
    position: absolute;
    top: 0;
    height: 100%;
    width: 10%;
    z-index: 10;
    cursor: pointer;
}

.prev-zone {
    left: 0;
}

.next-zone {
    right: 0;
}

/* --- Thumbnail Section --- */
.thumb-swiper {
    width: 100%;
    height: 16vh;
    min-height: 100px;
    max-height: 140px;
    background-color: #333;
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 0 40px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.thumb-swiper .swiper-wrapper {
    padding: 15px 0;
    box-sizing: border-box;
}

.thumb-swiper .swiper-slide {
    opacity: 0.4;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.thumb-swiper .swiper-slide-thumb-active {
    opacity: 1;
    transform: scale(1.05);
    z-index: 10;
}

.thumb-swiper .swiper-slide-thumb-active .thumb-image {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-radius: 2px;
}

.thumb-swiper picture {
    display: contents;
}

.thumb-image {
    height: calc(100% - 24px);
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.thumb-label {
    color: #bbb;
    font-size: 11px;
    text-align: center;
}

/* --- UI Elements --- */
.page-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 18px;
    border-radius: 9999px;
    font-size: 14px;
    pointer-events: none;
    z-index: 10;
}

/* --- Landscape Optimizations --- */
@media (orientation: landscape) and (max-height: 500px) {
    header {
        padding: 8px 20px;
        flex-direction: row;
        align-items: baseline;
        gap: 12px;
    }
    header h1 {
        font-size: 1.4rem;
    }
    header p {
        font-size: 0.85rem;
    }
    .thumb-swiper {
        display: none;
    }
    .app-content {
        padding: 0;
        gap: 0;
    }
    .main-viewer {
        height: calc(100dvh - 45px);
    }
    .page-indicator {
        bottom: 10px;
        font-size: 11px;
        padding: 3px 10px;
    }
}
