/* The header of every page (views/includes/industry-header.ejs): the masthead with the main sections and the account
   button, and the sticky topbar with the page's subsections, the market and language menus, search and the account menu.
   The colours, fonts and the wordmark come from static/anyavs/theme.css. The rules keep to the header, so the pages'
   own stylesheets (static/anyavs/industry-home.css, static/lopnor/css) neither style it nor are styled by it. */
:root {
    --gutter: clamp(16px, 4vw, 56px);
    /* Follows the sticky topbar's real height (it wraps on narrow screens). */
    --topbar-offset: 44px;
}

:is(.masthead, .topbar), :is(.masthead, .topbar) * { box-sizing: border-box; }
:is(.masthead, .topbar) a { color: inherit; text-decoration: none; }
:is(.masthead, .topbar) :is(button, input) { font: inherit; }
:is(.masthead, .topbar) :focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.masthead-inner, .topbar-inner { max-width: 1360px; margin-inline: auto; padding-inline: var(--gutter); }

.skip-link {
    position: absolute;
    inset: 10px auto auto var(--gutter);
    padding: 10px 16px;
    background: var(--paper);
    z-index: 2;
    transform: translateY(calc(-100% - 20px));
}
.skip-link:focus { transform: none; }

.masthead { background: var(--header-surface); color: var(--header-ink); font: 16px/1.55 var(--body-font); }
.masthead-inner {
    display: flex;
    align-items: center;
    gap: clamp(14px, 3.5vw, 52px);
    min-height: 96px;
    padding-block: 16px;
}
/* The brand and the button give way (their text wraps) before the navigation gets narrower than its basis. */
.masthead .brand { display: block; flex: 0 1 auto; min-width: 0; }
.primary-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 280px;
    flex-wrap: wrap;
    gap: 4px 6px;
    min-width: 0;
}
.primary-nav a {
    padding: 11px clamp(9px, 1vw, 16px);
    white-space: nowrap;
    color: var(--header-muted);
    font-size: 15px;
}
.primary-nav a:hover { color: var(--header-ink); box-shadow: inset 0 -2px var(--line-strong); }
.primary-nav a[aria-current] { color: var(--primary); font-weight: 700; box-shadow: inset 0 -2px var(--primary); }
:is(.masthead, .topbar) .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 20px;
    border: 0;
    background: var(--primary);
    color: white;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.55;
    cursor: pointer;
}
:is(.masthead, .topbar) .button:hover { background: var(--primary-strong); }
:is(.masthead, .topbar) .button:focus-visible { outline-color: var(--accent); }
.masthead-button { flex: 0 1 auto; gap: 8px; }
.masthead-button svg { flex: none; }
/* Its short label, shown where the full one would push the button below the brand (views/includes/industry-header.ejs);
   the full label stays its accessible name. */
.masthead-label-short { display: none; }
.masthead-button.is-compact .masthead-label-short { display: inline; }
.masthead-button.is-compact .masthead-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--toolbar);
    color: white;
    font: 16px/1.55 var(--body-font);
}
.topbar-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 16px;
    min-height: 44px;
    font-size: 13px;
}
.subnav {
    display: flex;
    flex: 1 1 0;
    flex-wrap: wrap;
    gap: 0 clamp(10px, 1.45vw, 20px);
    min-width: 0;
    margin-inline-start: 12px;
}
.subnav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    font-weight: 500;
}
.subnav a:is(:hover, :focus-visible) { text-decoration: underline; text-underline-offset: 4px; }
/* The current topic is underlined just below its label. A link is as tall as the bar, a comfortable tap target, so a line
   on its bottom edge would sit far below the text. */
