/* =========================================
   BREADCRUMB
   =========================================
   Behavior: registry-driven trail rendered into the topbar.
   Visual: Untitled-UI-style — single thin row, all segments
   equally weighted, chevron-right separators between them.
   Replaces what used to be the page title in the header.
*/

/* ─── Root + desktop list (md+) ─────────── */

.dmu-bc-root {
    display: flex;
    align-items: center;
    min-width: 0;
}

.dmu-bc-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    /* line-height: 1 collapses Bootstrap's body line-height (~19.6px)
       inherited from <body>, so the inline formatting context inside
       the <ul> doesn't add a phantom 5-6px tall line-box that would
       offset <li> baselines relative to each other. */
    line-height: 1;
}

.dmu-bc-item {
    display: inline-flex;
    align-items: center;
    position: relative;
}

/* Leaf segment truncates with ellipsis when its label exceeds 50ch.
   Ancestor segments stay full so the trail's structure is always
   readable; only the current page's name (often the longest, since
   it can be a freeform entity name) is allowed to clip. The label's
   own max-width drives the ellipsis — flex-shrink/min-width on the
   item make the leaf shrinkable in case the row is constrained, even
   though the cap on the label is what triggers the ellipsis in the
   common case. Ancestor items inherit the default flex-shrink: 1 but
   their .dmu-bc-link has white-space: nowrap with no overflow rule,
   so they push the row width rather than truncating. */
.dmu-bc-list .dmu-bc-item:last-child {
    min-width: 0;
    flex-shrink: 1;
}

.dmu-bc-list .dmu-bc-item:last-child .dmu-bc-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50ch;
}

/* ─── Segment link ─────────── */

.dmu-bc-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--body, #1f2937);
    font-size: 0.875rem;
    font-weight: 500;
    /* line-height: 1 collapses the text line-box to font-size so the
       text segment's height matches the home-icon segment's height
       within rounding error. Without this, the inherited 1.4 line-height
       inflates text segments by ~5px and the list's align-items: center
       has nothing to do because the row's vertical center isn't where
       the text's optical center sits. */
    line-height: 1;
    /* Multi-property transition so the primary-color hover shift on
       linkable segments (rule below) animates smoothly along with the
       existing background-color fade. */
    transition: background-color 120ms ease, color 120ms ease;
    white-space: nowrap;
}

.dmu-bc-link:hover,
.dmu-bc-link:focus {
    text-decoration: none;
}

.dmu-bc-label {
    display: inline-block;
    /* Assert line-height: 1 on the span itself, not just on the link
       parent. Some upstream CSS (Bootstrap typography defaults, or
       inherited body line-height) can re-inflate the span's line-box
       even when the link is line-height: 1, which pushes the text
       baseline below where the flex center would put a 14px box. */
    line-height: 1;
}

/* Hover affordance only on segments with sibling-jump enabled. Static
   segments and the leaf without siblings stay visually inert. */
.dmu-bc-item[data-bc-clickable="1"] .dmu-bc-link {
    cursor: pointer;
}

