/* ==========================================================================
   Yellow — asistente web de GELB (V0.4 visual)
   Traslada el sistema gráfico del brief de Yellow: esfera amarilla plana,
   trazo negro fino, bocadillos blancos, filas blancas sin borde, píldora de
   escritura con lápiz y envío lavanda. Paleta y tipografía de styles.css.
   ========================================================================== */

.yellow-launcher,
.yellow-panel {
  --yellow-radius: 18px;
  --yellow-radius-soft: 14px;
  --yellow-line: rgba(31, 31, 31, 0.12);
  --yellow-lavender-soft: rgba(119, 118, 168, 0.14);
  --yellow-shadow: 0 10px 32px rgba(31, 31, 31, 0.10);
  --yellow-lift: 0 1px 3px rgba(31, 31, 31, 0.07);
  --yellow-gap: 1.125rem;
}

/* --------------------------------------------------------------------------
   Botón de apertura: Yellow "asomándose" desde la píldora
   -------------------------------------------------------------------------- */

.yellow-launcher {
  position: fixed;
  right: var(--space-3);
  bottom: var(--space-3);
  z-index: 1000;
  display: flex;
  align-items: center;
  min-height: 2.6rem;
  padding: 0.55rem 1.15rem 0.55rem 3.1rem;
  border: 1px solid var(--yellow-line);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--yellow-shadow);
  transition: border-color 0.15s ease;
}
.yellow-launcher:hover { border-color: var(--color-lavender); }
.yellow-launcher[aria-expanded="true"] { display: none; }

/* La esfera sobresale por encima y por la izquierda de la píldora */
.yellow-peek {
  position: absolute;
  left: -0.7rem;
  bottom: 0.15rem;
  width: 3.6rem;
  height: 3.6rem;
  overflow: visible;
}

/* Guiño y energía: ocultos salvo durante el saludo puntual */
.yellow-energy { opacity: 0; }
.yellow-eye-wink { opacity: 0; }

/* --------------------------------------------------------------------------
   Panel: tarjeta cálida que se ajusta a su contenido
   -------------------------------------------------------------------------- */

.yellow-panel {
  position: fixed;
  right: var(--space-3);
  bottom: var(--space-3);
  z-index: 1001;
  width: min(23rem, calc(100vw - 2 * var(--space-3)));
  max-height: min(40rem, calc(100vh - 2 * var(--space-3)));
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-ink);
  border: 1px solid var(--yellow-line);
  border-radius: var(--yellow-radius);
  box-shadow: var(--yellow-shadow);
  overflow: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.yellow-panel[hidden] { display: none; }
.yellow-panel.is-entering { opacity: 0; transform: translateY(8px); }

/* Cabecera ligera: nombre con el punto amarillo del logotipo, subtítulo y cierre */
.yellow-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.5rem 0 var(--yellow-gap);
}
.yellow-title { margin: 0; font-family: var(--font-heading); font-weight: 600; font-size: 0.9375rem; line-height: 1.2; }
.yellow-title__dot {
  display: inline-block;
  width: 0.36em;
  height: 0.36em;
  margin-left: 0.12em;
  border-radius: 50%;
  background: var(--color-yellow);
}
.yellow-subtitle { margin: 0; font-size: 0.75rem; line-height: 1.3; color: var(--color-ink-soft); }
.yellow-close {
  margin-left: auto;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-ink-soft);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.yellow-close:hover { background: rgba(31, 31, 31, 0.06); color: var(--color-ink); }

/* --------------------------------------------------------------------------
   Conversación
   -------------------------------------------------------------------------- */

.yellow-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.6rem var(--yellow-gap) 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.yellow-figure { display: block; overflow: visible; }

/* Composición del brief: Yellow junto al bocadillo del saludo */
.yellow-intro {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
}
.yellow-intro__figure { flex-shrink: 0; width: 3.3rem; margin-bottom: 0.1rem; }
.yellow-intro__figure .yellow-figure { width: 100%; height: auto; }

