/* The helper pencil (docs/mascot.md, js/mascot.js). Brand colors only; calm motion; no motion when asked. */
.mc { --mc-w: 64px; --mc-line: #0a1330; --mc-tip: #0a1330; display: inline-block; flex: none; width: var(--mc-w); line-height: 0; color: var(--mc-line); }
.mc svg { width: 100%; height: auto; overflow: visible; }
.mc-sm { --mc-w: 44px; }
.mc.is-calm { --mc-w: 44px; }
.mc.is-calm.mc-sm { --mc-w: 36px; }
:root[data-theme="dark"] .mc { --mc-line: #c9c1ff; --mc-tip: #e9e6ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mc { --mc-line: #c9c1ff; --mc-tip: #e9e6ff; } }
.mc-off .mc { display: none; }

/* Parts: everything optional starts hidden; each pose turns on its own pieces. */
.mc .mc-tip { fill: var(--mc-tip); }
.mc .mc-feet { fill: currentColor; }
.mc .mc-a { display: none; fill: none; stroke: currentColor; stroke-width: 4.2; stroke-linecap: round; }
.mc .mc-m { display: none; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.mc .mc-m-open { fill: #0a1330; stroke: #fff; stroke-width: 2; }
.mc .mc-x { display: none; }
.mc .mc-sparks { stroke: #8b7cff; stroke-width: 3.4; stroke-linecap: round; }
.mc .mc-dots { fill: #8b7cff; }
.mc .mc-q path { fill: none; stroke: #8b7cff; stroke-width: 3; stroke-linecap: round; }
.mc .mc-q circle { fill: #8b7cff; }
.mc .mc-cheeks { fill: #fcb798; opacity: .75; }
.mc .mc-brows { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; opacity: .9; }
.mc .mc-eyes, .mc .mc-pupils, .mc .mc-arm, .mc .mc-fig, .mc .mc-b1 { transform-box: fill-box; transform-origin: center; }
.mc .mc-arm-b { transform-origin: 0% 100%; }

.mc--idle .mc-a-down, .mc--idle .mc-m-smile, .mc--idle .mc-cheeks { display: inline; }
.mc--think .mc-arm-a .mc-a-chin, .mc--think .mc-arm-b .mc-a-down, .mc--think .mc-m-flat, .mc--think .mc-dots, .mc--think .mc-brows { display: inline; }
.mc--think .mc-pupils { transform: translate(1px, -2px); }
.mc--happy .mc-a-up, .mc--happy .mc-m-open, .mc--happy .mc-sparks, .mc--happy .mc-cheeks { display: inline; }
.mc--cheer .mc-arm-a .mc-a-down, .mc--cheer .mc-arm-b .mc-a-fist, .mc--cheer .mc-m-smile, .mc--cheer .mc-brows, .mc--cheer .mc-cheeks { display: inline; }
.mc--wave .mc-arm-a .mc-a-down, .mc--wave .mc-arm-b .mc-a-up, .mc--wave .mc-m-smile, .mc--wave .mc-cheeks { display: inline; }
.mc--confused .mc-a-shrug, .mc--confused .mc-m-wave, .mc--confused .mc-brows, .mc--confused .mc-q { display: inline; }
.mc--confused .mc-b1 { transform: translateY(-2px) rotate(-10deg); }
.mc--confused .mc-pupils { transform: translate(-1px, 0); }

/* Motion: a slow bob, a blink, a hop when right, a nod when encouraging, a wave hello, a head tilt when puzzled. */
.mc .mc-fig { animation: mc-bob 3.2s ease-in-out infinite; }
.mc .mc-eyes { animation: mc-blink 4.6s infinite; }
.mc--think .mc-dots circle { animation: mc-dot 1.4s ease-in-out infinite; }
.mc--think .mc-dots circle:nth-child(2) { animation-delay: .2s; }
.mc--think .mc-dots circle:nth-child(3) { animation-delay: .4s; }
.mc--happy .mc-fig { animation: mc-hop .55s ease-out 2; }
.mc--cheer .mc-fig { animation: mc-nod .7s ease-in-out 1; }
.mc--wave .mc-arm-b { animation: mc-wave .5s ease-in-out 4 alternate; }
.mc--confused .mc-fig { animation: none; transform: rotate(6deg); }
@keyframes mc-bob { 50% { transform: translateY(-3px); } }
@keyframes mc-blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes mc-dot { 50% { opacity: .35; } }
@keyframes mc-hop { 40% { transform: translateY(-12px); } 70% { transform: translateY(0) scaleY(.96); } }
@keyframes mc-nod { 30% { transform: rotate(-5deg); } 65% { transform: rotate(3deg); } }
@keyframes mc-wave { from { transform: rotate(-12deg); } to { transform: rotate(14deg); } }

/* Calm (grades 10–12, /exams): no bob, no hop; poses still change. */
.mc.is-calm .mc-fig, .mc.is-calm.mc--happy .mc-fig, .mc.is-calm.mc--cheer .mc-fig { animation: none; }
.mc.is-calm.mc--wave .mc-arm-b { animation-iteration-count: 2; }
.reduce-motion .mc *, .reduce-motion .mc { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .mc *, .mc { animation: none !important; } }

/* Right-to-left: the pencil turns to face its bubble; the question mark stays readable. */
[dir="rtl"] .mc svg { transform: scaleX(-1); }
[dir="rtl"] .mc .mc-q { transform: scaleX(-1); transform-box: fill-box; transform-origin: center; }

/* The speech bubble: the pencil at the start side, the bubble's tail pointing at it. */
.mc-say { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.mc-say > .mc { margin-top: 4px; }
.mc-bubble { position: relative; flex: 1; min-width: 0; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.mc-bubble::before { content: ""; position: absolute; top: 26px; inset-inline-start: -7px; width: 12px; height: 12px; background: inherit;
  border: inherit; border-top-color: transparent; border-right-color: transparent; transform: rotate(45deg); border-radius: 0 0 0 3px; }
[dir="rtl"] .mc-bubble::before { border: inherit; border-bottom-color: transparent; border-left-color: transparent; border-radius: 0 3px 0 0; }
.mc-bubble > :first-child { margin-top: 0; }
.mc-bubble > :last-child { margin-bottom: 0; }
.mc-react { margin: 8px 0 0; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.mc-say.is-ok .mc-react { color: var(--green-ink); }
.mc-say.is-no .mc-react { color: var(--link); }
.mc-say-sm { gap: 10px; }
.mc-say-sm .mc-bubble { padding: 10px 14px; }
.mc-say-sm .mc-bubble::before { top: 16px; }
@media (max-width: 520px) {
  .mc { --mc-w: 50px; }
  .mc.is-calm, .mc-sm { --mc-w: 38px; }
  .mc-say { gap: 10px; }
  .mc-bubble { padding: 12px 13px; }
  .mc-bubble::before { top: 20px; }
}

/* Empty states ("nothing found", no friends yet) */
.mc-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.mc-empty .mc { --mc-w: 56px; }
.mc-off .mc-empty-alt { display: inline; }
.mc-empty-alt { display: none; }

/* Profile: the setting row's little preview */
.mc-pref { display: flex; align-items: center; gap: 12px; }
.mc-pref .mc { --mc-w: 30px; }

/* The reaction repeated beside the answer when the bubble is out of sight */
.mc-fb { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-weight: 600; color: var(--link); }
.mc-fb.is-ok { color: var(--green-ink); }
.mc-fb .mc { --mc-w: 30px; }

/* Games (js/mascot.js Mascot.game): the question in his bubble, turns announced, a corner Shido for fast games */
.mc-game { --mc-w: 56px; }
.mc-say-game { margin: 0 0 12px; text-align: start; }
.mc-say-game .mc-bubble { padding: 10px 14px; }
.mc-say-game .mc-bubble::before { top: 18px; }
.mc-say-game .mc-bubble > * { margin-top: 0; margin-bottom: 0; }
.mc-say-sm.mc-turn { justify-content: center; align-items: center; margin: 6px auto 10px; max-width: 520px; }
.mc-say-sm.mc-turn .mc-bubble { flex: 0 1 auto; }
.mc-say-sm.mc-turn .mc-bubble::before { top: 50%; margin-top: -6px; }
.mc-say.mc-hide { display: none; }
.mc-corner { display: inline-flex; align-items: center; order: 5; }
.mc-corner .mc { --mc-w: 30px; }
.mc-has-q .mc-corner { display: none; }
@media (max-width: 520px) { .mc-game { --mc-w: 44px; } .mc-corner .mc { --mc-w: 26px; } }

/* Talking: while the read-aloud voice speaks, the pencil in the bubble moves its mouth */
.mc-talking .mc-say .mc .mc-m { display: none; }
.mc-talking .mc-say .mc .mc-m-open { display: inline; transform-box: fill-box; transform-origin: center top; animation: mc-talk .22s ease-in-out infinite alternate; }
@keyframes mc-talk { from { transform: scaleY(.3); } to { transform: scaleY(1); } }

/* KG (kg.js): Shido replaces the old drawn pencil; the prompt becomes his speech bubble */
.kg-shido .mc { --mc-w: 64px; }
.kg-end .mc { --mc-w: 84px; }
.kg-shido .kg-prompt { position: relative; flex: 1; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.kg-shido .kg-prompt::before { content: ""; position: absolute; top: 50%; margin-top: -6px; inset-inline-start: -7px; width: 12px; height: 12px; background: inherit;
  border: inherit; border-top-color: transparent; border-right-color: transparent; transform: rotate(45deg); border-radius: 0 0 0 3px; }
[dir="rtl"] .kg-shido .kg-prompt::before { border: inherit; border-bottom-color: transparent; border-left-color: transparent; border-radius: 0 3px 0 0; }
@media (max-width: 520px) { .kg-shido .mc { --mc-w: 48px; } }
.mc-turn .mc-bubble > * { background: none; border: 0; box-shadow: none; padding: 0; margin: 0; }

/* How-to-play dialog (tutorial.js): Shido instead of the old drawn pencil */
.tu-shido.tu-shadi { --mc-w: 56px; width: var(--mc-w); height: auto; animation: none; }
.tu-young .tu-shido.tu-shadi { --mc-w: 66px; }
