/* ============================================================
   bada.systems - McBling Chrome & Crystal Systems Theory
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: #1A0A12;
    color: #C4A6B5;
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Background Grid (permanent, structural) ---------- */
#background-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent calc(12.5% - 1px),
            #3D1525 calc(12.5% - 1px),
            #3D1525 12.5%
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent calc(12.5% - 1px),
            #3D1525 calc(12.5% - 1px),
            #3D1525 12.5%
        );
    animation: gridPulse 3s ease-in-out infinite;
}

@keyframes gridPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* ---------- Scroll Progress Diamond ---------- */
#scroll-progress {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 28px;
    height: 28px;
    transform: rotate(45deg);
    border: 1px solid #E8D5E0;
    z-index: 1000;
    overflow: hidden;
    background: transparent;
}

#scroll-progress-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #FF69B4, #3D1525);
    transition: height 100ms linear;
}

/* ---------- Sparkle Effects ---------- */
.sparkle {
    position: absolute;
    width: 12px;
    height: 12px;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    animation: sparkleFlash 3s infinite;
}

.sparkle::before,
.sparkle::after {
    content: '';
    position: absolute;
    background: #FFFFFF;
}

.sparkle::before {
    width: 12px;
    height: 12px;
    left: 0;
    top: 0;
    clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
}

.sparkle::after {
    width: 12px;
    height: 12px;
    top: 0;
    left: 0;
    clip-path: polygon(50% 0%, 55% 45%, 100% 50%, 55% 55%, 50% 100%, 45% 55%, 0% 50%, 45% 45%);
    transform: rotate(45deg);
    opacity: 0.6;
}

/* Stagger sparkle animations */
.sparkle:nth-child(1) { animation-delay: 0s; animation-duration: 2.5s; }
.sparkle:nth-child(2) { animation-delay: 0.7s; animation-duration: 3.2s; }
.sparkle:nth-child(3) { animation-delay: 1.4s; animation-duration: 2.8s; }
.sparkle:nth-child(4) { animation-delay: 0.3s; animation-duration: 3.5s; }
.sparkle:nth-child(5) { animation-delay: 2.1s; animation-duration: 2.2s; }
.sparkle:nth-child(6) { animation-delay: 1.0s; animation-duration: 3.8s; }
.sparkle:nth-child(7) { animation-delay: 1.8s; animation-duration: 2.6s; }
.sparkle:nth-child(8) { animation-delay: 0.5s; animation-duration: 4.0s; }
.sparkle:nth-child(9) { animation-delay: 2.4s; animation-duration: 2.3s; }
.sparkle:nth-child(10) { animation-delay: 1.2s; animation-duration: 3.1s; }
.sparkle:nth-child(11) { animation-delay: 0.8s; animation-duration: 2.9s; }
.sparkle:nth-child(12) { animation-delay: 1.6s; animation-duration: 3.4s; }

@keyframes sparkleFlash {
    0%, 85%, 100% { opacity: 0; transform: scale(0.5); }
    90% { opacity: 0.6; transform: scale(1.2); }
    95% { opacity: 0.3; transform: scale(0.8); }
}

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

/* ---------- Panel Base Styles ---------- */
.panel {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    z-index: 1;
}

.panel-grid {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
    background:
        repeating-linear-gradient(
            3deg,
            transparent,
            transparent calc(12.5% - 1px),
            #3D1525 calc(12.5% - 1px),
            #3D1525 12.5%
        ),
        repeating-linear-gradient(
            93deg,
            transparent,
            transparent calc(12.5% - 1px),
            #3D1525 calc(12.5% - 1px),
            #3D1525 12.5%
        );
}

.panel-grid-prominent {
    opacity: 0.5;
}

.panel-content {
    position: relative;
    z-index: 5;
    max-width: 1200px;
    margin: 0 auto;
    padding: 8vh 5vw;
}

