/* Sector deep dive in two columns (MAR-788, scripts/lib/sector-rail.mjs):
   the hero and every section on the left, a statistics rail on the right.
   Same dimensions as a company deep dive (css/company-ecosystem-map.css
   .profile-grid.is-deep): 1344px page, 32px gutters, 384px rail, 24px gap. */
.sector-deep { max-width: 1344px; margin: 0 auto; padding: 0 32px; display: grid; grid-template-columns: minmax(0, 1fr) 384px; column-gap: 24px; align-items: start; }
.sector-deep > * { grid-column: 1; min-width: 0; }
.sector-deep > .sector-rail { grid-column: 2; grid-row: 1 / span 80; align-self: stretch; padding-top: 3.25rem; }
/* The gutters belong to the grid, not to each band inside it. */
.sector-deep > .hero, .sector-deep > section.body-section, .sector-deep > .section-divider { padding-left: 0; padding-right: 0; }
.sector-deep .body-inner { max-width: none; }

.sector-rail .profile-rail-inner { position: sticky; top: calc(var(--profile-subnav-bottom, 116px) + 16px); display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - var(--profile-subnav-bottom, 116px) - 32px); overflow-y: auto; scrollbar-width: thin; }
.sector-rail .rail-card { display: block; width: 100%; margin: 0; padding: 14px 16px 10px; border: 1px solid var(--border-light); border-radius: 12px; background: var(--surface-card, var(--navy-light)); font: inherit; color: inherit; text-align: left; }
.sector-rail a.rail-card { text-decoration: none; }
.sector-rail .rail-card[hidden] { display: none; }
/* Country rail: the location map on top. */
.sector-rail .rail-map { display: block; }
.sector-rail .rail-map .hero-map { display: block; height: 220px; max-width: none; }
.sector-rail button.rail-card { cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease; }
.sector-rail button.rail-card:hover { border-color: var(--border-mid); box-shadow: var(--shadow-sm, 0 2px 8px rgba(16, 24, 40, 0.06)); /* theme-guardrail-allow: fallback for a missing shadow token */ }
.sector-rail button.rail-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sector-rail .mx-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sector-rail .mx-title { font: 700 0.875rem/1.3 var(--font-sans); color: var(--white); }
.sector-rail .mx-change { font: 600 0.75rem/1.3 var(--font-sans); color: var(--text-light); text-align: right; }
.rail-chart-plot { display: block; min-height: 80px; margin-top: 10px; }
.rail-chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-sans); }
.rail-chart-open { display: block; margin-top: 6px; font: 600 0.75rem/1.3 var(--font-sans); color: var(--blue); }
.rail-bar { fill: var(--chart-navy); }
.rail-bar.is-partial { fill: var(--chart-sky); }
.rail-axis { stroke: var(--border-mid); stroke-width: 1; }
.rail-tick { fill: var(--text-light); font-size: 10px; font-weight: 500; }
.rail-val { fill: var(--white); font-size: 11px; font-weight: 700; font-family: var(--font-display); }
/* The rail funnel is the pop-up chart in small (MAR-818): one column per
   stage, the count and name standing on a log-scaled bar. */
