/* Import Inter font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* Import enhanced animations */
@import url('./animations.css');

/* Import mobile optimizations */
@import url('./mobile.css');

/* Import loading states and skeleton screens */
@import url('./loading.css');

/* Base styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    font-feature-settings: 'kern' 1, 'liga' 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Enhanced map container styles */
#map-container {
    width: 100%;
    height: 100vh;
    position: relative;
}

/* Enhanced POI marker styles */
.poi-marker {
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    z-index: 100;
}

.poi-marker:hover {
    transform: scale(1.05);
}

.poi-marker:active {
    transform: scale(0.95);
}

.poi-marker-container {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.poi-marker-main {
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.poi-marker-pulse > div {
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.poi-marker-pulse > div:nth-child(2) {
    animation-delay: 0.5s;
}

/* Enhanced sidebar panel with improved styling and layering */
#sidebar-info-panel {
    /* Enhanced white/blurish background */
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.98) 0%,
        rgba(255, 255, 255, 0.92) 100%);
    
    /* Improved backdrop effects */
    backdrop-filter: blur(20px) saturate(180%) contrast(120%);
    -webkit-backdrop-filter: blur(20px) saturate(180%) contrast(120%);
    
    /* Enhanced borders and shadows */
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        -16px 0 64px rgba(0, 0, 0, 0.08),
        -4px 0 16px rgba(0, 0, 0, 0.04),
        inset 1px 0 0 rgba(255, 255, 255, 0.4);
    
    /* Proper layering - above storytelling overlay */
    z-index: 30;
    
    /* Enhanced transitions */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* GPU acceleration for better performance */
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Enhanced sidebar transition states */
#sidebar-info-panel[data-transition-state="showing"] {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#sidebar-info-panel[data-transition-state="hiding"] {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#sidebar-info-panel[data-transition-state="visible"] {
    transform: translateX(0) !important;
}

#sidebar-info-panel[data-transition-state="hidden"] {
    transform: translateX(100%) !important;
}

/* Desktop styles for SidebarInfoPanel scrolling */
@media (min-width: 769px) {
    #sidebar-info-panel {
        /* Ensure it has a constrained height (e.g., h-full or height: 100vh). */
        /* The existing class 'h-full' likely means height: 100%. */
        overflow-y: hidden; /* Prevent the panel itself from scrolling */
    }

    /* The main padding container within the panel */
    #sidebar-info-panel > .p-6 { /* Targeting the direct child div with p-6 */
        display: flex;
        flex-direction: column;
        height: 100%; /* Make this inner container take full height of the panel */
    }

    /* The header div containing the title and close button */
    #sidebar-info-panel > .p-6 > .flex.justify-between.items-center {
        flex-shrink: 0; /* Prevents the header from shrinking */
    }

    #sidebar-content {
        flex-grow: 1;       /* Allows content area to take up available vertical space */
        overflow-y: auto;   /* Enables vertical scrollbar for content */
        min-height: 0;      /* Crucial for scrolling within flex child */
        /* Padding for sidebar-content is generally handled by its content or Tailwind classes. */
        /* The parent .p-6 provides overall padding for the panel's inner layout. */
    }

    /* Custom scrollbar for the #sidebar-content area on desktop */
    #sidebar-content::-webkit-scrollbar {
        width: 8px; /* Consistent with previous panel scrollbar width */
    }

    #sidebar-content::-webkit-scrollbar-track {
        background: #f8fafc; /* Light gray track, consistent with previous */
    }

    #sidebar-content::-webkit-scrollbar-thumb {
        background: #cbd5e1; /* Medium gray thumb, consistent with previous */
        border-radius: 4px;  /* Consistent with previous */
    }

    #sidebar-content::-webkit-scrollbar-thumb:hover {
        background: #94a3b8; /* Darker gray thumb on hover, consistent */
    }
}

/* Legacy scrollbar styles for #sidebar-info-panel - commented out as we now use #sidebar-content for scrolling */
/*
#sidebar-info-panel::-webkit-scrollbar {
    width: 6px;
}

#sidebar-info-panel::-webkit-scrollbar-track {
    background: #f8fafc;
}

#sidebar-info-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#sidebar-info-panel::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
*/

