/* =====================================================================================================
   SATORU, DRAWN FLAT: the styles for SatoruBot.razor's drawing
   Loaded by the app (App.razor) and by every server-rendered page (_Layout.cshtml), which do not load
   chatbot.css. Everything is scoped to an svg with the "ha" class, which is what SatoruBot's callers
   draw him in.
   ===================================================================================================== */

/* ---- His colours ----
   His own colours rather than the scene's, because he is a character and not a shape: a white head
   and a navy hat in either theme, like the mascot beside the chat. Dark mode only lifts the hat and
   softens the white, so he stays the brightest thing in the picture without glaring. */
:root {
    --ha-bot-shell: #FFFFFF;
    --ha-bot-edge: #C5D0DF;
    --ha-bot-hat: #1E3A5F;
    --ha-bot-visor: #13233C;
    --ha-bot-eye: #E4F6FF;
    --ha-bot-glow: #6FB8F5;
    --ha-bot-scarf: #2B63C6;
}

:root[data-theme="dark"] {
    --ha-bot-shell: #E8EEF6;
    --ha-bot-edge: #E8EEF6;
    --ha-bot-hat: #2F5E96;
    --ha-bot-visor: #0B1627;
    --ha-bot-scarf: #4A86E0;
}

.ha .ha-bot-shell { fill: var(--ha-bot-shell); stroke: var(--ha-bot-edge); stroke-width: 2.5; }
.ha .ha-bot-visor { fill: var(--ha-bot-visor); }
.ha .ha-bot-eye { fill: var(--ha-bot-eye); }
.ha .ha-bot-glow { fill: var(--ha-bot-glow); opacity: 0.45; }
.ha .ha-bot-scarf { fill: var(--ha-bot-scarf); }
.ha .ha-bot-hat { fill: var(--ha-bot-hat); }
.ha .ha-bot-rim { fill: none; stroke: var(--ha-bot-shell); stroke-width: 2.5; stroke-linecap: round; }
.ha .ha-bot-knob { fill: var(--ha-bot-shell); }
.ha .ha-bot-mark { fill: #fff; }
/* Legs, for a scene that shows more of him than his head (the wiki banner in HomeArt): a thick
   round-capped line, drawn twice, the edge colour first and a little wider, so it is outlined like
   the shell. */
.ha .ha-bot-limb-edge { fill: none; stroke: var(--ha-bot-edge); stroke-width: 15; stroke-linecap: round; }
.ha .ha-bot-limb { fill: none; stroke: var(--ha-bot-shell); stroke-width: 11; stroke-linecap: round; }
.ha .ha-bot-arc { fill: none; stroke: var(--ha-bot-eye); stroke-width: 3.5; stroke-linecap: round; }
.ha .ha-bot-arc--glow { stroke: var(--ha-bot-glow); stroke-width: 8; opacity: 0.45; }

/* Happy: the eyes give way to smiling arcs. Both are always drawn, so the change can fade. */
.ha .ha-bot-eyes,
.ha .ha-bot-happy { transition: opacity 200ms ease; }
.ha .ha-bot-happy { opacity: 0; }
.ha-bot--happy .ha-bot-happy { opacity: 1; }
.ha-bot--happy .ha-bot-eyes { opacity: 0; }

/* Sad: drooping, half-shut eyes in place of the usual ones, and his gaze dropped a little. For a
   failed answer and an index that would not build. */
.ha .ha-bot-sad { opacity: 0; transition: opacity 200ms ease; }
.ha-bot--sad .ha-bot-sad { opacity: 1; }
.ha-bot--sad .ha-bot-eyes { opacity: 0; }
.ha-bot--sad .ha-bot-look { transform: translateY(2px); }

/* Thinking, while an answer is written: the eyes drift up and from side to side. */
.ha-bot--thinking .ha-bot-look {
    animation: ha-bot-ponder 2.6s ease-in-out infinite;
}

@keyframes ha-bot-ponder {
    0%, 100% { transform: translate(-3px, -2.5px); }
    50%      { transform: translate(3px, -2.5px); }
}

/* Landed, when an answer arrives: a smile for a couple of seconds and a small hop, then himself
   again. Played once, by putting the class on; the chat gives it to the newest answer only. */
.ha-bot--landed .ha-bot-happy {
    animation: ha-bot-smile 2.8s ease both;
}

.ha-bot--landed .ha-bot-eyes {
    animation: ha-blink 5.2s ease-in-out infinite, ha-bot-smile-eyes 2.8s ease both;
}

.ha.ha-bot--landed {
    animation: ha-bot-hop 0.6s ease-out both;
}

@keyframes ha-bot-smile {
    0%       { opacity: 0; }
    10%, 75% { opacity: 1; }
    100%     { opacity: 0; }
}

@keyframes ha-bot-smile-eyes {
    0%       { opacity: 1; }
    10%, 75% { opacity: 0; }
    100%     { opacity: 1; }
}

@keyframes ha-bot-hop {
    0%, 70%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-5px); }
    85%           { transform: translateY(-1.5px); }
}

/* Reading, while the assistant's index is built: eyes down, along a line and back to the next. */
.ha-bot--reading .ha-bot-look {
    animation: ha-bot-read 2.2s ease-in-out infinite;
}

@keyframes ha-bot-read {
    0%   { transform: translate(-3.5px, 3px); }
    80%  { transform: translate(3.5px, 3px); }
    100% { transform: translate(-3.5px, 3.5px); }
}

/* ---- Festive hats ----
   data-season on <html>, written by the server (MascotSeason). Christmas recolours what is there: a red
   hat, a fat white rim, a pompom for the knob and a red-and-green striped scarf. Chinese New Year goes
   lucky red, hat and scarf, gilds the mark and knob, and hangs a lantern from the brim (drawn in
   SatoruBot, hidden otherwise). Halloween turns
   the hat a witchy purple with an orange mark, the scarf pumpkin orange, and sends a bat flapping over
   the brim. */
