/* Post menus — the ⋮ menu on posts (feed/partials/box_tools.php) and the
 * ⋯ menu on Watch (watch/partials/watch_area.php): ul.dropdown-menu.extended.short.tool.
 *
 * A rounded card that opens under the button, right-aligned: each item has a
 * round tinted icon chip, groups are split by a thin line, and Report / Block /
 * Delete (li.is-danger) are red. On phones (≤480px) it is a bottom sheet with a
 * grab handle over a dimmed page.
 *
 * Replaces the old look from style.css (.dropdown-menu.extended.short: lopsided
 * 10/5/10/2 corners, hard-coded left offsets, the white arrow nub) for these two
 * menus only; colours come from the sb_theme.css tokens so dark mode follows.
 * Loaded after sb_theme.css (includes/head.php), selectors carry "body" so they
 * win over style.css, style-responsive.css and watch/css/slides.css. */

body .dropdown-menu.extended.short.tool {
    --sbm-surface: var(--sb-surface, #fff);
    --sbm-text: var(--sb-text, #111);
    --sbm-muted: var(--sb-text-muted, rgba(0,0,0,.5));
    --sbm-hover: var(--sb-hover, #f2f3f5);
    --sbm-chip: var(--sb-surface-2, #f0f2f5);
    --sbm-border: var(--sb-border, #e6e6e6);
    --sbm-danger: var(--sb-danger, #c0392b);

    left: auto !important;
    right: 0 !important;
    top: calc(100% + 6px) !important;
    bottom: auto !important;
    width: 248px !important;
    max-width: calc(100vw - 24px) !important;
    min-width: 0;
    margin: 0;
    padding: 6px !important;
    background: var(--sbm-surface) !important;
    color: var(--sbm-text) !important;
    border: 1px solid var(--sbm-border) !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 32px rgba(15, 20, 30, .16), 0 2px 6px rgba(15, 20, 30, .08) !important;
    font-size: 14px !important;
    text-align: left;
    z-index: 1000;
    transform-origin: top right;
}
body .open > .dropdown-menu.extended.short.tool {
    animation: sbmIn .14s ease-out;
}
@keyframes sbmIn {
    from { opacity: 0; transform: translateY(-4px) scale(.97); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    body .open > .dropdown-menu.extended.short.tool { animation: none; }
}

/* No arrow nub on these menus (older markup may still have it). */
body .dropdown-menu.extended.short.tool > .notify-arrow { display: none !important; }

body .dropdown-menu.extended.short.tool > li {
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
    border: 0;
}
body .dropdown-menu.extended.short.tool > li > a {
    display: flex !important;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 6px 10px !important;
    min-height: 42px;
    border-radius: 10px !important;
    color: var(--sbm-text) !important;
    background: transparent !important;
    font-size: 14px !important;
    font-weight: 500;
    line-height: 1.3;
    white-space: normal;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color .12s ease;
}
body .dropdown-menu.extended.short.tool > li > a:hover,
body .dropdown-menu.extended.short.tool > li > a:focus-visible {
    background: var(--sbm-hover) !important;
    color: var(--sbm-text) !important;
    outline: none;
}
body .dropdown-menu.extended.short.tool > li > a:focus-visible {
    box-shadow: inset 0 0 0 2px var(--sb-link, #0073b7);
}

/* The leading icon (feather <i> or the 🎁 span) as a round chip. */
body .dropdown-menu.extended.short.tool > li > a > i:first-child,
body .dropdown-menu.extended.short.tool > li > a > span[aria-hidden="true"]:first-child {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border-radius: 50%;
    background: var(--sbm-chip);
    color: var(--sbm-text);
    font-size: 15px;
    line-height: 1;
}

/* Report, Block, Delete / Remove. */
body .dropdown-menu.extended.short.tool > li.is-danger > a,
body .dropdown-menu.extended.short.tool > li.is-danger > a:hover {
    color: var(--sbm-danger) !important;
}
body .dropdown-menu.extended.short.tool > li.is-danger > a > i:first-child {
    color: var(--sbm-danger);
    background: color-mix(in srgb, var(--sbm-danger) 12%, transparent);
}

/* Group separators. */
body .dropdown-menu.extended.short.tool > li.divider {
    height: 1px !important;
    margin: 5px 8px !important;
    padding: 0 !important;
    background: var(--sbm-border) !important;
    overflow: hidden;
}
body .dropdown-menu.extended.short.tool > li.divider:first-child,
body .dropdown-menu.extended.short.tool > li.divider + li.divider,
body .dropdown-menu.extended.short.tool > li.divider:last-child { display: none; }

/* Watch: the menu hangs under the ⋯ button in the top bar. */
.top-right-options { position: relative; }
/* The top bar (z-index 20) would hold the open menu under Watch's bottom bar on phones. */
.top-bar:has(> .top-right-options.open) { z-index: 10001 !important; }

/* Phones: a bottom sheet over a dimmed page. Bootstrap puts a
 * .dropdown-backdrop next to the button on touch screens. */
@media (max-width: 480px) {
    body .dropdown-menu.extended.short.tool,
    body ul.dropdown-menu.extended.short.tool {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        max-height: 80vh;
        overflow-y: auto;
        padding: 22px 10px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
        border: 0 !important;
        border-radius: 18px 18px 0 0 !important;
        /* The page behind dims (the shadow's spread), with or without Bootstrap's touch backdrop. */
        box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .42), 0 -8px 30px rgba(0, 0, 0, .22) !important;
        z-index: 1040 !important; /* over the bottom bar (sb_mobile_nav.css, 1030) */
        transform-origin: bottom center;
    }
    body .dropdown-menu.extended.short.tool::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: 2px;
        background: var(--sbm-border);
    }
    body .open > .dropdown-menu.extended.short.tool { animation: sbmUp .18s ease-out; }
    body .dropdown-menu.extended.short.tool > li > a {
        min-height: 50px;
        font-size: 15px !important;
    }
    body .dropdown.open > .dropdown-backdrop,
    .top-right-options.open > .dropdown-backdrop {
        position: fixed;
        inset: 0;
        background: transparent;
        z-index: 1039;
    }
}
@keyframes sbmUp {
    from { transform: translateY(24px); opacity: .6; }
    to   { transform: none; opacity: 1; }
}
