/* ============================================================
   article-content.css
   Універсальна стилізація rich-text контенту з TinyMCE.
   Будь-яка HTML-розмітка зі статті автоматично отримує охайний
   вигляд без ручного доопрацювання.

   Використання:
     <div class="article-content"><?= $article['content_ua'] ?></div>

   ⚠ Замінити старий клас .product-description на .article-content.
   Всі стилі — під єдиним префіксом .article-content, тому не
   протікають на решту сайту (див. проблему contact-form.css).
   ============================================================ */

/* Локальні токени: беруться з дизайн-системи сайту (styles.css),
   з фолбеком — щоб файл працював навіть якщо не всі змінні підключені. */
.article-content {
    --_accent:      var(--accent, #00c3ff);
    --_accent-dark: var(--accent-dark, #0092c4);
    --_ink:         var(--dark, #0b0c10);
    --_muted:       var(--muted, #5b6b7d);
    --_line:        #e6ebf2;
    --_bg-soft:     #f5f8fb;
    --_radius:      var(--radius, 14px);
    --_shadow:      var(--shadow, 0 5px 20px rgba(0, 0, 0, .06));

    /* Комфортна ширина рядка для читання (60–75 символів).
       Ширші елементи (img, table, iframe, blockquote) можуть
       виходити за межі через .article-content > * нижче. */
    /max-width: 72ch;
    margin-inline: auto;
    color: var(--_ink);
    font-size: clamp(17px, 1.05rem + .1vw, 19px);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-wrap: break-word;   /* довгі URL/слова не ламають сітку */
}

/* Прибираємо верхній відступ у першого і нижній — в останнього
   елемента, щоб контент не «відлипав» від заголовка та футера. */
.article-content > :first-child { margin-top: 0; }
.article-content > :last-child  { margin-bottom: 0; }

/* ---------- Абзаци та лід ---------- */
.article-content p {
    margin: 0 0 1.15em;
}
.article-content .lead,
.article-content > p:first-of-type {
    font-size: 1.12em;
    color: #33414f;
    line-height: 1.7;
}

/* ---------- Заголовки H2–H6 ----------
   H1 у контенті бути не повинно (єдиний H1 — назва статті),
   але на випадок помилки редактора стилізуємо і його як H2. */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    line-height: 1.25;
    font-weight: 800;
    color: var(--_ink);
    scroll-margin-top: calc(var(--header-height, 72px) + 20px); /* якір під фіксований хедер + для змісту */
}
.article-content h1,
.article-content h2 { font-size: clamp(24px, 3vw, 30px); margin: 1.8em 0 .6em; }
.article-content h3 { font-size: clamp(21px, 2.4vw, 25px); margin: 1.6em 0 .5em; }
.article-content h4 { font-size: clamp(19px, 2vw, 21px);   margin: 1.4em 0 .4em; }
.article-content h5 { font-size: 17px; margin: 1.3em 0 .35em; text-transform: uppercase; letter-spacing: .04em; color: var(--_muted); }
.article-content h6 { font-size: 15px; margin: 1.2em 0 .35em; text-transform: uppercase; letter-spacing: .06em; color: var(--_muted); }

/* Тонкий акцент під H2 — впізнаваність бренду без крикливості */
.article-content h2 {
    padding-bottom: .3em;
    border-bottom: 2px solid var(--_line);
}

/* ---------- Посилання ---------- */
.article-content a {
    color: var(--_accent-dark);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    transition: color .15s;
}
.article-content a:hover { color: var(--_accent); }

/* ---------- Текстові акценти ---------- */
.article-content strong,
.article-content b { font-weight: 800; }
.article-content em,
.article-content i { font-style: italic; }
.article-content mark {
    background: rgba(0, 195, 255, .18);
    color: inherit;
    padding: .05em .2em;
    border-radius: 4px;
}
.article-content small { font-size: .85em; color: var(--_muted); }
.article-content sup, .article-content sub { line-height: 0; }

/* ---------- Списки ---------- */
.article-content ul,
.article-content ol {
    margin: 0 0 1.15em;
    padding-left: 1.4em;
}
.article-content li { margin-bottom: .5em; }
.article-content li::marker { color: var(--_accent-dark); font-weight: 700; }
.article-content ul ul,
.article-content ol ol,
.article-content ul ol,
.article-content ol ul { margin: .5em 0 .5em; }

/* Список-«чеклист»: адмін ставить class="checklist" на <ul> */
.article-content ul.checklist { list-style: none; padding-left: 0; }
.article-content ul.checklist li {
    position: relative;
    padding-left: 1.9em;
}
.article-content ul.checklist li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: .05em;
    width: 1.3em; height: 1.3em;
    display: grid; place-items: center;
    background: rgba(0, 195, 255, .12);
    color: var(--_accent-dark);
    border-radius: 50%;
    font-size: .8em; font-weight: 900;
}

/* ---------- Цитати ---------- */
.article-content blockquote {
    margin: 1.5em 0;
    padding: 1em 1.25em;
    background: var(--_bg-soft);
    border-left: 4px solid var(--_accent);
    border-radius: 0 var(--_radius) var(--_radius) 0;
    color: #33414f;
    font-size: 1.05em;
}
.article-content blockquote p:last-child { margin-bottom: 0; }
.article-content blockquote cite {
    display: block;
    margin-top: .6em;
    font-style: normal;
    font-weight: 700;
    font-size: .9em;
    color: var(--_muted);
}

/* ---------- Зображення та підписи ---------- */
.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--_radius);
    /* контент-зображення НЕ мають бути lazy для першого екрана —
       lazy керується в HTML атрибутом, не тут */
}
.article-content figure {
    margin: 1.6em 0;
    text-align: center;
}
.article-content figure img { margin-inline: auto; box-shadow: var(--_shadow); }
.article-content figcaption {
    margin-top: .6em;
    font-size: .88em;
    color: var(--_muted);
    line-height: 1.5;
}

