/*
 | @mentions and reactions (.mgr-*): the mention chip in rendered text, the
 | @ picker, the reaction control and the "who reacted" dialog. Shared by
 | lesson/course/tip comments (.discussion), the group Discussion (.mgd) and
 | tip cards (.mtp-card). Same tokens as discussion.css.
 */
.mgr, .mgr-pick, .mgr-who, .mgr-mention {
    --mgr-brand: #4242d6;
    --mgr-brand-soft: #eef0ff;
    --mgr-ink: #1c1c6e;
    --mgr-muted: #6b7280;
    --mgr-line: #e5e7eb;
    --mgr-hair: #eef0f6;
    --mgr-love: #e0245e;
    --mgr-warm: #b45309;
}

.mgr-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- mention chip, inside rendered text ---------- */
.mgr-mention {
    padding: 0 3px;
    border-radius: 5px;
    background: var(--mgr-brand-soft);
    color: var(--mgr-brand);
    font-weight: 600;
    text-decoration: none;
    unicode-bidi: isolate;
    white-space: nowrap;
}
a.mgr-mention:hover { background: #e0e4ff; color: #3434b8; text-decoration: underline; }
a.mgr-mention:focus-visible { outline: 2px solid var(--mgr-brand); outline-offset: 1px; }

/* ---------- the @ picker ---------- */
.mgr-pick {
    position: fixed;
    z-index: 1090;
    max-height: 288px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--mgr-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(27, 29, 58, .06), 0 12px 32px rgba(27, 29, 58, .14);
}
.mgr-pick__item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
}
.mgr-pick__item.is-active, .mgr-pick__item:hover { background: var(--mgr-brand-soft); }
.mgr-pick__face {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--mgr-hair);
    color: var(--mgr-brand);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}
.mgr-pick__face--icon { border-radius: 8px; font-size: 18px; }
.mgr-pick__text { display: grid; min-width: 0; }
.mgr-pick__name { overflow: hidden; color: var(--mgr-ink); font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mgr-pick__sub { color: var(--mgr-muted); font-size: 12px; line-height: 1.3; }
.mgr-pick__note { padding: 10px; color: var(--mgr-muted); font-size: 13px; line-height: 1.5; }

/* ---------- reaction control ---------- */
.mgr {
    position: relative;
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}
.mgr__anchor { position: relative; display: inline-flex; }
/* While a finger is held on Like (reactions.js holdLock), a long press must open the bar, not select the post's text. */
html.mgr-holding, html.mgr-holding * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.mgr__bar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.mgr__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 8px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--mgr-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    -webkit-touch-callout: none;
    user-select: none;
    touch-action: manipulation;
    transition: background-color .15s ease, color .15s ease;
}
.mgr__btn:hover { background: var(--mgr-brand-soft); color: var(--mgr-brand); }
.mgr__btn:focus-visible { outline: 2px solid var(--mgr-brand); outline-offset: 2px; }
.mgr__btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; font-size: 16px; line-height: 1; }
.mgr__btn.is-on { color: var(--mgr-brand); }
.mgr__btn.is-love { color: var(--mgr-love); }
.mgr__btn.is-haha, .mgr__btn.is-thanks, .mgr__btn.is-insightful, .mgr__btn.is-mind_blown { color: var(--mgr-warm); }

/* The bar: floats above the button, start-aligned, emojis pop in one by one. */
.mgr__bar {
    position: absolute;
    bottom: calc(100% + 6px);
    inset-inline-start: -6px;
    z-index: 30;
    display: flex;
    gap: 2px;
    padding: 5px 6px;
    border: 1px solid var(--mgr-line);
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(27, 29, 58, .06), 0 10px 28px rgba(27, 29, 58, .16);
    white-space: nowrap;
}
/* Bridges the 6px gap so the pointer can travel from button to bar without closing it. */
.mgr__bar::after { content: ''; position: absolute; inset-inline: 0; top: 100%; height: 10px; }

.mgr__emoji {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    animation: mgr-emoji-in .28s cubic-bezier(.34, 1.56, .64, 1) both;
    animation-delay: calc(var(--i) * 30ms);
}
.mgr__glyph { font-size: 28px; line-height: 1; transition: transform .16s cubic-bezier(.34, 1.56, .64, 1); }
.mgr__emoji:hover .mgr__glyph, .mgr__emoji:focus-visible .mgr__glyph { transform: translateY(-6px) scale(1.3); }
.mgr__emoji:focus-visible { outline: 2px solid var(--mgr-brand); outline-offset: 0; }
.mgr__emoji.is-mine { background: var(--mgr-brand-soft); }
.mgr__tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(28, 28, 110, .92);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity .12s ease, transform .12s ease;
}
.mgr__emoji:hover .mgr__tip, .mgr__emoji:focus-visible .mgr__tip { opacity: 1; transform: translate(-50%, 0); }

