/*
 * ==============================================================================
 *                                 N A N D R A
 * ==============================================================================
 * Copyright © 2026, Shanghai Zhongying Network Technology Co., Ltd. All rights reserved.
 * Developed by Raffaele Gabrielli.
 *
 * This software is proprietary and confidential. Decompilation, reverse engineering,
 * disassembly, modification and redistribution, in whole or in part, are prohibited
 * without the prior written authorization of the rights holder. Unauthorized use
 * constitutes a violation of copyright law and will be prosecuted to the fullest
 * extent permitted by law.
 * ==============================================================================
 */

/* Nandra, the mascot: outfits, colours and animations of mascot/nandra.svg.
   Shared by the landing (mascot.js) and the app (frontend/src/components/Mascot.tsx imports this file).

   Host element: class "nm-wrap" plus one outfit class (nm-acciaio, nm-grafite, nm-blu, nm-pastello).
   State: a class on the <svg class="nm">: nm-wave, nm-think, nm-talk, nm-read, nm-work, nm-yes (nod), nm-no (head
   shake), nm-fault, nm-pending (none = idle). */

/* ---- outfits ---- */
.nm-wrap, .nm-wrap.nm-acciaio {              /* steel + safety yellow */
  --nm-ink: #23272E; --nm-body: #D7DCE2; --nm-body2: #AEB6C0; --nm-metal: #8E97A3;
  --nm-acc: #F5B700; --nm-acc2: #3A4350; --nm-bow: #FF6A3D; --nm-cheek: #FF6A3D;
  --nm-screen: #141A21; --nm-glow: #FFC53D; --nm-glow2: #5CE1FF;
}
.nm-wrap.nm-grafite {                        /* graphite + orange */
  --nm-ink: #0E1013; --nm-body: #525A66; --nm-body2: #3B424C; --nm-metal: #7C8693;
  --nm-acc: #FF7A1A; --nm-acc2: #9AA3AE; --nm-bow: #FF7A1A; --nm-cheek: #FF7A1A;
  --nm-screen: #0B0E12; --nm-glow: #5CE1FF; --nm-glow2: #FF9F45;
}
.nm-wrap.nm-blu {                            /* white + blue */
  --nm-ink: #1C2633; --nm-body: #E9EDF2; --nm-body2: #B9C4D1; --nm-metal: #8794A5;
  --nm-acc: #1F5FAE; --nm-acc2: #F5B700; --nm-bow: #F5B700; --nm-cheek: #FF7A59;
  --nm-screen: #111A26; --nm-glow: #7FE3FF; --nm-glow2: #F5B700;
}
.nm-wrap.nm-pastello {                       /* pastel */
  --nm-ink: #2E3047; --nm-body: #F5F3FF; --nm-body2: #E4E0F7; --nm-metal: #B9B4D6;
  --nm-acc: #FF6F91; --nm-acc2: #2EC4B6; --nm-bow: #FF6F91; --nm-cheek: #FF6F91;
  --nm-screen: #1B2433; --nm-glow: #6FFFE9; --nm-glow2: #FFC94D;
}

.nm-wrap { display: inline-block; line-height: 0; flex: none; }
.nm { display: block; width: 100%; height: auto; overflow: visible; }

/* ---- colours ---- */
.nm .nm-c-ink { fill: var(--nm-ink); }
.nm .nm-c-body { fill: var(--nm-body); }
.nm .nm-c-body2 { fill: var(--nm-body2); }
.nm .nm-c-metal { fill: var(--nm-metal); }
.nm .nm-c-acc { fill: var(--nm-acc); }
.nm .nm-c-acc2 { fill: var(--nm-acc2); }
.nm .nm-c-bow { fill: var(--nm-bow); }
.nm .nm-c-cheek { fill: var(--nm-cheek); }
.nm .nm-c-screen { fill: var(--nm-screen); }
.nm .nm-c-glow { fill: var(--nm-glow); }
.nm .nm-c-glow2 { fill: var(--nm-glow2); }
.nm .nm-s-ink { stroke: var(--nm-ink); }
.nm .nm-s-acc { stroke: var(--nm-acc); }
.nm .nm-s-glow { stroke: var(--nm-glow); }
.nm .nm-s-body2 { stroke: var(--nm-body2); }
.nm .nm-bot { stroke: var(--nm-ink); }

/* ---- animations ---- */
.nm * { transform-box: view-box; }
.nm .nm-bot { animation: nm-float 3.2s ease-in-out infinite; }
.nm .nm-shadow { transform-origin: 150px 342px; animation: nm-shadow 3.2s ease-in-out infinite; }
@keyframes nm-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes nm-shadow { 0%, 100% { transform: scaleX(1); opacity: .28; } 50% { transform: scaleX(.8); opacity: .16; } }

.nm .nm-eye { transform-box: fill-box; transform-origin: center; animation: nm-blink 4.5s infinite; }
@keyframes nm-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

/* stack light, like an industrial one: lamps switch sharply on and off, the unlit ones stay visible but dim.
   green steady, with a short blink every 8 s (the PLC scan) = ready      (idle, wave)
   green blinking   = request received, answer coming, done             (yes, talk)
   yellow blinking  = Claude at work                                     (think, read, work)
   yellow steady    = an edit is ready and waits for the operator        (pending)
   red blinking     = something went wrong                               (no)
   red steady       = fault, until the next request                      (fault) */
