/* The glass toolbar above a list (the page list and its trash, SEO, My Library, the Client Area's websites): one look
   for every toolbar on the platform. A frosted glass pill holds the filters (an .app-segmented with counts), a search
   box and the tool buttons, all on one 42px row. A tool is the platform's soft button as a pill: the brand mist behind
   dark words and no border; pointing at it flows and deepens the mist and turns its words and icons purple, and a mode
   turned on or an open panel draws the 1px purple line and halo of the open look. The search box and a drop-down are
   tinted fields without a line of their own; focus draws the focused field's line and halo.

   Markup (all classes optional but the bar):
     <div class="app-toolbar [app-toolbar-sticky] [app-toolbar-stack] [app-toolbar-titled]" data-app-toolbar>
       <div class="app-segmented app-segmented-even app-toolbar-filters"> options, each with <span class="app-count"> </div>
       <h2 class="app-toolbar-title">…<span class="app-count">2</span></h2>        (instead of filters, e.g. the trash)
       <p class="app-toolbar-end app-toolbar-note">…</p>                              (a short note at the end)
       <div class="app-toolbar-tools">
         <div class="app-search [app-search-filled]"> .app-search-icon, input.app-search-input
                                                         (data-app-placeholder, data-app-placeholder-short),
                                                         .app-search-clear or kbd.app-search-key </div>
         <button class="app-tool [app-tool-fold-first] [app-tool-round] [app-tool-danger]">
             <i class="bx …"></i><span class="app-tool-text" data-tip-label>…</span>[<i class="bx bx-chevron-down app-tool-chevron">][<span class="app-count">] </button>
       </div>
     </div>
   A row never squeezes or cuts its controls: js/app-toolbar.js folds it a step at a time where it is too short
   (data-app-toolbar-fit: 1, the .app-tool-fold-first tool keeps its icon and arrow; 2, every tool keeps only its icon,
   its count moving to a dot; 3, two rows) and gives an equal-width filter group its own steps (data-app-filter-fit: 1,
   less padding; 2, the counts fold away; 3, smaller labels; 4, a label on two lines). Tablets and phones always show
   the tools as round icons; phones always take two rows. The filters never scroll sideways (a scrolling box would cut
   the sliding pill's glow, R26). A skeleton draws the same bar with the same classes (the filters as one shape over
   the real, unseen options: skeleton-page-head.css .pskel-toolbar-filters). */

.app-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding: 6px;
    border: 1px solid var(--app-glass-line);
    border-radius: 999px;
    background: var(--app-glass);
    -webkit-backdrop-filter: blur(18px) saturate(1.4);
    backdrop-filter: blur(18px) saturate(1.4);
    box-shadow: 0 10px 30px color-mix(in srgb, var(--app-color-primary) 10%, transparent);
}

/* Stays in view 12px under the shell's top bar, which is sticky itself (app-shell.css) */
.app-toolbar-sticky {
    position: sticky;
    top: calc(var(--ml-topbar-height, 72px) + 12px);
    z-index: 6;
}

/* ---------- filters ---------- */

/* No frame of its own: the options sit on the bar's 42px row like its other controls, the same room from the bar's
   edge on every side as a search box or a note */
.app-toolbar-filters {
    flex: none;
    padding: 0;
    border: 0;
    background: none;
}

.app-toolbar-filters > .app-segmented-option {
    height: 42px;
    font-size: 13.5px;
    white-space: nowrap;
}

.app-toolbar-filters > .app-segmented-option:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

.app-toolbar-filters[data-app-filter-fit] > .app-segmented-option {
    padding: 0 8px;
}

.app-toolbar-filters:is([data-app-filter-fit="2"], [data-app-filter-fit="3"], [data-app-filter-fit="4"]) .app-count {
    display: none;
}

.app-toolbar-filters:is([data-app-filter-fit="3"], [data-app-filter-fit="4"]) > .app-segmented-option {
    padding: 0 6px;
    font-size: 12px;
}

.app-toolbar-filters[data-app-filter-fit="4"] > .app-segmented-option {
    padding: 0 4px;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
}

/* ---------- counts ----------
   A count in a small round badge. Outfit's figures draw about a quarter of a pixel above the middle of their line at
   this size, and Windows then sets the text on whole pixels, so a number centred as a box often lands a pixel high in
   its circle; half a pixel more room at the top moves it down a quarter, onto the circle's middle. On the bar the
   count is a see-through tint, so the sliding pill of a filter group shows through it while it passes an option on its
   way (a solid count would flash as a chip on the purple). */
