/* --- CORE LAYOUT --- */
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; 
    font-family: 'Inter', 'Noto Color Emoji', 'Segoe UI Emoji', sans-serif; }
#main-layout { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* Sidebar Base Styles */
#sidebar { 
    width: 130px; 
    background: rgb(255, 255, 255); 
    border-right: 1px solid #e5e7eb; 
    display: flex; 
    flex-direction: column; 
    z-index: 20000; /* High enough to sit on top of the map */
    transition: transform 0.3s ease-in-out; 
}

/* Mobile Specific Tweaks */
@media (max-width: 768px) {
    #sidebar {
        position: absolute; /* Float over the map/portal */
        height: 100%;
        left: 0;
        top: 0;
        transform: translateX(-100%); /* Start hidden off-screen */
    }
    /* When the 'open' class is added via JS, slide it in */
    #sidebar.open {
        transform: translateX(0);
        box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    }
}
/* shrink the title on landscape phones */
@media (max-height: 450px) {
    #top-nav {
        height: 40px;
        min-height: 40px;
        max-height: 40px;
    }
}
#sidebar-years { flex-grow: 1; overflow-y: auto; }

/* Content Area */
#content-area { 
    display: flex; 
    flex-direction: column; 
    width: 100vw;   /* Ensure it takes full width of the 'viewport' */
    height: 100dvh; /* Keeps it exactly the height of the phone screen */
    overflow: hidden; /* Prevents the title from scrolling away */
}
/* the title bar with the hamburger to the left and the view-switch to the right */
#top-nav {
    height: 60px;
    min-height: 60px;
    max-height: 60px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;      /* Force everything on ONE line */
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: white;
    z-index: 10001;
    overflow: hidden;       /* Safety: nothing leaks out */
    flex-shrink: 0;         /* Header never gets crushed */
}
/* alpine Retrospective: YYYY */
#current-year-label {
    flex-grow: 1;           /* Take the middle space */
    flex-shrink: 1;         /* Shrink if the phone is narrow */
    min-width: 0;           /* REQUIRED to allow shrinking/ellipsis */
    text-align: center;
    white-space: nowrap;    /* NO second line, ever */
    overflow: hidden;       /* Hide extra text if it doesn't fit */
    text-overflow: ellipsis; /* Add "..." if text is too long */
    font-size: 14px;        /* Fixed size for reliability */
}

/* The filter bar with the activity switches */
#header-filter-bar {
    -ms-overflow-style: none;  /* IE/Edge */
    scrollbar-width: none;     /* Firefox */
}
#header-filter-bar::-webkit-scrollbar {
    display: none;             /* Chrome/Safari */
}

/* Die Buttons im Header etwas kleiner und feiner */
#header-filter-bar .filter-button {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    font-size: 1.5rem;
    border-radius: 50%;
    border: 1px solid #e5e7eb;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Noto Color Emoji', sans-serif !important;
}

#header-filter-bar .filter-button-active {
    background: #d3f6b7 !important; 
    border-color: #7d7d7e !important;
}

/* View Containers: Absolute positioning relative to #content-area */
#portal-view, #map-view { 
    flex-grow: 1; /* Take up the remaining space */
    position: relative; /* Changed from absolute */
    width: 100%;
}

#portal-view { 
    background: #f9fafb; 
    padding: 20px; 
    overflow-y: auto; /* Allow scrolling inside the portal, but keep header fixed */
    height: 0; /* Pro-tip: This forces Flexbox to calculate height based on the parent, not the content */
    min-height: 100%; /* Ensures it fills the space */
}
#map-view { z-index: 5; display: none; flex-direction: column; /* Ensure internal elements layout correctly */
            width: 100%; height: 100%; overflow: hidden; } /* Hidden by default, switchView handles this */

/* Map styling to fill the entire section */
#map-container, #map { width: 100%; height: 100%; position: relative; display: block; }

