/* =========================================================
   MAELITO — chatbot salsero de Radio Ecuajey
   Mascota flotante (arriba del botón de WhatsApp) + panel de chat.
   Tematizado con los tokens del sitio (oro/rojo/oscuro, Playfair+Inter).
   ========================================================= */
:root{
  --mae-gold:#f5c542; --mae-gold-2:#d9a72c; --mae-red:#e63946;
  --mae-ink:#0d0d12; --mae-panel:#14141c; --mae-panel-2:#1c1c28;
  --mae-text:#f3f1ea; --mae-muted:#9a9aa6; --mae-line:rgba(255,255,255,.08);
}

/* ---------- Mascota flotante ---------- */
.mae-mascot{
  position:fixed; right:18px; bottom:96px; z-index:98;
  width:116px; aspect-ratio:460/924; height:auto; border:0; padding:0; margin:0;
  background:transparent; cursor:pointer; -webkit-tap-highlight-color:transparent; overflow:visible;
  filter:drop-shadow(0 14px 18px rgba(0,0,0,.55));
  transition:transform .25s ease, filter .25s ease;
}
/* Títere articulado de 3 capas (cabeza + cuerpo + piernas), cada una con su
   pivote: la CABEZA cabecea en el cuello, el CUERPO mece en la cadera y las
   PIERNAS pasean. Además respira, pega saltitos y le brotan notas → se mueve
   TODO: una mascota viva, no una foto. */
.mae-rig{ position:absolute; inset:0; animation:mae-liven 5.6s ease-in-out infinite; }
.mae-layer{ position:absolute; inset:0; width:100%; height:100%; object-fit:fill; pointer-events:none; }
.mae-legs{ transform-origin:50% 68%; animation:mae-legs 1.1s ease-in-out infinite; }
.mae-torso-grp{ position:absolute; inset:0; transform-origin:50% 68%; animation:mae-torso 1.1s ease-in-out infinite; }
.mae-fig-body{ transform-origin:50% 68%; animation:mae-breathe 3.4s ease-in-out infinite; }
.mae-fig-head{ transform-origin:50% 43.5%; animation:mae-head 1.1s ease-in-out infinite; }
.mae-mascot:hover{ transform:translateY(-3px) scale(1.05); filter:drop-shadow(0 20px 24px rgba(0,0,0,.6)); }
.mae-mascot:hover .mae-legs,
.mae-mascot:hover .mae-torso-grp,
.mae-mascot:hover .mae-fig-head{ animation-duration:.58s; } /* al oírlo, ¡se prende! */
.mae-mascot:focus-visible{ outline:3px solid var(--mae-gold); outline-offset:6px; border-radius:16px; }
.mae-mascot::after{ /* piso/halo cálido bajo los pies */
  content:""; position:absolute; left:50%; bottom:4px; width:66px; height:13px;
  transform:translateX(-50%); border-radius:50%;
  background:radial-gradient(ellipse at center, rgba(245,197,66,.35), transparent 70%);
  animation:mae-shadow 1.1s ease-in-out infinite;
}
/* piernas/pies: se balancean en la cadera (paso de salsa) */
@keyframes mae-legs{
  0%,100%{ transform:rotate(0deg) }
  25%    { transform:rotate(4.5deg) }
  50%    { transform:rotate(0deg) }
  75%    { transform:rotate(-4.5deg) }
}
/* cuerpo/brazos: contramece + rebote (hombros y mano barriendo) */
@keyframes mae-torso{
  0%,100%{ transform:translateY(0)   rotate(0deg) }
  25%    { transform:translateY(-3px) rotate(-3.4deg) }
  50%    { transform:translateY(-2px) rotate(0deg) }
  75%    { transform:translateY(-3px) rotate(3.4deg) }
}
/* cabeza: cabecea y se ladea con vida propia (encima del meneo del cuerpo) */
@keyframes mae-head{
  0%,100%{ transform:rotate(3.4deg)  translateY(0) }
  30%    { transform:rotate(-1deg)   translateY(-2px) }
  50%    { transform:rotate(-3.4deg) translateY(0) }
  80%    { transform:rotate(1deg)    translateY(-2px) }
}
/* respiración: el pecho sube y baja suave */
@keyframes mae-breathe{
  0%,100%{ transform:scaleY(1) }
  50%    { transform:scaleY(1.016) }
}
/* vida espontánea: cada ~6s pega un saltito y un shimmy */
@keyframes mae-liven{
  0%,68%,100%{ transform:translateY(0)   rotate(0deg) }
  76%        { transform:translateY(-11px) rotate(-2deg) }
  84%        { transform:translateY(0)    rotate(0deg) }
  90%        { transform:translateY(-5px) rotate(2deg) }
  96%        { transform:translateY(0)    rotate(0deg) }
}
@keyframes mae-shadow{
  0%,50%,100%{ opacity:.75; width:66px; }
  25%{ opacity:.55; width:52px; transform:translateX(calc(-50% + 9px)); }
  75%{ opacity:.55; width:52px; transform:translateX(calc(-50% - 9px)); }
}

