/* ==========================================================================
   Site action bar
   --------------------------------------------------------------------------
   Icons for a card's main actions plus a ⋮ "More actions" menu.
   Drawn by templates/components/site_action_bar.html (Django) and by
   createSiteActionBar() in static/js/siteUI.js (JavaScript); both draw the
   same markup. base.html loads this file on every page.

     .site-action-bar              row holding the icons and the ⋮ menu
     .site-action-icon             one icon button or link (also the ⋮ button)
     .site-action-menu             the ⋮ menu (a <details> element)
     .site-action-menu__panel      the list that opens under the ⋮ button
     .site-action-menu__item       one row of the list: icon + words
     .site-action-menu__item--danger   a red row (Delete)
   ========================================================================== */

.site-action-bar {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
}

/* --------------------------------------------------------------------------
   Icons (buttons, links, and the ⋮ button)
   -------------------------------------------------------------------------- */

/* Two classes, so the site's global a:link and button rules do not win.
   inline-flex centres the icon in the round hover background; lined up with
   the text line, it sat about 3px low. */
.site-action-bar .site-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #0073b1;
    cursor: pointer;
    line-height: 36px;
    text-align: center;
    transition: background-color 150ms ease-in-out;
}

.site-action-bar .site-action-icon:hover,
.site-action-bar .site-action-icon:focus-visible,
.site-action-menu[open] > .site-action-menu__button {
    background: #e8eef5;
    color: #005a8c;
    outline: 0;
}

.site-action-bar .site-action-icon:focus-visible {
    box-shadow: 0 0 0 2px #0073b1;
}

/* margin and padding are reset because site2.css gives every "button svg" a
   0.1rem 1rem margin, which pushed the icon off centre in a button's round
   hover background (links were not affected). */
.site-action-svg {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    margin: 0;
    vertical-align: middle;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   The ⋮ menu
   -------------------------------------------------------------------------- */

.site-action-menu {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
}

/* Hide the disclosure triangle every browser draws on a <summary>. */
.site-action-menu > .site-action-menu__button {
    list-style: none;
}

.site-action-menu > .site-action-menu__button::-webkit-details-marker {
    display: none;
}

.site-action-menu > .site-action-menu__button::marker {
    content: "";
}

/* Without JavaScript the list opens under the button, lined up on its right edge.
   site_action_menu.js switches it to .is-floating so a card that hides
   overflowing content cannot cut it off. */
.site-action-menu__panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 184px;
    max-width: calc(100vw - 32px);
    margin: 0;
    padding: 4px;
    border: 1px solid #dbe5ee;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
    text-align: left;
}

.site-action-menu__panel.is-floating {
    position: fixed;
    right: auto;
}

/* Two classes, so the site's global a:link and button rules do not win. */
.site-action-menu__panel .site-action-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #26384e;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
}

.site-action-menu__panel .site-action-menu__item:hover,
.site-action-menu__panel .site-action-menu__item:focus-visible {
    background: #f1f8f6;
    color: #0f766e;
    outline: 0;
    text-decoration: none;
}

.site-action-menu__panel .site-action-menu__item:focus-visible {
    box-shadow: inset 0 0 0 2px #0f766e;
}

.site-action-menu__panel .site-action-menu__item .site-action-svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

/* site.css sets 13px on every element, so the words need their own size. */
.site-action-menu__label {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
}

.site-action-menu__panel .site-action-menu__item--danger,
.site-action-menu__panel .site-action-menu__item--danger:hover,
.site-action-menu__panel .site-action-menu__item--danger:focus-visible {
    color: #b42318;
}

.site-action-menu__panel .site-action-menu__item--danger:hover,
.site-action-menu__panel .site-action-menu__item--danger:focus-visible {
    background: #fef3f2;
}

/* Phones: rows a little taller, so they are easy to tap. */
@media (max-width: 520px) {
    .site-action-menu__panel .site-action-menu__item {
        min-height: 44px;
    }
}

/* --------------------------------------------------------------------------
   Dark theme
   -------------------------------------------------------------------------- */

.dark .site-action-bar .site-action-icon,
[data-theme="dark"] .site-action-bar .site-action-icon,
[data-bs-theme="dark"] .site-action-bar .site-action-icon {
    color: #7cc4f8;
}

.dark .site-action-bar .site-action-icon:hover,
.dark .site-action-bar .site-action-icon:focus-visible,
.dark .site-action-menu[open] > .site-action-menu__button,
[data-theme="dark"] .site-action-bar .site-action-icon:hover,
[data-theme="dark"] .site-action-bar .site-action-icon:focus-visible,
[data-theme="dark"] .site-action-menu[open] > .site-action-menu__button,
[data-bs-theme="dark"] .site-action-bar .site-action-icon:hover,
[data-bs-theme="dark"] .site-action-bar .site-action-icon:focus-visible,
[data-bs-theme="dark"] .site-action-menu[open] > .site-action-menu__button {
    background: rgba(255, 255, 255, 0.1);
    color: #b9e0fc;
}

.dark .site-action-menu__panel,
[data-theme="dark"] .site-action-menu__panel,
[data-bs-theme="dark"] .site-action-menu__panel {
    border-color: #38546f;
    background: #101a2d;
    box-shadow: 0 12px 32px rgba(2, 6, 23, 0.5);
}

.dark .site-action-menu__panel .site-action-menu__item,
[data-theme="dark"] .site-action-menu__panel .site-action-menu__item,
[data-bs-theme="dark"] .site-action-menu__panel .site-action-menu__item {
    color: #eef5ff;
}

.dark .site-action-menu__panel .site-action-menu__item:hover,
.dark .site-action-menu__panel .site-action-menu__item:focus-visible,
[data-theme="dark"] .site-action-menu__panel .site-action-menu__item:hover,
[data-theme="dark"] .site-action-menu__panel .site-action-menu__item:focus-visible,
[data-bs-theme="dark"] .site-action-menu__panel .site-action-menu__item:hover,
[data-bs-theme="dark"] .site-action-menu__panel .site-action-menu__item:focus-visible {
    background: rgba(45, 212, 191, 0.12);
    color: #8cefe7;
}

.dark .site-action-menu__panel .site-action-menu__item--danger,
[data-theme="dark"] .site-action-menu__panel .site-action-menu__item--danger,
[data-bs-theme="dark"] .site-action-menu__panel .site-action-menu__item--danger {
    color: #fda29b;
}
