/* ATLAS Network Graph — styles
 * Palette: Cooperation Canada brand guide
 *   dark-blue #05213c · medium-blue #2e5c9e · bright-blue #009cde
 *   green #84cc62 · dark-grey #6a6a6a · light-grey #f7f7f7
 * Typography: Quicksand (loaded by the dashboard template).
 */

.atlas-network-wrapper {
    --atlas-dark-blue:   #05213c;
    --atlas-medium-blue: #2e5c9e;
    --atlas-bright-blue: #009cde;
    --atlas-green:       #84cc62;
    --atlas-dark-grey:   #6a6a6a;
    --atlas-light-grey:  #f7f7f7;

    --atlas-bg:          #ffffff;
    --atlas-fg:          var(--atlas-dark-blue);
    --atlas-muted:       var(--atlas-dark-grey);
    --atlas-border:      #d8e0ea;
    --atlas-accent:      var(--atlas-bright-blue);
    --atlas-soft:        var(--atlas-light-grey);
    --atlas-canvas-bg:   #fbfcfe;
    --atlas-net-height:  700px;

    position: relative;
    font-family: "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--atlas-fg);
    background: var(--atlas-bg);
    border: 1px solid var(--atlas-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(5, 33, 60, 0.06), 0 8px 24px -12px rgba(5, 33, 60, 0.10);
}

/* --- Tabs (top of widget) -------------------------------------------- */
.atlas-network-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--atlas-border);
    padding: 0 12px 0 8px;
}
/* Fullscreen button anchored to the right of the tab row */
.atlas-network-fs-in-tabs {
    margin-left: auto;
}
.atlas-network-tab {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    border-bottom: 3px solid transparent;
    padding: 14px 22px 12px;
    font: inherit;
    font-family: "Quicksand", system-ui, -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--atlas-muted);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    position: relative;
}
.atlas-network-tab:hover {
    color: var(--atlas-medium-blue);
    background: rgba(46, 92, 158, 0.04);
}
.atlas-network-tab.is-active {
    color: var(--atlas-medium-blue);
    border-bottom-color: var(--atlas-bright-blue);
}
.atlas-network-tab.is-active::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -3px;
    width: 0; height: 0;
    /* Tiny pointer triangle below the active tab — subtle anchoring */
    transform: translateX(-50%);
}
@media (max-width: 640px) {
    .atlas-network-tab { padding: 12px 14px 10px; font-size: 12px; letter-spacing: 0.04em; }
}

/* --- KPI strip (top of widget) --------------------------------------- */
.atlas-network-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    background: var(--atlas-dark-blue);
    color: #ffffff;
    border-bottom: 1px solid var(--atlas-dark-blue);
}
.atlas-network-kpi {
    padding: 14px 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.atlas-network-kpi:last-child {
    border-right: none;
}
.atlas-network-kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.62);
    font-weight: 600;
}
.atlas-network-kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.atlas-network-kpi-funding { color: var(--atlas-green); }
.atlas-network-kpi-sector  { color: var(--atlas-bright-blue); font-size: 18px; }
.atlas-network-kpi-wide    { grid-column: span 1; }

@media (max-width: 768px) {
    .atlas-network-kpis { grid-template-columns: repeat(2, 1fr); }
    .atlas-network-kpi { padding: 10px 14px; }
    .atlas-network-kpi-value { font-size: 18px; }
    .atlas-network-kpi-sector { font-size: 15px; }
}

/* --- Top controls bar ------------------------------------------------- */
.atlas-network-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 8px 14px;
    background: linear-gradient(180deg, #ffffff 0%, var(--atlas-soft) 100%);
    border-bottom: 1px solid var(--atlas-border);
    font-size: 12.5px;
}

/* Force [hidden] to override our flex/grid display rules on the controls.
   The UA stylesheet's `[hidden] { display: none }` loses to class selectors
   of equal specificity, so we restate the rule at a higher specificity. */
