/* =========================================================
   SIM-AI.XYZ - Pop Art + Watercolor + Circuit Simulation
   ========================================================= */

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

:root {
    --warm-canvas: #f2ebe0;
    --sepia-ink: #3a2e24;
    --pop-orange: #d4723c;
    --watercolor-teal: #5a9e8f;
    --halftone-rose: #c87a6e;
    --circuit-gold: #b89850;
    --parchment-light: #faf5ed;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Merriweather', Georgia, serif;
    font-size: clamp(15px, 1.5vw, 17px);
    line-height: 1.75;
    color: var(--sepia-ink);
    background: var(--warm-canvas);
    overflow-x: hidden;
}

/* --- Halftone Dot Background Pattern --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--halftone-rose) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.04;
    pointer-events: none;
    z-index: 0;
}

/* =========================================================
   HERO SECTION
   ========================================================= */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--warm-canvas);
    overflow: hidden;
    opacity: 0;
    animation: fadeInCanvas 0.6s ease-out 0s forwards;
}

@keyframes fadeInCanvas {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Halftone overlay on hero */
.halftone-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, var(--halftone-rose) 1.5px, transparent 1.5px);
    background-size: 12px 12px;
    opacity: 0;
    animation: halftoneExpand 0.8s ease-out 2.2s forwards;
    pointer-events: none;
    z-index: 1;
}

@keyframes halftoneExpand {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 0.06;
        transform: scale(1);
    }
}

/* Watercolor washes */
.watercolor-wash {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

.wash-1 {
    top: 10%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--pop-orange) 0%, transparent 70%);
    opacity: 0.06;
}

.wash-2 {
    bottom: 5%;
    right: -15%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--watercolor-teal) 0%, transparent 70%);
    opacity: 0.07;
}

/* Burst Rays SVG */
#burst-rays {
    position: absolute;
    width: min(80vw, 800px);
    height: min(80vw, 800px);
    z-index: 2;
    pointer-events: none;
}

.burst-ray {
    stroke: var(--pop-orange);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawRay 0.8s ease-out forwards;
    animation-delay: calc(600ms + var(--ray-delay, 0ms));
}

@keyframes drawRay {
    to {
        stroke-dashoffset: 0;
    }
}

/* Monitor */
#monitor {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    animation: monitorAppear 0.8s ease-out 1.4s forwards;
}

@keyframes monitorAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.monitor-screen {
    width: clamp(280px, 50vw, 480px);
    height: clamp(180px, 28vw, 300px);
    background: var(--parchment-light);
    border: 4px solid var(--sepia-ink);
    border-radius: 12px 12px 4px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 8px 8px 0 var(--sepia-ink);
}

.monitor-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 3px,
        rgba(58, 46, 36, 0.03) 3px,
        rgba(58, 46, 36, 0.03) 4px
    );
    pointer-events: none;
}

.hero-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(40px, 8vw, 80px);
    color: var(--sepia-ink);
    letter-spacing: 4px;
    text-align: center;
    line-height: 1;
    opacity: 0;
    animation: bounceIn 0.5s ease-out 1.8s forwards;
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(1.3);
    }
    60% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.hero-subtitle {
    font-family: 'Fira Mono', monospace;
    font-size: clamp(12px, 1.5vw, 16px);
    color: var(--pop-orange);
    letter-spacing: 6px;
    text-transform: uppercase;
    margin-top: 8px;
    opacity: 0;
    animation: fadeIn 0.6s ease-out 2.2s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.monitor-stand {
    width: 40px;
    height: 30px;
    background: var(--sepia-ink);
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}

.monitor-base {
    width: 100px;
    height: 8px;
    background: var(--sepia-ink);
    border-radius: 0 0 4px 4px;
}

/* Scroll Hint */
.hero-scroll-hint {
    position: absolute;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 4;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 3s forwards;
}

.hero-scroll-hint span {
    font-family: 'Fira Mono', monospace;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--sepia-ink);
    opacity: 0.5;
}

.hero-scroll-hint svg {
    animation: bounceDown 1.5s ease-in-out infinite;
}

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

/* =========================================================
   COMIC PANEL BREAKS
   ========================================================= */
.comic-panel-break {
    position: relative;
    width: 100%;
    padding: 3rem 1.5rem;
    background: var(--warm-canvas);
    border-top: 3px solid var(--sepia-ink);
    border-bottom: 3px solid var(--sepia-ink);
    z-index: 1;
}

.comic-strip {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    gap: 0;
    flex-wrap: wrap;
}

