/* ==========================================================================
   Bento-grid layout for the Community Profile widget
   Generic structure + effects only. Client-specific colours (nav buttons)
   live in custom2.css.

   TYPOGRAPHY IS LOCKED. On the /embed page custom2.css is re-included AFTER
   this file (see mod_page_embed_widget.R), so client font rules would normally
   leak into the widget. To keep the bento design consistent across every client
   without per-client testing, all bento font properties (font-family, -size,
   -weight, letter-spacing, …) are declared here with `!important` and always win
   over custom2.css. Override contract for clients (in custom2.css):
     • Rebrand the face        →  .bento-widget { --bento-font-family: <stack>; }
                                   (no !important — overrides the variable below)
     • Any other font override →  bento-prefixed rule WITH !important
                                   (wins because custom2.css loads after this file)
   Non-font overrides (e.g. nav-button colours) need no !important, as before.
   ========================================================================== */

.bento-widget {
  position: relative;            /* positioning context for expanded cards */
  width: 100%;
  /* The grid's own fixed height (see .bento-grid); the widget never drops below it. */
  min-height: calc(var(--bento-body-h) + var(--bento-gap) + var(--bento-btn-h));
  /* Query container so the responsive rules at the bottom of this file react to
     the WIDGET's own width, not the viewport — the widget is commonly embedded
     in an iframe or sits beside other content, where viewport @media can't see
     how narrow the widget actually is. */
  container-type: inline-size;
  container-name: bento;
  --bento-gap: 14px;
  --bento-radius: 16px;
  --bento-pad: 18px;
  /* Height of the card row (value column, hero, column 3). The grid's total
     height is this + one gap + the footer row, so changing the footer never
     shrinks the cards. */
  --bento-body-h: 502px;
  /* Height of the footer row — the search pill and every topic-nav button share
     it, which is what keeps them level. It is an EXPLICIT height on both (their
     padding sits inside it, box-sizing: border-box), so no @container font-size
     change below can alter it. 98px fits the icon circle over a two-line
     caption inside equal 14px padding — see .bento-nav-btn for the budget. */
  --bento-btn-h: 98px;
  /* The frost laid over every collapsed card. Deliberately LIGHT: the chart under
     a card must still read as a chart, so users can see there is something to
     open. Tune here, not per card. */
  --bento-frost-veil: rgba(255, 255, 255, 0.3);
  --bento-frost-blur: 1px;
  /* Hairline outline drawn round every tile. Applied as an OUTSET box-shadow, not
     a border: it costs no layout (so it can't disturb the 14% / --bento-btn-h
     geometry) and it can't be hidden by .bento-card-frost::after, which covers
     the card's own box. Also the top edge of each card's heading plate. Client
     rebrand hook. */
  --bento-border: rgba(31, 41, 51, 0.12);
  /* Ring round the ACTIVE topic-nav button. A neutral grey, deliberately not
     --bento-accent: the icon circles already carry the palette colours, and a
     coloured ring would compete with them. Client rebrand hook. */
  --bento-nav-active: #a6a6a6;
  /* Brand colour, used by the active panel tab and focus rings. Resolves to the
     client's own theme automatically: cityviz_container_headless() builds the
     embed page's bs_theme() with primary = config$style$charts$palette[1], so
     --bs-primary is already the first colour of the chart palette the panels are
     drawn in. The literal is the Cranbrook palette head, kept as a fallback for
     any context that loads bento.css without a compiled Bootstrap. Clients that
     want the tab a different colour from their charts set --bento-accent on
     .bento-widget in custom2.css. */
  --bento-accent: var(--bs-primary, #893448);
  /* Corner radius of the boxes INSIDE an expanded panel (the chart frame and the
     data-table overlay that covers it). They must match, or the overlay's corners
     stick out past the frame when the table opens. */
  --bento-panel-radius: 12px;
  --bento-font-family: din-2014, Arial, sans-serif;  /* CityViz face; client rebrand hook */
}

/* Typography lock — bento always uses the CityViz face, never the client's
   body/brand font. Excludes chart SVG text so plotly keeps its own (Roboto)
   font set inline on its <text> nodes. Clients rebrand by overriding
   --bento-font-family on .bento-widget in custom2.css (no !important needed). */
.bento-widget,
.bento-widget :not(svg):not(svg *) {
  font-family: var(--bento-font-family) !important;
}

/* The widget embeds bslib internals (navset_card_tab → .card-header /
   .bslib-navs-card-title / .nav-link; bslib::value_box → .bslib-value-box) that
   carry generic Bootstrap class names. Client custom2.css rules target those
   hooks directly — e.g. `.card-header { text-transform: uppercase; letter-spacing }`
   and `.value-box-showcase { font-size; font-weight }` — and (unlike bento's own
   .bento-* classes) they would leak in. Re-assert neutral, inheriting values here
   so these internals match the bento design on every client. */
.bento-widget .card-header,
.bento-widget .bslib-navs-card-title,
.bento-widget .nav-link,
.bento-widget .bslib-value-box .value-box-title,
.bento-widget .bslib-value-box .value-box-value,
.bento-widget .bslib-value-box .value-box-showcase {
  text-transform: none !important;
  letter-spacing: normal !important;
}

/* Interpretation prose is rendered HTML (p / a / strong / li). Pin its size to the
   .bento-interp-text scale and strip any inherited client transform/spacing, so a
   client `p { font-size }` / `a { letter-spacing }` can't reshape the copy. */
.bento-interp a,
.bento-interp p,
.bento-interp strong,
.bento-interp li {
  font-size: inherit !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}

/* Only the active topic is visible; the rest stay mounted (charts keep state) */
.bento-widget .bento-topic {
  display: none;
}
.bento-widget .bento-topic.is-active {
  display: block;
}

/* A ?panel= embed contains only the panel wrapper. Legacy cityviz.css hides
   #cityviz-widget-charts-panel on desktop because the old layout emitted both
   full and panel variants and selected between them at the mobile breakpoint.
   The bento widgets now emit just the requested variant, so a panel-only
   wrapper must remain visible at every viewport size. The extra class keeps
   this override scoped to the new conditional layout. */
.content-embed #cityviz-widget-charts-panel.bento-widget-panel-only {
  display: block;
}
/* The same legacy rule hides the full #cityviz-widget-charts on phones (≤600px)
   and shows a #cityviz-widget-links list of new-tab panel links in its place.
   Bento widgets render on phones directly instead — the stacked tier at the
   bottom of this file — and carry no link list. (1,2,0) beats cityviz.css's
   (1,1,0) whatever the load order; non-bento widgets keep the legacy swap. */
