/* chrono.games - Graffiti-informed broken-grid design */
/* Colors: #6b1d3a (burgundy), #f5edd6 (cream), #8c8578 (concrete gray), #e8443a (neon coral), 
   #1e1a1a (charcoal), #2a7d6e (teal), #c9a227 (mustard), #e8dcc4 (mid wall), #d4c8a8 (deep wall) */

@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&family=Caveat+Brush&family=Patrick+Hand&family=VT323&display=swap');

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Patrick Hand', cursive;
    font-size: 17px;
    line-height: 1.65;
    color: #1e1a1a;
    background: linear-gradient(
        to bottom,
        #f5edd6 0%,
        #f5edd6 20%,
        #e8dcc4 50%,
        #d4c8a8 80%,
        #d4c8a8 100%
    );
    background-attachment: fixed;
    min-height: 480vh;
    overflow-x: hidden;
    position: relative;
}

/* Concrete texture overlay via pseudo-element */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background:
        repeating-linear-gradient(
            87deg,
            transparent,
            transparent 120px,
            rgba(140, 133, 120, 0.04) 120px,
            rgba(140, 133, 120, 0.04) 121px
        ),
        repeating-linear-gradient(
            2deg,
            transparent,
            transparent 80px,
            rgba(140, 133, 120, 0.03) 80px,
            rgba(140, 133, 120, 0.03) 81px
        ),
        repeating-linear-gradient(
            135deg,
            transparent,
            transparent 200px,
            rgba(140, 133, 120, 0.05) 200px,
            rgba(140, 133, 120, 0.05) 201px
        );
}

/* Noise texture on body */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.3;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(140,133,120,0.15) 1px, transparent 1px),
        radial-gradient(circle at 80% 70%, rgba(140,133,120,0.12) 1px, transparent 1px),
        radial-gradient(circle at 50% 50%, rgba(140,133,120,0.1) 1px, transparent 1px),
        radial-gradient(circle at 10% 80%, rgba(140,133,120,0.13) 1px, transparent 1px),
        radial-gradient(circle at 90% 20%, rgba(140,133,120,0.11) 1px, transparent 1px);
    background-size: 7px 7px, 11px 11px, 13px 13px, 9px 9px, 15px 15px;
}

/* === SECTIONS === */
.section {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    padding: 60px 20px;
}

/* === SECTION 1: HERO === */
.section-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.hero-tag {
    position: relative;
    width: 90%;
    max-width: 900px;
    transform: rotate(-3deg);
}

.hero-svg {
    width: 100%;
    height: auto;
    overflow: visible;
}

.hero-text-stroke,
.hero-text-fill {
    font-family: 'Permanent Marker', cursive;
    font-size: 160px;
    letter-spacing: -0.03em;
}

.hero-text-stroke {
    fill: none;
    stroke: #6b1d3a;
    stroke-width: 3;
    stroke-dasharray: 1500;
    stroke-dashoffset: 1500;
    animation: drawStroke 2.5s ease-out forwards;
}

.hero-text-fill {
    fill: #6b1d3a;
    clip-path: inset(0 100% 0 0);
    animation: fillReveal 1.2s ease-out 2s forwards;
}

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

@keyframes fillReveal {
    to { clip-path: inset(0 0% 0 0); }
}

.hero-games-stencil {
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(48px, 10vw, 100px);
    color: #f5edd6;
    text-shadow: 3px 3px 0 #1e1a1a, -1px -1px 0 #1e1a1a;
    -webkit-text-stroke: 2px #1e1a1a;
    letter-spacing: 0.06em;
    margin-left: 35%;
    margin-top: -20px;
    transform: rotate(2deg);
    opacity: 0;
    animation: stencilAppear 0.8s ease-out 2.8s forwards;
}

@keyframes stencilAppear {
    from { opacity: 0; transform: rotate(2deg) translateY(15px); }
    to { opacity: 1; transform: rotate(2deg) translateY(0); }
}

.stencil-char {
    display: inline-block;
}