.comic-frame {
    flex: 1 1 250px;
    min-height: 200px;
    border: 3px solid var(--sepia-ink);
    padding: 1.5rem;
    position: relative;
    background: var(--parchment-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.comic-frame + .comic-frame {
    border-left: 0;
}

.frame-wide {
    flex: 1 1 100%;
    min-height: 300px;
}

/* Speech Bubbles */
.speech-bubble {
    background: #fff;
    border: 2.5px solid var(--sepia-ink);
    border-radius: 18px;
    padding: 1rem 1.2rem;
    position: relative;
    max-width: 220px;
}

.speech-bubble p {
    font-size: clamp(13px, 1.3vw, 15px);
    line-height: 1.5;
}

.bubble-left::after {
    content: '';
    position: absolute;
    bottom: -14px;
    left: 30px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 14px solid var(--sepia-ink);
}

.bubble-left::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 32px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 12px solid #fff;
    z-index: 1;
}

.bubble-right::after {
    content: '';
    position: absolute;
    bottom: -14px;
    right: 30px;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 14px solid var(--sepia-ink);
}

.bubble-right::before {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 32px;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 12px solid #fff;
    z-index: 1;
}

/* Comic Characters */
.character-svg {
    width: 80px;
    height: 110px;
}

.frame-caption {
    text-align: center;
}

.caption-text {
    font-family: 'Bangers', cursive;
    font-size: clamp(20px, 3vw, 32px);
    color: var(--pop-orange);
    letter-spacing: 1px;
}

.illustration-svg {
    width: 100%;
    max-width: 300px;
}

.panel-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(24px, 4vw, 42px);
    color: var(--sepia-ink);
    text-align: center;
    margin-bottom: 1rem;
    letter-spacing: 2px;
}

.architecture-diagram {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    display: block;
}

/* =========================================================
   SECTION TITLES
   ========================================================= */
.section-title {
    font-family: 'Bangers', cursive;
    font-size: clamp(32px, 5vw, 60px);
    color: var(--sepia-ink);
    text-align: center;
    padding: 3rem 1rem 2rem;
    letter-spacing: 2px;
    position: relative;
    z-index: 1;
}

.section-title::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: var(--pop-orange);
    margin: 0.5rem auto 0;
    border-radius: 2px;
}

/* =========================================================
   MASONRY GALLERY
   ========================================================= */
#masonry-gallery,
#masonry-gallery-2 {
    position: relative;
    padding: 0 1.5rem 3rem;
    max-width: 1200px;
    margin: 0 auto;
    z-index: 1;
}

/* Circuit board background pattern */
#masonry-gallery::before,
#masonry-gallery-2::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cline x1='0' y1='30' x2='20' y2='30' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='20' y1='30' x2='20' y2='10' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='20' y1='10' x2='40' y2='10' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='40' y1='10' x2='40' y2='50' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='40' y1='50' x2='60' y2='50' stroke='%23b89850' stroke-width='1'/%3E%3Ccircle cx='20' cy='30' r='2.5' fill='%23b89850'/%3E%3Ccircle cx='40' cy='10' r='2.5' fill='%23b89850'/%3E%3Ccircle cx='40' cy='50' r='2.5' fill='%23b89850'/%3E%3C/svg%3E") repeat;
    opacity: 0.06;
    pointer-events: none;
    z-index: -1;
}

.masonry-grid {
    column-count: 3;
    column-gap: 1.5rem;
}

/* =========================================================
   MASONRY CARDS
   ========================================================= */
.masonry-card {
    break-inside: avoid;
    border: 2px solid var(--sepia-ink);
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: var(--parchment-light);
    transform: rotate(var(--card-rotation, 0deg));
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: visible;
}

.masonry-card:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 6px 6px 0 var(--sepia-ink);
}

/* Card Variants */
.card-watercolor::before {
    content: '';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, var(--pop-orange) 0%, transparent 70%);
    opacity: 0.08;
    border-radius: 50%;
    pointer-events: none;
}

.card-watercolor::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: -5px;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, var(--watercolor-teal) 0%, transparent 70%);
    opacity: 0.1;
    border-radius: 50%;
    pointer-events: none;
}

.card-halftone {
    background-image: radial-gradient(circle, var(--halftone-rose) 0.8px, transparent 0.8px);
    background-size: 8px 8px;
    background-color: var(--parchment-light);
}

.card-halftone::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--parchment-light);
    opacity: 0.92;
    pointer-events: none;
}

.card-halftone > * {
    position: relative;
    z-index: 1;
}

