/* ============================================
   MATHS GALAXY - HUB STYLES
   This CSS creates the stunning space scene
   ============================================ */

/* --- 1. CSS VARIABLES ---
   Variables let us reuse colours easily.
   Change one value here, it updates everywhere! */
:root {
    --space-dark: #0a0a1a;
    --space-purple: #1a1a3a;
    --space-blue: #16213e;
    --accent-cyan: #4ecdc4;
    --accent-pink: #ff6b6b;
    --accent-gold: #ffd166;
    --star-white: #ffffff;
    --font-main: 'Nunito', sans-serif;
}

/* --- 2. RESET & BASE ---
   Remove default browser spacing so we control everything */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
}

/* --- 3. SPACE BACKGROUND ---
   A radial gradient creates a soft nebula glow from the centre */
body {
    background: radial-gradient(
        ellipse at 50% 50%,
        #1a1a4e 0%,
        var(--space-purple) 30%,
        var(--space-dark) 70%,
        #050510 100%
    );
    background-attachment: fixed;
}

/* --- 4. STARFIELD CANVAS ---
   The canvas sits behind everything (z-index: 1) */
#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none; /* Let clicks pass through to planets */
}

/* --- 5. UFO ---
   The cartoon UFO floats at the bottom */
.ufo-container {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    animation: float 3s ease-in-out infinite;
    cursor: pointer;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
}

.ufo-container:focus-visible {
    outline: 3px solid var(--accent-gold);
    outline-offset: 4px;
    border-radius: 50%;
}

.ufo {
    width: 100px;
    height: 100px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

/* UFO tractor beam - a soft glow beneath the UFO */
.ufo-beam {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 50px;
    background: linear-gradient(to bottom, rgba(78, 205, 196, 0.4), rgba(78, 205, 196, 0.1), transparent);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    opacity: 0.6;
    animation: beamPulse 1.5s ease-in-out infinite alternate;
}

.ufo-container.choosing .ufo-beam {
    width: 80px;
    height: 90px;
    opacity: 1;
}

.mobile-surprise {
    display: none;
}

.planet.surprise-selected {
    transform: scale(1.16);
}

.planet.surprise-selected .planet-body {
    border-color: var(--accent-gold);
    box-shadow: 0 0 24px rgba(255, 209, 102, 0.9), 0 0 70px rgba(255, 209, 102, 0.55);
}

/* --- 6. CONTENT LAYER ---
   Text and planets sit on top (z-index: 2) */
.content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100vh;
    padding: 10px 20px 120px;
    text-align: center;
}

.title {
    font-size: clamp(2.5rem, 8vw, 5rem); /* Responsive sizing */
    font-weight: 900;
    color: var(--star-white);
    text-shadow:
        0 0 10px rgba(78, 205, 196, 0.5),
        0 0 40px rgba(78, 205, 196, 0.3),
        0 0 80px rgba(78, 205, 196, 0.1);
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.subtitle {
    font-size: clamp(0.95rem, 2.5vw, 1.2rem);
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 30px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    opacity: 0.95;
    max-width: 700px;
    line-height: 1.5;
}

/* --- 7. PLANETS CONTAINER ---
   Holds the 8 planet portals in a 4x2 grid */
.planets-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 18px 22px;
    max-width: 680px;
    width: 100%;
    margin: 30px auto 0;
}

/* Desktop advertising rail. It is deliberately inactive until AdSense is
   approved, so visitors never see an empty placeholder. */
.desktop-ad-rail {
    display: none;
}