/* Bocadillos de Yellow: blancos, suaves, con la esquina hacia el personaje */
.yellow-bubble,
.yellow-msg--yellow {
  padding: 0.7rem 0.9rem;
  border-radius: var(--yellow-radius-soft) var(--yellow-radius-soft) var(--yellow-radius-soft) 4px;
  background: #fff;
  box-shadow: var(--yellow-lift);
}
.yellow-bubble { flex: 1; }
.yellow-bubble p { margin: 0 0 0.3em; }
.yellow-bubble p:last-child { margin-bottom: 0; }
.yellow-bubble__question { font-weight: 600; }

/* Starters: filas blancas sin borde, chevron oscuro */
.yellow-starters { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.15rem; }
.yellow-starter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-radius: var(--yellow-radius-soft);
  background: #fff;
  box-shadow: var(--yellow-lift);
  color: var(--color-ink);
  font-size: 0.84rem;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}
.yellow-starter:hover { box-shadow: 0 2px 8px rgba(31, 31, 31, 0.10); }
.yellow-starter__arrow {
  color: var(--color-ink);
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1;
  transition: transform 0.15s ease;
}
.yellow-starter:hover .yellow-starter__arrow { transform: translateX(2px); }

.yellow-invitation { margin: 0.3rem 0 0; font-size: 0.78rem; font-style: italic; color: var(--color-ink-soft); }

/* Mensajes: tu voz en lavanda suave; la de Yellow en bocadillo blanco */
.yellow-msg { max-width: 92%; }
.yellow-msg p { margin: 0 0 0.6em; white-space: pre-wrap; }
.yellow-msg p:last-child { margin-bottom: 0; }
.yellow-msg--yellow { align-self: flex-start; }
.yellow-msg--user {
  align-self: flex-end;
  max-width: 85%;
  padding: 0.55rem 0.85rem;
  border-radius: var(--yellow-radius-soft) var(--yellow-radius-soft) 4px var(--yellow-radius-soft);
  background: var(--yellow-lavender-soft);
}
.yellow-msg--error { align-self: flex-start; color: var(--color-ink-soft); }

/* "Déjame pensar…": Yellow pequeño y pensativo con su nube.
   Con reducir movimiento no hay animación, pero el estado sigue siendo
   inequívoco: personaje pensativo + nube + texto en tinta. */
.yellow-thinking { display: flex; align-items: flex-end; gap: 0.4rem; align-self: flex-start; }
.yellow-thinking__figure { display: block; width: 2.6rem; flex-shrink: 0; }
.yellow-thinking__figure .yellow-figure { width: 100%; height: auto; }
.yellow-status { margin: 0 0 0.35rem; font-size: 0.8125rem; color: var(--color-ink); }

/* CTAs: píldoras */
.yellow-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.yellow-cta {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-ink);
  border-radius: 999px;
  background: transparent;
  color: var(--color-ink);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 0.8125rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.yellow-cta:hover { background: var(--color-ink); color: var(--color-bg); }
.yellow-cta--primary { background: var(--color-ink); color: var(--color-bg); }
.yellow-cta--primary:hover { background: var(--color-lavender); border-color: var(--color-lavender); }

/* --------------------------------------------------------------------------
   Escritura: píldora blanca con lápiz y envío lavanda "→"
   -------------------------------------------------------------------------- */

