/* shell.css — the frame the two crude maps share (UI-04, 2026-10-28):
 * the sub-bar under the site's top bar, the key card down the map's left
 * edge, the folded credits by the zoom buttons, and the state codes.
 * js/shell.js builds the parts; this sheet is the look.
 *
 * Thomas, 2026-10-28: "Include the permanent side par like theirs with the
 * key on the side. And the permanent top bar for tab switching and back
 * buttons for when you click on pipelines. Scope out grid status UI for those
 * things and copy across." Grid Status's map is the model: white cards with
 * a soft shadow and round corners floating on the map, quiet grey type, the
 * current tab dark and underlined.
 *
 * Loaded by index.html (/flows/us/) and texas.html (/flows/texas/) between
 * app.css and the page's own sheet, and injected by model/site_build.py into
 * /flows/texas/filings/, the third page that carries the sub-bar. The page
 * sheets keep only what is theirs: how wide the key is and how tall it may
 * run on that page's map. Tokens only (tests/test_web_tokens.py).
 */

/* ------------------------------------------------------------ the sub-bar
 * partials/flows-tabs.html. One row, 36px, under the site's 45px top bar on
 * both pages (site_build pins the US map under the two: 45 + 36). It scrolls
 * inside itself rather than wrapping, so its height is a constant the map's
 * layout can count on.
 *
 * THREE GROUPS, NOT ONE SENTENCE (UI-06, Thomas 2026-10-29: "Currently ours
 * looks like a sentence of words. Make it cleanly separated in to tabs."):
 * the section's name as a quiet label (the .eyebrow, not a tab and not a
 * link), then the tabs, each its own full-height box with a hairline between
 * them, then, only while the reader is inside something, the drill group
 * ("← Back" and the trail) behind a full-height divider of its own, so the
 * trail can never be read as more tabs. The tabs are the top bar's tabs
 * (app.css .topnav), one size down. */
.crumbbar {
  display: flex;
  align-items: stretch;
  gap: var(--sp-2);
  height: 36px;
  box-sizing: border-box;
  margin: 0;
  padding: 0 var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: var(--t-data);
  line-height: 1;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

/* The section label. Its look is .eyebrow's (app.css, R2.3: never restyled
   locally); this only centres it and leaves a gap before the first tab. */
.crumbbar-root {
  display: flex;
  align-items: center;
  padding-right: var(--sp-1);
}

.crumbbar-sep {
  display: flex;
  align-items: center;
  color: var(--ink-faint);
}

.crumbbar-tabs {
  display: flex;
  gap: 0;
}

/* Grid Status's tab: grey, and the page you are on dark with a 2px rule
   under it that sits on the bar's own bottom edge. The whole height of the
   bar is the hit area. */
.crumbbar-tab {
  position: relative;
  display: flex;
  align-items: center;
  padding: 2px var(--sp-3) 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-body);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-ui) var(--ease),
              border-color var(--dur-ui) var(--ease);
}

/* The hairline between two tabs, as in the top bar. */
.crumbbar-tab + .crumbbar-tab::before {
  content: "";
  position: absolute;
  left: 0;
  top: 30%;
  bottom: 30%;
  width: 1px;
  background: var(--line-strong);
}

.crumbbar-tab:hover {
  color: var(--ink);
  border-bottom-color: var(--line-strong);
}

.crumbbar-tab.is-on {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}

/* Inside something: a full-height rule closes the tab group, and the drill
   group starts after it. */
.crumbbar.is-drilled .crumbbar-tabs {
  padding-right: var(--sp-2);
  border-right: 1px solid var(--line-strong);
}

