/* ============================================================
   ppuzzl.net - Victorian Noir Cabinet of Curiosities
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --dopamine-pink: #FF1493;
    --absinthe-green: #39FF14;
    --obsidian: #1C1520;
    --marble-vein: #3D3347;
    --gaslight-gold: #C5A55A;
    --parchment-mist: #E8DFD0;
    --bruise-purple: #4A1942;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--obsidian);
    color: var(--parchment-mist);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(17px, 1.6vw, 20px);
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Grid Overlay (infrastructure beneath Victorian ornament) --- */
#grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(8, 1fr);
    pointer-events: none;
    z-index: 1;
}

#grid-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            to right,
            rgba(255, 20, 147, 0.04) 0px,
            rgba(255, 20, 147, 0.04) 1px,
            transparent 1px,
            transparent calc(100% / 12)
        ),
        repeating-linear-gradient(
            to bottom,
            rgba(255, 20, 147, 0.04) 0px,
            rgba(255, 20, 147, 0.04) 1px,
            transparent 1px,
            transparent calc(100% / 8)
        );
}

/* --- Vault Door Section --- */
#vault-door {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--obsidian);
    z-index: 100;
    transition: opacity 0.3s ease;
}

#vault-door.opened {
    pointer-events: none;
}

#vault-rings {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vault-ring {
    position: absolute;
    pointer-events: none;
}

#ring-1 {
    width: min(90vw, 90vh);
    height: min(90vw, 90vh);
    animation: rotateClockwise 60s linear infinite;
}

#ring-2 {
    width: min(68vw, 68vh);
    height: min(68vw, 68vh);
    animation: rotateCounterClockwise 45s linear infinite;
}

#ring-3 {
    width: min(46vw, 46vh);
    height: min(46vw, 46vh);
    animation: rotateClockwise 80s linear infinite;
}

@keyframes rotateClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes rotateCounterClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

/* Vault opening animation */
.vault-ring.opening {
    animation-play-state: paused;
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: scale(2.5) !important;
    opacity: 0 !important;
}

/* Staggered delays for each ring */
#ring-1.opening {
    transition-delay: 0s;
}

#ring-2.opening {
    transition-delay: 0.15s;
}

#ring-3.opening {
    transition-delay: 0.3s;
}

/* --- Vault Wordmark --- */
#vault-wordmark {
    position: relative;
    z-index: 101;
    text-align: center;
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(32px, 5vw, 64px);
    letter-spacing: 0.2em;
    color: var(--parchment-mist);
    transition: transform 1s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.8s ease;
}

#vault-wordmark.transitioning {
    transform: translateY(-45vh) scale(0.5);
    opacity: 0;
}

.wordmark-dot {
    color: var(--dopamine-pink);
}

.wordmark-ext {
    color: var(--gaslight-gold);
    font-size: 0.6em;
}

/* --- Page Header --- */
#page-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px 40px;
    z-index: 50;
    background: linear-gradient(to bottom, var(--obsidian) 0%, rgba(28, 21, 32, 0.95) 60%, transparent 100%);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    pointer-events: none;
}

#page-header.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.header-wordmark {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(16px, 2vw, 24px);
    letter-spacing: 0.15em;
    color: var(--parchment-mist);
    text-transform: uppercase;
}

.header-dot {
    color: var(--dopamine-pink);
}

/* --- Cabinet Grid Section --- */
#cabinet-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 80px 24px 40px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}

#cabinet-grid.revealed {
    opacity: 1;
}

/* --- Cabinet Drawer Base --- */
.cabinet-drawer {
    perspective: 1200px;
    cursor: pointer;
    min-height: 260px;
}

.cabinet-drawer.span-2x1 {
    grid-column: span 2;
}

.cabinet-drawer.span-1x2 {
    grid-row: span 2;
}

.cabinet-drawer.span-2x2 {
    grid-column: span 2;
    grid-row: span 2;
}

.drawer-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 260px;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.cabinet-drawer.flipped .drawer-inner {
    transform: rotateY(180deg);
}

/* Flip pulse glow */
.cabinet-drawer.flipping .drawer-inner {
    animation: flipPulse 0.5s ease-in-out;
}

@keyframes flipPulse {
    0% { box-shadow: 0 0 0 rgba(255, 20, 147, 0); }
    50% { box-shadow: 0 0 30px rgba(255, 20, 147, 0.3); }
    100% { box-shadow: 0 0 0 rgba(255, 20, 147, 0); }
}

/* --- Drawer Faces --- */
.drawer-front,
.drawer-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    padding: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;

    /* Marble texture */
    background:
        linear-gradient(135deg, #1C1520 0%, #3D3347 50%, #1C1520 100%);
    border: 1px solid rgba(197, 165, 90, 0.15);
}

.drawer-front::before,
.drawer-back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.15;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='f'%3E%3CfeTurbulence baseFrequency='0.02' numOctaves='4' type='fractalNoise' /%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23f)' /%3E%3C/svg%3E");
    background-size: cover;
    pointer-events: none;
}

