/* ============================================================
   TAJWEED.CSS — Стили таджвида, легенда, ошибки загрузки
   Проект «Икра» · v413 (без)
   Порядок правил сохранён 1:1 с исходным <style>.
   ============================================================ */

/* === D1.1: канонический tajweed-span === */
span[class*="tajweed-"] {
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: inherit;
}

/* === D1.3 v383: канонический — без -webkit-text-fill-color === */
span[class^="tajweed-"] {
  display: inline;
  white-space: normal;
  font-weight: 500;
  line-height: 2;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === TAJWEED: БАЗОВЫЕ СТИЛИ (цвета правил) === */
/* D1 v383: дубликат span[class^="tajweed-"] удалён, канон выше */

.tajweed-madda_normal { color: #2554C7; }
.tajweed-madda_permissible { color: #3040E0; }
.tajweed-madda_obligatory { color: #2144C1; }
.tajweed-madda_necessary { color: #000EBC; }
.tajweed-qalqalah { color: #C80008; }
.tajweed-ghunnah { color: #C24D00; }
.tajweed-ikhfa { color: #8A009E; }
.tajweed-ikhfa_shafawi { color: #A8008C; }
.tajweed-idghaam_ghunnah { color: #0D785E; }
.tajweed-idghaam_no_ghunnah { color: #117A00; }
.tajweed-idghaam_shafawi { color: #367500; }
.tajweed-idghaam_mutajanisayn, .tajweed-idghaam_mutaqaribayn { color: #666666; }
.tajweed-iqlab { color: #0270B0; }
.tajweed-tafkhim { color: #1E3A8A; }

/* ДОБАВЛЕНО: Отсутствующие цвета для серых букв (теперь они видны) */
.tajweed-ham_wasl, .tajweed-laam_shamsiyah, .tajweed-silent { color: var(--tajweed-silent); }

/* Сохранение арабского соединения (shaping) */
.tajweed-span {
  display: inline;
  white-space: normal;
  font-weight: 500;
  line-height: 2;
}

/* Блок правил под аятом */
.ayah-tajweed-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(212,175,55,.3);
  font-size: 12px;
  font-weight: 600;
}
.ayah-tajweed-rules .rule-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ayah-tajweed-rules .rule-item i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* === TAJWEED: Легенда и правила === */
.tajweed-legend {
  background: var(--card);
  border: 1px solid var(--gold-accent);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}
.tajweed-legend .tl-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.tajweed-legend .tl-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.tajweed-legend .tl-item {
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
.tajweed-legend .tl-item i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.ayah-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(212,175,55,.3);
}
.ayah-rule {
  font-size: 12px;
  font-weight: 600;
  background: rgba(var(--accent-rgb), .08);
  padding: 2px 8px;
  border-radius: 6px;
}

/* === TAJWEED: Загрузка / Ошибка === */
.tajweed-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--card); border: 1px dashed var(--gold-accent);
  border-radius: 12px; font-size: 12px; color: var(--muted);
}
.tajweed-loading::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--gold-accent); border-top-color: transparent;
  animation: tj-spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes tj-spin { to { transform: rotate(360deg); } }

.tajweed-error {
  display: block;
  padding: 10px 14px; margin-bottom: 12px;
  background: rgba(201,106,90,.1); border: 1px solid rgba(201,106,90,.35);
  border-radius: 12px; font-size: 12px; color: var(--muted); line-height: 1.5;
}
.tajweed-error a { color: var(--gold-accent); text-decoration: underline; cursor: pointer; }


/* ============================================================
   IQRA V412 — КОНТРАСТ ТАДЖВИДА В ТЁМНОЙ И МОНО ТЕМАХ
   Цвета правил остаются различимыми; формы букв и shaping не меняются.
   ============================================================ */
[data-theme="dark"] .tajweed-madda_normal,
[data-theme="mono"] .tajweed-madda_normal { color: #A9C4FF; }
[data-theme="dark"] .tajweed-madda_permissible,
[data-theme="mono"] .tajweed-madda_permissible { color: #90A4FF; }
[data-theme="dark"] .tajweed-madda_obligatory,
[data-theme="mono"] .tajweed-madda_obligatory { color: #7B8DFF; }
[data-theme="dark"] .tajweed-madda_necessary,
[data-theme="mono"] .tajweed-madda_necessary { color: #6676FF; }
[data-theme="dark"] .tajweed-qalqalah,
[data-theme="mono"] .tajweed-qalqalah { color: #FF8589; }
[data-theme="dark"] .tajweed-ghunnah,
[data-theme="mono"] .tajweed-ghunnah { color: #FFB47D; }
[data-theme="dark"] .tajweed-ikhfa,
[data-theme="mono"] .tajweed-ikhfa { color: #DDA8F2; }
[data-theme="dark"] .tajweed-ikhfa_shafawi,
[data-theme="mono"] .tajweed-ikhfa_shafawi { color: #FF8AE6; }
[data-theme="dark"] .tajweed-idghaam_ghunnah,
[data-theme="mono"] .tajweed-idghaam_ghunnah { color: #70D7B7; }
[data-theme="dark"] .tajweed-idghaam_no_ghunnah,
[data-theme="mono"] .tajweed-idghaam_no_ghunnah { color: #9AD978; }
[data-theme="dark"] .tajweed-idghaam_shafawi,
[data-theme="mono"] .tajweed-idghaam_shafawi { color: #B8DF7E; }
[data-theme="dark"] .tajweed-idghaam_mutajanisayn,
[data-theme="dark"] .tajweed-idghaam_mutaqaribayn,
[data-theme="mono"] .tajweed-idghaam_mutajanisayn,
[data-theme="mono"] .tajweed-idghaam_mutaqaribayn { color: #C4C4C4; }
[data-theme="dark"] .tajweed-iqlab,
[data-theme="mono"] .tajweed-iqlab { color: #83D9F5; }
[data-theme="dark"] .tajweed-tafkhim,
[data-theme="mono"] .tajweed-tafkhim { color: #91AEFF; }
[data-theme="dark"] .tajweed-ham_wasl,
[data-theme="dark"] .tajweed-laam_shamsiyah,
[data-theme="dark"] .tajweed-silent,
[data-theme="mono"] .tajweed-ham_wasl,
[data-theme="mono"] .tajweed-laam_shamsiyah,
[data-theme="mono"] .tajweed-silent { color: var(--tajweed-silent); }

[data-theme="dark"] span[class*="tajweed-"],
[data-theme="mono"] span[class*="tajweed-"] {
  text-shadow: inherit;
  font-weight: 500;
}


/* ============================================================
   IQRA V415 — ВИДИМОСТЬ ПРАВИЛ В РЕЖИМЕ ЧТЕНИЯ
   Класс .has-tajweed ставит api.js, когда правила реально отрисованы.
   Нейтральная основа + без золотого свечения на буквах: цвета правил
   читаются чисто, а нетронутые буквы не спорят с оранжевым и лаймовым.
   Если таджвид не загрузился, класс снимается и текст остаётся золотым.
   ============================================================ */
.read-ayah-ar.has-tajweed { color: var(--tajweed-base); -webkit-text-fill-color: currentColor; background: none; text-shadow: none; }
.read-ayah-ar.has-tajweed span[class*="tajweed-"] { -webkit-text-fill-color: currentColor; text-shadow: none; }

/* Точки легенды под аятом берут цвет правила из темы, а не из JSON. */
.ayah-tajweed-rules .rule-item i[class*="tajweed-"] { background: currentColor; }


/* ============================================================
   IQRA V416 — СПРАВКА ПО ТАДЖВИДУ (сворачиваемая, цвета из тем)
   ============================================================ */
details.tajweed-legend > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
details.tajweed-legend > summary::-webkit-details-marker { display: none; }
details.tajweed-legend > summary::after {
  content: ""; flex: none; width: 8px; height: 8px;
  border-right: 2px solid var(--gold-accent); border-bottom: 2px solid var(--gold-accent);
  transform: rotate(45deg); transition: transform var(--dur-base) var(--ease-out);
}
details.tajweed-legend[open] > summary::after { transform: rotate(225deg); }
details.tajweed-legend .tl-title { margin-bottom: 0; }
details.tajweed-legend[open] .tl-title { margin-bottom: 0; }
details.tajweed-legend .tl-items { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 12px; }
.tajweed-legend .tl-item { align-items: flex-start; line-height: 1.4; }
.tajweed-legend .tl-item i { flex: none; margin-top: 4px; }
.tajweed-legend .tl-item i[class*="tajweed-"] { background: currentColor; }
.tajweed-legend .tl-note { margin-top: 12px; font-size: 11px; line-height: 1.5; color: var(--muted); }
