/* ============================================
   ward-explorer.css - embeddable ward explorer
   Scoped under .wx. Consumes --pc-* tokens only
   (css/pc-tokens.css) and the shared components in
   css/pc-components.css. Party colour arrives through
   the --party-color slot set from JS (pcPartyColor).
   ============================================ */

.wx {
    font-family: var(--pc-sans);
    color: var(--pc-text-body);
    position: relative;
    min-width: 0;
}
.wx [hidden] { display: none !important; }
.wx button { font-family: inherit; }

/* == Tabs == */
.wx-tabs { margin-bottom: 14px; }
.wx.is-mobile .wx-tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.wx.is-mobile .wx-tabs .pc-tab { padding: 12px 8px 10px; font-size: 10.5px; letter-spacing: 0.04em; flex: 0 0 auto; }

/* == Two-column grid (controls | map) == */
.wx-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
.wx.is-mobile .wx-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}

/* == Controls column == */
.wx-controls {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    min-width: 0;
}
.wx-controls-toggle {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: left;
    color: var(--pc-text);
}
.wx-controls-toggle:hover { background: var(--pc-hover-bg); }
.wx-controls-toggle-title {
    font-family: var(--pc-serif);
    font-weight: 700;
    font-size: 15px;
}
.wx-controls-toggle-meta {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pc-text-meta);
}
.wx-controls-body { padding: 12px 14px 14px; }
.wx.is-mobile .wx-controls-toggle { display: flex; }
.wx.is-mobile .wx-controls-body {
    display: none;
    border-top: 1px solid var(--pc-border-grid);
}
.wx.is-mobile .wx-controls.is-open .wx-controls-body { display: block; }

/* Control groups */
.wx-group { margin-bottom: 14px; }
.wx-group:last-child { margin-bottom: 0; }
.wx-group-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}
.wx-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pc-text-meta);
}
.wx-reset-link {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-size: 11px;
    color: var(--pc-text-meta);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.wx-reset-link:hover { color: var(--pc-text); }
.wx-hint {
    font-size: 11px;
    line-height: 1.5;
    color: var(--pc-text-meta);
    margin-top: 6px;
}
.wx-hint strong { color: var(--pc-text-secondary); font-weight: 600; }

/* Slider rows (pc-slider-row) with tap-to-edit value */
.wx-srow .pc-slider-name { font-size: 13px; line-height: 1.15; }
.wx-srow .pc-slider-ref { font-size: 9px; letter-spacing: 0.04em; white-space: nowrap; }
.wx-srow .pc-slider-value { cursor: text; }
.wx-slider-input {
    display: none;
    width: 62px;
    font-family: var(--pc-sans);
    font-size: 14px;
    font-weight: 700;
    color: var(--pc-text);
    background: var(--pc-surface);
    border: 1px solid var(--pc-text);
    padding: 2px 4px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}
.wx-slider-input::-webkit-outer-spin-button,
.wx-slider-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wx-srow.is-editing .pc-slider-value { display: none; }
.wx-srow.is-editing .wx-slider-input { display: inline-block; }
.wx-srow .pc-slider-value-block { min-width: 68px; }
.wx-srow--compact { padding: 6px 0; }
.wx-srow--compact .pc-slider-name {
    font-family: var(--pc-sans);
    font-size: 12px;
    font-weight: 600;
}
.wx-srow--compact .pc-slider-value { font-size: 14px; }
.wx-scale {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--pc-text-muted);
    margin-top: 3px;
}

/* Tactical disclosure inside controls */
.wx-controls .pc-disclosure { margin-top: 10px; }
.wx-controls .pc-disclosure-body { padding: 4px 0 6px; }

