/* 1. Подключаем EB Garamond для цифр */
@font-face {
  font-family: 'EBGaramondNumbers';
  src: url('https://fonts.gstatic.com/s/ebgaramond/v27/SlGDmQSNjdsmc35JDF1K5E55YMjF_7DPuGi-6_RkBI96k2WpQ.woff2') format('woff2');
  unicode-range: U+0030-0039;
  font-display: swap;
}

/* 2. Ядерное решение для цифр */
body * {
  font-variant-numeric: lining-nums !important;
  font-feature-settings: 'lnum' !important;
}

/* 3. Атомные стили для всех возможных случаев */
.t-card *,
.t-item *,
.t-product *,
.t-store__product *,
.t-descr *,
.t-text__descr *,
.t-richtext *,
.t-title__descr *,
[class*="card"],
[class*="product"],
[class*="item"],
[class*="description"],
[class*="descr"],
[class*="text"],
[class*="title"] {
  font-family: 'EBGaramondNumbers', 'Cormorant', serif !important;
}

/* 4. JavaScript-инъекция для сложных случаев */

document.addEventListener('DOMContentLoaded', function() {
  // Функция для обработки цифр
  function processNumbers(element) {
    const walker = document.createTreeWalker(
      element,
      NodeFilter.SHOW_TEXT,
      null,
      false
    );
    
    let node;
    while (node = walker.nextNode()) {
      if (/\d/.test(node.nodeValue)) {
        const wrapper = document.createElement('span');
        wrapper.className = 'force-ebgaramond';
        wrapper.style.fontFamily = 'EBGaramondNumbers, serif !important';
        wrapper.style.fontFeatureSettings = 'lnum !important';
        wrapper.style.fontVariantNumeric = 'lining-nums !important';
        node.parentNode.replaceChild(wrapper, node);
        wrapper.appendChild(node);
      }
    }
  }

  // Обрабатываем весь документ
  processNumbers(document.body);

  // Следим за изменениями (для динамического контента)
  new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
      mutation.addedNodes.forEach(function(node) {
        if (node.nodeType === 1) {
          processNumbers(node);
        }
      });
    });
  }).observe(document.body, {
    childList: true,
    subtree: true
  });
});


/* 5. Экстренные меры */

.force-ebgaramond,
[class*="t-"] span:not([style*="font-family"]),
[class*="card"] span,
[class*="product"] span {
  font-family: 'EBGaramondNumbers', serif !important;
  font-feature-settings: 'lnum' !important;
  font-variant-numeric: lining-nums !important;
}





