/* The site header's controls, shared by every page that draws the site's top
   bar: the static pages (public/static/header.js builds them) and the app's own
   Games and Custom Creator pages (ui/components/site_header.rs draws the same
   markup). Scoped to `.amx-hd-actions`, not to a page's body, so both load it
   unchanged; the tokens are the theme template's, which both define.

   The two controls: the account (Sign In,
   or your picture and name with your account's menu) and the site menu. Both
   menus open as panels under the bar; their entries rise in one after another
   (--i is each entry's place) and fade out together on close. */
.amx-hd-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.amx-hd-actions .amx-hd-account-slot {
    display: flex;
    align-items: center;
}

.amx-hd-actions .amx-hd-menu {
    position: relative;
}

.amx-hd-actions .amx-hd-sign-in,
.amx-hd-actions .amx-hd-account,
.amx-hd-actions .amx-hd-burger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 38px;
    border: 1px solid var(--button-border);
    border-radius: 8px;
    background: var(--button-bg);
    color: var(--button-text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.amx-hd-actions .amx-hd-sign-in {
    padding: 0 16px;
    border-color: transparent;
    background: var(--accent-gradient);
    color: var(--button-primary-text);
}

.amx-hd-actions .amx-hd-sign-in:focus-visible,
.amx-hd-actions .amx-hd-account:focus-visible,
.amx-hd-actions .amx-hd-burger:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.amx-hd-actions .amx-hd-sign-in:hover {
    color: var(--button-primary-text);
    filter: brightness(1.08);
}

.amx-hd-actions .amx-hd-account {
    padding: 3px 4px 3px 14px;
}

.amx-hd-actions .amx-hd-account-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.amx-hd-actions .amx-hd-avatar {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 30px;
    height: 30px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--accent-bg-hover);
    color: var(--text-color);
    font-size: 0.82rem;
    font-weight: 700;
}

.amx-hd-actions .amx-hd-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.amx-hd-actions .amx-hd-burger {
    flex-direction: column;
    gap: 4px;
    width: 40px;
    padding: 0;
}

.amx-hd-actions .amx-hd-burger span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform 200ms ease, opacity 150ms ease;
}

/* The three lines fold into a cross while the menu is open. */
.amx-hd-actions .amx-hd-burger[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.amx-hd-actions .amx-hd-burger[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.amx-hd-actions .amx-hd-burger[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.amx-hd-actions .amx-hd-account:hover,
.amx-hd-actions .amx-hd-burger:hover,
.amx-hd-actions .amx-hd-account[aria-expanded="true"],
.amx-hd-actions .amx-hd-burger[aria-expanded="true"] {
    border-color: var(--accent-color);
    background: var(--accent-bg-hover);
    color: var(--text-color);
}

.amx-hd-actions .amx-hd-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 110;
    display: grid;
    gap: 2px;
    width: 300px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--panel-bg-opaque);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition: opacity 250ms cubic-bezier(0.2, 0.7, 0.3, 1), transform 250ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.amx-hd-actions .amx-hd-panel[hidden] {
    display: none;
}

.amx-hd-actions .amx-hd-panel--account {
    width: 260px;
}

.amx-hd-actions .is-open > .amx-hd-panel {
    opacity: 1;
    transform: none;
}

.amx-hd-actions .amx-hd-panel > * {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 250ms cubic-bezier(0.2, 0.7, 0.3, 1), transform 250ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

.amx-hd-actions .is-open > .amx-hd-panel > * {
    opacity: 1;
    transform: none;
    transition-duration: 280ms;
    transition-delay: calc(var(--i, 0) * 32ms + 40ms);
}

.amx-hd-actions .amx-hd-site-link {
    display: grid;
    grid-template-columns: 36px 1fr;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--text-color);
}

.amx-hd-actions .amx-hd-site-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-bg);
    color: var(--accent-color);
}

.amx-hd-actions .amx-hd-site-icon svg {
    width: 19px;
    height: 19px;
}

.amx-hd-actions .amx-hd-site-words {
    display: grid;
    gap: 1px;
    line-height: 1.25;
}

.amx-hd-actions .amx-hd-site-words strong {
    font-size: 0.92rem;
}

.amx-hd-actions .amx-hd-site-words small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* The Deck Builder leads the menu, set apart from the pages under it. */
.amx-hd-actions .amx-hd-site-link.is-primary {
    margin-bottom: 6px;
    background: var(--accent-bg);
}

.amx-hd-actions .amx-hd-site-link.is-primary .amx-hd-site-icon {
    background: var(--accent-gradient);
    color: var(--button-primary-text);
}

.amx-hd-actions .amx-hd-site-link[aria-current="page"] strong {
    color: var(--accent-color);
}

.amx-hd-actions .amx-hd-account-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    padding: 8px 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.amx-hd-actions .amx-hd-account-head .amx-hd-avatar {
    width: 38px;
    height: 38px;
}

.amx-hd-actions .amx-hd-account-who {
    display: grid;
    min-width: 0;
    line-height: 1.3;
}

.amx-hd-actions .amx-hd-account-who strong,
.amx-hd-actions .amx-hd-account-who small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.amx-hd-actions .amx-hd-account-who strong {
    color: var(--text-color);
    font-size: 0.92rem;
}

.amx-hd-actions .amx-hd-account-who small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.amx-hd-actions .amx-hd-account-link {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}

.amx-hd-actions .amx-hd-sign-out {
    margin-top: 6px;
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    color: var(--danger-color);
}

.amx-hd-actions .amx-hd-site-link:hover,
.amx-hd-actions .amx-hd-site-link:focus-visible,
.amx-hd-actions .amx-hd-account-link:hover,
.amx-hd-actions .amx-hd-account-link:focus-visible {
    background: var(--accent-bg-hover);
    color: var(--text-color);
    filter: none;
}

.amx-hd-actions .amx-hd-site-link:focus-visible,
.amx-hd-actions .amx-hd-account-link:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
}

.amx-hd-actions .amx-hd-sign-out:hover,
.amx-hd-actions .amx-hd-sign-out:focus-visible {
    color: var(--danger-color);
}

@media (prefers-reduced-motion: reduce) {
    .amx-hd-actions .amx-hd-panel,
    .amx-hd-actions .amx-hd-panel > *,
    .amx-hd-actions .amx-hd-burger span {
        transition: none;
    }
}

@media (max-width: 680px) {
    /* On a phone the account shows its picture alone, and the menus span the
       width under the bar. */
    .amx-hd-actions .amx-hd-account {
        padding: 3px;
    }

    .amx-hd-actions .amx-hd-account-name {
        display: none;
    }

    .amx-hd-actions .amx-hd-menu {
        position: static;
    }

    .amx-hd-actions .amx-hd-panel,
    .amx-hd-actions .amx-hd-panel--account {
        /* The sticky bar's backdrop filter makes it the containing block for
           fixed descendants, so 100% is the bar's own height. */
        position: fixed;
        top: calc(100% + 8px);
        right: 16px;
        left: 16px;
        width: auto;
    }
}