.wx-reset-all { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.wx-reset-all .pc-btn { flex: 1 1 150px; min-width: 0; padding-left: 8px; padding-right: 8px; text-align: center; }
.wx-shared-note {
    font-size: 11px;
    line-height: 1.5;
    color: var(--pc-text-body);
    background: var(--pc-tint);
    border-left: 3px solid var(--pc-warning);
    padding: 6px 10px;
    margin-bottom: 12px;
}
.wx-shared-note .wx-reset-link { color: var(--pc-text-body); margin-left: 4px; }

/* Lock (hold share) button in the slider meta row */
.wx-lock {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid var(--pc-border);
    color: var(--pc-text-muted);
    cursor: pointer;
    transition: color 120ms, border-color 120ms, background 120ms;
}
.wx-lock:hover { color: var(--pc-text); border-color: var(--pc-text-muted); }
.wx-lock.is-locked { background: var(--pc-text); border-color: var(--pc-text); color: var(--pc-on-ink); }
.wx-srow.is-locked .pc-slider { opacity: 0.45; }
.wx-srow.is-locked .pc-slider-value::after { content: ' held'; font-size: 10px; font-weight: 600; color: var(--pc-text-meta); }

/* Layer picker (atlas tabs) */
.wx-layers { display: flex; flex-direction: column; gap: 4px; }
.wx-layer-btn {
    --party-color: var(--pc-text-meta);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--pc-text-body);
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    padding: 7px 10px;
    cursor: pointer;
    transition: border-color 120ms, background 120ms, color 120ms;
}
.wx-layer-btn:hover { border-color: var(--pc-text-muted); background: var(--pc-hover-bg); }
.wx-layer-btn.is-active {
    background: var(--pc-text);
    color: var(--pc-on-ink);
    border-color: var(--pc-text);
}
.wx-layer-btn .pc-swatch { background: var(--party-color); }
.wx-layer-btn.is-active .pc-swatch { outline: 1px solid var(--pc-on-ink); }
.wx-layer-sub {
    margin-left: auto;
    font-size: 10px;
    font-weight: 500;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
}
.wx-layer-btn.is-active .wx-layer-sub { color: var(--pc-on-ink); opacity: 0.75; }
.wx-layers-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pc-text-meta);
    margin: 10px 0 6px;
}
.wx-layers-title:first-child { margin-top: 0; }

/* == Map column == */
.wx-map-col { min-width: 0; }
.wx-map-panel {
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    min-width: 0;
}
.wx-map-toolbar {
    display: flex;
    align-items: center;
    gap: 8px 12px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-bottom: 1px solid var(--pc-border-light);
}
.wx-map-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--pc-text-secondary);
}
.wx-map-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.wx-fs-btn {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    color: var(--pc-text-secondary);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 5px 8px;
    transition: color 120ms, border-color 120ms;
}
.wx-fs-btn:hover { color: var(--pc-text); border-color: var(--pc-text); }

/* Result strip (scenario tab): constituency vote share bars */
.wx-result {
    padding: 10px 12px 6px;
    border-bottom: 1px solid var(--pc-border-light);
}
.wx-result-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--pc-text-meta);
    margin-bottom: 8px;
}
.wx-result .pc-bar-row { margin-bottom: 5px; }
.wx-result .pc-bar-name { width: 34px; font-weight: 700; color: var(--pc-text); }
.wx-result .pc-bar-track { height: 14px; }
.wx-result .pc-bar-val { width: auto; min-width: 46px; flex: 0 0 auto; font-weight: 700; color: var(--pc-text); font-size: 12px; }
.wx-result .pc-bar-chg { width: 40px; flex: 0 0 40px; font-size: 11px; }
.wx-ghost {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-right: 2px dashed var(--pc-text);
    opacity: 0.35;
    pointer-events: none;
}
.wx-ballots {
    font-size: 11px;
    line-height: 1.5;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
    margin-top: 4px;
}
.wx-ballots strong { color: var(--pc-text-body); font-weight: 600; }

/* Map area */
.wx-map-area {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: var(--pc-surface);
}
.wx-map-svg { display: block; width: 100%; }
.wx-map-svg text { pointer-events: none; }
.wx-ward, .wx-lsoa {
    stroke: var(--pc-surface);
    cursor: pointer;
    transition: opacity 120ms;
}
.wx-ward { stroke-width: 1.5px; }
.wx-lsoa { stroke-width: 0.5px; }
.wx-ward.is-hover, .wx-ward.is-selected { stroke: var(--pc-text); stroke-width: 2.5px; }
.wx-lsoa.is-hover, .wx-lsoa.is-selected { stroke: var(--pc-text); stroke-width: 1.5px; }
.wx-map-svg.has-selection .wx-ward:not(.is-selected):not(.is-hover),
.wx-map-svg.has-selection .wx-lsoa:not(.is-selected):not(.is-hover) { opacity: 0.72; }
.wx-ward-outline {
    fill: none;
    stroke: var(--pc-text-secondary);
    stroke-width: 1.5px;
    stroke-dasharray: 4 2;
    pointer-events: none;
}
.wx-map-label {
    font-family: var(--pc-sans);
    font-size: 9px;
    font-weight: 600;
    fill: var(--pc-text);
    paint-order: stroke;
    stroke: var(--pc-surface);
    stroke-width: 2.5px;
    stroke-linejoin: round;
    text-anchor: middle;
}
.wx-map-empty {
    padding: 40px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--pc-text-meta);
}

