/* ============================================
   Calendar Systems Explorer - Shared Styles
   ============================================

   Common styles used across all calendar pages:
   - CSS Variables for theming (dark mode support)
   - Keyframe animations
   - Accessibility utilities
   - Print styles
   - Responsive utilities
*/

/* ============================================
   CSS Custom Properties (Variables)
   ============================================ */

:root {
    /* Colors - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --border-color-strong: #d1d5db;

    /* Semantic Colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    --gradient-secondary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms;
    --transition-base: 200ms;
    --transition-slow: 300ms;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
}

/* Dark Mode */
.dark {
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-tertiary: #0f172a;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-tertiary: #9ca3af;
    --border-color: #374151;
    --border-color-strong: #4b5563;

    /* Adjust shadows for dark mode */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

/* ============================================
   Keyframe Animations
   ============================================ */

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

@keyframes bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes fillUp {
    from {
        height: 0%;
    }
    to {
        height: var(--fill-height, 100%);
    }
}

@keyframes fillRight {
    from {
        width: 0%;
    }
    to {
        width: var(--fill-width, 100%);
    }
}

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

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

@keyframes sparkle {
    0%, 100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2) rotate(180deg);
    }
}

@keyframes wiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

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

@keyframes ping {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes popIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes popOut {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
}

@keyframes bubble {
    0% {
        transform: translateY(10px);
        opacity: 0;
    }
    10% {
        transform: translateY(0);
        opacity: 1;
    }
    90% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-10px);
        opacity: 0;
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(139, 92, 246, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 1),
                    0 0 30px rgba(236, 72, 153, 0.7);
    }
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* ============================================
   Animation Utility Classes
   ============================================ */

.float {
    animation: float 3s ease-in-out infinite;
}

.bounce {
    animation: bounce 1s ease-in-out infinite;
}

.slide-in {
    animation: slideIn 0.6s ease-out forwards;
}

.slide-in-right {
    animation: slideInRight 0.6s ease-out forwards;
}

.slide-in-up {
    animation: slideInUp 0.6s ease-out forwards;
}

.slide-in-down {
    animation: slideInDown 0.6s ease-out forwards;
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

.fill-up {
    animation: fillUp 2s ease-out forwards;
}

.fill-right {
    animation: fillRight 2s ease-out forwards;
}

.rotate {
    animation: rotate 2s linear infinite;
}

.rotate-reverse {
    animation: rotateReverse 2s linear infinite;
}

.sparkle {
    animation: sparkle 2s ease-in-out infinite;
}

.wiggle {
    animation: wiggle 0.5s ease-in-out;
}

.shake {
    animation: shake 0.5s ease-in-out;
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

.ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.pop-in {
    animation: popIn 0.5s ease-out forwards;
}

.pop-out {
    animation: popOut 0.5s ease-out forwards;
}

.bubble-anim {
    animation: bubble 3s ease-in-out;
}

.ripple {
    animation: ripple 1s ease-out;
}

.glow {
    animation: glow 2s ease-in-out infinite;
}

/* ============================================
   Reduced Motion Support (Accessibility)
   ============================================ */

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

/* Force disable animations when user toggles */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* ============================================
   Focus Styles (Accessibility)
   ============================================ */

/* Modern focus-visible (only shows on keyboard navigation) */
*:focus-visible {
    outline: 3px solid var(--color-info);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* High contrast focus for better visibility */
@media (prefers-contrast: high) {
    *:focus-visible {
        outline-width: 4px;
        outline-offset: 3px;
    }
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px 16px;
    text-decoration: none;
    z-index: 9999;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: top var(--transition-base);
}

.skip-link:focus {
    top: 8px;
}

/* ============================================
   Utility Classes
   ============================================ */

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Show on focus (for skip links) */
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: initial;
    margin: initial;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Hide visually but keep for screen readers */
.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

/* No print - hide when printing */
.no-print {
    @media print {
        display: none !important;
    }
}

/* Print only - show only when printing */
.print-only {
    display: none;
}

@media print {
    .print-only {
        display: block;
    }
}

/* ============================================
   Speech Bubble Component
   ============================================ */

.speech-bubble {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-xl);
    border: 2px solid var(--border-color);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 30px;
    width: 0;
    height: 0;
    border: 20px solid transparent;
    border-top-color: var(--bg-primary);
    border-bottom: 0;
    margin-left: -20px;
}

.speech-bubble.top::after {
    bottom: auto;
    top: -20px;
    border-top: 0;
    border-bottom-color: var(--bg-primary);
}

.speech-bubble.right::after {
    left: auto;
    right: 30px;
}

/* ============================================
   Scroll Behavior
   ============================================ */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ============================================
   Body Defaults
   ============================================ */

body {
    overflow-x: hidden;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color var(--transition-base),
                color var(--transition-base);
}

/* ============================================
   Three.js Canvas Styles
   ============================================ */

#earth-canvas {
    border-radius: var(--radius-xl);
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================
   Block Stack Animation
   ============================================ */

.block-stack {
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   Season Card Hover Effect
   ============================================ */

.season-card {
    transition: transform var(--transition-base);
}

.season-card:hover {
    transform: scale(1.05) rotate(2deg);
}

/* ============================================
   Progress Dots
   ============================================ */

.progress-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    cursor: pointer;
}

.progress-dot.active {
    transform: scale(1.2);
    box-shadow: var(--shadow-lg);
}

.progress-dot:hover:not(.active) {
    opacity: 1;
    transform: scale(1.05);
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    /* Hide interactive/navigation elements */
    button:not(.print-include),
    .fixed,
    .sticky,
    nav,
    .progress-dots,
    .no-print,
    .theme-toggle,
    .sound-toggle,
    .font-size-controls,
    .share-button {
        display: none !important;
    }

    /* Reset colors for print */
    * {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
    }

    /* Keep borders visible */
    [class*="border"] {
        border-color: black !important;
    }

    /* Optimize layout */
    body {
        margin: 0;
        padding: 20px;
    }

    .max-w-4xl,
    .max-w-2xl {
        max-width: 100% !important;
    }

    /* Page breaks */
    .screen,
    article > section {
        page-break-after: always;
    }

    /* Avoid breaking inside important blocks */
    .bg-white,
    .rounded-xl,
    details,
    blockquote {
        page-break-inside: avoid;
    }

    /* Expand collapsed content */
    details {
        display: block !important;
    }

    details summary {
        display: none !important;
    }

    details > * {
        display: block !important;
    }

    /* Links - show URLs */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Skip navigation links */
    nav a[href]::after,
    .skip-link::after {
        content: none;
    }

    /* Emoji fallback for print */
    .emoji::after {
        content: "[" attr(aria-label) "]";
        font-size: 0.8em;
    }
}

/* Print-specific page size */
@page {
    margin: 2cm;
    size: A4;
}

/* ============================================
   High Contrast Mode Support
   ============================================ */

@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --border-color-strong: #000000;
    }

    .dark {
        --border-color: #ffffff;
        --border-color-strong: #ffffff;
    }

    * {
        border-width: 2px !important;
    }
}

