/* Grim, the support mascot (static/js/grim.js; docs/plans/community/GRIM_SUPPORT_PLAN.md "Where Grim sits").
   The conversation's messages (shared by the lobby perch and the Codex's Ask Grim box) and the perch itself.
   Stacking: below the Codex (80), the lobby's effects layer (80) and toast (90); the phone bottom bar is 44. */

/* ---- the conversation ---- */
.grim-msg { max-width: 88%; padding: 10px 12px; border-radius: 4px 14px 14px 14px; background: #1d1e27; color: #ece6d8;
    font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.grim-msg.me { align-self: flex-end; max-width: 80%; border-radius: 14px 4px 14px 14px; background: #f5b301; color: #1a1305; font-weight: 500; }
.grim-msg-wrap { align-self: flex-start; max-width: 88%; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.grim-msg-wrap .grim-msg { max-width: 100%; }
.grim-tag { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px;
    border: 1px solid currentColor; color: #f5b301; }
.grim-tag.codex { color: #5eead4; }
.grim-tag.humans { color: #fb923c; }
.grim-tag.account { color: #c4b5fd; }
.grim-tag.serious { color: #93c5fd; }
.grim-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.grim-act { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(245, 179, 1, .55); background: rgba(245, 179, 1, .08);
    color: #f5c542; font: 600 13px Inter, system-ui, sans-serif; cursor: pointer; text-align: left; }
.grim-act:hover { background: rgba(245, 179, 1, .16); }
.grim-act.primary { border: 0; background: #f5b301; color: #1a1305; font-weight: 700; }
.grim-act.primary:hover { background: #fcd34d; }
/* Thumbs on her answers (Phase 2): quiet until hovered or chosen. 32 px targets inside a 36 px row. */
.grim-votes { display: flex; gap: 2px; margin-top: -2px; }
.grim-vote { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 8px;
    background: transparent; color: #6f6a62; cursor: pointer; }
.grim-vote:hover { color: #d6d0c5; background: rgba(255, 255, 255, .05); }
.grim-vote.on { color: #f5b301; }
.grim-vote svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.grim-vote.on svg { fill: rgba(245, 179, 1, .18); }
.grim-act:focus-visible, .grim-chip:focus-visible, .grim-bird:focus-visible, .grim-tab:focus-visible, .grim-x:focus-visible,
.grim-send:focus-visible, .grim-hide:focus-visible, .grim-vote:focus-visible { outline: 2px solid #f5b301; outline-offset: 3px; }
.grim-typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.grim-typing i { width: 6px; height: 6px; border-radius: 50%; background: #a39e92; animation: grim-dot 1.2s ease-in-out infinite; }
.grim-typing i:nth-child(2) { animation-delay: .15s; }
.grim-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes grim-dot { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
html.calm-motion .grim-typing i { animation: none; }

/* ---- her drawings: idle motion (a head tilt, a blink). Calm motion holds her still; low graphics holds the loops on
   their first frame (SceneLoop), which is the resting pose. ---- */
.grim-side, .grim-portrait { display: block; width: 100%; height: 100%; }
.grim-tilt { transform-box: view-box; transform-origin: 72px 58px; animation: grim-tilt 9s ease-in-out infinite; }
.grim-lid { transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); animation: grim-blink 5.5s linear infinite; }
@keyframes grim-tilt { 0%, 58% { transform: rotate(0); } 64%, 86% { transform: rotate(-9deg); } 100% { transform: rotate(0); } }
@keyframes grim-blink { 0%, 90% { transform: scaleY(0); } 93% { transform: scaleY(1); } 96%, 100% { transform: scaleY(0); } }
html.calm-motion .grim-tilt, html.calm-motion .grim-lid { animation: none; }

/* ---- the lobby perch: bottom left, 96 x 112 (64 x 75 on a phone) ---- */
.grim-perch { position: fixed; left: 14px; bottom: 12px; z-index: 40; font-family: Inter, system-ui, sans-serif; color: #ece6d8; }
.grim-bird { display: block; width: 96px; height: 112px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 12px;
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .6)); transition: transform .3s ease; }
.grim-bird:hover .grim-side { transform: translateY(-2px); }
.grim-side { transition: transform .2s ease; }
/* tucked in while the page scrolls: only the head and crown peek over the bottom edge, over a soft dark fade */
.grim-perch::before { content: ''; position: fixed; left: 0; bottom: 0; width: 150px; height: 70px; pointer-events: none; opacity: 0;
    background: radial-gradient(ellipse at 30% 100%, rgba(5, 6, 9, .85), rgba(5, 6, 9, 0) 70%); transition: opacity .3s ease; }
.grim-perch.tucked::before { opacity: 1; }
.grim-perch.tucked .grim-bird { transform: translateY(64px); }
.grim-perch.away::before { display: none; }

.grim-bubble { position: absolute; left: 102px; bottom: 62px; width: max-content; max-width: 250px; padding: 11px 14px 12px; cursor: pointer;
    background: #15161d; border: 1px solid rgba(245, 179, 1, .45); border-radius: 14px 14px 14px 4px; box-shadow: 0 14px 34px rgba(0, 0, 0, .55);
    font-size: 14px; line-height: 1.45; animation: grim-in .35s ease both; }
.grim-bubble b { display: block; margin-bottom: 2px; font: 700 14px 'Playfair Display', Georgia, serif; color: #f5b301; }
@keyframes grim-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
html.calm-motion .grim-bubble, html.calm-motion .grim-card { animation: none; }
html.calm-motion .grim-bird, html.calm-motion .grim-side, html.calm-motion .grim-perch::before { transition: none; }

.grim-card { position: fixed; left: 16px; bottom: 136px; z-index: 41; width: min(360px, calc(100vw - 32px)); height: min(520px, calc(100vh - 210px)); height: min(520px, calc(100dvh - 210px));
    display: flex; flex-direction: column; background: #111218; border: 1px solid rgba(245, 179, 1, .35); border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .65); overflow: hidden; animation: grim-in .2s ease both; }
.grim-card[hidden] { display: none; }
/* the Social Tray (a 340 px rail that pushes the page) never meets her card */
html.social-open .grim-card { max-width: calc(100vw - var(--st-w, 340px) - 32px); }
.grim-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; background: #16171f; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.grim-face { flex: none; width: 46px; height: 46px; border-radius: 50%; overflow: hidden; border: 1px solid rgba(245, 179, 1, .5); background: #20212b; }
.grim-who { flex: 1; min-width: 0; }
.grim-who b { display: block; font: 700 19px 'Playfair Display', Georgia, serif; color: #f3ead7; }
.grim-who small { font-size: 12px; color: #a39e92; }
.grim-x { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, .12); background: transparent; color: #cfc8bb; cursor: pointer; }
.grim-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.grim-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 12px; }
.grim-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; }
.grim-chips[hidden] { display: none; }
.grim-chip { min-height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid rgba(245, 179, 1, .35); background: transparent;
    color: #e9dcc0; font: 500 12.5px Inter, system-ui, sans-serif; cursor: pointer; }
.grim-chip:hover { background: rgba(245, 179, 1, .14); }
.grim-form { display: flex; gap: 8px; padding: 0 14px 10px; }
.grim-form input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .12);
    background: #0c0d12; color: #ece6d8; font: 14px Inter, system-ui, sans-serif; }
.grim-form input::placeholder { color: #8f8a7f; }
.grim-form input:focus { outline: none; border-color: rgba(245, 179, 1, .6); }
.grim-send { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 12px; border: 0;
    background: #f5b301; color: #1a1305; cursor: pointer; }
.grim-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.grim-foot { display: flex; align-items: flex-end; gap: 10px; padding: 0 14px 12px; font-size: 11px; line-height: 1.4; color: #9d978b; }
.grim-foot span { flex: 1; }
.grim-hide { flex: none; padding: 4px 0; border: 0; background: none; color: #cfc8bb; font: 600 11px Inter, system-ui, sans-serif;
    text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.grim-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* put away: a crown-shaped tab at the screen's left edge */
.grim-tab { position: fixed; left: 0; bottom: 24px; width: 40px; height: 44px; padding: 8px 6px 8px 4px; border: 1px solid rgba(245, 179, 1, .45);
    border-left: 0; border-radius: 0 12px 12px 0; background: #15161d; box-shadow: 0 8px 20px rgba(0, 0, 0, .5); cursor: pointer; }
.grim-tab[hidden], .grim-bird[hidden] { display: none; }
.grim-tab svg { width: 100%; height: 100%; }

@media (max-width: 767px) {
    /* above the bottom bar, the safe area and the lobby toast's line */
    /* at rest she peeks from the left edge (her head and crown, 30 px), not over the lobby's cards (the Rewards
       card's tiles sat under her: MOBILE_CLEANUP_PLAN.md, launch audit); a tap opens her card as before */
    .grim-perch { left: 0; bottom: calc(var(--lr-bar, 0px) + 76px); }
    .grim-bird { width: 64px; height: 75px; transform: translateX(-34px); }
    /* tucked (the page scrolled away from its top, static/js/grim.js): off the left edge, so she never sits on a
       card's footer (MOBILE_CLEANUP_PLAN.md phase 2) */
    .grim-perch.tucked .grim-bird { transform: translateX(calc(-100% - 12px)); }
    .grim-perch::before { display: none; }
    .grim-bubble { left: 70px; bottom: 40px; max-width: min(230px, calc(100vw - 96px)); }
    .grim-card { left: 0; right: 0; bottom: var(--lr-bar, 0px); width: auto; max-width: none; height: min(640px, calc(100vh - var(--lr-bar, 0px) - 56px)); height: min(640px, calc(100dvh - var(--lr-bar, 0px) - 56px));
        border-radius: 18px 18px 0 0; border-bottom: 0; }
    html.social-open .grim-card { max-width: none; }
    .grim-tab { bottom: calc(var(--lr-bar, 0px) + 84px); }
}
