@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Nunito:wght@400;700&family=Fira+Mono:wght@400&display=swap');

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

:root {
    --pink: #FF6B9D;
    --yellow: #FFD93D;
    --green: #6BCB77;
    --blue: #4D96FF;
    --dark: #1A1A2E;
    --white: #FAFAFA;
    --orange: #FF8C42;
    --purple: #C084FC;
    --shadow-offset: 8px;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--dark);
    color: var(--white);
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    line-height: 1.75;
    overflow-x: hidden;
}

/* ============================================
   CONFETTI LAYER
   ============================================ */
.confetti-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    overflow: hidden;
}

/* ============================================
   MASCOT CHARACTERS
   ============================================ */
.mascot {
    position: fixed;
    z-index: 9000;
    pointer-events: none;
    transition: transform 0.2s ease-out;
    opacity: 0.85;
}
.mascot-circle {
    top: 20%;
    left: 5%;
}
.mascot-triangle {
    top: 50%;
    right: 5%;
}
.mascot-square {
    bottom: 15%;
    left: 10%;
}

/* ============================================
   NAVIGATION BAR
   ============================================ */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--pink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 8000;
    border-bottom: 4px solid var(--dark);
    box-shadow: 0 4px 0 var(--dark);
    transform: translateY(-100%);
    animation: navSlideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s forwards;
}

@keyframes navSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.nav-brand {
    font-family: 'Bungee', cursive;
    font-size: 1.8rem;
    color: var(--white);
    letter-spacing: 0.04em;
    text-shadow: 3px 3px 0 var(--dark);
}