/* Enhanced media viewer with improved backdrop and styling */
#media-viewer {
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    background: rgba(0, 0, 0, 0.85);
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#media-viewer.animate-fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#media-viewer.animate-fade-out {
    animation: fadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#media-viewer img,
#media-viewer video {
    border-radius: 16px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.6),
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    max-height: 85vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#media-viewer img:hover,
#media-viewer video:hover {
    transform: scale(1.02);
}

#media-close {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#media-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.animate-scale-up {
    animation: scaleUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced navigation controls with improved styling */
#navigation-controls {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
}

#navigation-controls:hover {
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.12),
        0 4px 16px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    transform: translateY(-1px);
}

#navigation-controls button {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#navigation-controls button:disabled {
    cursor: not-allowed;
}

#navigation-controls button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 16px rgba(14, 165, 233, 0.25),
        0 2px 8px rgba(14, 165, 233, 0.15);
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
}

#navigation-controls button:active {
    transform: translateY(-1px);
    transition: transform 0.1s ease;
}

#navigation-controls button:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 2px;
    box-shadow:
        0 0 0 4px rgba(14, 165, 233, 0.1),
        0 4px 8px rgba(14, 165, 233, 0.3);
}

.progress-dots {
    margin-top: 8px;
}

.progress-dots div {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Enhanced storytelling overlay with improved visual hierarchy */
#storytelling-overlay {
    backdrop-filter: blur(4px) saturate(120%);
    -webkit-backdrop-filter: blur(4px) saturate(120%);
    background: linear-gradient(0deg,
        rgba(0, 0, 0, 0.85) 0%,
        rgba(0, 0, 0, 0.45) 70%,
        transparent 100%);
}

#storytelling-overlay h3 {
    text-shadow:
        0 2px 8px rgba(0, 0, 0, 0.6),
        0 1px 2px rgba(0, 0, 0, 0.8);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

#storytelling-overlay p {
    text-shadow:
        0 1px 4px rgba(0, 0, 0, 0.5),
        0 1px 2px rgba(0, 0, 0, 0.7);
    line-height: 1.6;
    font-weight: 400;
}

#storytelling-overlay .text-gray-300 {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.narrative-progress-indicator {
    animation: slideInFromRight 0.5s ease-out;
}

/* Text truncation support classes */
.text-truncate-lines {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
}

.text-truncate-1 {
    -webkit-line-clamp: 1;
}

.text-truncate-2 {
    -webkit-line-clamp: 2;
}

.text-truncate-3 {
    -webkit-line-clamp: 3;
}

.text-truncate-4 {
    -webkit-line-clamp: 4;
}

/* Storytelling overlay text truncation enhancements */
#storytelling-overlay .truncated-content {
    position: relative;
}

#storytelling-overlay .truncated-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 1.6em;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.85));
    pointer-events: none;
}

/* Ensure proper text rendering for truncated content */
#storytelling-overlay p {
    margin-bottom: 0.75rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

#storytelling-overlay p:last-child {
    margin-bottom: 0;
}

/* Enhanced scroll progress bar */
#scroll-progress {
    z-index: 1000;
    backdrop-filter: blur(4px);
}

#scroll-progress-bar {
    background: linear-gradient(90deg, #0ea5e9, #3b82f6, #8b5cf6);
    box-shadow: 0 0 16px rgba(14, 165, 233, 0.6);
    transition: width 0.1s ease-out;
}

/* Content enhancements */
.prose {
    line-height: 1.7;
}

.prose p {
    margin-bottom: 1rem;
}

/* Animation keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

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

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

@keyframes bounce-in {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) skewX(-12deg);
    }
    100% {
        transform: translateX(200%) skewX(-12deg);
    }
}

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

/* Utility classes */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slide-up 0.5s ease-out backwards;
}

.animate-bounce-in {
    animation: bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.animation-delay-200 {
    animation-delay: 200ms;
}

/* Enhanced responsive design */
@media (max-width: 1024px) {
    #sidebar-info-panel {
        width: 100%;
        max-width: 440px;
    }
    
    #navigation-controls {
        backdrop-filter: blur(8px);
    }
}

