/* ============================================
   IRIA · COMPONENTS · Re-usable UI atoms
   ============================================ */

/* APP HEADER (dins de pantalles) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 56px;
  padding-right: 18px;
  padding-bottom: 14px;
  padding-left: 18px;
  border-bottom: 1px solid var(--divider);
  background: var(--glass-top);
  backdrop-filter: blur(12px) saturate(1.04);
  -webkit-backdrop-filter: blur(12px) saturate(1.04);
  box-shadow: 0 1px 0 rgba(255, 249, 238, .65);
  position: relative;
  z-index: 10;
}

.back-btn,
.settings-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(30, 30, 30, .09);
  transition: transform var(--t-fast);
}

.back-btn:hover,
.settings-btn:hover {
  transform: translate(-1px, -1px);
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.header-eyebrow {
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--rust);
}

.header-title {
  font-family: 'Bebas Neue';
  font-size: 16px;
  letter-spacing: .06em;
  color: var(--ink);
}

/* ============================================
   AVATAR IRIA · Live pulsing + halo
   ============================================ */

.iria-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.iria-avatar.size-sm { width: 46px; height: 46px; }
.iria-avatar.size-md { width: 108px; height: 108px; }
.iria-avatar.size-lg { width: 140px; height: 140px; }

.iria-halo {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2.5px solid var(--green);
  opacity: 0;
  pointer-events: none;
}

.iria-halo::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--green);
  opacity: 0;
}

.iria-avatar[data-state="listening"] .iria-halo {
  animation: halo-pulse 2.2s var(--ease-out) infinite;
}

.iria-avatar[data-state="listening"] .iria-halo::after {
  animation: halo-pulse 2.2s var(--ease-out) infinite;
  animation-delay: .8s;
}

@keyframes halo-pulse {
  0%   { opacity: 0; transform: scale(.92); }
  35%  { opacity: .5; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.18); }
}

.iria-circle {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, var(--rust-light) 0%, var(--rust) 55%, var(--rust-dark) 100%);
  border: 2px solid var(--line);
  box-shadow: 5px 6px 0 rgba(30, 30, 30, .18);
  transition: transform var(--t-mid) var(--ease-out);
}

.iria-avatar[data-state="thinking"] .iria-circle {
  animation: think-rotate 3s linear infinite;
}

@keyframes think-rotate {
  to { transform: rotate(360deg); }
}

.iria-avatar[data-state="speaking"] .iria-circle,
.iria-avatar[data-state="celebrate"] .iria-circle {
  animation: speak-bounce .9s var(--ease-out) infinite alternate;
}

@keyframes speak-bounce {
  to { transform: translateY(-3px) scale(1.02); }
}

.iria-dot {
  position: absolute;
  top: 28%;
  left: 30%;
  width: 16%;
  height: 16%;
  border-radius: 50%;
  background: var(--mustard);
  border: 1.5px solid var(--line);
  transition: top var(--t-mid) var(--ease-out), left var(--t-mid) var(--ease-out);
}

.iria-avatar[data-state="listening"] .iria-dot {
  top: 24%;
  left: 26%;
}

.iria-avatar[data-state="thinking"] .iria-dot {
  top: 18%;
  left: 42%;
}

.iria-avatar[data-state="speaking"] .iria-dot {
  top: 30%;
  left: 36%;
}

.iria-avatar[data-state="celebrate"] .iria-dot {
  top: 22%;
  left: 48%;
}

/* Avatar voice bars · only when speaking */
.iria-voice {
  position: absolute;
  bottom: 26%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 26px;
  opacity: 0;
  transition: opacity var(--t-fast);
}

.iria-avatar[data-state="speaking"] .iria-voice {
  opacity: 1;
}

.iria-voice span {
  width: 3px;
  background: var(--cream);
  border-radius: 2px;
  border: 1px solid var(--line);
  animation: voice-bar 1s var(--ease-out) infinite;
}

