/* ==========================================================
   Resultado de exames (dialog)
   ========================================================== */
.exam {
  /* mobile: tela cheia */
  width: 100%; max-width: 100%; height: 100%; max-height: 100%;
  margin: 0; padding: 0; border: 0;
  display: none; flex-direction: column;
  background: var(--cream); color: var(--ink);
  overflow: hidden;
}
.exam[open] { display: flex; animation: exam-up .45s var(--ease); }
.exam::backdrop { background: rgba(5, 58, 32, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.exam[open]::backdrop { animation: fade .3s ease; }
.exam.is-closing { animation: exam-down .3s var(--ease) forwards; }
.exam.is-closing::backdrop { animation: fade .3s ease reverse forwards; }

/* ---------- cabeçalho ---------- */
.exam__head {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 14px;
  background: var(--forest-900); color: #fff;
}
.exam__icon {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 12px;
  background: var(--lime); color: var(--forest-900);
}
.exam__titles { flex: 1; min-width: 0; }
.exam__titles h2 { font-size: 1.12rem; }
.exam__titles p { font-size: .82rem; color: #b9cdbf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam__close, .exam__back {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .1); color: #fff; cursor: pointer;
  transition: background .2s, transform .3s var(--ease);
}
.exam__close:hover { background: rgba(255, 255, 255, .2); transform: rotate(90deg); }
.exam__back { display: none; }
.exam__back .i { transform: rotate(180deg); }
.exam__back:hover { background: rgba(255, 255, 255, .2); transform: translateX(-2px); }
.exam:not([data-step="form"]) .exam__back { display: grid; }
.exam:not([data-step="form"]) .exam__icon { display: none; }

/* ---------- corpo e etapas ---------- */
.exam__body { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.exam__step { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.exam__step[hidden] { display: none !important; }
.exam__step:not([hidden]) { animation: step-in .45s var(--ease); }
@keyframes step-in { from { opacity: 0; transform: translateX(24px); } }

/* etapa 1 — telefone */
.exam__step--form {
  display: flex; flex-direction: column; justify-content: center; gap: 24px;
  padding: 28px var(--gutter) 24px;
  background:
    radial-gradient(circle at 50% -10%, rgba(127, 174, 78, .28), transparent 55%),
    var(--cream);
}

.exam__hero { text-align: center; }
.exam__hero h3 { font-size: clamp(1.6rem, 6.5vw, 2rem); font-weight: 800; color: var(--forest-900); margin-bottom: 8px; }
.exam__hero h3 em { color: var(--forest-600); }
.exam__hero p { color: var(--ink-2); }

.exam__art { position: relative; width: 120px; height: 120px; margin: 0 auto 20px; }
.exam__art-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px dashed rgba(11, 107, 58, .25);
  animation: rotate 24s linear infinite;
}
.exam__art-core {
  position: absolute; inset: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--forest-600), var(--forest-900)); color: var(--lime);
  box-shadow: 0 14px 30px rgba(5, 58, 32, .3);
}
.exam__art-core .i { width: 38px; height: 38px; }
.exam__art-chip {
  position: absolute; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--paper); color: var(--forest-700); box-shadow: var(--shadow);
  animation: float 5s ease-in-out infinite;
}
.exam__art-chip .i { width: 18px; height: 18px; }
.exam__art-chip--a { right: -6px; top: 10px; background: var(--lime); color: var(--forest-900); }
.exam__art-chip--a .i { stroke-width: 2.8; }
.exam__art-chip--b { left: -8px; bottom: 8px; animation-delay: -2.5s; }
.exam__art-chip--b .i { fill: currentColor; stroke: none; }
@keyframes rotate { to { transform: rotate(360deg); } }

