/* waifu-wars/css/worldMap.css - Styles for the world map and its interactive elements */

#world-map-container {
    position: absolute;
    top: 85px;
    left: 320px;
    right: 370px;
    bottom: 65px;
    color: white;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

#world-map-container.choosing-start {
    width: 100%;
    height: 100%;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    padding: 10px;
    box-sizing: border-box;
}

#world-map-header {
    padding: 15px;
    text-align: center;
    background: var(--theme-bg-color);
    border: 1px solid var(--theme-border-color);
    border-radius: 8px;
    margin: 0 auto 10px;
    width: fit-content;
}

#world-map-header h2 {
    margin: 0;
    font-weight: 300;
    letter-spacing: 2px;
    color: var(--theme-primary-text-color);
}

#map-area {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* This is the key container for positioning */
#map-content {
    position: relative;
    display: inline-block; /* This makes the container shrink-wrap the main map image */
    user-select: none;
    -webkit-user-drag: none;
    line-height: 0; /* Prevents unwanted space below the image */
}

/* Base map image dictates the aspect ratio */
#world-map-image {
    display: block;
    pointer-events: none; /* Make sure clicks go through to regions */
    z-index: 1;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.region-outline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%; /* Should now correctly match the width of the contained map image */
    height: 100%;/* Should now correctly match the height of the contained map image */
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
    z-index: 3;
}

/* All overlays are positioned absolutely to cover the map content */
.country-region, #player-marker {
    position: absolute;
}

/* The clickable areas are now sized relative to the map content which is sized by the image */
.country-region {
    z-index: 9;
    cursor: pointer;
    overflow: visible; /* Prevents tooltips from being cut off */
}

#player-marker {
    width: 20px;
    height: 20px;
    background: gold;
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px gold, 0 0 5px gold inset;
    z-index: 11;
    pointer-events: none;
}

.country-region.locked {
    cursor: not-allowed;
    filter: grayscale(80%) brightness(0.5);
}

.country-region:hover {
    z-index: 10; /* Bring hovered region to the front for tooltip */
}

/* Tooltip for region name on hover */
.region-name-tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -150%); /* Position above region */
    background: var(--theme-bg-color);
    color: var(--theme-primary-text-color);
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid var(--theme-border-color);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
    pointer-events: none;
    z-index: 12;
    font-size: 1.1em;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.country-region:hover .region-name-tooltip {
    opacity: 1;
    transform: translate(-50%, -170%); /* Animate upwards on hover */
}

/* Popup for region details on click */
.popup.region-info-popup {
    width: 400px;
    max-width: 90vw;
    text-align: left;
    background: var(--theme-bg-color);
    border: 1px solid var(--theme-border-color);
    cursor: default;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

.popup.region-info-popup h3 {
    text-align: center;
    margin: 0 0 15px 0;
    color: var(--theme-primary-text-color);
    font-family: 'Georgia', serif;
    font-size: 1.5em;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--theme-border-color);
}

.popup.region-info-popup h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--theme-secondary-text-color);
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
    font-size: 1.1em;
}

.popup.region-info-popup .capitol-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.popup.region-info-popup .capitol-container h4 {
    margin-top: 0;
    margin-bottom: 10px;
}

.popup.region-info-popup ul:not(.selectable-list) {
    list-style: '✧ ';
    padding-left: 20px;
    margin: 0;
}

.popup.region-info-popup li {
    padding: 2px 0;
}

.popup.region-info-popup .selectable-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
    max-height: 200px;
    overflow-y: auto;
}
.popup.region-info-popup .selectable-list.disabled {
    opacity: 0.5;
    pointer-events: none;
    background-color: rgba(0,0,0,0.2);
    border-radius: 5px;
    padding: 5px;
}

.popup.region-info-popup .city-selection-item {
    padding: 12px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.2s;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255,255,255,0.05);
    margin-bottom: 5px;
}

.popup.region-info-popup .city-selection-item span {
    font-size: 0.8em;
    color: #ccc;
}

.popup.region-info-popup .city-selection-item:hover {
    background-color: var(--theme-button-hover-bg);
}

.popup.region-info-popup .city-selection-item.selected {
    background-color: var(--theme-button-active-bg);
    border-color: var(--theme-border-color);
}

.popup.region-info-popup .city-selection-item.selected::after {
    content: '✔';
    color: #90ee90;
    font-weight: bold;
}

.travel-options {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    flex-shrink: 0;
    margin-left: 10px;
}
.travel-options .travel-btn {
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
}

/* --- Weather Effects --- */
.weather-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden; /* Contain weather effects */
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.weather-overlay.fog {
    background: radial-gradient(circle at 50% 50%, rgba(200,200,200,0.3) 0%, rgba(180,180,180,0) 70%);
    opacity: 0.7;
    animation: drift 60s linear infinite alternate;
}

@keyframes drift {
    from { transform: translateX(-10%) translateY(5%); }
    to { transform: translateX(10%) translateY(-5%); }
}

.raindrop {
    position: absolute;
    bottom: 100%;
    width: 1px;
    height: 50px;
    background: linear-gradient(to top, rgba(173,216,230,0), rgba(173,216,230,0.5));
    animation: fall linear infinite;
}

@keyframes fall {
    to { transform: translateY(100vh); }
}

.snowflake {
    position: absolute;
    top: -20px;
    color: #fff;
    user-select: none;
    animation: snowfall linear infinite;
    text-shadow: 0 0 5px #fff;
}

@keyframes snowfall {
    0% { transform: translateY(0vh) translateX(0px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) translateX(20px) rotate(360deg); opacity: 0; }
}

/* --- Mobile Optimizations --- */
@media (max-width: 1024px) {
    #world-map-container {
        left: 10px;
        right: 10px;
    }
    .region-name-tooltip {
        display: none; /* Tooltips are not user-friendly on touch devices */
    }
}