/* ---------- Panel 1: Hero ---------- */
.panel-hero {
    background: #2B0F1A;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 4vw), 0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.hero-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.hero-title {
    position: relative;
    font-size: clamp(3rem, 9vw, 7rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 2rem;
}

.chrome-text {
    display: block;
    font-family: 'Bungee', Impact, sans-serif;
    background: linear-gradient(135deg, #E8D5E0, #FFFFFF, #C4A6B5, #FFFFFF, #E8D5E0);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: chromeShift 4s ease-in-out infinite;
}

@keyframes chromeShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.outline-text {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    font-family: 'Bungee Outline', Impact, sans-serif;
    color: #3D1525;
    pointer-events: none;
}

.hero-subtitle {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: clamp(1rem, 2.5vw, 1.75rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #E8D5E0;
    margin-bottom: 2rem;
    opacity: 0.85;
}

.hero-diamond {
    margin-top: 1rem;
}

.diamond-shape {
    width: 30px;
    height: 30px;
    background: transparent;
    border: 2px solid #FF69B4;
    transform: rotate(45deg);
    animation: diamondSpin 8s linear infinite;
}

.diamond-glow {
    background: radial-gradient(circle, #FF69B4 0%, transparent 70%);
    opacity: 0.8;
}

@keyframes diamondSpin {
    0% { transform: rotate(45deg); }
    100% { transform: rotate(405deg); }
}

/* ---------- Panel 2: Thesis ---------- */
.panel-thesis {
    background: #2B0F1A;
    clip-path: polygon(0 4vw, 100% 0, 100% 100%, 0 calc(100% - 4vw));
    margin-top: -4vw;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.thesis-content {
    display: flex;
    align-items: center;
    gap: 3vw;
    padding: 12vh 3vw;
}

.thesis-icons {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    flex-shrink: 0;
    width: 140px;
}

.thesis-icons-left .icon-item {
    transform: translateX(-60px);
    opacity: 0;
    transition: transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 800ms ease-out;
}

.thesis-icons-right .icon-item {
    transform: translateX(60px);
    opacity: 0;
    transition: transform 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 800ms ease-out;
}

.thesis-icons-left .icon-item.visible,
.thesis-icons-right .icon-item.visible {
    transform: translateX(0);
    opacity: 1;
}

.thesis-icons-left .icon-item:nth-child(2),
.thesis-icons-right .icon-item:nth-child(2) { transition-delay: 100ms; }
.thesis-icons-left .icon-item:nth-child(3),
.thesis-icons-right .icon-item:nth-child(3) { transition-delay: 200ms; }
.thesis-icons-left .icon-item:nth-child(4),
.thesis-icons-right .icon-item:nth-child(4) { transition-delay: 300ms; }
.thesis-icons-left .icon-item:nth-child(5),
.thesis-icons-right .icon-item:nth-child(5) { transition-delay: 400ms; }
.thesis-icons-left .icon-item:nth-child(6),
.thesis-icons-right .icon-item:nth-child(6) { transition-delay: 500ms; }

.icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.system-icon {
    width: 80px;
    height: 80px;
    fill: none;
    stroke: #E8D5E0;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 300ms ease, filter 300ms ease, transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.icon-accent-fill {
    fill: #FF69B4;
    stroke: #FF69B4;
}

.system-icon:hover {
    stroke: url(#chromeGradient);
    filter: drop-shadow(0 0 6px rgba(255, 105, 180, 0.4));
}

.icon-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8C5A6E;
}

.thesis-text {
    flex: 1;
    text-align: center;
}

.thesis-statement {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    line-height: 1.8;
    color: #C4A6B5;
    max-width: 600px;
    margin: 0 auto;
}

/* ---------- Module Panels ---------- */
.panel-module-1 {
    background: #2B0F1A;
    clip-path: polygon(0 0, 100% 4vw, 100% calc(100% - 4vw), 0 100%);
    margin-top: -4vw;
}

.panel-module-2 {
    clip-path: polygon(0 4vw, 100% 0, 100% 100%, 0 calc(100% - 5vw));
    margin-top: -4vw;
}

.panel-light {
    background: #F2E6EB;
    color: #2B0F1A;
}

.panel-light .panel-grid {
    background:
        repeating-linear-gradient(
            -3deg,
            transparent,
            transparent calc(12.5% - 1px),
            rgba(61, 21, 37, 0.12) calc(12.5% - 1px),
            rgba(61, 21, 37, 0.12) 12.5%
        ),
        repeating-linear-gradient(
            87deg,
            transparent,
            transparent calc(12.5% - 1px),
            rgba(61, 21, 37, 0.12) calc(12.5% - 1px),
            rgba(61, 21, 37, 0.12) 12.5%
        );
    opacity: 0.4;
}

.panel-module-3 {
    background: #2B0F1A;
    clip-path: polygon(0 5vw, 100% 0, 100% calc(100% - 3vw), 0 100%);
    margin-top: -5vw;
}

.panel-module-4 {
    background: #2B0F1A;
    clip-path: polygon(0 3vw, 100% 0, 100% calc(100% - 4vw), 0 100%);
    margin-top: -3vw;
}

.module-content {
    padding: 10vh 5vw;
}

.module-title {
    position: relative;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 4rem;
    line-height: 1.2;
}

.module-title .chrome-text,
.module-title .outline-text {
    font-size: inherit;
}

/* Dark versions for light panel */
.chrome-text-dark {
    display: block;
    font-family: 'Bungee', Impact, sans-serif;
    background: linear-gradient(135deg, #3D1525, #1A0A12, #8C5A6E, #1A0A12, #3D1525);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: chromeShift 4s ease-in-out infinite;
}

.outline-text-dark {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    font-family: 'Bungee Outline', Impact, sans-serif;
    color: #D4A0C0;
    pointer-events: none;
    text-align: center;
}

/* ---------- Module Diagrams ---------- */
.module-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.diagram-cluster {
    width: 100%;
    max-width: 500px;
}

.diagram-svg {
    width: 100%;
    height: auto;
}

.node-main {
    fill: none;
    stroke: #E8D5E0;
    stroke-width: 2;
}

.node-secondary {
    fill: none;
    stroke: #D4A0C0;
    stroke-width: 2;
}

.node-tertiary {
    fill: none;
    stroke: #8C5A6E;
    stroke-width: 1.5;
}

.node-loop {
    fill: none;
    stroke: #3D1525;
    stroke-width: 1.5;
    stroke-dasharray: 8 4;
}

.node-main-dark {
    fill: none;
    stroke: #3D1525;
    stroke-width: 2;
}

.node-center-accent {
    fill: #FF69B4;
    stroke: none;
}

.node-emergence {
    fill: none;
    stroke: #E8D5E0;
    stroke-width: 1.5;
    stroke-dasharray: 4 3;
}

.node-emergence-inner {
    fill: none;
    stroke: #D4A0C0;
    stroke-width: 1;
}

.cell-active {
    fill: rgba(255, 105, 180, 0.3);
    stroke: #E8D5E0;
    stroke-width: 1;
}

.cell-inactive {
    fill: none;
    stroke: #3D1525;
    stroke-width: 1;
}

.diagram-path {
    fill: none;
    stroke: #E8D5E0;
    stroke-width: 1.5;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease-out;
}

.diagram-path.drawn {
    stroke-dashoffset: 0;
}

.diagram-path-accent {
    stroke: #FF69B4;
    stroke-width: 1;
    stroke-dasharray: 4 3;
}

.diagram-path-dark {
    fill: none;
    stroke: #2B0F1A;
    stroke-width: 1.5;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease-out;
}

.diagram-path-dark.drawn {
    stroke-dashoffset: 0;
}

.arrow-head-dark {
    fill: #2B0F1A;
    stroke: none;
}

/* ---------- Annotations ---------- */
.module-annotations {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    max-width: 900px;
    width: 100%;
}

.annotation {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.annotation p {
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    line-height: 1.7;
}

.panel-light .annotation p {
    color: #2B0F1A;
}

/* ---------- Diamond Bullets ---------- */
.diamond-bullet {
    display: inline-block;
    width: 10px;
    height: 10px;
    min-width: 10px;
    border: 1px solid #E8D5E0;
    transform: rotate(45deg);
    margin-top: 0.5rem;
    flex-shrink: 0;
}

.panel-light .diamond-bullet {
    border-color: #3D1525;
}

.diamond-bullet-inline {
    display: inline-block;
    width: 6px;
    height: 6px;
    border: 1px solid #8C5A6E;
    transform: rotate(45deg);
    margin: 0 0.5em;
    vertical-align: middle;
}

/* ---------- Panel 7: Index ---------- */
.panel-index {
    background: #2B0F1A;
    clip-path: polygon(0 0, 100% 3vw, 100% calc(100% - 3vw), 0 100%);
    margin-top: -3vw;
    min-height: 80vh;
}

.index-content {
    padding: 10vh 5vw;
}

.index-title {
    margin-bottom: 3rem;
}

.index-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem 4rem;
    max-width: 800px;
    margin: 0 auto;
}

.index-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.index-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 2px;
    transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94), background 300ms ease;
    cursor: default;
}

.index-row:hover {
    background: rgba(255, 105, 180, 0.06);
}

.index-row:hover .index-icon {
    stroke: #FFFFFF;
    filter: drop-shadow(0 0 4px rgba(255, 105, 180, 0.5));
}

.index-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    fill: none;
    stroke: #E8D5E0;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 300ms ease, filter 300ms ease;
}

.index-term {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #C4A6B5;
    transition: color 300ms ease;
}

.index-row:hover .index-term {
    color: #FF69B4;
}

/* ---------- Panel 8: Colophon ---------- */
.panel-colophon {
    background: #1A0A12;
    clip-path: polygon(0 6vw, 100% 0, 100% 100%, 0 100%);
    margin-top: -6vw;
    min-height: 40vh;
    display: flex;
    align-items: center;
}

.colophon-content {
    padding: 12vh 5vw 8vh;
    max-width: 900px;
}

.colophon-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.65rem, 0.9vw, 0.8rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8C5A6E;
    line-height: 2.2;
}

/* ---------- Subheading Styles (Outfit) ---------- */
.subheading {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: clamp(1rem, 2.5vw, 1.75rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #E8D5E0;
}

.panel-light .subheading {
    color: #2B0F1A;
}

/* ---------- Magnetic Element Base ---------- */
[data-magnetic] {
    transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

/* ---------- Panel Entry Animation ---------- */
.panel {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 1000ms ease-out, transform 1000ms ease-out;
}

.panel.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Responsive Adjustments ---------- */
@media (max-width: 768px) {
    .thesis-content {
        flex-direction: column;
        gap: 2rem;
    }

    .thesis-icons {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        width: auto;
        gap: 1rem;
    }

    .system-icon {
        width: 50px;
        height: 50px;
    }

    .module-annotations {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .index-columns {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .hero-subtitle {
        font-size: clamp(0.8rem, 3vw, 1.2rem);
    }
}

@media (max-width: 480px) {
    .thesis-icons {
        display: none;
    }

    .panel-content {
        padding: 6vh 4vw;
    }

    .hero-subtitle {
        font-size: clamp(0.7rem, 2.5vw, 1rem);
        letter-spacing: 0.06em;
    }
}
