/* ============================================================
   MELIA HERO — Widget vocal vitrine
   Palette : teal #4ECDC4 | coral #FF6B6B | navy #1A1A2E
   Mobile-first — 320px minimum
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --mh-teal:        #4ECDC4;
  --mh-teal-dark:   #3BA99C;
  --mh-coral:       #FF6B6B;
  --mh-navy:        #1A1A2E;
  --mh-navy-light:  #2D2D44;
  --mh-white:       #FFFFFF;
  --mh-dim:         rgba(255, 255, 255, 0.55);
  --mh-transition:  0.35s ease;
  --mh-avatar-size: 260px;
}

/* ── Hero layout ──────────────────────────────────────────── */
.melia-hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mh-navy);
  overflow: hidden;
  padding: 88px 48px 56px;
  gap: 64px;
}

/* Background image (darkened) */
.melia-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('./images/h1_accueil.jpeg');
  background-size: cover;
  background-position: center;
  filter: blur(1px) brightness(0.20);
  z-index: 0;
}

/* ── Left column ──────────────────────────────────────────── */
.mh-left {
  position: relative;
  z-index: 1;
  flex: 1;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.mh-logo {
  font-size: 24px;
  font-weight: 800;
  color: var(--mh-teal);
  letter-spacing: 1px;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mh-logo-bar {
  display: inline-block;
  width: 28px;
  height: 3px;
  background: var(--mh-teal);
  border-radius: 2px;
}

.mh-headline {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(28px, 3.6vw, 48px);
  font-weight: 800;
  color: var(--mh-white);
  line-height: 1.15;
  margin: 0;
}

.mh-headline em {
  font-style: normal;
  color: var(--mh-teal);
}

.mh-sub {
  font-size: clamp(15px, 1.6vw, 18px);
  color: var(--mh-dim);
  line-height: 1.70;
  margin: 0;
  max-width: 460px;
}

/* ── CTA Button ───────────────────────────────────────────── */
.mh-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 38px;
  background: linear-gradient(135deg, var(--mh-teal), var(--mh-teal-dark));
  color: var(--mh-navy);
  border: none;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  box-shadow: 0 8px 32px rgba(78, 205, 196, 0.40);
  transition: transform var(--mh-transition), box-shadow var(--mh-transition);
  align-self: flex-start;
  animation: mh-cta-breathe 2.8s ease-in-out infinite;
}

.mh-cta-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 44px rgba(78, 205, 196, 0.60);
}

@keyframes mh-cta-breathe {
  0%, 100% { box-shadow: 0 8px 32px rgba(78, 205, 196, 0.40); }
  50%       { box-shadow: 0 8px 52px rgba(78, 205, 196, 0.70); }
}

.mh-cta-icon {
  font-size: 22px;
  line-height: 1;
}

.mh-badge {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.35);
  font-style: italic;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── End session button (left side, visible when active) ──── */
.mh-end-btn {
  display: none;
  background: none;
  border: 1px solid rgba(255, 107, 107, 0.40);
  color: rgba(255, 107, 107, 0.80);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  align-self: flex-start;
}

.mh-end-btn:hover {
  border-color: var(--mh-coral);
  color: var(--mh-coral);
}

/* ── Right column ─────────────────────────────────────────── */
.mh-right {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  /* Fixed height prevents layout shift when state-label/timer appear */
  min-height: calc(var(--mh-avatar-size) + 80px);
}

/* ── Avatar zone ──────────────────────────────────────────── */
.mh-avatar-zone {
  position: relative;
  width: var(--mh-avatar-size);
  height: var(--mh-avatar-size);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mh-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  position: relative;
  z-index: 2;
  transition: filter var(--mh-transition);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.50);
}

/* ── Rings ────────────────────────────────────────────────── */
.mh-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--mh-teal);
  opacity: 0;
  z-index: 1;
  pointer-events: none;
}

/* ── State: idle — avatar cliquable ──────────────────────── */
.mh-state-idle {
  cursor: pointer;
}

.mh-state-idle .mh-avatar-img:hover {
  filter: brightness(1.08);
  transition: filter 0.2s;
}

.mh-state-idle .mh-ring-1 {
  opacity: 1;
  animation: mh-idle-breathe 3.2s ease-in-out infinite;
}

@keyframes mh-idle-breathe {
  0%, 100% { transform: scale(1.05); opacity: 0.25; }
  50%       { transform: scale(1.12); opacity: 0.55; }
}

/* ── State: requesting ────────────────────────────────────── */
.mh-state-requesting .mh-ring-1 {
  opacity: 1;
  border-right-color: transparent;
  border-bottom-color: transparent;
  animation: mh-spin 0.9s linear infinite;
}

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

/* ── State: connected ─────────────────────────────────────── */
.mh-state-connected .mh-ring-1 {
  opacity: 1;
  transform: scale(1.07);
  animation: mh-connected-glow 2.2s ease-in-out infinite;
}

@keyframes mh-connected-glow {
  0%, 100% { box-shadow: 0 0 14px rgba(78, 205, 196, 0.35); opacity: 0.7; }
  50%       { box-shadow: 0 0 30px rgba(78, 205, 196, 0.75); opacity: 1.0; }
}