.atlas-network-control[hidden],
.atlas-network-filter-group[hidden],
.atlas-network-actions[hidden] { display: none !important; }

/* --- Filter group (visual category for related filters) --------------
   Title is an inline pill on the LEFT of the controls (not stacked above).
   Each group is a single row that reflows together when wrapped. */
.atlas-network-filter-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 2px 10px 2px 0;
    border-right: 1px solid var(--atlas-border);
    flex: 0 0 auto;
}
.atlas-network-filter-group:last-of-type {
    border-right: none;
    padding-right: 0;
}
.atlas-network-group-title {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--atlas-medium-blue);
    user-select: none;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(46, 92, 158, 0.08);
    flex-shrink: 0;
    white-space: nowrap;
}
.atlas-network-filter-group-controls {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

/* Constrain select widths so dropdowns don't stretch and break the rhythm */
.atlas-network-control select {
    max-width: 130px;
    min-width: 0;
}
/* Multi-select buttons same width cap as native selects */
.atlas-network-multi-button {
    max-width: 130px;
    min-width: 0;
}

/* The actions block sits on the far right */
.atlas-network-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-left: auto;
    padding-left: 4px;
}

@media (max-width: 900px) {
    .atlas-network-filter-group {
        border-right: none;
        padding-right: 0;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--atlas-border);
        width: 100%;
    }
    .atlas-network-filter-group:last-of-type { border-bottom: none; }
    .atlas-network-actions { margin-left: 0; }
    .atlas-network-control select { max-width: 100%; }
}
.atlas-network-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.atlas-network-control > span {
    color: var(--atlas-muted);
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.atlas-network-control select {
    background: #fff;
    border: 1px solid var(--atlas-border);
    border-radius: 5px;
    padding: 4px 22px 4px 8px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--atlas-fg);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%232e5c9e' d='M5 6L0 0h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.atlas-network-control select:hover,
.atlas-network-control select:focus {
    border-color: var(--atlas-medium-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 92, 158, 0.12);
}
.atlas-network-control input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 96px;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--atlas-medium-blue), var(--atlas-bright-blue)) no-repeat;
    background-color: #e2e8f0;
    cursor: pointer;
    margin: 0;
    padding: 0;
}
.atlas-network-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 2.5px solid var(--atlas-bright-blue);
    box-shadow: 0 1px 3px rgba(5, 33, 60, 0.25);
    cursor: pointer;
    transition: transform 0.1s ease;
}
.atlas-network-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 2.5px solid var(--atlas-bright-blue);
    box-shadow: 0 1px 3px rgba(5, 33, 60, 0.25);
    cursor: pointer;
}
.atlas-network-control input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.15);
}
.atlas-network-control output {
    min-width: 22px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--atlas-medium-blue);
    font-weight: 700;
}