/* --- UI ELEMENTS --- */
.year-btn { padding: 12px 20px; cursor: pointer; font-weight: 700; color: #64748b; border-left: 4px solid transparent; transition: 0.2s; }
.year-btn:hover { background: #f8fafc; color: #4f46e5; }
.year-btn.active { background: #eef2ff; color: #4f46e5; border-left-color: #4f46e5; }

.floating-container { position: absolute; z-index: 9999; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.pop-out-panel { 
    background: white; padding: 15px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); 
    min-width: 240px; display: none; flex-direction: column; gap: 10px; border: 1px solid #e5e7eb; 
    max-height: 45vh; overflow-y: auto; 
}
.circle-toggle { 
    background: #4f46e5; color: white; width: 50px; height: 50px; border-radius: 50%; 
    cursor: pointer; border: 3px solid white; font-size: 1.5rem; display: flex; 
    align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(0,0,0,0.2); 
}

/* Marker & Popup Styles, priority to noto emojis */
.use-noto { font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.emoji-marker-outer { width: 28px!important; height: 28px!important; border-radius: 50%; border: 2px solid white; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.marker-ski { background: #9333ea; } .marker-piste { background: #4f46e5; } 
.marker-hike { background: #b54708; } .marker-climb { background: #eb1911d8; } .marker-rope { background: #d80303; } 
.marker-bike { background: #065f46; } .marker-bike-hike { background: #f97316; } .marker-trip { background: #928cfa; } 
.marker-unknown { background: #6b7280; }
.emoji-marker-inner { font-size: 11pt; background: white; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; 
    justify-content: center; font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif; }
.filter-button { padding: 8px; font-size: 0.75rem; font-weight: 700; border-radius: 8px; cursor: pointer; border: 1px solid #d1d5db; 
    text-align: center; width: 100%; font-family: 'Noto Color Emoji', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif; }
.filter-button-active { background: #4f46e5 !important; color: white !important; }
/* Activities Popup & Title Styling */
.leaflet-popup-content { width: 200px !important; margin: 4px; }
/* This targets any anchor inside our custom popups (still leaflet) specifically */
.custom-tour-popup a, 
.custom-tour-popup a:hover, 
.custom-tour-popup a:visited {
    color: white !important;
    text-decoration: none !important;
    display: flex; /* Helps with vertical alignment */
    align-items: center;
    justify-content: center;
}
.popup-title { 
    font-size: 10px; line-height: 1.3; margin: 5px 0; font-weight: bold;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.photo-popup-img { width: 100%; border-radius: 0.4rem; object-fit: cover; height: 120px; margin-bottom: 5px; }

.track-label { 
    background: rgba(255, 255, 255, 0.9); border: 1px solid #999; padding: 1px 5px; 
    font-weight: bold; border-radius: 4px; font-size: 10px; color: #333; 
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1); white-space: nowrap;
}

/* Styling for the Hover Tooltip */
.hover-title {
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    border: none !important;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
}

/* This styles the arrow to match the black background */
.leaflet-tooltip-top.hover-title:before {
    border-top-color: rgba(0, 0, 0, 0.8);
}
/* avoid the hover-title if we are on a touch device without mouse */
@media (hover: none) {
    .hover-title, .leaflet-tooltip-pane {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}
.leaflet-tooltip-right:before, .leaflet-tooltip-left:before { display: none; }

/* no image found or defined */
.portal-img-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #f3f4f6; /* Hellgrau */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.portal-img-container::before {
    content: "📷";
    font-size: 2rem;
    opacity: 0.2;
    position: absolute;
}

.portal-img-container img {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    z-index: 1;
    /* 1. Ein weicher weißer Schein direkt an der Kante (hellt den Übergang auf) */
    /* 2. Ein ganz dezenter dunklerer Schatten für die Tiefe */
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.8)) 
            drop-shadow(0 2px 10px rgba(10, 10, 10, 0.2));
    /* Optional: Ein minimaler Border, der nur 10% Deckkraft hat */
    border: 1px solid rgba(0,0,0,0.05);
}
