/* Menu pattern renderers B (TASK-UXP-032, HRMS-ADR-0059): hub launcher, top navigation + mega menu, command-first. Builds on the .hrms-menu block of shell.css. Logical properties only. */

/* ---------- Hub & launcher: tiles; an open group spans the row ---------- */
.hrms-menu--hub-launcher > .hrms-menu__tree {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 120px), 1fr));
    gap: 8px;
}

.hrms-menu--hub-launcher .hrms-menu__separator,
.hrms-menu--hub-launcher .hrms-menu__item--line {
    grid-column: 1 / -1;
}

.hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link {
    flex-direction: column;
    justify-content: center;
    min-block-size: max(88px, var(--hrms-menu-target, 44px));
    text-align: center;
    border: 1px solid var(--hrms-color-border-subtle);
}

.hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link .hrms-menu__chevron {
    display: none;
}

.hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item--group:has(> .hrms-menu__link[aria-expanded="true"]) {
    grid-column: 1 / -1;
}

.hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item--group > .hrms-menu__group {
    padding-inline-start: 0;
    margin-block-start: 8px;
}

/* ---------- Top navigation + mega menu ---------- */
.hrms-menu--top-mega {
    min-inline-size: 0;
}

.hrms-menu__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hrms-menu__item--mega {
    position: static;
}

.hrms-menu--top-mega .hrms-menu__link {
    inline-size: auto;
}

.hrms-menu__panel {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    box-sizing: border-box;
    inline-size: 100%;
    padding: 16px;
    margin-block-start: 4px;
    border: 1px solid var(--hrms-color-border-default);
    border-radius: var(--hrms-radius-md, 8px);
    background: var(--hrms-color-bg-surface);
}

.hrms-menu__panel[hidden] {
    display: none;
}

.hrms-menu__col {
    flex: 1 1 200px;
    min-inline-size: min(200px, 100%);
}

.hrms-menu__col-title {
    margin: 0 0 8px;
    padding-inline: 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--hrms-color-text-secondary);
}

.hrms-menu__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.hrms-menu__panel-footer {
    flex: 1 0 100%;
    padding-block-start: 8px;
    border-block-start: 1px solid var(--hrms-color-border-subtle);
}

