/* ppuzzl.works - Memphis Puzzle Grid Styles */

/* ===== CSS Custom Properties ===== */
:root {
    --primary-orange: #c4613a;
    --terracotta: #d4845a;
    --bg-cream: #fdf4e8;
    --dark-ground: #2d2926;
    --mustard: #e8a832;
    --teal: #2a8f82;
    --glitch-pink: #e85d8a;
    --text-light: #f5ebe0;
    --text-dark: #1a1714;
    --zone-bg: #fdf4e8;
    --snap-easing: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cabin', sans-serif;
    font-weight: 400;
    color: var(--text-dark);
    background-color: var(--zone-bg);
    overflow-x: hidden;
    transition: background-color 300ms ease-out;
    line-height: 1.65;
}

/* ===== Vertical Brand Column ===== */
.brand-column {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.brand-text {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: 0.4em;
    color: var(--primary-orange);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    white-space: nowrap;
    text-transform: lowercase;
    opacity: 0.85;
    transition: color 300ms ease-out;
}

body.zone-dark .brand-text {
    color: var(--text-light);
}

body.zone-terra .brand-text {
    color: var(--bg-cream);
}

/* ===== Particle Layer (Memphis Confetti) ===== */
.particle-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    opacity: 0.45;
}

.particle--triangle {
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 15px solid var(--primary-orange);
}

.particle--circle {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--mustard);
}

.particle--zigzag {
    width: 40px;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        var(--teal) 0px,
        var(--teal) 5px,
        transparent 5px,
        transparent 10px
    );
}

.particle--squiggle {
    width: 30px;
    height: 12px;
    border: 2px solid var(--glitch-pink);
    border-radius: 0 50% 50% 0 / 0 100% 100% 0;
    border-left: none;
}

/* ===== Floating Elements ===== */
.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.float-shape {
    position: absolute;
    will-change: transform;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.float-circle {
    top: 15%;
    right: 8%;
    animation: floatRotate 60s linear infinite;
}

.float-triangle {
    top: 45%;
    left: 5%;
    animation: floatBob 4s ease-in-out infinite;
}

.float-squiggle {
    top: 65%;
    right: 12%;
    animation: floatDrift 8s ease-in-out infinite alternate;
}

.float-circle-2 {
    top: 80%;
    left: 15%;
    animation: floatRotate 45s linear infinite reverse;
}

.float-triangle-2 {
    top: 25%;
    left: 70%;
    animation: floatBob 5s ease-in-out infinite;
    animation-delay: -2s;
}

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

@keyframes floatBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes floatDrift {
    0% { transform: translateX(0); }
    100% { transform: translateX(40px); }
}

/* ===== Zones ===== */
.zone {
    position: relative;
    min-height: 100vh;
    padding: 80px 60px 80px 80px;
    overflow: hidden;
}

.zone-sentinel {
    position: absolute;
    top: 50%;
    left: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* Zone 1: Cream with confetti */
.zone-1 {
    background-color: var(--bg-cream);
}

.confetti-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* Zone 2: Charcoal with terrazzo */
.zone-2 {
    background-color: var(--dark-ground);
}

.terrazzo-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(1.5px 1.5px at 10% 15%, rgba(196, 97, 58, 0.3) 50%, transparent 50%),
        radial-gradient(2px 2px at 25% 35%, rgba(232, 168, 50, 0.25) 50%, transparent 50%),
        radial-gradient(1px 1px at 40% 20%, rgba(42, 143, 130, 0.3) 50%, transparent 50%),
        radial-gradient(2.5px 2.5px at 55% 45%, rgba(212, 132, 90, 0.2) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 70% 10%, rgba(232, 93, 138, 0.25) 50%, transparent 50%),
        radial-gradient(2px 2px at 85% 55%, rgba(196, 97, 58, 0.2) 50%, transparent 50%),
        radial-gradient(1px 1px at 15% 65%, rgba(232, 168, 50, 0.3) 50%, transparent 50%),
        radial-gradient(2px 2px at 30% 80%, rgba(42, 143, 130, 0.2) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 60% 75%, rgba(212, 132, 90, 0.25) 50%, transparent 50%),
        radial-gradient(1px 1px at 80% 85%, rgba(232, 93, 138, 0.2) 50%, transparent 50%),
        radial-gradient(2px 2px at 45% 95%, rgba(196, 97, 58, 0.25) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 90% 30%, rgba(232, 168, 50, 0.2) 50%, transparent 50%);
    mix-blend-mode: soft-light;
}

/* Zone 3: Terracotta with cream overlays */
.zone-3 {
    background-color: var(--primary-orange);
}

.cream-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.cream-overlay-layer::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -30px;
    width: 300px;
    height: 300px;
    border: 4px solid rgba(253, 244, 232, 0.25);
    border-radius: 50%;
    transform: rotate(15deg);
}

