/* ==========================================================================
   Most Frequent Words — стили страницы частотного словаря
   ========================================================================== */

/* ---------- Таблица частотных слов ---------- */
.frequency-table-wrap {
  margin: 2rem 0 1rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.frequency-table {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.frequency-row {
  display: grid;
  grid-template-columns: 60px 1.1fr 1fr 2fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease, transform 0.2s ease;
  position: relative;
}

.frequency-row:last-child {
  border-bottom: none;
}

.frequency-row:hover {
  background: var(--bg-secondary);
}

.frequency-row--head {
  background: var(--bg-tertiary);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
  z-index: 5;
}

.frequency-row--head:hover {
  background: var(--bg-tertiary);
}

.freq-cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.freq-cell--num {
  align-items: center;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.freq-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  font-size: 0.8rem;
}

/* ---------- Слово + транскрипция + кнопка ---------- */
.freq-cell--word {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.freq-cell--word .word-english {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-color);
  flex: none;
}

.word-transcription {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  white-space: nowrap;
}

/* Кнопка озвучки внутри строки */
.frequency-row .pronounce-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  margin-left: auto;
}

/* ---------- Перевод ---------- */
.freq-cell--translation .word-russian {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ---------- Пример ---------- */
.freq-cell--example .example-en {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.3;
}

.freq-cell--example .example-ru {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ---------- Пагинация ---------- */
.mfw-pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin: 1.5rem 0 2rem;
  padding: 0.5rem 0;
}

.mfw-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  user-select: none;
}

.mfw-page-btn:hover {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
  transform: translateY(-2px);
}

.mfw-page-btn.is-active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
  cursor: default;
}

.mfw-page-btn[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.mfw-page-btn--arrow {
  font-weight: 700;
  min-width: 80px;
}

.mfw-page-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 40px;
  color: var(--text-secondary);
  font-weight: 700;
  user-select: none;
}

.mfw-pagination--bottom {
  margin-top: 2rem;
}

/* Активная строка */
.frequency-row.is-active {
  background: var(--help-hover-color);
  box-shadow: inset 3px 0 0 var(--primary-color);
}

/* Тост */
.mfw-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.7rem 1.2rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 2000;
  max-width: 90vw;
  text-align: center;
}

.mfw-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Анимация появления строк ---------- */
@media (prefers-reduced-motion: no-preference) {
  .frequency-row {
    opacity: 0;
    transform: translateY(8px);
    animation: mfwRowIn 0.35s ease forwards;
  }

  @keyframes mfwRowIn {
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Лёгкая задержка для «каскада» */
  .frequency-row:nth-child(2) {
    animation-delay: 0.02s;
  }

  .frequency-row:nth-child(3) {
    animation-delay: 0.04s;
  }

  .frequency-row:nth-child(4) {
    animation-delay: 0.06s;
  }

  .frequency-row:nth-child(5) {
    animation-delay: 0.08s;
  }

  .frequency-row:nth-child(6) {
    animation-delay: 0.10s;
  }

  .frequency-row:nth-child(7) {
    animation-delay: 0.12s;
  }

  .frequency-row:nth-child(8) {
    animation-delay: 0.14s;
  }

  .frequency-row:nth-child(9) {
    animation-delay: 0.16s;
  }

  .frequency-row:nth-child(10) {
    animation-delay: 0.18s;
  }
}

/* ---------- Адаптив: планшеты ---------- */
@media (max-width: 968px) {
  .frequency-row {
    grid-template-columns: 50px 1fr 1fr;
    grid-template-areas:
      "num word trans"
      "num example example";
    align-items: start;
    padding: 0.85rem 1rem;
    row-gap: 0.35rem;
  }

  .freq-cell--num {
    grid-area: num;
  }

  .freq-cell--word {
    grid-area: word;
  }

  .freq-cell--translation {
    grid-area: trans;
  }

  .freq-cell--example {
    grid-area: example;
  }

  .frequency-row--head {
    display: none;
  }

  .freq-cell--example .example-en {
    font-size: 0.85rem;
  }

  .freq-cell--example .example-ru {
    font-size: 0.78rem;
  }
}

/* ---------- Адаптив: телефоны ---------- */
@media (max-width: 600px) {
  .frequency-table-wrap {
    border-radius: var(--radius-md);
    margin: 1.25rem 0 1rem;
  }

  .frequency-row {
    grid-template-columns: 40px 1fr;
    grid-template-areas:
      "num word"
      "num trans"
      "num example";
    padding: 0.8rem 0.9rem;
    row-gap: 0.4rem;
  }

  .freq-num {
    min-width: 24px;
    height: 24px;
    font-size: 0.72rem;
  }

  .freq-cell--word .word-english {
    font-size: 1rem;
  }

  .word-transcription {
    font-size: 0.78rem;
  }

  .freq-cell--translation .word-russian {
    font-size: 0.9rem;
  }

  .frequency-row .pronounce-btn {
    width: 30px;
    height: 30px;
  }

  .mfw-page-btn {
    min-width: 36px;
    height: 36px;
    font-size: 0.85rem;
    padding: 0 0.5rem;
  }

  .mfw-page-btn--arrow {
    min-width: 64px;
  }
}

/* ---------- Печать ---------- */
@media print {

  .mfw-pagination,
  .pronounce-btn,
  .ad-container,
  .cta-section {
    display: none !important;
  }

  .frequency-row {
    break-inside: avoid;
    border-color: #ccc !important;
  }
}