/* =========================================================
   PaxHub · News styles
   Публичные страницы + админка. Работает поверх Tailwind.
   ========================================================= */

:root {
    --news-emerald: #10b981;          /* brand-emerald */
    --news-emerald-soft: rgba(16, 185, 129, .12);
    --news-emerald-border: rgba(16, 185, 129, .35);
    --news-amber: #f59e0b;            /* brand-amber */
    --news-surface-0: #0a0a0a;
    --news-surface-1: #121212;
    --news-text: #e5e5e5;
    --news-text-muted: #a1a1aa;
    --news-text-dim: #71717a;
    --news-border: rgba(255, 255, 255, .1);
    --news-radius: 1rem;
    --news-radius-lg: 1.25rem;
}

/* =========================================================
   1. Видео-плеер (16:9, lazy)
   ========================================================= */

.news-video {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;          /* 16:9 */
    height: 0;
    margin: 1.5rem 0;
    overflow: hidden;
    border-radius: var(--news-radius);
    background: #000;
    border: 1px solid var(--news-border);
}

.news-video iframe,
.news-video video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* =========================================================
   2. Контент статьи (.news-content) — Markdown / WYSIWYG
   ========================================================= */

.news-content {
    color: var(--news-text);
    font-size: 1rem;
    line-height: 1.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Первый/последний элемент без внешних отступов */
.news-content > *:first-child { margin-top: 0 !important; }
.news-content > *:last-child  { margin-bottom: 0 !important; }

/* --- Заголовки --- */
.news-content h1,
.news-content h2,
.news-content h3,
.news-content h4,
.news-content h5,
.news-content h6 {
    color: #fff;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.01em;
    scroll-margin-top: 5rem;         /* учёт sticky-хедера при якорях */
}

.news-content h1 {
    font-size: clamp(1.75rem, 3vw + 1rem, 2.25rem);
    margin: 2.25em 0 .75em;
}

.news-content h2 {
    font-size: clamp(1.4rem, 2vw + 1rem, 1.75rem);
    margin: 2em 0 .75em;
    padding-bottom: .5em;
    border-bottom: 1px solid var(--news-border);
}

.news-content h3 {
    font-size: 1.3rem;
    margin: 1.75em 0 .5em;
}

.news-content h4 {
    font-size: 1.1rem;
    margin: 1.5em 0 .5em;
}

.news-content h5,
.news-content h6 {
    font-size: 1rem;
    margin: 1.25em 0 .5em;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--news-text-muted);
}

/* --- Параграфы --- */
.news-content p {
    margin: 0 0 1.1em;
    line-height: 1.8;
}

/* --- Списки --- */
.news-content ul,
.news-content ol {
    margin: 0 0 1.25em;
    padding-left: 1.5em;
}

.news-content ul { list-style: disc outside; }
.news-content ol { list-style: decimal outside; }

.news-content li {
    margin: .4em 0;
    line-height: 1.7;
}

.news-content li::marker {
    color: var(--news-emerald);
    font-weight: 700;
}

.news-content li > ul,
.news-content li > ol {
    margin: .4em 0;
}

.news-content ul ul { list-style-type: circle; }
.news-content ul ul ul { list-style-type: square; }

/* --- Ссылки --- */
.news-content a {
    color: var(--news-emerald);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color .15s ease, color .15s ease;
}

.news-content a:hover {
    border-bottom-color: var(--news-emerald);
}

.news-content a:focus-visible {
    outline: 2px solid var(--news-emerald);
    outline-offset: 2px;
    border-radius: 2px;
}