/* ---------- Command-first: palette button on top of a small rail ---------- */
.hrms-menu--command-first {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hrms-menu__command {
    border: 1px solid var(--hrms-color-border-default);
    color: var(--hrms-color-text-secondary);
}

.hrms-menu__command .hrms-kbd {
    flex: 0 0 auto;
}

.hrms-menu__rail > .hrms-menu__item > .hrms-menu__link {
    font-size: 0.9375rem;
}

:root[data-contrast="high"] .hrms-menu__panel,
:root[data-contrast="high"] .hrms-menu__command {
    border-width: 2px;
}

@media (forced-colors: active) {
    .hrms-menu__panel,
    .hrms-menu__command {
        border: 1px solid CanvasText;
    }
}

/* ---------- Icon-only (rail layout, UXA-010/014): 44 px icon entries, label as tooltip + accessible name, groups open as a flyout ---------- */
.hrms-menu--icon-only .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link {
    position: relative;
    justify-content: center;
    padding-inline: 0;
}

.hrms-menu--icon-only .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link .hrms-menu__label,
.hrms-menu--icon-only .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link .hrms-menu__chevron {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.hrms-menu--icon-only .hrms-menu__tree > .hrms-menu__item--group {
    position: relative;
}

.hrms-menu--icon-only .hrms-menu__tree > .hrms-menu__item--group > .hrms-menu__group:not([hidden]) {
    position: absolute;
    inset-inline-start: calc(100% + 8px);
    inset-block-start: 0;
    z-index: 20;
    box-sizing: border-box;
    min-inline-size: 220px;
    padding: 8px;
    border: 1px solid var(--hrms-color-border-default);
    border-radius: var(--hrms-radius-md, 8px);
    background: var(--hrms-color-bg-surface);
}

.hrms-menu--icon-only .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link[data-tooltip]:hover::after,
.hrms-menu--icon-only .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    position: absolute;
    inset-inline-start: calc(100% + 8px);
    inset-block-start: 50%;
    transform: translateY(-50%);
    z-index: 20;
    padding-block: 4px;
    padding-inline: 8px;
    border-radius: var(--hrms-radius-sm, 4px);
    background: var(--hrms-color-bg-inverse);
    color: var(--hrms-color-text-inverse);
    font-size: 0.8125rem;
    white-space: nowrap;
    pointer-events: none;
}

/* G20-04: an entry without an icon shows its initial in the rail, sized like a 20 px icon. */
.hrms-menu__monogram {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 20px;
    block-size: 20px;
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1;
}

/* G20-04: the rail column never scrolls sideways; group flyouts still open beside it. */
.hrms-menu--icon-only {
    max-inline-size: 100%;
}

/* The palette trigger, when shown, sizes to its own box (V90-03). */
.hrms-menu__command {
    align-self: stretch;
    block-size: auto;
}

/* Top bar at phone width: wrap, never push the page sideways (V90-02). */
.hrms-menu--top-mega,
.hrms-menu__bar {
    max-inline-size: 100%;
}

.hrms-menu--top-mega .hrms-menu__link {
    min-inline-size: 0;
    max-inline-size: 100%;
}

.hrms-menu--top-mega .hrms-menu__label {
    overflow-wrap: anywhere;
}

/* ---------- High contrast: one outline on the active entry instead of a border per entry (UXA-011/013) ---------- */
:root[data-contrast="high"] .hrms-menu .hrms-menu__link:not(.hrms-menu__command) {
    border: 0;
}

:root[data-contrast="high"] .hrms-menu .hrms-menu__link[aria-current],
:root[data-contrast="high"] .hrms-menu .hrms-menu__link--group[aria-expanded="true"] {
    outline: 2px solid var(--hrms-color-border-focus);
    outline-offset: -2px;
}

:root[data-contrast="high"] .hrms-menu--persona-bands > .hrms-menu__tree > .hrms-menu__item--group > .hrms-menu__link {
    border-block-end: 0;
}

/* RW-05: on a phone the launcher tiles live in the drawer (opened from the top-bar menu button), not as an always-open grid above the page. */
@media (max-width: 767px) {
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu {
        display: none;
    }
}

/* Hub overlay (PLD, 7301 R159): with a horizontal layout the launcher sits in the sticky, blurred top bar; 88px tiles plus the full-width
   footer line made it ~286px tall and it covered the page header while scrolling. From tablet up the band is one compact row and scrolls away. */
@media (min-width: 768px) {
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top {
        position: static;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 128px), 1fr));
        gap: 6px;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link {
        flex-direction: row;
        min-block-size: var(--hrms-menu-target, 44px);
        gap: 8px;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher .hrms-menu__separator {
        display: none;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item--line {
        grid-column: auto;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item--line > .hrms-menu__link {
        justify-content: center;
        min-block-size: var(--hrms-menu-target, 44px);
        border: 1px solid var(--hrms-color-border-subtle);
    }
}

/* G21-04 (UX R162): from tablet up the band is one row in both languages and never scrolls sideways (a hidden destination has no cue).
   768-1023px: icon-only 44px tiles; the label stays the accessible name and shows as a tooltip on hover and keyboard focus; a tile without
   an icon keeps its label. From 1024px: tiles size to their label, which does not wrap inside the tile; only if they still do not fit does the row wrap (nothing is
   hidden). An open group takes its own row. */
@media (min-width: 768px) {
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree {
        display: flex;
        flex-wrap: wrap;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item {
        flex: 1 1 auto;
        min-inline-size: var(--hrms-menu-target, 44px);
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item--group:has(> .hrms-menu__link[aria-expanded="true"]) {
        flex-basis: 100%;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link {
        position: relative;
        padding-inline: 12px;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link .hrms-menu__label {
        white-space: nowrap;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link:has(.hrms-menu__icon) {
        padding-inline: 0;
        justify-content: center;
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link:has(.hrms-menu__icon) .hrms-menu__label {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link:has(.hrms-menu__icon)[data-tooltip]:hover::after,
    .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link:has(.hrms-menu__icon)[data-tooltip]:focus-visible::after {
        content: attr(data-tooltip);
        position: absolute;
        inset-block-start: calc(100% + 6px);
        inset-inline-start: 50%;
        transform: translateX(-50%);
        z-index: 20;
        padding-block: 4px;
        padding-inline: 8px;
        border-radius: var(--hrms-radius-sm, 4px);
        background: var(--hrms-color-bg-inverse);
        color: var(--hrms-color-text-inverse);
        font-size: 0.8125rem;
        white-space: nowrap;
        pointer-events: none;
    }
    [dir="rtl"] .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link:has(.hrms-menu__icon)[data-tooltip]:hover::after,
    [dir="rtl"] .hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link:has(.hrms-menu__icon)[data-tooltip]:focus-visible::after {
        transform: translateX(50%);
    }
}

/* G22-01 (UX R164): the current tile is marked by more than colour: aria-current (page = the tile's own page, true = a page of its hub) gets the
   selected background and brand colour from shell.css, and band tiles add a brand bar on their block-end edge so an icon-only tile still shows it. */
.hrms-shell[data-menu-pattern="hubLauncher"] .hrms-shell__top > .hrms-menu--hub-launcher > .hrms-menu__tree > .hrms-menu__item > .hrms-menu__link[aria-current] {
    box-shadow: inset 0 -3px 0 var(--hrms-color-text-brand);
}