/* ppuzzl.net - Chrome Puzzle Box Aesthetic */

:root {
    --polished-silver: #d4d6dc;
    --gun-metal: #2c2f33;
    --titanium-gold: #b8a88a;
    --steel-blue: #7b8fa1;
    --chromatic-magenta: #c77dba;
    --chromatic-cyan: #7dbac7;
    --graphite-black: #18191b;
    --matte-platinum: #e8e9ec;
    --block-border: 1px solid rgba(212, 214, 220, 0.15);
    --chrome-gradient: linear-gradient(135deg, #2c2f33 0%, #d4d6dc 40%, #7b8fa1 60%, #d4d6dc 80%, #2c2f33 100%);
    --iridescent-gradient: linear-gradient(90deg, #c77dba, #7dbac7, #b8a88a);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--graphite-black);
    color: var(--matte-platinum);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 1.125rem;
    line-height: 1.7;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    min-height: 100vh;
}

/* ===== PUZZLE BOARD GRID ===== */
#puzzle-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: minmax(200px, auto);
    max-width: 1200px;
    margin: 0 auto;
    padding: 2px;
    position: relative;
}

/* ===== BLOCKS BASE ===== */
.block {
    position: relative;
    border: var(--block-border);
    overflow: hidden;
    opacity: 0;
    transform: translate(var(--entry-x, 0), var(--entry-y, 0)) rotate(var(--entry-r, 0deg)) scale(var(--entry-s, 0.8));
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.block.assembled {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
}

.block.dissolving {
    transition: transform 1.5s cubic-bezier(0.22, 1, 0.36, 1), opacity 1.5s ease;
}

/* Grid placement */
.block[data-w="2"] { grid-column: span 2; }
.block[data-w="3"] { grid-column: span 3; }
.block[data-w="4"] { grid-column: span 4; }
.block[data-h="2"] { grid-row: span 2; }
.block[data-h="3"] { grid-row: span 3; }

/* Chrome border flash on assembly complete */
@keyframes border-flash {
    0% { border-color: rgba(212, 214, 220, 0.15); }
    50% { border-color: rgba(212, 214, 220, 0.8); }
    100% { border-color: rgba(212, 214, 220, 0.15); }
}

.block.flash-border {
    animation: border-flash 0.4s ease-out;
}

/* ===== HEADER BLOCK ===== */
.block-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--graphite-black);
    min-height: 120px;
}

#wordmark {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.wordmark-text {
    font-family: 'Archivo Black', sans-serif;
    font-size: 64px;
    fill: none;
    stroke: var(--polished-silver);
    stroke-width: 1.2;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 1.8s cubic-bezier(0.22, 1, 0.36, 1);
    letter-spacing: -0.04em;
}

.wordmark-text.drawn {
    stroke-dashoffset: 0;
}

.wordmark-text.undraw {
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== NARRATIVE BLOCKS ===== */
.block-narrative {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    background: var(--graphite-black);
}

.narrative-content {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-narrative-final .narrative-content {
    writing-mode: horizontal-tb;
}

.narrative-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 300;
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--matte-platinum);
    letter-spacing: 0.01em;
}

.narrative-text span {
    opacity: 0;
    transition: opacity 0.04s ease;
}

.narrative-text span.revealed {
    opacity: 1;
}

/* ===== MIRROR BLOCKS ===== */
.block-mirror {
    position: relative;
    min-height: 200px;
    cursor: crosshair;
}

.mirror-surface {
    position: absolute;
    inset: 0;
    background: conic-gradient(from 45deg, #2c2f33, #d4d6dc, #7b8fa1, #d4d6dc, #2c2f33);
    background-size: 200% 200%;
    animation: chrome-shift 12s ease-in-out infinite;
    filter: contrast(1.1) brightness(1.05);
}

@keyframes chrome-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.lens-flare {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.flare-spot {
    position: absolute;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    left: var(--flare-x, 50%);
    top: var(--flare-y, 50%);
    transform: translate(-50%, -50%);
    transition: left 0.15s ease-out, top 0.15s ease-out;
    opacity: 0;
}

.block-mirror:hover .flare-spot,
.block-mirror.flare-active .flare-spot {
    opacity: 1;
}

.flare-ring {
    position: absolute;
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 40%, rgba(199, 125, 186, 0.04) 60%, rgba(125, 186, 199, 0.04) 80%, transparent 100%);
    left: var(--flare-x, 50%);
    top: var(--flare-y, 50%);
    transform: translate(-50%, -50%);
    transition: left 0.15s ease-out, top 0.15s ease-out;
    opacity: 0;
}

.block-mirror:hover .flare-ring,
.block-mirror.flare-active .flare-ring {
    opacity: 1;
}

.flare-ghost {
    position: absolute;
    width: 2rem;
    height: 2rem;
    background: rgba(199, 125, 186, 0.05);
    clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
    left: calc(var(--flare-x, 50%) + 3rem);
    top: calc(var(--flare-y, 50%) - 1rem);
    transform: translate(-50%, -50%);
    transition: left 0.2s ease-out, top 0.2s ease-out;
    opacity: 0;
}

.block-mirror:hover .flare-ghost,
.block-mirror.flare-active .flare-ghost {
    opacity: 1;
}

/* ===== CULTURAL BLOCKS ===== */
.block-cultural {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--graphite-black);
    position: relative;
    min-height: 300px;
}

