﻿.flashing-icon {
    animation: flash 0.5s infinite;
}

@keyframes flash {
    0% {
        opacity: 1;
    }

    25% {
        opacity: 0.5;
    }

    50% {
        opacity: 0;
    }

    75% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* =========================
   Chat Art – Base
   ========================= */
.chatart-wrap {
    color: #cbd5f5;
}

.chatart-card {
    background: rgba(18, 26, 45, 0.65);
    border: 1px solid rgba(120, 140, 200, 0.25);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

/* small helper text */
.chatart-meta {
    font-size: 12px;
    opacity: 0.92;
}

.chatart-hint {
    opacity: 0.85;
    font-size: 12px;
}

    .chatart-hint ul {
        padding-left: 1.1rem;
        margin-bottom: 0;
    }

    .chatart-hint li {
        margin-bottom: .25rem;
    }

/* =========================
   Topbar (meta + buttons)
   ========================= */
.chatart-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.chatart-btn {
    border-radius: 10px;
}

/* =========================
   Grid wrapper (the "board")
   - gives it presence on mobile
   - ensures a visible clickable area
   ========================= */
.chatart-grid-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
    border-radius: 14px;
    /* subtle “board” effect so the grid doesn't look empty */
    background: radial-gradient(circle at 18% 25%, rgba(100,180,255,0.08), transparent 55%), radial-gradient(circle at 80% 20%, rgba(72,199,142,0.06), transparent 55%), rgba(10, 16, 28, 0.35);
    border: 1px solid rgba(255,255,255,0.10);
}

/* =========================
   Grid sizing
   ========================= */
.chatart-grid {
    /* tweak these in one place */
    --cols: 16;
    --gap: 6px;
    /* clamp keeps cells usable on phones and consistent on desktop */
    --cell: clamp(18px, calc((100vw - 2.25rem - (15 * var(--gap))) / var(--cols)), 28px);
    display: grid;
    grid-template-columns: repeat(var(--cols), var(--cell));
    gap: var(--gap);
    width: fit-content;
    margin-inline: auto;
    user-select: none;
    touch-action: none;
    /* IMPORTANT: make sure the grid area doesn't look "flat" on mobile.
     We don't know rows in CSS, so give a safe minimum height. */
    min-height: calc((12 * var(--cell)) + (11 * var(--gap)));
    /* keeps it centered even if something else tries to stretch it */
    justify-content: center;
}

/* Cells – make empty ones visible enough to invite interaction */
.chatart-cell {
    width: var(--cell);
    height: var(--cell);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 0 0 1px rgba(0,0,0,0.10);
    transition: transform 80ms ease, background 80ms ease, border-color 80ms ease, box-shadow 80ms ease;
}

    .chatart-cell.is-empty {
        background: rgba(255,255,255,0.025);
        border-color: rgba(255,255,255,0.085);
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    }

    .chatart-cell.is-filled {
        background: rgba(255,255,255,0.07);
        border-color: rgba(255,255,255,0.16);
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
    }

    .chatart-cell:hover {
        transform: translateY(-1px);
        background: rgba(255,255,255,0.06);
        border-color: rgba(120,190,255,0.28);
    }

    .chatart-cell:focus-visible {
        outline: none;
        box-shadow: 0 0 0 3px rgba(100,180,255,0.18);
    }

/* =========================
   Palette
   ========================= */
.chatart-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

    .chatart-palette::-webkit-scrollbar {
        width: 6px;
    }

    .chatart-palette::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.2);
        border-radius: 999px;
    }

.chatart-swatch {
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    font-size: 16px;
}

    .chatart-swatch.active {
        border-color: rgba(100, 180, 255, 0.75);
        box-shadow: 0 0 0 3px rgba(100, 180, 255, 0.15);
    }

/* =========================
   Output
   ========================= */
.chatart-output {
    width: 100%;
    min-height: 140px;
    background: rgba(10, 16, 28, 0.8);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 12px;
    color: #e7eeff;
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", monospace;
    font-size: 12px;
}

/* =========================
   Context menu
   ========================= */
.chatart-context {
    position: fixed;
    z-index: 9999;
    min-width: 220px;
    padding: 6px;
    border-radius: 12px;
    background: rgba(12, 18, 32, 0.96);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    backdrop-filter: blur(8px);
    color: #e7eeff;
}

    .chatart-context .item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 9px 10px;
        border-radius: 10px;
        cursor: pointer;
        user-select: none;
        font-size: 13px;
        line-height: 1.1;
    }

        .chatart-context .item:hover {
            background: rgba(255,255,255,0.06);
        }

        .chatart-context .item .k {
            opacity: 0.75;
            margin-left: auto;
            font-size: 12px;
        }

    .chatart-context .divider {
        height: 1px;
        margin: 6px 4px;
        background: rgba(255,255,255,0.10);
    }

    .chatart-context .muted {
        opacity: 0.75;
        font-size: 12px;
        padding: 4px 10px 8px 10px;
    }