/* Tooltip (pc-tooltip, absolute inside the map area) */
.wx-tooltip { display: none; }
.wx-tooltip.is-visible { display: block; }
.wx-tooltip-sub { font-size: 11px; color: var(--pc-text-meta); margin-bottom: 3px; }

/* Legend strip under the map */
.wx-map-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-top: 1px solid var(--pc-border-light);
}
.wx-map-foot .pc-legend { font-size: 11px; }
.wx-map-source {
    font-size: 10px;
    color: var(--pc-text-meta);
    line-height: 1.4;
    max-width: 420px;
}
.wx-gradient { display: flex; flex-direction: column; gap: 2px; }
.wx-gradient-title { font-size: 11px; font-weight: 600; color: var(--pc-text-secondary); }
.wx-gradient-bar { width: 140px; height: 10px; border: 1px solid var(--pc-border); }
.wx-gradient-labels {
    display: flex;
    justify-content: space-between;
    width: 140px;
    font-size: 10px;
    color: var(--pc-text-meta);
    font-variant-numeric: tabular-nums;
}

/* Info panel (ward / LSOA figures) */
.wx-info {
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    min-width: 0;
}
.wx-info-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--pc-border-light);
}
.wx-info-name {
    font-family: var(--pc-serif);
    font-weight: 700;
    font-size: 15px;
    color: var(--pc-text);
    line-height: 1.2;
}
.wx-info-sub { font-size: 11px; color: var(--pc-text-meta); margin-top: 2px; }
.wx-info-close {
    background: none;
    border: 0;
    cursor: pointer;
    font-size: 11px;
    color: var(--pc-text-meta);
    text-decoration: underline;
    text-underline-offset: 2px;
    padding: 0;
    flex: 0 0 auto;
}
.wx-info-close:hover { color: var(--pc-text); }
.wx-info-body { padding: 10px 12px 12px; font-size: 12px; }
.wx-info-body .pc-bar-row { margin-bottom: 4px; }
.wx-info-body .pc-bar-name { width: 34px; font-weight: 700; color: var(--pc-text); }
.wx-info-body .pc-bar-track { height: 10px; }
.wx-info-body .pc-bar-track { min-width: 40px; }
.wx-info-body .pc-bar-val { width: auto; min-width: 46px; flex: 0 0 auto; font-size: 11px; color: var(--pc-text-secondary); white-space: nowrap; }
.wx-info-body .pc-bar-chg { width: 34px; flex: 0 0 34px; font-size: 10px; }
.wx-info-meta { font-size: 11px; color: var(--pc-text-meta); margin-top: 8px; line-height: 1.5; }
.wx-info-caption {
    font-size: 11px;
    font-weight: 600;
    color: var(--pc-text-meta);
    margin-bottom: 6px;
}
.wx-demo-section { margin-bottom: 8px; }
.wx-demo-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pc-text-meta);
    margin-bottom: 2px;
}
.wx-demo-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid var(--pc-border-grid);
    font-size: 12px;
}
.wx-demo-row span:last-child { font-weight: 600; color: var(--pc-text); font-variant-numeric: tabular-nums; }

/* Info panel placement: overlay in the map area (atlas tabs, fullscreen)
   or a card below the map (scenario tab, mobile) */
.wx-info-slot-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 280px;
    max-width: calc(100% - 16px);
    max-height: calc(100% - 16px);
    overflow-y: auto;
    z-index: 5;
}
.wx-info-slot-overlay:empty { display: none; }
.wx-info-slot-below { margin-top: 12px; }
.wx-info-slot-below:empty { display: none; }
.wx.is-mobile .wx-map-panel.is-fullscreen .wx-info-slot-overlay {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    max-height: 55%;
}

