/* The FlexTools menu (js/tools-menu.js): the brand button top left, and the short list of the other
   web tools it opens. The same file in every web tool - the canonical copy is
   shared/tools-menu/tools-menu.css. It takes its colours from --fxm-* custom properties, which each
   tool maps onto its own tokens in css/app.css; the fallbacks are the house greys and a neutral
   accent, so it is never unreadable if a mapping is missing. */

/* The tool's icon and name, made a button. It keeps the brand's own layout; this only takes away
   what a button brings with it, and adds the chevron that says there is a menu. "button." so that it
   outweighs a tool's own .brand padding, which loads after this file. */
button.tools-menu-trigger {
    margin: -0.25rem -0.4rem;
    padding: 0.25rem 0.4rem;
    border: 0;
    border-radius: 6px;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    anchor-name: --tools-menu;
}

.tools-menu-trigger:hover,
.tools-menu-trigger:focus-visible {
    background: var(--fxm-hover, #1e242d);
}

.tools-menu-trigger:focus-visible {
    outline: 2px solid var(--fxm-accent, #8391a2);
    outline-offset: 1px;
}

.tools-menu-chev {
    width: 0.75rem;
    height: 0.75rem;
    margin-left: -0.1rem;
    fill: none;
    stroke: var(--fxm-muted, #8391a2);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The panel. Small on purpose - it is a way to the next tool, not a page - so the list scrolls rather
   than the panel growing. Placed under the brand: by anchor where the browser can, and otherwise at
   the top left, which is where the brand always is. */
.tools-menu {
    position: fixed;
    inset: 3rem auto auto 0.5rem;
    width: min(17.5rem, calc(100vw - 1rem));
    max-height: min(26rem, calc(100vh - 4rem));
    margin: 0;
    padding: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--fxm-border, #262f3a);
    border-radius: 10px;
    background: var(--fxm-pane, #15191f);
    color: var(--fxm-text, #dde5ee);
    font-size: 0.8125rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.tools-menu:popover-open {
    display: flex;
}

@supports (position-anchor: --tools-menu) {
    .tools-menu {
        position-anchor: --tools-menu;
        inset: auto;
        top: calc(anchor(bottom) + 0.35rem);
        left: anchor(left);
    }
}

.tools-menu-head {
    padding: 0.6rem 0.75rem 0.35rem;
}

.tools-menu-title {
    margin: 0;
    color: var(--fxm-muted, #8391a2);
    font-size: 0.75rem;
    font-weight: 600;
}

.tools-menu-filter {
    margin: 0 0.5rem 0.35rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--fxm-border, #262f3a);
    border-radius: 6px;
    background: var(--fxm-pane-alt, #11151a);
    color: var(--fxm-text, #dde5ee);
    font: inherit;
}

.tools-menu-filter:focus-visible {
    border-color: var(--fxm-accent, #8391a2);
    outline: none;
}

.tools-menu-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0 0.3rem 0.3rem;
    overflow-y: auto;
    list-style: none;
}

.tools-menu-item {
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr);
    gap: 0 0.6rem;
    align-items: center;
    padding: 0.35rem 0.45rem;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}

.tools-menu-item:hover,
.tools-menu-item:focus-visible {
    background: var(--fxm-hover, #1e242d);
    outline: none;
}

.tools-menu-item:focus-visible {
    box-shadow: inset 0 0 0 2px var(--fxm-accent, #8391a2);
}

.tools-menu-icon {
    display: grid;
    grid-row: span 2;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 6px;
    background: var(--fxm-pane-alt, #11151a);
    color: var(--fxm-muted, #8391a2);
    font-weight: 700;
}

/* Each icon comes in both themes (js/tools-menu.js); only the page's own is shown. The same three
   cases as every tool's theme tokens: dark unless light is chosen, or the system asks for it and
   dark isn't chosen. */
.tools-menu-icon-light {
    display: none;
}

:root[data-theme="light"] .tools-menu-icon-dark {
    display: none;
}

:root[data-theme="light"] .tools-menu-icon-light {
    display: grid;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .tools-menu-icon-dark {
        display: none;
    }

    :root:not([data-theme="dark"]) .tools-menu-icon-light {
        display: grid;
    }
}

.tools-menu-name {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tools-menu-item:hover .tools-menu-name,
.tools-menu-item:focus-visible .tools-menu-name {
    color: var(--fxm-accent, inherit);
}

.tools-menu-desc {
    overflow: hidden;
    color: var(--fxm-muted, #8391a2);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tools-menu-status {
    margin: 0;
    padding: 0.4rem 0.75rem 0.6rem;
    color: var(--fxm-muted, #8391a2);
}

.tools-menu-foot {
    padding: 0.45rem 0.75rem;
    border-top: 1px solid var(--fxm-border, #262f3a);
    font-size: 0.75rem;
}

.tools-menu-foot a {
    color: var(--fxm-muted, #8391a2);
}

.tools-menu-foot a:hover,
.tools-menu-foot a:focus-visible {
    color: var(--fxm-accent, inherit);
}
