/* ============================================================
   base.css — EduNudge GeoLab · Plate Tectonics Simulator
   Reset, custom properties, typography, body, scrollbar,
   utility classes and keyframe animations.
   Loaded first — no dependency on other CSS files.
   ============================================================ */

/* ----------------------------------------------------------
   1. GOOGLE FONTS IMPORT
   ---------------------------------------------------------- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap");

/* ----------------------------------------------------------
   2. CUSTOM PROPERTIES  (design tokens)
   ---------------------------------------------------------- */
:root {

    /* Brand */
    --clr-orange: #e86c2f;
    --clr-orange-light: #f08c55;
    --clr-orange-dark: #c4521f;
    --clr-orange-alpha: rgba(232, 108, 47, 0.18);

    --clr-teal: #1a3545;
    --clr-teal-mid: #224158;
    --clr-teal-light: #2d5570;
    --clr-teal-lighter: #3a6a87;
    --clr-teal-alpha: rgba(26, 53, 69, 0.85);

    /* Neutrals */
    --clr-white: #ffffff;
    --clr-off-white: #f4f6f8;
    --clr-grey-100: #e8ecef;
    --clr-grey-200: #d0d7de;
    --clr-grey-400: #8f9fac;
    --clr-grey-600: #556b7a;
    --clr-grey-800: #2c3e4a;

    /* Semantic */
    --clr-bg: #0a1a27;
    --clr-surface: #112233;
    --clr-surface-raised: #162d40;
    --clr-border: rgba(255, 255, 255, 0.09);
    --clr-border-strong: rgba(255, 255, 255, 0.18);

    --clr-text-primary: #e8f0f5;
    --clr-text-secondary: #8fafc2;
    --clr-text-muted: #5a7a90;

    /* Boundary colours (mirrors config.js for CSS use) */
    --clr-convergent: #e86c2f;
    --clr-divergent: #4fc3f7;
    --clr-transform: #a5d6a7;

    /* Typography */
    --font-body: "Inter", system-ui, sans-serif;
    --font-display: "Space Grotesk", system-ui, sans-serif;

    --fs-xs: 0.6875rem;
    /*  11px */
    --fs-sm: 0.75rem;
    /*  12px */
    --fs-base: 0.875rem;
    /*  14px */
    --fs-md: 1rem;
    /*  16px */
    --fs-lg: 1.125rem;
    /*  18px */
    --fs-xl: 1.25rem;
    /*  20px */
    --fs-2xl: 1.5rem;
    /*  24px */
    --fs-3xl: 1.875rem;
    /*  30px */

    --fw-light: 300;
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semi: 600;
    --fw-bold: 700;

    --lh-tight: 1.2;
    --lh-snug: 1.35;
    --lh-base: 1.55;
    --lh-loose: 1.75;

    /* Spacing scale (4-pt grid) */
    --sp-1: 0.25rem;
    /*  4px */
    --sp-2: 0.5rem;
    /*  8px */
    --sp-3: 0.75rem;
    /* 12px */
    --sp-4: 1rem;
    /* 16px */
    --sp-5: 1.25rem;
    /* 20px */
    --sp-6: 1.5rem;
    /* 24px */
    --sp-8: 2rem;
    /* 32px */
    --sp-10: 2.5rem;
    /* 40px */
    --sp-12: 3rem;
    /* 48px */
    --sp-16: 4rem;
    /* 64px */

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.55);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.65);
    --shadow-glow-orange: 0 0 16px rgba(232, 108, 47, 0.50);
    --shadow-glow-teal: 0 0 16px rgba(79, 195, 247, 0.35);

    /* Transitions */
    --ease-default: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);

    --dur-fast: 120ms;
    --dur-normal: 220ms;
    --dur-slow: 380ms;

    /* Z-index ladder */
    --z-below: -1;
    --z-base: 0;
    --z-raised: 10;
    --z-dropdown: 100;
    --z-overlay: 200;
    --z-modal: 300;
    --z-toast: 400;
    --z-tooltip: 500;

    /* Layout */
    --panel-width: 340px;
    --header-height: 56px;
    --metrics-height: 56px;
}

/* ----------------------------------------------------------
   3. MODERN CSS RESET
   Based on Andy Bell's reset + Josh Comeau additions
   ---------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    tab-size: 2;
    scroll-behavior: smooth;
}

body {
    min-height: 100dvh;
    font-family: var(--font-body);
    font-size: var(--fs-base);
    font-weight: var(--fw-regular);
    line-height: var(--lh-base);
    color: var(--clr-text-primary);
    background-color: var(--clr-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    /* globe fills viewport */
}

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    line-height: 1;
}

a {
    color: var(--clr-orange-light);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--clr-orange);
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-display);
    line-height: var(--lh-tight);
}

ul,
ol {
    list-style: none;
}

/* ----------------------------------------------------------
   4. CUSTOM SCROLLBAR  (webkit)
   ---------------------------------------------------------- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--clr-teal-lighter);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--clr-orange);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--clr-teal-lighter) transparent;
}

/* ----------------------------------------------------------
   5. FOCUS STYLES  (accessibility)
   ---------------------------------------------------------- */
