/* ============================================================
   DORIA – territories.css
   Shared styles for the TerritoriesOverlay component (Fire/Forest
   Monitor). Scoped prefix: terr-*. Loaded globally so the map
   tooltip labels (which attach to the Leaflet pane) are styled
   regardless of the active page.
   ============================================================ */

/* ── Control rows (rendered into a page panel section) ─────── */
.terr-controls { display: flex; flex-direction: column; gap: 6px; }

.terr-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid rgba(var(--ink), 0.08);
    border-radius: 0;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
@media (hover: hover) and (pointer: fine) {
    .terr-row:hover {
        border-color: rgba(var(--brand-rgb), 0.4);
        background: rgba(var(--ink), 0.02);
    }
}
.terr-row:active {
    border-color: rgba(var(--brand-rgb), 0.4);
    background: rgba(var(--ink), 0.02);
}
.terr-row:focus-within { border-color: rgba(var(--brand-rgb), 0.6); }
.terr-cb { accent-color: var(--clr-accent, var(--brand-ink)); cursor: pointer; }
.terr-swatch {
    width: 14px;
    height: 14px;
    border-radius: 0;
    flex-shrink: 0;
    opacity: 0.85;
    border: 1px solid rgba(var(--ink), 0.25);
}
.terr-name { flex: 1; font-size: 0.78125rem; color: var(--clr-text, rgb(var(--ink))); }
.terr-clear {
    background: transparent;
    border: 1px solid rgba(var(--ink), 0.2);
    color: rgba(var(--ink), 0.55);
    font-size: 0.875rem;
    line-height: 1;
    min-width: 32px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 0;
    flex-shrink: 0;
    transition: color 0.15s, border-color 0.15s;
}
@media (hover: hover) and (pointer: fine) {
    .terr-clear:hover {
        color: #ff6b6b;
        border-color: #ff6b6b;
    }
}
.terr-clear:active {
    color: #ff6b6b;
    border-color: #ff6b6b;
}
.terr-clear:focus-visible { outline: 2px solid #ff6b6b; outline-offset: 2px; }
.terr-spin {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.6875rem;
    color: var(--clr-accent, var(--brand-ink));
    animation: terr-pulse 1s ease-in-out infinite;
}
@keyframes terr-pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

/* ── Map labels (Leaflet tooltips) ─────────────────────────── */
/* Map chrome tokens (--map-ink, --map-panel), not --ink: the chip sits on
   the map, so it follows the basemap rather than the page theme. Over
   satellite imagery it stays light-on-dark in both themes (--ink turns
   black in light mode, and black text on this dark chip was unreadable);
   on a light schematic basemap the chip and its text flip together. */
.terr-label.leaflet-tooltip {
    background: rgba(var(--map-panel), 0.82);
    border: 1px solid rgba(var(--map-ink), 0.14);
    color: rgba(var(--map-ink), 0.92);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 0.625rem;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
}
.terr-label.leaflet-tooltip::before { display: none; }   /* drop the pointer arrow */
/* Hidden by the overlay's label declutter (territoriesOverlay.js): it
   would have overlapped a label already shown. Hover the marker to see it.
   visibility, because Leaflet writes the tooltip's opacity inline. */
.terr-label.leaflet-tooltip.terr-label--hidden { visibility: hidden !important; }

/* Point marker: the resting reticle triangle (pointIcon). The div is
   only a hit box; Leaflet's default white div-icon box is replaced. */
.terr-point {
    background: none;
    border: none;
    cursor: pointer;
}
.terr-point svg { display: block; overflow: visible; }
.terr-point:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 2px; }

/* ── Click card (Leaflet popup, territoriesOverlay.js bindCard) ──
   Same chip as the label so the name reads as one object growing a few
   details. Two-class selectors with !important: map.css, fireMonitoring.css
   and siteAnalysis.css restyle every .leaflet-popup-* with !important. */
.leaflet-popup.terr-popup { margin-bottom: 0; }
.leaflet-popup.terr-popup .leaflet-popup-content-wrapper {
    background: rgba(var(--map-panel), 0.94) !important;
    border: 1px solid rgba(var(--map-ink), 0.16) !important;
    border-radius: 0 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
    padding: 0 !important;
    min-width: 0 !important;
    animation: none !important;
}
.leaflet-popup.terr-popup .leaflet-popup-content {
    margin: 0 !important;
    min-width: 0 !important;
    width: auto !important;
    line-height: 1.4 !important;
    color: rgba(var(--map-ink), 0.92) !important;
    font-family: var(--font-mono, 'JetBrains Mono', monospace) !important;
}
.leaflet-popup.terr-popup .leaflet-popup-tip-container { display: none !important; }
.leaflet-popup.terr-popup .leaflet-popup-close-button {
    top: 4px !important;
    right: 4px !important;
    width: 1.5rem !important;
    height: 1.5rem !important;
    padding: 0 !important;
    font: 400 0.875rem/1.5rem var(--font-mono, 'JetBrains Mono', monospace) !important;
    text-align: center !important;
    color: rgba(var(--map-ink), 0.5) !important;
    background: none !important;
}
@media (hover: hover) and (pointer: fine) {
    .leaflet-popup.terr-popup .leaflet-popup-close-button:hover { color: rgb(var(--map-ink)) !important; }
}
@media (pointer: coarse) {
    .leaflet-popup.terr-popup .leaflet-popup-close-button { width: 2.75rem !important; height: 2.75rem !important; line-height: 2.75rem !important; top: -6px !important; right: -6px !important; }
}

.terr-card {
    padding: 8px 32px 9px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    white-space: nowrap;
}
.terr-card__kind {
    font-size: 0.6875rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(var(--map-ink), 0.5);
}
.terr-card__name {
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: rgb(var(--map-ink));
    margin-bottom: 2px;
}
.terr-card__row {
    display: flex;
    gap: 10px;
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    color: rgba(var(--map-ink), 0.75);
}
.terr-card__row > span:first-child {
    min-width: 48px;
    color: rgba(var(--map-ink), 0.45);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