/* =========================
   Mobile tweaks
   ========================= */
@media (max-width: 576px) {
    .chatart-topbar {
        flex-direction: column;
        align-items: stretch;
    }

        /* make the button row usable on tiny screens */
        .chatart-topbar .d-flex.gap-2 {
            width: 100%;
            justify-content: space-between;
        }

    /* give the board a bit less padding so grid gets more width */
    .chatart-grid-wrap {
        padding: 8px;
    }

    /* slightly tighter gaps on small screens */
    .chatart-grid {
        --gap: 4px;
        /* ensure it still feels like a grid even if viewport is narrow */
        min-height: calc((var(--rows, 12) * var(--cell)) + ((var(--rows, 12) - 1) * var(--gap)));
    }

    .chatart-cell {
        border-radius: 6px;
        font-size: clamp(12px, 3.3vw, 16px);
    }
}
/* =========================
   Presets
   ========================= */
.chatart-presets .form-select,
.chatart-presets .btn {
    border-radius: 10px;
}

.chatart-presets .form-select {
    background: rgba(10, 16, 28, 0.55);
    border: 1px solid rgba(255,255,255,0.14);
    color: #e7eeff;
}

    .chatart-presets .form-select:focus {
        box-shadow: 0 0 0 3px rgba(100,180,255,0.18);
        border-color: rgba(100,180,255,0.35);
    }

#presetHint {
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
}

/* =========================
   Toolbar
   ========================= */
.chatart-toolbar {
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(10, 16, 28, 0.35);
    border: 1px solid rgba(255,255,255,0.10);
}

.chatart-tbtn {
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.chatart-toolbar-group {
    min-width: 240px;
    max-width: 360px;
}

@media (max-width: 576px) {
    .chatart-toolbar-group {
        min-width: 100%;
        max-width: 100%;
    }
}
.chatart-tbtn i {
    font-size: 1rem;
    line-height: 1;
}

.chatart-tbtn:hover {
    transform: translateY(-1px);
}

.chatart-toolbar .vr {
    height: 24px;
    opacity: 0.25;
}

@media (max-width: 576px) {
    .chatart-toolbar .vr {
        display: none;
    }
}
#btnPresetDelete:hover,
#btnClear:hover {
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}
/* =========================
   Compact toolbar dropdowns
   ========================= */
.chatart-toolbar-group {
    min-width: 160px; /* desktop default */
    max-width: 200px;
}

    .chatart-toolbar-group .form-select {
        font-size: 12px;
        padding-right: 1.75rem; /* room for caret */
    }

/* On very wide screens, allow a bit more room */
@media (min-width: 1400px) {
    .chatart-toolbar-group {
        min-width: 180px;
        max-width: 240px;
    }
}

/* Mobile: dropdowns should still be usable */
@media (max-width: 576px) {
    .chatart-toolbar-group {
        min-width: 100%;
        max-width: 100%;
    }
}
.chatart-toolbar-group .form-select option {
    max-width: 100%;
}
.chatart-toolbar-group .form-select {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =========================
   Thumbnail grid clone
   ========================= */
.chatart-thumb-grid {
    --thumb-scale: 0.33; /* ~3x smaller */
    --thumb-cell: calc(var(--cell, 24px) * var(--thumb-scale));
    display: grid;
    grid-template-columns: repeat(16, var(--thumb-cell));
    grid-auto-rows: var(--thumb-cell);
    gap: 0;
    width: fit-content;
    margin: 6px auto 12px auto;
    /* container look (optional, keep it subtle) */
    padding: 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(120, 140, 200, 0.22);
    user-select: none;
}

.chatart-thumb-cell {
    width: var(--thumb-cell);
    height: var(--thumb-cell);
    /* no spacing artifacts */
    padding: 0;
    margin: 0;
    border: 0;
    outline: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* smaller emoji */
    font-size: calc(var(--thumb-cell) * 0.9);
    line-height: 1;
}

    /* empty cells: either fully invisible, or faint (pick one) */
    .chatart-thumb-cell.is-empty {
        /* Option A: invisible (recommended) */
        opacity: 0;
        /* Option B: faint dots, if you want a subtle guide:
    opacity: 0.06;
    */
    }

/* mobile: slightly larger so it stays readable */
@media (max-width: 576px) {
    .chatart-thumb-grid {
        --thumb-scale: 0.38;
    }
}
