/* Смешанная таблица умножения и деления.
   Все селекторы под .app--table-mix, чтобы не задеть другие тренажёры.
   Вид близкий к отдельным таблицам: вкладки, пилюли «На N», крупный пример. */

.app--table-mix {
  --tmid-mul: #e07b39;
  --tmid-mul-bg: #fff3e0;
  --tmid-div: #2563eb;
  position: relative;
  max-width: 48rem;
  width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
  padding: var(--space-3) max(var(--space-3), env(safe-area-inset-left, 0px))
    max(var(--space-4), env(safe-area-inset-bottom, 0px));
}

.app--table-mix[hidden],
.app--table-mix [hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  .app--table-mix {
    padding: var(--space-4) max(var(--space-4), env(safe-area-inset-left, 0px)) var(--space-6);
    border-radius: var(--trainer-radius-card, var(--radius-2xl));
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--trainer-shadow-card, var(--shadow-sm));
  }

  .tmid-topbar {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
  }

  .tmid-table-scroll {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .tmid-table-scroll-btn {
    display: none !important;
  }
}

.tmid-topbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.tmid-tabs {
  display: flex;
  gap: var(--space-2);
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  padding: var(--space-1);
  border-radius: var(--radius-full);
  background: var(--surface-offset);
  box-sizing: border-box;
}

.tmid-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-muted);
}

.tmid-tab.active {
  background: var(--primary);
  color: var(--text-inv);
}

.tmid-table-picker {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.tmid-table-scroll {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: var(--space-2);
  overflow-x: auto;
  padding-block-end: var(--space-1);
  scrollbar-width: none;
}

.tmid-table-scroll::-webkit-scrollbar {
  display: none;
}

.tmid-table-scroll-btn {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 800;
}

.tmid-table-btn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
}

.tmid-table-btn--all {
  font-weight: 800;
}

.tmid-table-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inv);
}

@media (hover: hover) and (pointer: fine) {
  .tmid-table-btn:hover:not(.active) {
    border-color: var(--primary);
    background: var(--primary-bg);
  }
}

.tmid-question-card {
  position: relative;
  overflow: hidden;
  margin-bottom: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--trainer-radius-card, var(--radius-2xl));
  background: var(--surface);
  box-shadow: var(--trainer-shadow-card, var(--shadow-sm));
  text-align: center;
}

.tmid-equation {
  max-width: none;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, var(--text-3xl));
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

.tmid-equation-answer--ok {
  color: var(--success);
}

.tmid-equation-answer--pulse {
  color: var(--success);
  display: inline-block;
}

.tmid-hint-row {
  display: flex;
  margin-bottom: var(--space-2);
}

.tmid-hint-btn,
.tmid-next-btn,
.tmid-quiz-skip,
.tmid-quiz-next {
  width: auto;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: 2px solid var(--primary);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--primary);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
}

.tmid-hint-btn--pulse {
  animation: tmid-hint-pulse 1.2s ease-in-out infinite;
}

@keyframes tmid-hint-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.tmid-hint-panel {
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--tmid-mul) 25%, transparent);
  border-radius: var(--radius-xl);
  background: var(--tmid-mul-bg);
}

.tmid-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.tmid-dot-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 120px;
  padding: var(--space-2);
  border: 1px dashed color-mix(in srgb, var(--tmid-mul) 35%, transparent);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.tmid-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--tmid-mul);
}

.tmid-hint-text {
  max-width: none;
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
}

.tmid-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  width: 100%;
  max-width: 26rem;
  margin: 0 auto var(--space-2);
}

.tmid-opt {
  min-height: 64px;
  padding: var(--space-4) var(--space-3);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
}

.tmid-opt.wrong-ans {
  border-color: var(--error);
  background: var(--error-bg);
  color: var(--error);
}

.tmid-opt.correct-ans {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.tmid-opt.quiz-opt-shake {
  animation: tmid-shake 0.4s ease;
}

.tmid-answer-row {
  display: flex;
  gap: var(--space-2);
  max-width: 26rem;
  margin: 0 auto var(--space-2);
}

.tmid-answer-input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: center;
}

