/**
 * Homepage Interactive Map - Mobile & Desktop Responsive Styles
 */

/* Map Container */
.homepage-interactive-map {
    position: relative;
    width: 100%;
    height: 700px;
    min-height: 500px;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid var(--color-border);
    background: var(--color-bg-card);
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#homepageMapCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
}

#homepageMapCanvas:active {
    cursor: grabbing;
}

/* Map Controls */
.map-zoom-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
    pointer-events: auto;
}

.map-control-btn {
    width: 45px;
    height: 45px;
    background: var(--color-bg-card);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    color: var(--color-text);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.map-control-btn:hover {
    background: var(--color-bg-light);
    border-color: var(--color-accent);
    transform: scale(1.05);
}

.map-control-btn:active {
    transform: scale(0.95);
}

/* Map Controls Bar */
.map-controls-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    justify-content: center;
}

.map-controls-bar input,
.map-controls-bar select,
.map-controls-bar button {
    transition: all 0.2s ease;
}

.map-controls-bar input:focus,
.map-controls-bar select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.2);
}

/* Search Results Dropdown */
.map-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 0.5rem;
    background: var(--color-bg-card);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.search-result-item {
    padding: 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--color-bg-light);
}

.search-result-item:last-child {
    border-bottom: none;
}

/* Village Details Panel - Desktop */
.village-details-panel {
    position: fixed;
    top: 50%;
    right: -400px;
    transform: translateY(-50%);
    width: 380px;
    max-width: calc(100vw - 2rem);
    max-height: 80vh;
    background: var(--color-bg-card);
    border: 2px solid var(--color-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1), bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    visibility: hidden;
    opacity: 0;
}

.village-details-panel.active {
    right: 2rem;
    visibility: visible;
    opacity: 1;
}

.close-panel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 35px;
    height: 35px;
    background: transparent;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    color: var(--color-text);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    touch-action: manipulation;
    z-index: 10;
}

.close-panel:hover {
    background: var(--color-primary);
    border-color: var(--color-accent);
    transform: rotate(90deg);
}

/* Village Details Panel - Mobile (Bottom Sheet) */
@media (max-width: 768px) {
    .village-details-panel {
        top: auto;
        bottom: -100%;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        max-height: 80vh;
        transform: none;
        border-radius: 20px 20px 0 0;
        transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1), right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .village-details-panel.active {
        bottom: 0;
        right: 0;
    }

    /* Mobile Map Container */
    .homepage-interactive-map {
        height: 500px;
        min-height: 400px;
        border-radius: 15px;
    }

    /* Mobile Controls */
    .map-zoom-controls {
        top: 0.75rem;
        right: 0.75rem;
        gap: 0.4rem;
    }

    .map-control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
        border-radius: 15px;
    }

    /* Mobile Controls Bar */
    .map-controls-bar {
        flex-direction: column;
        gap: 0.75rem;
    }

    .map-controls-bar input,
    .map-controls-bar select,
    .map-controls-bar button {
        width: 100%;
        min-width: auto;
        padding: 1rem;
        font-size: 1rem;
    }

    /* Mobile Search Results */
    .map-search-results {
        max-height: 250px;
        border-radius: 12px;
    }

    .search-result-item {
        padding: 1.25rem;
        font-size: 1rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .homepage-interactive-map {
        height: 400px;
        min-height: 350px;
    }

    .map-control-btn {
        width: 45px;
        height: 45px;
        font-size: 1.4rem;
    }

    .village-details-panel {
        max-height: 85vh;
        padding: 1.5rem;
    }
}

/* Tooltip */
.map-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--color-bg-card);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 250px;
}

@media (max-width: 768px) {
    .map-tooltip {
        font-size: 0.85rem;
        padding: 0.6rem 0.85rem;
        max-width: 200px;
    }
}

/* Accessibility */
.map-control-btn:focus,
#closeVillagePanel:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #homepageMapCanvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .homepage-interactive-map {
        height: 400px;
    }

    .village-details-panel {
        max-height: 70vh;
    }
}