/* === ENTRADA: Maelito llega CAMINANDO desde fuera de la pantalla === */
.mae-mascot.mae-arriving{ animation:mae-walkin 2.6s cubic-bezier(.26,.06,.4,1) both; }
.mae-mascot.mae-arriving .mae-rig{ animation:none; }
.mae-mascot.mae-arriving .mae-legs{ animation:mae-walk .42s ease-in-out infinite; }
.mae-mascot.mae-arriving .mae-torso-grp{ animation:mae-walkbob .42s ease-in-out infinite; }
.mae-mascot.mae-arriving .mae-fig-head{ animation:mae-headwalk .42s ease-in-out infinite; }
.mae-mascot.mae-arriving .mae-fig-body{ animation:none; }
.mae-mascot.mae-arriving .mae-note{ animation:none; opacity:0; }
/* remate: llega y pega un bailecito más movido antes de quedarse bailando suave */
.mae-mascot.mae-celebrate .mae-legs{ animation:mae-legs .58s ease-in-out infinite; }
.mae-mascot.mae-celebrate .mae-torso-grp{ animation:mae-torso .58s ease-in-out infinite; }
.mae-mascot.mae-celebrate .mae-fig-head{ animation:mae-head .58s ease-in-out infinite; }

@keyframes mae-walkin{ 0%{ transform:translateX(260px) } 100%{ transform:translateX(0) } }
@keyframes mae-walk{ 0%,100%{ transform:rotate(7deg) } 50%{ transform:rotate(-7deg) } }
@keyframes mae-walkbob{
  0%,100%{ transform:translateY(0)   rotate(1.5deg) }
  25%    { transform:translateY(-6px) rotate(0deg) }
  50%    { transform:translateY(0)   rotate(-1.5deg) }
  75%    { transform:translateY(-6px) rotate(0deg) }
}
@keyframes mae-headwalk{  /* la cabeza rebota con cada paso al caminar */
  0%,100%{ transform:translateY(0)   rotate(2deg) }
  25%    { transform:translateY(-3px) rotate(0deg) }
  50%    { transform:translateY(0)   rotate(-2deg) }
  75%    { transform:translateY(-3px) rotate(0deg) }
}

/* nota musical que sube de vez en cuando */
.mae-note{
  position:absolute; left:4px; top:10px; color:var(--mae-gold);
  font-size:18px; opacity:0; pointer-events:none;
  animation:mae-notea 4.4s ease-in-out infinite;
}
.mae-note2{ left:auto; right:8px; top:30px; font-size:15px; color:var(--mae-red);
  animation:mae-notea 4.4s ease-in-out infinite; animation-delay:2.1s; }
@keyframes mae-notea{
  0%,70%,100%{opacity:0; transform:translate(0,0) rotate(0)}
  78%{opacity:1}
  92%{opacity:0; transform:translate(-14px,-34px) rotate(-18deg)}
}

