/* =========================================================
   PHOTO VIEWER — COMPLETE CSS
   Floating Main Image + Thumbnail Timeline
   ========================================================= */

   :root {
    --bg: #0d0f14;
    --bg-deep: #080b11;

    --panel: rgba(32, 36, 47, 0.72);
    --panel-solid: rgba(10, 13, 20, 0.94);
    --panel-border: rgba(255, 255, 255, 0.12);

    --text: #ecf0f6;
    --muted: #acb7cc;

    --accent: #5aa8ff;
    --accent-soft: rgba(90, 168, 255, 0.30);

    --danger: #ff6e73;
    --success: #63d6a0;

    --viewer-gap: 8px;

    --thumb-strip-height: 96px;
    --selection-height: 46px;

    --viewer-bottom-space:
        calc(
            var(--thumb-strip-height)
            + var(--selection-height)
            + 18px
        );
}


/* =========================================================
   GLOBAL RESET
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;

    font-family:
        "Inter",
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    background: var(--bg);
    color: var(--text);

    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    overflow: hidden;
}


/* =========================================================
   UTILITY
   ========================================================= */

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;

    width: 1px;
    height: 1px;

    margin: -1px;
    padding: 0;

    overflow: hidden;

    border: 0;

    clip: rect(0 0 0 0);
}


/* =========================================================
   AUTH SCREEN
   ========================================================= */

.auth-screen {
    min-height: 100dvh;

    display: grid;
    place-items: center;

    position: relative;

    background:
        linear-gradient(
            rgba(5, 8, 14, 0.64),
            rgba(5, 8, 14, 0.78)
        ),
        url("../main.jpeg")
            center center /
            cover
            no-repeat,
        radial-gradient(
            circle at top,
            #1b202d 0,
            #0d0f14 62%
        );
}

.auth-card {
    width: min(420px, 92vw);

    padding: 28px;

    border-radius: 20px;

    background: var(--panel);

    border: 1px solid var(--panel-border);

    backdrop-filter: blur(10px);

    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.48);
}

.auth-subtitle {
    color: var(--muted);
}

#auth-title {
    margin: 0;

    font-size: 1.25rem;

    line-height: 1.2;

    white-space: nowrap;
}

.pin-input {
    width: 100%;

    margin-top: 16px;

    font-size: 1.5rem;

    letter-spacing: 0.36em;

    text-align: center;

    padding: 12px;

    border-radius: 12px;

    border: 1px solid var(--panel-border);

    background: rgba(0, 0, 0, 0.35);

    color: var(--text);

    outline: none;
}

.pin-input:focus {
    border-color: var(--accent);

    box-shadow:
        0 0 0 3px var(--accent-soft);
}

.pin-hint {
    color: var(--muted);

    font-size: 0.85rem;
}

.pin-error {
    min-height: 1.2em;

    color: var(--danger);
}


/* =========================================================
   APPLICATION SHELL
   ========================================================= */

.app-shell {
    width: 100%;
    height: 100dvh;

    display: grid;

    grid-template-rows: auto 1fr;

    gap: 8px;

    padding: 8px;

    overflow: hidden;
}


/* =========================================================
   TOP BAR
   ========================================================= */

.topbar {
    position: relative;

    z-index: 100;

    display: grid;

    grid-template-columns:
        minmax(150px, 1fr)
        minmax(180px, 400px)
        minmax(260px, 1fr);

    gap: 12px;

    align-items: center;

    margin: 0;

    padding: 10px 16px;

    border:
        1px solid var(--panel-border);

    border-radius: 12px;

    background:
        rgba(8, 11, 17, 0.72);

    backdrop-filter: blur(12px);

    box-shadow:
        0 5px 25px rgba(0, 0, 0, 0.16);
}

.topbar-left,
.topbar-right,
.selection-bar {
    display: flex;

    align-items: center;

    gap: 10px;
}

.topbar-left {
    min-width: 0;
}

.topbar-right {
    justify-content: flex-end;
}

.topbar-center {
    display: flex;

    justify-content: center;

    min-width: 0;
}

.brand {
    font-size: 0.92rem;

    line-height: 1.1;

    white-space: nowrap;
}

.collection-name {
    color: var(--muted);

    font-size: 0.92rem;

    white-space: nowrap;
}


/* =========================================================
   SEARCH
   ========================================================= */

.search-input,
.goto-input {
    border:
        1px solid var(--panel-border);

    background:
        rgba(0, 0, 0, 0.35);

    color: var(--text);

    border-radius: 10px;

    padding: 8px 10px;

    outline: none;

    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background 160ms ease;
}

