/* ============================================
   mosoon.xyz - Palazzo Cabinet of Curiosities
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --aged-parchment: #f5efe6;
    --marble-cream: #e8ddd0;
    --burnt-umber-dark: #2a2520;
    --ink-umber: #3d342a;
    --warm-ivory: #f0e8db;
    --palazzo-gold: #d4a853;
    --venetian-rose: #c45e4f;
    --vein-shadow: #c4b8a4;
    --gallery-stone: #a89b8c;
    --marble-vein-light: #d4c8b8;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    color: var(--ink-umber);
    background: var(--aged-parchment);
    overflow: hidden;
    line-height: 1.72;
    letter-spacing: 0.01em;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Scroll Container --- */
.scroll-container {
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

/* --- Section Base --- */
.section {
    width: 100%;
    height: 100vh;
    position: relative;
    scroll-snap-align: start;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Paper Texture Overlay --- */
.paper-texture {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.paper-texture[data-filter="1"] { filter: url(#paperNoise1); }
.paper-texture[data-filter="2"] { filter: url(#paperNoise2); }
.paper-texture[data-filter="3"] { filter: url(#paperNoise3); }
.paper-texture[data-filter="4"] { filter: url(#paperNoise4); }
.paper-texture[data-filter="5"] { filter: url(#paperNoise5); }

/* --- Edge Vignette (per section) --- */
.section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(196,184,164,0.12) 100%);
    pointer-events: none;
    z-index: 1;
}

/* --- Section Cornice Dividers --- */
.section-cornice {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 16px;
    z-index: 5;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='16'%3E%3Cellipse cx='10' cy='8' rx='7' ry='6' fill='none' stroke='%23c4b8a4' stroke-width='1' opacity='0.35'/%3E%3Crect x='24' y='4' width='6' height='8' fill='none' stroke='%23c4b8a4' stroke-width='0.8' opacity='0.25'/%3E%3Cline x1='33' y1='6' x2='33' y2='10' stroke='%23c4b8a4' stroke-width='0.6' opacity='0.25'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
}

/* ============================================
   SECTION 0 - THE VESTIBULE (Hero)
   ============================================ */
.section-vestibule {
    background: var(--aged-parchment);
    flex-direction: column;
    /* Marble texture via CSS */
    background-image:
        linear-gradient(137deg, rgba(196,184,164,0.04) 0%, transparent 50%),
        linear-gradient(251deg, rgba(196,184,164,0.06) 0%, transparent 60%),
        linear-gradient(43deg, rgba(196,184,164,0.03) 0%, transparent 45%),
        repeating-linear-gradient(115deg, transparent, transparent 12px, rgba(196,184,164,0.05) 12px, rgba(196,184,164,0.05) 13px);
    background-color: var(--aged-parchment);
}

/* Marble floor effect */
.marble-floor {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) perspective(800px) rotateX(60deg);
    width: 140%;
    height: 50%;
    opacity: 0;
    transition: opacity 1.2s ease;
    z-index: 0;
    background:
        conic-gradient(from 45deg at 25% 25%, var(--aged-parchment) 0deg, var(--marble-cream) 90deg, var(--aged-parchment) 180deg, var(--marble-cream) 270deg, var(--aged-parchment) 360deg),
        conic-gradient(from 45deg at 75% 25%, var(--marble-cream) 0deg, var(--aged-parchment) 90deg, var(--marble-cream) 180deg, var(--aged-parchment) 270deg, var(--marble-cream) 360deg),
        conic-gradient(from 45deg at 25% 75%, var(--marble-cream) 0deg, var(--aged-parchment) 90deg, var(--marble-cream) 180deg, var(--aged-parchment) 270deg, var(--marble-cream) 360deg),
        conic-gradient(from 45deg at 75% 75%, var(--aged-parchment) 0deg, var(--marble-cream) 90deg, var(--aged-parchment) 180deg, var(--marble-cream) 270deg, var(--aged-parchment) 360deg);
    background-size: 50% 50%;
    background-repeat: repeat;
    mask-image: linear-gradient(to top, rgba(0,0,0,0.3) 0%, transparent 80%);
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,0.3) 0%, transparent 80%);
}

.marble-floor.visible {
    opacity: 0.15;
}

.vestibule-content {
    position: relative;
    z-index: 2;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Logotype */
.logotype {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: clamp(3.5rem, 9vw, 8rem);
    color: var(--ink-umber);
    letter-spacing: -0.02em;
    line-height: 1;
    display: flex;
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
}

.letter.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
    transition-delay: calc(var(--delay) * 80ms + 600ms);
}

/* Gold line */
.gold-line {
    width: 120px;
    height: 2px;
    background: var(--palazzo-gold);
    margin: 24px 0 20px;
    transform: scaleX(0);
    transform-origin: center;
}

.gold-line.visible {
    transform: scaleX(1);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transition-delay: 1.4s;
}

/* Tagline */
.tagline {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.85rem, 1.4vw, 1.1rem);
    letter-spacing: 0.03em;
    color: var(--gallery-stone);
    opacity: 0;
    max-width: 500px;
}

.tagline.visible {
    opacity: 1;
    transition: opacity 0.5s ease;
    transition-delay: 1.8s;
}

/* ============================================
   SECTIONS 1-4 - GALLERY CHAMBERS
   ============================================ */
.section-gallery {
    background: var(--aged-parchment);
    padding: 64px;
}

/* Alternate section backgrounds */
#section2 {
    background-color: var(--marble-cream);
}

#section3 {
    background-color: var(--aged-parchment);
}

#section4 {
    background-color: var(--marble-cream);
}

/* Marble Columns */
.marble-column {
    position: absolute;
    top: 10%;
    width: 4px;
    height: 70%;
    border-radius: 2px;
    z-index: 2;
    background: linear-gradient(180deg,
        var(--aged-parchment) 0%,
        var(--marble-cream) 25%,
        var(--vein-shadow) 50%,
        var(--marble-cream) 75%,
        var(--aged-parchment) 100%
    );
    box-shadow: 2px 0 8px rgba(0,0,0,0.06);
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.marble-column-left {
    left: 24px;
    transform: translateX(-20px);
}

.marble-column-right {
    right: 24px;
    transform: translateX(20px);
}

.marble-column.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Gallery Split Layout (2-column) */
.gallery-split {
    display: flex;
    align-items: center;
    gap: 48px;
    width: 100%;
    max-width: 1100px;
    position: relative;
    z-index: 3;
}

.gallery-left {
    flex: 0 0 40%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-right {
    flex: 0 0 55%;
}

.gallery-text-left {
    flex: 0 0 55%;
}

/* Inverted layout */
.gallery-split-inverted {
    flex-direction: row-reverse;
}

/* Marble Bust SVGs */
.marble-bust {
    width: 100%;
    max-width: 280px;
    height: auto;
}

/* Section Headings */
.section-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--ink-umber);
    letter-spacing: -0.02em;
    margin-bottom: 24px;
    line-height: 1.15;
}

/* Section Body */
.section-body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: var(--ink-umber);
    line-height: 1.72;
    letter-spacing: 0.01em;
    margin-bottom: 20px;
}

/* Section Captions */
.section-caption {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.85rem, 1.4vw, 1.1rem);
    letter-spacing: 0.03em;
    color: var(--gallery-stone);
}

/* --- Animate In --- */
.animate-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    transition-delay: var(--anim-delay, 0ms);
}

.animate-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.animate-in-card {
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition-delay: var(--anim-delay, 0ms);
}

.animate-in-card.visible {
    opacity: 1;
    transform: scale(1) translateY(var(--card-offset, 0px));
}

/* ============================================
   SECTION 3 - CARD FOCAL
   ============================================ */
.card-focal-content {
    position: relative;
    z-index: 3;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 800px;
}

/* ============================================
   CARD FLIP ELEMENTS
   ============================================ */
.card-flip-container {
    perspective: 1200px;
    width: 320px;
    height: 420px;
    cursor: pointer;
}

.card-flip {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-flip.flipped {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 8px;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Card Front */
.card-front {
    background: var(--aged-parchment);
    border: 1px solid var(--vein-shadow);
    box-shadow: 0 8px 32px rgba(42,37,32,0.15);
    /* Paper texture on front */
    background-image:
        radial-gradient(ellipse at center, transparent 40%, rgba(196,184,164,0.1) 100%),
        linear-gradient(137deg, rgba(196,184,164,0.03) 0%, transparent 50%);
    background-color: var(--aged-parchment);
}

.card-heading {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1.35rem;
    color: var(--ink-umber);
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}

.card-description {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--ink-umber);
    line-height: 1.72;
    letter-spacing: 0.01em;
    margin-bottom: 20px;
}

.card-caption {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    color: var(--gallery-stone);
    margin-top: auto;
}

/* Card Back */
.card-back {
    background: var(--venetian-rose);
    transform: rotateY(180deg);
    box-shadow: 0 8px 32px rgba(42,37,32,0.15);
    align-items: center;
    text-align: center;
    border-radius: 8px;
}

.card-back-quote {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--warm-ivory);
    line-height: 1.5;
    margin-bottom: 20px;
}

.card-back-attribution {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 0.9rem;
    color: rgba(240, 232, 219, 0.75);
    letter-spacing: 0.03em;
}

/* Card flip shadow animation */
.card-flip-container:hover .card-flip,
.card-flip.flipped {
    box-shadow: none;
}

.card-front {
    transition: box-shadow 0.35s ease;
}

.card-flip-container:hover .card-front {
    box-shadow: 0 16px 48px rgba(42,37,32,0.2);
}

/* Dopamine brightness flash on reveal */
.card-back.flash {
    filter: brightness(1.15);
    transition: filter 0.2s ease;
}

.card-back.no-flash {
    filter: brightness(1);
    transition: filter 0.3s ease;
}

/* ============================================
   SECTION 4 - THREE CARDS ROW
   ============================================ */
.cards-row-content {
    position: relative;
    z-index: 3;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1100px;
}

.cards-row {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.cards-row .card-flip-container {
    transform: translateY(var(--card-offset, 0px));
}

.cards-row .animate-in-card.visible {
    transform: scale(1) translateY(var(--card-offset, 0px));
}

/* ============================================
   SECTION 5 - THE ARCHIVE
   ============================================ */
.section-archive {
    background-color: var(--aged-parchment);
    background-image:
        linear-gradient(137deg, rgba(196,184,164,0.04) 0%, transparent 50%),
        linear-gradient(251deg, rgba(196,184,164,0.06) 0%, transparent 60%);
    padding: 0;
}

.archive-frame {
    position: relative;
    z-index: 3;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 64px 24px;
    overflow: hidden;
}

.archive-scroll {
    max-width: 680px;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 0 16px 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--vein-shadow) transparent;
}

.archive-scroll::-webkit-scrollbar {
    width: 6px;
}

.archive-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.archive-scroll::-webkit-scrollbar-thumb {
    background: var(--vein-shadow);
    border-radius: 3px;
}

.archive-content p {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    color: var(--ink-umber);
    line-height: 1.72;
    letter-spacing: 0.01em;
    margin-bottom: 24px;
}

.archive-epigraph {
    font-family: 'Cormorant Garamond', serif !important;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 1.6vw, 1.15rem) !important;
    color: var(--gallery-stone) !important;
    letter-spacing: 0.03em !important;
    border-left: 2px solid var(--palazzo-gold);
    padding-left: 20px;
    margin-bottom: 32px !important;
}