.app-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 20px;
    padding: 0.5px 6px 0;
    border-radius: 999px;
    background: var(--app-count-soft);
    color: var(--app-text-muted);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.app-segmented-option:is([aria-pressed="true"], [aria-current="true"]) .app-count {
    background: color-mix(in srgb, var(--app-color-white) 22%, transparent);
    color: var(--app-color-white);
}

/* A count of things to look at, in amber */
.app-count-warn {
    background: color-mix(in srgb, var(--app-warning) 16%, transparent);
    color: var(--app-warning);
}

/* On a tool's tinted pill the count is solid, so it reads as a chip of its own */
.app-tool .app-count {
    background: var(--app-surface);
}

/* ---------- a title instead of filters (the trash: back, title with its count, then the tools) ---------- */

.app-toolbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 0;
    color: var(--app-text-strong);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

/* Outfit's capitals and x-height sit above the middle of the line box (the room below is for descenders), so the
   count rises by the same optical nudge as an icon beside text and lines up with the letters, not with the box */
.app-toolbar-title .app-count {
    min-width: 24px;
    height: 22px;
    font-size: 12px;
    translate: 0 calc(var(--app-icon-nudge, 0.06em) * -1);
}

/* ---------- the tools ---------- */

/* The tools sit at the right end; the search box's auto margin pushes them there, and turns to 0 when the row is full,
   so a row that is still too long runs out on the right, where js/app-toolbar.js measures it and folds labels */
