/* EmojiPicker (Elevate.Client/Shared/Components/Common/Emoji/EmojiPicker.razor).
   Global file on purpose: Client .razor.css never loads (see .claude/chapters/blazor-rendering.md).
   Every colour comes from MudBlazor palette tokens so the picker follows dark mode.
   --elevate-kb-inset / --elevate-vv-height are set on <html> by emojipicker.js while a picker is open
   (visual viewport tracking for the phone bottom sheet). */

:root {
    --elevate-emoji-font: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

.emoji-picker {
    display: inline-flex;
    align-items: center;
    position: relative;
}

.emoji-picker-activator {
    display: inline-flex;
    align-items: center;
}

/* MudBlazor writes max-width inline on this element; the width clamp is what keeps it on-screen on desktop. */
.emoji-picker-popover {
    width: min(340px, calc(100vw - 24px));
}

.emoji-picker-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 24px);
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--mud-default-borderradius);
    box-shadow: var(--mud-elevation-8);
    overflow: hidden;
}

.emoji-picker-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 8px 2px 10px;
    flex: 0 0 auto;
}

.emoji-picker-search {
    flex: 1 1 auto;
    min-width: 0;
}

.emoji-picker-search .mud-input-control {
    margin: 0;
}

/* Only the bottom sheet needs a visible dismiss control (no Escape key, little page left to tap). */
.emoji-picker-close {
    display: none;
    flex: 0 0 auto;
}

/* Wrapping, never scrolling: a horizontally scrollable strip eats the tap that follows a swipe
   (see the blazor-rendering chapter), so nine tabs wrap to a second row on narrow screens instead. */
.emoji-picker-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    flex: 0 0 auto;
}

.emoji-picker-tab {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-family: var(--elevate-emoji-font);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.emoji-picker-tab.active {
    background-color: var(--mud-palette-primary-hover);
    box-shadow: inset 0 -2px 0 var(--mud-palette-primary);
}

.emoji-picker-tab .mud-icon-root {
    width: 20px;
    height: 20px;
    color: var(--mud-palette-text-secondary);
}

.emoji-picker-tab.active .mud-icon-root {
    color: var(--mud-palette-primary);
}

.emoji-picker-loading {
    flex: 0 0 auto;
}

.emoji-picker-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 8px 2px 12px;
    flex: 0 0 auto;
    color: var(--mud-palette-text-secondary);
    background-color: var(--mud-palette-background-grey);
}

/* Fixed height for a stable popover across tabs, but allowed to shrink when the panel's ceiling binds
   (short landscape phones, a docked devtools window, a raised keyboard). */
.emoji-picker-body {
    flex: 0 1 auto;
    height: 264px;
    min-height: 96px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 8px 8px;
}

.emoji-picker-section-title {
    display: block;
    padding: 2px 4px 6px;
    color: var(--mud-palette-text-secondary);
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 2px;
}

.emoji-picker-item {
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-family: var(--elevate-emoji-font);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-picker-item:focus-visible,
.emoji-picker-tab:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -2px;
}

@media (hover: hover) and (pointer: fine) {
    .emoji-picker-item:hover,
    .emoji-picker-tab:hover {
        background-color: var(--mud-palette-action-default-hover);
    }
}

.emoji-picker-item:active {
    transform: scale(1.15);
}

.emoji-picker-empty {
    min-height: 96px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: var(--mud-palette-text-secondary);
    padding: 16px;
}

/* Syncfusion toolbar host: the activator is a native toolbar button carrying a Material icon. */
.e-toolbar .emoji-picker-activator .e-tbar-btn .rte-emoji-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
}

/* Touch: every target at the 44px floor the rest of the app uses (a finger pad over 38px cells hits three
   glyphs at once). */
@media (pointer: coarse) {
    .emoji-picker-tab {
        width: 44px;
        height: 44px;
    }

    .emoji-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
        gap: 4px;
    }

    .emoji-picker-item {
        height: 44px;
        min-height: 44px;
    }
}

/* Narrow or short screens: the popover becomes a bottom sheet so the grid stays reachable and never
   overflows the viewport. MudBlazor positions popovers with inline top/left, hence the !important
   overrides. The two variables keep the sheet above a raised soft keyboard (emojipicker.js). */
@media (max-width: 600px), (max-height: 480px) {
    .mud-popover.emoji-picker-popover {
        position: fixed !important;
        top: auto !important;
        left: 8px !important;
        right: 8px !important;
        bottom: calc(8px + var(--elevate-kb-inset, 0px) + env(safe-area-inset-bottom, 0px)) !important;
        width: auto !important;
        max-width: none !important;
        transform: none !important;
    }

    .emoji-picker-panel {
        max-height: calc(var(--elevate-vv-height, 100dvh) - 16px);
    }

    .emoji-picker-body {
        height: 38vh;
    }

    .emoji-picker-close {
        display: inline-flex;
    }
}
