/* ==========================================================================
   quran-modal.css — Модальные окна и попапы
   1) Попап слова (absolute, рядом с кликнутым словом): корень, значение, POS
   2) Попап «Поделиться» (центрированный модал с опциями)
   ========================================================================== */

/* ==========================================================================
   Попап слова (word popup)
   ========================================================================== */

.quran-word-popup {
  position: absolute;
  z-index: var(--z-tooltip);
  min-width: 200px;
  max-width: 280px;
  background: var(--quran-bg);
  border: 1px solid var(--quran-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--transition-fast) ease,
              transform var(--transition-fast) ease;
}

.quran-word-popup.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* --- Стрелка попапа (вверх) --- */
.quran-word-popup::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--quran-bg);
  border-inline-start: 1px solid var(--quran-border);
  border-top: 1px solid var(--quran-border);
}

/* --- Стрелка вниз (если попап над словом) --- */
.quran-word-popup.above::before {
  top: auto;
  bottom: -6px;
  border-inline-start: none;
  border-top: none;
  border-inline-end: 1px solid var(--quran-border);
  border-bottom: 1px solid var(--quran-border);
}

/* --- Кнопка закрытия попапа --- */
.quran-word-popup__close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--medium-gray);
  cursor: pointer;
  border-radius: 4px;
  transition: background var(--transition-fast) ease;
}

.quran-word-popup__close:hover {
  background: var(--quran-highlight);
}

.quran-word-popup__close svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

/* --- Арабское слово в попапе --- */
.quran-word-popup__word {
  font-family: var(--font-arabic);
  font-size: 1.5rem;
  color: var(--quran-arabic);
  direction: rtl;
  text-align: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--quran-border);
  margin-bottom: 8px;
}

/* --- Строка данных (корень, POS, перевод) --- */
.quran-word-popup__row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
}

.quran-word-popup__label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--medium-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  min-width: 50px;
}

.quran-word-popup__value {
  font-size: 0.8125rem;
  color: var(--quran-text);
}

/* --- Корень (арабский) --- */
.quran-word-popup__root {
  font-family: var(--font-arabic);
  font-size: 1.125rem;
  color: var(--emerald);
  direction: rtl;
}

/* --- Часть речи (POS tag) --- */
.quran-word-popup__pos {
  display: inline-block;
  padding: 1px 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--info);
  background: rgba(59, 130, 246, 0.08);
  border-radius: 4px;
}

/* --- Ссылка на Муджам --- */
.quran-word-popup-mujam {
  display: block;
  margin-top: 8px;
  padding: 5px 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--emerald);
  text-decoration: none;
  text-align: center;
  border-top: 1px dashed var(--quran-border, #e5e7eb);
}
.quran-word-popup-mujam:hover { color: var(--emerald-dark); text-decoration: underline; }

.quran-mufradat-mujam {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--emerald);
  text-decoration: none;
}
.quran-mufradat-mujam:hover { text-decoration: underline; }

/* --- Морфология (дополнительно) --- */
.quran-word-popup__morphology {
  font-size: 0.75rem;
  color: var(--medium-gray);
  line-height: 1.5;
  padding-top: 6px;
  border-top: 1px dashed var(--quran-border);
  margin-top: 6px;
}

/* ==========================================================================
   Попап «Поделиться» — реальные классы из HTML
   ========================================================================== */

/* ==========================================================================
   Inline share dropdown (рядом с кнопкой)
   ========================================================================== */

.quran-share-wrapper {
  position: relative;
  display: inline-flex;
}

