/* Optional account control alongside the shared header language selector. */
.site-auth {
    position: relative;
    flex: 0 0 auto;
    max-width: min(100%, 12rem);
    color: var(--text-color);
    text-align: start;
}

.site-auth > summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 35px;
    max-width: 100%;
    padding: .4rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface);
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.4;
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.site-auth > summary::-webkit-details-marker {
    display: none;
}

.site-auth > summary::after {
    flex: 0 0 auto;
    width: 5px;
    height: 5px;
    margin-inline-start: .2rem;
    border-inline-end: 1px solid currentColor;
    border-block-end: 1px solid currentColor;
    content: '';
    transform: rotate(45deg) translateY(-2px);
    opacity: .65;
}

.site-auth[open] > summary,
.site-auth > summary:hover {
    border-color: #fca5a5;
    background: var(--primary-soft);
    color: var(--primary-hover);
}

#site-auth-label {
    display: block;
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-auth-menu {
    position: absolute;
    inset-block-start: calc(100% + .65rem);
    inset-inline-end: 0;
    z-index: 120;
    display: grid;
    gap: .55rem;
    width: 260px;
    max-width: calc(100vw - 2rem);
    padding: .85rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.site-auth [hidden] {
    display: none !important;
}

#site-auth-providers {
    display: grid;
    gap: .5rem;
}

.site-auth-provider,
.site-auth-logout,
.site-auth-retry {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-color);
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.site-auth-provider:hover,
.site-auth-logout:hover,
.site-auth-retry:hover {
    border-color: #fca5a5;
    background: var(--primary-soft);
    color: var(--primary-hover);
}

.site-auth-provider[aria-disabled="true"],
.site-auth button:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.site-auth-provider[aria-disabled="true"]:hover {
    border-color: var(--border-color);
    background: var(--surface);
    color: var(--text-color);
}

.site-auth-email {
    margin: 0;
    padding: .1rem .15rem .4rem;
    font-size: .8rem;
    font-weight: 500;
    text-align: start;
    overflow-wrap: anywhere;
}

.site-auth-status {
    margin: .15rem 0 0;
    color: var(--light-text);
    font-size: .74rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.site-auth-status.is-error {
    color: #b91c1c;
}

.site-auth summary:focus-visible,
.site-auth a:focus-visible,
.site-auth button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

@media (max-width: 640px) {
    .site-auth {
        max-width: 11rem;
    }

    .site-auth > summary {
        padding: .4rem .65rem;
        font-size: .76rem;
    }

    #site-auth-label {
        max-width: 8.5rem;
    }
}

/* Keep the primary navigation and optional account controls compact. */
header:has(> #site-auth) {
    flex-direction: row;
    gap: .5rem .9rem;
    padding: .7rem 1rem;
}

header:has(> #site-auth) > nav ul {
    gap: .1rem;
}

header:has(> #site-auth) > nav ul li a {
    gap: .35rem;
    padding: .45rem .55rem;
    font-size: .8rem;
}

header:has(> #site-auth) > nav ul li a i {
    font-size: .78rem;
}

header:has(> #site-auth) .language-menu {
    gap: .4rem;
    font-size: .8rem;
}

header:has(> #site-auth) .language-menu label {
    font-size: 0;
}

header:has(> #site-auth) .language-menu label i {
    font-size: .82rem;
}

header:has(> #site-auth) .language-menu select {
    min-width: 7rem;
    max-width: 9rem;
    min-height: 35px;
    padding-block: .4rem;
    padding-inline-start: .65rem;
    padding-inline-end: 2.2rem;
    background-position: right 10px center;
    font-size: .8rem;
}

@media (max-width: 1100px) {
    header:has(> #site-auth) > .site-auth {
        order: 1;
    }

    header:has(> #site-auth) > nav {
        order: 2;
        flex-basis: 100%;
    }
}

@media (max-width: 640px) {
    header:has(> #site-auth) {
        justify-content: space-between;
        gap: .55rem .6rem;
        padding-inline: .75rem;
    }

    header:has(> #site-auth) > .logo {
        flex-basis: 100%;
        text-align: center;
    }

    header:has(> #site-auth) .language-menu {
        flex: 1 1 0;
        justify-content: flex-start;
        min-width: 0;
        margin-inline: 0;
    }

    header:has(> #site-auth) > .site-auth {
        flex: 0 1 auto;
        min-width: 0;
    }

    header:has(> #site-auth) > nav ul {
        gap: .05rem;
    }

    header:has(> #site-auth) > nav ul li a {
        gap: .3rem;
        padding: .4rem .5rem;
        font-size: .78rem;
    }

    #site-auth-label {
        min-width: 0;
    }
}