.atlas-network-reset,
.atlas-network-export,
.atlas-network-recenter {
    /* All three buttons share the same flex sizing box so a text button
       (Reset / Export PNG) and an icon-only button (Recenter) end up the
       SAME height. Without inline-flex the icon-button shrank to the
       SVG's intrinsic 14px and looked half a row shorter. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 30px;
    padding: 4px 14px;
    border: 1px solid var(--atlas-border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--atlas-fg);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease,
                border-color 0.18s ease, box-shadow 0.18s ease, transform 0.08s ease;
}
.atlas-network-recenter {
    gap: 6px;
}
/* Icon-only variant — same min-height as the text buttons, square
   horizontal padding so the SVG sits in a 30x30 box instead of a
   wide rectangle. */
.atlas-network-recenter--icon {
    padding: 4px 8px;
    gap: 0;
}
.atlas-network-reset:hover,
.atlas-network-export:hover,
.atlas-network-recenter:hover {
    background: var(--atlas-medium-blue);
    color: #ffffff;
    border-color: var(--atlas-medium-blue);
    box-shadow: 0 2px 6px rgba(46, 92, 158, 0.22);
}
.atlas-network-reset:active,
.atlas-network-export:active,
.atlas-network-recenter:active {
    transform: translateY(1px);
}
.atlas-network-export {
    border-color: var(--atlas-medium-blue);
    color: var(--atlas-medium-blue);
}
.atlas-network-export:hover {
    background: var(--atlas-bright-blue);
    border-color: var(--atlas-bright-blue);
}

/* --- Multi-select dropdown (country tab) ----------------------------- */
.atlas-network-multi {
    position: relative;
}
.atlas-network-multi-wrap {
    position: relative;
}
.atlas-network-multi-button {
    background: #ffffff;
    border: 1px solid var(--atlas-border);
    border-radius: 6px;
    padding: 6px 28px 6px 10px;
    font: inherit;
    font-weight: 500;
    color: var(--atlas-fg);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    /* Size to content (e.g. "2025", "All provinces") instead of a fixed
       180px floor; cap long values like full province names with the
       ellipsis on .atlas-network-multi-button > span:first-child. */
    min-width: 0;
    max-width: 190px;
    text-align: left;
}
/* Locked / informational multi-select (coalition Year = 2025 snapshot):
   visible and openable so the user sees the value, but not changeable. */
.atlas-network-control--locked .atlas-network-multi-button {
    cursor: default;
    background: var(--atlas-soft);
    color: var(--atlas-muted);
}
.atlas-network-control--locked .atlas-network-multi-options input,
.atlas-network-control--locked .atlas-network-multi-all input {
    pointer-events: none;
}
.atlas-network-control--locked .atlas-network-multi-dropdown label {
    cursor: default;
    opacity: 0.75;
}
.atlas-network-multi-button:hover,
.atlas-network-multi-button:focus {
    border-color: var(--atlas-medium-blue);
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 92, 158, 0.12);
}
.atlas-network-multi-button > span:first-child {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.atlas-network-multi-button svg {
    flex-shrink: 0;
    color: var(--atlas-medium-blue);
}
.atlas-network-multi-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 260px;
    max-width: 320px;
    max-height: 320px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--atlas-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px -6px rgba(5, 33, 60, 0.18);
    z-index: 30;
    padding: 8px 4px;
}
.atlas-network-multi-dropdown[hidden] { display: none; }
.atlas-network-multi-dropdown label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--atlas-fg);
    border-radius: 4px;
    user-select: none;
}
.atlas-network-multi-dropdown label:hover { background: var(--atlas-soft); }
.atlas-network-multi-dropdown input[type="checkbox"] {
    margin: 0;
    accent-color: var(--atlas-bright-blue);
    cursor: pointer;
    flex-shrink: 0;
}
.atlas-network-multi-all {
    border-bottom: 1px solid var(--atlas-border);
    margin-bottom: 4px;
    padding-bottom: 8px !important;
    font-weight: 600;
    color: var(--atlas-medium-blue) !important;
}
.atlas-network-multi-options {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* --- View-mode pill toggle (organization tab) ------------------------ */
.atlas-network-view-toggle {
    /* Inherits .atlas-network-control flex; the span label sits left of the pills */
}
.atlas-network-view-pills {
    display: inline-flex;
    background: #ffffff;
    border: 1px solid var(--atlas-border);
    border-radius: 999px;
    padding: 2px;
    gap: 0;
}
.atlas-network-view-pill {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 4px 14px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--atlas-muted);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.atlas-network-view-pill:hover { color: var(--atlas-medium-blue); }
.atlas-network-view-pill.is-active {
    background: var(--atlas-medium-blue);
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(46, 92, 158, 0.25);
}

/* --- Organization-tab "pick an org" prompt ---------------------------
   The prompt is now a NESTED child of .atlas-network-empty (not on the same
   element), so it's a normal flex child sized by its own max-width without
   inheriting the absolute positioning. Parent's flex center properties take
   care of horizontal + vertical centering on the canvas. */
.atlas-network-empty-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: var(--atlas-muted);
    line-height: 1.6;
    padding: 32px;
    max-width: 520px;
    /* Override the .atlas-network-empty italic that would cascade to this
       child via the parent's font-style. (It doesn't actually cascade since
       font-style isn't inherited automatically when overridden by intermediate
       text styling — but stay explicit to be safe.) */
    font-style: normal;
}
.atlas-network-empty-prompt strong {
    display: block;
    color: var(--atlas-medium-blue);
    font-size: 16px;
    margin-bottom: 10px;
    letter-spacing: 0.02em;
    font-style: normal;
}
.atlas-network-empty-prompt p {
    margin: 0;
    color: var(--atlas-muted);
    font-style: normal;
}
.atlas-network-empty-prompt em {
    color: var(--atlas-fg);
    font-style: normal;
    font-weight: 600;
}