.content-embed #cityviz-widget-charts.bento-widget {
  display: block;
}

/* --------------------------------------------------------------------------
   Full-surface topic (e.g. the Business Landscape "Location" map explorer):
   the body fills the whole widget area and the topic-nav row floats over it,
   so the user can still switch back to the other topics. No value boxes/cards.
   -------------------------------------------------------------------------- */
.bento-topic-full {
  position: relative;
  height: calc(var(--bento-body-h) + var(--bento-gap) + var(--bento-btn-h));
  border-radius: var(--bento-radius);
  overflow: hidden;
}
.bento-topic-full > div:first-child {
  height: 100%;
}
.bento-topic-full .bento-nav {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 500;
  flex: 0 0 auto;
  height: auto;
  width: max-content;
  max-width: calc(100% - 28px);
  padding: 6px;
  gap: 6px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: calc(var(--bento-radius) + 4px);
  box-shadow: 0 4px 16px rgba(31, 41, 51, 0.18);
}
/* Same (0,3,0)+ specificity as the base nav-button rule below, which would
   otherwise win. */
.bento-widget .bento-topic-full .bento-nav .bento-nav-btn {
  flex: 0 0 auto;
  min-width: 92px;
}

/* Two rows: the three-column body, then a footer holding the search pill (at
   column 1's width) beside the topic nav (spanning columns 2 and 3). */
.bento-grid {
  display: flex;
  flex-direction: column;
  gap: var(--bento-gap);
  /* A DEFINITE height (not height:100% against an auto-height .bento-topic, which
     collapses to content height) so the whole flex chain resolves top-down: the
     body, every column and every chart fills this height, and no per-topic content
     can change the grid height. This is what actually stops the topic-to-topic
     bounce. */
  height: calc(var(--bento-body-h) + var(--bento-gap) + var(--bento-btn-h));
  align-items: stretch;
}

/* Three proportional columns (mirrors the mock proportions) */
.bento-grid-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: var(--bento-gap);
  align-items: stretch;
}

/* The pill's 14% flex-basis resolves against the SAME inner width as
   .bento-col-values-wrap's — both rows are full-width children of .bento-grid,
   and a percentage basis is measured before `gap` comes out of free space. With
   the same gap on both rows, the nav's left edge therefore lands exactly on
   column 2's and its right edge on column 3's. `flex-shrink: 0` plus the
   `min-width: 0` on the button (see below) are what hold that alignment. */
.bento-grid-footer {
  flex: 0 0 var(--bento-btn-h);
  display: flex;
  gap: var(--bento-gap);
  min-height: 0;
}

.bento-col {
  display: flex;
  flex-direction: column;
  gap: var(--bento-gap);
  min-width: 0;
}

.bento-col-values-wrap { flex: 0 0 14%; min-height: 0; }
.bento-col-main        { flex: 1 1 50%; min-height: 0; }
.bento-col-side        { flex: 1 1 36%; min-height: 0; }

/* bento_layout_wide(): one surface in place of columns 2 AND 3 (the Business
   Landscape "Location" map). Column 1 and the footer are unchanged, so this
   topic lines up exactly with its card-based sibling. */
.bento-col-main-wide { flex: 1 1 auto; min-height: 0; }
.bento-main-full {
  /* The explore module's controls are an absolutePanel SIBLING of the map div,
     so this is the positioned ancestor that keeps them inside the surface. */
  position: relative;
  flex: 1 1 auto;
  min-height: 0;                /* never drive the grid height */
  border-radius: var(--bento-radius);
  overflow: hidden;             /* clip the map to the rounded corners */
  box-shadow: 0 0 0 1px var(--bento-border);
}
/* The controls panel carries an INLINE max-height: calc(100vh - 120px) sized for
   a full-page map (mod_widget_explore.R); inside this ~500px surface that lets
   an open Filters accordion run past the clipped edge with Apply/Reset out of
   reach. Only !important beats the inline style.

   cityviz.js/.css implement a "grow the panel while a selectize list is open"
   hatch (.dropdown-open => max-height: none) so a long list stays visible on a
   full-page map. That hatch is actively harmful in a bounded surface — the panel
   balloons to its full content height, overflows the 500px box by ~330px and is
   clipped by the `overflow: hidden` above, putting Filters' Apply/Reset out of
   reach for as long as the control keeps focus. The bento surface opts out of it
   in both directions (hence the .dropdown-open selector, which outranks
   cityviz.css's own !important on specificity rather than load order), which is
   also what makes the open dropdown reachable — see the rule below. Do NOT drop
   the .dropdown-open half: without it the panel balloons past the clipped edge
   again the moment a list opens. */
.bento-main-full .panel-controls,
.bento-main-full .panel-controls.dropdown-open {
  max-height: calc(100% - 20px) !important;
  overflow-y: auto !important;
}
/* The panel above is the ONLY scroller in this surface, exactly as the Filters
   accordion behaves: expanding a control grows what the panel scrolls over
   rather than opening a scroll box of its own. Giving the list back its own cap
   nests a second scroller inside the first, and both bars end up on screen at
   once.
   The list can be uncapped here because .selectize-dropdown is absolutely
   positioned inside .selectize-control (`position: relative`), i.e. its
   containing block is inside the panel — so it extends the panel's SCROLLABLE
   OVERFLOW and the panel's single scrollbar reaches the whole list.
   This is also what cityviz.css sets for every other .panel-controls in the app,
   so the bento surface is no longer a special case.
   `max-height: none` is what actually removes the inner scroller; the
   `overflow-y` below still COMPUTES to `auto` (per spec, `visible` paired with
   selectize's own `overflow-x: hidden` computes to `auto`) — it just has nothing
   left to scroll. It is kept for parity with the cityviz.css rule. */
.bento-main-full .panel-controls .selectize-dropdown-content {
  max-height: none;
  overflow-y: visible;
}
/* The explore module's own bottom-centre CityViz credit (its `is_widget` footer,
   which we keep for the controls panel's widget positioning) lands on top of the
   MapLibre attribution strip in this shorter surface. The widget already carries
   .bento-powered-by below the grid, so drop the inner one rather than the flag. */
.bento-main-full .panel-footer {
  display: none;
}

/* --------------------------------------------------------------------------
   Column 1 — unified value-box card (the search pill sits in the grid footer)
   -------------------------------------------------------------------------- */