.exam__form { display: grid; gap: 10px; width: 100%; max-width: 420px; margin-inline: auto; }
.exam__input {
  position: relative; display: flex; align-items: center;
  height: 64px; padding: 0 10px 0 8px; border-radius: 18px;
  background: var(--paper); border: 2px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.exam__input:focus-within { border-color: var(--forest-600); box-shadow: 0 0 0 5px rgba(11, 107, 58, .12); }
.exam__input.is-valid { border-color: var(--open); }
.exam__input.has-error { border-color: var(--coral); animation: shake .35s; }
.exam__prefix {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 13px;
  background: var(--lime-100); color: var(--forest-700); margin-right: 10px;
  transition: background .25s, color .25s;
}
.exam__input.is-valid .exam__prefix { background: var(--open); color: #fff; }
.exam__input input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; letter-spacing: .01em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.exam__input input::placeholder { color: #c3c9c1; font-weight: 500; }
.exam__clear {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: var(--sand); color: var(--ink-2); cursor: pointer;
}
.exam__clear[hidden] { display: none; }
.exam__clear .i { width: 16px; height: 16px; }
.exam__hint { padding-left: 6px; font-size: .84rem; color: var(--ink-3); min-height: 1.3em; }
.exam__hint.is-error { color: var(--coral); font-weight: 600; }
.exam__form .btn { margin-top: 6px; }
.exam__form .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

.exam__perks {
  list-style: none; margin: 0 auto; padding: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px;
  font-size: .82rem; color: var(--ink-2);
}
.exam__perks li { display: inline-flex; align-items: center; gap: 6px; }
.exam__perks .i { width: 16px; height: 16px; color: var(--open); stroke-width: 2.6; }

/* etapa 2 — resultados */
.exam__step--result { background: var(--cream); overflow: hidden; }
.exam__step--result iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
  background: var(--cream); opacity: 0; transition: opacity .35s;
}
.exam.is-ready .exam__step--result iframe { opacity: 1; }
.exam__loading {
  position: absolute; inset: 0; display: grid; align-content: start; gap: 18px;
  padding: 28px var(--gutter); color: var(--ink-3); font-size: .9rem; text-align: center;
  transition: opacity .3s;
}
.exam.is-ready .exam__loading { opacity: 0; pointer-events: none; }
.skeleton { display: grid; gap: 12px; }
.skeleton span {
  height: 72px; border-radius: 16px;
  background: linear-gradient(90deg, #efeadf 0%, #f8f5ee 50%, #efeadf 100%) 0 0 / 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton span:first-child { height: 26px; width: 55%; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* etapa 3 — não encontrado */
.exam__step--empty { display: grid; place-items: center; padding: 28px var(--gutter); background: var(--cream); }
.exam__empty { width: 100%; max-width: 400px; text-align: center; }
.exam__empty-icon {
  display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%;
  background: #ffe8e2; color: var(--coral);
}
.exam__empty-icon .i { width: 34px; height: 34px; }
.exam__empty h3 { font-size: 1.5rem; margin-bottom: 8px; }
.exam__empty > p { color: var(--ink-2); }
.exam__empty strong { color: var(--ink); white-space: nowrap; }
.exam__empty-actions { display: grid; gap: 10px; margin: 24px 0 16px; }
.exam__empty-note { font-size: .82rem; color: var(--ink-3) !important; }

/* ---------- rodapé ---------- */
.exam__foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--paper);
  font-size: .82rem; color: var(--ink-3);
}
.exam__foot a { color: var(--forest-600); font-weight: 700; text-decoration: none; }
.exam__foot a:hover { text-decoration: underline; }

@keyframes exam-up { from { transform: translateY(40px); opacity: 0; } }
@keyframes exam-down { to { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* desktop: janela central */
@media (min-width: 720px) {
  .exam {
    width: min(760px, calc(100vw - 48px)); height: min(720px, calc(100dvh - 64px));
    margin: auto; border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  }
  .exam__head { padding: 16px 24px; }
  .exam__step--form { padding: 36px 48px; }
  .exam__foot { padding: 14px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .exam[open], .exam.is-closing, .exam__step:not([hidden]) { animation: none; }
  .exam__art-ring, .exam__art-chip, .skeleton span { animation: none; }
}
