/**
 * OD WWL Interactive Map block styles.
 * Uses theme design tokens (var(--od-color-*)) injected globally.
 * Material Icons are loaded globally on singular pages (see od-register-enqueue.php).
 */

/* ---------- SVG path classes ----------
   The source SVG tags each <path> with either .cls-1 (standard land) or
   .cls-2 (very thin strokes for tiny islands). Default fill is light gray;
   rank-based fills (red/orange) are injected inline per-instance by the PHP
   block template using scoped selectors like #wwl-svg-map-wrapper-xxx #AF. */

.wwl-svg-map__svg .cls-1,
.wwl-svg-map__svg .cls-2 {
    fill: var(--od-color-light-gray);
    stroke: #fff;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wwl-svg-map__svg .cls-1 {
    stroke-width: 0.5px;
}

.wwl-svg-map__svg .cls-2 {
    stroke-width: 0.25px;
}

/* ---------- Map surface ---------- */

.wwl-svg-map-wrapper {
    position: relative;
    overflow: hidden;
    background-color: var(--od-color-dark-gray);
    border-radius: 6px;
}

.wwl-svg-map__inner {
    position: relative;
}

.wwl-svg-map__svg {
    display: block;
    width: 100%;
    /* Match the viewBox aspect ratio (1730.4x855.5) so the SVG box always
       exactly contains the rendered world map. */
    aspect-ratio: 1730.4 / 855.5;
    height: auto;
    max-height: 650px;
}

@media (max-width: 639px) {
    /* On small phones the aspect-ratio-derived height is too short to read
       the map comfortably. Drop the strict ratio and add 50px of vertical
       breathing room on top of whatever width-driven height we'd get. */
    .wwl-svg-map__svg {
        aspect-ratio: auto;
        height: calc(100vw * 855.5 / 1730.4 + 50px);
        max-height: 500px;
    }
}

@media (max-width: 399px) {
    /* Very narrow phones: add another 100px (150px total over base ratio). */
    .wwl-svg-map__svg {
        height: calc(100vw * 855.5 / 1730.4 + 150px);
    }
}

@media (min-width: 980px) {
    .wwl-svg-map__svg {
        aspect-ratio: auto;
        height: 500px;
        max-height: none;
    }
}

.wwl-svg-country {
    transition: opacity 0.15s ease, filter 0.15s ease;
    cursor: pointer;
}

.wwl-map-zoomed { opacity: 0.5; }
.wwl-map-zoomed.wwl-map-selected { opacity: 1; }

/* ---------- Top-left control bar ---------- */

.wwl-svg-map__controls {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 6px;
    z-index: 20;
}

.wwl-svg-map__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: #fff;
    color: var(--od-color-purple);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.wwl-svg-map__btn:hover,
.wwl-svg-map__btn:focus-visible {
    background-color: var(--od-color-purple);
    color: #fff;
    outline: none;
}

.wwl-svg-map__btn .material-icons {
    font-size: 20px;
    line-height: 1;
}

/* The info button is always visible; clicking it opens the info window. */
/* ---------- Tooltip (hover-on-country) ---------- */

.wwl-svg-map__tooltip {
    position: absolute;
    top: 0;
    left: 50%;
    z-index: 30;
    max-width: 260px;
    padding: 6px 12px;
    background-color: #fff;
    color: var(--od-color-purple);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
    transform: translate(-50%, -50px);
}

.wwl-svg-map__tooltip::after {
    content: "";
    position: absolute;
    bottom: -7px;
    left: 50%;
    width: 0;
    border-style: solid;
    border-width: 8px 8px 0;
    border-color: #fff transparent transparent transparent;
    transform: translateX(-50%);
}

/* ---------- Info / country windows ---------- */

.wwl-svg-map__window {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 25;
    width: 280px;
    max-width: calc(100% - 24px);
    padding: 16px 20px;
    background-color: #fff;
    color: var(--od-color-dark-gray);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    font-size: 16px;
}

/* The info window starts closed; the info button opens it, and the close
   button (or selecting a country / centering) closes it again. */
.wwl-svg-map__info {
    width: 320px;
}

.wwl-svg-map__info p {
    margin: 0 0 6px;
    font-size: 14px;
    line-height: 1.4;
}

.wwl-svg-map__window h2 {
    margin: 0 40px 10px 0;
    padding: 0 0 6px 0;
    color: var(--od-color-purple);
    font-size: 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--od-color-purple);
}

.wwl-svg-map__window h3 {
    margin: 12px 0 8px;
    color: var(--od-color-dark-gray);
    font-size: 15px;
    font-weight: 600;
}

.wwl-svg-map__window p {
    margin: 0 0 8px;
    line-height: 1.4;
}

.wwl-svg-map__window .wwl-svg-map__link.button {
    display: block;
    width: 100%;
    margin-bottom: 6px;
    padding: 8px 12px;
    font-size: 15px;
    line-height: 1.2;
    text-align: center;
}

/* Close button (top-right of every window) */
.wwl-svg-map__window-close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: transparent;
    color: var(--od-color-purple);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.wwl-svg-map__window-close:hover,
.wwl-svg-map__window-close:focus-visible {
    background-color: var(--od-color-purple);
    color: #fff;
    outline: none;
}

.wwl-svg-map__window-close .material-icons {
    font-size: 20px;
    line-height: 1;
}

/* ---------- Per-country info window ---------- */

.wwl-svg-map__country-window {
    width: 320px;
}

.wwl-svg-map__country-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}

.wwl-svg-map__country-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    background-color: var(--od-color-wwl-red);
    color: #fff;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
}

.wwl-svg-map__country-meta {
    margin: 0 0 6px;
    font-size: 14px;
    line-height: 1.4;
}

.wwl-svg-map__country-meta strong {
    color: var(--od-color-purple);
    font-weight: 600;
}

.wwl-svg-map__country-actions {
    margin: 12px 0 0;
    text-align: right;
}

.wwl-svg-map__country-link {
    display: inline-block;
    padding: 8px 14px;
    background-color: var(--od-color-purple);
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.wwl-svg-map__country-link:hover,
.wwl-svg-map__country-link:focus-visible {
    background-color: var(--od-color-wwl-red);
    color: #fff;
    text-decoration: none;
    outline: none;
}