.search-input {
    width: 100%;

    max-width: 380px;
}

.search-input::placeholder,
.goto-input::placeholder {
    color: rgba(172, 183, 204, 0.60);
}

.search-input:focus,
.goto-input:focus {
    border-color: var(--accent);

    background:
        rgba(0, 0, 0, 0.48);

    box-shadow:
        0 0 0 3px var(--accent-soft);
}

.goto-form {
    display: flex;

    gap: 8px;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    border:
        1px solid var(--panel-border);

    color: var(--text);

    background:
        rgba(255, 255, 255, 0.06);

    border-radius: 10px;

    padding: 8px 12px;

    cursor: pointer;

    transition:
        background 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease,
        transform 160ms ease;
}

.btn:hover,
.btn:focus-visible {
    border-color: var(--accent);

    background:
        rgba(255, 255, 255, 0.09);

    box-shadow:
        0 0 0 2px var(--accent-soft);

    outline: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn.is-active {
    border-color: var(--accent);

    background:
        rgba(90, 168, 255, 0.18);

    box-shadow:
        0 0 0 2px var(--accent-soft);
}

.btn-primary {
    background:
        linear-gradient(
            180deg,
            #3f96ff,
            #2e74da
        );

    border-color: #5ea8ff;
}

.btn-icon {
    width: 36px;
    height: 36px;

    padding: 0;

    display: inline-flex;

    align-items: center;
    justify-content: center;
}

.btn-block {
    width: 100%;
}


/* =========================================================
   MAIN VIEWER CANVAS
   ========================================================= */

.viewer-main {
    position: relative;

    width: 100%;
    height: 100%;

    min-height: 0;

    display: block;

    overflow: hidden;

    background:
        radial-gradient(
            circle at 50% 35%,
            rgba(74, 90, 116, 0.22),
            transparent 54%
        ),
        linear-gradient(
            180deg,
            #354052 0%,
            #2d3745 48%,
            #222b37 100%
        );
}


/* =========================================================
   FLOATING MAIN IMAGE VIEWER
   ========================================================= */

.viewer-stage {
    position: absolute;

    top: 0;
    left: 0;
    right: 0;

    bottom:
        calc(
            var(--thumb-strip-height)
            + var(--selection-height)
            + 20px
        );

    min-height: 0;

    height: auto;

    border: none;

    border-radius: 0;

    background: transparent;

    overflow: visible;

    z-index: 5;
}


/* =========================================================
   IMAGE VIEWPORT
   ========================================================= */

.image-viewport {
    position: relative;

    width: 100%;
    height: 100%;

    display: flex;

    align-items: center;
    justify-content: center;

    padding:
        12px
        76px
        18px;

    touch-action: none;

    overflow: visible;
}


/* =========================================================
   MAIN IMAGE
   ========================================================= */

#image-frame {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    max-width: 100%;
    max-height: 100%;

    overflow: hidden;

    border:
        2px solid #ffffff;

    border-radius: 5px;

    background: #ffffff;

    box-shadow:
        0 10px 25px rgba(0, 0, 0, 0.32),
        0 25px 65px rgba(0, 0, 0, 0.48);
}

#main-image {
    display: block;

    width: auto;
    height: auto;

    /*
     * The image can now occupy almost the entire
     * available viewport.
     */
    max-width: 100%;
    max-height: 100%;

    object-fit: contain;

    box-sizing: border-box;

    user-select: none;

    -webkit-user-drag: none;

    transition:
        opacity 220ms ease,
        transform 220ms ease;

    transform-origin: center center;

    will-change: transform;
}

#main-image.photo-enter {
    animation:
        photoIn 220ms ease-out;
}

@keyframes photoIn {
    from {
        opacity: 0;

        transform:
            scale(0.985);
    }

    to {
        opacity: 1;

        transform:
            scale(1);
    }
}


/* =========================================================
   PHOTO INFORMATION OVERLAY
   ========================================================= */

.viewer-overlay {
    position: absolute;

    left: 28px;
    right: 28px;

    bottom: 28px;

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 10px;

    pointer-events: none;

    z-index: 30;
}

.meta-pill,
.counter-pill {
    padding:
        8px 12px;

    border-radius: 10px;

    background:
        rgba(8, 11, 17, 0.70);

    border:
        1px solid rgba(255, 255, 255, 0.14);

    backdrop-filter: blur(10px);

    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.22);

    font-size: 0.86rem;

    white-space: nowrap;
}