/* "Needs pick" attention state on a multi-select control. Used on the
   Organisation tab when no org is yet selected (the canvas is empty and
   the prompt asks the user to pick one) — pulses the focus filter button
   so the visitor sees WHERE to act. Soft brand-blue glow, no layout shift. */
.atlas-network-multi.is-needs-pick > .atlas-network-multi-button {
    border-color: var(--atlas-medium-blue);
    color: var(--atlas-medium-blue);
    box-shadow: 0 0 0 3px rgba(46, 92, 158, 0.18);
    animation: atlas-net-needs-pick-pulse 1.8s ease-in-out infinite;
}
@keyframes atlas-net-needs-pick-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(46, 92, 158, 0.18); }
    50%      { box-shadow: 0 0 0 6px rgba(46, 92, 158, 0.32); }
}
@media (prefers-reduced-motion: reduce) {
    .atlas-network-multi.is-needs-pick > .atlas-network-multi-button { animation: none; }
}

.atlas-network-buttons {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Fullscreen toggle button: icon-only, square */
.atlas-network-fs {
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--atlas-border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--atlas-medium-blue);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease,
                border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
.atlas-network-fs:hover {
    background: var(--atlas-medium-blue);
    color: #ffffff;
    border-color: var(--atlas-medium-blue);
    box-shadow: 0 2px 6px rgba(46, 92, 158, 0.22);
}
.atlas-network-fs:active { transform: translateY(1px); }
.atlas-network-fs .atlas-network-fs-exit { display: none; }
.atlas-network-wrapper.is-fullscreen .atlas-network-fs .atlas-network-fs-enter { display: none; }
.atlas-network-wrapper.is-fullscreen .atlas-network-fs .atlas-network-fs-exit  { display: block; }

/* Meta indicator now lives inside .atlas-network-canvas-wrap as a
   floating overlay in the bottom-right corner (moved from the controls
   bar per UX feedback — the count belongs near the visualization, not
   in the toolbar). */
.atlas-network-meta {
    position: absolute;
    bottom: 12px;
    right: 14px;
    z-index: 9;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--atlas-border);
    border-radius: 999px;
    color: var(--atlas-muted);
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(5, 33, 60, 0.08);
}

/* --- Fullscreen mode -------------------------------------------------- */
/* Two paths supported:
 *   1) Native Fullscreen API (`:fullscreen`) — browser positions us itself.
 *   2) JS-class fallback (`.is-fullscreen`) for browsers that block the API
 *      (Safari iOS) — needs explicit position:fixed + z-index. */
.atlas-network-wrapper.is-fullscreen {
    position: fixed;
    top: 0; left: 0;
    z-index: 99999;
}
.atlas-network-wrapper.is-fullscreen,
.atlas-network-wrapper:fullscreen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}
.atlas-network-wrapper.is-fullscreen .atlas-network-canvas-wrap,
.atlas-network-wrapper:fullscreen .atlas-network-canvas-wrap {
    flex: 1;
    height: auto;
    min-height: 300px;
}
.atlas-network-wrapper.is-fullscreen .atlas-network-drawer,
.atlas-network-wrapper:fullscreen .atlas-network-drawer {
    top: 24px;
    right: 24px;
    /* in fullscreen the drawer is inside the (now huge) canvas-wrap;
       cap it so the drawer doesn't extend below the viewport */
    max-height: calc(100% - 48px);
}

