/* App MarIA — segue o mockup "Conceito visual": coluna de celular, que no
   tablet e no desktop vira um cartão centralizado. */

:root {
  --navy: #0b2c7e;
  --navy-ink: #13245a;
  --green: #14963f;
  --green-bright: #22b04f;
  --green-soft: #dcf6e3;
  --yellow: #ffcc00;
  --red: #e5333a;
  --ink: #1d2a4d;
  --muted: #5b6785;
  --line: #e6ebf5;
  --bg: #ffffff;
  --page: #eaf1fc;
  --card: #ffffff;
  --shadow: 0 6px 24px rgb(20 40 90 / 0.08);
  --radius: 18px;
  --tabbar-h: 68px;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

/* Componentes com `display` próprio não podem anular o atributo hidden. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
}

button {
  font: inherit;
  color: inherit;
}

svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

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

:focus-visible {
  outline: 3px solid var(--navy);
  outline-offset: 3px;
}

/* ─── Moldura ─────────────────────────────────────────────────── */

.app {
  position: relative;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.main {
  flex: 1;
  padding: max(16px, env(safe-area-inset-top)) 16px 20px;
}

@media (min-width: 600px) {
  body {
    background: radial-gradient(circle at 20% 0%, #f6f9ff, var(--page) 60%);
    padding: 24px 0;
  }

  .app {
    min-height: calc(100dvh - 48px);
    border-radius: 32px;
    box-shadow: 0 20px 60px rgb(20 40 90 / 0.14);
    overflow: hidden;
  }
}

/* ─── Marca ───────────────────────────────────────────────────── */

.brand {
  position: relative;
  display: flex;
  justify-content: center;
}

.logo {
  width: min(250px, 66vw);
  height: auto;
  stroke: none;
}

.logo__mar {
  font-family: 'Montserrat', 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: 98px;
  fill: var(--navy);
}

.logo__ia {
  font-family: 'Montserrat', 'Arial Black', sans-serif;
  font-weight: 900;
  font-size: 64px;
  fill: var(--yellow);
}

/* ─── Herói: avatar, nome, espectro, controles ────────────────── */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Na linha do logo, à esquerda: não ocupa altura da tela. */
.back {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 8px 6px;
  border: 0;
  border-radius: 999px;
  background: #f1f4fa;
  color: var(--navy);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.back svg {
  width: 18px;
  height: 18px;
}

.portrait {
  --level: 0;
  --face: min(232px, 60vw);
  position: relative;
  /* Largura e altura explícitas: com aspect-ratio + padding o Safari do
     iPhone desenhava o círculo oval. */
  width: var(--face);
  height: var(--face);
  flex-shrink: 0;
  margin-top: 10px;
  border-radius: 50%;
  background: var(--green-soft);
  padding: 10px;
  /* O halo cresce com a voz de quem está falando. */
  box-shadow: 0 0 0 calc(var(--level) * 12px) rgb(34 176 79 / 0.16);
  transition: box-shadow 90ms linear;
}

.portrait__face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #e8f1fa;
}

/* Camadas do avatar (static/js/avatar.js): boca embaixo, olhos por cima. */
.avatar__layer {
  position: absolute;
  inset: 0;
}

.avatar__eyes {
  z-index: 1;
}

.avatar__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  /* Sai só depois que a próxima, por cima, terminou de entrar. */
  transition: opacity 0s linear 60ms;
}

.avatar__frame.is-visible {
  opacity: 1;
  transition: opacity 60ms ease-out;
}

/* Olhos são recortes sobre a boca: podem esmaecer nos dois sentidos. */
.avatar__eyes .avatar__frame,
.avatar__eyes .avatar__frame.is-visible {
  transition: opacity 45ms linear;
}

.service-chip {
  margin: 14px 0 0;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--chip-bg, var(--green-soft));
  color: var(--chip-ink, var(--green));
}

.hello {
  margin: 14px 0 0;
  font-family: 'Montserrat', sans-serif;
  font-size: clamp(26px, 7.4vw, 32px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy-ink);
  line-height: 1.1;
}

.service-chip:not([hidden]) + .hello {
  margin-top: 8px;
}

.hello em {
  font-style: normal;
  color: var(--green);
}

.greeting {
  margin: 6px 0 0;
  font-size: 17px;
  color: var(--muted);
}

.spectrum {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 330px;
  height: 64px;
  margin-top: 18px;
}

.spectrum i {
  flex: 0 0 5px;
  height: 100%;
  border-radius: 3px;
  background: var(--bar, var(--green-bright));
  transform: scaleY(0.08);
  will-change: transform;
}

.status {
  margin: 6px 0 0;
  min-height: 22px;
  font-size: 16px;
  font-weight: 600;
  color: var(--green);
}

.app[data-mode='idle'] .status {
  color: var(--muted);
  font-weight: 500;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin-top: 14px;
}

.ctl {
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition:
    transform 120ms ease,
    opacity 120ms ease;
}

.ctl:active:not(:disabled) {
  transform: scale(0.94);
}

.ctl:disabled {
  opacity: 0.45;
  cursor: default;
}

.ctl--mute {
  width: 58px;
  height: 58px;
  background: #e8edf8;
  color: var(--navy);
}

.ctl--mute[aria-pressed='true'] {
  background: var(--navy);
  color: #fff;
}

.ctl--mic {
  position: relative;
  width: 88px;
  height: 88px;
  background: linear-gradient(160deg, var(--green-bright), var(--green));
  color: #fff;
  box-shadow:
    0 0 0 9px rgb(34 176 79 / 0.16),
    0 10px 24px rgb(20 150 63 / 0.35);
}

.ctl--mic svg {
  width: 38px;
  height: 38px;
}

/* Conversa aberta: o botão "respira", como no mockup. */
.app[data-connected='true'] .ctl--mic::after {
  content: '';
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 3px solid rgb(34 176 79 / 0.35);
  animation: ring 1.8s ease-out infinite;
}

.app[data-connected='true'] .ctl--mic {
  cursor: default;
}

.ctl--end {
  width: 62px;
  height: 62px;
  background: var(--red);
  color: #fff;
  box-shadow: 0 8px 18px rgb(229 51 58 / 0.3);
}

@keyframes ring {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* Aviso flutuante acima da barra inferior: não empurra o layout. */
.error {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  z-index: 15;
  width: min(448px, calc(100% - 32px));
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fdecee;
  color: #a3222a;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 10px 30px rgb(163 34 42 / 0.18);
  transform: translateX(-50%);
}

/* ─── "Como posso ajudar hoje?" ───────────────────────────────── */

.help {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  padding: 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--navy-ink);
  text-decoration: none;
}

/* Logo do WhatsApp em rosa (pedido do produto; o manual da Meta prevê só
   verde, preto ou branco). O logo já é o próprio balão: sem fundo. */
.help__icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #ec4899;
}

