/* ============================================
   Alexandria's World — Apple-Inspired Design
   ============================================ */

:root {
    /* Typography */
    --font-display: 'Fredoka', -apple-system, system-ui, sans-serif;
    --font-body: 'DM Sans', -apple-system, system-ui, sans-serif;

    /* Warm palette */
    --bg-primary: #FFF8F0;
    --bg-secondary: #FEF3E2;
    --bg-globe: #0a0e27;
    --text-primary: #1D1D1F;
    --text-secondary: #6E6E73;
    --text-light: #FFFFFFEE;
    --accent-coral: #FF6B6B;
    --accent-gold: #FEC84A;
    --accent-warm-purple: #A06CD5;
    --accent-sky: #6BB6FF;
    --accent-teal: #4ECDC4;

    /* Glassmorphism */
    --glass-bg: rgba(255, 248, 240, 0.88);
    --glass-blur: blur(24px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.35);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);

    /* Motion */
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
    --duration-fast: 200ms;
    --duration-normal: 400ms;
    --duration-slow: 600ms;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
}

/* ---- CTA Button (used in modals) ---- */
.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--accent-coral), #FF8E53);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform var(--duration-fast) var(--ease-spring),
                box-shadow var(--duration-fast) var(--ease-smooth);
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
}

.cta-button:hover { transform: scale(1.05); }
.cta-button:active { transform: scale(0.97); }
.cta-button.small { padding: 0.6rem 1.2rem; font-size: 0.85rem; }

/* ---- Globe Section (Full Page) ---- */
.globe-section {
    background: var(--bg-globe);
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Top bar overlay */
.top-bar {
    text-align: center;
    padding: 1.25rem 1rem 0.5rem;
    flex-shrink: 0;
}

.top-title {
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 3.6vw, 2.4rem);
    font-weight: 700;
    color: var(--text-light);
    line-height: 1.1;
}

.top-title .accent {
    background: linear-gradient(135deg, var(--accent-coral), var(--accent-warm-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.top-subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.25rem;
}

/* Bottom stats */
.bottom-stats {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.05em;
    z-index: 10;
}

.bottom-stats .dot { color: rgba(255, 255, 255, 0.2); }

.continent-pills {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.25rem 1rem 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.pill {
    padding: 0.35rem 1rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
}

.pill:hover {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

.pill.active {
    color: var(--bg-globe);
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    font-weight: 600;
}

#cesiumContainer {
    flex: 1;
    width: 100%;
    min-height: 0;
}

/* Hide Cesium default UI */
.cesium-viewer-toolbar,
.cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer,
.cesium-viewer-fullscreenContainer,
.cesium-viewer-infoBoxContainer,
.cesium-viewer-selectionIndicatorContainer,
.cesium-viewer-geocoderContainer,
.cesium-viewer-navigationHelpButtonContainer,
.cesium-credit-logoContainer,
.cesium-viewer-bottom {
    display: none !important;
}

.cesium-widget-credits { display: none !important; }

.country-tooltip {
    position: fixed;
    pointer-events: none;
    padding: 0.75rem 1.25rem;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--glass-shadow);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--duration-fast), transform var(--duration-fast);
    z-index: 100;
    white-space: nowrap;
}

.country-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.country-tooltip .tooltip-flag {
    font-size: 1.3rem;
    margin-right: 0.5rem;
}

.country-tooltip .tooltip-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--accent-coral);
    margin-top: 0.25rem;
    font-weight: 400;
}

/* ---- Book Reader ---- */
.reader-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal) var(--ease-smooth);
}

.reader-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.reader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 39, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.reader-container {
    position: relative;
    width: 90vw;
    max-width: 800px;
    max-height: 90vh;
    background: white;
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(40px) scale(0.95);
    transition: transform var(--duration-normal) var(--ease-spring);
}

.reader-overlay.open .reader-container {
    transform: translateY(0) scale(1);
}

.reader-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.06);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-fast);
    z-index: 10;
}

.reader-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.reader-header {
    padding: 1.5rem 2rem 0.75rem;
    text-align: center;
}

.reader-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mascot-character {
    position: absolute;
    right: 1%;
    bottom: 5%;
    height: 70vh;
    max-height: 650px;
    z-index: 10;
    pointer-events: none;
    filter: drop-shadow(0 0 20px rgba(0, 0, 0, 0.5));
    animation: mascotFloat 4s ease-in-out infinite;
}

@keyframes mascotFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

@media (max-width: 768px) {
    .mascot-character {
        height: 30vh;
        right: 1%;
        bottom: 12%;
    }
}

.reader-flag {
    font-size: 1.6rem;
    vertical-align: middle;
    margin-right: 0.3rem;
}

.reader-flag img.emoji,
.country-tooltip img.emoji {
    height: 1.4em;
    width: 1.4em;
    vertical-align: -0.2em;
    margin-right: 0.3rem;
}

.reader-progress {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.reader-book {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    min-height: 0;
    position: relative;
}

.reader-nav {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-spring);
    z-index: 5;
}

.reader-nav:hover {
    background: var(--accent-coral);
    color: white;
    transform: scale(1.1);
}

.reader-nav:active {
    transform: scale(0.95);
}

.reader-nav:disabled {
    opacity: 0.3;
    cursor: default;
    transform: none;
}

.reader-nav:disabled:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.reader-page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 1rem;
    min-height: 0;
    overflow-y: auto;
}

.reader-page-image {
    width: 100%;
    max-height: 55vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: opacity var(--duration-normal) var(--ease-smooth);
}

.reader-page-image.loading {
    opacity: 0.3;
}

.reader-page-text {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-primary);
    max-width: 600px;
}

/* Audio button */
.read-to-me-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    margin-top: 0.5rem;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent-coral);
    background: rgba(255, 107, 107, 0.08);
    border: 1.5px solid rgba(255, 107, 107, 0.2);
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-spring);
}

.read-to-me-btn:hover {
    background: rgba(255, 107, 107, 0.15);
    transform: scale(1.05);
}

.read-to-me-btn.playing {
    color: white;
    background: var(--accent-coral);
    border-color: var(--accent-coral);
}

.reader-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 1rem 2rem 1.5rem;
}

.reader-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.12);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-spring);
}

.reader-dot.active {
    background: var(--accent-coral);
    width: 24px;
    border-radius: 4px;
}

.reader-dot:hover:not(.active) {
    background: rgba(0, 0, 0, 0.25);
}

/* ---- Coming Soon ---- */
.coming-soon-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-normal);
}

.coming-soon-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.coming-soon-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 39, 0.6);
    backdrop-filter: blur(8px);
}

.coming-soon-card {
    position: relative;
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 24px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    transform: scale(0.9);
    transition: transform var(--duration-normal) var(--ease-spring);
}

.coming-soon-overlay.open .coming-soon-card {
    transform: scale(1);
}

.coming-soon-flag {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.coming-soon-card h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.coming-soon-text {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ---- Animations ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hero { min-height: 50vh; padding: 3rem 1.5rem; }
    .hero-stats { gap: 1.5rem; }
    .reader-container { width: 95vw; border-radius: 16px; }
    .reader-nav { width: 36px; height: 36px; }
    .reader-page-image { max-height: 45vh; }
    .continent-pills { gap: 0.35rem; }
    .pill { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
