/* ============================================
   RRIDDL.com - Art Deco Gilded Puzzle Box
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Jewel-Tone Palette */
    --midnight-sapphire: #0d1b3e;
    --imperial-emerald: #0a3d2e;
    --burnished-gold: #c9a84c;
    --ruby-flash: #9b1b30;
    --amethyst-veil: #3d1f56;
    --ivory-whisper: #f5f0e8;
    --topaz-glow: #d4a017;
    --onyx-deep: #0a0a0f;

    /* Typography */
    --font-display: 'Poiret One', sans-serif;
    --font-secondary: 'Cormorant Garamond', serif;
    --font-body: 'Josefin Sans', sans-serif;

    /* Diagonal angle */
    --diagonal-angle: 7deg;
    --section-overlap: 4vw;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--onyx-deep);
    color: var(--ivory-whisper);
    font-family: var(--font-body);
    font-weight: 300;
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Gold Star Background Pattern (inline SVG data URI) --- */
.star-pattern {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpolygon points='20,16 21.2,19.2 24.5,19.2 21.8,21.2 22.8,24.5 20,22.5 17.2,24.5 18.2,21.2 15.5,19.2 18.8,19.2' fill='%23c9a84c' opacity='0.05'/%3E%3C/svg%3E");
    background-repeat: repeat;
    pointer-events: none;
    z-index: 0;
}

/* --- Diamond Lattice Pattern --- */
.diamond-lattice {
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 28px,
            rgba(201, 168, 76, 0.08) 28px,
            rgba(201, 168, 76, 0.08) 29px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 28px,
            rgba(201, 168, 76, 0.08) 28px,
            rgba(201, 168, 76, 0.08) 29px
        );
    pointer-events: none;
    z-index: 0;
}

/* --- Diamond Navigation --- */
#diamond-nav {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 18px;
    z-index: 1000;
}