.drawer-back {
    transform: rotateY(180deg);
    background:
        linear-gradient(315deg, #1C1520 0%, #4A1942 40%, #1C1520 100%);
}

/* --- Drawer hover --- */
.cabinet-drawer:hover .drawer-front,
.cabinet-drawer:hover .drawer-back {
    border-color: rgba(255, 20, 147, 0.25);
}

.cabinet-drawer:hover .corner-bracket {
    transform: scale(1.15);
}

/* --- Corner Brackets --- */
.corner-bracket {
    position: absolute;
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.corner-bracket::before,
.corner-bracket::after {
    content: '';
    position: absolute;
    background-color: var(--gaslight-gold);
}

.corner-bracket.top-left {
    top: 8px;
    left: 8px;
}
.corner-bracket.top-left::before {
    top: 0;
    left: 0;
    width: 1px;
    height: 20px;
}
.corner-bracket.top-left::after {
    top: 0;
    left: 0;
    width: 20px;
    height: 1px;
}

.corner-bracket.top-right {
    top: 8px;
    right: 8px;
}
.corner-bracket.top-right::before {
    top: 0;
    right: 0;
    width: 1px;
    height: 20px;
}
.corner-bracket.top-right::after {
    top: 0;
    right: 0;
    width: 20px;
    height: 1px;
}

.corner-bracket.bottom-left {
    bottom: 8px;
    left: 8px;
}
.corner-bracket.bottom-left::before {
    bottom: 0;
    left: 0;
    width: 1px;
    height: 20px;
}
.corner-bracket.bottom-left::after {
    bottom: 0;
    left: 0;
    width: 20px;
    height: 1px;
}

.corner-bracket.bottom-right {
    bottom: 8px;
    right: 8px;
}
.corner-bracket.bottom-right::before {
    bottom: 0;
    right: 0;
    width: 1px;
    height: 20px;
}
.corner-bracket.bottom-right::after {
    bottom: 0;
    right: 0;
    width: 20px;
    height: 1px;
}

/* --- Drawer Typography --- */
.drawer-numeral {
    font-family: 'MedievalSharp', cursive;
    font-size: clamp(48px, 5vw, 72px);
    color: var(--gaslight-gold);
    opacity: 0.15;
    position: absolute;
    top: 16px;
    right: 24px;
    line-height: 1;
}

.drawer-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(20px, 3vw, 36px);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--parchment-mist);
    margin-bottom: 12px;
}

.drawer-teaser {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(15px, 1.4vw, 18px);
    color: var(--gaslight-gold);
    line-height: 1.6;
    opacity: 0.7;
}

.drawer-back-title {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(16px, 2vw, 24px);
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--absinthe-green);
    margin-bottom: 16px;
}

.drawer-content {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: clamp(15px, 1.4vw, 18px);
    color: var(--parchment-mist);
    line-height: 1.7;
    opacity: 0.9;
}

/* --- Cipher Footer --- */
#cipher-footer {
    position: relative;
    z-index: 2;
    padding: 60px 24px 40px;
    text-align: center;
}

.footer-cipher-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
}

.cipher-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 18px;
    color: var(--gaslight-gold);
    border: 1px solid rgba(197, 165, 90, 0.2);
    background: rgba(61, 51, 71, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.cipher-char:hover {
    color: var(--absinthe-green);
    border-color: var(--absinthe-green);
    background: rgba(57, 255, 20, 0.05);
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.5);
}

.cipher-char.revealed {
    color: var(--absinthe-green);
    border-color: rgba(57, 255, 20, 0.3);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.4);
}

.footer-decoded {
    opacity: 0;
    transition: opacity 0.8s ease;
    margin-bottom: 24px;
}

.footer-decoded.visible {
    opacity: 1;
}

.footer-text {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(14px, 1.5vw, 18px);
    letter-spacing: 0.15em;
    color: var(--parchment-mist);
    margin-bottom: 8px;
}

.footer-subtext {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(14px, 1.3vw, 17px);
    color: var(--gaslight-gold);
    opacity: 0.6;
}

.footer-ornament {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.footer-divider {
    width: 200px;
    height: 20px;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    #cabinet-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 80px 16px 32px;
    }

    .cabinet-drawer.span-2x2 {
        grid-column: span 2;
        grid-row: span 2;
    }
}

@media (max-width: 600px) {
    #cabinet-grid {
        grid-template-columns: 1fr;
        padding: 72px 12px 24px;
    }

    .cabinet-drawer.span-2x1,
    .cabinet-drawer.span-2x2 {
        grid-column: span 1;
    }

    .cabinet-drawer.span-1x2,
    .cabinet-drawer.span-2x2 {
        grid-row: span 1;
    }

    .cabinet-drawer {
        min-height: 220px;
    }

    .drawer-inner {
        min-height: 220px;
    }

    #vault-wordmark {
        font-size: clamp(24px, 8vw, 40px);
    }

    .footer-cipher-row {
        gap: 6px;
    }

    .cipher-char {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--obsidian);
}

::-webkit-scrollbar-thumb {
    background: var(--marble-vein);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gaslight-gold);
}

/* --- Selection --- */
::selection {
    background: rgba(255, 20, 147, 0.3);
    color: var(--parchment-mist);
}