/* --- Жирный / курсив / зачёркнутый --- */
.news-content strong,
.news-content b { color: #fff; font-weight: 800; }

.news-content em,
.news-content i { font-style: italic; }

.news-content del,
.news-content s { color: var(--news-text-dim); text-decoration: line-through; }

.news-content mark {
    background: rgba(245, 158, 11, .25);
    color: inherit;
    padding: 0 .2em;
    border-radius: .2em;
}

/* --- Инлайн-код --- */
.news-content code {
    background: rgba(255, 255, 255, .06);
    color: #f4f4f5;
    padding: .15em .4em;
    border-radius: .3em;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .9em;
    word-break: break-word;
}

/* --- Блок кода --- */
.news-content pre,
.news-content pre.news-code {
    background: #0a0a0a;
    border: 1px solid var(--news-border);
    border-radius: .85rem;
    padding: 1em 1.15em;
    margin: 1.25em 0;
    overflow-x: auto;
    font-size: .85em;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
}

.news-content pre code,
.news-content pre.news-code code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: #e5e5e5;
    font-size: inherit;
    white-space: pre;
}

.news-content pre[data-lang]::before {
    content: attr(data-lang);
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--news-text-dim);
    margin-bottom: .5em;
    font-family: ui-monospace, monospace;
}

/* --- Цитата --- */
.news-content blockquote {
    margin: 1.25em 0;
    padding: .75em 1.25em;
    border-left: 3px solid var(--news-emerald);
    background: var(--news-emerald-soft);
    color: #d4d4d8;
    font-style: italic;
    border-radius: 0 .6rem .6rem 0;
}

.news-content blockquote p { margin: .4em 0; }

.news-content blockquote p:first-child { margin-top: 0; }
.news-content blockquote p:last-child  { margin-bottom: 0; }

.news-content blockquote cite {
    display: block;
    margin-top: .5em;
    font-size: .9em;
    color: var(--news-text-dim);
    font-style: normal;
}

/* --- Картинки --- */
.news-content img {
    max-width: 100%;
    height: auto;
    border-radius: .85rem;
    display: block;
    margin: 1.25em auto;
    border: 1px solid var(--news-border);
}

.news-content figure {
    margin: 1.5em 0;
}

.news-content figure > img {
    margin: 0 auto;
}

.news-content figcaption {
    margin-top: .6em;
    font-size: .85em;
    color: var(--news-text-dim);
    text-align: center;
    line-height: 1.5;
}

/* --- Таблицы --- */
.news-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25em 0;
    font-size: .92em;
    overflow: hidden;
    border-radius: .6rem;
    border: 1px solid var(--news-border);
    display: block;
    overflow-x: auto;
}

.news-content thead {
    background: rgba(255, 255, 255, .04);
}

.news-content th,
.news-content td {
    padding: .7em .9em;
    text-align: left;
    border-bottom: 1px solid var(--news-border);
}

.news-content th {
    color: #fff;
    font-weight: 700;
    font-size: .85em;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.news-content tbody tr:last-child td { border-bottom: 0; }

.news-content tbody tr:hover {
    background: rgba(255, 255, 255, .02);
}

/* --- HR --- */
.news-content hr {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--news-border), transparent);
    margin: 2em 0;
}

/* --- Вложенные видео внутри контента --- */
.news-content .news-video {
    margin: 1.5em 0;
}

/* --- Чек-листы (task list) --- */
.news-content input[type="checkbox"] {
    margin-right: .4em;
    accent-color: var(--news-emerald);
}

.news-content li:has(input[type="checkbox"]) {
    list-style: none;
    margin-left: -1.4em;
}

/* --- Сноски (если когда-нибудь понадобятся) --- */
.news-content sup a {
    font-size: .75em;
    padding: 0 .15em;
    color: var(--news-emerald);
}

/* =========================================================
   3. Шапка статьи — счётчики, теги
   ========================================================= */

.news-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    font-size: .75rem;
    color: var(--news-text-dim);
}

.news-meta-sep {
    color: #3f3f46;
    user-select: none;
}

.news-tag {
    display: inline-flex;
    align-items: center;
    padding: .25rem .75rem;
    border-radius: 9999px;
    font-size: .75rem;
    font-weight: 600;
    background: var(--news-emerald-soft);
    color: var(--news-emerald);
    text-decoration: none;
    transition: background-color .15s ease;
}

.news-tag:hover {
    background: rgba(16, 185, 129, .22);
}

/* =========================================================
   4. Карточки, галерея, related
   ========================================================= */