.cream-overlay-layer::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 10%;
    width: 0;
    height: 0;
    border-left: 120px solid transparent;
    border-right: 120px solid transparent;
    border-bottom: 200px solid rgba(253, 244, 232, 0.12);
    transform: rotate(-10deg);
}

/* ===== Puzzle Grid ===== */
.puzzle-grid {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: 2fr 3fr 2fr;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Puzzle Cells ===== */
.puzzle-cell {
    position: relative;
    overflow: visible;
    will-change: transform, opacity;
}

/* Puzzle piece clip-paths with knobs and sockets */
.cell-1 {
    grid-column: 1 / 2;
    clip-path: polygon(0% 0%, 85% 0%, 85% 35%, 100% 35%, 100% 65%, 85% 65%, 85% 100%, 0% 100%, 0% 65%, 5% 55%, 5% 45%, 0% 35%);
}

.cell-2 {
    grid-column: 2 / 3;
    clip-path: polygon(0% 0%, 100% 0%, 100% 35%, 95% 45%, 95% 55%, 100% 65%, 100% 100%, 0% 100%, 0% 65%, 15% 65%, 15% 35%, 0% 35%);
}

.cell-3 {
    grid-column: 3 / 4;
    clip-path: polygon(15% 0%, 100% 0%, 100% 100%, 15% 100%, 15% 65%, 0% 65%, 0% 35%, 15% 35%);
}

.cell-4 {
    grid-column: 1 / 3;
    clip-path: polygon(0% 0%, 100% 0%, 100% 40%, 95% 50%, 100% 60%, 100% 100%, 0% 100%);
}

.cell-5 {
    grid-column: 3 / 4;
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 60%, 5% 50%, 0% 40%);
}

.cell-6 {
    grid-column: 1 / 2;
    clip-path: polygon(0% 0%, 85% 0%, 85% 40%, 100% 40%, 100% 60%, 85% 60%, 85% 100%, 0% 100%);
}

.cell-7 {
    grid-column: 2 / 4;
    clip-path: polygon(15% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, 15% 0%, 15% 40%, 0% 40%, 0% 60%, 15% 60%);
}

.cell-8 {
    grid-column: 1 / 2;
    clip-path: polygon(0% 0%, 85% 0%, 85% 35%, 100% 35%, 100% 65%, 85% 65%, 85% 100%, 0% 100%);
}

.cell-9 {
    grid-column: 2 / 3;
    clip-path: polygon(15% 0%, 85% 0%, 85% 35%, 100% 50%, 85% 65%, 85% 100%, 15% 100%, 15% 65%, 0% 50%, 15% 35%);
}

.cell-10 {
    grid-column: 3 / 4;
    clip-path: polygon(15% 0%, 100% 0%, 100% 100%, 15% 100%, 15% 65%, 0% 50%, 15% 35%);
}

.cell-inner {
    background: rgba(253, 244, 232, 0.95);
    padding: 32px 28px;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    transition: box-shadow 200ms ease, transform 200ms ease;
}

.cell-inner.dark-cell {
    background: rgba(45, 41, 38, 0.9);
    color: var(--text-light);
    border: 1px solid rgba(196, 97, 58, 0.3);
}

.cell-inner.terra-cell {
    background: rgba(45, 41, 38, 0.85);
    color: var(--text-light);
    border: 1px solid rgba(253, 244, 232, 0.2);
}