.help__icon svg {
  width: 100%;
  height: 100%;
}

.help__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: 17px;
  font-weight: 700;
}

.help__text small {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.help__chevron {
  color: var(--muted);
}

/* ─── Atendimentos ────────────────────────────────────────────── */

.services {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
  scroll-margin-top: 16px;
}

.service {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px 10px;
  border: 0;
  border-radius: var(--radius);
  background: var(--tint);
  color: var(--ink-tint);
  cursor: pointer;
  transition: transform 120ms ease;
}

.service:active {
  transform: scale(0.97);
}

.service > svg:first-child {
  width: 34px;
  height: 34px;
  stroke-width: 2.2;
}

.service span {
  /* Estreito de propósito: os quatro rótulos quebram em duas linhas iguais. */
  max-width: 5.6em;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--navy-ink);
}

.service__chevron {
  width: 18px;
  height: 18px;
}

.service[aria-current='true'] {
  outline: 2.5px solid var(--ink-tint);
  outline-offset: -2.5px;
}

.service--protecao {
  --tint: #fde8eb;
  --ink-tint: #d3263a;
}

.service--exames {
  --tint: #e2f6e8;
  --ink-tint: #14963f;
}

.service--emprego {
  --tint: #e4eefd;
  --ink-tint: #1f4fc4;
}