.counter-pill {
    font-weight: 600;
}


/* =========================================================
   ZOOM CONTROLS
   ========================================================= */

.zoom-controls {
    position: absolute;

    top: 14px;
    right: 18px;

    display: flex;

    gap: 8px;

    z-index: 40;
}

.zoom-controls .btn {
    min-width: 36px;
}


/* =========================================================
   LEFT / RIGHT NAVIGATION
   ========================================================= */

.nav-btn {
    position: absolute;

    top: 50%;

    transform:
        translateY(-50%);

    z-index: 50;

    width: 44px;
    height: 64px;

    display: flex;

    align-items: center;
    justify-content: center;

    border:
        1px solid rgba(255, 255, 255, 0.13);

    border-radius: 14px;

    background:
        rgba(8, 11, 17, 0.68);

    backdrop-filter: blur(10px);

    color: var(--text);

    font-size: 2rem;

    line-height: 1;

    cursor: pointer;

    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.28);

    transition:
        background 160ms ease,
        border-color 160ms ease,
        transform 160ms ease,
        box-shadow 160ms ease;
}

.nav-btn:hover {
    background:
        rgba(20, 25, 34, 0.92);

    border-color:
        rgba(255, 255, 255, 0.28);

    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.38);

    transform:
        translateY(-50%)
        scale(1.04);
}

.nav-btn:active {
    transform:
        translateY(-50%)
        scale(0.96);
}

.nav-btn.prev {
    left: 18px;
}

.nav-btn.next {
    right: 18px;
}


/* =========================================================
   IMAGE LOADER
   ========================================================= */

.image-loader {
    position: absolute;

    top: 50%;
    left: 50%;

    width: 30px;
    height: 30px;

    margin:
        -15px 0 0 -15px;

    border:
        3px solid rgba(255, 255, 255, 0.20);

    border-top-color:
        var(--accent);

    border-radius: 50%;

    animation:
        spin 0.8s linear infinite;

    z-index: 60;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* =========================================================
   IMAGE ERROR
   ========================================================= */

.image-error {
    position: absolute;

    top: 50%;
    left: 50%;

    transform:
        translate(-50%, -50%);

    display: grid;

    gap: 10px;

    min-width: 240px;

    text-align: center;

    background:
        rgba(12, 14, 20, 0.82);

    border:
        1px solid var(--panel-border);

    border-radius: 12px;

    padding: 18px;

    backdrop-filter: blur(10px);

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.35);

    z-index: 70;
}


/* =========================================================
   INFORMATION PANEL
   ========================================================= */

.info-panel {
    position: absolute;

    top: 56px;
    right: 12px;

    min-width: 230px;
    max-width: 300px;

    background:
        rgba(10, 13, 20, 0.78);

    border:
        1px solid var(--panel-border);

    border-radius: 12px;

    padding: 10px;

    backdrop-filter: blur(10px);

    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.35);

    z-index: 80;
}

.info-panel p {
    margin: 6px 0;

    font-size: 0.85rem;

    color: var(--muted);
}


/* =========================================================
   THUMBNAIL TIMELINE
   ========================================================= */

.thumb-strip {
    position: absolute;

    left: 0;
    right: 0;

    bottom:
        var(--selection-height);

    width: auto;

    height:
        var(--thumb-strip-height);

    min-height:
        var(--thumb-strip-height);

    max-height:
        var(--thumb-strip-height);

    display: flex;

    flex-direction: row;

    align-items: center;

    gap: 8px;

    overflow-x: auto;

    overflow-y: visible;

    padding:
        10px 12px;

    background:
        rgba(8, 11, 17, 0.82);

    border:
        1px solid rgba(255, 255, 255, 0.10);

    border-radius: 12px;

    backdrop-filter: blur(14px);

    box-shadow:
        0 10px 35px rgba(0, 0, 0, 0.32);

    scroll-behavior: smooth;

    scrollbar-width: thin;

    scrollbar-color:
        rgba(255, 255, 255, 0.22)
        transparent;

    z-index: 25;
}


/* =========================================================
   THUMBNAIL SCROLLBAR — CHROME
   ========================================================= */

.thumb-strip::-webkit-scrollbar {
    height: 5px;
}

.thumb-strip::-webkit-scrollbar-track {
    background: transparent;
}

.thumb-strip::-webkit-scrollbar-thumb {
    background:
        rgba(255, 255, 255, 0.20);

    border-radius: 999px;
}

.thumb-strip::-webkit-scrollbar-thumb:hover {
    background:
        rgba(255, 255, 255, 0.35);
}