/* --- Canvas ----------------------------------------------------------- */
.atlas-network-canvas-wrap {
    position: relative;
    width: 100%;
    height: var(--atlas-net-height);
    background:
        radial-gradient(ellipse at top, rgba(0, 156, 222, 0.045) 0%, rgba(0, 156, 222, 0) 60%),
        radial-gradient(ellipse at bottom, rgba(132, 204, 98, 0.04) 0%, rgba(132, 204, 98, 0) 60%),
        var(--atlas-canvas-bg);
}
.atlas-network-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.atlas-network-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--atlas-muted);
    font-style: italic;
    text-align: center;
    padding: 24px;
}

/* --- Data-scope disclaimer (per-tab, always visible) -----------------
   Sits BELOW the canvas (right above the legend) so the visualization
   is framed by the data-scope note + legend strip together. Brand-blue
   left border + soft tint = "informational, please read". Baked into
   the PNG export too. */
.atlas-network-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 16px 10px 14px;
    border-top: 1px solid var(--atlas-border);
    border-left: 4px solid var(--atlas-bright-blue);
    background: rgba(0, 156, 222, 0.05);
    color: var(--atlas-dark-blue);
    font-size: 12.5px;
    line-height: 1.5;
}
.atlas-network-disclaimer-icon {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--atlas-medium-blue);
}
.atlas-network-disclaimer-label {
    flex-shrink: 0;
    font-weight: 700;
    color: var(--atlas-medium-blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 10.5px;
    padding-top: 2px;
}
.atlas-network-disclaimer-body {
    flex: 1;
    min-width: 0;
}
.atlas-network-disclaimer-body strong {
    color: var(--atlas-dark-blue);
}
.atlas-network-disclaimer-body [data-disclaimer-type][hidden] { display: none; }
.atlas-network-disclaimer-close {
    flex-shrink: 0;
    margin-left: auto;
    align-self: flex-start;
    background: none;
    border: 0;
    padding: 0 2px;
    cursor: pointer;
    line-height: 1;
    font-size: 18px;
    color: var(--atlas-medium-blue);
    opacity: 0.55;
    transition: opacity 0.15s;
}
.atlas-network-disclaimer-close:hover { opacity: 1; }
.atlas-network-disclaimer.is-dismissed { display: none; }

/* --- Loading skeleton ---------------------------------------------------
   Replicates the .mbe-skeleton pattern defined in metabase-embed.php so the
   network widget's loading state is visually indistinguishable from the
   chart-loading state used everywhere else on the ATLAS dashboard. Defining
   the classes here too means the widget works even on pages where no
   Metabase embed has triggered mbe_enqueue_lazy_loader(). */
.atlas-network-skeleton {
    /* Overlays the entire canvas area. Padding renders as inner gutters
       around the .mbe-skeleton via the nested absolute positioning below
       so the skeleton fully fills the visualization zone (the previous
       flex-row layout left the bottom 60%+ of the area blank in some
       browsers because .mbe-skeleton's intrinsic height was tiny). */
    position: absolute;
    inset: 0;
    display: none;
    z-index: 8;
    pointer-events: none;
    background: var(--atlas-canvas-bg);
}
.atlas-network-wrapper.is-loading .atlas-network-skeleton {
    display: block;
}
.atlas-network-skeleton .mbe-skeleton {
    /* Pinned to the four sides minus a uniform gutter so the shimmer
       canvas IS the whole visualization area, not a centred letterbox. */
    position: absolute;
    inset: 18px;
    height: auto;
    width: auto;
    display: block;
    /* The bars (b1..b4) stack from the top — leave space at the bottom
       by letting the gradient fill the remaining area. */
    padding: 28px 28px 24px;
    box-sizing: border-box;
}

.mbe-skeleton {
    position: relative;
    display: block;
    overflow: hidden;
    background: linear-gradient(180deg, #fafbfc 0%, #f3f5f7 100%);
    border-radius: 6px;
    padding: 28px 24px 22px;
    box-sizing: border-box;
}
.mbe-skeleton::before {
    content: "";
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at 30% 50%, rgba(0, 156, 222, 0.08) 0%, transparent 55%);
    animation: mbe-pulse 2.6s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}
.mbe-skel-bar, .mbe-skel-shimmer { position: relative; z-index: 1; }
.mbe-skel-bar {
    display: block;
    background: #e6ebf0;
    border-radius: 3px;
    margin-top: 14px;
    height: 14px;
    animation: mbe-bar-breathe 2s ease-in-out infinite;
}
.mbe-skel-bar--b1 { animation-delay: 0.0s;  width: 78%; }
.mbe-skel-bar--b2 { animation-delay: 0.15s; width: 60%; }
.mbe-skel-bar--b3 { animation-delay: 0.30s; width: 42%; }
.mbe-skel-bar--b4 { animation-delay: 0.45s; width: 24%; }
.mbe-skel-bar--axis {
    width: 90%; height: 1px; margin-top: 0;
    background: #d9dde2; animation: none;
}
.mbe-skel-shimmer {
    position: absolute; inset: 0;
    background: linear-gradient(115deg,
        rgba(255, 255, 255, 0)  0%,
        rgba(255, 255, 255, 0.65) 50%,
        rgba(255, 255, 255, 0) 100%);
    animation: mbe-shimmer 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    pointer-events: none;
    z-index: 2;
}
@keyframes mbe-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%);  }
}
@keyframes mbe-pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}
@keyframes mbe-bar-breathe {
    0%, 100% { opacity: 0.85; transform: scaleX(1); }
    50%      { opacity: 1;    transform: scaleX(1.02); }
}
@keyframes mbe-spin { to { transform: rotate(360deg); } }