.iria-voice span:nth-child(1) { height: 8px; animation-delay: 0ms; }
.iria-voice span:nth-child(2) { height: 14px; animation-delay: 100ms; }
.iria-voice span:nth-child(3) { height: 22px; animation-delay: 200ms; }
.iria-voice span:nth-child(4) { height: 14px; animation-delay: 100ms; }
.iria-voice span:nth-child(5) { height: 8px; animation-delay: 0ms; }

@keyframes voice-bar {
  0%, 100% { transform: scaleY(.4); }
  50%      { transform: scaleY(1); }
}

/* ============================================
   ESTATS IA · chips track
   ============================================ */

.state-track {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.state-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-family: 'Bebas Neue';
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--muted);
  box-shadow: 2px 2px 0 rgba(30, 30, 30, .08);
  transition: background var(--t-mid), color var(--t-mid);
}

.state-chip.active {
  background: var(--green);
  color: var(--cream);
  box-shadow: 3px 3px 0 rgba(30, 30, 30, .18);
}

.state-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  border: 1px solid var(--line);
  transition: background var(--t-mid);
}

.state-chip.active .dot {
  background: var(--mustard);
  animation: dot-pulse 1.4s var(--ease-out) infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: .5; transform: scale(.85); }
  50%      { opacity: 1; transform: scale(1); }
}

/* ============================================
   ONA DE VEU · live wave (animated)
   ============================================ */

.wave-card {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 4px 4px 0 rgba(30, 30, 30, .10);
}

.wave-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.wave-title .lab {
  font-family: 'Bebas Neue';
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--rust);
}

.wave-title .src {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 44px;
}

.wave span {
  flex: 1;
  background: var(--green);
  border-radius: 2px;
  border: 1px solid var(--line);
  transform-origin: center;
  animation: wave-bar 1.8s var(--ease-out) infinite;
}

.wave span:nth-child(3n)   { background: var(--mustard); }
.wave span:nth-child(odd)  { background: var(--rust); }

.wave span:nth-child(1)  { animation-delay: 0ms; }
.wave span:nth-child(2)  { animation-delay: 100ms; }
.wave span:nth-child(3)  { animation-delay: 200ms; }
.wave span:nth-child(4)  { animation-delay: 50ms; }
.wave span:nth-child(5)  { animation-delay: 150ms; }
.wave span:nth-child(6)  { animation-delay: 250ms; }
.wave span:nth-child(7)  { animation-delay: 80ms; }
.wave span:nth-child(8)  { animation-delay: 180ms; }
.wave span:nth-child(9)  { animation-delay: 30ms; }
.wave span:nth-child(10) { animation-delay: 230ms; }
.wave span:nth-child(11) { animation-delay: 140ms; }
.wave span:nth-child(12) { animation-delay: 60ms; }
.wave span:nth-child(13) { animation-delay: 200ms; }
.wave span:nth-child(14) { animation-delay: 110ms; }
.wave span:nth-child(15) { animation-delay: 170ms; }
.wave span:nth-child(16) { animation-delay: 90ms; }
.wave span:nth-child(17) { animation-delay: 250ms; }
.wave span:nth-child(18) { animation-delay: 40ms; }
.wave span:nth-child(19) { animation-delay: 160ms; }
.wave span:nth-child(20) { animation-delay: 220ms; }

@keyframes wave-bar {
  0%, 100% { transform: scaleY(.25); }
  50%      { transform: scaleY(1); }
}

.wave-card.is-paused .wave span {
  animation-play-state: paused;
  opacity: 0.35;
  transform: scaleY(0.2);
}

.wave-card.is-thinking .wave-title .lab {
  color: var(--muted);
}

.wave-card.is-live .wave span {
  animation-duration: 1.1s;
}

.wave-card.is-live .wave span:nth-child(odd) {
  animation-duration: 0.85s;
}

/* ============================================
   BUBBLES · xat & typing
   ============================================ */

.bubble {
  max-width: 88%;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 3px 3px 0 rgba(30, 30, 30, .12);
  animation: bubble-in .4s var(--ease-out);
}

