/* ============================================================
   County Drill-Down (str-counties.js) — trading-terminal, dark.
   Everything is prefixed .smc- and lives inside the map stage or
   the state panel slot; tokens come from .sm (str-map.css).
   ============================================================ */

/* ---- Entry button in the state panel ----------------------- */
.smc-entry { margin-top: 14px; }
.smc-explore {
    position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 13px 14px; text-align: left; cursor: pointer; overflow: hidden;
    color: var(--sm-text, #E7ECF5); font: inherit;
    background:
        linear-gradient(135deg, rgba(251, 191, 36, .13), rgba(251, 191, 36, 0) 55%),
        var(--sm-raise, #1B2740);
    border: 1px solid rgba(251, 191, 36, .45); border-radius: 12px;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.smc-explore::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
    background-image:
        linear-gradient(rgba(251, 191, 36, .07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(251, 191, 36, .07) 1px, transparent 1px);
    background-size: 18px 18px;
    -webkit-mask-image: linear-gradient(90deg, transparent 35%, #000);
    mask-image: linear-gradient(90deg, transparent 35%, #000);
}
.smc-explore:hover { border-color: #FBBF24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .12), 0 10px 26px rgba(0, 0, 0, .35); transform: translateY(-1px); }
.smc-explore:focus-visible { outline: 2px solid #FBBF24; outline-offset: 2px; }
.smc-explore-ic {
    flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
    color: #FBBF24; background: rgba(251, 191, 36, .12); border: 1px solid rgba(251, 191, 36, .35);
}
.smc-explore-t { position: relative; z-index: 1; min-width: 0; display: grid; gap: 2px; }
.smc-explore-h { font-weight: 800; font-size: .95rem; letter-spacing: -.01em; color: #fff; }
.smc-explore-s { font-size: .74rem; color: var(--sm-dim, #96A3BC); line-height: 1.35; }
.smc-explore-s b { color: #FBBF24; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---- The view, layered over the map stage ------------------ */
.smc-stage-open > svg, .smc-stage-open > .sm-maptitle, .smc-stage-open > .sm-maplegend { visibility: hidden; }

.smc-view {
    position: absolute; left: 0; right: 0; top: 0; min-height: 100%; z-index: 30;
    display: flex; flex-direction: column; box-sizing: border-box;
    padding: 12px 14px 12px;
    color: var(--sm-text, #E7ECF5);
    background:
        radial-gradient(1200px 520px at 30% 0%, rgba(52, 211, 153, .06), transparent 60%),
        linear-gradient(rgba(38, 51, 76, .22) 1px, transparent 1px) 0 0 / 100% 32px,
        linear-gradient(90deg, rgba(38, 51, 76, .22) 1px, transparent 1px) 0 0 / 32px 100%,
        var(--sm-bg, #0B1220);
    border-radius: 0 0 15px 15px;
    container-type: inline-size; container-name: smc;
    opacity: 0; transition: opacity .22s ease;
}
.smc-view.is-on { opacity: 1; }
.smc-view.is-leaving { opacity: 0; pointer-events: none; }
.smc-view *, .smc-view *::before, .smc-view *::after { box-sizing: border-box; }

/* header bar */
.smc-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--sm-line, #26334C); }
.smc-back {
    flex: none; display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font: inherit;
    font-size: .78rem; font-weight: 700; color: var(--sm-text, #E7ECF5);
    padding: 7px 12px; border-radius: 9px; background: var(--sm-panel, #131C2C); border: 1px solid var(--sm-line, #26334C);
    transition: border-color .15s ease, background .15s ease;
}
.smc-back:hover { border-color: var(--sm-accent, #34D399); background: var(--sm-raise, #1B2740); }
.smc-back:focus-visible, .smc-metric:focus-visible, .smc-toprow:focus-visible, .smc-card-x:focus-visible,
.smc-mkbtn:focus-visible, .smc-retry:focus-visible { outline: 2px solid var(--sm-accent, #34D399); outline-offset: 2px; }
.smc-title {
    margin: 0; min-width: 0; flex: 1 1 auto; outline: none;
    font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Segoe UI Mono', Consolas, monospace;
    font-size: .95rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #fff;
}
.smc-title-n::before {
    content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 9px; border-radius: 2px;
    background: #FBBF24; box-shadow: 0 0 10px rgba(251, 191, 36, .7); vertical-align: 1px;
}
.smc-title-c { color: var(--sm-dim, #96A3BC); font-weight: 600; font-variant-numeric: tabular-nums; }
.smc-kbd {
    flex: none; font: 600 .66rem ui-monospace, 'SF Mono', Consolas, monospace; letter-spacing: .06em; color: var(--sm-faint, #6B7A96);
    padding: 3px 7px; border: 1px solid var(--sm-line, #26334C); border-bottom-width: 2px; border-radius: 6px;
}

/* metric switcher */
.smc-metrics { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 2px; }
.smc-metric {
    cursor: pointer; font: inherit; font-size: .76rem; font-weight: 600; white-space: nowrap;
    color: var(--sm-dim, #96A3BC); padding: 6px 11px; border-radius: 999px;
    background: rgba(19, 28, 44, .85); border: 1px solid var(--sm-line, #26334C);
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.smc-metric::before {
    content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px;
    background: var(--smc-c, #96A3BC); opacity: .55; transition: opacity .15s ease;
}
.smc-metric[data-metric="homeValue4br"] { --smc-c: #F472B6; }
.smc-metric[data-metric="homeValue"] { --smc-c: #38BDF8; }
.smc-metric[data-metric="homeValueYoY"] { --smc-c: #34D399; }
.smc-metric[data-metric="seasonalShare"] { --smc-c: #A78BFA; }
.smc-metric[data-metric="bigHomeShare"] { --smc-c: #22D3EE; }
.smc-metric[data-metric="tourismJobShare"] { --smc-c: #FB923C; }
.smc-metric:hover:not(:disabled) { color: #fff; border-color: var(--sm-faint, #6B7A96); }
.smc-metric.is-on { color: #fff; border-color: var(--smc-c); background: color-mix(in srgb, var(--smc-c) 16%, #131C2C); }
.smc-metric.is-on::before { opacity: 1; box-shadow: 0 0 8px var(--smc-c); }
.smc-metric:disabled { opacity: .35; cursor: not-allowed; }

/* body */
.smc-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-top: 8px; flex: 1 1 auto; min-height: 0; }
.smc-mapcol { min-width: 0; display: flex; flex-direction: column; }
.smc-map { position: relative; flex: 1 1 auto; min-height: 120px; display: flex; align-items: center; justify-content: center; padding: 6px 0; }
.sm-map-wrap .smc-svg, .smc-svg {
    display: block; width: 100%; height: auto; max-height: 72vh; overflow: visible;
    filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .55));
    touch-action: pan-y;
}
.smc-counties { transform-box: view-box; transform-origin: 50% 50%; animation: smcExplode .55s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes smcExplode { from { opacity: 0; transform: scale(.9); } 60% { opacity: 1; } to { opacity: 1; transform: scale(1); } }
.smc-county {
    stroke: #0B1220; stroke-width: .7; stroke-linejoin: round; vector-effect: non-scaling-stroke;
    cursor: pointer; transition: fill .38s ease;
}
.smc-county.is-empty { stroke: #0B1220; }
.smc-dot { stroke: #0B1220; stroke-width: 1; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .38s ease; }
.smc-dot.is-empty { stroke: #3A4A68; }
.smc-hl, .smc-sel { fill: none; pointer-events: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; opacity: 0; }
.smc-hl { stroke: #fff; stroke-width: 1.8; filter: drop-shadow(0 0 5px rgba(255, 255, 255, .55)); }
.smc-sel { stroke: #FBBF24; stroke-width: 2.4; filter: drop-shadow(0 0 6px rgba(251, 191, 36, .75)); }
.smc-hl.is-on, .smc-sel.is-on { opacity: 1; }

/* tracked-market pins */
.smc-pin { cursor: pointer; outline: none; }
.smc-pin-halo { fill: rgba(251, 191, 36, .18); stroke: rgba(251, 191, 36, .55); stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill .15s ease; }
.smc-pin-dot { fill: #FBBF24; stroke: #0B1220; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.smc-pin:hover .smc-pin-halo, .smc-pin:focus-visible .smc-pin-halo { fill: rgba(251, 191, 36, .45); stroke: #FBBF24; }
.smc-pin:focus-visible .smc-pin-dot { stroke: #fff; }
.smc-pin-label {
    font-family: inherit; font-size: 12.5px; font-weight: 700; fill: #fff; letter-spacing: .01em;
    paint-order: stroke; stroke: #0B1220; stroke-width: 3.6px; stroke-linejoin: round; pointer-events: none;
}
.smc-pins { animation: smcFade .4s ease .45s both; }
@keyframes smcFade { from { opacity: 0; } to { opacity: 1; } }

/* legend */
.smc-legend { padding-top: 8px; min-height: 46px; }
.smc-legend-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: .72rem; color: var(--sm-faint, #6B7A96); margin-bottom: 6px; }
.smc-legend-h b { font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sm-dim, #96A3BC); }
.smc-legend-row { display: flex; flex-wrap: wrap; gap: 5px 14px; }
.smc-lg { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--sm-dim, #96A3BC); font-variant-numeric: tabular-nums; white-space: nowrap; }
.smc-sw { flex: none; display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #1C2638; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.smc-sw-none { background: repeating-linear-gradient(45deg, #1C2638 0 2.5px, #34435F 2.5px 4.5px); box-shadow: inset 0 0 0 1px #3A4A68; }

/* side column */
.smc-side { min-width: 0; display: grid; gap: 10px; align-content: start; }
.smc-card, .smc-top {
    background: rgba(19, 28, 44, .92); border: 1px solid var(--sm-line, #26334C); border-radius: 12px; padding: 12px 13px;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.smc-top:empty { display: none; }
.smc-card.is-pinned { border-color: rgba(251, 191, 36, .55); box-shadow: 0 0 0 1px rgba(251, 191, 36, .12), 0 12px 30px rgba(0, 0, 0, .35); }
.smc-sec { font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--sm-faint, #6B7A96); margin-bottom: 8px; }
.smc-sec-in { margin-top: 12px; }
.smc-big {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Segoe UI Mono', Consolas, monospace;
    font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.smc-big-s { font-size: .74rem; color: var(--sm-dim, #96A3BC); margin-top: 4px; line-height: 1.4; }
.smc-range { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--sm-line, #26334C); font-size: .76rem; color: var(--sm-dim, #96A3BC); }
.smc-range b { color: #fff; font-variant-numeric: tabular-nums; }
.smc-hint { margin: 9px 0 0; font-size: .7rem; color: var(--sm-faint, #6B7A96); line-height: 1.45; }
.smc-note { margin: 9px 0 0; font-size: .7rem; color: var(--sm-faint, #6B7A96); line-height: 1.45; }

.smc-card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 9px; }
.smc-card-n { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; color: #fff; line-height: 1.2; }
.smc-card-s { font-size: .74rem; color: var(--sm-dim, #96A3BC); margin-top: 3px; }
.smc-card-s b { color: #FBBF24; font-weight: 700; font-variant-numeric: tabular-nums; }
.smc-card-x {
    flex: none; width: 26px; height: 26px; border-radius: 7px; cursor: pointer; font-size: 1.05rem; line-height: 1;
    color: var(--sm-dim, #96A3BC); background: transparent; border: 1px solid var(--sm-line, #26334C);
}
.smc-card-x:hover { color: #fff; border-color: var(--sm-faint, #6B7A96); }

.smc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 10px; font-size: .78rem; line-height: 1.75; color: var(--sm-dim, #96A3BC); }
.smc-rows .smc-row { grid-template-columns: minmax(0, 1fr) auto 66px; padding: 1px 6px; margin: 0 -6px; border-radius: 6px; }
.smc-rows .smc-row.is-active { background: rgba(255, 255, 255, .05); color: #fff; }
.smc-row-k { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smc-row-v { color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.smc-row-r { font: 600 .68rem ui-monospace, 'SF Mono', Consolas, monospace; color: var(--sm-faint, #6B7A96); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.smc-row.is-active .smc-row-r { color: #FBBF24; }
.is-up { color: #34D399 !important; }
.is-down { color: #F87171 !important; }

.smc-mk { display: flex; flex-wrap: wrap; gap: 6px; }
.smc-mkbtn {
    cursor: pointer; font: inherit; font-size: .74rem; font-weight: 700; color: #FBBF24; padding: 5px 10px; border-radius: 999px;
    background: rgba(251, 191, 36, .1); border: 1px solid rgba(251, 191, 36, .4);
}
.smc-mkbtn:hover { background: rgba(251, 191, 36, .2); border-color: #FBBF24; }

/* top 10 */
.smc-toplist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.smc-toplist li { margin: 0; padding: 0; }
.smc-toprow {
    display: grid; grid-template-columns: 20px 10px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%;
    cursor: pointer; font: inherit; font-size: .78rem; text-align: left; color: var(--sm-text, #E7ECF5);
    padding: 5px 7px; border-radius: 7px; background: transparent; border: 1px solid transparent;
    transition: background .12s ease, border-color .12s ease;
}
.smc-toprow:hover, .smc-toprow:focus-visible { background: var(--sm-raise, #1B2740); }
.smc-toprow.is-on { border-color: rgba(251, 191, 36, .55); background: rgba(251, 191, 36, .08); }
.smc-toprow { position: relative; padding-bottom: 8px; }
.smc-toprow-b { position: absolute; left: 35px; right: 7px; bottom: 3px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .05); overflow: hidden; }
.smc-toprow-b i { display: block; height: 100%; border-radius: 2px; background: var(--sm-faint, #6B7A96); opacity: .85; transition: width .4s ease; }
.smc-toprow-r { font: 600 .68rem ui-monospace, 'SF Mono', Consolas, monospace; color: var(--sm-faint, #6B7A96); text-align: right; }
.smc-toprow .smc-sw { width: 9px; height: 9px; border-radius: 2px; }
.smc-toprow-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smc-toprow-v { font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; }

/* attribution */
.smc-attr { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--sm-line, #26334C); font-size: .66rem; line-height: 1.5; color: var(--sm-faint, #6B7A96); }
.smc-attr-c { color: var(--sm-dim, #96A3BC); }

/* tooltip */
.smc-tip {
    position: absolute; z-index: 5; left: 0; top: 0; pointer-events: none; opacity: 0; min-width: 196px; max-width: 270px;
    background: rgba(5, 9, 15, .97); border: 1px solid #33425F; border-radius: 10px; padding: 9px 11px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .65); transition: opacity .1s ease;
}
.smc-tip.is-on { opacity: 1; }
.smc-tip-t { font-weight: 800; font-size: .88rem; color: #fff; }
.smc-tip-pin { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #FBBF24; margin-right: 7px; }
.smc-tip-rank { font: 600 .66rem ui-monospace, 'SF Mono', Consolas, monospace; color: #FBBF24; margin: 3px 0 6px; letter-spacing: .02em; }
.smc-tip .smc-row { line-height: 1.65; }
.smc-tip .smc-row.is-active .smc-row-k { color: #fff; }
.smc-tip-cta { margin-top: 6px; font-size: .7rem; color: var(--sm-faint, #6B7A96); }

/* loading + error */
.smc-loading { display: grid; justify-items: center; gap: 12px; padding: 90px 20px; color: var(--sm-dim, #96A3BC); font-size: .86rem; }
.smc-loading-bar { position: relative; width: 160px; height: 3px; border-radius: 3px; background: var(--sm-line, #26334C); overflow: hidden; }
.smc-loading-bar::after { content: ''; position: absolute; inset: 0; width: 40%; border-radius: 3px; background: #FBBF24; animation: smcLoad 1.1s ease-in-out infinite; }
@keyframes smcLoad { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.smc-error { display: grid; justify-items: center; gap: 8px; padding: 70px 20px; text-align: center; font-size: .84rem; color: var(--sm-dim, #96A3BC); }
.smc-error strong { color: #fff; font-size: .95rem; }
.smc-retry {
    margin-top: 6px; cursor: pointer; font: inherit; font-size: .8rem; font-weight: 700; color: #05231A; padding: 8px 16px;
    border-radius: 9px; background: var(--sm-accent-deep, #10B981); border: 1px solid var(--sm-accent-deep, #10B981);
}
.smc-retry:hover { background: var(--sm-accent, #34D399); }

/* ---- Wide stage: map + side column ------------------------- */
@container smc (min-width: 760px) {
    .smc-body { grid-template-columns: minmax(0, 1fr) 286px; gap: 14px; }
    .smc-side { max-height: 100%; }
}
@container smc (max-width: 520px) {
    .smc-kbd { display: none; }
    .smc-title { flex-basis: 100%; order: 2; font-size: .82rem; }
    .smc-legend-h span { display: none; }
    .smc-metric { font-size: .72rem; padding: 6px 9px; }
}

@media (prefers-reduced-motion: reduce) {
    .smc-view, .smc-county, .smc-dot, .smc-explore, .smc-tip { transition: none; }
    .smc-counties, .smc-pins, .smc-loading-bar::after { animation: none; }
    .smc-explore:hover { transform: none; }
}
