:root {
    --gold: #d8c690;
    --gold-bright: #f2dfaa;
    --panel-bg: rgba(13, 13, 13, 0.68);
    --line: rgba(224, 202, 138, 0.18);
    --text: #f7f4ea;
    --muted: rgba(255, 255, 255, 0.62);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

body {
    font-family: "Forum", sans-serif;
}

button,
iframe {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 2.2s ease;
}

.scene.active {
    opacity: 1;
    pointer-events: auto;
}

.scene-decoration,
.scene-decoration.active {
    pointer-events: none;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================================================
   INTRO
========================================================= */

#intro-text {
    position: fixed;
    top: 7vh;
    left: 50%;
    z-index: 100;
    width: min(1000px, 85vw);
    transform: translateX(-50%);
    color: rgba(232, 226, 202, 0.429);
    font-family: "Marcellus", serif;
    text-align: center;
    font-size: clamp(14px, 1vw, 20px);
    font-weight: 300;
    line-height: 1.9;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.8s ease-in-out;

}

#intro-text.visible {
    opacity: 1;
    transform: translateX(-50%);
}

#intro-text p {
    margin: 8px 0;
}

#intro-text strong {
    color: white;
    font-weight: 500;
}

#logo {
    position: fixed;
    top: 28px;
    left: 40px;
    z-index: 500;
    opacity: 0;
    font-family: "Allura", cursive;
    font-size: 40px;
    font-weight: 400;
    letter-spacing: 1px;
    user-select: none;
    pointer-events: none;
    background: linear-gradient(
        135deg,
        #fff7d6 0%,
        #e9d08b 25%,
        #b88a2d 55%,
        #f6e6b5 80%,
        #fff7d6 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgba(255, 220, 120, 0.12),
                 0 0 20px rgba(180, 140, 40, 0.10);
}

#logo.visible {
    opacity: 1;
}

/* =========================================================
   RETOUR
========================================================= */

#back-button {
    position: fixed;
    top: 92px;
    left: 40px;
    z-index: 510;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 8px 0;
    border: 0;
    background: transparent;
    color: var(--gold);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.02em;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-8px);
    cursor: pointer;
    transition: opacity 0.35s ease, transform 0.35s ease, color 0.25s ease;
}

#back-button.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

#back-button:hover {
    color: white;
}

/* =========================================================
   GALERIE
========================================================= */

#gallery {
    position: fixed;
    top: 5vh;
    right: 0;
    z-index: 300;
    width: min(72vw, 1120px);
    height: 90vh;
    padding: clamp(22px, 3vw, 46px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: 28px 0 0 28px;
    background: var(--panel-bg);
    box-shadow: -10px 0 35px rgba(0,0,0,.18);
    backdrop-filter: blur(12px) saturate(110%);
    -webkit-backdrop-filter: blur(22px) saturate(120%);
    opacity: 0;
    transform: translateX(104%);
    pointer-events: none;
    transition: transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.4s ease;
}

#gallery.open {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.gallery-shell {
    width: min(900px, 100%);
    height: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    gap: clamp(18px, 2.2vh, 28px);
}

.preview-frame {
    position: relative;
    min-height: 0;
    overflow: hidden;
    border-radius: 22px;
    background: #060606;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
    cursor: pointer;
    isolation: isolate;
}

.preview-frame:focus-visible {
    outline: 2px solid var(--gold-bright);
    outline-offset: 4px;
}

.demo-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.015);
    transition: opacity 0.45s ease, transform 0.8s ease;
}

.demo-media.active {
    opacity: 1;
    transform: scale(1);
}

.preview-frame:hover .demo-media.active {
    transform: scale(1.025);
}

.preview-shade {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(
        180deg,
        rgba(0, 0, 0, 0.02) 45%,
        rgba(0, 0, 0, 0.56) 100%
    );
}

.preview-hint {
    position: absolute;
    left: 90%;
    top: 10px;
    z-index: 4;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.785);
    background: rgba(7, 7, 7, 0.44);
    backdrop-filter: blur(10px);
    transform: translate(-50%, 0);
    opacity: 0.7;
    font-size: 11px;
    letter-spacing: 0.04em;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.preview-frame:hover .preview-hint {
    opacity: 1;
}

.carousel-arrow {
    position: absolute;
    top: 50%;
    z-index: 5;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    background: rgba(5, 5, 5, 0.46);
    color: rgba(255, 255, 255, 0.86);
    font-size: 38px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.68;
    transform: translateY(-50%);
    backdrop-filter: blur(10px);
    transition: opacity 0.25s ease, transform 0.25s ease,
                background 0.25s ease, border-color 0.25s ease;
}

.carousel-arrow span {
    transform: translateY(-2px);
}