/* ---------- Таблиці ----------
   TinyMCE віддає «голий» <table>. Обгортка .table-scroll додається
   міні-скриптом у шаблоні (див. план). CSS покриває обидва випадки. */
.article-content .table-scroll {
    overflow-x: auto;
    margin: 1.6em 0;
    border: 1px solid var(--_line);
    border-radius: var(--_radius);
    -webkit-overflow-scrolling: touch;
}
.article-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: .95em;
}
.article-content .table-scroll > table { margin: 0; }
.article-content:not(:has(.table-scroll)) table { margin: 1.6em 0; } /* fallback без обгортки */
.article-content th,
.article-content td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--_line);
    vertical-align: top;
}
.article-content thead th {
    background: var(--_ink);
    color: #fff;
    font-weight: 700;
    white-space: nowrap;
}
.article-content tbody tr:nth-child(even) { background: var(--_bg-soft); }
.article-

/* ---------- Таблиці ----------*/

/* Базовий вигляд таблиці (і обгорнутої, і ні) */
.article-content table {
    width: 100%;
    border-collapse: separate;          /* separate → стабільні sticky-фони й рамки */
    border-spacing: 0;
    font-size: .93em;
    font-variant-numeric: tabular-nums; /* рівні колонки цифр */
    line-height: 1.35;
}
.article-content:not(:has(.table-scroll)) table { margin: 1.6em 0; } /* fallback без обгортки */