.rail-funnel-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; align-items: stretch; }
.rail-funnel-list li { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.rail-funnel-list i { order: 2; display: block; height: calc(96px * var(--share)); margin-top: 6px; background: var(--eyebrow); opacity: calc(var(--shade) * 1.8); }
.rail-funnel-text { order: 1; font: 600 0.6875rem/1.2 var(--font-sans); color: var(--white); }
.rail-funnel-text b { display: block; margin-bottom: 2px; font: 700 1.375rem/1.05 var(--font-display); letter-spacing: -0.01em; }
.rail-funnel-tip { order: 3; position: absolute; left: 0; top: calc(100% + 4px); width: 220px; z-index: 3; display: none; padding: 8px 10px; border: 1px solid var(--border-mid); border-radius: 8px; background: var(--surface-card, var(--navy-light)); box-shadow: var(--shadow-lg); font: 500 0.75rem/1.4 var(--font-sans); color: var(--text-light); }
.rail-funnel-list li:nth-child(n+3) .rail-funnel-tip { left: auto; right: 0; }
.rail-funnel-tip b { display: block; font-weight: 700; color: var(--white); }
.rail-funnel-list li:hover .rail-funnel-tip { display: block; }
.rail-hub-list { list-style: none; margin: 10px 0 0; padding: 0; }
.rail-hub-list li { display: grid; grid-template-columns: 88px minmax(0, 1fr) 24px; align-items: center; gap: 10px; padding: 5px 0; font: 500 0.8125rem/1.3 var(--font-sans); color: var(--white); }
.rail-hub-bar { display: block; height: 10px; background: var(--chart-track, var(--border-light)); }
.rail-hub-bar i { display: block; height: 100%; background: var(--chart-navy); }
.rail-hub-n { text-align: right; font-weight: 700; font-family: var(--font-display); }
/* Country rail: hubs by enterprise value, so the number column is wider. */
.rail-hubs.is-ev .rail-hub-list li { grid-template-columns: 104px minmax(0, 1fr) 52px; }
.rail-hubs.is-ev .rail-hub-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Flagship location pages (MAR-808): the detailed funnel stays in the page
   for the deck view only, and the deck view drops the two columns.
   Off-screen, not display:none: the funnel widget measures itself when the
   page loads and would boot in its phone layout at zero width. */
body:not(.drp-pages) .deck-only { position: absolute; left: -9999px; top: 0; width: 1280px; visibility: hidden; pointer-events: none; }
body.drp-pages .sector-deep { display: block; max-width: none; padding: 0; }
body.drp-pages .sector-rail { display: none; }
/* In the funnel pop-up the split of each stage shows without a hover. */
@media (min-width: 761px) { .rail-dialog .lsf-split { opacity: 1; } }

/* The pop-up: the full section, with its own filters. */
.rail-dialog { inset: 0; margin: auto; width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border-mid); border-radius: 16px; background: var(--navy); color: var(--white); box-shadow: var(--shadow-lg); overflow-y: auto; }
.rail-dialog::backdrop { background: rgba(16, 24, 40, 0.45); /* theme-guardrail-allow: modal scrim */ }
.rail-dialog section.body-section { padding: 0 2rem 1.5rem; background: none; }
.rail-dialog section.body-section > .body-inner { max-width: none; padding-top: 1.75rem; border-top: 0; }
.rail-dialog-close { position: sticky; top: 12px; float: right; z-index: 5; margin: 12px 12px 0 0; width: 34px; height: 34px; border: 1px solid var(--border-light); border-radius: 9px; background: var(--navy); color: var(--text-light); font: 400 1.25rem/1 var(--font-sans); cursor: pointer; }
.rail-dialog-close:hover { color: var(--white); border-color: var(--border-mid); }
.rail-dialog-foot { margin: 0; padding: 0 2rem 1.5rem; font: 600 0.8125rem/1.4 var(--font-sans); }
.rail-dialog-foot a { color: var(--blue); text-decoration: none; }

/* Exits in the pop-up: bars by year or quarter, stacked by exit type. */
.rail-exits-controls { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 14px; }
.rail-exits-group { display: flex; align-items: center; gap: 6px; font: 600 0.75rem/1 var(--font-sans); color: var(--text-light); }
.rail-pill { appearance: none; padding: 0.5rem 0.75rem; border: 1px solid var(--border-light); border-radius: 999px; background: none; color: var(--text-light); font: 700 0.75rem/1 var(--font-sans); cursor: pointer; }
.rail-pill.is-on { background: var(--surface-card, var(--navy-light)); border-color: var(--border-mid); color: var(--white); }
.rail-exits-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; font: 500 0.75rem/1.3 var(--font-sans); color: var(--text-light); }
.rail-exits-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.rail-exits svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-sans); }
.rail-exits .rail-tick { font-size: 11px; }
.rail-exits .rail-val { font-size: 13px; }
.rail-grid { stroke: var(--chart-grid); stroke-width: 1; }
.rail-seg-acquisition { fill: var(--chart-navy); background: var(--chart-navy); }
.rail-seg-buyout { fill: var(--chart-sky); background: var(--chart-sky); }
.rail-seg-ipo { fill: var(--chart-sky-tint); background: var(--chart-sky-tint); stroke: var(--chart-sky); stroke-width: 0; }
.rail-seg-count { fill: var(--chart-navy); }

@media (max-width: 1100px) {
    .sector-deep { display: flex; flex-direction: column; align-items: stretch; padding: 0 1.25rem; }
    .sector-deep > * { order: 2; }
    .sector-deep > .hero { order: 0; }
    .sector-deep > .sector-rail { order: 1; padding-top: 16px; }
    .sector-rail .profile-rail-inner { position: static; display: grid; grid-template-columns: 1fr 1fr; align-items: start; max-height: none; overflow: visible; }
}
@media (max-width: 700px) {
    .sector-rail .profile-rail-inner { grid-template-columns: 1fr; }
    .rail-dialog section.body-section { padding: 0 1rem 1.25rem; }
    .rail-dialog-foot { padding: 0 1rem 1.25rem; }
}

/* The stat cards keep one row in the narrower body column (not in the deck view, which hides them). */
@media (min-width: 1101px) {
    body:not(.drp-pages) .sector-deep .hero-statline { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.6rem; }
    body:not(.drp-pages) .sector-deep .hero-statline .hero-stat { min-width: 0; padding: 0.85rem 0.8rem; }
}