.archive-closing {
    font-family: 'Cormorant Garamond', serif !important;
    font-weight: 400;
    font-style: italic;
    color: var(--gallery-stone) !important;
    letter-spacing: 0.03em !important;
    margin-top: 16px;
}

/* ============================================
   SECTION 6 - THE CIPHER (Footer)
   ============================================ */
.section-cipher {
    background: var(--burnt-umber-dark);
    flex-direction: column;
}

.section-cipher::before {
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.15) 100%);
}

.cipher-content {
    position: relative;
    z-index: 3;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cipher-marble-motif {
    width: 80px;
    height: auto;
    margin-bottom: 40px;
    opacity: 0.6;
}

.cipher-phrase {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--palazzo-gold);
    letter-spacing: 0.03em;
    line-height: 1.8;
    margin-bottom: 32px;
}

.cipher-sign {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--gallery-stone);
    letter-spacing: 0.04em;
    opacity: 0.6;
}

/* ============================================
   NAVIGATION DOTS
   ============================================ */
.nav-dots {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-dots.visible {
    opacity: 1;
}

.nav-dot {
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.dot-inner {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-image:
        linear-gradient(137deg, rgba(196,184,164,0.3) 0%, transparent 50%),
        linear-gradient(251deg, rgba(196,184,164,0.4) 0%, transparent 60%);
    background-color: var(--marble-cream);
    border: 1.5px solid var(--vein-shadow);
    transition: all 0.3s ease;
    position: relative;
}

.nav-dot.active .dot-inner {
    border-color: var(--palazzo-gold);
    box-shadow: 0 0 0 2px var(--palazzo-gold);
}

/* Dopamine pulse on activation */
@keyframes dotPulse {
    0% { box-shadow: 0 0 0 2px var(--palazzo-gold), 0 0 0 2px rgba(212,168,83,0.4); }
    100% { box-shadow: 0 0 0 2px var(--palazzo-gold), 0 0 0 14px rgba(212,168,83,0); }
}

.nav-dot.pulse .dot-inner {
    animation: dotPulse 0.6s ease-out;
}

/* ============================================
   RESPONSIVE - Below 768px
   ============================================ */
@media (max-width: 768px) {
    .section-gallery {
        padding: 32px 24px;
    }

    .gallery-split,
    .gallery-split-inverted {
        flex-direction: column;
        gap: 32px;
    }

    .gallery-left,
    .gallery-right,
    .gallery-text-left {
        flex: none;
        width: 100%;
    }

    .gallery-left {
        order: -1;
    }

    .marble-bust {
        max-width: 180px;
    }

    .marble-column {
        display: none;
    }

    .marble-floor {
        transform: translateX(-50%) perspective(800px) rotateX(45deg);
    }

    /* Cards stack vertically */
    .cards-row {
        flex-direction: column;
        align-items: center;
        gap: 24px;
    }

    .card-flip-container {
        width: calc(100% - 48px);
        max-width: 320px;
        height: auto;
        min-height: 380px;
    }

    .cards-row .card-flip-container {
        transform: none !important;
    }

    .cards-row .animate-in-card.visible {
        transform: scale(1) translateY(0) !important;
    }

    /* Nav dots horizontal at bottom */
    .nav-dots {
        right: auto;
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
    }

    .archive-frame {
        padding: 32px 16px;
    }

    .archive-scroll {
        padding: 0 8px 32px;
    }
}

/* ============================================
   WATER STAIN / PATINA MARKS
   ============================================ */
.section-vestibule::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 15% 30%, rgba(196,184,164,0.02) 0%, transparent 40%),
        radial-gradient(circle at 80% 60%, rgba(196,184,164,0.02) 0%, transparent 35%),
        radial-gradient(circle at 50% 85%, rgba(196,184,164,0.02) 0%, transparent 30%);
}

