/*
 * The banner's user menu, shared by the schema list and the editor: a person
 * button - with a green dot while signed in, grey while not - that opens a list
 * with the user's name, the language flags and the dark theme switch, and
 * logging in or out.
 */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.user-menu [hidden],
.user-menu-list[hidden],
.user-menu-list [hidden] {
    display: none !important;
}

/* The pages differ underneath (the schema list sizes boxes by their border,
   jQuery Mobile gives the editor's labels 16px and a bottom margin), so the
   menu sets these itself to look the same on both. */
.user-menu,
.user-menu *,
.user-menu *::before,
.user-menu *::after,
.user-menu-list,
.user-menu-list *,
.user-menu-list *::before,
.user-menu-list *::after {
    box-sizing: border-box;
}

.user-menu-btn,
.user-menu-switch {
    font: 400 14px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 1px solid #475569;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.user-menu-btn:hover,
.user-menu-btn:focus-visible,
.user-menu.is-open .user-menu-btn {
    border-color: #94a3b8;
    color: #e2e8f0;
    outline: none;
}

/* Signed in: a brighter person with a green dot at its corner, ringed in
   the banner's colour so it sits apart from the button's edge. */
.user-menu-btn {
    position: relative;
}

.user-menu.is-signed-in .user-menu-btn {
    border-color: #94a3b8;
    color: #e2e8f0;
}

.user-menu.is-signed-in .user-menu-btn::after {
    content: '';
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--banner-bg, #1e293b);
    border-radius: 50%;
    background: #22c55e;
}

.user-menu.is-signed-in .user-menu-btn:hover,
.user-menu.is-signed-in .user-menu-btn:focus-visible,
.user-menu.is-signed-in.is-open .user-menu-btn {
    border-color: #e2e8f0;
    color: #ffffff;
}

.user-menu-btn svg {
    display: block;
    width: 18px;
    height: 18px;
}

/* The list moves under <body> and is placed under the button by
   user-menu.js, above jQuery Mobile's popups (1100). */
.user-menu-list {
    position: fixed;
    z-index: 1200;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-width: 220px;
    max-width: 300px;
    padding: 6px 0;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
    color: #1e293b;
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.3;
    text-align: left;
    text-shadow: none;
    white-space: nowrap;
}

.user-menu-name {
    margin-bottom: 4px;
    padding: 8px 14px 10px;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 8px 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font: inherit;
    text-align: left;
    text-shadow: none;
    cursor: pointer;
}

.user-menu-item:hover,
.user-menu-item:focus-visible {
    background: #f1f5f9;
    outline: none;
}

.user-menu-item svg {
    flex: none;
    width: 16px;
    height: 16px;
}

.user-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 14px;
}

.user-menu-list .user-menu-row label {
    display: inline;
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    cursor: pointer;
}

/* The language: the two flags side by side, the language in effect ringed
   in blue and the other one dimmed. */
.user-menu-flags {
    display: inline-flex;
    gap: 8px;
}

.user-menu-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 3px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
}

.user-menu-flag svg {
    display: block;
    width: 20px;
    height: 14px;
    border-radius: 2px;
    opacity: 0.5;
    transition: opacity 0.15s ease;
}

.user-menu-flag:hover svg {
    opacity: 0.85;
}

.user-menu-flag[aria-checked="true"] {
    box-shadow: 0 0 0 2px #2563eb;
    cursor: default;
}

.user-menu-flag[aria-checked="true"] svg {
    opacity: 1;
}

/* The theme switch: a day sky with the sun on the knob while light, a night
   sky with the moon while dark; the track shows the other one faintly. */
.user-menu-switch {
    position: relative;
    flex: none;
    width: 50px;
    height: 26px;
    margin: 0;
    padding: 0;
    border: 1px solid #93c5fd;
    border-radius: 999px;
    background: #dbeafe;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.user-menu-switch .theme-switch-track {
    position: absolute;
    top: 50%;
    width: 13px;
    height: 13px;
    transform: translateY(-50%);
    transition: opacity 0.2s ease;
}

.user-menu-switch .theme-switch-track-sun {
    left: 6px;
    color: #f59e0b;
    opacity: 0;
}

.user-menu-switch .theme-switch-track-moon {
    right: 6px;
    color: #64748b;
    opacity: 0.55;
}

.user-menu-switch .theme-switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
    transition: left 0.2s ease, background 0.2s ease;
}

.user-menu-switch .theme-switch-knob svg {
    width: 14px;
    height: 14px;
}

.user-menu-switch .theme-switch-sun {
    color: #f59e0b;
}

.user-menu-switch .theme-switch-moon,
.user-menu-switch[aria-checked="true"] .theme-switch-sun {
    display: none;
}

.user-menu-switch[aria-checked="true"] {
    border-color: #4338ca;
    background: #1e1b4b;
}

.user-menu-switch[aria-checked="true"] .theme-switch-knob {
    left: 26px;
    background: #e0e7ff;
}

.user-menu-switch[aria-checked="true"] .theme-switch-moon {
    display: block;
    color: #4338ca;
}

.user-menu-switch[aria-checked="true"] .theme-switch-track-sun {
    opacity: 0.7;
}

.user-menu-switch[aria-checked="true"] .theme-switch-track-moon {
    opacity: 0;
}

.user-menu-flag:focus-visible,
.user-menu-switch:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.user-menu-sep {
    height: 1px;
    margin: 4px 0;
    background: #e2e8f0;
}

body.panel-theme-dark .user-menu-list {
    border-color: #3a465c;
    background: #222838;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    color: #e2e8f0;
}

body.panel-theme-dark .user-menu-name,
body.panel-theme-dark .user-menu-sep {
    border-color: #3a465c;
}

body.panel-theme-dark .user-menu-sep {
    background: #3a465c;
}

body.panel-theme-dark .user-menu-item:hover,
body.panel-theme-dark .user-menu-item:focus-visible {
    background: #2b3345;
}

body.panel-theme-dark .user-menu-flag[aria-checked="true"] {
    box-shadow: 0 0 0 2px #60a5fa;
}