.service--negocio {
  --tint: #fff4d4;
  --ink-tint: #e8a400;
}

@media (max-width: 330px) {
  .services {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ─── Barra inferior ──────────────────────────────────────────── */

.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: var(--tabbar-h);
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgb(255 255 255 / 0.96);
  backdrop-filter: blur(8px);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: #8a94ab;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.tab.is-active {
  color: var(--navy);
  font-weight: 700;
}

.tab.is-active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  width: 44px;
  height: 3px;
  border-radius: 2px;
  background: var(--navy);
}

/* ─── Histórico ───────────────────────────────────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(13 26 60 / 0.4);
}

.sheet[hidden] {
  display: none;
}

.sheet__panel {
  width: 100%;
  max-width: 480px;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--bg);
  animation: rise 220ms ease-out;
}

@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet__head h2 {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 20px;
  color: var(--navy-ink);
}

.sheet__close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #f1f4fa;
  cursor: pointer;
}

.sheet__note {
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log li {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.4;
}

.log .log__user {
  align-self: flex-end;
  background: #e4eefd;
}

.log .log__agent {
  align-self: flex-start;
  background: #f1f4f8;
}

.log .log__divider {
  align-self: center;
  max-width: none;
  padding: 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.log b {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.sheet__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 11px 16px;
  border: 1px solid #f3c4ca;
  border-radius: 12px;
  background: #fff5f6;
  color: #b4232f;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.sheet__clear svg {
  width: 18px;
  height: 18px;
}

/* Sem conversas, não há o que apagar. */
.log__empty:not([hidden]) + .sheet__clear {
  display: none;
}

.log__empty {
  margin: 12px 0;
  text-align: center;
  color: var(--muted);
}

/* ─── Sobre (tela da 2Labs) ───────────────────────────────────── */

.about {
  --brand: #1a6e8c;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 20;
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  background: #f6f9fc;
  transform: translateX(-50%);
  animation: rise 220ms ease-out;
}

.about__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.about__bar h2 {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 20px;
  color: var(--navy-ink);
}

.about__back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #f1f4fa;
  color: var(--navy);
  cursor: pointer;
}

.about__scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.twolabs {
  width: 150px;
  height: auto;
  stroke: none;
}

.twolabs text {
  font-family: 'Inter', Arial, sans-serif;
  font-weight: 800;
}

.twolabs__two {
  font-size: 32px;
  fill: var(--brand);
}

.twolabs__labs {
  font-size: 26px;
  letter-spacing: 0.5px;
  fill: #111827;
}

.twolabs__sub {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 3.5px;
  fill: #374151;
}

.about__hero,
.about__card,
.about__notice {
  border: 1px solid #dde8f2;
  border-radius: 16px;
  background: var(--bg);
}

.about__hero {
  padding: 22px 18px 8px;
  background: linear-gradient(160deg, #ffffff 30%, #eaf4fb);
}

.about__hero h3 {
  margin: 16px 0 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 22px;
  line-height: 1.25;
  color: #111827;
}

.about__hero p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: #4b5563;
}

.about__art {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 6px;
  stroke: none;
}

.about__notice {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: #eef6fb;
}

.about__notice p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
}

.about__notice b {
  display: block;
  color: #111827;
}

.about__badge {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #e1eff8;
  color: var(--brand);
}

.about__badge svg {
  width: 22px;
  height: 22px;
}

.about__card {
  padding: 16px;
}

.about__card h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 15px;
  color: #111827;
}

.about__card h4 svg {
  width: 20px;
  height: 20px;
  color: var(--brand);
}

.about__identity {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e5edf5;
  border-radius: 12px;
}

.about__logo-box {
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 10px;
  background: #eef5fb;
}

.about__logo-box .twolabs {
  width: 170px;
}

.about__identity p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
}

.about__facts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.about__facts li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e5edf5;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.about__facts small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
}

