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

:root {
    --raspberry: #ff2d6f;
    --cobalt: #3d5afe;
    --sunflower: #ffc400;
    --cream: #fef9ef;
    --ink: #1a1a3e;
    --spearmint: #00c9a7;
    --grape: #9c4dff;
    --charcoal: #2a2a3a;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    color: var(--ink);
    background: var(--cream);
    line-height: 1.65;
    overflow-x: hidden;
}

/* === Scroll Progress === */
#scroll-progress {
    position: fixed;
    left: 0;
    top: 0;
    width: 3px;
    height: 0;
    background: var(--raspberry);
    z-index: 9999;
    transition: none;
}

/* === Viewport Sections === */
.viewport-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 4rem 2rem;
    width: 100%;
}

.dark-bg {
    background: var(--charcoal);
    color: var(--cream);
}

.light-bg {
    background: var(--cream);
    color: var(--ink);
}

/* === Section 1: Puzzle Box === */
#puzzle-box {
    background: var(--cream);
    overflow: hidden;
}

.puzzle-title {
    display: flex;
    gap: clamp(0.3rem, 1vw, 1rem);
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    z-index: 2;
    position: relative;
}

.letter-shape {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(5rem, 12vw, 14rem);
    letter-spacing: 0.08em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.8s ease;
    color: var(--ink);
}

.letter-shape.scattered {
    opacity: 0.6;
}

.shape-circle { 
    width: clamp(5rem, 12vw, 14rem); 
    height: clamp(5rem, 12vw, 14rem); 
    background: var(--sunflower); 
    border-radius: 50%; 
}
.shape-triangle { 
    width: clamp(5rem, 12vw, 14rem); 
    height: clamp(5rem, 12vw, 14rem); 
    background: var(--raspberry); 
    clip-path: polygon(50% 5%, 5% 95%, 95% 95%); 
    padding-top: 1rem;
}
.shape-square { 
    width: clamp(5rem, 12vw, 14rem); 
    height: clamp(5rem, 12vw, 14rem); 
    background: var(--cobalt); 
}
.shape-diamond { 
    width: clamp(5rem, 12vw, 14rem); 
    height: clamp(5rem, 12vw, 14rem); 
    background: var(--spearmint); 
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); 
}
.shape-hexagon { 
    width: clamp(5rem, 12vw, 14rem); 
    height: clamp(5rem, 12vw, 14rem); 
    background: var(--grape); 
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%); 
}
.shape-trapezoid { 
    width: clamp(5rem, 12vw, 14rem); 
    height: clamp(5rem, 12vw, 14rem); 
    background: var(--raspberry); 
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%); 
}
.shape-pentagon { 
    width: clamp(5rem, 12vw, 14rem); 
    height: clamp(5rem, 12vw, 14rem); 
    background: var(--sunflower); 
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%); 
}

.subtitle {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 500;
    margin-top: 2rem;
    z-index: 2;
    position: relative;
    opacity: 0.8;
}

.geo-composition {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.geo {
    position: absolute;
    opacity: 0.15;
}

.geo-circle-1 {
    width: 300px; height: 300px;
    border-radius: 50%;
    background: var(--raspberry);
    top: 10%; left: 5%;
}
.geo-triangle-1 {
    width: 250px; height: 220px;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background: var(--cobalt);
    top: 20%; right: 10%;
}
.geo-rect-1 {
    width: 200px; height: 200px;
    background: var(--sunflower);
    bottom: 15%; left: 15%;
}
.geo-circle-2 {
    width: 180px; height: 180px;
    border-radius: 50%;
    background: var(--grape);
    bottom: 10%; right: 20%;
}
.geo-triangle-2 {
    width: 150px; height: 130px;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    background: var(--spearmint);
    top: 60%; left: 50%;
}

.scroll-hint {
    position: absolute;
    bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 2;
    animation: bobbing 2s ease-in-out infinite;
}

.scroll-hint-text {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 0.8vw, 0.85rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

@keyframes bobbing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(8px); }
}

/* === Pattern Dividers === */
.pattern-divider {
    width: 100%;
    height: 50px;
    flex-shrink: 0;
}

.zigzag-band {
    background: repeating-linear-gradient(
        135deg,
        var(--raspberry) 0px, var(--raspberry) 10px,
        transparent 10px, transparent 20px,
        var(--cobalt) 20px, var(--cobalt) 30px,
        transparent 30px, transparent 40px
    );
}

.concentric-band {
    background: repeating-radial-gradient(
        circle,
        var(--sunflower) 0px, var(--sunflower) 4px,
        transparent 4px, transparent 12px
    );
}

.chevron-band {
    background: repeating-linear-gradient(
        60deg,
        var(--spearmint) 0px, var(--spearmint) 10px,
        transparent 10px, transparent 20px,
        var(--grape) 20px, var(--grape) 30px,
        transparent 30px, transparent 40px
    );
}