#section1::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 25% 20%, rgba(196,184,164,0.02) 0%, transparent 35%),
        radial-gradient(circle at 70% 70%, rgba(196,184,164,0.02) 0%, transparent 40%),
        radial-gradient(circle at 45% 50%, rgba(196,184,164,0.02) 0%, transparent 30%),
        radial-gradient(circle at 90% 30%, rgba(196,184,164,0.02) 0%, transparent 25%);
}

#section2::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 10% 60%, rgba(196,184,164,0.02) 0%, transparent 38%),
        radial-gradient(circle at 85% 25%, rgba(196,184,164,0.02) 0%, transparent 32%),
        radial-gradient(circle at 55% 80%, rgba(196,184,164,0.02) 0%, transparent 28%);
}

#section3::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 30% 40%, rgba(196,184,164,0.02) 0%, transparent 36%),
        radial-gradient(circle at 75% 20%, rgba(196,184,164,0.02) 0%, transparent 30%),
        radial-gradient(circle at 50% 70%, rgba(196,184,164,0.02) 0%, transparent 34%),
        radial-gradient(circle at 15% 85%, rgba(196,184,164,0.02) 0%, transparent 26%);
}

#section4::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 20% 50%, rgba(196,184,164,0.02) 0%, transparent 40%),
        radial-gradient(circle at 65% 30%, rgba(196,184,164,0.02) 0%, transparent 33%),
        radial-gradient(circle at 80% 75%, rgba(196,184,164,0.02) 0%, transparent 28%);
}