.dmu-bc-item[data-bc-clickable="1"] .dmu-bc-link:hover,
.dmu-bc-item.is-open .dmu-bc-link {
    background: color-mix(in srgb, var(--body, #1f2937) 7%, transparent);
}

/* Hover color shift to brand primary for every segment that links
   somewhere actionable. Two paths in:
     1. :not(:last-child) — every segment EXCEPT the leaf. Home and
        middle segments always navigate to a parent page.
     2. [data-bc-clickable="1"] — any segment with sibling-jump,
        INCLUDING a leaf that has siblings (e.g. a company view page
        where the leaf opens a list of other companies).
   A non-clickable leaf has neither marker and stays inert on hover
   (the global a:hover would normally tint it secondary; we explicitly
   leave that case alone since hovering "you are here" with no
   destination is meaningless).
   The .is-open clause keeps the dropdown's parent segment colored
   while the dropdown is open. The .dmu-bc-label span inside the link
   is targeted explicitly because relying on inheritance was leaving
   the label gray on hover. (0,4,0) class-scoped specificity beats
   the global a:hover (0,1,1). */
.dmu-bc-item:not(:last-child) .dmu-bc-link:hover,
.dmu-bc-item:not(:last-child) .dmu-bc-link:focus,
.dmu-bc-item:not(:last-child) .dmu-bc-link:hover .dmu-bc-label,
.dmu-bc-item:not(:last-child) .dmu-bc-link:focus .dmu-bc-label,
.dmu-bc-item[data-bc-clickable="1"] .dmu-bc-link:hover,
.dmu-bc-item[data-bc-clickable="1"] .dmu-bc-link:focus,
.dmu-bc-item[data-bc-clickable="1"] .dmu-bc-link:hover .dmu-bc-label,
.dmu-bc-item[data-bc-clickable="1"] .dmu-bc-link:focus .dmu-bc-label,
.dmu-bc-item.is-open .dmu-bc-link,
.dmu-bc-item.is-open .dmu-bc-link .dmu-bc-label {
    color: var(--primary, #6f42c1);
}

/* ─── Down-caret next to clickable segments ─────────── */
/* The caret is part of the segment's visual unit — same color as the
   segment text, NOT the muted separator gray. Size matches the
   separator so the row reads as visually consistent. */

.dmu-bc-caret {
    /* !important defeats Lucide's inline width/height attributes on
       the rendered <svg> (the framework injects width="18" height="18"
       which would otherwise win the specificity contest). */
    width: 12px !important;
    height: 12px !important;
    margin-left: 4px;
    color: inherit;
    flex-shrink: 0;
}

/* ─── Separator chevron between segments ─────────── */
/* De-emphasized vs the segment text: smaller than the 14px segment
   font and muted gray. Reads as a connector, not a character. */

.dmu-bc-sep {
    /* !important defeats Lucide's inline width/height attributes on
       the rendered <svg> (the framework injects width="18" height="18"
       which would otherwise win the specificity contest).
       14px matches the segment text size (font-size: 0.875rem ≈ 14px)
       so chevron and label read at the same optical weight. margin: 0
       removes the previous 4px lateral padding — the link's own 8px
       horizontal padding already provides enough breathing room and
       the row reads more compactly without extra chevron margin. */
    width: 14px !important;
    height: 14px !important;
    margin: 0;
    flex-shrink: 0;
    color: var(--muted, #727272);
    /* Override Bootstrap's body line-height (19.6px) inherited via
       .dmu-bc-list -> .dmu-bc-item. The SVG is display: block so
       line-height does not affect its own box, but keeping it at 1
       prevents stale inherited values from confusing future readouts. */
    line-height: 1;
}

/* ─── Home icon on the root segment ─────────── */
/* The leftmost "Home" segment renders as an icon instead of text.
   Same color as other segment text; sized to read at the same optical
   weight as the 14px segment label.
   display: block strips the SVG's default inline baseline behavior so
   it doesn't sit on the text baseline of its inline-flex parent. With
   the parent's align-items: center, a block-display SVG centers
   geometrically with adjacent text/chevron content. */

.dmu-bc-home {
    /* !important defeats Lucide's inline width/height attributes on
       the rendered <svg> (the framework injects width="18" height="18"
       which would otherwise win the specificity contest). */
    width: 20px !important;
    height: 20px !important;
    color: inherit;
    flex-shrink: 0;
    display: block;
    /* Chip painted behind the SVG glyph (not the whole link) so the
       "Home" text at ≥1200px stays unboxed. background fills the SVG's
       20×20 box; box-shadow spread (same color, 6px) extends the chip
       to 32×32 without affecting layout — that's the chip's visual
       "padding" around the glyph. The home link uses padding-top/bottom
       of 6px so the link's box is also 32px tall, matching the chip
       exactly (hit area = visible area). The home link is taller than
       text-only links (32px vs 22px) but every flex container in the
       breadcrumb uses align-items: center, so all icon/text centers
       still share a single horizontal axis. */
    background: color-mix(in srgb, var(--body, #1f2937) 6%, transparent);
    border-radius: 6px;
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--body, #1f2937) 6%, transparent);
    transition: background-color 120ms ease, box-shadow 120ms ease;
}

/* Hover the entire link, but only the icon chip darkens — the text
   stays plain. Triggers via the parent so the chip responds to hover
   anywhere in the link's hit area, not just over the SVG itself.
   Both background and box-shadow update together so the chip stays
   a single solid color. */
.dmu-bc-link[aria-label="Home"]:hover .dmu-bc-home,
.dmu-bc-link[aria-label="Home"]:focus .dmu-bc-home {
    background: color-mix(in srgb, var(--body, #1f2937) 11%, transparent);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--body, #1f2937) 11%, transparent);
}

/* Vertical padding sized so the home link's outer box (20px icon +
   6px+6px padding = 32px) matches the chip's visible box (20 + 6+6 =
   32px). Background is intentionally NOT here; the chip lives on the
   SVG, not the link. */
.dmu-bc-link[aria-label="Home"] {
    padding-top: 6px;
    padding-bottom: 6px;
}

/* "Home" text next to the home icon at md+ (≥768px). Below md the
   home segment stays icon-only — the parent <a aria-label="Home">
   keeps the segment named for assistive tech in both states. */
.dmu-bc-home-label {
    display: none;
    /* margin-left accounts for both the chip's 6px box-shadow spread
       (which extends past the SVG box) and breathing room between the
       chip and the text. 6px spread + 8px gap = 14px total. */
    margin-left: 14px;
    line-height: 1;
}

/* On department home pages the trail is just the Home seed, so the
   label is the only context the user has — show it at every width.
   The .dmu-bc-on-home class is set server-side in menu/menu.php when
   $breadCount === 1. */
.dmu-bc-on-home .dmu-bc-home-label {
    display: inline;
}

@media (min-width: 768px) {
    .dmu-bc-home-label {
        display: inline;
    }
}

/* ─── Dropdown panel (sibling list) ─────────── */

.dmu-bc-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 1080;
    min-width: 280px;
    max-width: 360px;
    max-height: 360px;
    overflow: auto;

    background: var(--foreground, #fff);
    border: 1px solid color-mix(in srgb, var(--body, #1f2937) 12%, transparent);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);

    padding: 8px 0;

    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
}

.dmu-bc-dropdown.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dmu-bc-dropdown-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 8px;
    border-bottom: 1px solid color-mix(in srgb, var(--body, #1f2937) 8%, transparent);
}

.dmu-bc-dropdown-search input {
    flex: 1 1 auto;
    border: 0;
    outline: none;
    padding: 6px 8px;
    font-size: 0.85rem;
    background: transparent;
    color: inherit;
}

.dmu-bc-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.dmu-bc-dropdown-row {
    display: block;
    padding: 8px 14px;
    font-size: 0.85rem;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.dmu-bc-dropdown-row:hover,
.dmu-bc-dropdown-row:focus {
    background: color-mix(in srgb, var(--primary, #6f42c1) 8%, transparent);
    outline: none;
    /* Defeat the global a:hover rule in styles.css which sets
       color: var(--secondary) for every <a> on the site. The
       dropdown rows are <a> elements rendered by breadcrumb.js, and
       without this explicit color they pick up the secondary tint
       on hover. (0,2,0) class-scoped specificity beats (0,1,1) on
       a:hover so no !important is needed.) */
    color: var(--primary, #6f42c1);
}

.dmu-bc-dropdown-row.is-current {
    background: color-mix(in srgb, var(--primary, #6f42c1) 12%, transparent);
    font-weight: 600;
    /* Pinned-current row gets the same explicit color so hover and
       focus on the current row stay primary instead of flipping to
       the global a:hover secondary. */
    color: var(--primary, #6f42c1);
}

.dmu-bc-dropdown-row .dmu-bc-row-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dmu-bc-dropdown-row .dmu-bc-row-secondary {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--body, #1f2937) 60%, transparent);
}

.dmu-bc-dropdown-empty,
.dmu-bc-dropdown-loading,
.dmu-bc-dropdown-error {
    padding: 12px 14px;
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--body, #1f2937) 65%, transparent);
}

.dmu-bc-dropdown-error {
    color: #b91c1c;
}

/* ─── Mobile inline breadcrumb strip (<md) ─────────── */
/* Replaces the previous standalone popover-trigger button. The strip
   is server-rendered as parallel markup to the desktop chain — JS
   does not transform one into the other; CSS picks which to show via
   d-md-none on this wrapper and d-md-flex on the desktop <ul>. */

.dmu-bc-mobile {
    display: none;
    align-items: center;
    /* Larger gap (8px) compensates for the removed chevron separators —
       the strip now relies purely on whitespace to delimit elements. */
    gap: 8px;
    min-width: 0;
    width: 100%;
}

@media (max-width: 575.98px) {
    .dmu-bc-mobile {
        display: flex;
    }
}

.dmu-bc-mobile-icon {
    /* !important defeats Lucide's inline width/height attributes on
       the rendered <svg>, same pattern as desktop .dmu-bc-home.
       Default size is 14px (the ellipsis); the home icon overrides
       this below to 18px so home reads as the primary affordance and
       the ellipsis stays visually secondary. */
    width: 14px !important;
    height: 14px !important;
    display: block;
    flex-shrink: 0;
    color: inherit;
}

.dmu-bc-mobile-home .dmu-bc-mobile-icon {
    width: 18px !important;
    height: 18px !important;
}

/* "Home" text rendered next to the icon only when chain depth = 1
   (the home page itself). On deeper pages the leaf segment provides
   the contextual label and the home icon stands alone as a back-to-
   home affordance. Inherits color from the parent <a>; display:
   inline is fine inside the inline-flex .dmu-bc-mobile-home. */
.dmu-bc-mobile-home-label {
    margin-left: 8px;
    font-weight: 500;
    line-height: 1;
}

.dmu-bc-mobile-sep {
    width: 10px !important;
    height: 10px !important;
    display: block;
    flex-shrink: 0;
    color: var(--muted, #727272);
}

/* Home link and the popover-trigger button share visual treatment:
   inline-flex container around a 14px icon, no chrome. The button
   retains its .dmu-bc-mobile-button class because js/base/breadcrumb.js
   queries that class to bind the popover open/close handler — the
   class is the JS hook, not just a styling target. */
.dmu-bc-mobile-home,
.dmu-bc-mobile-button {
    display: inline-flex;
    align-items: center;
    padding: 4px;
    margin: 0;
    background: none;
    border: 0;
    color: inherit;
    flex-shrink: 0;
    text-decoration: none;
    cursor: pointer;
}

.dmu-bc-mobile-current {
    /* The only flex-shrinkable child in the strip — absorbs all
       horizontal overflow. min-width: 0 is required: flex children
       default to min-width: auto, which prevents them from shrinking
       below their content's intrinsic width. Without this, long leaf
       names overflow the viewport instead of truncating. */
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
}

/* ─── Mobile popover (<md) ─────────── */
/* The popover itself is unchanged from the previous design — only its
   trigger moved from a standalone button into the inline strip above
   as the "ellipsis" element. */

.dmu-bc-mobile-popover {
    position: fixed;
    z-index: 1090;
    top: 60px;
    left: 8px;
    right: 8px;
    max-height: calc(100vh - 80px);
    overflow: auto;

    background: var(--foreground, #fff);
    border: 1px solid color-mix(in srgb, var(--body, #1f2937) 12%, transparent);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);

    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 140ms ease, transform 140ms ease;
}

.dmu-bc-mobile-popover.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dmu-bc-mobile-list {
    list-style: none;
    padding: 6px 0;
    margin: 0;
}

.dmu-bc-mobile-item {
    border-bottom: 1px solid color-mix(in srgb, var(--body, #1f2937) 6%, transparent);
}

.dmu-bc-mobile-item:last-child {
    border-bottom: 0;
}

.dmu-bc-mobile-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 0.9rem;
    color: inherit;
    text-decoration: none;
}

/* Mobile keeps the leaf-current visual cue inside the popover —
   it's a different surface from the inline desktop row. */
.dmu-bc-mobile-link.is-current {
    font-weight: 600;
    color: var(--primary, #6f42c1);
}

.dmu-bc-mobile-caret {
    width: 16px;
    height: 16px;
    opacity: 0.55;
    transition: transform 140ms ease;
}

.dmu-bc-mobile-item.is-open .dmu-bc-mobile-caret {
    transform: rotate(180deg);
}

.dmu-bc-mobile-sublist {
    list-style: none;
    margin: 0;
    padding: 0 0 8px;
    background: color-mix(in srgb, var(--body, #1f2937) 4%, transparent);
}

.dmu-bc-mobile-sublist .dmu-bc-dropdown-row {
    padding-left: 28px;
}

/* Backdrop blocks page interaction while popover is open. */
.dmu-bc-mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1085;
    background: rgba(15, 23, 42, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.dmu-bc-mobile-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}