/* Десктоп: горизонтальный ряд кнопок, поверх контента */
.quran-share-dropdown {
  position: fixed;
  z-index: 500;
  display: flex;
  flex-direction: row;
  gap: 4px;
  background: var(--quran-bg, #fff);
  border: 1.5px solid #86efac;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 5px 8px;
  white-space: nowrap;
}

.quran-share-dropdown button {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--quran-text, #333);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.quran-share-dropdown button:hover {
  background: color-mix(in srgb, var(--emerald) 8%, transparent);
  color: var(--emerald, #059669);
}

/* Мобильный: вертикальный список */
@media (max-width: 767px) {
  .quran-share-dropdown {
    flex-direction: column;
    min-width: 180px;
  }
}

/* Ночной режим */
.night-mode .quran-share-dropdown {
  background: #1a1a2e;
  border-color: var(--emerald-dark, #065f46);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.night-mode .quran-share-dropdown button {
  color: #d1d5db;
}

.night-mode .quran-share-dropdown button:hover {
  background: color-mix(in srgb, var(--emerald) 15%, transparent);
  color: var(--emerald-light, #6ee7b7);
}

/* ==========================================================================
   Toast-уведомление (копирование)
   ========================================================================== */

.quran-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--emerald-dark, #065f46);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.quran-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Попап «Поделиться» — старые BEM-классы (legacy)
   ========================================================================== */

/* --- Оверлей --- */
.quran-share-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal) ease;
}

.quran-share-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* --- Модальное окно --- */
.quran-share-modal {
  background: var(--quran-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 90%;
  max-width: 400px;
  padding: 24px;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-normal) ease;
}

.quran-share-overlay.active .quran-share-modal {
  transform: scale(1) translateY(0);
}

/* --- Заголовок модала --- */
.quran-share-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.quran-share-modal__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--quran-text);
}

.quran-share-modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--medium-gray);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast) ease;
}

.quran-share-modal__close:hover {
  background: var(--quran-highlight);
}

.quran-share-modal__close svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* --- Превью аята для шаринга --- */
.quran-share-modal__preview {
  padding: 16px;
  background: var(--light-gray);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  text-align: center;
}

.quran-share-modal__preview-arabic {
  font-family: var(--font-arabic);
  font-size: 1.25rem;
  line-height: 2;
  color: var(--quran-arabic);
  direction: rtl;
  margin-bottom: 8px;
}

.quran-share-modal__preview-ref {
  font-size: 0.75rem;
  color: var(--medium-gray);
}

/* --- Опции поделиться --- */
.quran-share-modal__options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.quran-share-modal__option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--quran-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--quran-text);
  cursor: pointer;
  transition: background var(--transition-fast) ease,
              border-color var(--transition-fast) ease;
}

.quran-share-modal__option:hover {
  background: var(--quran-highlight);
  border-color: var(--emerald);
}

.quran-share-modal__option svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.quran-share-modal__option-label {
  font-size: 0.6875rem;
  font-weight: 500;
}

/* --- Кнопка «Копировать ссылку» --- */
.quran-share-modal__copy-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--quran-border);
  border-radius: var(--radius-sm);
  background: var(--light-gray);
  cursor: pointer;
  transition: background var(--transition-fast) ease;
}

.quran-share-modal__copy-link:hover {
  background: var(--quran-highlight);
}

.quran-share-modal__copy-link-text {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--medium-gray);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: start;
}

.quran-share-modal__copy-link-btn {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--emerald);
  white-space: nowrap;
}

/* --- Состояние «Скопировано» --- */
.quran-share-modal__copy-link.copied {
  border-color: var(--emerald);
}

.quran-share-modal__copy-link.copied .quran-share-modal__copy-link-btn {
  color: var(--success);
}

/* ==========================================================================
   Ночной режим
   ========================================================================== */

.night-mode .quran-word-popup {
  background: #1e1e30;
  border-color: var(--quran-border);
}

.night-mode .quran-word-popup::before {
  background: #1e1e30;
  border-color: var(--quran-border);
}

.night-mode .quran-share-modal {
  background: #1e1e30;
}

.night-mode .quran-share-modal__preview {
  background: rgba(255, 255, 255, 0.05);
}

.night-mode .quran-share-modal__copy-link {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--quran-border);
}

.night-mode .quran-share-modal__option {
  border-color: var(--quran-border);
}