/* --- Legend ----------------------------------------------------------- */
.atlas-network-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    padding: 12px 20px;
    border-top: 1px solid var(--atlas-border);
    background: #ffffff;
    font-size: 13px;
    color: var(--atlas-muted);
}
.atlas-network-legend strong {
    color: var(--atlas-fg);
    font-weight: 700;
    letter-spacing: 0.01em;
}
.atlas-network-types {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-left: 8px;
}
.atlas-network-legend-type {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 10px;
    border-radius: 999px;
    background: var(--atlas-soft);
    color: var(--atlas-fg);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.atlas-network-legend-type:hover {
    background: #ffffff;
    border-color: var(--atlas-border);
}
/* Click-to-filter chips — hint affordance + active highlight state.
   Active chip uses its own color (--c) as a tinted bg + colored border. */
.atlas-network-legend-type--clickable {
    cursor: pointer;
    user-select: none;
}
.atlas-network-legend-type--clickable:focus-visible {
    outline: 2px solid var(--atlas-bright-blue);
    outline-offset: 2px;
}
.atlas-network-legend-type--clickable.is-active {
    background: var(--c, var(--atlas-medium-blue));
    border-color: var(--c, var(--atlas-medium-blue));
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(5, 33, 60, 0.18);
}
.atlas-network-legend-type--clickable.is-active::before {
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px #ffffff;
    background: #ffffff;
}
.atlas-network-legend-type--clickable.is-active.atlas-network-legend-edge::before {
    background: #ffffff;
}
.atlas-network-legend-type::before {
    content: "";
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--c, var(--atlas-muted));
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px var(--c, var(--atlas-muted));
    flex-shrink: 0;
}
/* Bipartite secondary-kind chip shows the distinguishing shape */
.atlas-network-legend-kind[data-kind="coalition"]::before {
    width: 11px; height: 11px; border-radius: 2px;
    transform: rotate(45deg);
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px var(--c, var(--atlas-muted));
}
.atlas-network-legend-kind[data-kind="sector"]::before {
    border-radius: 3px;
    box-shadow: 0 0 0 2px #ffffff, 0 0 0 3px var(--c, var(--atlas-muted));
}
.atlas-network-legend-kind[data-kind="country"]::before {
    /* Approximated hexagon via clip-path; ::before is a square so clip works */
    border-radius: 2px;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    box-shadow: none;
}