.diamond-dot {
    width: 10px;
    height: 10px;
    border: 1px solid var(--burnished-gold);
    background: transparent;
    transform: rotate(45deg);
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.diamond-dot.active {
    background-color: var(--burnished-gold);
    transform: rotate(45deg) scale(1.3);
}

.diamond-dot:hover {
    background-color: var(--topaz-glow);
    transform: rotate(45deg) scale(1.2);
}

/* --- Chamber Base Styles --- */
.chamber {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chamber[data-bg="sapphire"] {
    background: linear-gradient(var(--diagonal-angle), var(--midnight-sapphire), #0f2248);
    clip-path: polygon(0 0, 100% var(--section-overlap), 100% calc(100% - var(--section-overlap)), 0 100%);
}

.chamber[data-bg="emerald"] {
    background: linear-gradient(var(--diagonal-angle), var(--imperial-emerald), #0d4a36);
    clip-path: polygon(0 var(--section-overlap), 100% 0, 100% 100%, 0 calc(100% - var(--section-overlap)));
}

.chamber[data-bg="amethyst"] {
    background: linear-gradient(var(--diagonal-angle), var(--amethyst-veil), #4a2568);
    clip-path: polygon(0 0, 100% var(--section-overlap), 100% calc(100% - var(--section-overlap)), 0 100%);
}

.chamber[data-bg="deep"] {
    background: linear-gradient(var(--diagonal-angle), var(--midnight-sapphire), var(--onyx-deep));
    clip-path: polygon(0 var(--section-overlap), 100% 0, 100% 100%, 0 100%);
}

.chamber + .diagonal-connector + .chamber {
    margin-top: calc(var(--section-overlap) * -2);
}

.chamber-inner {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 8vh 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Hero Chamber --- */
.hero-chamber {
    background: var(--onyx-deep);
    clip-path: none;
    flex-direction: column;
    transition: background-color 0.6s ease;
}

.hero-chamber.revealed {
    background: var(--midnight-sapphire);
}

/* Chevron Container */
.chevron-container {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1000px;
    z-index: 1;
    opacity: 0;
}

.chevron-container.animate {
    opacity: 1;
}

.chevron-svg {
    width: 100%;
    height: auto;
}

#chevron-path {
    stroke-dasharray: 2500;
    stroke-dashoffset: 2500;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.chevron-container.animate #chevron-path {
    stroke-dashoffset: 0;
}

/* Sunburst */
.sunburst-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 60vmin;
    height: 60vmin;
    z-index: 0;
    opacity: 0;
    transition: transform 2s ease-out, opacity 0.8s ease;
}

.sunburst-container.animate {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.sunburst-svg {
    width: 100%;
    height: 100%;
}

.section-sunburst {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 40vmin;
    height: 40vmin;
    z-index: 0;
    opacity: 0;
    transition: transform 2s ease-out, opacity 0.8s ease;
}

.section-sunburst.animate {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.sunburst-svg.small {
    width: 100%;
    height: 100%;
}

/* Hero Content */
.hero-content {
    position: relative;
    z-index: 5;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 8vw, 7rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.6em;
    color: var(--burnished-gold);
    opacity: 0;
    transition: opacity 0.8s ease, letter-spacing 0.8s ease;
}

.hero-title.animate {
    opacity: 1;
    letter-spacing: 0.2em;
}

.hero-tagline {
    font-family: var(--font-secondary);
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    font-weight: 300;
    letter-spacing: 0.05em;
    color: var(--ivory-whisper);
    opacity: 0.85;
}

.tagline-letter {
    opacity: 0;
    display: inline-block;
    transition: opacity 0.15s ease;
}

.tagline-letter.visible {
    opacity: 1;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 3vh;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0;
    animation: fadeInScroll 0.5s ease 4s forwards;
    z-index: 5;
}

@keyframes fadeInScroll {
    to { opacity: 0.6; }
}

.scroll-diamond {
    width: 8px;
    height: 8px;
    border: 1px solid var(--burnished-gold);
    transform: rotate(45deg);
    animation: pulseDiamond 2s ease-in-out infinite;
}

@keyframes pulseDiamond {
    0%, 100% { transform: rotate(45deg) scale(1); opacity: 0.6; }
    50% { transform: rotate(45deg) scale(1.3); opacity: 1; }
}

.scroll-line {
    width: 1px;
    height: 30px;
    background: linear-gradient(to bottom, var(--burnished-gold), transparent);
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0%, 100% { height: 30px; }
    50% { height: 45px; }
}

/* --- Diagonal Connectors --- */
.diagonal-connector {
    position: relative;
    height: 80px;
    margin-top: calc(var(--section-overlap) * -2);
    z-index: 10;
    pointer-events: none;
}

.connector-svg {
    width: 100%;
    height: 100%;
}

.connector-line {
    stroke-dasharray: 1300;
    stroke-dashoffset: 1300;
    transition: stroke-dashoffset 1s ease;
}

.connector-line.drawn {
    stroke-dashoffset: 0;
}

.connector-diamond {
    opacity: 0;
    transition: opacity 0.3s ease 0.8s;
}

.connector-line.drawn + .connector-diamond,
.connector-line.drawn ~ .connector-diamond {
    opacity: 1;
}

/* --- Chamber Titles --- */
.chamber-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 3.5rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--burnished-gold);
    margin-bottom: 3rem;
    position: relative;
    z-index: 3;
    text-align: center;
}

/* --- Flip Card --- */
.flip-card {
    perspective: 1200px;
    width: 100%;
    max-width: 680px;
    min-height: 420px;
    cursor: pointer;
    position: relative;
    z-index: 3;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    min-height: 420px;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-style: preserve-3d;
    will-change: transform;
}

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

.flip-card-front,
.flip-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border: 1px solid var(--burnished-gold);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Card Back - Ornate Art Deco Pattern */
.flip-card-back {
    background: var(--amethyst-veil);
    z-index: 2;
}

.card-pattern {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.pattern-diamond {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%) rotate(45deg);
    border: 1px solid var(--burnished-gold);
    opacity: 0.6;
}

.pattern-diamond::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140px;
    height: 140px;
    transform: translate(-50%, -50%);
    border: 1px solid var(--burnished-gold);
    opacity: 0.5;
}

.pattern-diamond::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    transform: translate(-50%, -50%);
    border: 1px solid var(--burnished-gold);
    opacity: 0.4;
}

.pattern-chevrons {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            30deg,
            transparent,
            transparent 30px,
            rgba(201, 168, 76, 0.1) 30px,
            rgba(201, 168, 76, 0.1) 31px
        ),
        repeating-linear-gradient(
            -30deg,
            transparent,
            transparent 30px,
            rgba(201, 168, 76, 0.1) 30px,
            rgba(201, 168, 76, 0.1) 31px
        ),
        repeating-linear-gradient(
            150deg,
            transparent,
            transparent 30px,
            rgba(201, 168, 76, 0.1) 30px,
            rgba(201, 168, 76, 0.1) 31px
        ),
        repeating-linear-gradient(
            -150deg,
            transparent,
            transparent 30px,
            rgba(201, 168, 76, 0.1) 30px,
            rgba(201, 168, 76, 0.1) 31px
        );
}

.pattern-corners {
    position: absolute;
    inset: 0;
}

.pattern-corners::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at 0 0, rgba(201, 168, 76, 0.15) 0%, transparent 70%);
}

.pattern-corners::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at 100% 100%, rgba(201, 168, 76, 0.15) 0%, transparent 70%);
}

/* Card corner ornaments */
.flip-card-back::before {
    content: '';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 100% 0, rgba(201, 168, 76, 0.2) 0%, transparent 70%);
    z-index: 3;
}

