/* Личный словарь: попап перевода слова, страница словаря, флеш-карты, письмо иероглифов. */

/* --- Попап перевода слова (тап по слову в тексте урока) --- */
.l2g-word-pop {
  position: fixed;
  z-index: 70;
  max-width: calc(100vw - 20px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .18);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.l2g-word-pop-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.l2g-word-pop-head > div { min-width: 0; overflow-wrap: anywhere; }
.l2g-word-pop-word { font-size: 18px; }
.l2g-word-pop-pinyin { display: block; color: var(--text-soft); }
.l2g-word-pop-translation { color: var(--text); line-height: 1.4; overflow-wrap: anywhere; min-height: 20px; }
.l2g-word-pop-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.l2g-spin { animation: l2g-spin 1s linear infinite; }
@keyframes l2g-spin { to { transform: rotate(360deg); } }

/* --- Страница словаря --- */
.dict-panel { display: grid; gap: 4px; padding: 8px 20px 20px; }
.dict-course { padding: 14px 0; border-bottom: 1px solid var(--line); }
.dict-course:last-child { border-bottom: 0; }
.dict-course > h3 { margin: 0 0 10px; font-size: 17px; }
.dict-lesson { margin: 0 0 14px; }
.dict-lesson:last-child { margin-bottom: 0; }
.dict-lesson > h4 { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .02em; }
.dict-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.dict-row:last-child { border-bottom: 0; }
.dict-row-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; min-width: 0; }
.dict-row-body strong { overflow-wrap: anywhere; }
.dict-row-body span { color: var(--text-soft); overflow-wrap: anywhere; }
.dict-pinyin { color: var(--primary); }
.dict-materials { margin-top: 16px; }
.dict-materials summary { cursor: pointer; padding: 14px 20px; font-weight: 700; }

@media (max-width: 480px) {
  .dict-row { grid-template-columns: auto 1fr auto; }
  .dict-row-body { grid-column: 2; }
}

/* --- Флеш-карты (повторение слов) --- */
.dict-flash { max-width: 420px; margin: 0 auto; padding: 24px 16px; display: grid; gap: 16px; justify-items: center; text-align: center; }
.dict-flash-progress { color: var(--text-soft); font-weight: 700; }
.dict-flash-card { width: 100%; max-width: 340px; perspective: 1200px; cursor: pointer; }
.dict-flash-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }
.dict-flash-card-inner { position: relative; width: 100%; min-height: 220px; transition: transform .4s ease; transform-style: preserve-3d; }
.dict-flash-card.flipped .dict-flash-card-inner { transform: rotateY(180deg); }
.dict-flash-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  display: grid; gap: 12px; align-content: center; justify-items: center; padding: 24px;
}
.dict-flash-front strong { font-size: 30px; overflow-wrap: anywhere; }
.dict-flash-back { transform: rotateY(180deg); }
.dict-flash-back span { font-size: 19px; overflow-wrap: anywhere; }
.dict-flash-back small { color: var(--text-soft); font-size: 15px; }
.dict-flash-actions { display: flex; gap: 12px; }
.dict-flash-summary { text-align: center; padding: 48px 20px; display: grid; gap: 12px; justify-items: center; }
.dict-flash-summary i { width: 40px; height: 40px; color: var(--primary); }

/* --- Письмо иероглифов: карточки в уроке (блок "Прописи") --- */
.learn-hanzi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin: 12px 0; }
.learn-hanzi-card { display: grid; gap: 10px; justify-items: center; text-align: center; }
.learn-hanzi-target, .hanzi-modal-target {
  position: relative;
  width: 100%; max-width: 180px; aspect-ratio: 1 / 1; margin: 0 auto;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden;
}
.learn-hanzi-target::before, .hanzi-modal-target::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to bottom, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(45deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(-45deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px));
  opacity: .45;
  pointer-events: none;
}
.learn-hanzi-target svg, .hanzi-modal-target svg { position: relative; max-width: 100%; height: auto; display: block; }
.learn-hanzi-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* --- Модалка "Как пишется" --- */
.hanzi-modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px; }
.hanzi-modal-card { display: grid; gap: 10px; justify-items: center; text-align: center; }
.hanzi-modal-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

@media (max-width: 375px) {
  .learn-hanzi-grid, .hanzi-modal-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
