/* =====================================================================
   easter-eggs.css
   Visual support for the easter-egg JS. Each block is scoped tightly
   so it can be removed in isolation. CSS classes are toggled by JS
   in easter-eggs.js — file loads ONLY effects-supporting styles, no
   structural rules.
   ===================================================================== */

/* ---------------------------------------------------------------------
   Shared sprite frame — small inline-block crab that floats above
   normal content, anchored exactly where JS positions it.
   --------------------------------------------------------------------- */
.egg-sprite {
  position: fixed;
  pointer-events: none;
  z-index: 60;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5))
          drop-shadow(0 0 18px rgba(245, 165, 36, 0.25));
  image-rendering: pixelated;     /* keep pixel-art sharp at any size */
  user-select: none;
  -webkit-user-drag: none;
}

/* Sprite "walk" entry — fades in + slides */
.egg-sprite[data-anim="walk-in"] {
  animation: egg-walk-in 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.egg-sprite[data-anim="walk-out"] {
  animation: egg-walk-out 0.5s cubic-bezier(0.55, 0, 0.68, 0.2) both;
}
.egg-sprite[data-anim="puff"] {
  animation: egg-puff 0.42s ease-out both;
}

@keyframes egg-walk-in {
  from { opacity: 0; transform: translateX(-12px) scale(0.92); }
  to   { opacity: 1; transform: translateX(0)     scale(1);    }
}
@keyframes egg-walk-out {
  from { opacity: 1; transform: translateX(0)    scale(1);    }
  to   { opacity: 0; transform: translateX(28px) scale(0.92); }
}
@keyframes egg-puff {
  0%   { opacity: 0; transform: scale(0.6) translateY(8px); }
  40%  { opacity: 1; transform: scale(1.06) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------------------------------------------------------------------
   Egg 1 — Late-night mode. Activated by body.is-night (time-based)
   or body.is-nap (URL-hash forced #nap). Both apply the same visuals.
   --------------------------------------------------------------------- */
body.is-night,
body.is-nap {
  --night-tint: #8b9cff;       /* soft periwinkle for the "sleeping" mood */
}

/* Replace the live agent banner with a sleeping state. The original
   .agent-status is faded out and a sibling .agent-status-night is
   slid in by JS at init time. */
body.is-night .agent-status,
body.is-nap   .agent-status { display: none; }

.agent-status-night {
  display: none;
  align-items: center;
  gap: 0.55rem;
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1;
  color: var(--night-tint, #8b9cff);
}

body.is-night .agent-status-night,
body.is-nap   .agent-status-night { display: inline-flex; }

.agent-status-night img {
  /* Aspect-ratio matches the tightened sleeping.svg viewBox (22:40).
     Height-driven so the sprite stays proportional regardless of font.
     ~3.6em tall puts the crab at a visible-but-not-dominant scale; width
     follows the aspect automatically. */
  height: 3.6em;
  width: auto;
  aspect-ratio: 22 / 40;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
}

.agent-status-night .verb {
  font-weight: 500;
  letter-spacing: 0.02em;
  animation: night-breath 3.6s ease-in-out infinite;
}

.agent-status-night .meta {
  color: #525a6b;
  margin-left: 0.4rem;
}

@keyframes night-breath {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.55; }
}

/* Subtly dim the brand prompt ›/ glyphs during night mode — the
   feeling is "everything has dimmed down for the night". */
body.is-night .brand-prompt,
body.is-night .brand-slash,
body.is-nap   .brand-prompt,
body.is-nap   .brand-slash {
  opacity: 0.45;
}

@media (prefers-reduced-motion: reduce) {
  .agent-status-night .verb { animation: none; opacity: 0.7; }
  .egg-sprite[data-anim] { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* ---------------------------------------------------------------------
   Egg 4 — Etymology hover popover.
   Now Apple-style: no sprite. Just a compact monospace spec card with
   IPA + an English approximation of the pronunciation. The .name-note
   text already supplies the meaning; the popover supplies HOW to say it.
   --------------------------------------------------------------------- */
.egg-etymology {
  position: absolute;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px) scale(0.95);
  transform-origin: bottom left;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.32, 0, 0.16, 1);
}
.egg-etymology.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.egg-etymology .bubble {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.75rem 0.5rem;
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  white-space: nowrap;
  letter-spacing: 0.01em;
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.6);
}
.egg-etymology .bubble::before {
  content: "";
  position: absolute;
  left: 14px;
  bottom: -6px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--card);
}
.egg-etymology .ipa {
  color: var(--primary);
  font-weight: 600;
}
.egg-etymology .rom {
  color: var(--muted-foreground);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------
   Egg 5 — Portrait peek.
   A small crab sprite slides out from behind the right edge of the
   About portrait after 6s of sustained hover. JS handles the timing;
   CSS provides the slide-in / slide-out keyframes.
   --------------------------------------------------------------------- */
.about-portrait { /* parent positioning already exists in main styles */ }

.egg-peek {
  position: absolute;
  bottom: 18%;
  right: -38px;
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  z-index: 5;          /* above ::before dot-grid, below the portrait img */
  pointer-events: none;
  transform: translateX(40px) scale(0.94);
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1),
              opacity   0.4s ease;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}
.egg-peek.is-out {
  opacity: 1;
  transform: translateX(0) scale(1);
}
.egg-peek.is-leaving {
  transition: transform 0.45s ease-in, opacity 0.35s ease-in;
  transform: translateX(40px) scale(0.94);
  opacity: 0;
}

/* ---------------------------------------------------------------------
   Egg 7 — Konami overlay.
   Full-page dim + centered happy-dance crab + tiny credits line.
   Click anywhere to dismiss.
   --------------------------------------------------------------------- */
.egg-konami {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: radial-gradient(circle at center, #0d1230 0%, #050811 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}
.egg-konami.is-open {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

/* Starfield — small CSS-painted stars, sprinkled with delay variants */
.egg-konami::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 20%, #fff8 50%, transparent 60%),
    radial-gradient(1px 1px at 28% 75%, #fff5 50%, transparent 60%),
    radial-gradient(2px 2px at 62% 14%, #ffd7ff 50%, transparent 60%),
    radial-gradient(1px 1px at 80% 60%, #c0e7ff 50%, transparent 60%),
    radial-gradient(1.5px 1.5px at 45% 84%, #fff 50%, transparent 60%),
    radial-gradient(1px 1px at 90% 25%, #fff 50%, transparent 60%),
    radial-gradient(2px 2px at 17% 62%, #ffe89d 50%, transparent 60%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  animation: egg-star-twinkle 4s ease-in-out infinite;
}

@keyframes egg-star-twinkle {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.5; }
}

.egg-konami img {
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
  position: relative;
  filter: drop-shadow(0 16px 40px rgba(0, 0, 0, 0.6))
          drop-shadow(0 0 60px rgba(245, 165, 36, 0.25));
}

.egg-konami-credits {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  position: relative;
}
.egg-konami-credits strong { color: var(--primary); font-weight: 600; }
.egg-konami-hint {
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  color: var(--faint-foreground);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 1rem;
  position: relative;
}

/* ---------------------------------------------------------------------
   Egg 8 — Mouse-trail dizziness.
   The dizzy crab appears at a viewport point chosen by JS; uses the
   shared .egg-sprite class for fade + drop-shadow.
   --------------------------------------------------------------------- */
.egg-dizzy {
  width: 88px;
  height: 88px;
  animation: egg-dizzy-pop 1.1s ease-out forwards;
}
@keyframes egg-dizzy-pop {
  0%   { opacity: 0; transform: scale(0.4) rotate(-10deg); }
  20%  { opacity: 1; transform: scale(1.1) rotate(6deg); }
  80%  { opacity: 1; transform: scale(1) rotate(-3deg); }
  100% { opacity: 0; transform: scale(0.9) rotate(0deg); }
}

/* ---------------------------------------------------------------------
   Egg 9 — Window-narrow comedy.
   When viewport falls below 340px (pretty extreme), an overheated
   crab appears in the bottom-right of the page. Pure CSS via media
   query; no JS needed.
   --------------------------------------------------------------------- */
.egg-narrow {
  display: none;
  position: fixed;
  bottom: 12px;
  right: 8px;
  width: 60px;
  height: 60px;
  image-rendering: pixelated;
  opacity: 0.7;
  pointer-events: none;
  z-index: 30;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}
@media (max-width: 340px) {
  .egg-narrow { display: block; }
}

/* ---------------------------------------------------------------------
   Egg 10 — Esc-hold "Interrupted!".
   JS swaps the agent banner verb text + colour for 2s when Esc is
   held for 1.5s. Pure visual swap; .agent-status-interrupted overrides
   colour/animation, then is removed.
   --------------------------------------------------------------------- */
.agent-status.is-interrupted {
  --agent-color: #ff6b6b !important;
}
.agent-status.is-interrupted .agent-verb {
  animation: none !important;
  background: none !important;
  -webkit-text-fill-color: #ff6b6b !important;
  color: #ff6b6b !important;
}

/* ---------------------------------------------------------------------
   Egg 11 — #hi wave.
   A waving crab appears in the agent banner, walks across, exits.
   Built as a fixed sprite that animates left→right inside the banner.
   --------------------------------------------------------------------- */
.egg-banner-wave {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 2;
  animation: egg-banner-wave 4.2s ease-in-out forwards;
}
@keyframes egg-banner-wave {
  0%   { left: -38px;            opacity: 0; }
  10%  { opacity: 1; }
  20%  { left: 25%; }
  40%  { left: 30%; }            /* small dwell — the wave */
  60%  { left: 60%; }
  90%  { left: calc(100% + 6px); opacity: 1; }
  100% { left: calc(100% + 40px);opacity: 0; }
}

/* ---------------------------------------------------------------------
   Egg 13 — #party.
   Workflows section outcome arrows → juggling crab mini-sprites.
   JS adds .is-party-mode to the body; CSS hides the existing arrow
   ::before and injects a sprite via a sibling element JS appended.
   --------------------------------------------------------------------- */
body.is-party-mode .workflows-grid .outcome::before { display: none; }
.egg-party-juggle {
  display: inline-block;
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  vertical-align: middle;
  margin-right: 0.4em;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

/* ---------------------------------------------------------------------
   Egg 14 — #404 disconnected sprite in the wordmark footer.
   The disconnected crab appears next to the giant brand mark with a
   small "where am i" speech bubble. JS injects.
   --------------------------------------------------------------------- */
.egg-404 {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
  position: relative;
}
.egg-404 img {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}
.egg-404 .bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--muted-foreground);
  letter-spacing: 0.02em;
  position: relative;
  margin-bottom: 14px;
}
.egg-404 .bubble::after {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 12px;
  width: 0; height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid var(--card);
}

/* ---------------------------------------------------------------------
   Reduced-motion guard for any sprite that pulses or pops.
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .egg-card-walker,
  .egg-banner-wave,
  .egg-dizzy { animation-duration: 0.001s; }
  .egg-konami::before { animation: none; }
  .egg-peek { transition: none; }
}