:root[data-season="halloween"] .ha { --ha-bot-hat: #3E2560; --ha-bot-scarf: #F07A1A; }
:root[data-season="halloween"][data-theme="dark"] .ha { --ha-bot-hat: #5A3A86; --ha-bot-scarf: #FF8F33; }
:root[data-season="halloween"] .ha .ha-bot-mark { fill: #FF9A2E; }
:root[data-season="halloween"] .ha .ha-bot-knob { fill: #FF9A2E; }

.ha .ha-bot-bat { display: none; }
:root[data-season="halloween"] .ha .ha-bot-bat { display: inline; }
.ha .ha-bot-bat path { fill: #2A1840; }
:root[data-theme="dark"] .ha .ha-bot-bat path { fill: #B79BE0; }

:root[data-season="halloween"] .ha .ha-bot-bat-flap {
    transform-box: fill-box;
    transform-origin: center;
    animation: ha-bot-flap 0.5s ease-in-out infinite alternate, ha-bot-flit 3.4s ease-in-out infinite;
}

@keyframes ha-bot-flap {
    from { scale: 1 1; }
    to   { scale: 1 0.45; }
}

@keyframes ha-bot-flit {
    0%, 100% { translate: 0 0; }
    50%      { translate: -3px 3px; }
}

:root[data-season="christmas"] .ha { --ha-bot-hat: #C62828; --ha-bot-scarf: #D32F2F; }
:root[data-season="christmas"][data-theme="dark"] .ha { --ha-bot-hat: #D84343; --ha-bot-scarf: #E04848; }

/* His scarf in red-and-green stripes: green dashes down the middle of each red piece. */
.ha .ha-bot-scarf-stripes { display: none; }
:root[data-season="christmas"] .ha .ha-bot-scarf-stripes {
    display: inline;
    fill: none;
    stroke: #2E8B3E;
    stroke-width: 9;
    stroke-dasharray: 4.5 4.5;
}
:root[data-season="christmas"] .ha .ha-bot-scarf-stripes--end { stroke-width: 5; stroke-dasharray: 3.5 3.5; }
:root[data-season="christmas"] .ha .ha-bot-rim { stroke: #FFFFFF; stroke-width: 6; }
:root[data-season="christmas"] .ha .ha-bot-knob { r: 6px; fill: #FFFFFF; }

.ha .ha-bot-lantern { display: none; }
:root[data-season="cny"] .ha .ha-bot-lantern {
    display: inline;
    transform-box: view-box;
    transform-origin: 93px 37px;
    animation: ha-bot-sway 3.2s ease-in-out infinite;
}
:root[data-season="cny"] .ha { --ha-bot-hat: #C62828; --ha-bot-scarf: #D32F2F; }
:root[data-season="cny"][data-theme="dark"] .ha { --ha-bot-hat: #D84343; --ha-bot-scarf: #E04848; }
:root[data-season="cny"] .ha .ha-bot-knob { fill: #F2B632; }
:root[data-season="cny"] .ha .ha-bot-mark { fill: #F6C445; }

.ha .ha-bot-lantern-cord,
.ha .ha-bot-lantern-tassel { fill: none; stroke: #E0A526; stroke-width: 1.4; stroke-linecap: round; }
.ha .ha-bot-lantern-tassel { stroke-width: 2.2; }
.ha .ha-bot-lantern-body { fill: #D32F2F; }
.ha .ha-bot-lantern-rib { fill: none; stroke: #9E1B1B; stroke-width: 0.9; }
.ha .ha-bot-lantern-cap { fill: #F2B632; }

@keyframes ha-bot-sway {
    0%, 100% { transform: rotate(-6deg); }
    50%      { transform: rotate(6deg); }
}

/* ---- Satoru beside a message (SatoruEmpty, _SatoruFigure) ----
   On screens with nothing to show: an error, a page not found, an empty list, a search that found
   nothing. He stands at the left of the words, his face set by the caller (ha-bot--sad and so on). */
.sat-empty {
    display: flex;
    align-items: center;
    gap: 18px;
}

.sat-empty-fig {
    flex: none;
    display: block;
    width: 64px;
    height: 70px;
}

.sat-empty-fig--small {
    width: 36px;
    height: 40px;
}

.sat-empty-svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.sat-empty-body {
    min-width: 0;
}

.sat-empty-body > :first-child { margin-top: 0; }
.sat-empty-body > :last-child { margin-bottom: 0; }

@media (max-width: 480px) {
    .sat-empty {
        align-items: flex-start;
        gap: 12px;
    }

    .sat-empty-fig {
        width: 44px;
        height: 48px;
    }
}

/* ---- His own motions ---- */
.ha .ha-bot-eyes {
    transform-box: fill-box;
    transform-origin: center;
    animation: ha-blink 5.2s ease-in-out infinite;
}

/* A blink every few seconds, as the mascot beside the chat does. */
@keyframes ha-blink {
    0%, 90%, 100% { transform: scaleY(1); }
    94%           { transform: scaleY(0.12); }
}

/* A float of his own, for pages that do not have the home page's (ha-float, in chatbot.css). */
.ha .ha-bot-float {
    animation: ha-bot-float 6s ease-in-out infinite;
}

@keyframes ha-bot-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
    .ha .ha-bot-eyes,
    .ha .ha-bot-float,
    .ha .ha-bot-look,
    .ha .ha-bot-happy,
    .ha.ha-bot--landed,
    :root[data-season="cny"] .ha .ha-bot-lantern,
    :root[data-season="halloween"] .ha .ha-bot-bat-flap {
        animation: none;
    }
}