/* "← Back", shown only while the reader is inside something. */
.crumbbar-back {
  display: flex;
  align-items: center;
  align-self: center;
  gap: var(--sp-1);
  margin-left: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.crumbbar-back:hover {
  background: var(--surface-2);
}

/* Keyboard focus, the app's --ink ring. The tabs draw it inside themselves,
   because the bar is its own scroll box and would clip a ring outside them. */
.crumbbar-tab:focus-visible,
.crumbbar-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.crumbbar-back:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.crumbbar-trail {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.crumbbar-link {
  color: var(--ink-body);
  text-decoration: none;
}

.crumbbar-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.crumbbar-here {
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------ the key card
 * keyPanel() in js/shell.js. A white card floating on the map's left edge,
 * one section per layer: a bold title with an eye that hides the layer, the
 * legend for it, and its smaller switches. The page sheet sets the width and
 * the body's height cap; this is everything else. */
.map-key {
  font-family: var(--font-ui);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  color: var(--ink);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.map-key-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-ui);
  cursor: pointer;
}

.map-key-header:hover {
  background: var(--surface-2);
}

.map-key-title {
  font-size: var(--t-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--label-tracking);
  color: var(--ink);
}

/* Grid Status folds its panel with a "<". Open, the chevron points at the
   edge the card folds towards; folded, it points back out. */
.map-key-chevron::before {
  content: "‹";
  font-size: var(--t-title);
  line-height: 1;
  color: var(--ink-body);
}

.map-key.collapsed .map-key-chevron::before {
  content: "›";
}

.map-key.collapsed .map-key-body {
  display: none;
}

.map-key.collapsed .map-key-header {
  border-bottom: none;
}

.map-key-body {
  box-sizing: border-box;
  padding: 0 var(--sp-3) var(--sp-2);
  overflow-y: auto;
}

.key-section {
  padding: var(--sp-3) 0 var(--sp-2);
}

.key-section + .key-section {
  border-top: 1px solid var(--line);
}

.key-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.key-section-title {
  margin: 0;
  font-size: var(--t-data);
  font-weight: 600;
  color: var(--ink);
}

/* The eye. Shown: an open eye in the body ink; hidden: struck through and
   faint, and the section's legend fades with it. */
.key-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: var(--r-ctl);
  color: var(--ink-body);
  cursor: pointer;
}

.key-eye:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.key-eye svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key-eye[aria-pressed="false"] {
  color: var(--ink-faint);
}

.key-section.is-off .key-section-title,
.key-section.is-off .key-legend,
.key-section.is-off .key-section-note {
  opacity: 0.45;
}

.key-legend {
  list-style: none;
  margin: var(--sp-2) 0 0;
  padding: 0;
}

/* The chip column is fixed, so every label starts on the same x whichever
   shape its chip is (a 3px line, a 12px triangle). */
.key-legend-row {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  column-gap: var(--sp-2);
  padding: 2px 0;
  font-size: var(--t-data);
  line-height: 1.3;
  color: var(--ink-body);
}

.key-section-note {
  margin: var(--sp-1) 0 0;
  font-size: var(--t-label);
  line-height: 1.35;
  color: var(--ink-faint);
}

/* A section's smaller switch (Other pipelines, Export sub-regions...). */
.map-key-item {
  display: grid;
  grid-template-columns: 13px 26px 1fr;
  align-items: start;
  column-gap: var(--sp-2);
  margin-top: var(--sp-2);
  cursor: pointer;
}

.map-key-check {
  width: 13px;
  height: 13px;
  margin: 2px 0 0;
  accent-color: var(--ink);
  cursor: pointer;
}

.map-key-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.map-key-label {
  font-size: var(--t-data);
  line-height: 1.3;
  color: var(--ink-body);
}

.map-key-item:hover .map-key-label {
  color: var(--ink);
}

.map-key-note {
  font-size: var(--t-label);
  line-height: 1.3;
  color: var(--ink-faint);
}

/* ------------------------------------------------------------ the chips
 * keySwatch() in js/shell.js. The colour arrives as `--swatch`, set inline
 * to the string `var(--map-basin)`, never a resolved value, so a theme swap
 * re-resolves every chip with no handler. */
.key-swatch {
  display: block;
  justify-self: center;
  margin-top: 1px;
}

.key-swatch-area {
  width: 14px;
  height: 11px;
  border: 1.5px solid var(--swatch);
  border-radius: 2px;
  background: var(--swatch);
}

/* A layer drawn as an outline (the national border). */
.key-swatch-area.key-swatch-hollow {
  background: transparent;
}

/* Several colours in one chip: the production ramp, low to high. */
.key-swatch-split {
  display: flex;
  width: 22px;
  height: 11px;
  border-radius: 2px;
  overflow: hidden;
}

.key-swatch-seg {
  flex: 1;
  background: var(--swatch);
}

.key-swatch-diamond {
  width: 10px;
  height: 10px;
  background: var(--swatch);
  transform: rotate(45deg);
}

.key-swatch-triangle {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid var(--swatch);
}

.key-swatch-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--swatch);
}

