/* ============================================================================
   Shared ops nav-cluster styles

   Top-right cluster: language · waffle apps launcher · avatar account menu.
   Linked by both base.html and settings/base.html so the headers can't drift.
   Originated as duplicated blocks in base.html and settings.
   ============================================================================ */
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
/* WCAG SC 1.4.10 Reflow: the cluster had no flex-wrap and its pills set
   white-space: nowrap, so it could neither wrap nor shrink. At a 320px viewport
   (equivalently 400% zoom on a desktop, which is the common real-world path) the
   header pushed the page to 480px of horizontal scroll on the intake wizard.
   Wrapping is only half the fix: every template pins .header-inner to a fixed
   54px, which would clip the second row, so the row is allowed to grow at narrow
   widths. Scoped as header.site-header .header-inner (0-1-2) because base.html and
   the per-page templates declare .header-inner (0-1-0) in an inline <style> that
   comes after this sheet. */
.header-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; min-width: 0; }
@media (max-width: 480px) {
    header.site-header .header-inner {
        flex-wrap: wrap;
        height: auto;
        min-height: 54px;
        row-gap: 4px;
        padding-top: 4px;
        padding-bottom: 4px;
    }
    .header-login-btn { padding: .35rem .6rem; font-size: .75rem; }
}
/* Anonymous Sign-In pill. base.html styles .header-login-btn in its own
   inline <style> via var(--accent); static R2 pages (Words meetings, People) only
   load THIS sheet, so the fetched nav-cluster fragment's <a class="header-login-btn">
   rendered as unstyled text without this rule. var(--accent, …) keeps base.html's
   theming (incl. dark mode) where the token is defined and falls back on static pages. */