.card-circuit {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cline x1='0' y1='30' x2='20' y2='30' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='20' y1='30' x2='20' y2='10' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='20' y1='10' x2='40' y2='10' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='40' y1='10' x2='40' y2='50' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='40' y1='50' x2='60' y2='50' stroke='%23b89850' stroke-width='1'/%3E%3Ccircle cx='20' cy='30' r='2.5' fill='%23b89850'/%3E%3Ccircle cx='40' cy='10' r='2.5' fill='%23b89850'/%3E%3Ccircle cx='40' cy='50' r='2.5' fill='%23b89850'/%3E%3C/svg%3E");
    background-color: var(--parchment-light);
}

.card-circuit::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--parchment-light);
    opacity: 0.9;
    pointer-events: none;
}

.card-circuit > * {
    position: relative;
    z-index: 1;
}

/* Card Badge */
.card-badge {
    position: absolute;
    top: -8px;
    right: 12px;
    background: var(--pop-orange);
    color: var(--parchment-light);
    font-family: 'Bangers', cursive;
    font-size: 18px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid var(--sepia-ink);
    z-index: 2;
}

/* Card Title */
.card-title {
    font-family: 'Archivo Black', sans-serif;
    font-size: clamp(16px, 2vw, 22px);
    color: var(--sepia-ink);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

/* Card Body */
.card-body {
    font-size: clamp(14px, 1.3vw, 16px);
    line-height: 1.7;
    color: var(--sepia-ink);
    margin-bottom: 0.75rem;
}

/* Card Tag */
.card-tag {
    display: inline-block;
    font-family: 'Fira Mono', monospace;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--watercolor-teal);
    border: 1.5px solid var(--watercolor-teal);
    padding: 3px 10px;
    border-radius: 2px;
    margin-top: 0.5rem;
}

/* Card Detail / Code */
.card-detail {
    margin: 1rem 0 0.5rem;
}

.code-snippet {
    display: block;
    font-family: 'Fira Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    background: var(--warm-canvas);
    border: 1px solid var(--circuit-gold);
    border-left: 3px solid var(--circuit-gold);
    padding: 0.75rem 1rem;
    color: var(--sepia-ink);
    border-radius: 0 4px 4px 0;
}

/* Card Quote */
.card-quote blockquote {
    font-style: italic;
    font-size: clamp(15px, 1.5vw, 18px);
    color: var(--pop-orange);
    border-left: 3px solid var(--pop-orange);
    padding-left: 1rem;
    margin: 1rem 0 0.5rem;
}

.card-quote cite {
    font-size: 13px;
    color: var(--sepia-ink);
    opacity: 0.7;
    font-style: normal;
}

/* Card Stat */
.card-stat {
    text-align: center;
    margin: 1rem 0 0.5rem;
}

.stat-number {
    display: block;
    font-family: 'Bangers', cursive;
    font-size: clamp(28px, 4vw, 42px);
    color: var(--pop-orange);
    letter-spacing: 1px;
}

.stat-label {
    display: block;
    font-family: 'Fira Mono', monospace;
    font-size: 11px;
    color: var(--sepia-ink);
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Card Scale Viz */
.card-scale-viz {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin: 1rem 0 0.5rem;
    flex-wrap: wrap;
}

.scale-level {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--circuit-gold);
    border-radius: 4px;
    background: var(--warm-canvas);
}

.scale-level[data-level="quantum"] {
    border-color: var(--watercolor-teal);
}

.scale-level[data-level="molecular"] {
    border-color: var(--pop-orange);
}

.scale-level[data-level="macro"] {
    border-color: var(--circuit-gold);
}

.scale-label {
    font-family: 'Archivo Black', sans-serif;
    font-size: 12px;
    color: var(--sepia-ink);
}

.scale-size {
    font-family: 'Fira Mono', monospace;
    font-size: 11px;
    color: var(--sepia-ink);
    opacity: 0.7;
}

.scale-arrow {
    font-size: 20px;
    color: var(--circuit-gold);
    font-weight: 700;
}

/* Featured Card */
.card-featured {
    border-width: 3px;
    border-color: var(--pop-orange);
    background: var(--parchment-light);
}

.card-featured .card-title {
    color: var(--pop-orange);
}

/* Circuit Diagrams */
.circuit-diagram {
    width: 100%;
    max-width: 280px;
    margin: 0.5rem auto;
    display: block;
}

/* Agent Dots SVG */
.agent-dots-svg {
    width: 100%;
    max-width: 200px;
    display: block;
    margin: 0.5rem auto;
}