.carousel-arrow-left {
    left: 18px;
}

.carousel-arrow-right {
    right: 18px;
}

.carousel-arrow:hover {
    opacity: 1;
    background: rgba(15, 15, 15, 0.78);
    border-color: rgba(242, 223, 170, 0.5);
    transform: translateY(-50%) scale(1.06);
}

.preview-frame.slide-next .demo-media.active {
    animation: mediaInNext 0.5s ease both;
}

.preview-frame.slide-prev .demo-media.active {
    animation: mediaInPrev 0.5s ease both;
}

@keyframes mediaInNext {
    from { opacity: 0; transform: translateX(20px) scale(1.015); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes mediaInPrev {
    from { opacity: 0; transform: translateX(-20px) scale(1.015); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

.gallery-meta {
    min-width: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.caption-block {
    min-width: 0;
    flex:1;
}

#demo-kicker {
    margin: 0 0 7px;
    color: var(--gold);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

#demo-title {
    margin: 0;
    margin-top: 20px;
    max-width: 760px;
    color: var(--text);
    font-size: clamp(14px, 2vw, 22px);
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.02em;
    text-align:center;
}

#demo-subtitle {
    margin: 8px 0 0;
    text-align: center;

    color: var(--gold);

    font-size: 13px;
    font-weight: 300;
    line-height: 1.4;

    opacity: .9;
}

.demo-counter {
    flex: 0 0 auto;
    padding-bottom: 3px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
    letter-spacing: 0.13em;
}

.gallery-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}


/* =========================================================
   VIEWER IFRAME
========================================================= */

#viewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: clamp(10px, 2vw, 28px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#viewer.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.viewer-window {
    position: relative;
    z-index: 1;
    width: min(96vw, 1680px);
    height: min(94vh, 1080px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 22px;
    background: #050505;
    box-shadow: 0 35px 120px rgba(0, 0, 0, 0.65);
    opacity: 0;
    transform: scale(0.965) translateY(14px);
    transition: opacity 0.42s ease,
                transform 0.58s cubic-bezier(0.22, 1, 0.36, 1);
}

#viewer.open .viewer-window {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.viewer-toolbar {
    height: 62px;
    padding: 0 18px 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(10, 10, 10, 0.92);
}

.viewer-title-wrap {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.viewer-label {
    flex: 0 0 auto;
    color: var(--gold);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.13em;
}

#viewer-title {
    min-width: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.82);
    font-size: 8px;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#close-viewer {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    color: white;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
}

#close-viewer:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: rotate(4deg) scale(1.05);
}

.viewer-content {
    position: relative;
    height: calc(100% - 62px);
    background: #000;
}

#demo-frame {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
    opacity: 0;
    background: #000;
    transition: opacity 0.35s ease;
}

#demo-frame.loaded {
    opacity: 1;
}

.viewer-loader {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, 0.55);
    background: #050505;
    font-size: 13px;
    letter-spacing: 0.04em;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.viewer-loader::after {
    content: "";
    position: absolute;
    width: 42px;
    height: 42px;
    margin-top: -54px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.viewer-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

body.viewer-open {
    cursor: default !important;
}

/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 900px) {
    #gallery {
        top: auto;
        bottom: 0;
        width: 100vw;
        height: min(80vh, 760px);
        border-right: 0;
        border-left: 0;
        border-bottom: 0;
        border-radius: 26px 26px 0 0;
        transform: translateY(104%);
    }

    #gallery.open {
        transform: translateY(0);
    }

    #back-button {
        top: 82px;
    }

    .gallery-shell {
        gap: 16px;
    }

    .carousel-arrow {
        width: 46px;
        height: 46px;
    }
}

@media (max-width: 620px) {
    #logo {
        top: 20px;
        left: 22px;
        font-size: 34px;
    }

    #back-button {
        top: 67px;
        left: 22px;
    }

    #gallery {
        height: 78vh;
        padding: 18px;
    }

    .gallery-meta {
        align-items: flex-start;
    }

    #demo-title {
        font-size: 18px;
    }

    .gallery-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .demo-dots {
        justify-content: center;
    }

    .explore-button {
        width: 100%;
    }

    .preview-hint {
        display: none;
    }

    .carousel-arrow {
        opacity: 0.88;
    }

    .carousel-arrow-left {
        left: 10px;
    }

    .carousel-arrow-right {
        right: 10px;
    }

    #viewer {
        padding: 0;
    }

    .viewer-window {
        width: 100vw;
        height: 100vh;
        border: 0;
        border-radius: 0;
    }

    .viewer-toolbar {
        height: 58px;
        padding-left: 15px;
    }

    .viewer-content {
        height: calc(100% - 58px);
    }

    .viewer-label {
        display: none;
    }
}

@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;
    }
}