.bento-col-values {
  flex: 1 1 auto;            /* fill column 1 */
  min-height: 0;            /* don't let the value boxes grow the grid past its baseline */
  background: #f6f6f6;
  border-radius: var(--bento-radius);
  box-shadow: 0 0 0 1px var(--bento-border);
  padding: var(--bento-pad);
  gap: var(--bento-pad);
}

.bento-vbox {
  flex: 1 1 0;
  min-height: 0;            /* share the column height; never drive it (prevents topic-to-topic bounce) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
}
.bento-vbox + .bento-vbox {
  padding-top: var(--bento-pad);
}
.bento-vbox-icon {
  font-size: 1.6rem !important;
  /*color: var(--cv-brand-color, #3E4C59);*/
  color: #afafaf;
  opacity: 0.85;
}
.bento-vbox-value {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  line-height: 1.05 !important;
  color: #3f4955;
}
.bento-vbox-label {
  font-size: 0.875rem !important;
  color: #1f2933;
  line-height: 1.25 !important;
}

/* --------------------------------------------------------------------------
   Column 2 — hero card (fills the body row; the nav lives in the footer)
   -------------------------------------------------------------------------- */
.bento-main-hero {
  flex: 1 1 auto;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   Topic nav — the footer row's right-hand element, spanning columns 2 and 3
   -------------------------------------------------------------------------- */
.bento-nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: var(--bento-gap);
}
/* Nav AND search buttons are one design (after Notion's cards): a white card
   with a hairline, the icon in a filled circle pinned to the top-left, the
   caption left-aligned and pinned to the BOTTOM. The padding is EQUAL on all four
   sides and `justify-content: space-between` hands whatever height is left to
   the gap between icon and caption — so the space above the circle always
   equals the space below the caption, whether the caption is one line or two.
   It also lines the circles up along the top of the row and the captions along
   the bottom.

   NOT CLIENT-THEMEABLE. The selectors are (0,3,0) on purpose: older client
   custom2.css files style these buttons with (0,2,0) rules
   (`.bento-nav-btn.bento-nav-<topic> { background-color }`,
   `.bento-nav-btn.is-active { box-shadow }`, `.bento-grid-footer
   .bento-search-btn { … }`) and load AFTER this file, so anything weaker would
   lose to them. Colour comes from config instead: bento_topic_nav() sets
   --bento-nav-color per button from config$style$charts$palette (cycled), and
   the active ring uses the neutral --bento-nav-active.
   Every responsive override of these buttons below must use the SAME selectors,
   or this base rule beats it.

   Height budget (two-line caption, the worst case): 14px padding + 28px circle +
   6px minimum gap + 2 × 1rem × 1.1 (≈35.2px) + 14px padding ≈ 97.2 → 98px =
   --bento-btn-h. A one-line caption leaves a ~24px gap. Any caption that would
   overflow this budget breaks the equal-padding promise, so re-check it if the
   circle, caption size or padding change (the caption's flex-shrink: 0 makes an
   overflow eat into the bottom padding rather than clip the second line). */
.bento-widget .bento-nav .bento-nav-btn,
.bento-widget .bento-grid-footer .bento-search-btn {
  min-width: 0;                   /* beat a <button>'s automatic minimum size */
  height: var(--bento-btn-h);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between; /* icon top, caption bottom; spare height between */
  gap: 6px;                       /* the MINIMUM icon-to-caption space */
  overflow: hidden;
  border: none;
  border-radius: var(--bento-radius);
  padding: 14px;                  /* equal all round; inside the explicit height */
  cursor: pointer;
  text-align: left;
  color: #52606d;
  background: #ffffff;
  /* Inset, like every bento button ring: costs no layout. */
  box-shadow: 0 0 0 1px var(--bento-border) inset;
  transition: color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.bento-widget .bento-nav .bento-nav-btn { flex: 1 1 0; }
/* Hover and active RESTATE the hairline: box-shadow doesn't cascade per layer. */
.bento-widget .bento-nav .bento-nav-btn:hover,
.bento-widget .bento-grid-footer .bento-search-btn:hover {
  color: #1f2933;
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px var(--bento-border) inset, 0 6px 16px rgba(31, 41, 51, 0.12);
}
.bento-widget .bento-nav .bento-nav-btn.is-active {
  color: #1f2933;
  box-shadow: 0 0 0 2px var(--bento-nav-active) inset;
}
.bento-widget .bento-nav .bento-nav-btn.is-active:hover {
  box-shadow: 0 0 0 2px var(--bento-nav-active) inset, 0 6px 16px rgba(31, 41, 51, 0.12);
}
.bento-widget .bento-nav .bento-nav-btn:focus-visible,
.bento-widget .bento-grid-footer .bento-search-btn:focus-visible {
  outline: 2px solid var(--bento-accent);
  outline-offset: 2px;
}

/* The icon circle. Nav: the button's palette colour (inline --bento-nav-color,
   falling back to the accent when no palette is configured). Search: light grey. */
.bento-nav-icon,
.bento-search-btn-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem !important;   /* the glyph: fa() sizes its svg in em */
  line-height: 1 !important;
}
.bento-nav-icon {
  color: #ffffff;
  background: var(--bento-nav-color, var(--bento-accent));
}
.bento-search-btn-icon {
  color: #52606d;
  background: #eceff1;
}

/* Long captions ("Workforce Outlook", fr "Perspectives de la main-d'œuvre") get a
   SECOND line rather than an ellipsis; the height budget above is sized for two.
   Clamped at two so a caption can never grow the button. */
.bento-nav-label,
.bento-search-btn-label {
  max-width: 100%;
  font-size: 1rem !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  text-align: left;
  line-height: 1.1 !important;
  /* Never squeezed by the flex column: `overflow: hidden` would otherwise let it
     shrink below two lines and clip the second one at the baseline. */
  flex-shrink: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;          /* last resort: wrap, never spill */
}

/* --------------------------------------------------------------------------
   Column 3 — one card (grow) over a row of two cards
   -------------------------------------------------------------------------- */
.bento-side-top {
  flex: 1.1 1 0;
  min-height: 0;
}
.bento-side-bottom {
  flex: 1 1 0;
  display: flex;
  gap: var(--bento-gap);
  min-height: 0;
}
.bento-side-cell {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   Bento cards + frosted glass
   -------------------------------------------------------------------------- */
.bento-card {
  position: relative;
  height: 100%;
  border-radius: var(--bento-radius);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--bento-border);
  cursor: pointer;
}

