/* ============================================================================
   Gremsy .com — Distributor dot-matrix map (self-hosted, no external tiles).
   Scoped under .dist-map. Cyan accent = --color-primary (#00aedf). Panel is a
   fixed-dark HUD "control screen"; dots are painted on <canvas> by
   distributor-map.js, markers are absolutely-positioned buttons over it.
============================================================================ */
.dist-map {
    --dm-accent: var(--color-primary, #00aedf);
    position: relative;
    width: 100%;
    aspect-ratio: 20 / 9;
    max-height: 520px;
    background:
        radial-gradient(120% 90% at 50% -10%, rgba(0, 174, 223, 0.12), transparent 60%),
        #070b10;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 5px;
    overflow: hidden;
}

/* land dots canvas fills the panel */
.dist-map__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* marker coordinate layer — same box as the canvas; markers use % left/top */
.dist-map__markers {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* ---- marker ---- */
.dist-marker {
    position: absolute;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;      /* center on its coordinate */
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.35s ease, transform 0.25s ease;
    z-index: 2;
}
.dist-marker__dot {
    position: absolute;
    inset: 3px;                 /* 8px core */
    border-radius: 50%;
    background: var(--dm-accent);
    box-shadow: 0 0 0 2px rgba(7, 11, 16, 0.9), 0 0 10px 1px rgba(0, 174, 223, 0.9);
}
/* pulsing ring */
.dist-marker__dot::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1px solid var(--dm-accent);
    opacity: 0;
    animation: dm-pulse 2.4s ease-out infinite;
}
@keyframes dm-pulse {
    0%   { transform: scale(0.6); opacity: 0.9; }
    70%  { transform: scale(2.6); opacity: 0; }
    100% { transform: scale(2.6); opacity: 0; }
}
.dist-marker:hover,
.dist-marker.is-active { transform: scale(1.35); z-index: 6; }

/* dimmed when filtered out by region */
.dist-marker.is-dim { opacity: 0.18; pointer-events: none; }
.dist-marker.is-dim .dist-marker__dot::after { animation: none; }

/* ---- tooltip (child of marker) ---- */
.dist-marker__tip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 9px);
    transform: translate(-50%, 4px);
    min-width: max-content;
    max-width: 220px;
    padding: 7px 10px;
    background: #0f172a;
    border: 1px solid rgba(0, 174, 223, 0.35);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease;
    pointer-events: none;
    z-index: 8;
    text-align: left;
}
.dist-marker:hover .dist-marker__tip,
.dist-marker.is-active .dist-marker__tip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}
.dist-marker__tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #0f172a;
}
.dist-marker__tip b {
    display: block;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    white-space: normal;
}
.dist-marker__tip span {
    display: block;
    margin-top: 2px;
    color: var(--dm-accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* ---- panel chrome: legend / count / hint ---- */
.dist-map__legend {
    position: absolute;
    left: 14px;
    bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    z-index: 4;
    pointer-events: none;
}
.dist-map__legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #cbd5e1;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.dist-map__legend i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--dm-accent);
    box-shadow: 0 0 8px rgba(0, 174, 223, 0.9);
}
.dist-map__hint {
    position: absolute;
    right: 14px;
    bottom: 12px;
    z-index: 4;
    color: #64748b;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    pointer-events: none;
}

/* ---- card flash when a marker focuses it ---- */
@keyframes dm-card-flash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 174, 223, 0); }
    25%      { box-shadow: 0 0 0 3px rgba(0, 174, 223, 0.6); }
}
.dist-card.is-flash { animation: dm-card-flash 1.4s ease-out; }

@media (max-width: 640px) {
    .dist-map { aspect-ratio: 4 / 3; }
    .dist-map__hint { display: none; }
}

/* ============================================================================
   HERO MODE — the map is a full-bleed hero backdrop; headline + filter overlay
   the empty lower-left (South Atlantic) region so northern markers stay clear.
============================================================================ */
.dist-hero {
    position: relative;
    overflow: hidden;
    background: #070b10;
    height: min(94vh, 900px);
    min-height: 720px;
}
.dist-map--hero {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    max-height: none;
    border: 0;
    border-radius: 0;
    background: #070b10;
    z-index: 0;
}
.dist-map--hero .dist-map__markers { z-index: 5; }

/* soft dark scrim: strongest bottom-left, clears to the top-right so markers glow */
.dist-hero__scrim {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background:
        linear-gradient(to top, rgba(7, 11, 16, 0.96) 2%, rgba(7, 11, 16, 0.55) 26%, rgba(7, 11, 16, 0) 52%),
        linear-gradient(to right, rgba(7, 11, 16, 0.85) 0%, rgba(7, 11, 16, 0.25) 42%, rgba(7, 11, 16, 0) 70%),
        radial-gradient(120% 80% at 90% 6%, rgba(0, 174, 223, 0.16), transparent 55%);
}
.dist-hero__content {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;             /* let drag-pan pass through to the map... */
}
.dist-hero__content button { pointer-events: auto; }   /* ...but keep filter buttons clickable */
/* text legibility over the (un-scrimmed) map — shadow only on glyphs, map/markers stay bright */
.dist-hero__content h1,
.dist-hero__content p,
.dist-hero__content .data-mono { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 6px 28px rgba(0, 0, 0, 0.45); }
.dist-hero .dist-map__legend,
.dist-hero .dist-map__hint { z-index: 6; }