.cell-label {
    font-family: 'Silkscreen', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--primary-orange);
    margin-bottom: 12px;
    display: block;
}

.dark-cell .cell-label,
.terra-cell .cell-label {
    color: var(--mustard);
}

.cell-title {
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.02em;
    line-height: 1.1;
    margin-bottom: 16px;
    color: var(--text-dark);
}

.dark-cell .cell-title,
.terra-cell .cell-title {
    color: var(--text-light);
}

.cell-body {
    font-family: 'Cabin', sans-serif;
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.7;
    margin-bottom: 20px;
    max-width: 500px;
}

.zone-1 .cell-body {
    color: var(--text-dark);
}

.dark-cell .cell-body {
    font-size: 1rem;
    line-height: 1.65;
    color: rgba(245, 235, 224, 0.85);
}

.terra-cell .cell-body {
    font-size: 1rem;
    line-height: 1.65;
    color: rgba(245, 235, 224, 0.85);
}

.cell-tag {
    font-family: 'Silkscreen', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--teal);
    padding: 4px 10px;
    border: 1px solid var(--teal);
    display: inline-block;
    align-self: flex-start;
}

.dark-cell .cell-tag {
    color: var(--glitch-pink);
    border-color: var(--glitch-pink);
}

.terra-cell .cell-tag {
    color: var(--mustard);
    border-color: var(--mustard);
}

/* ===== Slide-Reveal Animation ===== */
.slide-from-left {
    opacity: 0;
    transform: translateX(-100vw) rotate(-6deg);
    transition: transform 800ms var(--snap-easing), opacity 600ms ease;
}

.slide-from-right {
    opacity: 0;
    transform: translateX(100vw) rotate(6deg);
    transition: transform 800ms var(--snap-easing), opacity 600ms ease;
}

.slide-from-left.revealed,
.slide-from-right.revealed {
    opacity: 1;
    transform: translateX(0) rotate(0deg);
}

/* ===== Glitch Hover Effect ===== */
@keyframes glitchEffect {
    0% {
        text-shadow: none;
        box-shadow: none;
    }
    20% {
        text-shadow: -3px 0 #e85d8a, 3px 0 #2a8f82;
        box-shadow: -3px 0 0 rgba(232, 93, 138, 0.3), 3px 0 0 rgba(42, 143, 130, 0.3);
    }
    40% {
        text-shadow: 3px 0 #e85d8a, -3px 0 #2a8f82;
        box-shadow: 3px 0 0 rgba(232, 93, 138, 0.3), -3px 0 0 rgba(42, 143, 130, 0.3);
    }
    60% {
        text-shadow: -2px 0 #e85d8a, 2px 0 #2a8f82;
        box-shadow: -2px 0 0 rgba(232, 93, 138, 0.2), 2px 0 0 rgba(42, 143, 130, 0.2);
    }
    80% {
        text-shadow: 1px 0 #e85d8a, -1px 0 #2a8f82;
        box-shadow: 1px 0 0 rgba(232, 93, 138, 0.1), -1px 0 0 rgba(42, 143, 130, 0.1);
    }
    100% {
        text-shadow: none;
        box-shadow: none;
    }
}

.puzzle-cell.glitching .cell-inner {
    animation: glitchEffect 200ms steps(4) forwards;
}

.puzzle-cell.glitching .cell-title {
    animation: glitchEffect 200ms steps(4) forwards;
}

/* ===== Floating Navigation ===== */
.float-nav {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.nav-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--primary-orange);
    background: var(--bg-cream);
    color: var(--primary-orange);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    bottom: 0;
    right: 0;
    transition: transform 400ms var(--snap-easing), opacity 300ms ease, background-color 200ms ease;
    opacity: 0;
    transform: scale(0.5);
    pointer-events: none;
}

.nav-btn:hover {
    background: var(--primary-orange);
    color: var(--bg-cream);
}

.nav-btn-center {
    position: relative;
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
    z-index: 10;
    width: 56px;
    height: 56px;
    background: var(--primary-orange);
    color: var(--bg-cream);
    border-color: var(--primary-orange);
    box-shadow: 0 4px 16px rgba(196, 97, 58, 0.4);
}