.atlas-network-legend-explain {
    color: var(--atlas-muted);
    font-style: italic;
}

/* Edge-color swatches (consortium tab: edges colored by dominant sector).
   Renders a short colored bar instead of a dot so users immediately read
   the swatch as "this is the line color" rather than "this is a node". */
.atlas-network-legend-edge::before {
    width: 18px;
    height: 3px;
    border-radius: 2px;
    box-shadow: none;
    background: var(--c, var(--atlas-muted));
}
.atlas-network-legend-sep {
    color: var(--atlas-border);
    font-weight: 700;
    margin: 0 -4px;
    user-select: none;
}

/* --- Caveat (methodology note, collapsible) -------------------------- */
.atlas-network-caveat {
    /* Collapsed = a thin, transparent row (just the toggle) so it doesn't
       eat vertical space below the legend. The soft background + roomier
       padding only kick in once it's [open]. */
    padding: 5px 20px;
    border-top: 1px solid var(--atlas-border);
    background: transparent;
    font-size: 13px;
    color: var(--atlas-muted);
    line-height: 1.6;
}
.atlas-network-caveat[open] {
    padding: 4px 20px 12px;
    background: var(--atlas-soft);
}
.atlas-network-caveat summary {
    cursor: pointer;
    color: var(--atlas-medium-blue);
    font-weight: 600;
    list-style: none;
    padding: 0;
    font-size: 12px;
    user-select: none;
}
.atlas-network-caveat summary::-webkit-details-marker { display: none; }
.atlas-network-caveat summary::before {
    content: "▸";
    display: inline-block;
    margin-right: 8px;
    transition: transform 0.2s ease;
    color: var(--atlas-medium-blue);
    font-size: 11px;
}
.atlas-network-caveat[open] summary::before {
    transform: rotate(90deg);
}
.atlas-network-caveat p {
    margin: 10px 0 4px;
    /* Use the full caveat width up to a comfortable reading bound. 80ch
       capped at roughly half the screen on wide desktop layouts, which
       looked broken next to the full-bleed network canvas above. 130ch
       still keeps line length within reading-research comfort (45-130 char
       window) on monitors up to ~1600px wide, while filling the visible
       caveat row at common dashboard widths. */
    max-width: 130ch;
}
.atlas-network-caveat strong {
    color: var(--atlas-fg);
    font-weight: 700;
}

/* --- Drawer (node / edge details) ------------------------------------
   Positioned relative to .atlas-network-canvas-wrap (the drawer is a
   direct child of the canvas), so the offsets are measured from the
   canvas top-right rather than from the wrapper top-right (which would
   land the drawer behind the KPI strip). */