@media (min-width: 1280px) and (min-height: 700px) {
    body.ads-enabled .content {
        padding-right: 220px;
    }

    body.ads-enabled .desktop-ad-rail {
        position: absolute;
        top: 50%;
        right: clamp(24px, 3vw, 56px);
        z-index: 2;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        width: 160px;
        transform: translateY(-50%);
    }

    .ad-label {
        color: rgba(255, 255, 255, 0.58);
        font-size: 0.68rem;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .desktop-ad-slot {
        width: 160px;
        height: 600px;
        overflow: hidden;
    }
}

/* --- 8. PLANET PORTALS ---
   Each planet is a clickable circle with a glow */
.planet {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    transition: transform 0.3s ease;
    cursor: pointer;
}

.planet:hover {
    transform: scale(1.1);
}

.planet-body {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

/* Planet 1 - Cyan glow (Star Shooter) */
.planet-1 {
    background: radial-gradient(circle at 30% 30%, #6ee7db, #2a9d8f);
    box-shadow:
        0 0 20px rgba(78, 205, 196, 0.4),
        0 0 60px rgba(78, 205, 196, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-1 {
    box-shadow:
        0 0 30px rgba(78, 205, 196, 0.7),
        0 0 80px rgba(78, 205, 196, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 2 - Pink glow (Comet Catcher) */
.planet-2 {
    background: radial-gradient(circle at 30% 30%, #ff9e9e, #e76f51);
    box-shadow:
        0 0 20px rgba(255, 107, 107, 0.4),
        0 0 60px rgba(255, 107, 107, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-2 {
    box-shadow:
        0 0 30px rgba(255, 107, 107, 0.7),
        0 0 80px rgba(255, 107, 107, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 3 - Gold/Purple glow (Alien Counting) */
.planet-3 {
    background: radial-gradient(circle at 30% 30%, #c77dff, #7b2cbf);
    box-shadow:
        0 0 20px rgba(199, 125, 255, 0.4),
        0 0 60px rgba(199, 125, 255, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-3 {
    box-shadow:
        0 0 30px rgba(199, 125, 255, 0.7),
        0 0 80px rgba(199, 125, 255, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 4 - Green/Teal glow (Moon Match) */
.planet-4 {
    background: radial-gradient(circle at 30% 30%, #2dd4bf, #0d9488);
    box-shadow:
        0 0 20px rgba(45, 212, 191, 0.4),
        0 0 60px rgba(45, 212, 191, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-4 {
    box-shadow:
        0 0 30px rgba(45, 212, 191, 0.7),
        0 0 80px rgba(45, 212, 191, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 5 - Orange/Red glow (Times Table Trek) */
.planet-5 {
    background: radial-gradient(circle at 30% 30%, #fb923c, #dc2626);
    box-shadow:
        0 0 20px rgba(251, 146, 60, 0.4),
        0 0 60px rgba(251, 146, 60, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-5 {
    box-shadow:
        0 0 30px rgba(251, 146, 60, 0.7),
        0 0 80px rgba(251, 146, 60, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 6 - Indigo/Blue glow (Planet Division) */
.planet-6 {
    background: radial-gradient(circle at 30% 30%, #818cf8, #4f46e5);
    box-shadow:
        0 0 20px rgba(129, 140, 248, 0.4),
        0 0 60px rgba(129, 140, 248, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-6 {
    box-shadow:
        0 0 30px rgba(129, 140, 248, 0.7),
        0 0 80px rgba(129, 140, 248, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 7 - Amber/Gold glow (Pattern Planet) */
.planet-7 {
    background: radial-gradient(circle at 30% 30%, #fbbf24, #d97706);
    box-shadow:
        0 0 20px rgba(251, 191, 36, 0.4),
        0 0 60px rgba(251, 191, 36, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-7 {
    box-shadow:
        0 0 30px rgba(251, 191, 36, 0.7),
        0 0 80px rgba(251, 191, 36, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 8 - Lime/Green glow (Space Shapes) */
.planet-8 {
    background: radial-gradient(circle at 30% 30%, #a3e635, #65a30d);
    box-shadow:
        0 0 20px rgba(163, 230, 53, 0.4),
        0 0 60px rgba(163, 230, 53, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-8 {
    box-shadow:
        0 0 30px rgba(163, 230, 53, 0.7),
        0 0 80px rgba(163, 230, 53, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 9 - Rose/Pink glow (Cosmic Order) */
.planet-9 {
    background: radial-gradient(circle at 30% 30%, #fda4af, #e11d48);
    box-shadow:
        0 0 20px rgba(244, 63, 94, 0.4),
        0 0 60px rgba(244, 63, 94, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-9 {
    box-shadow:
        0 0 30px rgba(244, 63, 94, 0.7),
        0 0 80px rgba(244, 63, 94, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet 10 - Cyan/Blue glow (Asteroid Sorter) */
.planet-10 {
    background: radial-gradient(circle at 30% 30%, #67e8f9, #0891b2);
    box-shadow:
        0 0 20px rgba(34, 211, 238, 0.4),
        0 0 60px rgba(34, 211, 238, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.planet:hover .planet-10 {
    box-shadow:
        0 0 30px rgba(34, 211, 238, 0.7),
        0 0 80px rgba(34, 211, 238, 0.4),
        inset 0 0 30px rgba(255, 255, 255, 0.2);
}

/* Planet icon inside */
.planet-icon {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Planet labels */
.planet-name {
    margin-top: 15px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--star-white);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.planet-skill {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--accent-gold);
    opacity: 0.8;
    margin-top: 4px;
}

/* --- 9. ANIMATIONS --- */

/* Float animation: makes the UFO bob up and down */
@keyframes float {
    0%, 100% {
        transform: translateX(-50%) translateY(0px);
    }
    50% {
        transform: translateX(-50%) translateY(-15px);
    }
}

/* Beam animation: makes the UFO tractor beam pulse */
@keyframes beamPulse {
    0% {
        opacity: 0.4;
        transform: translateX(-50%) scaleY(0.9);
    }
    100% {
        opacity: 0.7;
        transform: translateX(-50%) scaleY(1.1);
    }
}

/* --- 10. RESPONSIVE DESIGN ---
   Makes it look good on phones, tablets and smart displays */

@media (max-width: 820px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .content {
        height: auto;
        min-height: 100vh;
        padding: 10px 16px 32px;
    }

    .planets-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 28px 18px;
        max-width: 440px;
        padding: 0;
        margin-top: 20px;
    }

    .planet-body {
        width: clamp(82px, 24vw, 100px);
        height: clamp(82px, 24vw, 100px);
    }

    .planet-icon {
        width: clamp(38px, 12vw, 50px);
        height: clamp(38px, 12vw, 50px);
    }

    .planet-name {
        margin-top: 12px;
        font-size: 0.9rem;
    }

    .planet-skill {
        font-size: 0.75rem;
    }

    .ufo-container {
        display: none;
    }

    .mobile-surprise {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 48px;
        margin: -10px 0 4px;
        padding: 10px 20px;
        border: 2px solid rgba(255, 209, 102, 0.65);
        border-radius: 999px;
        background: rgba(10, 10, 30, 0.72);
        color: var(--star-white);
        font: 800 1rem var(--font-main);
        box-shadow: 0 0 20px rgba(255, 209, 102, 0.18);
        cursor: pointer;
    }

    .mobile-surprise:focus-visible {
        outline: 3px solid var(--accent-gold);
        outline-offset: 3px;
    }

    .utility-links {
        position: relative;
        left: auto;
        bottom: auto;
        width: max-content;
        margin: 0 auto 16px;
    }
}

@media (max-width: 400px) {
    .content {
        padding: 8px 12px 28px;
    }

    .planets-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 24px 12px;
        padding: 0;
        margin-top: 15px;
    }

    .planet-body {
        width: clamp(78px, 25vw, 92px);
        height: clamp(78px, 25vw, 92px);
    }

    .planet-icon {
        width: clamp(36px, 12vw, 46px);
        height: clamp(36px, 12vw, 46px);
    }

    .planet-name {
        font-size: 0.82rem;
    }

    .planet-skill {
        font-size: 0.7rem;
    }
}
