/* ══════════════════════════════════════════════════════
   LOGIN PAGE: MASCOTS
   Four mascots stand beside the login card: they sway, blink, follow the pointer, turn away when the password is shown,
   tilt on Caps Lock, and react happy/sad to the login result.
   Markup is inline SVG in index.html (not <img>, JS needs the inner circles); logic is in js/login-animation.js.
   Colours: three body colours derive from `--primary`, so each client copy gets its own brand colour.
   The fourth (charcoal) is deliberately neutral; four of the same colour would look flat.
   ────────────────────────────────────────────────────── */

/* Split screen: tinted mascot panel on the left, card on a clean background on the right.
   Panels take full height, giving two clear halves (previously everything floated in the middle with empty space on both sides). */
.login-shell{
  display:grid;
  grid-template-columns:1.16fr .84fr;
  min-height:100vh;
  position:relative;
  z-index:1;
}

.mascot-panel{
  position:relative;
  overflow:hidden;
  display:grid;
  place-items:center;
  padding:clamp(24px,4vw,64px);
  /* Two layers:
     1. a soft spotlight right behind the mascots so they stand out from the panel
     2. a top-to-bottom darkening gradient for depth
     Replaces the three drifting orbs, which looked like blotches inside the panel.
     Both layers mix with --background, so one rule works for light and dark. */
  background:
    radial-gradient(ellipse 60% 46% at 50% 64%,
      color-mix(in srgb,rgb(var(--brand-rgb)) 30%,var(--background)),
      transparent 72%),
    linear-gradient(180deg,
      color-mix(in srgb,rgb(var(--brand-rgb)) 7%,var(--background)),
      color-mix(in srgb,rgb(var(--brand-rgb)) 25%,var(--background)));
}

.form-panel{
  display:grid;
  place-items:center;
  padding:clamp(24px,3vw,48px);
  background:var(--background);
}