:focus-visible {
    outline: 2px solid var(--clr-orange);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* ----------------------------------------------------------
   6. SELECTION COLOUR
   ---------------------------------------------------------- */
::selection {
    background: var(--clr-orange);
    color: var(--clr-white);
}

/* ----------------------------------------------------------
   7. ROOT LAYOUT
   The app is a single viewport: header + main (globe + panel)
   ---------------------------------------------------------- */
#app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ----------------------------------------------------------
   8. LOADING OVERLAY
   ---------------------------------------------------------- */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: var(--clr-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-6);
    transition: opacity 0.4s ease;
}

.loader-logo {
    font-family: var(--font-display);
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    color: var(--clr-white);
    letter-spacing: -0.02em;
}

.loader-logo span {
    color: var(--clr-orange);
}

.loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--clr-teal-light);
    border-top: 3px solid var(--clr-orange);
    border-radius: var(--radius-full);
    animation: spin 0.85s linear infinite;
}

#loading-text {
    font-size: var(--fs-sm);
    color: var(--clr-text-muted);
    letter-spacing: 0.04em;
    min-height: 1.2em;
}

/* ----------------------------------------------------------
   9. TOOLTIP
   ---------------------------------------------------------- */
#globe-tooltip {
    position: fixed;
    z-index: var(--z-tooltip);
    background: var(--clr-teal);
    color: var(--clr-text-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--clr-border-strong);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

/* ----------------------------------------------------------
   10. UTILITY CLASSES
   ---------------------------------------------------------- */

/* Text */
.text-orange {
    color: var(--clr-orange);
}

.text-teal {
    color: var(--clr-teal-lighter);
}

.text-muted {
    color: var(--clr-text-muted);
}

.text-sm {
    font-size: var(--fs-sm);
}

.text-xs {
    font-size: var(--fs-xs);
}

.text-lg {
    font-size: var(--fs-lg);
}

.text-bold {
    font-weight: var(--fw-bold);
}

.text-semi {
    font-weight: var(--fw-semi);
}

.text-display {
    font-family: var(--font-display);
}

.text-center {
    text-align: center;
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Layout */
.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: var(--sp-1);
}

.gap-2 {
    gap: var(--sp-2);
}

.gap-3 {
    gap: var(--sp-3);
}

.gap-4 {
    gap: var(--sp-4);
}

.flex-1 {
    flex: 1;
}

.w-full {
    width: 100%;
}

.h-full {
    height: 100%;
}

/* Spacing */
.p-2 {
    padding: var(--sp-2);
}

.p-3 {
    padding: var(--sp-3);
}

.p-4 {
    padding: var(--sp-4);
}

.px-3 {
    padding-inline: var(--sp-3);
}

.px-4 {
    padding-inline: var(--sp-4);
}

.py-2 {
    padding-block: var(--sp-2);
}

.py-3 {
    padding-block: var(--sp-3);
}

.mt-2 {
    margin-top: var(--sp-2);
}

.mt-4 {
    margin-top: var(--sp-4);
}

.mb-2 {
    margin-bottom: var(--sp-2);
}

.mb-4 {
    margin-bottom: var(--sp-4);
}

/* Visibility */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Surfaces */
.surface {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
}

.surface-raised {
    background: var(--clr-surface-raised);
    border: 1px solid var(--clr-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* Divider */
.divider {
    height: 1px;
    background: var(--clr-border);
    margin: var(--sp-3) 0;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semi);
    padding: 2px var(--sp-2);
    border-radius: var(--radius-full);
    background: var(--clr-orange-alpha);
    color: var(--clr-orange-light);
    white-space: nowrap;
}

/* Tag */
.tag {
    display: inline-block;
    font-size: var(--fs-xs);
    padding: 2px var(--sp-2);
    border-radius: var(--radius-full);
    border: 1px solid var(--clr-border-strong);
    color: var(--clr-text-secondary);
}

/* ----------------------------------------------------------
   11. KEYFRAME ANIMATIONS
   ---------------------------------------------------------- */

/* Spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Fade-in upward */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pulse ring (used by hotspot CSS counterpart) */
@keyframes pulseRing {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    70% {
        transform: scale(1.6);
        opacity: 0;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* Glow breathe */
@keyframes glowBreathe {

    0%,
    100% {
        box-shadow: 0 0 8px var(--clr-orange-alpha);
    }

    50% {
        box-shadow: 0 0 22px rgba(232, 108, 47, 0.50);
    }
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide in from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale pop */
@keyframes scalePop {
    0% {
        transform: scale(0.85);
        opacity: 0;
    }

    70% {
        transform: scale(1.04);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Progress fill */
@keyframes progressFill {
    from {
        width: 0;
    }
}

/* ----------------------------------------------------------
   12. REDUCED MOTION
   ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ----------------------------------------------------------
   END base.css
   ---------------------------------------------------------- */