.block-label {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--steel-blue);
    opacity: 0.6;
}

.cultural-label {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    font-family: 'Fira Code', monospace;
    font-size: 0.65rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--titanium-gold);
    opacity: 0.4;
}

.cultural-svg {
    width: 80%;
    max-width: 280px;
    height: auto;
}

/* SVG Draw Animations */
.svg-draw {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.svg-draw.svg-long {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 3s cubic-bezier(0.22, 1, 0.36, 1);
}

.svg-draw.svg-delay-1 {
    transition-delay: 0.5s;
}

.svg-draw.svg-delay-2 {
    transition-delay: 1s;
}

.svg-draw.svg-delay-3 {
    transition-delay: 1.5s;
}

.svg-draw.animate {
    stroke-dashoffset: 0;
}

.svg-fill-chrome.animate {
    fill: rgba(44, 47, 51, 0.3);
    transition: fill 0.8s ease 1.8s, stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== VOID BLOCKS ===== */
.block-void {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111213;
    min-height: 200px;
}

.void-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--polished-silver);
    animation: void-pulse 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

@keyframes void-pulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.5); }
}

.void-ripple {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1px solid var(--polished-silver);
    animation: void-ripple-expand 3s ease-out infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes void-ripple-expand {
    0% { width: 6px; height: 6px; opacity: 0.6; }
    100% { width: 60px; height: 60px; opacity: 0; }
}

/* ===== DISSOLUTION ZONE ===== */
#dissolution-zone {
    height: 100vh;
    position: relative;
}

/* ===== NAVIGATION DISC ===== */
#nav-disc {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    width: 48px;
    height: 48px;
}

.disc-inner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--chrome-gradient);
    background-size: 200% 200%;
    animation: chrome-shift 12s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid rgba(212, 214, 220, 0.3);
    position: relative;
    z-index: 2;
    animation: disc-rotate 20s linear infinite, chrome-shift 12s ease-in-out infinite;
}

@keyframes disc-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.disc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chromatic-magenta);
    box-shadow: 0 0 8px rgba(199, 125, 186, 0.5);
}

.radial-menu {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 48px;
    height: 48px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#nav-disc:hover .radial-menu,
#nav-disc.menu-open .radial-menu {
    opacity: 1;
    pointer-events: all;
}

.radial-item {
    position: absolute;
    font-family: 'Fira Code', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--matte-platinum);
    text-decoration: none;
    padding: 0.3rem 0.6rem;
    background: rgba(44, 47, 51, 0.9);
    border: 1px solid rgba(212, 214, 220, 0.2);
    border-radius: 2px;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.radial-item:hover {
    color: var(--chromatic-cyan);
    border-color: var(--chromatic-cyan);
}

.radial-item:nth-child(1) { right: 60px; bottom: 0; }
.radial-item:nth-child(2) { right: 56px; bottom: 32px; }
.radial-item:nth-child(3) { right: 44px; bottom: 62px; }
.radial-item:nth-child(4) { right: 24px; bottom: 86px; }
.radial-item:nth-child(5) { right: 0; bottom: 104px; }
.radial-item:nth-child(6) { right: -20px; bottom: 120px; }

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, .display-text {
    font-family: 'Archivo Black', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: -0.04em;
    color: var(--polished-silver);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #puzzle-board {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    .block[data-w="2"],
    .block[data-w="3"],
    .block[data-w="4"] {
        grid-column: span 1;
    }

    .block[data-h="2"],
    .block[data-h="3"] {
        grid-row: span 1;
    }

    .narrative-content {
        writing-mode: horizontal-tb;
        height: auto;
        padding: 1rem 0;
    }

    .block-narrative {
        min-height: 150px;
    }

    .block-cultural {
        min-height: 250px;
    }

    .block-mirror {
        min-height: 150px;
    }

    .block-header {
        min-height: 100px;
    }

    #wordmark {
        max-width: 300px;
    }

    .wordmark-text {
        font-size: 40px;
    }

    .block-void {
        min-height: 100px;
    }

    #nav-disc {
        bottom: 1rem;
        right: 1rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 1rem;
    }

    .block-cultural {
        padding: 1.5rem;
    }

    .narrative-text {
        font-size: 1rem;
    }
}