.mgr-pop-in { transition: opacity .14s ease, transform .18s cubic-bezier(.34, 1.56, .64, 1); }
.mgr-pop-out { transition: opacity .1s ease, transform .1s ease; }
.mgr-pop-from { opacity: 0; transform: translateY(6px) scale(.96); }

@keyframes mgr-emoji-in {
    from { opacity: 0; transform: translateY(8px) scale(.6); }
    to { opacity: 1; transform: none; }
}

/* Summary: overlapping emoji discs + "You and 3 others". */
.mgr__sum {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 2px 8px 2px 4px;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--mgr-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.mgr__sum:hover { background: var(--mgr-hair); color: var(--mgr-ink); }
.mgr__sum:focus-visible { outline: 2px solid var(--mgr-brand); outline-offset: 2px; }
.mgr__faces { display: inline-flex; align-items: center; direction: ltr; }
.mgr__face {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--mgr-hair);
    font-size: 13px;
    line-height: 1;
}
.mgr__face + .mgr__face { margin-left: -6px; }
.mgr__count { white-space: nowrap; }
.mgr__error { flex-basis: 100%; color: #b42318; font-size: 12px; line-height: 1.4; }

/* ---------- who reacted ---------- */
.mgr-who {
    /* The theme resets every margin to 0, which strips the UA's margin:auto
       that centres a modal <dialog> , it then sticks to a corner. */
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(420px, calc(100vw - 32px));
    height: fit-content;
    max-height: min(560px, calc(100dvh - 48px));
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(27, 29, 58, .06), 0 24px 48px rgba(27, 29, 58, .2);
}
.mgr-who::backdrop { background: rgba(28, 28, 110, .35); }
.mgr-who__panel { display: flex; flex-direction: column; max-height: inherit; }
.mgr-who__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 20px; }
.mgr-who__title { margin: 0; color: var(--mgr-ink); font-size: 17px; font-weight: 700; line-height: 1.3; }
.mgr-who__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: var(--mgr-hair);
    color: var(--mgr-ink);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.mgr-who__close:hover { background: var(--mgr-brand-soft); }
.mgr-who__tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px;
    overflow-x: auto;
    border-bottom: 1px solid var(--mgr-hair);
    scrollbar-width: none;
}
.mgr-who__tab {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--mgr-muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}
.mgr-who__tab[aria-selected="true"] { border-bottom-color: var(--mgr-brand); color: var(--mgr-brand); }
.mgr-who__tab:focus-visible { outline: 2px solid var(--mgr-brand); outline-offset: -2px; }
.mgr-who__list { display: grid; gap: 2px; margin: 0; padding: 8px 8px 12px; overflow-y: auto; list-style: none; }
.mgr-who__row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px; border-radius: 10px; }
.mgr-who__avatar { position: relative; flex: none; }
.mgr-who__face {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: hsl(var(--mgr-hue, 240) 70% 92%);
    color: hsl(var(--mgr-hue, 240) 45% 32%);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
}
.mgr-who__badge {
    position: absolute;
    right: -4px;
    bottom: -2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #fff;
    font-size: 12px;
    line-height: 1;
}
.mgr-who__name { color: var(--mgr-ink); font-size: 15px; font-weight: 600; }
.mgr-who__note { padding: 16px 12px; color: var(--mgr-muted); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
    .mgr__emoji { animation: none; }
    .mgr__glyph, .mgr__tip, .mgr-pop-in, .mgr-pop-out { transition: none; }
}

/* Touch: bigger targets, the bar sized to the screen. */
@media (pointer: coarse) {
    .mgr__btn, .mgr__sum { min-height: 40px; }
    .mgr__emoji { width: 44px; height: 44px; }
}
@media (max-width: 380px) {
    .mgr__emoji { width: 38px; height: 38px; }
    .mgr__glyph { font-size: 24px; }
}

/* ---------- placement: lesson / course / tip comments ---------- */
.d-comment__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
.d-comment__react { display: contents; }
.d-comment__react .mgr__anchor:first-child .mgr__btn { margin-inline-start: -8px; }
/* "Like · Reply · Edit", then the emojis and count at the end of the row, as on Facebook. */
.d-comment__react .mgr__sum { order: 9; margin-inline-start: auto; }
.d-comment__react .mgr__error { order: 10; }

/* ---------- placement: group Discussion ---------- */
/* Post foot: [Like][😆❤️ 4] …………… [3 comments][Comment] */
.mgd-post__foot { justify-content: flex-start; flex-wrap: wrap; }
.mgd-post__react .mgr__anchor:first-child .mgr__btn { margin-inline-start: -8px; }
.mgd-post__foot .mgd-post__count { margin-inline-start: auto; }
/* Comment meta: [Like][👍 2] · 3h · Edit, in the meta row's smaller type. */
.mgd-comment__react .mgr__btn { min-height: 28px; margin-inline-start: -6px; padding: 2px 6px; font-size: 12px; }
.mgd-comment__react .mgr__sum { min-height: 28px; font-size: 12px; }
.mgd-comment__react .mgr__face { width: 20px; height: 20px; font-size: 12px; }

