/* Imitação (scripts/features/imitation.js): fundo branco, personagem grande no meio. */
body[data-design] .choices.im-workspace {
  --im-height: clamp(380px, calc(100dvh - 150px), 900px);
  display: block;
  width: 100%;
  max-width: none;
  margin: 0 auto;
}

body.training-fullscreen .choices.im-workspace {
  --im-height: calc(100dvh - 70px);
}

body[data-design] .im-page {
  height: var(--im-height);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: clamp(8px, 1.6vh, 16px);
  padding: clamp(10px, 2vh, 20px);
  box-sizing: border-box;
  border-radius: 28px;
  background: #ffffff;
}

.im-title {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #1d3b57;
}

.im-title strong {
  font-size: clamp(1.5rem, 3.2vw, 2.4rem);
  font-weight: 950;
  letter-spacing: 0;
}

.im-category {
  padding: 4px 12px;
  border-radius: 999px;
  background: #e8f3fd;
  color: #0f5c99;
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
}

.im-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.im-stage video {
  /* Sempre cabe na área (largura ou altura, o que for menor), sem passar por cima do botão. */
  position: absolute;
  inset: 0;
  margin: auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  background: #ffffff;
  object-fit: contain;
  pointer-events: none;
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.im-page.is-playing .im-stage video {
  transform: scale(1.02);
  box-shadow: 0 0 0 6px #ffd23f, 0 14px 40px rgba(15, 92, 153, 0.18);
}

.im-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 92, 153, 0.85);
  color: #ffffff;
  font-weight: 900;
  transform: translateX(-50%);
  pointer-events: none;
  animation: im-hint-pulse 1.6s ease-in-out infinite;
}

.im-page.is-playing .im-hint,
.im-page.is-done .im-hint,
body.training-fullscreen .im-hint {
  display: none;
}

@keyframes im-hint-pulse {
  50% { transform: translateX(-50%) scale(1.06); }
}

.im-show {
  min-height: 56px;
  padding: 0 34px;
  border: 0;
  border-radius: 18px;
  background: #22a55b;
  color: #ffffff;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 900;
  box-shadow: 0 5px 0 #17803f;
  cursor: pointer;
}

.im-show:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #17803f;
}

.im-page.is-playing .im-show {
  opacity: 0.55;
}

.im-star {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  color: #ffc83d;
  font-size: clamp(1.6rem, 3.5vw, 2.6rem);
  text-shadow: 0 2px 6px rgba(160, 110, 0, 0.35);
  pointer-events: none;
  animation: im-star 1s ease-out var(--delay) both;
}

@keyframes im-star {
  from { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  30% { opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(40deg); opacity: 0; }
}

.im-empty {
  align-self: center;
  color: #47637d;
  font-weight: 800;
}

/* Seta "próxima ação", meio transparente, no canto de baixo à direita. */
body[data-design] .im-page {
  position: relative;
}

.im-next {
  position: absolute;
  right: clamp(12px, 2vw, 24px);
  bottom: clamp(12px, 2vh, 24px);
  z-index: 3;
  width: clamp(56px, 7vw, 76px);
  height: clamp(56px, 7vw, 76px);
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(15, 92, 153, 0.32);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(8, 30, 52, 0.18);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 160ms ease, transform 160ms ease;
}

.im-next svg {
  width: 52%;
  height: 52%;
}

.im-next:hover,
.im-next:focus-visible {
  opacity: 1;
}

.im-next:active {
  transform: scale(0.92);
}

/* Tela cheia: o vídeo ocupa a tela inteira; sem título, sem "Mostrar" e sem cantos (toque no personagem mostra). */
body.training-fullscreen .choices.im-workspace {
  position: fixed;
  inset: 0;
  z-index: 1;
  max-width: none;
  margin: 0;
  padding: 0;
}

body.training-fullscreen .im-page {
  height: 100dvh;
  display: block;
  padding: 0;
  border-radius: 0;
  background: #ffffff;
}

body.training-fullscreen .im-title,
body.training-fullscreen .im-show {
  display: none;
}

body.training-fullscreen .im-stage {
  position: absolute;
  inset: 0;
}

body.training-fullscreen .im-stage video {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  object-fit: cover;
}

body.training-fullscreen .im-page.is-playing .im-stage video {
  transform: none;
  box-shadow: none;
}

/* Tocando em tela cheia: moldura amarela por dentro da tela. */
body.training-fullscreen .im-glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 0 8px #ffd23f;
  opacity: 0;
  transition: opacity 200ms ease;
}