/* Drip lines */
.drip-lines {
    width: 100%;
    height: auto;
    position: absolute;
    bottom: -100px;
    left: 0;
}

.drip {
    fill: none;
    stroke: #6b1d3a;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: dripDown 1.5s ease-in 3.3s forwards;
}

.drip-2 { stroke-width: 2; animation-delay: 3.5s; }
.drip-3 { stroke-width: 2.5; animation-delay: 3.7s; }
.drip-4 { stroke-width: 1.5; animation-delay: 3.4s; }

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

/* Stencil icons (scattered) */
.stencil-icon {
    position: absolute;
    z-index: 3;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.stencil-icon:hover {
    opacity: 1;
}

/* === SECTION 2: CARDS === */
.section-cards {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    padding: 80px 40px;
    min-height: 100vh;
    position: relative;
}

.card {
    width: 320px;
    transform: rotate(var(--rotate, 0deg)) translateX(var(--offset-x, 0px));
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
}

.card-inner {
    background: #f5edd6;
    padding: 30px 25px;
    border: 3px solid #1e1a1a;
    box-shadow: 4px 6px 0 #1e1a1a;
    position: relative;
    clip-path: polygon(
        0% 2%, 3% 0%, 8% 1%, 15% 0%, 22% 2%, 30% 0%, 38% 1%, 45% 0%, 52% 2%, 60% 0%, 
        68% 1%, 75% 0%, 82% 2%, 90% 0%, 95% 1%, 100% 0%, 
        100% 98%, 97% 100%, 92% 99%, 85% 100%, 78% 98%, 70% 100%, 62% 99%, 55% 100%, 
        48% 98%, 40% 100%, 32% 99%, 25% 100%, 18% 98%, 10% 100%, 5% 99%, 0% 100%
    );
}

.card:hover {
    transform: rotate(var(--rotate, 0deg)) translateX(var(--offset-x, 0px)) translate(2px, -3px);
}

.card:hover .card-inner {
    box-shadow: 6px 8px 0 #1e1a1a;
}

.card-title {
    font-family: 'Permanent Marker', cursive;
    font-size: 36px;
    color: #6b1d3a;
    line-height: 0.88;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
}

.card-title span {
    display: inline-block;
}

.card-body {
    font-family: 'Patrick Hand', cursive;
    font-size: 17px;
    line-height: 1.65;
    color: #1e1a1a;
    margin-bottom: 12px;
}

.card-badge {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: #2a7d6e;
    background: #1e1a1a;
    padding: 3px 10px;
    display: inline-block;
    letter-spacing: 0.1em;
}

/* Card overlap positioning */
.card-1 { margin-top: 40px; z-index: 3; }
.card-2 { margin-top: -30px; z-index: 4; }
.card-3 { margin-top: 20px; z-index: 2; }

/* === SECTION 3: CARTRIDGES === */
.section-cartridges {
    min-height: 100vh;
    padding: 80px 30px;
    position: relative;
}

.section-heading {
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(48px, 8vw, 96px);
    color: #6b1d3a;
    line-height: 0.88;
    letter-spacing: -0.03em;
    transform: rotate(-2deg);
    margin-bottom: 50px;
    margin-left: 5%;
}

.section-heading span {
    display: inline-block;
}

.cartridge-shelf {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-end;
    gap: 25px;
    padding: 20px;
}

.cartridge {
    transform: scale(var(--scale, 1)) translateY(var(--y-offset, 0px));
    transition: transform 0.3s ease;
}

.cartridge:hover {
    transform: scale(calc(var(--scale, 1) * 1.05)) translateY(calc(var(--y-offset, 0px) - 8px));
}

.cartridge-body {
    width: 140px;
    height: 200px;
    border-radius: 8px 8px 4px 4px;
    border: 3px solid #1e1a1a;
    position: relative;
    overflow: hidden;
    box-shadow: 3px 5px 0 #1e1a1a;
}

.cartridge-1 .cartridge-body { background: #6b1d3a; }
.cartridge-2 .cartridge-body { background: #2a7d6e; }
.cartridge-3 .cartridge-body { background: #c9a227; }
.cartridge-4 .cartridge-body { background: #8c8578; }
.cartridge-5 .cartridge-body { background: #e8443a; }

.cartridge-label {
    background: #f5edd6;
    margin: 15px 12px;
    padding: 12px 8px;
    border: 2px solid #1e1a1a;
    border-radius: 3px;
    text-align: center;
    position: relative;
}

.cartridge-title {
    font-family: 'Caveat Brush', cursive;
    font-size: 18px;
    line-height: 1.1;
    color: #1e1a1a;
    display: block;
    font-weight: bold;
}

.cartridge-year {
    font-family: 'VT323', monospace;
    font-size: 12px;
    color: #8c8578;
    display: block;
    margin-top: 4px;
}

.cartridge-slot {
    width: 60%;
    height: 18px;
    background: #1e1a1a;
    margin: 0 auto;
    border-radius: 0 0 4px 4px;
    position: absolute;
    bottom: 12px;
    left: 20%;
}

/* Spray clock positioned element */
.spray-clock {
    position: absolute;
    z-index: 3;
    opacity: 0.85;
}

/* === SECTION 4: TIMELINE === */
.section-timeline {
    min-height: 100vh;
    padding: 80px 30px;
    position: relative;
}

.timeline-path {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    min-height: 700px;
}

.timeline-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.timeline-crack {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease-out;
}

.timeline-crack.animated {
    stroke-dashoffset: 0;
}

.timeline-node {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 320px;
}

.node-marker {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 50%;
    background: #e8443a;
    border: 3px solid #1e1a1a;
    box-shadow: 2px 3px 0 #1e1a1a;
}

.node-content {
    background: rgba(245, 237, 214, 0.9);
    padding: 12px 16px;
    border: 2px solid #1e1a1a;
    box-shadow: 3px 4px 0 #1e1a1a;
    transform: rotate(-1deg);
}

.node-year {
    font-family: 'VT323', monospace;
    font-size: 14px;
    color: #2a7d6e;
    display: block;
    letter-spacing: 0.1em;
}

.node-label {
    font-family: 'Caveat Brush', cursive;
    font-size: 24px;
    color: #6b1d3a;
    display: block;
    line-height: 1.1;
}

.node-text {
    font-family: 'Patrick Hand', cursive;
    font-size: 15px;
    color: #1e1a1a;
    line-height: 1.5;
    margin-top: 4px;
}

/* Alternating node rotations */
.timeline-node-1 .node-content { transform: rotate(-2deg); }
.timeline-node-2 .node-content { transform: rotate(1.5deg); }
.timeline-node-3 .node-content { transform: rotate(-1deg); }
.timeline-node-4 .node-content { transform: rotate(2deg); }
.timeline-node-5 .node-content { transform: rotate(-1.5deg); }

/* === SECTION 5: GAME OVER === */
.section-gameover {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 80px 30px;
}

.gameover-block {
    transform: rotate(4deg);
    text-align: center;
}

.gameover-title {
    font-family: 'Permanent Marker', cursive;
    font-size: clamp(56px, 12vw, 120px);
    color: #e8443a;
    line-height: 0.88;
    letter-spacing: -0.03em;
    text-shadow: 4px 5px 0 #1e1a1a;
    margin-bottom: 30px;
}

.gameover-title span {
    display: inline-block;
}

.gameover-line1 {
    display: block;
}

.insert-coin {
    margin-bottom: 30px;
}

.coin-text {
    font-family: 'VT323', monospace;
    font-size: 28px;
    color: #c9a227;
    letter-spacing: 0.15em;
    animation: coinBlink 1.2s step-end infinite;
}

@keyframes coinBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.coin-slot {
    display: inline-block;
    transition: transform 0.2s;
}

.coin-slot:hover {
    transform: scale(1.1);
}

/* Cassette tape */
.cassette {
    position: absolute;
    bottom: 8%;
    right: 8%;
    transform: rotate(-8deg);
}

.cassette-reel {
    animation: reelSpin 3s linear infinite;
    transform-origin: center;
}

.cassette-reel-left {
    animation: reelSpinLeft 3s linear infinite;
}

.cassette-reel-right {
    animation: reelSpinRight 3s linear infinite;
}

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

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

/* === PERSISTENT TIME COUNTER === */
.time-counter {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    background: rgba(30, 26, 26, 0.92);
    border: 1px solid #2a7d6e;
    border-radius: 6px;
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 12px rgba(42, 125, 110, 0.25);
    /* Scanline effect inside */
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(30, 26, 26, 0.3) 2px,
        rgba(30, 26, 26, 0.3) 4px
    );
}

.counter-label {
    font-family: 'VT323', monospace;
    font-size: 10px;
    color: #8c8578;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.counter-value {
    font-family: 'VT323', monospace;
    font-size: 22px;
    color: #2a7d6e;
    letter-spacing: 0.08em;
    text-shadow: 0 0 8px rgba(42, 125, 110, 0.4);
}

/* === STAGGER ANIMATION === */
.stagger-item {
    opacity: 0;
    transform: translateY(30px) rotate(var(--rotate, 0deg));
    transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.stagger-item.visible {
    opacity: 1;
    transform: translateY(0) rotate(var(--rotate, 0deg));
}

/* Different entry directions */
.stagger-item.from-left {
    transform: translateX(-50px) rotate(var(--rotate, 0deg));
}
.stagger-item.from-left.visible {
    transform: translateX(0) rotate(var(--rotate, 0deg));
}

.stagger-item.from-right {
    transform: translateX(50px) rotate(var(--rotate, 0deg));
}
.stagger-item.from-right.visible {
    transform: translateX(0) rotate(var(--rotate, 0deg));
}

.stagger-item.from-tilt {
    transform: rotate(calc(var(--rotate, 0deg) + 8deg)) scale(0.9);
}
.stagger-item.from-tilt.visible {
    transform: rotate(var(--rotate, 0deg)) scale(1);
}

/* === CHECKERBOARD SECTION DIVIDER === */
.section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background-image: 
        repeating-conic-gradient(#6b1d3a 0% 25%, transparent 0% 50%);
    background-size: 16px 16px;
    opacity: 0.04;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,0));
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1), rgba(0,0,0,0));
    pointer-events: none;
}

/* === MOBILE ADAPTATION === */
@media (max-width: 768px) {
    .card {
        --rotate: calc(var(--rotate) * 0.5) !important;
        width: 280px;
    }
    
    .section-cards {
        padding: 60px 20px;
    }
    
    .card-1, .card-2, .card-3 {
        margin-top: 10px;
    }

    .hero-tag {
        transform: rotate(-1.5deg);
    }
    
    .hero-text-stroke, .hero-text-fill {
        font-size: 100px;
    }

    .section-heading {
        transform: rotate(-1deg);
    }

    .gameover-block {
        transform: rotate(2deg);
    }

    .cartridge-shelf {
        gap: 15px;
    }

    .cartridge-body {
        width: 110px;
        height: 160px;
    }

    .timeline-node {
        max-width: 240px;
    }

    .cassette {
        position: relative;
        bottom: auto;
        right: auto;
        margin-top: 30px;
        transform: rotate(-4deg);
    }

    .stencil-icon {
        display: none;
    }
}

@media (max-width: 480px) {
    .hero-text-stroke, .hero-text-fill {
        font-size: 72px;
    }

    .hero-games-stencil {
        font-size: 40px;
        margin-left: 20%;
    }

    .card {
        width: 90%;
        --offset-x: 0px !important;
    }

    .timeline-node {
        position: relative;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        max-width: 100%;
        margin-bottom: 25px;
    }

    .timeline-path {
        min-height: auto;
        display: flex;
        flex-direction: column;
    }

    .timeline-svg {
        display: none;
    }
}