.nav-items {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.nav-item {
    font-family: 'Bungee', cursive;
    font-size: 0.7rem;
    color: var(--dark);
    text-decoration: none;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.4rem 0.8rem;
    background: var(--white);
    border: 2px solid var(--dark);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    box-shadow: 3px 3px 0 var(--dark);
}
.nav-item:hover {
    transform: rotate(5deg);
    box-shadow: 5px 5px 0 var(--dark);
}
.nav-item-circle {
    border-radius: 50%;
    padding: 0.5rem;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.nav-item-diamond {
    transform: rotate(0deg);
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.nav-item-diamond:hover {
    transform: rotate(5deg);
}
.nav-item-triangle {
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    width: 56px;
    height: 52px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 0.5rem;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.memphis-content {
    position: relative;
    z-index: 10;
    padding-top: 72px;
}

/* ============================================
   SECTION BASE
   ============================================ */
.memphis-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 5rem 2rem;
}

/* ============================================
   PATTERN BACKGROUNDS
   ============================================ */
.pattern-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.18;
}

.pattern-terrazzo {
    background-image:
        radial-gradient(circle 8px at 15% 25%, var(--pink) 100%, transparent 100%),
        radial-gradient(circle 5px at 45% 15%, var(--yellow) 100%, transparent 100%),
        radial-gradient(circle 12px at 75% 35%, var(--green) 100%, transparent 100%),
        radial-gradient(circle 6px at 25% 65%, var(--blue) 100%, transparent 100%),
        radial-gradient(circle 9px at 85% 75%, var(--purple) 100%, transparent 100%),
        radial-gradient(circle 4px at 55% 55%, var(--orange) 100%, transparent 100%),
        radial-gradient(circle 7px at 35% 85%, var(--pink) 100%, transparent 100%),
        radial-gradient(circle 10px at 65% 90%, var(--yellow) 100%, transparent 100%),
        radial-gradient(circle 6px at 10% 50%, var(--green) 100%, transparent 100%),
        radial-gradient(circle 8px at 90% 45%, var(--blue) 100%, transparent 100%);
}

.pattern-confetti {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Crect x='30' y='20' width='10' height='10' fill='%234D96FF' transform='rotate(35 35 25)'/%3E%3Ccircle cx='80' cy='50' r='5' fill='%23FFD93D'/%3E%3Cpolygon points='150,30 155,40 145,40' fill='%231A1A2E'/%3E%3Crect x='120' y='80' width='8' height='8' fill='%23C084FC' transform='rotate(60 124 84)'/%3E%3Ccircle cx='40' cy='130' r='4' fill='%23FF8C42'/%3E%3Cpolygon points='180,120 185,130 175,130' fill='%236BCB77'/%3E%3Crect x='70' y='170' width='12' height='6' fill='%234D96FF' transform='rotate(20 76 173)'/%3E%3Ccircle cx='160' cy='170' r='6' fill='%23FF6B9D'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

.pattern-grid-dots {
    background-image: radial-gradient(circle, var(--white) 3px, transparent 3px);
    background-size: 24px 24px;
}

.pattern-squiggles {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='60'%3E%3Cpath d='M0 30 Q25 5 50 30 Q75 55 100 30 Q125 5 150 30 Q175 55 200 30' fill='none' stroke='%231A1A2E' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 60px;
}

.pattern-zigzag {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cpolyline points='0,40 30,0 60,40 90,0 120,40' fill='none' stroke='%231A1A2E' stroke-width='2'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 120px 40px;
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero-section {
    background: var(--dark);
    text-align: center;
    flex-direction: column;
}

.hero-bg-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bg-shape {
    position: absolute;
    opacity: 0.2;
    animation: floatShape 6s ease-in-out infinite;
}
.bg-shape:nth-child(2) { animation-delay: -1s; }
.bg-shape:nth-child(3) { animation-delay: -2s; }
.bg-shape:nth-child(4) { animation-delay: -3s; }
.bg-shape:nth-child(5) { animation-delay: -4s; }
.bg-shape:nth-child(6) { animation-delay: -0.5s; }
.bg-shape:nth-child(7) { animation-delay: -2.5s; }

@keyframes floatShape {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.shape-circle {
    border-radius: 50%;
}

.shape-triangle {
    width: 0;
    height: 0;
    border-left: 70px solid transparent;
    border-right: 70px solid transparent;
    border-bottom: 120px solid var(--yellow);
    background: none !important;
}

.shape-squiggle {
    width: 120px;
    height: 5px;
    background: var(--purple);
    border-radius: 3px;
    transform: rotate(15deg);
}

.shape-rect {
    width: 80px;
    height: 50px;
    border-radius: 4px;
}

.shape-zigzag {
    width: 100px;
    height: 30px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='30'%3E%3Cpolyline points='0,30 25,0 50,30 75,0 100,30' fill='none' stroke='%23FF8C42' stroke-width='3'/%3E%3C/svg%3E") no-repeat;
}

.hero-content {
    position: relative;
    z-index: 10;
}

.hero-title {
    font-family: 'Bungee', cursive;
    font-size: clamp(3rem, 12vw, 9rem);
    color: var(--white);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    position: relative;
}

.hero-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(-80px);
    text-shadow: 6px 6px 0 var(--pink), 12px 12px 0 rgba(0,0,0,0.2);
}

.hero-tagline {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    color: var(--yellow);
    margin-top: 1.5rem;
    letter-spacing: 0.12em;
    text-transform: lowercase;
    position: relative;
    z-index: 10;
    opacity: 0;
}

/* ============================================
   SECTION DIVIDERS
   ============================================ */
.section-divider {
    position: relative;
    z-index: 10;
    height: 40px;
    overflow: hidden;
}
.section-divider svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ============================================
   MEMPHIS CARD CONTAINERS
   ============================================ */
.memphis-card {
    background: var(--white);
    border: 4px solid var(--dark);
    padding: 3rem 2.5rem;
    position: relative;
    max-width: 800px;
    width: 100%;
    box-shadow: var(--shadow-offset) var(--shadow-offset) 0 var(--dark);
    transition: box-shadow 0.1s ease, transform 0.1s ease;
}

.memphis-card:hover {
    box-shadow: 12px 12px 0 var(--dark);
    transform: translate(-2px, -2px);
}

.card-skew {
    border-radius: 4px 24px 4px 4px;
}

.card-rounded {
    border-radius: 24px 4px 24px 4px;
}

.card-stepped {
    clip-path: polygon(0 0, 95% 0, 100% 5%, 100% 100%, 5% 100%, 0 95%);
    border-radius: 0;
    border: none;
    outline: 4px solid var(--dark);
}

.card-skew-reverse {
    border-radius: 4px 4px 24px 4px;
}

/* ============================================
   ALGO SECTIONS
   ============================================ */
.algo-section {
    flex-direction: column;
}

.sort-section {
    background: var(--pink);
}

.search-section {
    background: var(--blue);
}

.traverse-section {
    background: var(--green);
}

.philosophy-section {
    background: var(--yellow);
}

.algo-title {
    font-family: 'Bungee', cursive;
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--dark);
    text-shadow: 4px 4px 0 rgba(255,255,255,0.3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.algo-subtitle {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--dark);
    margin-bottom: 2rem;
}

.code-snippet {
    font-family: 'Fira Mono', monospace;
    font-size: 14px;
    background: var(--dark);
    color: var(--yellow);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
}

.algo-desc {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.3vw, 1.05rem);
    color: var(--dark);
    margin-top: 1.5rem;
    line-height: 1.75;
}

/* ============================================
   SORT VISUALIZATION
   ============================================ */
.sort-viz {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    height: 220px;
    padding: 1rem 0;
    position: relative;
}

.sort-bar {
    width: 32px;
    border-radius: 4px 4px 0 0;
    border: 3px solid var(--dark);
    box-shadow: 3px 3px 0 var(--dark);
    transition: height 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.2s ease;
}

.sort-bar.comparing {
    transform: scaleX(1.15);
    border-color: var(--orange);
}

.sort-bar.sorted {
    border-color: var(--green);
    box-shadow: 3px 3px 0 var(--green);
}

.sort-compare-indicator {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s, left 0.3s ease;
}

/* ============================================
   RUN BUTTONS
   ============================================ */
.run-btn {
    font-family: 'Bungee', cursive;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
    color: var(--white);
    background: var(--dark);
    border: 3px solid var(--dark);
    padding: 0.7rem 2rem;
    cursor: pointer;
    margin-top: 1.5rem;
    box-shadow: 4px 4px 0 var(--orange);
    transition: box-shadow 0.1s ease, transform 0.1s ease;
}
.run-btn:hover {
    box-shadow: 6px 6px 0 var(--orange);
    transform: translate(-1px, -1px);
}
.run-btn:active {
    box-shadow: 2px 2px 0 var(--orange);
    transform: translate(1px, 1px);
}

.run-btn-light {
    background: var(--yellow);
    color: var(--dark);
    border-color: var(--dark);
    box-shadow: 4px 4px 0 var(--dark);
}
.run-btn-light:hover {
    box-shadow: 6px 6px 0 var(--dark);
}
.run-btn-light:active {
    box-shadow: 2px 2px 0 var(--dark);
}

/* ============================================
   SEARCH VISUALIZATION
   ============================================ */
.search-viz {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 1rem 0;
}

.search-box {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--dark);
    border-radius: 4px;
    font-family: 'Fira Mono', monospace;
    font-size: 0.8rem;
    color: var(--dark);
    background: var(--white);
    box-shadow: 3px 3px 0 var(--dark);
    transition: background 0.3s, transform 0.3s, opacity 0.3s;
}

.search-box.eliminated {
    opacity: 0.25;
    transform: scale(0.85);
    background: #ddd;
}

.search-box.active-range {
    background: var(--yellow);
    transform: scale(1.05);
}

.search-box.found {
    background: var(--green);
    transform: scale(1.2);
    box-shadow: 6px 6px 0 var(--dark);
}

.search-box.checking {
    background: var(--orange);
    transform: scale(1.1);
}

.search-info {
    margin-top: 1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    color: var(--white);
    font-size: 1.1rem;
}

/* ============================================
   GRAPH TRAVERSAL
   ============================================ */
.traverse-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.traverse-toggle {
    font-family: 'Bungee', cursive;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    padding: 0.5rem 1.2rem;
    border: 3px solid var(--dark);
    cursor: pointer;
    background: var(--white);
    color: var(--dark);
    box-shadow: 3px 3px 0 var(--dark);
    transition: box-shadow 0.1s, transform 0.1s, background 0.2s;
}
.traverse-toggle.active {
    background: var(--blue);
    color: var(--white);
}
.traverse-toggle[data-mode="dfs"].active {
    background: var(--pink);
}
.traverse-toggle:hover {
    transform: translate(-1px, -1px);
    box-shadow: 5px 5px 0 var(--dark);
}

.graph-viz {
    padding: 1rem 0;
    display: flex;
    justify-content: center;
}

.graph-svg {
    width: 100%;
    max-width: 400px;
}

.graph-node {
    transition: fill 0.3s ease;
}

.graph-node.visited-bfs {
    fill: var(--blue);
}

.graph-node.visited-dfs {
    fill: var(--pink);
}

/* ============================================
   PHILOSOPHY SECTION
   ============================================ */
.philosophy-title {
    font-family: 'Bungee', cursive;
    font-size: clamp(2.5rem, 6vw, 5rem);
    color: var(--dark);
    line-height: 1.15;
    margin-bottom: 2rem;
    text-shadow: 4px 4px 0 rgba(255,255,255,0.25);
    letter-spacing: 0.04em;
}

.philosophy-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 1.1rem;
    line-height: 1.8;
    max-width: 600px;
    margin: 0 auto;
    color: var(--dark);
}

.philosophy-shapes {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 2.5rem;
}

.phil-shape {
    width: 50px;
    height: 50px;
    animation: floatShape 4s ease-in-out infinite;
}
.phil-circle {
    background: var(--pink);
    border-radius: 50%;
    border: 3px solid var(--dark);
    box-shadow: 4px 4px 0 var(--dark);
    animation-delay: 0s;
}
.phil-triangle {
    width: 0;
    height: 0;
    border-left: 25px solid transparent;
    border-right: 25px solid transparent;
    border-bottom: 45px solid var(--blue);
    background: none;
    animation-delay: -1.3s;
    filter: drop-shadow(4px 4px 0 var(--dark));
}
.phil-square {
    background: var(--green);
    border: 3px solid var(--dark);
    box-shadow: 4px 4px 0 var(--dark);
    border-radius: 3px;
    animation-delay: -2.6s;
}

/* ============================================
   FOOTER
   ============================================ */
.memphis-footer {
    background: var(--dark);
    padding: 4rem 2rem;
    text-align: center;
    border-top: 4px solid var(--pink);
    position: relative;
    z-index: 10;
}

.footer-brand {
    font-family: 'Bungee', cursive;
    font-size: 1.5rem;
    color: var(--white);
    letter-spacing: 0.04em;
    text-shadow: 3px 3px 0 var(--pink);
    display: block;
}

.footer-tagline {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: 0.9rem;
    color: rgba(250, 250, 250, 0.5);
    margin-top: 0.5rem;
}

.footer-shapes {
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.footer-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    animation: floatShape 3s ease-in-out infinite;
}
.footer-dot:nth-child(2) { animation-delay: -0.5s; }
.footer-dot:nth-child(3) { animation-delay: -1s; }
.footer-dot:nth-child(4) { animation-delay: -1.5s; }
.footer-dot:nth-child(5) { animation-delay: -2s; }
.footer-dot:nth-child(6) { animation-delay: -2.5s; }

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */
.algo-section .section-inner {
    opacity: 0;
    transform: translateY(60px) rotate(-2deg);
    transition: opacity 0.8s ease-out, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.algo-section .section-inner.visible {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
}

.philosophy-section .section-inner {
    opacity: 0;
    transform: scale(0.85) rotate(1deg);
    transition: opacity 0.8s ease-out, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.philosophy-section .section-inner.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* ============================================
   DIVIDER SHAPE ANIMATIONS
   ============================================ */
.section-divider.animate svg pattern circle,
.section-divider.animate svg pattern polygon {
    animation: dividerBounce 0.6s ease-out;
}

@keyframes dividerBounce {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .nav-items {
        gap: 0.3rem;
    }
    .nav-item-circle,
    .nav-item-diamond,
    .nav-item-triangle {
        width: 40px;
        height: 40px;
        font-size: 0.55rem;
    }
    .nav-brand {
        font-size: 1.3rem;
    }
    .memphis-card {
        padding: 2rem 1.5rem;
    }
    .sort-bar {
        width: 24px;
    }
    .search-box {
        width: 36px;
        height: 36px;
        font-size: 0.7rem;
    }
    .mascot {
        display: none;
    }
}

@media (max-width: 480px) {
    .nav-item span {
        font-size: 0.5rem;
    }
    .sort-bar {
        width: 18px;
        gap: 3px;
    }
    .search-box {
        width: 30px;
        height: 30px;
        font-size: 0.6rem;
    }
}