.yellow-form { padding: 0.45rem var(--yellow-gap) 0.35rem; }
.yellow-field {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  padding: 0.25rem 0.25rem 0.25rem 0.85rem;
  border: 1px solid var(--yellow-line);
  border-radius: 20px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Foco: un único anillo lavanda pegado al borde, sin contorno separado */
.yellow-field:focus-within { border-color: var(--color-lavender); box-shadow: 0 0 0 1px var(--color-lavender); }
.yellow-pencil {
  align-self: center;
  color: var(--color-ink-soft);
  opacity: 0.75;
  font-size: 0.95rem;
  line-height: 1;
}
.yellow-input {
  flex: 1;
  min-width: 0;
  height: 2.125rem;
  padding: 0.4rem 0;
  border: 0;
  background: transparent;
  font-size: 1rem; /* ≥16px evita el zoom automático en iOS */
  line-height: 1.35;
  resize: none;
}
.yellow-input:focus,
.yellow-input:focus-visible { outline: none; } /* el foco se muestra en .yellow-field */
.yellow-input::placeholder { color: var(--color-ink-soft); opacity: 0.8; }
.yellow-send {
  flex-shrink: 0;
  width: 2.125rem;
  height: 2.125rem;
  border: 0;
  border-radius: 999px;
  background: var(--color-lavender);
  color: #fff;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.yellow-send:hover:not(:disabled) { background: var(--color-ink); }
.yellow-send:disabled { opacity: 0.4; cursor: default; }

/* Aviso de privacidad: nota al pie, secundaria pero legible (≥ 4,5:1) */
.yellow-notice {
  margin: 0;
  padding: 0 var(--yellow-gap) 0.8rem;
  font-size: 0.65rem;
  line-height: 1.45;
  color: #6a6a6a;
}
.yellow-notice a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.yellow-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Expresividad puntual (nada continuo; desactivada con reducir movimiento)
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  /* Botón: un guiño con energía, una sola vez tras cargar la página */
  .yellow-launcher.is-greeting .yellow-eye-open { animation: yellow-blink-out 1.6s ease 1; }
  .yellow-launcher.is-greeting .yellow-eye-wink { animation: yellow-blink-in 1.6s ease 1; }
  .yellow-launcher.is-greeting .yellow-energy { animation: yellow-energy 1.6s ease 1; }

  /* Saludo del panel: el brazo saluda y aparece la energía, solo la primera vez */
  .yellow-intro.is-hello .yellow-arm-wave {
    transform-box: view-box;
    transform-origin: 49.5px 27px;
    animation: yellow-wave 1.1s ease-in-out 0.25s 1;
  }
  .yellow-intro.is-hello .yellow-energy { animation: yellow-energy 1.4s ease 0.2s 1; }

  /* Pensando: actividad continua y suave SOLO mientras se espera la respuesta.
     El personaje respira, las burbujas suben hacia la nube y la nube flota. */
  .yellow-thinking { animation: yellow-fade-in 0.25s ease 1; }
  .yellow-thinking__figure .yellow-figure { animation: yellow-breathe 1.8s ease-in-out infinite; }
  .yellow-thinking .yellow-cloud {
    transform-box: fill-box;
    transform-origin: center;
    animation: yellow-cloud-float 1.8s ease-in-out infinite;
  }
  .yellow-thinking .yellow-thought { animation: yellow-thought-pulse 1.8s ease-in-out infinite; }
  .yellow-thinking .yellow-thought--far { animation-delay: 0.3s; }
}

@keyframes yellow-blink-out { 0%, 15%, 75%, 100% { opacity: 1; } 25%, 65% { opacity: 0; } }
@keyframes yellow-blink-in { 0%, 15%, 75%, 100% { opacity: 0; } 25%, 65% { opacity: 1; } }
@keyframes yellow-energy { 0%, 100% { opacity: 0; } 20%, 70% { opacity: 1; } }
@keyframes yellow-wave {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-14deg); }
  50% { transform: rotate(10deg); }
  75% { transform: rotate(-6deg); }
}
@keyframes yellow-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes yellow-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes yellow-cloud-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-1px) scale(1.06); }
}
@keyframes yellow-thought-pulse {
  0%, 100% { opacity: 0.25; }
  40%, 60% { opacity: 1; }
}


@media (prefers-reduced-motion: reduce) {
  .yellow-panel,
  .yellow-launcher,
  .yellow-field,
  .yellow-starter,
  .yellow-starter__arrow { transition: none; }
}

/* --------------------------------------------------------------------------
   Móvil: hoja inferior; el botón de apertura es solo el personaje
   -------------------------------------------------------------------------- */

@media (max-width: 47.9375em) {
  .yellow-launcher {
    right: var(--space-2);
    bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    width: 3.25rem;
    height: 3.25rem;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    justify-content: center;
  }
  .yellow-launcher__label { display: none; }
  .yellow-peek {
    position: static;
    width: 4.5rem;
    height: 4.5rem;
    flex-shrink: 0;
  }

  .yellow-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    border-bottom: 0;
    border-radius: var(--yellow-radius) var(--yellow-radius) 0 0;
  }
  .yellow-starter { min-height: 2.75rem; } /* objetivo táctil cómodo en móvil */
  .yellow-notice { padding-bottom: calc(0.8rem + env(safe-area-inset-bottom)); }
}