.subnav a[aria-current], .subnav .nav-more:has(a[aria-current]) > summary {
    font-weight: 700;
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 5px;
}
.topbar-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0 8px;
    margin-inline-start: auto;
}
.toolbar-menu { position: relative; }
.toolbar-menu > summary {
    display: flex;
    gap: 7px;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding-inline: 8px;
    list-style: none;
    cursor: pointer;
}
.toolbar-menu > summary::-webkit-details-marker { display: none; }
.toolbar-menu > summary:is(:hover, :focus-visible), .toolbar-menu[open] > summary { background: #29371938; }
.topbar :focus-visible { outline-offset: -2px; }
.toolbar-menu > .tool { color: var(--toolbar-muted); }
.tool::after {
    content: "";
    width: 6px;
    height: 6px;
    margin-block-start: -3px;
    border: solid currentColor;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}
.toolbar-menu[open] > .tool::after { transform: translateY(3px) rotate(225deg); }
.toolbar-menu > .search-toggle { width: 44px; margin-inline-end: -6px; }
.toolbar-popover {
    position: absolute;
    z-index: 1;
    inset: calc(100% + 6px) 0 auto auto;
    min-width: 175px;
    /* The topbar is sticky, so a long list scrolls inside the popover instead of past the viewport. */
    max-height: calc(100vh - var(--topbar-offset) - 16px);
    max-height: calc(100dvh - var(--topbar-offset) - 16px);
    overflow-y: auto;
    padding: 6px;
    background: var(--header-surface);
    color: var(--header-ink);
    border: 1px solid var(--line-strong);
    box-shadow: 0 5px 18px #1a1d121c;
}
.toolbar-popover > a { display: block; padding: 9px 10px; }
.toolbar-popover > a:hover, .toolbar-popover > a[aria-current] { background: var(--primary-tint); }

/* A navigation the page script fits keeps to one line; the links that do not fit are listed under More. */
.nav-fit { flex-wrap: nowrap; }
/* A link keeps its label on one line, so a navigation that is too narrow overflows and the page script moves links into More. */
.nav-fit > a { flex-shrink: 0; white-space: nowrap; }
/* So does More: squeezed, it would wrap its label and hide the overflow, and the script would stop moving links into it. */
.nav-fit > .nav-more { flex-shrink: 0; white-space: nowrap; }
.nav-more .toolbar-popover > a {
    display: block;
    min-height: 0;
    padding: 9px 10px;
    box-shadow: none;
    font-size: 14px;
    white-space: nowrap;
}
.nav-more .toolbar-popover > a[aria-current] { font-weight: 700; }
/* In the masthead, More looks like the links beside it, and its list opens above the sticky topbar. */
.primary-nav .nav-more > summary {
    min-height: 0;
    padding: 11px clamp(9px, 1vw, 16px);
    color: var(--header-muted);
    font-size: 15px;
}
.primary-nav .nav-more > summary:is(:hover, :focus-visible), .primary-nav .nav-more[open] > summary {
    background: none;
    color: var(--header-ink);
    box-shadow: inset 0 -2px var(--line-strong);
}
.primary-nav .nav-more:has(a[aria-current]) > summary { color: var(--primary); font-weight: 700; box-shadow: inset 0 -2px var(--primary); }
.masthead .toolbar-popover { z-index: 11; }
.search-form { display: flex; width: min(320px, calc(100vw - 32px)); }
.search-form input {
    flex: 1;
    min-width: 0;
    background: white;
    color: var(--ink);
    border: 1px solid #849472;
    padding-inline: 10px;
}
.search-form .button { padding-inline: 12px; }

/* The signed-in member's menu (views/includes/member-identity-switcher.ejs): the market and language menus, the
   workspaces to enter and signing out. */
.account-menu .member-identity-name { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Its submenus open outside its box, so it neither clips nor scrolls them (it is short). */
.account-menu > .account-popover { min-width: 210px; max-height: none; overflow: visible; }
.member-identity-menu { display: grid; gap: 2px; }
.member-identity-menu > a { display: flex; align-items: center; min-height: 40px; padding: 9px 10px; }
.member-identity-menu > a:hover { background: var(--primary-tint); }
.member-identity-menu > a.is-active { font-weight: 700; }
/* In the member's menu the market and language menus are submenus: one at a time, each opens its own list beside the
   menu, to its left (the menu sits at the right of the topbar), level with its row. Its arrow points there. */
.account-site-menus { display: grid; gap: 2px; }
.account-site-menus .toolbar-menu > summary {
    flex-direction: row-reverse;
    justify-content: flex-end;
    min-height: 40px;
    padding-inline: 10px;
    color: var(--header-ink);
}
.account-site-menus .toolbar-menu > summary:is(:hover, :focus-visible),
.account-site-menus .toolbar-menu[open] > summary { background: var(--primary-tint); }
.account-site-menus .toolbar-menu > .tool::after { margin-block-start: 0; transform: rotate(135deg); }
.account-site-menus .toolbar-menu > .toolbar-popover { z-index: 2; inset: -7px calc(100% + 13px) auto auto; }
.member-identity-option { display: inline-flex; flex: 1; align-items: center; gap: 8px; min-width: 0; line-height: 1; }
.member-identity-badge { flex: 0 0 auto; width: 13px; height: 13px; }
.member-identity-badge img { display: block; width: 100%; height: 100%; }
.member-identity-menu-separator { height: 1px; margin: 5px 4px; background: var(--line); }
.member-identity-logout { margin: 0; }
.member-identity-logout button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: #7b2834;
    text-align: start;
    cursor: pointer;
}
.member-identity-logout button:hover { background: #fff1f1; color: #9a3441; }
/* The unread counts of the workspaces (static/lopnor/js/member-task-notifications.js). */
:is(.masthead, .topbar) .member-task-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #d93025;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
}
:is(.masthead, .topbar) .member-task-badge[hidden] { display: none; }
.member-identity-option > .member-task-badge { margin-inline-start: auto; }

@media (max-width: 720px) {
    .masthead-inner { flex-wrap: wrap; padding-block: 16px 8px; gap: 10px 12px; }
    .masthead .brand .wordmark { font-size: 32px; }
    .masthead-button { margin-inline-start: auto; }
    .primary-nav { order: 1; flex-basis: 100%; gap: 2px; }
    .primary-nav a, .primary-nav .nav-more > summary { font-size: 14px; }
    /* The topics take a line of their own, the tools the next. */
    .subnav { flex-basis: 100%; margin-inline-start: 0; }
}

@media (max-width: 560px) {
    .masthead-button { flex-shrink: 1; max-width: 42%; padding-inline: 12px; }
    .masthead .brand { flex-shrink: 1; min-width: 0; }
    .market-menu .toolbar-popover { inset-inline: 0 auto; }
    /* A phone has no room beside the member's menu: a submenu opens just below the menu, level with its right edge, and
       its arrow points down. */
    .account-site-menus .toolbar-menu { position: static; }
    .account-site-menus .toolbar-menu > .toolbar-popover { inset: calc(100% + 4px) -1px auto auto; }
    .account-site-menus .toolbar-menu > summary { flex-direction: row; justify-content: space-between; }
    .account-site-menus .toolbar-menu > .tool::after { margin-block-start: -3px; transform: rotate(45deg); }
    .account-site-menus .toolbar-menu[open] > .tool::after { transform: translateY(3px) rotate(225deg); }
    /* On a phone the member's menu shows only its icon (its name stays in the summary's title), so the tools keep to one line under the topics. */
    .account-menu .member-identity-name { display: none; }
}