.header-login-btn {
    display: inline-flex; align-items: center;
    /* --action-ink needs the same fallback --accent has, and for the same reason:
       it is defined only in base.html, so on a standalone page (request_detail,
       request_issues, request_confirm, the static R2 pages) the token is unset and
       `color` silently inherits the body text instead. That shipped as #3d4551 on
       #005ea2 — 1.44:1, measured live on request.ungovr.org — where the rule plainly
       intends white. An unset custom property does not fail loudly; it hands you the
       inherited value and looks deliberate. */
    background: var(--accent, #005ea2); color: var(--action-ink, #fff); border: none;
    padding: .4rem .875rem; border-radius: 4px; cursor: pointer;
    font-size: .8rem; font-weight: 500; line-height: 1.2;
    text-decoration: none; white-space: nowrap;
}
.header-login-btn:hover { background: var(--accent-2, #1a4480); }
.apps-waffle, .profile-wrap { position: relative; }
.icon-btn, .avatar-btn {
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid transparent;
    background: transparent; cursor: pointer; display: flex; align-items: center;
    justify-content: center; padding: 0; transition: background .15s;
}
.icon-btn:hover, .avatar-btn:hover { background: var(--wash-hover); }
.icon-btn[aria-expanded="true"], .avatar-btn[aria-expanded="true"] { background: var(--tint-accent); }
/* Waffle a bit bigger than the profile button (chrome tweak). */
.icon-btn { width: 44px; height: 44px; }
.waffle-glyph { display: grid; grid-template-columns: repeat(3,1fr); gap: 3.5px; width: 24px; height: 24px; }
.waffle-glyph i { background: var(--action); border-radius: 2px; opacity: .85; }
/* Dark internal chrome: the navy waffle dots vanish on the dark header
   flip to light dots and dark-aware hover fills. Contrast rules documented in
   docs/design/header-controls-light-dark.md */
/* Was a hardcoded cool grey, which reads blue on the graphite internal
   surface. Use the theme variable so a retheme reaches this glyph. */
body.internal-surface:not(.force-light) .waffle-glyph i { background: var(--text-soft); opacity: .92; }
body.internal-surface:not(.force-light) .icon-btn:hover,
body.internal-surface:not(.force-light) .avatar-btn:hover { background: rgba(232,226,215,.14); }
body.internal-surface:not(.force-light) .icon-btn[aria-expanded="true"],
body.internal-surface:not(.force-light) .avatar-btn[aria-expanded="true"] { background: rgba(232,226,215,.22); }
/* Avatar fills the 40px profile button so its outer circle matches the UG logo height. */
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    /* Same unset-token trap as .header-login-btn above — the initials would inherit
       body text over the gradient on any page that does not load base.html. */
    background: linear-gradient(135deg,var(--action,#1a4480),var(--accent,#005ea2));
    color: var(--action-ink, #fff);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem; border: 2px solid var(--surface-card); box-shadow: 0 0 0 1px #dfe1e2;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.3rem; margin: 0 auto 10px; }
.apps-pop, .profile-pop {
    /* z-index 1100: above the Leaflet control tier (.leaflet-top/.leaflet-bottom
       default to 1000) so the header chrome popovers aren't occluded by the +/-
       map zoom controls on entity map pages. Stays below the dialog/modal
       tier (cgb-modal is 1500). The popovers compete in the root stacking context
       because .site-header sets no position/z-index, so this must beat 1000. */
    position: absolute; top: 52px; right: 0; z-index: 1100; background: var(--surface-card);
    border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgba(20,40,80,.18);
    display: none;
}
.apps-pop.open, .profile-pop.open { display: block; }
.apps-pop { width: 300px; padding: 14px; }
.apps-pop-h { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); padding: 2px 6px 10px; }
.apps-pop-h-note { font-weight: 500; color: var(--text-muted); letter-spacing: 0; text-transform: none; }
.apps-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; }
/* Four-section waffle: Government Transparency / Public Actions / UnGovr
   Published Sites (all public), then the gated Internal UnGovr section. */
.apps-pop-sep { border-top: 1px solid var(--border); margin: 8px 6px 12px; }
.app-tile { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px; border-radius: 10px; text-align: center; text-decoration: none; position: relative; }
.app-tile:hover { background: var(--wash-hover); }
.app-tile .ic { width: 30px; height: 30px; color: var(--accent-2); display: flex; align-items: center; justify-content: center; }
.app-tile .ic svg { width: 26px; height: 26px; }
.app-tile .lbl { font-size: .74rem; color: var(--text-soft); font-weight: 500; line-height: 1.15; }
.app-tile .crawl-activity-dot { position: absolute; top: 8px; right: 14px; margin: 0; }
.profile-pop { width: 282px; overflow: hidden; }
.profile-head { padding: 18px 16px 14px; text-align: center; border-bottom: 1px solid var(--border); }
.profile-name { font-weight: 700; color: var(--accent-2); }
.profile-name a { color: inherit; text-decoration: none; }
.profile-name a:hover { text-decoration: underline; }
.profile-role { font-size: .78rem; color: var(--text-muted); margin-top: 1px; }
.profile-row {
    display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-size: .88rem;
    color: var(--text-soft); cursor: pointer; text-decoration: none; width: 100%;
    background: none; border: none; text-align: left; font-family: inherit;
}
.profile-row:hover { background: var(--wash-hover); }
.profile-row svg { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.profile-row.sep { border-top: 1px solid var(--border); }
.profile-row .chev { margin-left: auto; color: var(--text-muted); font-size: .8rem; }
.profile-row.console { background: var(--wash-hover); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); color: var(--accent-2); font-weight: 600; }
.profile-row.console svg, .profile-row.console .chev { color: var(--accent); }
.profile-pop .entity-selector-wrap { padding: 6px 12px; margin: 0; }
.profile-pop .entity-selector input { width: 100%; }
/* Flow the "act as" results inline so they aren't clipped by the popover's
   overflow:hidden (the popover grows; on mobile it scrolls). */
.profile-pop .entity-dropdown { position: static; box-shadow: none; max-height: 220px; }
@media (max-width: 640px) {
    .apps-pop, .profile-pop { position: fixed; top: 64px; left: 8px; right: 8px; width: auto; max-height: 75vh; overflow-y: auto; }
}