.atlas-network-drawer {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 380px;
    max-width: calc(100% - 32px);
    max-height: calc(100% - 32px);
    background: #ffffff;
    border: 1px solid var(--atlas-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(5, 33, 60, 0.18), 0 4px 12px rgba(5, 33, 60, 0.08);
    overflow-y: auto;
    padding: 18px 20px 14px;
    z-index: 10;
    animation: atlas-net-drawer-in 0.18s ease-out;
    /* Neutralise the dashboard's `.mbe-main { text-align: justify; hyphens:
       auto }` which otherwise cascades into this embedded widget. */
    text-align: left;
    hyphens: manual;
}
@keyframes atlas-net-drawer-in {
    from { opacity: 0; transform: translateX(8px); }
    to   { opacity: 1; transform: translateX(0); }
}
.atlas-network-drawer[hidden] { display: none; }
.atlas-network-drawer-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    color: var(--atlas-muted);
    padding: 0;
    border-radius: 6px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.atlas-network-drawer-close:hover {
    color: var(--atlas-dark-blue);
    background: var(--atlas-soft);
}
.atlas-network-drawer h3 {
    margin: 0 0 14px;
    font-size: 16px;
    color: var(--atlas-medium-blue);
    font-weight: 700;
    padding-right: 28px;
    line-height: 1.3;
    word-break: break-word;
    border-bottom: 2px solid var(--atlas-bright-blue);
    padding-bottom: 10px;
}
.atlas-network-drawer-subhead {
    margin: 14px 0 8px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--atlas-medium-blue);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: rgba(46, 92, 158, 0.08);
    border-radius: 4px;
}
.atlas-network-drawer dl {
    display: grid;
    /* Each row is its own <dl>, so an auto-sized (max-content) label column
       resolves to a DIFFERENT width per row — the longest FR label
       ("Financement consortium", "Organisations visibles") pushed its value
       further right than the others, breaking vertical alignment of the value
       column. A FIXED label width (sized to fit the longest label across both
       languages at the 12px dt size) makes every value start at the same x. */
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 4px 14px;
    margin: 0 0 4px;
    align-items: baseline;
}
.atlas-network-drawer dt {
    font-size: 12px;
    color: var(--atlas-muted);
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
}
.atlas-network-drawer dd {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--atlas-fg);
    font-variant-numeric: tabular-nums;
    word-break: break-word;
    line-height: 1.4;
}
.atlas-network-website-link {
    color: var(--atlas-medium-blue);
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    font-weight: 600;
}
.atlas-network-website-link:hover {
    color: var(--atlas-bright-blue);
}
/* The drawer renders inside the dashboard's .mbe-main, whose `.mbe-main p`
   rule (font-size:18px; text-align:justify; line-height:1.78; specificity
   0,1,1) outranks a bare `.atlas-network-drawer-fullview` (0,1,0) and hijacks
   the note — oversized, justified (huge inter-word gaps) and hyphenated
   ("orga-nisation"). Qualifying with the ancestor class raises specificity to
   (0,2,0) so these win, and we explicitly reset text-align / hyphens. */
.atlas-network-drawer .atlas-network-drawer-fullview {
    margin: 8px 0 4px;
    padding: 8px 10px;
    border-left: 3px solid var(--atlas-bright-blue);
    background: rgba(0, 156, 222, 0.05);
    font-size: 11.5px;
    font-weight: 400;
    font-style: italic;
    color: var(--atlas-muted);
    line-height: 1.45;
    text-align: left;
    hyphens: manual;
}
.atlas-network-drawer .atlas-network-drawer-hint {
    margin: 14px 0 0;
    padding: 8px 10px;
    border-top: 1px dashed var(--atlas-border);
    font-size: 11.5px;
    font-weight: 400;
    font-style: italic;
    color: var(--atlas-muted);
    line-height: 1.45;
    text-align: left;
    hyphens: manual;
}

/* --- Mobile ----------------------------------------------------------- */
@media (max-width: 768px) {
    .atlas-network-controls {
        gap: 8px 12px;
        padding: 10px 12px;
    }
    .atlas-network-meta {
        margin-left: 0;
        flex-basis: 100%;
        text-align: left;
    }
    .atlas-network-control input[type="range"] { width: 100px; }
    .atlas-network-drawer {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: auto;
        max-height: 50vh;
        border-radius: 8px 8px 0 0;
    }
}

/* --- High contrast / reduced motion --------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .atlas-network-caveat summary::before { transition: none; }
}