/* globo de saludo */
.mae-hello{
  position:fixed; right:128px; bottom:150px; z-index:98;
  max-width:210px; background:linear-gradient(135deg,#fff,#fdf6e3); color:#1a1205;
  font-family:var(--sans,'Inter',sans-serif); font-size:.86rem; font-weight:600; line-height:1.35;
  padding:.7rem .85rem; border-radius:16px 16px 4px 16px;
  box-shadow:0 16px 34px rgba(0,0,0,.45); border:1px solid rgba(217,167,44,.5);
  transform:translateY(8px) scale(.9); opacity:0; pointer-events:none;
  transition:transform .35s cubic-bezier(.34,1.56,.64,1), opacity .35s ease;
}
.mae-hello.show{ transform:translateY(0) scale(1); opacity:1; pointer-events:auto; }
.mae-hello b{ color:var(--mae-red); }
.mae-hello::after{ content:""; position:absolute; right:-7px; bottom:14px; width:14px; height:14px;
  background:#fdf6e3; border-right:1px solid rgba(217,167,44,.5); border-bottom:1px solid rgba(217,167,44,.5);
  transform:rotate(-45deg); border-radius:0 0 3px 0; }
.mae-hello .mae-hello-x{ position:absolute; top:-9px; left:-9px; width:22px; height:22px; border-radius:50%;
  background:#1a1205; color:#fff; border:0; font-size:13px; line-height:22px; cursor:pointer; box-shadow:0 3px 8px rgba(0,0,0,.4); }

/* badge "1" cuando Maelito espera */
.mae-badge{
  position:absolute; top:-2px; right:-2px; min-width:20px; height:20px; padding:0 5px;
  background:var(--mae-red); color:#fff; border-radius:999px; font-size:11px; font-weight:800;
  line-height:20px; text-align:center; box-shadow:0 0 0 2px var(--mae-ink);
  font-family:var(--sans,'Inter',sans-serif);
}

/* ---------- Panel de chat ---------- */
.mae-panel{
  position:fixed; right:22px; bottom:22px; z-index:120;
  width:380px; max-width:calc(100vw - 32px); height:580px; max-height:calc(100vh - 90px);
  display:flex; flex-direction:column; overflow:hidden;
  background:var(--mae-panel); color:var(--mae-text);
  border:1px solid var(--mae-line); border-radius:22px;
  box-shadow:0 30px 70px rgba(0,0,0,.6), 0 0 0 1px rgba(245,197,66,.06);
  font-family:var(--sans,'Inter','Segoe UI',sans-serif);
  transform:translateY(24px) scale(.96); opacity:0; pointer-events:none;
  transform-origin:bottom right; transition:transform .3s cubic-bezier(.34,1.3,.5,1), opacity .25s ease;
}
.mae-panel.open{ transform:translateY(0) scale(1); opacity:1; pointer-events:auto; }
body.mae-open .wa-float{ opacity:0; pointer-events:none; transition:opacity .2s; }
body.mae-open .mae-mascot, body.mae-open .mae-hello{ opacity:0; pointer-events:none; transition:opacity .2s; }

/* header */
.mae-head{
  display:flex; align-items:center; gap:.7rem; padding:.85rem 1rem;
  background:
     radial-gradient(120% 140% at 0% 0%, rgba(230,57,70,.28), transparent 55%),
     linear-gradient(135deg, #1b1017 0%, #16141d 60%, #12100a 100%);
  border-bottom:1px solid var(--mae-line); position:relative;
}
.mae-head::after{ content:""; position:absolute; left:0; right:0; bottom:-1px; height:2px;
  background:linear-gradient(90deg, var(--mae-red), var(--mae-gold), transparent); opacity:.8; }
.mae-ava{ width:46px; height:46px; border-radius:50%; flex-shrink:0; object-fit:cover;
  border:2px solid var(--mae-gold); box-shadow:0 0 0 3px rgba(245,197,66,.15); background:#20202c; }
.mae-id{ flex:1; min-width:0; line-height:1.15; }
.mae-id .n{ font-family:var(--serif,'Playfair Display',serif); font-weight:700; font-size:1.12rem;
  display:flex; align-items:center; gap:.4rem; }
.mae-id .r{ font-size:.73rem; color:var(--mae-gold); font-weight:600; letter-spacing:.3px;
  display:flex; align-items:center; gap:.35rem; }
.mae-live-dot{ width:7px; height:7px; border-radius:50%; background:#36d26a; box-shadow:0 0 0 0 rgba(54,210,106,.6);
  animation:mae-pulse 1.8s infinite; }
@keyframes mae-pulse{ 0%{box-shadow:0 0 0 0 rgba(54,210,106,.55)} 70%{box-shadow:0 0 0 7px rgba(54,210,106,0)} 100%{box-shadow:0 0 0 0 rgba(54,210,106,0)} }
.mae-x{ width:34px; height:34px; border-radius:50%; border:0; cursor:pointer; flex-shrink:0;
  background:rgba(255,255,255,.07); color:var(--mae-text); font-size:18px; display:grid; place-items:center;
  transition:background .2s; }
.mae-x:hover{ background:rgba(255,255,255,.16); }

/* cuerpo de mensajes */
.mae-body{
  flex:1; overflow-y:auto; padding:1rem .9rem .4rem; display:flex; flex-direction:column; gap:.7rem;
  background:
    radial-gradient(90% 60% at 100% 0%, rgba(245,197,66,.05), transparent 60%),
    linear-gradient(180deg, #121019, #14141c);
  scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.18) transparent;
}
.mae-body::-webkit-scrollbar{ width:8px; }
.mae-body::-webkit-scrollbar-thumb{ background:rgba(255,255,255,.14); border-radius:4px; }

.mae-row{ display:flex; gap:.5rem; align-items:flex-end; max-width:100%; animation:mae-in .32s ease both; }
.mae-row.bot{ justify-content:flex-start; }
.mae-row.me{ justify-content:flex-end; }
.mae-row .mini{ width:26px; height:26px; border-radius:50%; flex-shrink:0; object-fit:cover;
  border:1.5px solid var(--mae-gold-2); background:#20202c; }
@keyframes mae-in{ from{opacity:0; transform:translateY(8px)} to{opacity:1; transform:none} }

.mae-bub{
  padding:.6rem .8rem; border-radius:16px; font-size:.9rem; line-height:1.45;
  max-width:84%; word-wrap:break-word; }
.mae-row.bot .mae-bub{ background:var(--mae-panel-2); color:var(--mae-text);
  border:1px solid var(--mae-line); border-bottom-left-radius:5px; }
.mae-row.me .mae-bub{ background:linear-gradient(135deg, var(--mae-gold), var(--mae-gold-2)); color:#2a1d02;
  font-weight:600; border-bottom-right-radius:5px; }
.mae-bub b, .mae-bub strong{ color:var(--mae-gold); }
.mae-row.me .mae-bub b{ color:#6b4a00; }
.mae-bub a{ color:var(--mae-gold); font-weight:700; text-decoration:underline; }
.mae-bub .q{ display:block; font-family:var(--serif,'Playfair Display',serif); font-style:italic;
  color:#fef3d0; border-left:3px solid var(--mae-red); padding-left:.6rem; margin:.35rem 0; }

/* chips de respuesta rápida */
.mae-chips{ display:flex; flex-wrap:wrap; gap:.4rem; padding:.1rem 0 .3rem 32px; animation:mae-in .32s ease both; }
.mae-chip{
  border:1px solid rgba(245,197,66,.4); background:rgba(245,197,66,.08); color:var(--mae-gold);
  font-family:inherit; font-size:.82rem; font-weight:600; padding:.42rem .7rem; border-radius:999px;
  cursor:pointer; transition:background .18s, transform .1s, color .18s; white-space:nowrap; }
.mae-chip:hover{ background:var(--mae-gold); color:#2a1d02; }
.mae-chip:active{ transform:scale(.96); }

/* tarjetas (emisora / canción / programa) */
.mae-card{
  display:flex; align-items:center; gap:.7rem; padding:.6rem .7rem; border-radius:14px;
  background:var(--mae-panel-2); border:1px solid var(--mae-line); margin-top:.1rem; }
.mae-card + .mae-card{ margin-top:.45rem; }
.mae-card-thumb{ width:40px; height:40px; border-radius:10px; flex-shrink:0; display:grid; place-items:center;
  font-weight:800; color:#fff; font-size:1.05rem; background:linear-gradient(135deg,var(--mae-red),var(--mae-gold-2)); }
.mae-card-thumb.rank{ border-radius:50%; background:linear-gradient(135deg,#2a2a38,#1a1a24); color:var(--mae-gold);
  border:1.5px solid var(--mae-gold-2); }
.mae-card-info{ flex:1; min-width:0; }
.mae-card-info .t{ font-weight:700; font-size:.9rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mae-card-info .s{ font-size:.78rem; color:var(--mae-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mae-card-act{ flex-shrink:0; border:0; cursor:pointer; border-radius:999px; font-family:inherit;
  font-weight:700; font-size:.78rem; padding:.4rem .7rem; display:inline-flex; align-items:center; gap:.3rem;
  background:linear-gradient(135deg,var(--mae-red),var(--mae-gold-2)); color:#fff; transition:transform .1s, filter .2s; }
.mae-card-act:hover{ filter:brightness(1.1); }
.mae-card-act:active{ transform:scale(.95); }
.mae-card-act.ghost{ background:transparent; border:1px solid rgba(245,197,66,.4); color:var(--mae-gold); }
.mae-card-act svg{ width:13px; height:13px; }
.mae-card-act.playing{ background:linear-gradient(135deg,#36d26a,#1f9e4e); }

/* indicador "escribiendo" */
.mae-typing{ display:inline-flex; gap:4px; padding:.7rem .8rem; }
.mae-typing span{ width:7px; height:7px; border-radius:50%; background:var(--mae-muted); animation:mae-ty 1.1s infinite; }
.mae-typing span:nth-child(2){ animation-delay:.18s } .mae-typing span:nth-child(3){ animation-delay:.36s }
@keyframes mae-ty{ 0%,60%,100%{transform:translateY(0);opacity:.4} 30%{transform:translateY(-5px);opacity:1} }

/* input */
.mae-foot{ padding:.6rem .7rem calc(.6rem + env(safe-area-inset-bottom,0px)); border-top:1px solid var(--mae-line);
  background:var(--mae-panel); }
.mae-inwrap{ display:flex; align-items:flex-end; gap:.5rem; background:var(--mae-panel-2);
  border:1px solid var(--mae-line); border-radius:14px; padding:.35rem .35rem .35rem .8rem; }
.mae-inwrap:focus-within{ border-color:rgba(245,197,66,.5); }
.mae-in{ flex:1; border:0; outline:0; background:transparent; color:var(--mae-text); font-family:inherit;
  font-size:.9rem; resize:none; max-height:84px; line-height:1.4; padding:.35rem 0; }
.mae-in::placeholder{ color:var(--mae-muted); }
.mae-send{ width:38px; height:38px; flex-shrink:0; border:0; border-radius:11px; cursor:pointer;
  background:linear-gradient(135deg,var(--mae-gold),var(--mae-gold-2)); color:#2a1d02; display:grid; place-items:center;
  transition:transform .1s, filter .2s; }
.mae-send:hover{ filter:brightness(1.08); } .mae-send:active{ transform:scale(.92); }
.mae-send svg{ width:19px; height:19px; }
.mae-foot .hint{ text-align:center; font-size:.68rem; color:var(--mae-muted); margin:.4rem 0 0; }
.mae-foot .hint b{ color:var(--mae-gold-2); }

/* responsive */
@media (max-width:520px){
  .mae-mascot{ width:94px; height:auto; right:10px; bottom:82px; }
  .mae-hello{ right:98px; bottom:128px; max-width:170px; font-size:.8rem; }
  .mae-panel{ right:10px; left:10px; bottom:10px; width:auto; max-width:none; height:auto;
    top:12px; max-height:none; border-radius:18px; }
}

/* respeta reduce-motion */
@media (prefers-reduced-motion:reduce){
  .mae-mascot,.mae-rig,.mae-layer,.mae-torso-grp,.mae-mascot::after,.mae-note,.mae-live-dot,.mae-typing span{ animation:none; }
  .mae-mascot.mae-arriving,.mae-mascot.mae-arriving .mae-legs,.mae-mascot.mae-arriving .mae-torso-grp,
  .mae-mascot.mae-arriving .mae-fig-head,.mae-mascot.mae-celebrate .mae-legs,
  .mae-mascot.mae-celebrate .mae-torso-grp,.mae-mascot.mae-celebrate .mae-fig-head{ animation:none; }
  .mae-panel,.mae-hello,.mae-row{ transition:none; animation:none; }
}