/* =========================================================
   THUMBNAIL ITEM
   ========================================================= */

.thumb-item {
    position: relative;

    width: 120px;
    height: 74px;

    flex:
        0 0 auto;

    border:
        2px solid transparent;

    border-radius: 5px;

    overflow: hidden;

    background:
        #0f131d;

    cursor: pointer;

    transition:
        transform 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease;
}

.thumb-item:hover {
    transform:
        scale(1.04);

    border-color:
        rgba(255, 255, 255, 0.40);
}

.thumb-item img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    opacity: 0;

    transition:
        opacity 150ms ease;
}

.thumb-item.ready img {
    opacity: 1;
}


/* =========================================================
   ACTIVE THUMBNAIL
   ========================================================= */

.thumb-item.active {
    border-color:
        #ffffff;

    transform:
        scale(1.16);

    z-index: 10;

    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.62),
        0 0 0 1px rgba(255, 255, 255, 0.15);
}

.thumb-item.active:hover {
    transform:
        scale(1.16);
}


/* =========================================================
   THUMBNAIL NUMBER
   ========================================================= */

.thumb-index {
    position: absolute;

    right: 5px;
    bottom: 5px;

    padding:
        2px 6px;

    border-radius: 999px;

    background:
        rgba(0, 0, 0, 0.62);

    color:
        #f2f6ff;

    font-size:
        0.72rem;

    font-weight:
        700;

    line-height:
        1.2;

    pointer-events: none;
}


/* =========================================================
   SELECTION / ACTION BAR
   ========================================================= */

.selection-bar {
    position: absolute;

    left: 0;
    right: 0;

    bottom: 0;

    height:
        var(--selection-height);

    box-sizing: border-box;

    padding:
        8px 10px;

    display: flex;

    align-items: center;

    justify-content: flex-start;

    gap: 8px;

    border:
        1px solid var(--panel-border);

    border-radius: 10px;

    background:
        rgba(10, 13, 20, 0.94);

    backdrop-filter:
        blur(10px);

    box-shadow:
        0 -5px 20px rgba(0, 0, 0, 0.12);

    z-index: 30;
}

.selection-left {
    display: flex;

    gap: 8px;
}

.selection-bar .btn {
    padding:
        6px 8px;

    font-size:
        0.75rem;
}

.selection-count {
    margin-left: auto;

    font-size:
        0.78rem;

    color:
        var(--muted);

    white-space: nowrap;
}


/* =========================================================
   FULLSCREEN
   ========================================================= */

body.is-fullscreen {
    background:
        #080b11;
}

body.is-fullscreen .topbar,
body.is-fullscreen .selection-bar,
body.is-fullscreen .thumb-strip {
    display: none !important;
}

body.is-fullscreen .app-shell {
    width: 100vw;
    height: 100dvh;

    padding: 0;

    display: block;
}

body.is-fullscreen .viewer-main {
    position: fixed;

    inset: 0;

    width: 100vw;
    height: 100dvh;

    display: block;

    z-index: 9999;

    background:
        #080b11;
}

body.is-fullscreen .viewer-stage {
    position: absolute;

    inset: 0;

    bottom: 0;

    z-index: 5;
}

body.is-fullscreen .image-viewport {
    width: 100%;
    height: 100%;

    padding:
        20px 90px;
}

body.is-fullscreen #main-image {
    max-width: 100%;
    max-height: 100%;
}


/* =========================================================
   MINIMAL UI MODE
   ========================================================= */

body.ui-minimal .zoom-controls,
body.ui-minimal .nav-btn {
    opacity: 0.12;

    transition:
        opacity 200ms ease;
}

body.ui-minimal .zoom-controls:hover,
body.ui-minimal .nav-btn:hover {
    opacity: 1;
}


/* =========================================================
   SCROLLBAR — GENERAL
   ========================================================= */

* {
    scrollbar-width: thin;

    scrollbar-color:
        rgba(255, 255, 255, 0.20)
        transparent;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background:
        rgba(255, 255, 255, 0.20);

    border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
    background:
        rgba(255, 255, 255, 0.35);
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1100px) {

    .topbar {
        grid-template-columns:
            minmax(140px, 1fr)
            minmax(180px, 320px)
            auto;
    }

    .image-viewport {
        padding:
            10px 64px 16px;
    }

    .nav-btn.prev {
        left: 12px;
    }

    .nav-btn.next {
        right: 12px;
    }

    #main-image {
        max-width: 100%;
        max-height: 100%;
    }
}


/* =========================================================
   MOBILE / SMALL TABLET
   ========================================================= */