.flip-card-back::after {
    content: '';
    position: absolute;
    bottom: 12px;
    left: 12px;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 0 100%, rgba(201, 168, 76, 0.2) 0%, transparent 70%);
    z-index: 3;
}

/* Card Front */
.flip-card-front {
    background: linear-gradient(var(--diagonal-angle), rgba(13, 27, 62, 0.95), rgba(10, 61, 46, 0.95));
    transform: rotateY(180deg);
    gap: 1.5rem;
}

.flip-card-front h3 {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 3vw, 2.2rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--burnished-gold);
}

.flip-card-front p {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1.5vw, 1.05rem);
    font-weight: 300;
    line-height: 1.75;
    color: var(--ivory-whisper);
    max-width: 520px;
}

.card-ornament {
    width: 60px;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--burnished-gold), transparent);
    margin-top: 0.5rem;
}

/* --- Keystone Quote --- */
.keystone-quote {
    clip-path: polygon(5% 0, 95% 0, 100% 100%, 0 100%);
    background: rgba(201, 168, 76, 0.08);
    border: 1px solid rgba(201, 168, 76, 0.25);
    padding: 1.5rem 2.5rem;
    margin-top: 1rem;
}

.keystone-quote p {
    font-family: var(--font-secondary);
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.05em;
    color: var(--burnished-gold);
    max-width: none;
}

.final-quote {
    margin-top: 1.5rem;
}

/* --- Gallery Corridor --- */
.gallery-row {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: 1000px;
}

.gallery-card {
    flex: 0 1 220px;
    min-height: 280px;
    border: 1px solid var(--burnished-gold);
    background: rgba(10, 10, 15, 0.5);
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.gallery-card[data-stagger="1"] {
    margin-top: 30px;
    transform: translateX(60px);
}

.gallery-card[data-stagger="2"] {
    margin-top: 60px;
    transform: translateX(-60px);
}

.gallery-card[data-stagger="3"] {
    margin-top: 90px;
    transform: translateX(60px);
}

.gallery-card.visible {
    opacity: 1;
    transform: translateX(0);
}

.gallery-card[data-stagger="1"].visible {
    transform: translateX(0);
    margin-top: 30px;
}

.gallery-card[data-stagger="2"].visible {
    transform: translateX(0);
    margin-top: 60px;
}

.gallery-card[data-stagger="3"].visible {
    transform: translateX(0);
    margin-top: 90px;
}

.gallery-card-inner {
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
    height: 100%;
}

.gallery-card-icon {
    width: 60px;
    height: 60px;
}

.gallery-card-icon svg {
    width: 100%;
    height: 100%;
}

.gallery-card h3 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--burnished-gold);
}

.gallery-card p {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 300;
    line-height: 1.7;
    color: var(--ivory-whisper);
    opacity: 0.85;
}

/* Gallery card hover */
.gallery-card:hover {
    background: rgba(201, 168, 76, 0.05);
    border-color: var(--topaz-glow);
}

/* --- Stepped Border --- */
.stepped-border-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    z-index: 5;
}

.stepped-svg {
    width: 100%;
    height: 100%;
}

.stepped-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease;
}

.stepped-path.drawn {
    stroke-dashoffset: 0;
}

/* --- Opening Animation Overlay --- */
body.loading {
    overflow: hidden;
}

body.loading .hero-chamber {
    background: var(--onyx-deep);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    #diamond-nav {
        right: 12px;
        gap: 14px;
    }

    .diamond-dot {
        width: 8px;
        height: 8px;
    }

    .chamber-inner {
        padding: 6vh 1.2rem;
    }

    .gallery-row {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .gallery-card {
        flex: 0 1 auto;
        width: 100%;
        max-width: 320px;
        min-height: auto;
    }

    .gallery-card[data-stagger="1"],
    .gallery-card[data-stagger="2"],
    .gallery-card[data-stagger="3"] {
        margin-top: 0;
    }

    .gallery-card[data-stagger="1"].visible,
    .gallery-card[data-stagger="2"].visible,
    .gallery-card[data-stagger="3"].visible {
        margin-top: 0;
    }

    .flip-card {
        min-height: 360px;
    }

    .flip-card-inner {
        min-height: 360px;
    }

    .flip-card-front {
        padding: 2rem 1.5rem;
    }

    .flip-card-back {
        padding: 2rem 1.5rem;
    }

    .keystone-quote {
        padding: 1rem 1.5rem;
    }

    .hero-title {
        letter-spacing: 0.4em;
    }

    .hero-title.animate {
        letter-spacing: 0.15em;
    }

    .chevron-container {
        width: 95%;
    }

    .diagonal-connector {
        height: 50px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(1.8rem, 10vw, 3.5rem);
    }

    .chamber-title {
        font-size: clamp(1.2rem, 5vw, 2rem);
    }

    .gallery-card {
        flex: 0 1 auto;
        min-height: auto;
    }
}