.news-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
    margin-top: 2rem;
}

@media (min-width: 768px) {
    .news-gallery { grid-template-columns: repeat(3, 1fr); }
}

.news-gallery-item {
    display: block;
    border-radius: .75rem;
    overflow: hidden;
    border: 1px solid var(--news-border);
    transition: border-color .2s ease, transform .2s ease;
}

.news-gallery-item:hover {
    border-color: var(--news-emerald-border);
}

.news-gallery-item img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}

.news-gallery-item:hover img {
    transform: scale(1.04);
}

/* Карточки (index/category) — бейдж видео */
.news-card-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .15rem .5rem;
    font-size: 10px;
    font-weight: 800;
    border-radius: .25rem;
    background: var(--news-emerald-soft);
    color: var(--news-emerald);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.news-card-badge--featured { background: rgba(245, 158, 11, .15); color: var(--news-amber); }

/* =========================================================
   5. Адаптив
   ========================================================= */

@media (max-width: 640px) {
    .news-content {
        font-size: 15px;
        line-height: 1.75;
    }

    .news-content h2 { font-size: 1.35rem; }
    .news-content h3 { font-size: 1.15rem; }

    .news-content pre,
    .news-content pre.news-code {
        font-size: .8em;
        padding: .85em 1em;
    }

    .news-content blockquote {
        padding: .6em 1em;
        font-size: .95em;
    }

    .news-video {
        margin: 1rem 0;
        border-radius: .75rem;
    }
}

/* =========================================================
   6. Печать
   ========================================================= */

@media print {
    .news-video,
    .news-gallery,
    .news-meta,
    .news-tag,
    nav, .share-buttons, [data-share] {
        display: none !important;
    }

    .news-content {
        color: #000;
        font-size: 11pt;
        line-height: 1.5;
    }

    .news-content h1,
    .news-content h2,
    .news-content h3,
    .news-content h4,
    .news-content strong {
        color: #000;
    }

    .news-content a {
        color: #000;
        text-decoration: underline;
    }

    .news-content a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: .85em;
        color: #555;
    }

    .news-content pre,
    .news-content blockquote {
        border: 1px solid #ccc;
        background: #f5f5f5;
    }
}

/* =========================================================
   7. Reduce motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .news-gallery-item,
    .news-gallery-item img,
    .news-tag,
    .news-content a {
        transition: none !important;
    }
}

/* =========================================================
   8. Toast UI Editor — тёмная тема, ВИДИМЫЕ иконки
   ⚠️  КЛЮЧЕВОЕ: используем background-color, не background.
       background: ... сбрасывает background-image — а именно
       в нём лежат SVG-иконки кнопок Toast UI.
   ========================================================= */

/* --- Контейнер --- */
.news-editor-wrap .toastui-editor-defaultUI {
    border-color: var(--news-border) !important;
    border-radius: .75rem !important;
    overflow: hidden;
}

/* --- Тулбар --- */
.news-editor-wrap .toastui-editor-defaultUI-toolbar {
    background: var(--news-surface-0) !important;
    border-bottom: 1px solid var(--news-border) !important;
    padding: 6px 8px !important;
}

.news-editor-wrap .toastui-editor-toolbar-group {
    border-right-color: var(--news-border) !important;
}

/* --- ИКОНКИ КНОПОК --- */
.news-editor-wrap .toastui-editor-toolbar-icons {
    border: 0 !important;
    background-color: transparent !important;   /* ← НЕ background! */
    border-radius: .4rem !important;
    transition: background-color .15s ease;
}

.news-editor-wrap .toastui-editor-toolbar-icons:hover {
    background-color: rgba(255, 255, 255, .1) !important;
}

.news-editor-wrap .toastui-editor-toolbar-icons.active {
    background-color: var(--news-emerald-soft) !important;
}

/* Страховка: если SVG-иконки тёмные (тёмная тема не подхватилась) —
   принудительно делаем их светло-серыми.
   filter не трогает background-image, но меняет рендер — работает
   независимо от цвета SVG. */