/* Card Illustrations */
.card-illustration {
    display: flex;
    justify-content: center;
    margin: 0.5rem 0;
}

.molecule-svg {
    width: 100%;
    max-width: 200px;
}

/* =========================================================
   PATH-DRAW ANIMATIONS
   ========================================================= */
.circuit-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2.5s ease-in-out;
}

.circuit-node {
    transform: scale(0);
    transform-origin: center;
    transform-box: fill-box;
    transition: transform 0.4s ease-out;
}

.circuit-path.animated {
    stroke-dashoffset: 0;
}

.circuit-node.animated {
    transform: scale(1);
}

/* =========================================================
   FOOTER
   ========================================================= */
#footer {
    position: relative;
    padding: 3rem 1.5rem;
    background: var(--sepia-ink);
    text-align: center;
    overflow: hidden;
    z-index: 1;
}

.footer-circuit-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cline x1='0' y1='30' x2='20' y2='30' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='20' y1='30' x2='20' y2='10' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='20' y1='10' x2='40' y2='10' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='40' y1='10' x2='40' y2='50' stroke='%23b89850' stroke-width='1'/%3E%3Cline x1='40' y1='50' x2='60' y2='50' stroke='%23b89850' stroke-width='1'/%3E%3Ccircle cx='20' cy='30' r='2.5' fill='%23b89850'/%3E%3Ccircle cx='40' cy='10' r='2.5' fill='%23b89850'/%3E%3Ccircle cx='40' cy='50' r='2.5' fill='%23b89850'/%3E%3C/svg%3E") repeat;
    opacity: 0.1;
    pointer-events: none;
}

.footer-content {
    position: relative;
    z-index: 1;
}

.footer-logo {
    margin-bottom: 0.5rem;
}

.footer-logo-text {
    font-family: 'Bangers', cursive;
    font-size: clamp(28px, 4vw, 40px);
    color: var(--parchment-light);
    letter-spacing: 3px;
}

.footer-logo-dot {
    font-family: 'Bangers', cursive;
    font-size: clamp(28px, 4vw, 40px);
    color: var(--pop-orange);
    letter-spacing: 3px;
}

.footer-tagline {
    font-family: 'Fira Mono', monospace;
    font-size: 13px;
    color: var(--halftone-rose);
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 1.5rem;
}

.footer-dots {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.footer-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--circuit-gold);
    opacity: 0.6;
}

.footer-dots .dot:nth-child(2) {
    background: var(--pop-orange);
}

.footer-dots .dot:nth-child(3) {
    background: var(--watercolor-teal);
}

.footer-dots .dot:nth-child(4) {
    background: var(--halftone-rose);
}

/* =========================================================
   SCROLL REVEAL ANIMATIONS
   ========================================================= */
.masonry-card {
    opacity: 0;
    transform: rotate(var(--card-rotation, 0deg)) translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, box-shadow 0.3s ease;
}

.masonry-card.visible {
    opacity: 1;
    transform: rotate(var(--card-rotation, 0deg)) translateY(0);
}

.masonry-card.visible:hover {
    transform: rotate(0deg) translateY(-3px);
    box-shadow: 6px 6px 0 var(--sepia-ink);
}

.comic-frame {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.comic-frame.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
    .masonry-grid {
        column-count: 2;
    }

    .comic-strip {
        flex-direction: column;
    }

    .comic-frame + .comic-frame {
        border-left: 3px solid var(--sepia-ink);
        border-top: 0;
    }
}

@media (max-width: 600px) {
    .masonry-grid {
        column-count: 1;
    }

    .comic-frame {
        min-height: 160px;
    }

    .speech-bubble {
        max-width: 100%;
    }

    #hero {
        min-height: 500px;
    }
}

/* =========================================================
   AGENT DOT ANIMATION
   ========================================================= */
.agent-dot {
    animation: agentFloat 3s ease-in-out infinite alternate;
}

.agent-dot:nth-child(2) { animation-delay: 0.3s; }
.agent-dot:nth-child(3) { animation-delay: 0.6s; }
.agent-dot:nth-child(4) { animation-delay: 0.9s; }
.agent-dot:nth-child(5) { animation-delay: 1.2s; }
.agent-dot:nth-child(6) { animation-delay: 1.5s; }
.agent-dot:nth-child(7) { animation-delay: 1.8s; }
.agent-dot:nth-child(8) { animation-delay: 2.1s; }

@keyframes agentFloat {
    0% { transform: translate(0, 0); }
    100% { transform: translate(3px, -3px); }
}