.nm .nm-lamp { opacity: .22; }
.nm .nm-lamp-g { opacity: 1; animation: nm-lamp-scan 8s steps(1) infinite; }
@keyframes nm-lamp-scan { 0% { opacity: 1; } 95% { opacity: .22; } 97% { opacity: 1; } }
@keyframes nm-lamp-blink { 0% { opacity: 1; } 50% { opacity: .22; } }
.nm.nm-yes .nm-lamp-g, .nm.nm-talk .nm-lamp-g { animation: nm-lamp-blink .4s steps(1) infinite; }
.nm.nm-think .nm-lamp-g, .nm.nm-read .nm-lamp-g, .nm.nm-work .nm-lamp-g,
.nm.nm-pending .nm-lamp-g, .nm.nm-no .nm-lamp-g, .nm.nm-fault .nm-lamp-g { opacity: .22; animation: none; }
.nm.nm-think .nm-lamp-y, .nm.nm-read .nm-lamp-y, .nm.nm-work .nm-lamp-y { opacity: 1; animation: nm-lamp-blink .8s steps(1) infinite; }
.nm.nm-pending .nm-lamp-y { opacity: 1; }
.nm.nm-no .nm-lamp-r { opacity: 1; animation: nm-lamp-blink .4s steps(1) infinite; }
.nm.nm-fault .nm-lamp-r { opacity: 1; }

.nm .nm-tail { transform-origin: 226px 104px; animation: nm-sway 3.2s ease-in-out infinite; }
@keyframes nm-sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(7deg); } }

.nm .nm-led { animation: nm-led 1.2s steps(1) infinite; }
.nm .nm-led.nm-l2 { animation-delay: .4s; }
.nm .nm-led.nm-l3 { animation-delay: .8s; }
.nm .nm-led.nm-l4 { animation-delay: .2s; }
@keyframes nm-led { 0% { opacity: 1; } 50% { opacity: .2; } }
.nm.nm-think .nm-led { animation-duration: .3s; }

.nm .nm-arm-r { transform-origin: 206px 228px; }
.nm .nm-arm-l { transform-origin: 94px 228px; animation: nm-arm 3.2s ease-in-out infinite; }
@keyframes nm-arm { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-4deg); } }
.nm.nm-wave .nm-arm-r { animation: nm-wave .6s ease-in-out infinite alternate; }
@keyframes nm-wave { from { transform: rotate(-145deg); } to { transform: rotate(-105deg); } }

.nm .nm-dots { opacity: 0; }
.nm .nm-eyes { transition: transform .3s; }
.nm.nm-think .nm-eyes { transform: translate(4px, -6px); }
.nm.nm-think .nm-eye { animation: none; transform: scaleY(.55); }
.nm.nm-think .nm-dots { opacity: 1; }
.nm.nm-think .nm-dots rect { animation: nm-dot 1.2s infinite; }
.nm.nm-think .nm-dots rect:nth-child(2) { animation-delay: .2s; }
.nm.nm-think .nm-dots rect:nth-child(3) { animation-delay: .4s; }
@keyframes nm-dot { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

.nm .nm-mouth-talk { opacity: 0; }
.nm.nm-talk .nm-mouth-smile { opacity: 0; }
.nm.nm-talk .nm-mouth-talk { opacity: 1; transform-box: fill-box; transform-origin: center; animation: nm-talk .22s ease-in-out infinite alternate; }
@keyframes nm-talk { from { transform: scaleY(.3); } to { transform: scaleY(1); } }

.nm .nm-mouth-sad { opacity: 0; }

/* head: nods (yes: request received, edit ready) and shakes (no: something went wrong), pivoting on the neck */
.nm .nm-head { transform-origin: 150px 204px; }
.nm.nm-yes .nm-head { animation: nm-nod .5s ease-in-out 2; }
@keyframes nm-nod { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px) scaleY(.97); } }
.nm.nm-no .nm-head { animation: nm-shake .5s ease-in-out 3; }
@keyframes nm-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }

/* read: Claude is reading the project, the eyes scan the lines left to right */
.nm.nm-read .nm-eyes { animation: nm-scan 1.6s ease-in-out infinite; }
@keyframes nm-scan { 0%, 100% { transform: translate(-7px, 3px); } 50% { transform: translate(7px, 3px); } }
.nm.nm-read .nm-led { animation-duration: .6s; }

/* work: Claude is changing the project, eyes down on the job, arms at work */
.nm.nm-work .nm-eyes { transform: translateY(6px); }
.nm.nm-work .nm-eye { animation: none; transform: scaleY(.75); }
.nm.nm-work .nm-arm-l { animation: nm-tap-l .3s ease-in-out infinite alternate; }
.nm.nm-work .nm-arm-r { animation: nm-tap-r .3s ease-in-out .15s infinite alternate; }
@keyframes nm-tap-l { from { transform: rotate(0); } to { transform: rotate(16deg); } }
@keyframes nm-tap-r { from { transform: rotate(0); } to { transform: rotate(-16deg); } }
.nm.nm-work .nm-led { animation-duration: .25s; }

/* no (the head shakes) and fault (after it, until the next request): sad mouth, eyes low */
.nm.nm-no .nm-mouth-smile, .nm.nm-fault .nm-mouth-smile { opacity: 0; }
.nm.nm-no .nm-mouth-sad, .nm.nm-fault .nm-mouth-sad { opacity: 1; }
.nm.nm-no .nm-eye, .nm.nm-fault .nm-eye { animation: none; transform: scaleY(.6); }
.nm.nm-fault .nm-eyes { transform: translateY(5px); }
.nm.nm-fault .nm-led { animation-duration: 2.4s; }

/* still pose for people who asked for less motion (the state still shows: lamps, eyes, dots, mouth) */
@media (prefers-reduced-motion: reduce) {
  .nm *, .nm.nm-wave .nm-arm-r { animation: none !important; }
  .nm.nm-wave .nm-arm-r { transform: rotate(-125deg); }
}