/* "Sized by capacity": three plants, small to large. */
.key-swatch-sizes {
  display: flex;
  align-items: center;
  gap: 2px;
}

.key-size {
  border-radius: 50%;
  background: var(--swatch);
}

.key-size-s { width: 5px; height: 5px; }
.key-size-m { width: 8px; height: 8px; }
.key-size-l { width: 11px; height: 11px; }

/* A line as the map draws it: solid (a pipeline we hold flows for), dotted
   (a Texas T-1 estimate, round dots like the map's), dashed (no flows),
   thin (a state line, another pipeline). */
.key-swatch-line {
  width: 22px;
}

.key-line-solid {
  height: 3px;
  border-radius: 1px;
  background: var(--swatch);
}

.key-line-dotted {
  height: 4px;
  background-image: radial-gradient(circle, var(--swatch) 1.6px, transparent 1.9px);
  background-size: 6px 4px;
  background-position: 0 50%;
}

.key-line-dashed {
  border-top: 2px dashed var(--swatch);
}

.key-line-thin {
  border-top: 1px solid var(--swatch);
}

/* ------------------------------------------------------------ the credits
 * credits() in js/shell.js: Grid Status's small black (i) by the zoom
 * buttons. Folded at every width; one click opens the pill to its left. */
.credits {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.credits-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  background: var(--ink);
  border: 0;
  border-radius: var(--r-pill);
  color: var(--surface);
  cursor: pointer;
}

.credits-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.credits-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.credits-pill {
  display: flex;
  align-items: center;
  min-height: 22px;
  padding: 2px var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-panel);
}

/* Leaflet's own attribution box, moved inside the pill: its corner float,
   margin and strip background go, the pill is the surface now. */
.credits-pill .leaflet-control-attribution {
  float: none;
  clear: none;
  margin: 0;
  padding: 0;
  background: none;
  color: var(--ink-body);
  font-family: var(--font-ui);
  font-size: var(--t-label);
  line-height: 1.4;
  white-space: nowrap;
}

.credits-pill .leaflet-control-attribution a {
  background: none;
  color: var(--ink);
}

/* ------------------------------------------------------------ state codes
 * stateCodes() in js/shell.js: two-letter codes at each state's label point,
 * small grey caps with the map's halo, in a pane that takes no pointer. */
.state-code {
  background: none;
  border: 0;
}

.state-code-in {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: var(--label-tracking);
  color: var(--ink-faint);
  text-shadow: 0 0 2px var(--map-halo), 0 0 2px var(--map-halo);
  pointer-events: none;
}

/* ------------------------------------------------------------ detail close
 * The × on a detail card: the same as the bar's Back (goBack in shell.js). */
.detail-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--ink-body);
  font: inherit;
  font-size: var(--t-title);
  line-height: 1;
  cursor: pointer;
}

.detail-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* ------------------------------------------------------------ map tools
 * Grid Status's round tool buttons beside the key (the Texas map's search,
 * texas.js buildTools). */
.map-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-panel);
  color: var(--ink-body);
  cursor: pointer;
}

.map-tool-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.map-tool-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* ------------------------------------------------------------ narrow
 * Inside something, a phone has no room for the tabs AND the trail: the bar
 * keeps "← Back" and the trail, and the tabs come back on the overview. */
@media (max-width: 820px) {
  .crumbbar {
    padding: 0 var(--sp-4);
  }
  .crumbbar.is-drilled .crumbbar-root,
  .crumbbar.is-drilled .crumbbar-tabs {
    display: none;
  }
  .crumbbar.is-drilled .crumbbar-back {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-key-chevron::before,
  .crumbbar-tab { transition: none; }
}