/* in hero mode the tooltip flips BELOW the marker (top-band markers would clip
   the fixed header if it opened upward) */
.dist-map--hero .dist-marker__tip {
    top: calc(100% + 9px);
    bottom: auto;
}
.dist-map--hero .dist-marker__tip::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #0f172a;
}

/* GEO country map as the full-bleed hero (map on top; hero copy sits in a band below). */
.dist-hero .dist-geo__svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dist-hero .dist-geo__ctrl { top: auto; bottom: 20px; right: 20px; }
.dist-hero .dist-geo__hint { display: none; }   /* redundant with overlaid content + zoom controls */

@media (max-width: 767px) {
    /* mobile: map becomes a full-width strip (whole world; aspect matches the data). */
    .dist-hero { height: auto; min-height: 0; }
    .dist-hero .dist-geo__svg { position: relative; inset: auto; aspect-ratio: 1000 / 372; height: auto; }
    .dist-hero .dist-geo__ctrl { bottom: 12px; right: 12px; }
}

/* ============================================================================
   GEO MAP (#2) — framed vector map: country outlines + hover highlight + zoom/pan.
   Shares the marker/filter state with the hero. Scoped under .dist-geo.
============================================================================ */
.dist-geo {
    position: relative;
    width: 100%;
    aspect-ratio: 1000 / 372;
    min-height: 340px;
    max-height: 620px;
    background:
        radial-gradient(120% 90% at 50% 0%, rgba(0, 174, 223, 0.08), transparent 55%),
        #070b10;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 5px;
    overflow: hidden;
}
.dist-geo__svg {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
}
.dist-geo__svg.is-drag { cursor: grabbing; }

/* country shapes — subtle fill (hoverable area) + thin steel borders */
.dist-geo__country {
    fill: rgba(148, 163, 184, 0.05);
    stroke: rgba(148, 163, 184, 0.24);
    stroke-width: 0.6;
    vector-effect: non-scaling-stroke;
    pointer-events: all;
    transition: fill 0.15s ease, stroke 0.15s ease;
}
.dist-geo__country:hover {
    fill: rgba(0, 174, 223, 0.14);
    stroke: var(--color-primary, #00aedf);
    stroke-width: 1.1;
}

/* SVG markers (counter-scaled to stay screen-constant while zooming) */
.dist-geo-marker { cursor: pointer; }
.dist-geo-marker__dot {
    fill: var(--color-primary, #00aedf);
    filter: drop-shadow(0 0 3px rgba(0, 174, 223, 0.95));
    transition: opacity 0.35s ease;
}
.dist-geo-marker__pulse {
    fill: none;
    stroke: var(--color-primary, #00aedf);
    stroke-width: 1.2;
    transform-box: fill-box;
    transform-origin: center;
    animation: dm-geo-pulse 2.4s ease-out infinite;
}
@keyframes dm-geo-pulse {
    0%   { transform: scale(0.5); opacity: 0.9; }
    70%  { transform: scale(2.6); opacity: 0; }
    100% { transform: scale(2.6); opacity: 0; }
}
.dist-geo-marker.is-dim { opacity: 0.16; pointer-events: none; }
.dist-geo-marker.is-dim .dist-geo-marker__pulse { animation: none; }
.dist-geo-marker.is-active .dist-geo-marker__dot,
.dist-geo-marker:hover .dist-geo-marker__dot { filter: drop-shadow(0 0 6px rgba(0, 174, 223, 1)); }

/* zoom controls */
.dist-geo__ctrl {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dist-geo__ctrl button {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.7);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.15s ease;
}
.dist-geo__ctrl button:hover { color: #fff; border-color: var(--color-primary, #00aedf); background: rgba(0, 174, 223, 0.18); }

.dist-geo__hint {
    position: absolute;
    left: 14px;
    bottom: 12px;
    z-index: 4;
    color: #64748b;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    pointer-events: none;
}

/* HTML tooltip overlaid on the panel */
.dist-geo__tip {
    position: absolute;
    z-index: 6;
    transform: translate(-50%, calc(-100% - 10px));
    min-width: max-content;
    max-width: 220px;
    padding: 7px 10px;
    background: #0f172a;
    border: 1px solid rgba(0, 174, 223, 0.35);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}
.dist-geo__tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #0f172a;
}
.dist-geo__tip b { display: block; color: #fff; font-size: 12px; font-weight: 700; line-height: 1.25; }
.dist-geo__tip span { display: block; margin-top: 2px; color: var(--color-primary, #00aedf); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