/* Клітинки */
.article-content th,
.article-content td {
    padding: 11px 16px;
    text-align: center;                 /* числа по центру; перша колонка — зліва (нижче) */
    vertical-align: middle;
    border: 0;
    border-bottom: 1px solid var(--_line);
    white-space: nowrap;
}
.article-content th + th,
.article-content td + td { border-left: 1px solid #eef2f7; }   /* тонка сітка між колонками */
.article-content tbody tr:last-child td { border-bottom: 0; }

/* Перша колонка — мітки зліва, напівжирні */
.article-content th:first-child,
.article-content td:first-child { text-align: left; font-weight: 600; }

/* Шапка: темний градієнт + бірюзове підкреслення (бренд) */
.article-content thead th {
    position: sticky; top: 0;           /* закріпиться лише якщо контейнеру задати max-height */
    background: linear-gradient(180deg, #14161d, var(--_ink));
    color: #fff;
    font-weight: 700;
    letter-spacing: .01em;
    box-shadow: inset 0 -2px 0 var(--_accent);
    z-index: 3;
}
.article-content thead th + th { border-left-color: rgba(255, 255, 255, .09); }

/* Зебра + ховер рядка */
.article-content tbody tr:nth-child(even) td { background: var(--_bg-soft); }
.article-content tbody tr:hover td { background: rgba(0, 195, 255, .09); }

/* Останній стовпець (підсумок / «Рік») — акцентний роздільник */
.article-content td:last-child,
.article-content thead th:last-child { border-left: 2px solid var(--_line); }
.article-content thead th:last-child { border-left-color: rgba(255, 255, 255, .16); }

/* ---- Обгорнута таблиця: скрол-контейнер + липка перша колонка ---- */
.article-content .table-scroll {
    overflow-x: auto;
    margin: 1.7em 0;
    border: 1px solid var(--_line);
    border-radius: var(--_radius);
    background: #fff;
    box-shadow: 0 1px 2px rgba(11, 12, 16, .05);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cdd7e1 #f0f4f8;
}
.article-content .table-scroll::-webkit-scrollbar { height: 8px; }
.article-content .table-scroll::-webkit-scrollbar-track { background: #f0f4f8; border-radius: 0 0 var(--_radius) var(--_radius); }
.article-content .table-scroll::-webkit-scrollbar-thumb { background: #cdd7e1; border-radius: 4px; }
.article-content .table-scroll::-webkit-scrollbar-thumb:hover { background: #b4c1cf; }

.article-content .table-scroll > table {
    margin: 0;
    min-width: max-content;             /* скрол з'явиться лише коли таблиця ширша за екран */
}

/* Липка перша колонка — назви областей завжди видно при скролі вбік */
.article-content .table-scroll th:first-child,
.article-content .table-scroll td:first-child {
    position: sticky;
    left: 0;
    box-shadow: 8px 0 10px -8px rgba(11, 12, 16, .22);
}
.article-content .table-scroll thead th:first-child { z-index: 4; }
.article-content .table-scroll tbody td:first-child {
    background: #fff;
    color: var(--_ink);
    z-index: 2;
}
.article-content .table-scroll tbody tr:nth-child(even) td:first-child { background: #eef2f6; }
.article-content .table-scroll tbody tr:hover td:first-child { background: #e3f5fb; color: var(--_accent-dark); }

/* Заокруглення верхніх кутів під рамку контейнера */
.article-content .table-scroll thead tr:first-child th:first-child { border-top-left-radius: calc(var(--_radius) - 1px); }
.article-content .table-scroll thead tr:first-child th:last-child  { border-top-right-radius: calc(var(--_radius) - 1px); }

/* Мобільні уточнення для таблиць (скоуплено під .table-scroll —
   перекриває загальний мобільний блок унизу файла) */
@media (max-width: 640px) {
    .article-content .table-scroll > table { font-size: .9em; }
    .article-content .table-scroll th,
    .article-content .table-scroll td { padding: 9px 12px; }
}





/* ---------- Код ---------- */
.article-content code,
.article-content kbd,
.article-content samp {
    font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
    font-size: .9em;
}
.article-content :not(pre) > code {
    background: #eef2f7;
    color: #c026a3;
    padding: .15em .4em;
    border-radius: 6px;
    white-space: nowrap;
}
.article-content pre {
    margin: 1.5em 0;
    padding: 1em 1.2em;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--_radius);
    overflow-x: auto;
    line-height: 1.6;
    font-size: .9em;
}
.article-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    white-space: pre;
}

/* ---------- Розділювач ---------- */
.article-content hr {
    margin: 2.2em 0;
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--_line) 20%, var(--_line) 80%, transparent);
}

/* ---------- Відео / iframe (адаптивні embed) ----------
   Обгортка .embed-responsive додається скриптом; є і фолбек. */
.article-content .embed-responsive {
    position: relative;
    margin: 1.6em 0;
    aspect-ratio: 16 / 9;
    border-radius: var(--_radius);
    overflow: hidden;
    box-shadow: var(--_shadow);
    background: #000;
}
.article-content .embed-responsive iframe,
.article-content .embed-responsive video,
.article-content .embed-responsive object {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
/* Фолбек: iframe/відео без обгортки */
.article-content > iframe,
.article-content > video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    margin: 1.6em 0;
    border: 0;
    border-radius: var(--_radius);
}

/* ---------- Details / Summary (акордеон, FAQ) ---------- */
.article-content details {
    margin: 1em 0;
    padding: 0 1.2em;
    background: #fff;
    border: 1px solid var(--_line);
    border-radius: var(--_radius);
    overflow: hidden;
}
.article-content details[open] { box-shadow: var(--_shadow); }
.article-content summary {
    padding: 1em 0;
    margin: 0 -1.2em;
    padding-inline: 1.2em;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1em;
}
.article-content summary::-webkit-details-marker { display: none; }
.article-content summary::after {
    content: "+";
    font-size: 1.4em;
    font-weight: 400;
    color: var(--_accent-dark);
    transition: transform .2s;
    line-height: 1;
}
.article-content details[open] summary::after { transform: rotate(45deg); }
.article-content details > :not(summary) { padding-bottom: 1.1em; }

/* ---------- Callout-блоки ----------
   Адмін у TinyMCE ставить на <div> class="callout callout-tip" тощо.
   Або на <blockquote> — теж працює. */
.article-content .callout {
    --_c: var(--_accent);
    --_c-bg: rgba(0, 195, 255, .07);
    position: relative;
    margin: 1.6em 0;
    padding: 1.1em 1.25em 1.1em 3.2em;
    background: var(--_c-bg);
    border: 1px solid color-mix(in srgb, var(--_c) 30%, transparent);
    border-left: 4px solid var(--_c);
    border-radius: var(--_radius);
}
.article-content .callout::before {
    content: "ℹ";
    position: absolute;
    left: 1em; top: 1em;
    width: 1.5em; height: 1.5em;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--_c);
    color: #fff;
    font-weight: 900;
    font-size: .95em;
}
.article-content .callout > :last-child { margin-bottom: 0; }
.article-content .callout-title {
    display: block;
    font-weight: 800;
    margin-bottom: .3em;
    color: var(--_ink);
}
/* Порада */
.article-content .callout-tip {
    --_c: #16a34a; --_c-bg: rgba(22, 163, 74, .07);
}
.article-content .callout-tip::before { content: "💡"; background: none; font-size: 1.3em; }
/* Важливо */
.article-content .callout-important {
    --_c: var(--_accent-dark); --_c-bg: rgba(0, 195, 255, .08);
}
.article-content .callout-important::before { content: "★"; }
/* Попередження */
.article-content .callout-warning {
    --_c: #ea580c; --_c-bg: rgba(234, 88, 12, .08);
}
.article-content .callout-warning::before { content: "!"; }

/* ---------- Кнопки в контенті ----------
   TinyMCE-кнопка = <a class="btn"> або <a class="button">. */
.article-content a.btn,
.article-content a.button,
.article-content .wp-block-button__link {
    display: inline-flex;
    align-items: center;
    gap: .5em;
    padding: 14px 28px;
    margin: .3em 0;
    background: var(--_accent);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    border-radius: var(--_radius);
    box-shadow: 0 12px 30px rgba(0, 195, 255, .3);
    transition: transform .25s, box-shadow .25s;
}
.article-content a.btn:hover,
.article-content a.button:hover {
    transform: translateY(-3px);
    color: #fff;
}

/* ---------- Доступність та рух ---------- */
.article-content :focus-visible {
    outline: 3px solid var(--_accent);
    outline-offset: 2px;
    border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
    .article-content * { transition: none !important; }
}

/* ---------- Мобільні уточнення ---------- */
@media (max-width: 640px) {
    .article-content { font-size: 17px; }
    .article-content th,
    .article-content td { padding: 10px 12px; }
    .article-content pre,
    .article-content blockquote { border-radius: 10px; }
}
