/* Explore page (map + filterable timeline) */

/* Break out of the centered .main-section-wrapper max-width on this page. */
.main-section-wrapper:has(> #explore-page) {
    max-width: none;
    padding: 0.5rem 1rem;
}

#explore-page {
    max-width: none;
    margin: 0 auto;
    padding: 0;
}

#explore-page h1 {
    font-size: 1.5rem;
    margin: 0.5rem 0 1rem 0;
}

#explore-filters {
    background: #f6f6f6;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    align-items: flex-start; /* left-align contents */
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    width: 100%;
}

.filter-label {
    font-weight: 600;
    min-width: 9em;
    flex-shrink: 0;
}

.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-start;
}

.filter-pill {
    background: #fff;
    border: 1px solid #aaa;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.filter-pill .pill-flag {
    font-size: 1.05em;
    line-height: 1;
}

.filter-pill .pill-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    /* PhyloPic silhouettes are black on transparent; invert when active. */
    transition: filter 0.15s;
}

.filter-pill.active .pill-icon {
    filter: invert(1);
}

.filter-pill:hover {
    background: #eaeaea;
}

.filter-pill.active {
    background: #355;
    color: #fff;
    border-color: #355;
}

.search-wrapper {
    position: relative;
    flex-grow: 1;
    max-width: 22em;
    z-index: 10;
}

#taxon-search {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
    border: 1px solid #aaa;
    border-radius: 6px;
    box-sizing: border-box;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #aaa;
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    width: 100%;
    box-sizing: border-box;
}

.search-result-item {
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-result-item.highlighted {
    background: #b49898;
}

.search-result-icon,
.search-result-icon-placeholder {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    object-fit: contain;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.filter-chip {
    background: #e1ecf4;
    border: 1px solid #b6cee8;
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.chip-remove {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    padding: 0 0.2rem;
    color: #335;
}

.chip-remove:hover {
    color: #c00;
}

.filter-actions {
    justify-content: flex-start;
}

#filter-clear-all {
    padding: 0.3rem 0.8rem;
    border: 1px solid #888;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

#filter-clear-all:hover {
    background: #f0f0f0;
}

#map {
    height: 55vh;
    min-height: 320px;
    margin-bottom: 1rem;
    border-radius: 6px;
    overflow: hidden;
    z-index: 1;
}

.popup-content {
    max-width: 250px;
    color: inherit;
}

.popup-title {
    font-weight: bold;
    margin-bottom: 0.2rem;
}

.popup-meta {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.4rem;
}

.popup-img {
    width: 100%;
    border-radius: 4px;
}

/* Timeline */

#timeline-wrapper {
    position: relative;
    width: 100%;
    user-select: none;
    margin-bottom: 1.5rem;
    padding-top: 20px; /* room for handle labels above */
}

#timeline-svg {
    display: block;
    width: 100%;
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#timeline-handles {
    position: absolute;
    top: 20px; /* aligned with svg start (after padding-top) */
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

#timeline-handle-labels {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 18px;
    pointer-events: none;
}

.handle-label {
    position: absolute;
    transform: translateX(-50%);
    background: #355;
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
}

.timeline-handle {
    position: absolute;
    top: 4px;
    bottom: 32px;
    width: 12px;
    margin-left: -6px;
    background: rgba(50, 50, 50, 0.85);
    border-radius: 3px;
    cursor: ew-resize;
    pointer-events: auto;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.timeline-handle:hover {
    background: rgba(20, 20, 20, 0.95);
}

.timeline-handle span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 18px;
    background: #fff;
    border-radius: 1px;
}

.period-label {
    pointer-events: none;
    user-select: none;
}