.tmid-answer-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.tmid-answer-input--ok {
  border-color: var(--success);
  color: var(--success);
}

.tmid-answer-input--wrong {
  border-color: var(--error);
  color: var(--error);
  animation: tmid-shake 0.35s ease;
}

@keyframes tmid-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.tmid-check-btn,
.tmid-start-btn,
.tmid-action-btn--primary {
  width: auto;
  min-height: 56px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--primary);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--text-inv);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
}

.tmid-check-btn:disabled,
.tmid-quiz-next:disabled {
  opacity: 0.55;
}

.tmid-quiz-actions,
.tmid-block-done__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.tmid-next-btn {
  align-self: center;
  margin-top: var(--space-2);
}

.tmid-quiz-idle:not([hidden]),
.tmid-block-done:not([hidden]),
.tmid-summary:not([hidden]),
.tmid-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.tmid-quiz-idle:not([hidden]),
.tmid-block-done:not([hidden]),
.tmid-summary:not([hidden]) {
  align-items: center;
  margin-top: var(--space-2);
}

.tmid-block-done__text,
.tmid-summary__title {
  max-width: none;
  margin: 0 0 var(--space-3);
  text-align: center;
}

.tmid-summary {
  width: 100%;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--surface);
  box-sizing: border-box;
}

.tmid-summary .check-stats {
  margin-bottom: var(--space-4);
}

.app--table-mix .tmid-feedback,
.app--table-mix .feedback-area {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  margin: 0 0 var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.app--table-mix .tmid-feedback.empty,
.app--table-mix .feedback-area.empty {
  min-height: 0;
  margin: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
}

.app--table-mix .tmid-feedback.success,
.app--table-mix .feedback-area.success {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.app--table-mix .tmid-feedback.error,
.app--table-mix .feedback-area.error {
  border-color: var(--error);
  background: var(--error-bg);
  color: var(--error);
}

.app--table-mix .tmid-feedback.neutral,
.app--table-mix .feedback-area.neutral {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}

/* Общий фейерверк TrainerCommon. Без этих правил кусочки .cp остаются
   обычными блоками и растягивают карточку: styles-chasiki.css на странице нет. */
.app--table-mix .trainer-quiz-confetti {
  position: absolute;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.app--table-mix .trainer-quiz-confetti .cp {
  position: absolute;
  top: -12px;
  border-radius: 2px;
  animation-name: tmid-confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes tmid-confetti-fall {
  to {
    transform: translateY(110vh) rotate(480deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tmid-hint-btn--pulse,
  .tmid-opt.quiz-opt-shake,
  .tmid-answer-input--wrong {
    animation: none;
  }

  .app--table-mix .trainer-quiz-confetti {
    display: none;
  }
}

/* Блок «потренировать отдельно» стоит под тренажёром, не внутри карточки. */
.tmid-separate {
  display: grid;
  gap: var(--space-4);
}

.tmid-separate > h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.25;
}

.tmid-separate__grid {
  display: grid;
  gap: var(--space-4);
}

@media (min-width: 720px) {
  .tmid-separate__grid {
    grid-template-columns: 1fr 1fr;
  }
}

.tmid-separate__card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--tmid-card, var(--primary)) 22%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tmid-card, var(--primary)) 8%, var(--surface));
}

.tmid-separate__card--mul {
  --tmid-card: #e07b39;
}

.tmid-separate__card--div {
  --tmid-card: #2563eb;
}

.tmid-separate__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.tmid-separate__text {
  max-width: none;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.tmid-separate__link {
  width: fit-content;
  max-width: 100%;
  margin-top: 0.35rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--tmid-card, var(--primary));
  border-radius: 999px;
  background: var(--surface);
  color: var(--tmid-card, var(--primary));
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
}

.tmid-separate__link:hover {
  background: color-mix(in srgb, var(--tmid-card, var(--primary)) 8%, var(--surface));
  color: var(--tmid-card, var(--primary));
}