/* ── State: listening ────────────────────────────────────── */
.mh-state-listening .mh-ring-1 {
  opacity: 1;
  animation: mh-expand 1.4s ease-out infinite;
}
.mh-state-listening .mh-ring-2 {
  opacity: 1;
  animation: mh-expand 1.4s ease-out 0.45s infinite;
}
.mh-state-listening .mh-ring-3 {
  opacity: 1;
  animation: mh-expand 1.4s ease-out 0.90s infinite;
}

@keyframes mh-expand {
  0%   { transform: scale(1.05); opacity: 0.75; }
  100% { transform: scale(1.65); opacity: 0;    }
}

/* ── State: speaking ─────────────────────────────────────── */
.mh-state-speaking .mh-ring-1 {
  opacity: 1;
  transform: scale(1.07);
  animation: mh-speak-pulse 0.9s ease-in-out infinite alternate;
}
.mh-state-speaking .mh-ring-2 {
  opacity: 0.55;
  transform: scale(1.14);
  animation: mh-speak-pulse 0.9s ease-in-out 0.25s infinite alternate;
}

@keyframes mh-speak-pulse {
  from { box-shadow: 0 0 10px rgba(78, 205, 196, 0.25); opacity: 0.45; }
  to   { box-shadow: 0 0 38px rgba(78, 205, 196, 0.85); opacity: 1.00; }
}

/* ── State: error ────────────────────────────────────────── */
.mh-state-error .mh-ring-1 {
  opacity: 1;
  border-color: var(--mh-coral);
  transform: scale(1.07);
}

.mh-state-error .mh-avatar-img {
  filter: brightness(0.55);
}

/* ── State: ended ────────────────────────────────────────── */
.mh-state-ended .mh-avatar-img {
  filter: brightness(0.45) grayscale(0.4);
}

/* ── Speech bubble ───────────────────────────────────────── */
.mh-bubble {
  display: none;
  background: rgba(26, 26, 46, 0.90);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(78, 205, 196, 0.30);
  border-radius: 18px;
  padding: 14px 20px;
  font-size: 14px;
  line-height: 1.60;
  color: var(--mh-white);
  max-width: 300px;
  text-align: center;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  animation: mh-bubble-in 0.25s ease-out;
}

@keyframes mh-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.mh-bubble.partial {
  opacity: 0.75;
  font-style: italic;
}

/* ── State label ──────────────────────────────────────────── */
.mh-state-label {
  display: none;
  font-size: 13px;
  color: var(--mh-dim);
  text-align: center;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0.3px;
}

/* ── Timer ────────────────────────────────────────────────── */
.mh-timer {
  display: none;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.35);
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition: color 0.4s;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.mh-timer.warning {
  color: var(--mh-coral);
  font-weight: 600;
}

/* ── Error box ────────────────────────────────────────────── */
.mh-error-box {
  display: none;
  background: rgba(255, 107, 107, 0.10);
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 16px;
  padding: 18px 22px;
  max-width: 300px;
  text-align: center;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.mh-error-msg {
  color: var(--mh-white);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 14px;
}

.mh-retry-btn {
  padding: 10px 26px;
  background: var(--mh-teal);
  color: var(--mh-navy);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.3s;
  font-family: inherit;
}

.mh-retry-btn:hover {
  background: var(--mh-teal-dark);
}

/* ── Session ended box ────────────────────────────────────── */
.mh-ended-box {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.mh-ended-emoji { font-size: 38px; }

.mh-ended-text {
  color: var(--mh-white);
  font-size: 15px;
  font-weight: 600;
}

.mh-ended-sub {
  color: var(--mh-dim);
  font-size: 13px;
}

.mh-dismiss-btn {
  margin-top: 4px;
  padding: 10px 26px;
  background: var(--mh-teal);
  color: var(--mh-navy);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background 0.3s;
  font-family: inherit;
}

.mh-dismiss-btn:hover {
  background: var(--mh-teal-dark);
}

/* ── Tablet ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .melia-hero {
    gap: 40px;
    padding: 88px 32px 48px;
  }

  :root {
    --mh-avatar-size: 220px;
  }
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 720px) {
  .melia-hero {
    flex-direction: column-reverse;
    align-items: center;
    padding: 100px 20px 52px;
    gap: 28px;
    min-height: auto;
  }

  .mh-left {
    align-items: center;
    text-align: center;
    max-width: 100%;
  }

  .mh-sub {
    max-width: 100%;
  }

  .mh-cta-btn {
    align-self: center;
  }

  .mh-end-btn {
    align-self: center;
  }

  /* Right column fixed height — évite les sauts de layout */
  .mh-right {
    min-height: 320px;
    justify-content: center;
  }

  :root {
    --mh-avatar-size: 190px;
  }
}

@media (max-width: 400px) {
  .melia-hero {
    padding: 96px 16px 44px;
  }

  :root {
    --mh-avatar-size: 160px;
  }

  .mh-cta-btn {
    padding: 16px 28px;
    font-size: 16px;
  }
}
