/* ============================================
   KOPICK — CHOOSE YOUR WORLD
   Styles for worlds.html + destination pages
   ============================================ */

/* ---- WORLDS HUB PAGE ---- */

.worlds-page {
    min-height: 100vh;
    background-color: var(--bg-body);
    background-image: 
        linear-gradient(
            to bottom,
            var(--bg-body) 0%,
            rgba(18, 18, 18, 0.4) 15%,
            rgba(18, 18, 18, 0.4) 85%,
            var(--bg-body) 100%
        ),
        url('assets/images/worlds-lineup.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    padding-top: 100px;
}

[data-theme="light"] .worlds-page {
    background-image: 
        linear-gradient(
            to bottom,
            var(--bg-body) 0%,
            rgba(244, 244, 244, 0.3) 15%,
            rgba(244, 244, 244, 0.3) 85%,
            var(--bg-body) 100%
        ),
        url('assets/images/worlds-lineup.png');
}

.worlds-home-section {
    position: relative;
    width: 100%;
    background-color: var(--bg-body);
    background-image: 
        linear-gradient(
            to bottom,
            var(--bg-body) 0%,
            rgba(18, 18, 18, 0.4) 15%,
            rgba(18, 18, 18, 0.4) 85%,
            #090909 100%
        ),
        url('assets/images/worlds-lineup.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    padding: 60px 0 60px;
    overflow: hidden;
}

[data-theme="light"] .worlds-home-section {
    background-image: 
        linear-gradient(
            to bottom,
            var(--bg-body) 0%,
            rgba(244, 244, 244, 0.3) 15%,
            rgba(244, 244, 244, 0.3) 85%,
            var(--bg-body) 100%
        ),
        url('assets/images/worlds-lineup.png');
}

.worlds-header {
    text-align: center;
    padding: 60px 20px 40px;
}

.worlds-header h1 {
    font-family: 'Bungee', cursive;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--text-main);
    letter-spacing: 4px;
    margin-bottom: 20px;
}

.worlds-subtitle {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(0.85rem, 2vw, 1.1rem);
    color: var(--text-secondary);
    letter-spacing: 3px;
    line-height: 1.8;
    text-transform: uppercase;
}

/* ---- WORLDS GRID ---- */

.worlds-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 40px 80px;
}

/* ---- WORLD CARD ---- */

.world-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 3 / 4;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                box-shadow 0.4s ease;
    will-change: transform;
}

.world-card:hover {
    transform: translateY(-8px) scale(1.02);
}

.world-card:active {
    transform: translateY(-4px) scale(1.01);
}

/* Card image */
.world-card__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease, filter 0.4s ease;
}

.world-card:hover .world-card__image {
    transform: scale(1.06);
    filter: brightness(0.7);
}

/* Card overlay gradient */
.world-card__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.3) 40%,
        rgba(0, 0, 0, 0.1) 100%
    );
    z-index: 1;
    transition: background 0.4s ease;
}

/* Card content */
.world-card__content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30px 25px;
    z-index: 2;
}

.world-card__number {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 3px;
    opacity: 0.5;
    margin-bottom: 8px;
    display: block;
}

.world-card__title {
    font-family: 'Bungee', cursive;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    color: #fff;
    letter-spacing: 2px;
    margin-bottom: 12px;
    line-height: 1.3;
}