/* The actual card content (navset + chart) lives here */
.bento-card-frost {
  position: relative;
  height: 100%;
}
.bento-card-frost .bslib-card,
.bento-card-frost .card {
  height: 100% !important;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 15px;
}

/* Frost overlay: sits ON TOP of the content (so a click on a collapsed card
   lands on the card, not the chart) and veils it LIGHTLY. Every collapsed card —
   hero and column 3 alike — shows its live chart through this, which is what
   tells users there is a chart to open. Strength lives in --bento-frost-veil /
   --bento-frost-blur on .bento-widget.
   (0,2,1), not (0,1,1): older client custom2.css files carry a
   `.bento-card-frost::after { background: … }` tint (0,1,1) that loads after
   this file and would otherwise win, tinting some cards and not others. */
.bento-card .bento-card-frost::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--bento-frost-veil);
  -webkit-backdrop-filter: blur(var(--bento-frost-blur));
  backdrop-filter: blur(var(--bento-frost-blur));
  transition: backdrop-filter 0.2s ease, background 0.2s ease;
}

/* Heading hint sits ABOVE the frost, anchored to the BOTTOM of the card */
.bento-card-heading {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 20px 18px 33px 33px;
  pointer-events: none;
}
/* The plate behind the heading: flat 80% white with a crisp hairline top edge
   in the tiles' own --bento-border, so it reads as a panel laid over the chart
   rather than part of it. On a pseudo-element (not the heading's background) so
   z-index: -1 keeps it behind the heading text but above the frost. The
   border-top is safe here: the pseudo is absolutely positioned, so it costs no
   layout (unlike a border on a tile — see .bento-card). */
.bento-card-heading::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: rgba(240, 240, 240, 0.8);
}
.bento-card-heading-primary {
  font-size: 1.9rem !important;
  font-weight: 800 !important;
  color: #1f2933;
  line-height: 1.1 !important;
}
.bento-card--frosted .bento-card-heading-primary {
  font-size: 1.7rem !important;
}
.bento-card-heading-secondary {
  margin-top: 4px;
  font-size: 1rem !important;
  font-weight: 600 !important;
  color: #3E4C59;
  opacity: 0.85;
}

/* Hover "twitch" hint that the card is interactive */
@keyframes bento-twitch {
  0%   { transform: scale(1) rotate(0deg); }
  30%  { transform: scale(1.012) rotate(-0.3deg); }
  60%  { transform: scale(1.012) rotate(0.3deg); }
  100% { transform: scale(1) rotate(0deg); }
}
/* Every box-shadow below RESTATES the hairline: box-shadow doesn't cascade
   per-layer, so omitting it here would drop the outline on hover/expand. */
.bento-card:not(.bento-expanded):hover {
  animation: bento-twitch 0.4s ease;
  box-shadow: 0 0 0 1px var(--bento-border), 0 8px 24px rgba(31, 41, 51, 0.18);
}

/* --------------------------------------------------------------------------
   Expanded state — fills the widget area only
   -------------------------------------------------------------------------- */
.bento-card.bento-expanded {
  position: absolute;
  inset: 0;
  /* Above .panel-controls (z-index 1450, cityviz.css): the Location topic's map
     controls share this stacking context — no ancestor between them creates one
     — and would otherwise paint on top of the expanded search card. */
  z-index: 1500;
  height: auto;
  cursor: default;
  /* INSET here, unlike the collapsed hairline: an expanded card is inset:0 against
     .bento-widget, so an outset ring would paint 1px outside the widget's box (and
     get shaved by a flush iframe edge). The frost is hidden in this state, so an
     inset ring is visible. */
  box-shadow: 0 0 0 1px var(--bento-border) inset, 0 12px 40px rgba(31, 41, 51, 0.28);
}
.bento-card.bento-expanded .bento-card-frost::after {
  display: none;            /* remove frost so content is interactive */
}
.bento-card.bento-expanded .bento-card-heading {
  display: none;            /* hide the hint; real tab pills are now visible */
}

/* Collapsed secondary cards are chart-only teasers: hide the information column
   so the chart fills the card and every box keeps a constant height. The hero
   keeps its interpretation visible. On expand
   the column is revealed automatically (the :not(.bento-expanded) stops matching). */
.bento-card--frosted:not(.bento-expanded) .bento-interp {
  display: none;
}

/* The hero keeps a HINT of its interpretation while collapsed. Pin the prose to
   a constant few-line height (faded at the bottom) so the hero's height no
   longer depends on how long each topic's interpretation is — varying prose
   length is what still made the grid bounce. The full text shows on expand. */
.bento-card--hero:not(.bento-expanded) .bento-interp-text {
  height: 4.6em;            /* ~3 lines of the 0.85rem interp text — constant */
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent);
          mask-image: linear-gradient(to bottom, #000 60%, transparent);
}

/* Expanded cards reveal the full interpretation; let it scroll if it's long. */
.bento-card.bento-expanded .bento-interp {
  overflow-y: auto;
}

.bento-close {
  display: none;
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 60;
  width: 34px;
  height: 34px;
  line-height: 30px;
  text-align: center;
  font-size: 1.5rem !important;
  border-radius: 50%;
  background: rgba(31, 41, 51, 0.08);
  color: #1f2933;
  cursor: pointer;
}
.bento-close:hover { background: rgba(31, 41, 51, 0.18); }
.bento-card.bento-expanded .bento-close { display: block; }

/* --------------------------------------------------------------------------
   Panel tabs — an underline strip, not Bootstrap's folder tabs

   THREE SELECTOR SHAPES, on purpose. navset_card_tab() emits BS3 markup
   (`ul.nav-tabs > li.active > a`, no .nav-item/.nav-link anywhere) and bslib's
   bs3compat Sass @extends the BS5 rules onto it, so the compiled stylesheet
   carries `.nav-link`, `.nav-tabs>li>a` AND `.card-header-tabs .nav-tabs>li>a.active`
   variants of every rule. Which one is live depends on whether .active sits on the
   <li> (server render) or on the <a> (after bs3compat's tab plugin runs). Matching
   all three is what stops a second underline appearing once a tab is clicked.

   Every selector here leads with .bento-widget .bento-card, i.e. (0,3,x) or more,
   which clears Bootstrap's (0,2,1)-and-below AND the client's
   `.content-embed .card-header` (0,2,0) in custom2.css. Fonts carry !important
   per this file's typography lock: custom2.css sets --bs-nav-link-font-size /
   -font-weight / -color, which the anchors would otherwise inherit.
   -------------------------------------------------------------------------- */