.nav-btn-center:hover {
    background: var(--dark-ground);
    border-color: var(--dark-ground);
    box-shadow: 0 4px 20px rgba(45, 41, 38, 0.5);
}

.float-nav.open .nav-btn-1 {
    opacity: 1;
    transform: translate(0, -70px) scale(1);
    pointer-events: all;
}

.float-nav.open .nav-btn-2 {
    opacity: 1;
    transform: translate(-55px, -50px) scale(1);
    pointer-events: all;
}

.float-nav.open .nav-btn-3 {
    opacity: 1;
    transform: translate(-70px, 10px) scale(1);
    pointer-events: all;
}

.float-nav.open .nav-btn-4 {
    opacity: 1;
    transform: translate(-45px, -120px) scale(1);
    pointer-events: all;
}

.nav-label {
    font-family: 'Silkscreen', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 200ms ease;
}

.nav-btn:hover .nav-label {
    opacity: 1;
}

/* ===== Glitch Puzzle Decorations ===== */
.zone::before {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    opacity: 0.08;
    z-index: 0;
    pointer-events: none;
}

.zone-1::before {
    top: 10%;
    right: 5%;
    background:
        linear-gradient(transparent 49%, var(--primary-orange) 49%, var(--primary-orange) 51%, transparent 51%) 0 0 / 100% 8px repeat-y,
        linear-gradient(90deg, transparent 49%, var(--glitch-pink) 49%, var(--glitch-pink) 51%, transparent 51%) 0 0 / 8px 100% repeat-x;
    clip-path: polygon(25% 0%, 75% 0%, 100% 25%, 100% 75%, 75% 100%, 25% 100%, 0% 75%, 0% 25%);
}

.zone-2::before {
    bottom: 10%;
    left: 3%;
    width: 180px;
    height: 180px;
    background:
        linear-gradient(transparent 48%, var(--mustard) 48%, var(--mustard) 52%, transparent 52%) 0 0 / 100% 6px repeat-y;
    clip-path: polygon(20% 0%, 80% 0%, 80% 40%, 100% 40%, 100% 60%, 80% 60%, 80% 100%, 20% 100%, 20% 60%, 0% 60%, 0% 40%, 20% 40%);
    opacity: 0.12;
}

.zone-3::before {
    top: 15%;
    left: 8%;
    width: 160px;
    height: 160px;
    background:
        linear-gradient(transparent 47%, var(--bg-cream) 47%, var(--bg-cream) 53%, transparent 53%) 0 0 / 100% 10px repeat-y;
    clip-path: circle(50%);
    opacity: 0.1;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .zone {
        padding: 60px 24px 60px 56px;
    }

    .puzzle-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .cell-1, .cell-2, .cell-3, .cell-4, .cell-5,
    .cell-6, .cell-7, .cell-8, .cell-9, .cell-10 {
        grid-column: 1 / -1;
        clip-path: polygon(0% 0%, 92% 0%, 92% 40%, 100% 50%, 92% 60%, 92% 100%, 0% 100%, 0% 60%, 8% 50%, 0% 40%);
    }

    .cell-inner {
        min-height: 200px;
        padding: 24px 32px;
    }

    .cell-title {
        font-size: clamp(1.5rem, 8vw, 3rem);
    }

    .brand-column {
        width: 36px;
    }

    .brand-text {
        font-size: 1.1rem;
        letter-spacing: 0.3em;
    }

    .float-circle,
    .float-circle-2,
    .float-triangle-2 {
        display: none;
    }
}

@media (max-width: 600px) {
    .zone {
        padding: 40px 16px 40px 44px;
    }

    .brand-column {
        width: 32px;
    }

    .brand-text {
        font-size: 0.9rem;
    }

    .float-nav {
        bottom: 20px;
        right: 20px;
    }

    .nav-btn-center {
        width: 48px;
        height: 48px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
    }

    .floating-elements {
        display: none;
    }
}

/* ===== Scan-line overlay for zone 2 ===== */
.zone-2::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 1;
}