@media (max-width: 768px) {
    #sidebar-info-panel {
        width: 100%;
        max-width: 100%;
        height: 100vh;
    }
    
    #navigation-controls {
        position: fixed;
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        padding: 1rem;
    }
    
    #navigation-controls .flex-col {
        flex-direction: row;
        align-items: center;
        space-x: 1rem;
    }
    
    #navigation-controls button {
        padding: 0.75rem 1.5rem;
        font-size: 0.8rem;
        min-width: auto;
    }
    
    #step-indicator {
        order: 2;
        margin: 0 1rem;
        text-align: center;
    }
    
    .progress-dots {
        margin: 0.5rem 0 0 0;
    }
    
    #storytelling-overlay {
        padding: 1.5rem;
        background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 70%, transparent 100%);
    }
    
    #storytelling-overlay h3 {
        font-size: 1.4rem;
        margin-bottom: 0.5rem;
    }
    
    #storytelling-overlay p {
        font-size: 1rem;
    }
    
    #media-viewer img,
    #media-viewer video {
        max-height: 70vh;
        border-radius: 8px;
    }
}

@media (max-width: 640px) {
    #navigation-controls button {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    #storytelling-overlay {
        padding: 1rem;
    }
    
    .poi-marker-container {
        transform: scale(0.9);
    }
}

/* Improve 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;
    }
    
    .poi-marker-pulse > div {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #navigation-controls {
        background: #ffffff;
        border: 2px solid #000000;
    }
    
    #storytelling-overlay {
        background: rgba(0, 0, 0, 0.98);
    }
    
    .poi-marker-main {
        border-width: 3px;
    }
}

/* Focus management */
button:focus,
.poi-marker:focus,
[tabindex]:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 2px;
}

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

/* Loading states */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Enhanced scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1, #94a3b8);
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #94a3b8, #64748b);
}
::-webkit-scrollbar-corner {
    background: #f1f5f9;
}

/* PWA Install Button Styles */
#pwa-install-button {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

#pwa-install-button button {
    font-feature-settings: 'kern' 1, 'liga' 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* PWA Countdown Animation */
@keyframes pwa-countdown {
    0% {
        transform: scale(1);
        opacity: 0.75;
    }
    50% {
        transform: scale(1.5);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Screen Reader Only Class */
.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;
}

/* Enhanced Overview Content Styling */
.overview-content {
    position: relative;
    padding: 0.5rem 0;
}

.overview-content::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #0ea5e9, #3b82f6);
    border-radius: 2px;
    opacity: 0.6;
}

/* Enhanced Progress Indicator Styling */
.narrative-progress-indicator {
    animation: slideInFromRight 0.5s ease-out;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-feature-settings: 'kern' 1, 'liga' 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.narrative-progress-indicator .animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Enhanced language switcher with improved styling */
#language-switcher {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.08),
        0 1px 4px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    overflow: hidden;
}

#language-switcher button {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

#language-switcher button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

#language-switcher button:hover::before {
    left: 100%;
}

#language-switcher button:hover {
    background: rgba(14, 165, 233, 0.1);
    color: #0ea5e9;
    transform: translateY(-1px);
}

#language-switcher button.active {
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    color: white;
    box-shadow:
        0 2px 8px rgba(14, 165, 233, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

#language-switcher button:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 2px;
}

/* Enhanced touch targets for mobile */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

.touch-target-comfortable {
    padding: 12px;
}

/* Enhanced visual hierarchy */
.visual-hierarchy-primary {
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.025em;
}

.visual-hierarchy-secondary {
    font-weight: 500;
    color: #475569;
    letter-spacing: -0.01em;
}

.visual-hierarchy-tertiary {
    font-weight: 400;
    color: #64748b;
}

/* Enhanced micro-interactions */
.micro-interaction {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.micro-interaction:hover {
    transform: translateY(-1px);
}

.micro-interaction:active {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

/* Enhanced glass morphism effects */
.glass-morphism {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px) saturate(180%) contrast(120%);
    -webkit-backdrop-filter: blur(16px) saturate(180%) contrast(120%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.glass-morphism-dark {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px) saturate(150%);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