.app-toolbar-tools {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* Something to put at the right end without a search box before it (a short note, a lone tool) */
.app-toolbar-end {
    margin-left: auto;
}

/* A short note on the bar (the number of accounts). Its row is as tall as the bar's controls, so the bar keeps the same
   room above and below it whether it shares the row with the filters or sits on a row of its own (two rows), and its
   words keep off the bar's round end. On the filters' row it stays on one line, so a note that does not fit runs past
   the bar's end and js/app-toolbar.js takes the bar to two rows; on a row of its own it may wrap. */
.app-toolbar-note {
    display: flex;
    align-items: center;
    min-height: 42px;
    /* Only the paragraph's own margins above and below: the end's auto margin on the left stays */
    margin-block: 0;
    padding: 0 12px;
    color: var(--app-text-muted);
    font-size: 13.5px;
    line-height: 1.3;
    white-space: nowrap;
}

/* The mist lies on the surface colour, so a tool laid over a picture (a card's ⋯) never lets the picture through */
.app-tool {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    gap: 6px;
    height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background-color: var(--app-surface);
    background-image: var(--app-btn-soft-fill);
    background-position: 0 0;
    background-repeat: no-repeat;
    background-size: 200% 100%;
    color: var(--app-text-strong);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    /* Own layer, so its words are not redrawn (a visible flash) each time the press bounce ends */
    will-change: transform;
    transition: background-position 0.9s var(--app-ease-out), color 0.25s ease, box-shadow 0.25s ease;
}

/* An even size, so the icon lands on whole pixels in the middle of a round tool */
.app-tool .bx {
    font-size: 20px;
    transition: color 0.2s ease, transform 0.4s var(--app-ease-spring);
}

/* The chevron's glyph carries its own space on the right; 2px in balances the button against the icon on the left */
.app-tool .app-tool-chevron {
    margin-right: -2px;
    color: var(--app-text-muted);
    font-size: 18px;
}

/* Round: an icon-only tool, or one on a card or a row whose words the page hides on a narrow screen (app-ui.js marks it
   data-app-icon-only), so pages never size a tool themselves. Tools on a toolbar are left out: the toolbar's own fold
   steps size them (the first to fold keeps its arrow), and it measures them with their words shown back for a moment */
.app-tool:is(.app-tool-round, [data-app-icon-only]:not(.app-toolbar .app-tool)) {
    width: 42px;
    padding: 0;
}

.app-tool-danger {
    background-image: var(--app-btn-soft-danger-fill);
    color: var(--app-btn-danger-text);
}

.app-tool:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Pointing at it flows and deepens the mist and turns its words and icons (the arrow too) purple; a danger tool's stay
   red. Keyboard focus is every button's 2px purple outline 3px off its edge (app-ui.css). */
@media (hover: hover) {
    .app-tool:not(:disabled, [aria-disabled="true"]):hover {
        background-position: 100% 0;
    }

    .app-tool:not(:disabled, [aria-disabled="true"]):hover,
    .app-tool:not(:disabled, [aria-disabled="true"]):hover .bx {
        color: var(--app-btn-soft-active-text);
    }

    .app-tool-danger:not(:disabled, [aria-disabled="true"]):hover,
    .app-tool-danger:not(:disabled, [aria-disabled="true"]):hover .bx {
        color: var(--app-btn-danger-text);
    }
}

/* On (a mode turned on) or open (its panel shows): the platform's open look, the mist at rest with a 1px purple line
   and a soft 4px halo round it, purple words; as specific as the hover above and after it, so the pointer resting on
   it keeps the look */
.app-tool:is([aria-pressed="true"], [aria-expanded="true"]):not(:disabled, [aria-disabled="true"]),
.app-tool:is([aria-pressed="true"], [aria-expanded="true"]):not(:disabled, [aria-disabled="true"]) .bx {
    color: var(--app-btn-soft-active-text);
}

.app-tool:is([aria-pressed="true"], [aria-expanded="true"]):not(:disabled, [aria-disabled="true"]) {
    background-position: 0 0;
    box-shadow: var(--app-field-focus);
}

/* A finger gets 44 x 44px: an unseen area round the 42px tool, the tool itself unchanged */
@media (pointer: coarse) {
    .app-tool::after {
        content: "";
        position: absolute;
        inset: min(0px, calc((100% - 44px) / 2));
    }
}

/* A drop-down (WebbuilderUI SelectMenu) among the tools is a tinted pill on the tools' row */
.app-toolbar .app-sel-toggle {
    height: 42px;
    border-color: transparent;
    background: var(--app-control-soft);
}

.app-toolbar .app-sel[data-open] .app-sel-toggle {
    background: var(--app-control-soft-open);
}

@media (hover: hover) {
    .app-toolbar .app-sel:not([data-open]) .app-sel-toggle:not(:disabled, [aria-disabled="true"]):hover {
        border-color: transparent;
        color: var(--app-accent);
    }

    .app-toolbar .app-sel:not([data-open]) .app-sel-toggle:not(:disabled, [aria-disabled="true"]):hover .app-sel-icon {
        color: var(--app-accent);
    }
}

/* ---------- the search box ---------- */

/* Grows with the room it has (240px at best) and gives way to the tools' labels only down to 180px (js/app-toolbar.js
   reads the same least width) */
.app-search {
    position: relative;
    flex: 0 1 240px;
    min-width: 180px;
    margin-left: auto;
}

/* The magnifier sits where the round end's centre is (21px in from the left of the 42px pill), the same distance as
   the × or the "/" key at the right end, so both ends of the pill match */
.app-search-icon {
    position: absolute;
    top: 12px;
    left: 12px;
    display: block;
    width: 18px;
    height: 18px;
    color: var(--app-text-muted);
    font-size: 18px;
    line-height: 1;
    pointer-events: none;
    transition: color 0.2s ease;
}

.app-search-input {
    width: 100%;
    height: 42px;
    padding: 0 16px 0 39px;
    border: 1px solid transparent;
    border-radius: 999px;
    outline: none;
    background: var(--app-control-soft);
    color: var(--app-text-strong);
    font: inherit;
    font-size: 16px;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

/* The "/" key takes 42px at the right end on a computer; × takes 40px once something is typed */
.app-search:has(.app-search-key) .app-search-input {
    padding-right: 42px;
}

.app-search-filled .app-search-input {
    padding-right: 40px;
}

.app-search-input::placeholder {
    color: var(--app-text-muted);
    font-size: 14.5px;
}

.app-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* A finger gets 44px of height: an unseen strip above and below the 42px box, under the field (z-index -1, so a tap on
   the field still lands on it); js/app-toolbar.js hands a tap on the strip to the field */
@media (pointer: coarse) {
    .app-search::after {
        content: "";
        position: absolute;
        z-index: -1;
        inset: min(0px, calc((100% - 44px) / 2)) 0;
    }
}

/* Hover keeps the box as it is and only turns the magnifier and the placeholder to the accent colour */
@media (hover: hover) {
    .app-search:hover .app-search-icon,
    .app-search:hover .app-search-input::placeholder {
        color: var(--app-accent);
    }
}

/* Focus: the platform's focused field (app-ui.css --app-field-focus, rules/UI.md R24) */
.app-search-input:focus {
    border-color: var(--app-accent);
    background: var(--app-surface);
    box-shadow: var(--app-field-focus);
}

.app-search:focus-within .app-search-icon {
    color: var(--app-accent);
}

.app-search-clear {
    position: absolute;
    top: 50%;
    right: 7px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--app-text-muted);
    font-size: 18px;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background-color 0.2s ease, color 0.2s ease;
}

@media (hover: hover) {
    .app-search-clear:hover {
        background: var(--app-accent-soft);
        color: var(--app-accent);
    }
}

/* The key that reaches the box ("/"), outlined on the box's own tint */
.app-search-key {
    position: absolute;
    top: 50%;
    right: 9px;
    display: inline-grid;
    place-items: center;
    box-sizing: border-box;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border: 1px solid var(--app-line);
    border-bottom-width: 2px;
    border-radius: 7px;
    background: transparent;
    color: var(--app-text-muted);
    font: 600 12px var(--app-font-family);
    pointer-events: none;
    transform: translateY(-50%);
}

.app-search-input:focus ~ .app-search-key {
    display: none;
}

/* ---------- folding where the row is too short (js/app-toolbar.js) ---------- */

.app-toolbar[data-app-toolbar-fit="1"] .app-tool-fold-first .app-tool-text,
.app-toolbar:is([data-app-toolbar-fit="2"], [data-app-toolbar-fit="3"]) .app-tool-text,
.app-toolbar:is([data-app-toolbar-fit="2"], [data-app-toolbar-fit="3"]) .app-tool-chevron {
    display: none;
}

.app-toolbar[data-app-toolbar-fit="1"] .app-tool-fold-first {
    gap: 2px;
}

.app-toolbar:is([data-app-toolbar-fit="2"], [data-app-toolbar-fit="3"]) .app-tool:not(.app-tool-round) {
    width: 42px;
    padding: 0;
}

/* A folded tool's count moves to a brand-coloured dot on its corner */
.app-toolbar:is([data-app-toolbar-fit="2"], [data-app-toolbar-fit="3"]) .app-tool .app-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    padding: 0.5px 5px 0;
    border: 2px solid var(--app-surface);
    background: var(--app-color-primary);
    color: var(--app-color-white);
}