.bento-widget .bento-card .card-header {
  padding: 0;
  margin-bottom: 14px;
  background: transparent;
  border-bottom: none;
  border-radius: 0;
}
.bento-widget .bento-card .nav-tabs.card-header-tabs,
.bento-widget .bento-card .nav-tabs {
  margin: 0;
  gap: 10px;
  /* Restated because .card-header-tabs zeroes it; this hairline is the strip the
     active tab's 3px underline sits on. */
  /*border-bottom: 1px solid var(--bento-border);*/
  border-bottom: 1px solid transparent;
}
.bento-widget .bento-card .nav-tabs > li > a,
.bento-widget .bento-card .nav-tabs .nav-link {
  margin: 0 0 -1px 0;        /* pull the underline down ONTO the strip's hairline */
  padding: 4px 6px 12px;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #52606d;
  font-size: 1rem !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.bento-widget .bento-card .nav-tabs > li > a:hover,
.bento-widget .bento-card .nav-tabs .nav-link:hover {
  color: #1f2933;
  border-color: transparent transparent var(--bento-border);
}
.bento-widget .bento-card .nav-tabs > li.active > a,
.bento-widget .bento-card .nav-tabs > li > a.active,
.bento-widget .bento-card .nav-tabs .nav-link.active {
  color: var(--bento-accent);
  background: transparent;
  border-color: transparent transparent var(--bento-accent);
}
/* Bootstrap's own focus ring on these anchors is a blue glow, which lands next to
   the accent underline; match the tool buttons' ring instead. */
.bento-widget .bento-card .nav-tabs > li > a:focus-visible,
.bento-widget .bento-card .nav-tabs .nav-link:focus-visible {
  outline: 2px solid var(--bento-accent);
  outline-offset: -2px;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
   Chart + interpretation split inside each panel
   -------------------------------------------------------------------------- */
.bento-panel-split {
  display: flex;
  gap: 16px;
  height: 100%;
  min-height: 0;
}
.bento-panel-chart {
  position: relative;          /* anchor for the data-table overlay */
  flex: 2 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* Hairline frame round the chart, EXPANDED ONLY — that is the state the user
   sees the frame in. Under a collapsed card's frost a frame would only show up
   as a ghost box competing with the card's own outline.
   Padding keeps plotly's axis labels off the frame; the data-table overlay's
   `inset: 0` resolves against the PADDING box, so it covers that padding but
   leaves the frame visible — hence both share --bento-panel-radius. */
.bento-card.bento-expanded .bento-panel-chart {
  /*border: 1px solid var(--bento-border);*/
  border: 1px solid transparent;
  border-radius: var(--bento-panel-radius);
  padding: 10px;
}
.bento-panel-chart-canvas {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* Let a SINGLE chart/map fill the panel height, so it grows with the card when
   expanded. The fixed pixel height set by plotlyOutput() is overridden here.
   :only-child means KPI-gauge stacks (multiple widgets in one panel) are left
   at their fixed heights; if a panel doesn't match, it just keeps today's size. */
.bento-panel-chart-canvas > .html-widget:only-child {
  flex: 1 1 0;
  height: 100% !important;   /* beats the inline height:300px from plotlyOutput() */
  min-height: 0;
}

/* MapLibre maps: own stacking context, so the legend (z-index 1002 in mapgl's
   CSS), popups and controls stay inside the map and the collapsed card's frost
   (z-index 2) and heading (3) still cover them. */
.bento-panel-chart-canvas .maplibregl-map,
.cv-getting-around {
  isolation: isolate;
}

/* Commute → Getting around: the map sits in a wrapper with a mode switch
   overlaid, so the wrapper takes the single-widget fill above and passes it on
   to the map. */
.cv-getting-around {
  position: relative;
  display: flex;
  flex-direction: column;
}
.bento-panel-chart-canvas > .cv-getting-around:only-child {
  flex: 1 1 0;
  min-height: 0;
}
.cv-getting-around > .html-widget {
  flex: 1 1 0;
  height: 100% !important;
  min-height: 0;
}
/* Mode switch: Shiny radioButtons (label > input + span) drawn as a joined
   button group; the checked radio's span carries the active colour. Top-left,
   clear of the zoom controls (top-right). Selectors go through
   .shiny-input-container to outrank bslib's BS5 form-check rules, which target
   `.shiny-input-container .radio-inline` (inline margin, start padding, floated
   input) regardless of stylesheet order. */
.cv-getting-around-modes {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
}
.cv-getting-around-modes .shiny-input-container {
  width: auto;
  margin: 0;
}
.cv-getting-around-modes .control-label { display: none; }
.cv-getting-around-modes .shiny-input-container .shiny-options-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin: 0;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.cv-getting-around-modes .shiny-input-container .radio-inline {
  position: relative;
  display: block;
  margin: 0;
  padding: 0;
}
.cv-getting-around-modes .shiny-input-container .radio-inline input[type="radio"] {
  position: absolute;
  float: none;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.cv-getting-around-modes .radio-inline span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: #333;
  background: #fff;
  border: 1px solid var(--bento-border);
  cursor: pointer;
  white-space: nowrap;
}
.cv-getting-around-modes .radio-inline + .radio-inline span { border-left: 0; }
.cv-getting-around-modes .radio-inline:first-child span { border-radius: 6px 0 0 6px; }
.cv-getting-around-modes .radio-inline:last-child span { border-radius: 0 6px 6px 0; }
.cv-getting-around-modes .radio-inline span:hover { background: #f5f5f5; }
.cv-getting-around-modes input[type="radio"]:checked + span {
  color: #fff;
  background: var(--bento-accent);
  border-color: var(--bento-accent);
}
.cv-getting-around-modes input[type="radio"]:focus-visible + span {
  outline: 2px solid var(--bento-accent);
  outline-offset: 2px;
}

/* Right-hand information column: top-aligned stack of title, interpretation,
   tools, reference, and the bottom-right "Powered by CityViz" credit. */
.bento-interp {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;        /* clip an over-long interpretation; never grow the card */
  display: flex;
  flex-direction: column;
  align-self: stretch;
  font-size: 0.85rem !important;
  color: #52606d;
  line-height: 1.45 !important;
}
.bento-interp-title {
  font-size: 1.4rem !important;
  font-weight: 800 !important;
  line-height: 1.15 !important;
  color: #1f2933;
  margin-bottom: 10px;
}
.bento-interp-text { margin-bottom: 14px; font-size: 16px !important; }
.bslib-card .card-body .bento-interp-text p:last-child { margin-bottom: 0; }

/* Tools row: outlined "Data table" + "Download chart" buttons.
   WRAPS on purpose. .bento-interp is `flex: 1 1 0` against the chart's `flex: 2 1 0`
   and clips (`overflow: hidden`), so in a narrow widget the two buttons exceed the
   column and the second would be sliced off rather than pushed to a new line. */
.bento-chart-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  row-gap: 8px;
  margin-bottom: 18px;
  margin-top: 2rem;
}
.bento-chart-tool {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  /* Wrapping the ROW can't rescue a single button that is wider than the column;
     these let one shrink and wrap its own label instead of overflowing. Measured
     at a 600px widget: "Download chart" is 163px in a 167px column — it fits, but
     with 4px to spare, so a longer translation or a client font would clip. */
  max-width: 100%;
  min-width: 0;              /* beat a <button>'s automatic minimum size */
  border: 1px solid var(--bento-border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  cursor: pointer;
  color: #1f2933;
  background: #e6e6e6;
  transition: color 0.15s ease, background-color 0.15s ease,
              border-color 0.15s ease, transform 0.15s ease;
}
/* fontawesome::fa() sets fill:currentColor and height inline, so the glyph tracks
   the label's colour on hover with no rule of its own; it only needs to be kept
   from shrinking when a long label wraps. */
.bento-chart-tool svg { flex: 0 0 auto; }
.bento-chart-tool:hover {
  background: #f5f7fa;
  border-color: rgba(31, 41, 51, 0.28);
  transform: translateY(-1px);
}
.bento-chart-tool:focus-visible { outline: 2px solid var(--bento-accent); outline-offset: 2px; }

/* Reference block (data source / region / period) */
.bento-interp-reference {
  padding-top: 16px;
  font-size: 0.72rem !important;
  line-height: 1.4 !important;
  color: #7b8794;
}
.bento-interp-reference .references p { margin-bottom: 2px; }
.bento-interp-reference .references strong { color: #52606d; }

/* Per-card credit, pushed to the bottom-right of the column */
.bento-panel-powered {
  margin-top: auto;
  padding-top: 10px;
  text-align: right;
  font-size: 0.75rem !important;
  line-height: 1.2 !important;
  color: #9aa5b1;
}
.bento-panel-powered a { color: #9aa5b1; text-decoration: none; }
.bento-panel-powered a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Data-table overlay (accessible alternative to the chart)
   -------------------------------------------------------------------------- */
.bento-data-table-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  background: #ffffff;
  border-radius: var(--bento-panel-radius);   /* must match the chart frame */
  overflow: hidden;
}
.bento-data-table-overlay.is-open { display: block; padding-top: 25px; }
.bento-data-table-scroll {
  height: 100%;
  overflow: auto;
  padding: 8px 14px 14px;
}
.bento-table-close {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 5;
  width: 30px;
  height: 30px;
  line-height: 26px;
  text-align: center;
  font-size: 1.4rem !important;
  border: none;
  border-radius: 50%;
  background: rgba(31, 41, 51, 0.08);
  color: #1f2933;
  cursor: pointer;
}
.bento-table-close:hover { background: rgba(31, 41, 51, 0.18); }

.bento-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem !important;
  color: #1f2933;
}
.bento-data-table caption {
  text-align: left;
  font-weight: 700 !important;
  padding: 4px 0 10px;
  color: #1f2933;
}
.bento-data-table th,
.bento-data-table td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid #e4e7eb;
  white-space: nowrap;
}
.bento-data-table thead th { border-bottom: 2px solid #cbd2d9; }
.bento-data-table th[scope="col"]:first-child,
.bento-data-table th[scope="row"],
.bento-data-table td:first-child {
  text-align: left;
}
.bento-data-table th[scope="row"] { font-weight: 600 !important; }

/* Tab pills under frost get a little breathing room below the heading */
.bento-card .bslib-navs-card-title .nav {
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Search button (grid footer, left of the topic nav) + search card overlay
   -------------------------------------------------------------------------- */
/* The search button shares the nav buttons' look (see .bento-nav-btn above —
   same card, a light-grey icon circle); only its width is set here. The 14%
   basis puts the nav's left edge exactly on column 2's (see .bento-grid-footer),
   and the min-width: 0 in the shared rule is load-bearing — a <button>'s
   automatic minimum size would otherwise push it past 14% at narrow widths. */
.bento-widget .bento-grid-footer .bento-search-btn {
  flex: 0 0 14%;
}

/* The search card is hidden until the search button expands it. The generic
   .bento-card.bento-expanded rules above supply the absolute overlay + the
   visible close (×); we only toggle visibility and let the body scroll. */
.bento-search-card { display: none; }
.bento-search-card.bento-expanded { display: block; }
.bento-search-card .bento-search-body {
  height: 100%;
  overflow-y: auto;
  padding: 28px;
}

/* --------------------------------------------------------------------------
   "Powered by CityViz" credit — bottom-right of the widget
   -------------------------------------------------------------------------- */
.bento-powered-by {
  text-align: right;
  padding: 8px 14px 0;
  font-size: 0.75rem !important;
  line-height: 1.2 !important;
  color: #9aa5b1;
}
.bento-powered-by a {
  color: #8f9ba8;
  text-decoration: none;
}
.bento-powered-by a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Responsive — as the widget narrows, scale a few elements down so the layout
   stays legible WITHOUT changing the column layout (only the footer row gets
   shorter, to keep the nav buttons' proportions). Queried against the
   .bento-widget container (see container-type above) so it reacts to the
   WIDGET's own width — embedded in an iframe or sitting beside other content in
   the app — not the viewport.

   Two tiers (≤960px, then a tighter ≤680px) each shrink:
     • side-bottom card titles — the two narrowest cards, whose long single-word
       titles ("Ethnicity", "Languages") would otherwise clip. Scoped to
       .bento-side-bottom so the wider side-top card and the column-2 hero keep
       their full size. We deliberately keep these two cards side-by-side rather
       than stacking them: stacking made column 3 hold three cards that spilled
       past the fixed-height grid and overlapped the nav row.
     • nav/search captions and icon circles — smaller, with tighter horizontal
       padding, so the captions don't crowd when the row is tight. These can
       never change the buttons' HEIGHT: .bento-nav-btn and .bento-search-btn
       both carry an explicit --bento-btn-h (their padding sits inside it), which
       is what keeps the footer row level at every width. The overrides use the
       base rule's (0,3,0) selectors, which they must match to win.
     • value-box values (.bento-vbox-value) — smaller/lighter so the big numbers
       don't dominate the narrowed value column.
   -------------------------------------------------------------------------- */
@container bento (max-width: 960px) {
  /* Drop the big left/right indent and trim the title so "Ethnicity" /
     "Languages" keep fitting their half-width cells — they start clipping at
     ~1.7rem well before 800px. */
  .bento-side-bottom .bento-card-heading {
    padding: 20px 14px 30px 16px;
  }
  .bento-side-bottom .bento-card-heading-primary {
    font-size: 1.4rem !important;
    overflow-wrap: break-word;   /* last resort: wrap, never hard-clip */
  }
  .bento-side-bottom .bento-card-heading-secondary {
    font-size: 0.9rem !important;
  }
  /* Nav/search captions: smaller, with tighter padding — still equal on all four
     sides, so the space-between gap absorbs the freed height. */
  .bento-nav-label,
  .bento-search-btn-label { font-size: 0.78rem !important; }
  .bento-widget .bento-nav .bento-nav-btn,
  .bento-widget .bento-grid-footer .bento-search-btn { padding: 10px; }
  /* …and a shorter footer to match, or the space-between gap would swell to
     ~30px. Budget: 10 + 28 circle + 6 + 2 × 0.78rem × 1.1 (≈27.5) + 10 ≈ 82 → 84.
     Set on the widget's CHILDREN (a container can't match its own query), so the
     grid height follows; the widget's own min-height keeps the 98px figure, which
     the grid + credit still clear. */
  .bento-widget > * { --bento-btn-h: 84px; }
  /* Value-box numbers: smaller/lighter so they don't dominate the narrow column. */
  .bento-vbox-value {
    font-size: 1.35rem !important;   /* 0.9 × the 1.5rem base */
    font-weight: 700 !important;
  }
}

/* Tighter tier: same elements as ≤960px, shrunk further for very narrow widgets
   (only the changed properties are restated; the rest cascade from ≤960px). */
@container bento (max-width: 680px) {
  .bento-side-bottom .bento-card-heading {
    padding: 18px 12px 26px 14px;
  }
  .bento-side-bottom .bento-card-heading-primary {
    font-size: 0.85rem !important;
  }
  .bento-side-bottom .bento-card-heading-secondary {
    font-size: 0.82rem !important;
  }
  /* Smaller circles and captions, tighter padding: Workforce Profile's six
     buttons are ~86px each at this width, and the search button's 14% is only
     ~95px — tight enough that its automatic minimum size could otherwise push it
     past 14% and pull the nav's left edge off column 2. */
  .bento-nav-label,
  .bento-search-btn-label { font-size: 0.7rem !important; }
  .bento-nav-icon,
  .bento-search-btn-icon {
    width: 24px;
    height: 24px;
    font-size: 0.8rem !important;
  }
  .bento-widget .bento-nav .bento-nav-btn,
  .bento-widget .bento-grid-footer .bento-search-btn { padding: 8px; }
  /* 8 + 24 circle + 6 + 2 × 0.7rem × 1.1 (≈24.6) + 8 ≈ 71 → 72. */
  .bento-widget > * { --bento-btn-h: 72px; }
  .bento-vbox-value {
    font-size: 1.2rem !important;    /* 0.8 × the 1.5rem base */
    font-weight: 600 !important;
  }
}

/* --------------------------------------------------------------------------
   Stacked tier (≤600px) — the phone layout. Unlike the two tiers above, this
   one DOES change the grid geometry: at this width three columns can't hold
   readable cards, so everything stacks in one column.

   600px matches the legacy phone breakpoint in cityviz.css (whose link-list
   swap bento widgets opt out of — see the rule near the top of this file).

   The footer is `position: sticky`, which pins it only where THIS document
   scrolls, i.e. when the widget is opened top-level. Inside a client's embed
   iframe it can't: iframe-resizer sizes the iframe to its content, so the
   iframe never scrolls. There bento.js emulates sticky instead (placeFooters):
   embed-cityviz.js on the host page reports where the iframe sits in its
   viewport, and the JS translates the footer to the bottom of the visible part
   of the iframe. A raw iframe without embed-cityviz.js gets none of that — the
   footer just sits at the end of the stack.

     • quick facts — one row of four, divided by hairlines;
     • cards — full width, one per row, each collapsed card a fixed-height teaser;
     • footer — a sticky tab bar (search pill + topic buttons, icon over label);
     • an expanded card grows IN PLACE in the stack (bento.js scrolls it into
       view) and reads top-to-bottom: tabs, title, chart, interpretation, tools,
       reference — instead of the desktop chart | info-column split;
     • the search card opens as a full-screen sheet.

   Typography keeps `!important`, per the lock at the top of this file; the
   ≤680px values it overrides are `!important` too and lose on source order.
   -------------------------------------------------------------------------- */
@container bento (max-width: 600px) {
  /* The stacked-layout signal for bento.js (isStacked), so the JS never
     duplicates this breakpoint. A container can't match its own query, so it
     goes on the widget's children; it inherits down to every card and footer. */
  .bento-widget > * { --bento-stacked: 1; }

  /* ---- Grid: one column, content-driven height ---------------------------- */
  .bento-grid { height: auto; }
  .bento-grid-body { flex: none; flex-direction: column; }
  .bento-col-values-wrap,
  .bento-col-main,
  .bento-col-side,
  .bento-col-main-wide,
  .bento-main-hero,
  .bento-side-top,
  .bento-side-bottom,
  .bento-side-cell {
    flex: none;
  }
  .bento-side-bottom { flex-direction: column; }

  /* Teaser heights live on the CARD, not its wrapper, so an expanded card can
     grow (the wrappers are auto-height above). */
  .bento-main-hero > .bento-card:not(.bento-expanded) { height: 240px; }
  .bento-col-side .bento-card:not(.bento-expanded)    { height: 200px; }

  /* Collapsed cards are chart-only teasers here — the hero too. Its info column
     can't fit beside the chart at this width (it broke "Families by Size" into
     one word per line); the full text shows on expand. */
  .bento-card:not(.bento-expanded) .bento-interp { display: none; }

  /* Every card is full-width now, so undo the ≤680px shrink that sized the
     side-bottom titles for half-width cells. */
  .bento-card-heading,
  .bento-side-bottom .bento-card-heading {
    padding: 16px 16px 20px 20px;
  }
  .bento-card-heading-primary                 { font-size: 1.6rem !important; }
  .bento-card--frosted .bento-card-heading-primary { font-size: 1.5rem !important; }
  .bento-card .bento-card-heading-secondary   { font-size: 0.95rem !important; }

  /* The Location map surface: no row height to fill any more. */
  .bento-main-full { flex: none; height: 420px; }

  /* ---- Quick facts: one row of four --------------------------------------- */
  .bento-col-values {
    flex-direction: row;
    gap: 0;
    padding: 14px 4px;
  }
  .bento-vbox {
    flex: 1 1 0;
    min-width: 0;
    justify-content: flex-start;
    gap: 2px;
    padding: 0 6px;
  }
  .bento-vbox + .bento-vbox {
    padding-top: 0;
    border-left: 1px solid var(--bento-border);
  }
  .bento-vbox-icon { font-size: 1.1rem !important; }
  .bento-vbox-value {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
  }
  /* Wrap freely, no clamp: the row is content-height now, so a long (fr) label
     grows the row rather than being cut off. */
  .bento-vbox-label {
    font-size: 0.7rem !important;
    line-height: 1.2 !important;
    overflow-wrap: break-word;
  }

  /* ---- Footer: sticky tab bar --------------------------------------------- */
  /* z-index clears the Location map's .panel-controls (1450) and stays under the
     search sheet (2000). Expanded cards drop to z-index: auto below, so the bar
     also paints over a card scrolled beneath it. */
  .bento-grid-footer {
    --bento-btn-h: 52px;
    position: sticky;
    bottom: 0;
    z-index: 1460;
    flex: none;
    gap: 6px;
    padding: 8px;
    background: #ffffff;
    border-radius: var(--bento-radius) var(--bento-radius) 0 0;
    box-shadow: 0 -6px 18px rgba(31, 41, 51, 0.12);
  }
  /* Unwrap the nav so the search pill and every topic button are siblings and
     share the bar equally (up to 7: Workforce Profile + Outlook + search). */
  .bento-grid-footer .bento-nav { display: contents; }
  /* A tab bar: centred, unlike the left-aligned desktop cards, but with the same
     equal padding + space-between. (0,3,0) to match the base rule.
     6px + 22px circle + 3px min gap + one ~12px line + 6px ≈ 49px, inside the
     52px bar height. */
  .bento-widget .bento-grid-footer .bento-search-btn,
  .bento-widget .bento-nav .bento-nav-btn {
    flex: 1 1 0;
    align-items: center;
    gap: 3px;
    padding: 6px;
    border-radius: 12px;
    text-align: center;
  }
  /* Touch layout: no hover lift (it sticks after a tap on mobile browsers). */
  .bento-widget .bento-grid-footer .bento-search-btn:hover,
  .bento-widget .bento-nav .bento-nav-btn:hover {
    transform: none;
  }
  .bento-nav-icon,
  .bento-search-btn-icon {
    width: 22px;
    height: 22px;
    font-size: 0.75rem !important;
  }
  /* One line with an ellipsis; the button's `title` carries the full caption. */
  .bento-nav-label,
  .bento-search-btn-label {
    display: block;
    max-width: 100%;
    font-size: 0.65rem !important;
    line-height: 1.15 !important;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ---- Expanded card: in place, single column ----------------------------- */
  /* Not an overlay any more: the card stays in the stack and grows to its
     content. z-index: auto (not 1500) so the sticky footer paints over it. */
  .bento-card.bento-expanded {
    position: relative;
    inset: auto;
    z-index: auto;
    height: auto;
    box-shadow: 0 0 0 1px var(--bento-border), 0 8px 24px rgba(31, 41, 51, 0.14);
  }
  .bento-card.bento-expanded .bento-card-frost { height: auto; }
  /* margin-bottom: bslib's .bslib-mb-spacing (1.5rem) is trapped inside the
     card by its overflow: hidden — invisible at a fixed height, a blank strip
     under the content at an auto one. */
  .bento-card.bento-expanded .bento-card-frost .card {
    height: auto !important;
    margin-bottom: 0;
  }
  /* Keep the tab strip clear of the × button. */
  .bento-widget .bento-card.bento-expanded .card-header { padding-right: 44px; }

  /* Order: title → chart → interpretation → tools → reference → credit. The
     info column is unwrapped (display: contents) so its children become items of
     the split, and the title is pulled ahead of the chart. bento.js still finds
     everything through .bento-panel-split / .bento-interp-title. */
  .bento-card.bento-expanded .bento-panel-split {
    flex-direction: column;
    gap: 14px;
    height: auto;
  }
  .bento-card.bento-expanded .bento-interp { display: contents; }
  .bento-card.bento-expanded .bento-interp-title {
    order: -1;
    margin-bottom: 0;
  }
  /* A DEFINITE chart height: under the auto-height chain above, the base
     `height: 100% !important` would resolve to nothing and collapse Plotly.
     Multi-widget canvases (KPI gauge stacks) keep their natural heights. */
  .bento-card.bento-expanded .bento-panel-chart {
    flex: none;
    min-height: 320px;
    padding: 0;
  }
  .bento-card.bento-expanded .bento-panel-chart-canvas { flex: none; }
  .bento-card.bento-expanded .bento-panel-chart-canvas > .html-widget:only-child {
    flex: none;
    height: 320px !important;
  }
  .bento-card.bento-expanded .bento-panel-chart-canvas > .cv-getting-around:only-child {
    flex: none;
    height: 320px;
  }
  /* The split's gap now does the spacing these did in the desktop column. */
  .bento-card.bento-expanded .bento-interp-text { margin-bottom: 0; }
  .bento-card.bento-expanded .bento-chart-tools { margin: 0; }
  .bento-card.bento-expanded .bento-interp-reference { padding-top: 0; }
  .bento-card.bento-expanded .bento-panel-powered {
    margin-top: 0;
    padding-top: 0;
  }

  /* ---- Search: a full-screen sheet ---------------------------------------- */
  /* Restates the overlay for the search card only (same specificity as the
     in-place rule above, so it wins on order). Opened from the sticky bar while
     scrolled anywhere in the stack, so it must cover the screen, not the top
     of a tall widget. */
  .bento-search-card.bento-expanded {
    position: fixed;
    inset: 0;
    z-index: 2000;
    height: auto;
    border-radius: 0;
  }
  .bento-search-card .bento-search-body { padding: 52px 16px 16px; }
}