body.training-fullscreen .im-page.is-playing .im-glow {
  opacity: 1;
}

body.training-fullscreen .im-next {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
}

/* Botão verde da barra lateral: pareamento auditivo-visual (Imitação Orofacial). */
.im-match-toggle {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-radius: 14px;
  background: #22a55b;
  color: #ffffff;
  font: inherit;
  font-weight: 900;
  line-height: 1.15;
  box-shadow: 0 4px 0 #17803f;
  cursor: pointer;
}
.im-match-toggle.is-on { background: #7b5cd6; box-shadow: 0 4px 0 #5a3fb0; }
.im-match-toggle:active { transform: translateY(2px); box-shadow: 0 2px 0 #17803f; }

/* Atividade: cartão branco com borda preta (como a Letra que Falta); vídeo menor em cima, opções embaixo. */
body[data-design] .im-page.im-match {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  place-items: stretch;
  padding: clamp(8px, 1.6vh, 16px);
}
.im-match-card {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1.25fr) minmax(0, 1fr);
  border: 4px solid #111111;
  border-radius: 22px;
  background: #ffffff;
  overflow: hidden;
}
.im-match-top {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(8px, 1.6vh, 16px);
  border-bottom: 4px solid #111111;
}
.im-match-video {
  width: 100%;
  height: 100%;
}
.im-match-video video {
  border-radius: 18px;
  background: #ffffff;
}
.im-page.im-match.is-playing .im-match-video video { box-shadow: 0 0 0 5px #ffd23f; transform: none; }
.im-match-replay {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(15, 92, 153, 0.85);
  font-size: 1.3rem;
  pointer-events: none;
}
.im-match-score {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 2;
  display: flex;
  gap: 8px;
  font-weight: 900;
}
.im-match-score b, .im-match-score i {
  padding: 3px 10px;
  border-radius: 999px;
  font-style: normal;
  font-size: 0.95rem;
}
.im-match-score b { background: #e6f7ee; color: #17803f; }
.im-match-score i { background: #fdecec; color: #b42323; }
.im-match-options {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  container-type: size;
}
.im-match-option {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5%;
  padding: 4% 4%;
  overflow: hidden;
  border: 0;
  border-left: 4px solid #111111;
  background: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s ease;
}
.im-match-option:first-child { border-left: 0; }
/* Boca e letra sempre cabem no quadro: tamanho pela altura e pela largura de cada opção. */
.im-match-option img {
  width: min(62cqh, calc(100cqw / var(--n) * 0.52));
  height: auto;
  aspect-ratio: 1;
  flex: none;
  object-fit: cover;
  border-radius: 16%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}
.im-match-option b {
  flex: none;
  color: #111111;
  font: 900 min(44cqh, calc(100cqw / var(--n) * 0.26)) / 1 "Arial Black", "Nunito", system-ui, sans-serif;
}
.im-match-option:active { background: #f3f6fa; }
.im-match-option.is-right { background: #e6f7ee; box-shadow: inset 0 0 0 6px #2fb36f; }
.im-match-option.is-right b { color: #17803f; }
.im-match-option.is-wrong { animation: im-match-wrong 0.45s ease; filter: grayscale(1); opacity: 0.45; }
@keyframes im-match-wrong {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
body.training-fullscreen .im-page.im-match { background: #ffffff; padding: 12px; }
body.training-fullscreen:not(.controls-hidden) .im-page.im-match { padding-top: 70px; }
/* Tela cheia do pareamento: o vídeo fica inteiro dentro da parte de cima do cartão (não cobre a tela). */
body.training-fullscreen .im-page.im-match .im-stage {
  position: relative;
  inset: auto;
}
body.training-fullscreen .im-page.im-match .im-stage video {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  object-fit: contain;
}
body.training-fullscreen .im-page.im-match.is-playing .im-match-video video { box-shadow: 0 0 0 5px #ffd23f; }