.bubble-user {
  align-self: flex-end;
  background: var(--mustard);
  border-radius: 18px 18px 4px 18px;
}

.bubble-iria {
  align-self: flex-start;
  background: var(--paper);
  border-radius: 18px 18px 18px 4px;
}

.bubble-text {
  font-family: 'Fraunces';
  font-size: 15px;
  font-weight: 480;
  letter-spacing: -.01em;
  color: var(--ink);
  line-height: 1.35;
}

.bubble-text em {
  font-style: italic;
  color: var(--rust-dark);
  font-weight: 600;
  border-bottom: 2px dashed var(--rust-dark);
  padding-bottom: 1px;
}

.bubble-meta {
  margin-top: 6px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--ink);
  text-transform: uppercase;
  opacity: .65;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Typing indicator */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 3px 3px 0 rgba(30, 30, 30, .10);
  align-self: flex-start;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.1s var(--ease-out) infinite;
}

.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ============================================
   DETECTION HINT (patró català)
   ============================================ */

.hint {
  display: flex;
  gap: 10px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 3px 3px 0 rgba(30, 30, 30, .10);
  align-self: flex-start;
  max-width: 90%;
  animation: bubble-in .5s var(--ease-out) .3s both;
}

.hint-chip {
  background: var(--rust);
  color: var(--cream);
  font-family: 'Bebas Neue';
  font-size: 10px;
  letter-spacing: .14em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  align-self: flex-start;
  white-space: nowrap;
}

.hint-text {
  font-size: 11.5px;
  font-weight: 500;
  color: #3A332B;
  line-height: 1.45;
}

/* ============================================
   MIC BAR (bottom)
   ============================================ */

.mic-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--divider);
  background: var(--glass-bottom);
  backdrop-filter: blur(12px) saturate(1.04);
  -webkit-backdrop-filter: blur(12px) saturate(1.04);
  box-shadow: 0 -1px 0 rgba(255, 249, 238, .5);
  position: relative;
  z-index: 5;
}

.mic-aux {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 3px 3px 0 rgba(30, 30, 30, .10);
  transition: transform var(--t-fast);
}

.mic-aux:hover { transform: translate(-1px, -1px); }

.mic-main {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--rust);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--cream);
  box-shadow: 6px 6px 0 rgba(30, 30, 30, .18);
  position: relative;
  transition: transform var(--t-fast);
}

.mic-main::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid var(--rust);
  border-radius: 50%;
  opacity: .35;
  animation: mic-pulse 1.6s var(--ease-out) infinite;
}

@keyframes mic-pulse {
  0%   { transform: scale(1); opacity: .5; }
  100% { transform: scale(1.25); opacity: 0; }
}

.mic-main:hover { transform: scale(1.04); }
.mic-main:active { transform: scale(.98); }

.mic-main svg { width: 28px; height: 28px; }

/* ============================================
   CTA · primary button (dins de pantalles)
   ============================================ */

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: var(--rust);
  color: var(--cream);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font-family: Inter;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -.01em;
  box-shadow: 4px 4px 0 rgba(30, 30, 30, .15);
  transition: transform var(--t-fast);
  width: 100%;
}

.cta:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 rgba(30, 30, 30, .18); }
.cta:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 rgba(30, 30, 30, .12); }

.cta-secondary {
  background: var(--paper);
  color: var(--ink);
}

.cta-green { background: var(--green); }
.cta-mustard { background: var(--mustard); color: var(--ink); }

/* ============================================
   FRAME MARKERS (decorative)
   ============================================ */

.frame-mark {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--line);
  z-index: 5;
  pointer-events: none;
}

.frame-mark.tl { top: 48px; left: 18px; border-right: none; border-bottom: none; }
.frame-mark.tr { top: 48px; right: 18px; border-left: none; border-bottom: none; }
.frame-mark.bl { bottom: 18px; left: 18px; border-right: none; border-top: none; }
.frame-mark.br { bottom: 18px; right: 18px; border-left: none; border-top: none; }