@media (max-width: 900px) {

    :root {
        --thumb-strip-height: 82px;
        --selection-height: 84px;
    }

    .app-shell {
        gap: 6px;

        padding:
            6px;
    }

    .topbar {
        grid-template-columns: 1fr;

        padding:
            10px;
    }

    .topbar-left,
    .topbar-center,
    .topbar-right {
        justify-content: flex-start;

        flex-wrap: wrap;
    }

    .topbar-right {
        justify-content: flex-start;
    }

    .search-input {
        max-width: none;
    }

    .viewer-stage {
        bottom:
            calc(
                var(--thumb-strip-height)
                + var(--selection-height)
                + 12px
            );
    }

    .image-viewport {
        padding:
            8px 48px 12px;
    }

    #image-frame {
        border-radius:
            4px;
    }

    #main-image {
        max-width: 100%;
        max-height: 100%;
    }

    .nav-btn {
        width:
            38px;

        height:
            52px;

        border-radius:
            12px;

        font-size:
            1.7rem;
    }

    .nav-btn.prev {
        left:
            6px;
    }

    .nav-btn.next {
        right:
            6px;
    }

    .viewer-overlay {
        left:
            12px;

        right:
            12px;

        bottom:
            12px;
    }

    .meta-pill,
    .counter-pill {
        padding:
            6px 9px;

        font-size:
            0.75rem;
    }

    .zoom-controls {
        top:
            8px;

        right:
            8px;

        gap:
            5px;
    }

    .thumb-strip {
        padding:
            8px 10px;

        gap:
            6px;

        border-radius:
            10px;
    }

    .thumb-item {
        width:
            88px;

        height:
            60px;
    }

    .thumb-item.active {
        transform:
            scale(1.10);
    }

    .thumb-item.active:hover {
        transform:
            scale(1.10);
    }

    .selection-bar {
        min-height:
            var(--selection-height);

        height:
            auto;

        flex-wrap:
            wrap;

        align-content:
            center;

        padding:
            8px;
    }

    .selection-left {
        flex-wrap:
            wrap;
    }

    .selection-count {
        margin-left:
            auto;
    }
}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 600px) {

    :root {
        --thumb-strip-height: 76px;
        --selection-height: 92px;
    }

    .app-shell {
        padding:
            4px;

        gap:
            4px;
    }

    .topbar {
        padding:
            8px;

        border-radius:
            10px;
    }

    .collection-name {
        font-size:
            0.78rem;
    }

    .brand {
        font-size:
            0.82rem;
    }

    .image-viewport {
        padding:
            6px 42px 8px;
    }

    #image-frame {
        box-shadow:
            0 8px 20px rgba(0, 0, 0, 0.38),
            0 18px 40px rgba(0, 0, 0, 0.45);
    }

    .nav-btn {
        width:
            34px;

        height:
            48px;

        font-size:
            1.5rem;
    }

    .nav-btn.prev {
        left:
            4px;
    }

    .nav-btn.next {
        right:
            4px;
    }

    .viewer-overlay {
        left:
            8px;

        right:
            8px;

        bottom:
            8px;
    }

    .meta-pill {
        max-width:
            65vw;

        overflow:
            hidden;

        text-overflow:
            ellipsis;
    }

    .counter-pill {
        flex:
            0 0 auto;
    }

    .thumb-strip {
        padding:
            7px;

        gap:
            5px;
    }

    .thumb-item {
        width:
            76px;

        height:
            54px;
    }

    .thumb-index {
        right:
            3px;

        bottom:
            3px;

        font-size:
            0.65rem;

        padding:
            2px 5px;
    }

    .selection-bar {
        padding:
            7px;

        gap:
            5px;
    }

    .selection-bar .btn {
        padding:
            6px 7px;

        font-size:
            0.7rem;
    }

    .selection-count {
        width:
            100%;

        text-align:
            right;

        margin-left:
            0;
    }
}


/* =========================================================
   TOUCH DEVICES
   ========================================================= */

@media (hover: none) and (pointer: coarse) {

    .thumb-item:hover {
        transform:
            none;

        border-color:
            transparent;
    }

    .thumb-item.active {
        transform:
            scale(1.10);
    }

    .btn:hover {
        box-shadow:
            none;
    }

    .nav-btn:hover {
        transform:
            translateY(-50%);
    }
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior:
            auto !important;

        animation-duration:
            0.01ms !important;

        animation-iteration-count:
            1 !important;

        transition-duration:
            0.01ms !important;
    }
}