/* Ward cards below the map (scenario tab) */
.wx-below { margin-top: 12px; }
.wx-cards-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin: 14px 0 6px;
}
.wx-cards-title {
    font-family: var(--pc-serif);
    font-weight: 700;
    font-size: 15px;
    color: var(--pc-text);
}
.wx-cards-cap { font-size: 11px; color: var(--pc-text-meta); }
.wx-note {
    font-size: 11px;
    line-height: 1.5;
    color: var(--pc-text-secondary);
    background: var(--pc-tint);
    border-left: 3px solid var(--pc-border);
    padding: 8px 12px;
    margin: 0 0 10px;
}
.wx-note strong { color: var(--pc-text); font-weight: 600; }
.wx-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.wx.is-mobile .wx-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wx.is-narrow .wx-cards { grid-template-columns: minmax(0, 1fr); }
.wx-card {
    border: 1px solid var(--pc-border);
    background: var(--pc-surface);
    padding: 8px 10px;
    cursor: pointer;
    min-width: 0;
    transition: border-color 120ms, background 120ms;
}
.wx-card:hover { border-color: var(--pc-text-muted); background: var(--pc-hover-bg); }
.wx-card.is-selected { border-color: var(--pc-text); }
.wx-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}
.wx-card-name {
    font-size: 12px;
    font-weight: 700;
    color: var(--pc-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wx-card-win {
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    color: var(--pc-text);
    font-variant-numeric: tabular-nums;
}
.wx-card-win .pc-swatch { margin-right: 4px; }
.wx-card-meta {
    font-size: 10px;
    color: var(--pc-text-meta);
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}
.wx-card .pc-bar-row { margin-bottom: 2px; gap: 6px; }
.wx-card .pc-bar-name { width: 24px; font-size: 10px; font-weight: 700; color: var(--pc-text-secondary); }
.wx-card .pc-bar-track { height: 7px; }
.wx-card .pc-bar-val { width: 38px; font-size: 10px; color: var(--pc-text-meta); }

/* == Fullscreen map panel (class-based, as the swingometer) == */
.wx-map-panel.is-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* Stop above the Raptive sticky-footer reservation (50px phone,
       90px desktop) so the footer ad stays visible. */
    bottom: 50px;
    z-index: 9000;
    border: 0;
    padding-top: env(safe-area-inset-top);
}
.wx:not(.is-mobile) .wx-map-panel.is-fullscreen { bottom: 90px; }
.wx-map-panel.is-fullscreen .wx-map-area { flex: 1 1 auto; height: 0; }
.wx-map-panel.is-fullscreen .wx-map-svg { height: 100%; }
.wx-map-panel.is-fullscreen .wx-result { display: none; }

/* == Undo toast (pc-toast, lifted above the sticky footer) == */
.wx-toast { bottom: 104px; }

/* == Method notes == */
.wx-method { margin-top: 20px; }
.wx-method .pc-disclosure-body { max-width: 760px; font-size: 13px; }
.wx-method p { margin: 0 0 10px; }
.wx-method strong { color: var(--pc-text); font-weight: 600; }
.wx-method a { color: var(--pc-text-body); text-decoration: underline; text-underline-offset: 2px; }

/* == Static map (read-only choropleth, unframed) == */
.wx-static .wx-map-panel { border: 0; background: transparent; }
.wx-static .wx-map-area { background: transparent; cursor: default; overflow: visible; }
.wx-static .wx-ward { cursor: default; }
.wx-static .wx-map-foot { padding: 6px 0 0; border-top: 0; flex-direction: column; align-items: flex-start; gap: 4px; }
.wx-static .wx-map-source { max-width: none; }
.wx-static .wx-gradient-bar, .wx-static .wx-gradient-labels { width: 180px; }

/* == Touch targets == */
.wx.is-mobile .wx-layer-btn,
.wx.is-mobile .wx-fs-btn,
.wx.is-mobile .wx-info-close { min-height: 44px; }
.wx.is-mobile .wx-reset-link { min-height: 32px; }
.wx.is-mobile .wx-lock { width: 32px; height: 32px; }

/* Touch targets are shrunk by the site-wide html { zoom: 0.8 } in style.css:
   a 32px rule renders as 26 physical px. Sizes below are pre-divided by 0.8
   so they land at the intended physical size on a phone. */
.wx.is-mobile .wx-lock { width: 40px; height: 40px; }
.wx.is-mobile .wx-layer-btn,
.wx.is-mobile .wx-fs-btn,
.wx.is-mobile .wx-info-close { min-height: 55px; }
.wx.is-mobile .wx-reset-link { min-height: 40px; display: inline-flex; align-items: center; }
.wx.is-mobile .wx-view-toggle button { min-height: 40px; padding-left: 12px; padding-right: 12px; }
/* Expand the slider's draggable band without changing how the track looks:
   the horizontal gradient is painted as a 6px stripe centred in a taller box. */
.wx.is-mobile .pc-slider {
    height: 36px;
    background-size: 100% 6px;
    background-position: left center;
    background-repeat: no-repeat;
}
.wx.is-mobile .wx-fs-btn { min-width: 55px; }