/* Two rows (step 3, or a bar that always stacks): the filters or the title above, the search and the tools below */
.app-toolbar:is([data-app-toolbar-fit="3"], .app-toolbar-stack) {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    border-radius: 26px;
}

.app-toolbar:is([data-app-toolbar-fit="3"], .app-toolbar-stack) .app-toolbar-tools {
    gap: 8px;
}

.app-toolbar[data-app-toolbar-fit="3"] .app-search {
    flex: 1 1 auto;
    min-width: 0;
}

/* A note on a row of its own reads from the left, like the text under it, and wraps where it must */
.app-toolbar:is([data-app-toolbar-fit="3"], .app-toolbar-stack) .app-toolbar-note {
    margin-left: 0;
    white-space: normal;
}

/* A bar with a title keeps the title on the first row beside what comes before it (the back button) */
.app-toolbar-titled:is([data-app-toolbar-fit="3"], .app-toolbar-stack) {
    flex-flow: row wrap;
    align-items: center;
}

.app-toolbar-titled:is([data-app-toolbar-fit="3"], .app-toolbar-stack) .app-toolbar-title {
    flex: 1;
}

.app-toolbar-titled:is([data-app-toolbar-fit="3"], .app-toolbar-stack) .app-toolbar-tools {
    flex: 1 1 100%;
    order: 3;
}

/* ---------- tablets and phones ---------- */

/* Touch screens have no "/" key to press */
@media (max-width: 1023.98px), (hover: none) {
    .app-search-key {
        display: none;
    }

    .app-search:has(.app-search-key) .app-search-input {
        padding-right: 16px;
    }

    .app-search-filled .app-search-input {
        padding-right: 40px;
    }
}

/* The search box takes the room; the tools are round icons, their counts on a dot */
@media (max-width: 1023.98px) {
    .app-toolbar-tools {
        flex: 1;
    }

    .app-search {
        flex: 1 1 auto;
        min-width: 0;
    }

    .app-toolbar .app-tool:not(.app-tool-round) {
        width: 42px;
        padding: 0;
    }

    .app-toolbar .app-tool-text,
    .app-toolbar .app-tool-chevron {
        display: none;
    }

    .app-toolbar .app-tool .app-count {
        position: absolute;
        top: -4px;
        right: -4px;
        min-width: 20px;
        padding: 0.5px 5px 0;
        border: 2px solid var(--app-surface);
        background: var(--app-color-primary);
        color: var(--app-color-white);
    }
}

/* Phones: always two rows, 8px under the top bar */
@media (max-width: 767.98px) {
    .app-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        border-radius: 26px;
    }

    .app-toolbar-sticky {
        top: calc(var(--ml-topbar-height, 64px) + 8px);
    }

    .app-toolbar-tools {
        gap: 8px;
    }

    .app-toolbar-note {
        margin-left: 0;
        white-space: normal;
    }

    .app-toolbar-titled {
        flex-flow: row wrap;
        align-items: center;
    }

    .app-toolbar-titled .app-toolbar-title {
        flex: 1;
    }

    .app-toolbar-titled .app-toolbar-tools {
        flex: 1 1 100%;
        order: 3;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-tool,
    .app-tool .bx,
    .app-search-icon,
    .app-search-input,
    .app-count {
        transition: none;
    }
}