/* ============================================
   Loading States
   ============================================ */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--border-color);
    border-top-color: var(--color-info);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rotate 0.6s linear infinite;
}

/* ============================================
   Tooltip
   ============================================ */

.tooltip {
    position: relative;
}

.tooltip::before,
.tooltip::after {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.tooltip::before {
    content: attr(data-tooltip);
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: var(--text-sm);
    white-space: nowrap;
    border-radius: var(--radius-md);
}

.tooltip::after {
    content: '';
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
}

/* ============================================
   Badge
   ============================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.badge-success {
    background: var(--color-success);
    color: white;
}

.badge-warning {
    background: var(--color-warning);
    color: white;
}

.badge-error {
    background: var(--color-error);
    color: white;
}

.badge-info {
    background: var(--color-info);
    color: white;
}

/* ============================================
   Gradient Text
   ============================================ */

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================
   Glass Morphism Effect
   ============================================ */

.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   Responsive Typography
   ============================================ */

@media (max-width: 640px) {
    :root {
        font-size: 14px;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    :root {
        font-size: 15px;
    }
}

@media (min-width: 1025px) {
    :root {
        font-size: 16px;
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

/* WebKit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color-strong);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color-strong) var(--bg-secondary);
}

/* ============================================
   Selection Styling
   ============================================ */

::selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
}

.dark ::selection {
    background: rgba(139, 92, 246, 0.5);
}

/* ============================================
   Settings Panel (Consolidated UI Controls)
   ============================================ */

.settings-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    padding: 1.5rem;
}

.dark .settings-panel {
    background: #1F2937;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
}

.settings-panel.open {
    right: 0;
}

.settings-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.settings-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.dark .settings-toggle {
    background: #374151;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.settings-overlay.open {
    opacity: 1;
    visibility: visible;
}

.settings-header {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #E5E7EB;
}

.dark .settings-header {
    color: #F3F4F6;
    border-bottom-color: #4B5563;
}

.settings-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #E5E7EB;
}

.dark .settings-section {
    border-bottom-color: #4B5563;
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
    display: block;
}

.dark .settings-label {
    color: #F3F4F6;
}

.settings-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.settings-button {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #D1D5DB;
    background: #F9FAFB;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 80px;
    text-align: center;
}

.settings-button:hover {
    background: #E5E7EB;
}

.dark .settings-button {
    border-color: #4B5563;
    background: #374151;
    color: #F3F4F6;
}

.dark .settings-button:hover {
    background: #4B5563;
}

.settings-button.active {
    background: #8B5CF6;
    color: white;
    border-color: #8B5CF6;
}

.settings-info {
    font-size: 0.75rem;
    color: #6B7280;
    margin-top: 0.5rem;
}

.dark .settings-info {
    color: #9CA3AF;
}

/* Breadcrumb - subtle overlay */
.breadcrumb-nav {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 50;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: 0.875rem;
}

.dark .breadcrumb-nav {
    background: rgba(31, 41, 55, 0.95);
}

@media (max-width: 768px) {
    .settings-panel {
        width: 100%;
        right: -100%;
    }

    .breadcrumb-nav {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }

    .settings-toggle {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
    }
}