.world-card__tagline {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* Card accent bar */
.world-card__accent {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 3;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.world-card:hover .world-card__accent {
    transform: scaleX(1);
}

/* Theme accents per world */
.world-card[data-world="spider"] .world-card__accent { background: #8b0000; }
.world-card[data-world="spider"] .world-card__number { color: #c44; }
.world-card[data-world="spider"]:hover { box-shadow: 0 20px 60px rgba(139, 0, 0, 0.25); }

.world-card[data-world="race"] .world-card__accent { background: #e60012; }
.world-card[data-world="race"] .world-card__number { color: #e60012; }
.world-card[data-world="race"]:hover { box-shadow: 0 20px 60px rgba(230, 0, 18, 0.2); }

.world-card[data-world="jack"] .world-card__accent { background: #c9a84c; }
.world-card[data-world="jack"] .world-card__number { color: #c9a84c; }
.world-card[data-world="jack"]:hover { box-shadow: 0 20px 60px rgba(201, 168, 76, 0.25); }

/* ---- TRANSITION OVERLAY ---- */

#transition-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    overflow: hidden;
    display: none;
}

#transition-overlay.active {
    display: block;
    pointer-events: all;
}

.transition-bg {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
}

/* ---- SPIDER SWARM CANVAS ---- */

.spider-swarm-canvas {
    position: absolute;
    inset: 0;
    z-index: 10;
    width: 100%;
    height: 100%;
}

/* ---- RACE F1 ELEMENTS ---- */

.f1-red-light {
    position: absolute;
    inset: 0;
    background: 
        radial-gradient(ellipse at center, rgba(230, 0, 18, 0.22) 0%, rgba(180, 0, 10, 0.1) 45%, transparent 70%),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, rgba(10, 0, 2, 0.45) 50%, rgba(0, 0, 0, 0.75) 100%);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

.f1-car-track {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 30;
    overflow: hidden;
}

.f1-car-wrapper {
    position: absolute;
    left: 50%;
    top: 50%;
    will-change: transform;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-50%, -50%) translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.f1-car-img {
    width: clamp(750px, 85vw, 1250px);
    max-width: none;
    height: auto;
    display: block;
    user-select: none;
    pointer-events: none;
    transform: translateZ(0);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: high-quality;
}

@media (max-width: 768px) {
    .f1-car-img {
        /* On phone (rotated 90deg), width becomes length: 480px-560px looks stunning */
        width: clamp(380px, 85vh, 560px);
        max-width: none;
    }
}

.f1-speed-line {
    position: absolute;
    height: 2px;
    background: linear-gradient(to left, transparent, rgba(255, 255, 255, 0.95), #e60012, transparent);
    z-index: 25;
    opacity: 0;
    border-radius: 2px;
    will-change: transform, opacity;
    transform: translateZ(0);
}

.f1-speed-line.vertical {
    height: auto;
    width: 2px;
    background: linear-gradient(to top, transparent, rgba(255, 255, 255, 0.95), #e60012, transparent);
}

/* ---- JACK CARD TRANSITION ---- */

.jack-transition-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1200px;
    z-index: 9998;
    background: transparent;
    pointer-events: none;
}

.jack-transition-wrapper.active {
    pointer-events: all;
}

.jack-card-clone {
    will-change: transform, opacity;
    transform-style: preserve-3d;
    border-radius: 16px;
    box-shadow: 0 20px 80px rgba(201, 168, 76, 0.4);
}

.jack-card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.jack-card-face--front {
    z-index: 2;
    transform: rotateY(0deg);
}

.jack-card-face--back {
    transform: rotateY(180deg);
    background: #000;
    border: 2px solid rgba(201, 168, 76, 0.9);
    box-shadow: inset 0 0 30px rgba(201, 168, 76, 0.3), 0 0 50px rgba(201, 168, 76, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.jack-card-face--back img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ============================================
   DESTINATION PAGES
   ============================================ */

.edition-page {
    min-height: 100vh;
    background: #0a0a0a;
    color: #fff;
    padding-top: 80px;
    overflow-x: hidden;
}

/* Edition hero */
.edition-hero {
    position: relative;
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    overflow: hidden;
}

.edition-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.08;
    z-index: 0;
}

.edition-hero h1 {
    font-family: 'Bungee', cursive;
    font-size: clamp(2.5rem, 8vw, 5rem);
    letter-spacing: 6px;
    z-index: 1;
    margin-bottom: 16px;
    animation: editionFadeIn 0.8s ease-out both;
}

.edition-hero p {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.3rem);
    letter-spacing: 4px;
    opacity: 0.7;
    z-index: 1;
    animation: editionFadeIn 0.8s ease-out 0.2s both;
}

@keyframes editionFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- SPIDER THEME ---- */

.spider-theme {
    background: radial-gradient(ellipse at center, #1a0808 0%, #0a0a0a 70%);
}

.spider-theme::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cline x1='100' y1='0' x2='100' y2='200' stroke='%23fff' stroke-width='0.3'/%3E%3Cline x1='0' y1='100' x2='200' y2='100' stroke='%23fff' stroke-width='0.3'/%3E%3Cline x1='0' y1='0' x2='200' y2='200' stroke='%23fff' stroke-width='0.3'/%3E%3Cline x1='200' y1='0' x2='0' y2='200' stroke='%23fff' stroke-width='0.3'/%3E%3Ccircle cx='100' cy='100' r='30' fill='none' stroke='%23fff' stroke-width='0.3'/%3E%3Ccircle cx='100' cy='100' r='60' fill='none' stroke='%23fff' stroke-width='0.3'/%3E%3Ccircle cx='100' cy='100' r='90' fill='none' stroke='%23fff' stroke-width='0.3'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.06;
}

.spider-theme h1 {
    color: #c44;
    text-shadow: 0 0 60px rgba(200, 60, 60, 0.3);
}

.spider-theme p {
    color: rgba(200, 150, 150, 0.7);
}

/* ---- RACE THEME ---- */

.race-theme {
    background: linear-gradient(180deg, #0d0d0d 0%, #0a0a0a 100%);
}

.race-theme::before {
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 48px,
        rgba(255,255,255,0.03) 48px,
        rgba(255,255,255,0.03) 50px
    );
    opacity: 0.5;
}

.race-theme h1 {
    color: #fff;
    text-shadow: 0 0 60px rgba(230, 0, 18, 0.3);
}

.race-theme p {
    color: #e60012;
}

/* Race checkered accent */
.race-checkered {
    height: 6px;
    background-image: repeating-linear-gradient(
        90deg,
        #fff 0px, #fff 10px,
        #0a0a0a 10px, #0a0a0a 20px
    );
    opacity: 0.4;
}

/* ---- JACK THEME ---- */

.jack-theme {
    background: radial-gradient(ellipse at center, #1a1608 0%, #0a0a0a 70%);
}

.jack-theme::before {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M30 5 L35 20 L30 15 L25 20 Z' fill='%23c9a84c' opacity='0.15'/%3E%3Cpath d='M30 40 Q35 50 30 55 Q25 50 30 40 Z' fill='%23c9a84c' opacity='0.1'/%3E%3C/svg%3E");
    background-size: 60px 60px;
    opacity: 0.12;
}

.jack-theme h1 {
    color: #c9a84c;
    text-shadow: 0 0 60px rgba(201, 168, 76, 0.3);
}

.jack-theme p {
    color: rgba(201, 168, 76, 0.7);
}

/* ---- PRODUCT SECTION ---- */

.edition-product {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
    animation: editionFadeIn 0.8s ease-out 0.3s both;
}

.edition-product img {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
}

/* ---- SHOP NOW BUTTON ---- */

.edition-shop-btn {
    display: block;
    width: fit-content;
    margin: 20px auto 30px;
    padding: 16px 50px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    letter-spacing: 4px;
    text-decoration: none;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0;
    color: #fff;
    background: transparent;
    transition: all 0.3s ease;
    animation: editionFadeIn 0.8s ease-out 0.5s both;
}

.edition-shop-btn:hover {
    background: #fff;
    color: #0a0a0a;
    border-color: #fff;
}

/* Spider shop btn accent */
.spider-theme ~ .edition-product + .edition-shop-btn:hover,
.spider-page .edition-shop-btn:hover {
    background: #8b0000;
    border-color: #8b0000;
    color: #fff;
}

.race-page .edition-shop-btn:hover {
    background: #e60012;
    border-color: #e60012;
    color: #fff;
}

.jack-page .edition-shop-btn:hover {
    background: #c9a84c;
    border-color: #c9a84c;
    color: #0a0a0a;
}

/* ---- BACK LINK ---- */

.edition-back {
    display: block;
    text-align: center;
    padding: 20px;
    margin-bottom: 40px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    text-transform: uppercase;
    transition: color 0.3s ease;
    animation: editionFadeIn 0.8s ease-out 0.6s both;
}

.edition-back:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
    .worlds-page,
    .worlds-home-section,
    [data-theme="light"] .worlds-page,
    [data-theme="light"] .worlds-home-section {
        background-image: none;
        background-color: var(--bg-body);
    }

    .worlds-grid {
        grid-template-columns: 1fr;
        max-width: 500px;
        padding: 20px 20px 60px;
        gap: 24px;
    }

    .world-card {
        aspect-ratio: 4 / 5;
    }

    /* Ensure hover styles apply on tap for touch devices */
    .world-card .world-card__image {
        filter: brightness(0.75);
    }

    .world-card .world-card__accent {
        transform: scaleX(1);
    }
}

@media (max-width: 480px) {
    .worlds-header {
        padding: 40px 16px 24px;
    }

    .worlds-header h1 {
        font-size: 1.6rem;
        letter-spacing: 2px;
    }

    .worlds-subtitle {
        font-size: 0.75rem;
        letter-spacing: 2px;
    }

    .world-card__content {
        padding: 20px 16px;
    }

    .edition-hero h1 {
        font-size: 2rem;
    }

    .edition-shop-btn {
        padding: 14px 36px;
        font-size: 0.8rem;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    .world-card {
        transition: none;
    }

    .world-card__image {
        transition: none;
    }

    .world-card__accent {
        transition: none;
        transform: scaleX(1);
    }

    .edition-hero h1,
    .edition-hero p,
    .edition-product,
    .edition-shop-btn,
    .edition-back {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .spider-swarm-canvas,
    .race-car,
    .speed-line,
    .jack-card-clone {
        transition: none;
    }
}

/* ============================================
   LIGHT THEME OVERRIDES FOR WORLDS
   ============================================ */

[data-theme="light"] .worlds-page {
    background: var(--bg-body);
}

[data-theme="light"] .world-card {
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .world-card__overlay {
    background: linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.75) 0%,
        rgba(0, 0, 0, 0.15) 40%,
        rgba(0, 0, 0, 0.05) 100%
    );
}