.about__footer {
  padding: 6px 2px 0;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
}
/* ─── Celular: uma tela só, sem rolagem ────────────────────────────
   O app ocupa exatamente a altura visível (dvh já desconta a barra do
   Safari). Cada bloco usa uma fração dessa altura, com piso e teto, e
   a área do avatar absorve o que sobrar. */

@media (max-width: 599px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .app {
    height: 100vh; /* navegadores sem dvh */
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: max(8px, env(safe-area-inset-top)) 14px 8px;
    gap: 1.2dvh;
  }

  .logo {
    width: auto;
    height: clamp(42px, 8.5dvh, 76px);
  }

  .back {
    padding: 6px 10px 6px 4px;
    font-size: 13px;
  }

  /* A área central mede a própria altura (container query) e o avatar fica
     com o que sobrar depois do texto, espectro e botões — medido: ~25dvh + 50px. */
  .hero {
    flex: 1;
    min-height: 0;
    justify-content: center;
    container-type: size;
  }

  .portrait {
    --face: clamp(110px, min(27dvh, 60vw), 232px); /* sem container queries */
    --face: clamp(80px, min(60vw, 100cqh - 25dvh - 50px), 232px);
    margin-top: 0;
    padding: 7px;
  }

  .service-chip {
    margin-top: 1dvh;
    padding: 2px 10px;
    font-size: 12px;
  }

  .hello {
    margin-top: 0.9dvh;
    font-size: clamp(21px, 3.7dvh, 30px);
  }

  .service-chip:not([hidden]) + .hello {
    margin-top: 0.5dvh;
  }

  .greeting {
    margin-top: 2px;
    font-size: clamp(13px, 2.1dvh, 16px);
  }

  .spectrum {
    height: clamp(26px, 6dvh, 56px);
    margin-top: 1.2dvh;
  }

  .status {
    margin-top: 2px;
    min-height: 18px;
    font-size: clamp(13px, 2dvh, 15px);
  }

  .controls {
    margin-top: 1dvh;
    gap: 24px;
  }

  .ctl--mute {
    width: clamp(44px, 6.6dvh, 56px);
    height: clamp(44px, 6.6dvh, 56px);
  }

  .ctl--mic {
    width: clamp(60px, 9.6dvh, 84px);
    height: clamp(60px, 9.6dvh, 84px);
    box-shadow:
      0 0 0 7px rgb(34 176 79 / 0.16),
      0 8px 20px rgb(20 150 63 / 0.32);
  }

  .ctl--mic svg {
    width: 32px;
    height: 32px;
  }

  .ctl--end {
    width: clamp(48px, 7.2dvh, 60px);
    height: clamp(48px, 7.2dvh, 60px);
  }

  .help {
    margin-top: 0;
    padding: 9px 12px;
    gap: 10px;
  }

  .help__icon {
    width: 34px;
    height: 34px;
  }


  .help__text {
    font-size: 15px;
  }

  .help__text small {
    font-size: 12px;
  }

  .services {
    margin-top: 0;
    gap: 8px;
  }

  .service {
    gap: 3px;
    padding: 9px 2px 6px;
    border-radius: 14px;
  }

  .service > svg:first-child {
    width: 26px;
    height: 26px;
  }

  .service span {
    font-size: 12.5px;
  }

  .service__chevron {
    width: 14px;
    height: 14px;
  }

  .tabbar {
    --tabbar-h: 58px;
    position: static;
    padding-top: 4px;
  }

  .tab {
    font-size: 12px;
  }

  .tab svg {
    width: 22px;
    height: 22px;
  }
}

/* Celular baixo (iPhone SE e parecidos): some o texto secundário para o
   rosto não ficar minúsculo. */
@media (max-width: 599px) and (max-height: 600px) {
  .greeting,
  .help__text small,
  .service__chevron {
    display: none;
  }

  .help {
    padding: 7px 12px;
  }

  .help__icon {
    width: 30px;
    height: 30px;
  }

  .portrait {
    --face: clamp(80px, min(60vw, 100cqh - 25dvh - 30px), 232px);
  }
}

/* Celular muito baixo (ou deitado): melhor rolar do que espremer. */
@media (max-width: 599px) and (max-height: 520px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