.news-editor-wrap .toastui-editor-toolbar-icons {
    filter: brightness(0) invert(0.85);
}

.news-editor-wrap .toastui-editor-toolbar-icons:hover,
.news-editor-wrap .toastui-editor-toolbar-icons.active {
    filter: brightness(0) invert(1);
}

/* Кастомная кнопка «Вставить видео» — исключаем из filter,
   чтобы FontAwesome-иконка осталась зелёной */
.news-editor-wrap [data-name="insertVideo"] {
    filter: none !important;
}

.news-editor-wrap [data-name="insertVideo"] i.fa-video {
    color: var(--news-emerald);
    font-size: 14px;
    line-height: 1;
}

/* --- Контент --- */
.news-editor-wrap .toastui-editor-main,
.news-editor-wrap .toastui-editor-md-container,
.news-editor-wrap .toastui-editor-ww-container,
.news-editor-wrap .toastui-editor-md-preview {
    background: var(--news-surface-0) !important;
    color: var(--news-text) !important;
}

.news-editor-wrap .toastui-editor-contents {
    color: var(--news-text) !important;
    font-size: 15px !important;
}

.news-editor-wrap .toastui-editor-contents h1,
.news-editor-wrap .toastui-editor-contents h2,
.news-editor-wrap .toastui-editor-contents h3 {
    color: #fff !important;
}

.news-editor-wrap .toastui-editor-contents blockquote {
    border-left-color: var(--news-emerald) !important;
    background: var(--news-emerald-soft) !important;
    color: #d4d4d8 !important;
}

.news-editor-wrap .toastui-editor-contents code {
    background: rgba(255, 255, 255, .06) !important;
    color: #f4f4f5 !important;
}

.news-editor-wrap .toastui-editor-contents pre {
    background: #050505 !important;
    border: 1px solid var(--news-border) !important;
}

.news-editor-wrap .toastui-editor-contents a {
    color: var(--news-emerald) !important;
}

.news-editor-wrap .toastui-editor-contents th {
    background: rgba(255, 255, 255, .04) !important;
    color: #fff !important;
}

.news-editor-wrap .toastui-editor-contents td,
.news-editor-wrap .toastui-editor-contents th {
    border-color: var(--news-border) !important;
}

/* --- Попапы (вставка ссылки, картинки, таблицы) --- */
.news-editor-wrap .toastui-editor-popup {
    background: var(--news-surface-1) !important;
    border: 1px solid var(--news-border) !important;
    border-radius: .75rem !important;
    color: var(--news-text) !important;
}

.news-editor-wrap .toastui-editor-popup-body {
    background: var(--news-surface-1) !important;
    color: var(--news-text) !important;
}

.news-editor-wrap .toastui-editor-popup-body input,
.news-editor-wrap .toastui-editor-popup-body select {
    background: var(--news-surface-0) !important;
    border: 1px solid var(--news-border) !important;
    color: var(--news-text) !important;
    border-radius: .5rem !important;
}

.news-editor-wrap .toastui-editor-popup-body button {
    border-radius: .5rem !important;
}

.news-editor-wrap .toastui-editor-popup-add-image .toastui-editor-popup-body button,
.news-editor-wrap .toastui-editor-ok-button {
    background: var(--news-emerald) !important;
    color: #000 !important;
    border: 0 !important;
    font-weight: 700 !important;
}

/* --- Свитч режима (WYSIWYG / Markdown) --- */
.news-editor-wrap .toastui-editor-mode-switch {
    background: var(--news-surface-0) !important;
    border-top: 1px solid var(--news-border) !important;
    color: var(--news-text-muted) !important;
}

.news-editor-wrap .toastui-editor-mode-switch .tab-item {
    color: var(--news-text-muted) !important;
    background: transparent !important;
    border-color: var(--news-border) !important;
}

.news-editor-wrap .toastui-editor-mode-switch .tab-item.active {
    color: var(--news-emerald) !important;
    border-color: var(--news-emerald) !important;
    background: var(--news-emerald-soft) !important;
}