.dot-band {
    background: radial-gradient(circle, var(--grape) 2px, transparent 2px);
    background-size: 20px 20px;
    background-color: var(--cream);
}

/* === Section Titles === */
.section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(3rem, 8vw, 10rem);
    letter-spacing: 0.08em;
    text-align: center;
    margin-bottom: 0.5rem;
}

.section-intro {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    text-align: center;
    max-width: 60ch;
    margin-bottom: 3rem;
    opacity: 0.85;
}

/* === Card Grid === */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 960px;
    width: 100%;
}

.card-wrapper {
    perspective: 1200px;
    aspect-ratio: 1;
    max-width: 280px;
    width: 100%;
    justify-self: center;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-style: preserve-3d;
}

.card-wrapper:hover .card-inner,
.card-wrapper.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 12px;
    border: 2px solid var(--card-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(26,26,62,0.1);
    transition: box-shadow 0.6s ease;
}

.card-wrapper:hover .card-front,
.card-wrapper:hover .card-back,
.card-wrapper.flipped .card-front,
.card-wrapper.flipped .card-back {
    box-shadow: 0 8px 40px rgba(26,26,62,0.2);
}

.dark-bg .card-front {
    background: var(--charcoal);
}

.light-bg .card-front {
    background: var(--cream);
}

.card-back {
    transform: rotateY(180deg);
    background: repeating-radial-gradient(
        circle,
        rgba(255,196,0,0.08) 0px, rgba(255,196,0,0.08) 4px,
        transparent 4px, transparent 12px
    );
}

.dark-bg .card-back {
    background-color: #1a1a3e;
    color: var(--cream);
}

.light-bg .card-back {
    background-color: var(--cream);
    color: var(--ink);
}

.card-icon {
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
}

.card-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 0.8vw, 0.85rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--card-color);
    font-weight: 700;
}

.card-back p {
    font-family: 'DM Sans', sans-serif;
    font-size: clamp(0.85rem, 1vw, 1rem);
    line-height: 1.6;
    text-align: center;
    max-width: 240px;
}

/* === Timeline === */
.timeline-section {
    padding: 6rem 2rem;
}

.timeline {
    position: relative;
    max-width: 900px;
    width: 100%;
    padding: 2rem 0;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--raspberry);
    transform: translateX(-50%);
}

.timeline-node {
    position: relative;
    display: flex;
    align-items: flex-start;
    margin-bottom: 4rem;
}

.timeline-node:nth-child(even) {
    flex-direction: row-reverse;
}

.node-dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    flex-shrink: 0;
}

.node-content {
    max-width: 380px;
    width: calc(50% - 48px);
}

.node-content.left {
    text-align: right;
    margin-right: auto;
    padding-right: 3rem;
}

.node-content.right {
    text-align: left;
    margin-left: auto;
    padding-left: 3rem;
}

.node-label {
    font-family: 'Space Mono', monospace;
    font-size: clamp(0.7rem, 0.8vw, 0.85rem);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
    color: var(--raspberry);
    display: block;
    margin-bottom: 0.5rem;
}

.node-content p {
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.65;
}

/* === Completed Puzzle (Mural) === */
#completed-puzzle {
    overflow: hidden;
    min-height: 100vh;
}

.mural-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.mural-shape {
    position: absolute;
    background: var(--shape-color);
    will-change: transform;
}

.mural-tagline {
    z-index: 2;
    position: relative;
    opacity: 0;
    transition: opacity 1.2s ease;
}

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

.mural-tagline h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(3rem, 8vw, 10rem);
    letter-spacing: 0.08em;
    color: var(--cream);
    text-align: center;
}

/* Pulse animation */
@keyframes pulse-once {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.mural-container.assembled {
    animation: pulse-once 1.2s ease-in-out 0.3s 1;
}

/* === Footer === */
.site-footer {
    background: var(--ink);
    color: var(--cream);
    text-align: center;
    padding: 2rem;
}

.footer-pattern {
    height: 16px;
    background: repeating-linear-gradient(
        90deg,
        var(--raspberry) 0px, var(--raspberry) 16px,
        var(--cobalt) 16px, var(--cobalt) 32px
    );
    margin-bottom: 1.5rem;
}

.footer-text {
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    opacity: 0.7;
}

/* === Reveal Animations === */
.reveal-element {
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    transition-delay: var(--delay, 0ms);
}

.reveal-element.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === Hover Effects === */
.card-wrapper:hover .card-front {
    filter: hue-rotate(15deg);
}

/* === Responsive === */
@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .card-grid {
        grid-template-columns: 1fr;
        max-width: 320px;
    }

    .puzzle-title {
        gap: 0.2rem;
    }

    .timeline-line {
        left: 24px;
    }

    .node-dot {
        left: 24px;
    }

    .node-content.left,
    .node-content.right {
        text-align: left;
        margin-left: 72px;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
        width: calc(100% - 72px);
    }

    .mural-shape:nth-child(n+6) {
        display: none;
    }
}