/* ── Mascots ── */
.mascots{
  /* clamp: on large monitors it looks much bigger than the card (fills empty space), on laptops it does not push the card.
     At 820px the SVG is ~535px tall, which fits a 1080 screen. */
  width:clamp(420px,44vw,820px);
  max-width:100%;
  height:auto;
  display:block;
  animation: mascotsIn .7s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes mascotsIn {
  from { opacity:0; transform:translateY(26px) scale(.96); }
  to   { opacity:1; transform:translateY(0)    scale(1);   }
}

/* Each character sways at its own rhythm; otherwise the group moves like one block. */
.mascot{ animation: mascotFloat 4s ease-in-out infinite; transform-origin:center bottom; }
.mascot--1{ animation-delay:0s;   }
.mascot--2{ animation-delay:.5s;  }
.mascot--3{ animation-delay:1s;   }
.mascot--4{ animation-delay:1.5s; }
@keyframes mascotFloat {
  0%,100% { transform:translateY(0);    }
  50%     { transform:translateY(-9px); }
}

/* JS moves the pupils; CSS only smooths the motion. */
.pupil{ transition:transform .13s cubic-bezier(.4,0,.2,1); }

/* Password visible: mascots turn away
   JS adds `.is-hiding` on the SVG. The lean is on the inner .turn group because .mascot's transform already
   belongs to the bob animation; two animations on one transform would conflict. */
.turn{
  transform-box:fill-box;
  transform-origin:50% 100%;      /* Pivot at the floor, so they lean instead of slide */
  transition:transform .34s cubic-bezier(.34,1.4,.64,1);
}
.mascots.is-hiding .mascot--1 .turn{ transform:rotate(-14deg); }
.mascots.is-hiding .mascot--2 .turn{ transform:rotate(-10deg); }
.mascots.is-hiding .mascot--3 .turn{ transform:rotate(-17deg); }
.mascots.is-hiding .mascot--4 .turn{ transform:rotate(-11deg); }

.eye-open,.mouth-happy{ transition:opacity .14s ease; }
.eye-lid,.mouth-upset{ opacity:0; transition:opacity .14s ease; }
.mascots.is-hiding .eye-open,
.mascots.is-hiding .mouth-happy{ opacity:0; }
.mascots.is-hiding .eye-lid,
.mascots.is-hiding .mouth-upset{ opacity:1; }

/* Caps Lock: questioning head tilt, opposite direction to turn-away.
   :not(.is-hiding) so a visible password always wins. */
.mascots.is-alert:not(.is-hiding) .mascot--3 .turn{ transform:rotate(9deg); }

/* Blink: same closed-eye arcs, much faster than the reveal cross-fade. */
.mascot.is-blinking .eye-open{ opacity:0; }
.mascot.is-blinking .eye-lid { opacity:1; }
.mascot.is-blinking .eye-open,
.mascot.is-blinking .eye-lid { transition-duration:.07s; }

/* Login rejected: the group shrinks back and the smile drops. */
.mascots.is-sad{ animation: mascotShake .5s cubic-bezier(.36,.07,.19,.97); }
.mascots.is-sad .mouth-happy{ opacity:0; }
.mascots.is-sad .mouth-upset{ opacity:1; }
@keyframes mascotShake {
  10%,90%      { transform:translateX(-3px); }
  20%,80%      { transform:translateX(5px);  }
  30%,50%,70%  { transform:translateX(-7px); }
  40%,60%      { transform:translateX(7px);  }
}

/* Login accepted: a jump before the redirect. */
.mascots.is-happy .mascot{ animation: mascotJump .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes mascotJump {
  0%   { transform:translateY(0);     }
  40%  { transform:translateY(-26px); }
  70%  { transform:translateY(0);     }
  85%  { transform:translateY(-8px);  }
  100% { transform:translateY(0);     }
}

/* ── Caps Lock hint ── */
.caps-hint{
  display:none;
  align-items:center;gap:5px;
  margin-top:6px;
  font-size:11.5px;font-weight:600;
  color:var(--accent-foreground);
}
.caps-hint.show{ display:flex; }

/* When space is tight */

/* Wide screens (1081px+) keep the split layout; here only make sure very short windows don't waste space on
   mascots and card padding. Both sizes depend on viewport HEIGHT (vh), which scales with zoom, so 90% and 100%
   zoom on one laptop give identical physical pixels. */
@media (min-width:1081px){
  /* SVG viewBox is 420x274 (aspect ~1.53), so "95vh wide" means ~62vh tall: fits after panel padding, never cropped.
     This cap only applies on very wide, short windows (aspect > ~2.16, e.g. 1366x620 or 1920x620).
     1920x1080, 1600x900, 1440x900, 1366x768: 44vw wins, nothing changes. */
  .mascots{ width:min(clamp(420px,44vw,820px),95vh); }
  /* Card panel's vertical padding also uses vh. When the card fits it is centred anyway; the padding only matters
     when space is tight, where it reduces scrolling. Above ~1067px height it resolves to 48px (no change).
     Horizontal padding is unchanged. */
  .form-panel{ padding:clamp(20px,4.5vh,48px) clamp(24px,3vw,48px); }
}

/* Below 1080px there is no room for two panels: mascots go ABOVE the card (better than squeezing beside it),
   and disappear on very small screens (block below). */
@media (max-width:1080px){
  /* No room for two panels: stack them. Mascot panel gets only the height it needs, the rest goes to the card. */
  .login-shell{ grid-template-columns:1fr; grid-template-rows:auto 1fr; }
  .mascot-panel{ padding:28px 20px; }
  /* Third cap, 70vh: here the banner sits on top of the card, so in short windows it must shrink itself
     rather than push the card down. On iPad (768x1024, 820x1180) 520px wins, no change; this only matters in
     621-742px tall stacked windows (e.g. 1024x700), since below 620px the banner is hidden anyway. */
  .mascots{ width:min(520px,88vw,70vh); }
  .form-panel{ padding:28px 20px 40px; }
}

/* Hide mascots ONLY on narrow screens.
   Previously a bare `(max-height:620px)` applied at every width, so on a 1366x768 laptop:
   100% zoom -> viewport 1366x620 -> mascots gone, card alone
   90% zoom -> viewport 1518x689 -> mascots shown, split screen
   i.e. the same page looked completely different.
   Why: on wide screens the mascots are in a separate COLUMN beside the card, so hiding them gives the card no
   extra vertical space (measured: 1366x620 scrolled just as much before and after). The card is ~640px tall
   and needs some scrolling in a 620px window either way. The old rule only cost branding.
   In the stacked layout (<=1080px) the mascot panel sits above the card and really costs height, so the height
   condition is still valid there (landscape phones 844x390, 932x430; small netbooks 1024x600).
   So the condition is kept, but only inside max-width:1080px. */
@media (max-width:560px), (max-width:1080px) and (max-height:620px){
  .mascot-panel{ display:none; }
  /* Reset rows when the panel is hidden: with `auto 1fr` the lone card lands in the first (auto) row and the 1fr row
     takes all leftover space, so the card sticks to the top instead of centring.
     Keep columns:1fr too: both conditions are now inside max-width:1080px (where the block above already sets 1fr),
     but if that breakpoint ever changes, this stops the card falling into the 1.16fr wide column. */
  .login-shell{ grid-template-columns:1fr; grid-template-rows:1fr; }
}

@media (prefers-reduced-motion:reduce){
  .mascots,.mascot,.turn,.pupil{ animation:none!important; transition:none!important; }
}
