/* ============================================================
   Новости (/news/): сетка карточек + страница статьи.
   Подключается точечно из blog.tpl / blog_post.tpl — классы nw-*
   не входят в purge-сборку css.css, пересборка не нужна.
   Палитра «Новый Ориентир»: teal #009688, тёмный teal #0e5164,
   нейтрали подтонированы в teal. Плоские карточки без теней.
   ============================================================ */

.nw {
    --nw-ink: #0e5164;
    --nw-body: #33555f;
    --nw-muted: #6d8a90;
    --nw-teal: #009688;
    --nw-teal-deep: #00776c;
    --nw-line: #e2ecea;
    --nw-chip-bg: #eaf4f2;
    --nw-surface: #fbfdfc;
    --nw-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    color: var(--nw-body);
}

/* ---------- Шапка раздела ---------- */

.nw__head {
    margin: 8px 0 20px;
}

.nw__title {
    margin: 0 0 4px;
    font-size: clamp(26px, 3.4vw, 38px);
    font-weight: 600;
    line-height: 1.15;
    color: var(--nw-ink);
    letter-spacing: -0.01em;
}

.nw__lede {
    margin: 0;
    max-width: 60ch;
    font-size: 15px;
    color: var(--nw-muted);
}

/* Чипы рубрик + поиск: одна строка на десктопе, скролл-лента на телефоне */
.nw__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 0 0 24px;
    padding: 14px 0;
    border-top: 1px solid var(--nw-line);
    border-bottom: 1px solid var(--nw-line);
}

.nw__chips {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.nw-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--nw-line);
    border-radius: 999px;
    background: #fff;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--nw-ink);
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 160ms var(--nw-ease-out);
}

.nw-chip__n {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--nw-muted);
    font-variant-numeric: tabular-nums;
}

.nw-chip:active { transform: scale(0.97); }

.nw-chip--on,
.nw-chip--on:hover,
.nw-chip--on:focus {
    background: var(--nw-ink);
    border-color: var(--nw-ink);
    color: #fff;
    text-decoration: none;
}

.nw-chip--on .nw-chip__n { color: rgba(255, 255, 255, 0.65); }

@media (hover: hover) and (pointer: fine) {
    .nw-chip:hover {
        border-color: var(--nw-teal);
        color: var(--nw-teal-deep);
        text-decoration: none;
    }
}

/* Поиск: компактный, справа от чипов */
.nw__search {
    display: flex;
    flex: 0 1 240px;
    margin-left: auto;
}

.nw__search .form-group { margin: 0; flex: 1 1 auto; }

.nw__search input[type="text"] {
    width: 100%;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--nw-line);
    border-radius: 999px;
    background: var(--nw-surface);
    font-size: 13.5px;
    color: var(--nw-ink);
    transition: border-color 150ms ease, background-color 150ms ease;
}

.nw__search input[type="text"]::placeholder { color: var(--nw-muted); }

.nw__search input[type="text"]:focus {
    outline: none;
    border-color: var(--nw-teal);
    background: #fff;
}

.nw__search [type="submit"] {
    height: 36px;
    margin-left: 8px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--nw-teal);
    color: #fff;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 150ms ease, transform 160ms var(--nw-ease-out);
}

.nw__search [type="submit"]:hover { background: var(--nw-teal-deep); }
.nw__search [type="submit"]:active { transform: scale(0.96); }

@media (max-width: 767px) {
    .nw__bar { flex-direction: column; align-items: stretch; }
    .nw__chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0 -15px;
        padding: 0 15px;
    }
    .nw__chips::-webkit-scrollbar { display: none; }
    .nw__search { flex-basis: auto; margin-left: 0; }
}

/* ---------- Сетка карточек ---------- */

.nw__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px 20px;
    margin: 0 0 32px;
}

@media (max-width: 1199px) {
    .nw__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 639px) {
    .nw__grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
}

/* ---------- Карточка ---------- */

.nw-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--nw-line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: border-color 200ms ease, transform 200ms var(--nw-ease-out);
}

.nw-card:active { transform: scale(0.99); }

@media (hover: hover) and (pointer: fine) {
    .nw-card:hover { border-color: #b9d6d2; }
    .nw-card:hover .nw-card__media img { transform: scale(1.04); }
    .nw-card:hover .nw-card__title { color: var(--nw-teal-deep); }
}

.nw-card__link {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    color: inherit;
    text-decoration: none;
}

.nw-card__link:hover,
.nw-card__link:focus { color: inherit; text-decoration: none; }

.nw-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--nw-chip-bg);
}

.nw-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 350ms var(--nw-ease-out);
}

/* Фолбэк без обложки: teal-градиент + роза ветров («Ориентир») */
.nw-card__media--none {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke='%23ffffff' stroke-opacity='.16' stroke-width='1.4'%3E%3Ccircle cx='50' cy='50' r='30'/%3E%3Ccircle cx='50' cy='50' r='42'/%3E%3Cpath d='M50 8v12M50 80v12M8 50h12M80 50h12'/%3E%3Cpath d='M50 26 58 50l-8 24-8-24z' fill='%23ffffff' fill-opacity='.14' stroke='none'/%3E%3Cpath d='M26 50l24-8 24 8-24 8z' fill='%23ffffff' fill-opacity='.08' stroke='none'/%3E%3C/svg%3E") no-repeat right -36px bottom -52px / 210px 210px,
        linear-gradient(150deg, #0e5164 12%, #147c74 68%, #009688 100%);
}

.nw-card__media--none::after {
    content: "Новый Ориентир";
    position: absolute;
    left: 18px;
    bottom: 14px;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
}

.nw-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 8px;
    padding: 16px 18px 18px;
}

.nw-card__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--nw-muted);
    font-variant-numeric: tabular-nums;
}

.nw-card__meta .nw-dot { opacity: 0.55; }

.nw-card__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--nw-ink);
    transition: color 150ms ease;
    /* максимум 3 строки, чтобы карточки не расползались */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nw-card__excerpt {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--nw-body);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nw-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    padding-top: 10px;
}

.nw-card__cat {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--nw-chip-bg);
    font-size: 12px;
    font-weight: 500;
    color: var(--nw-ink);
    white-space: nowrap;
}

.nw-card__author {
    font-size: 12.5px;
    color: var(--nw-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Featured: первая статья первой страницы ---------- */

@media (min-width: 640px) {
    .nw-card--featured { grid-column: 1 / -1; }

    .nw-card--featured .nw-card__link {
        flex-direction: row;
        align-items: stretch;
    }

    .nw-card--featured .nw-card__media {
        flex: 0 0 54%;
        aspect-ratio: auto;
        min-height: 300px;
    }

    .nw-card--featured .nw-card__body {
        justify-content: center;
        gap: 12px;
        padding: 28px 32px;
    }

    .nw-card--featured .nw-card__title {
        font-size: clamp(20px, 2.4vw, 27px);
        line-height: 1.25;
        -webkit-line-clamp: 4;
    }

    .nw-card--featured .nw-card__excerpt {
        font-size: 15px;
        line-height: 1.6;
        -webkit-line-clamp: 4;
    }

    .nw-card--featured .nw-card__foot {
        justify-content: flex-start;
        gap: 14px;
        margin-top: 0; /* низ не прижимаем — весь кластер центрируется целиком */
    }
}

/* ---------- Пустое состояние ---------- */

.nw-empty {
    padding: 64px 20px 72px;
    text-align: center;
}

.nw-empty__mark {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    color: var(--nw-teal);
    opacity: 0.8;
}

.nw-empty__title {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 600;
    color: var(--nw-ink);
}

.nw-empty__text {
    margin: 0 auto 20px;
    max-width: 46ch;
    font-size: 14.5px;
    color: var(--nw-muted);
}

.nw-empty__link {
    display: inline-block;
    padding: 10px 22px;
    border-radius: 999px;
    background: var(--nw-teal);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 150ms ease, transform 160ms var(--nw-ease-out);
}

.nw-empty__link:hover,
.nw-empty__link:focus { background: var(--nw-teal-deep); color: #fff; text-decoration: none; }
.nw-empty__link:active { transform: scale(0.97); }

/* ---------- :visited ----------
   css.css задаёт a:visited { color: var(--color-primary) } — специфичность (0,1,1)
   перебивает одиночный класс (0,1,0). После визита в каталог «Смотреть каталог»
   становилась teal-на-teal, заголовки карточек и чипы — teal. Закрепляем цвета. */

.nw-chip:visited { color: var(--nw-ink); }
.nw-chip--on:visited { color: #fff; }
.nw-card__link:visited { color: inherit; }
.nw-card__cat:visited,
.nw-article__follow:visited,
.nw-share__btn:visited,
.nw-article__nav a:visited { color: var(--nw-ink); }
.nw-empty__link:visited { color: #fff; }
.nw-empty__link:visited:hover,
.nw-empty__link:visited:focus { color: #fff; }

/* ---------- Пагинация (обёртка над штатным блоком) ---------- */

.nw__paging { margin: 8px 0 40px; }

.nw__paging .pagination > li > a,
.nw__paging .pagination > li > span {
    color: var(--nw-ink);
    border-color: var(--nw-line);
}

.nw__paging .pagination > .active > a,
.nw__paging .pagination > .active > span {
    background: var(--nw-ink);
    border-color: var(--nw-ink);
    color: #fff;
}

/* ============================================================
   Страница статьи
   ============================================================ */

.nw-article {
    max-width: 780px;
    margin: 0 auto;
}

.nw-article__cat-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 10px 0 14px;
}

.nw-article__cat-row .nw-card__cat { text-decoration: none; transition: background-color 150ms ease; }

@media (hover: hover) and (pointer: fine) {
    .nw-article__cat-row a.nw-card__cat:hover { background: #d8ebe8; }
}

.nw-article__title {
    margin: 0 0 14px;
    font-size: clamp(26px, 3.6vw, 40px);
    font-weight: 600;
    line-height: 1.18;
    letter-spacing: -0.01em;
    color: var(--nw-ink);
}

.nw-article__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 22px;
    font-size: 13.5px;
    color: var(--nw-muted);
    font-variant-numeric: tabular-nums;
}

.nw-article__author { color: var(--nw-body); font-weight: 500; }

.nw-article__follow {
    margin-left: auto;
    padding: 6px 14px;
    border: 1px solid var(--nw-line);
    border-radius: 999px;
    background: #fff;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--nw-ink);
    text-decoration: none;
    transition: border-color 150ms ease, transform 160ms var(--nw-ease-out);
}

.nw-article__follow:hover { border-color: var(--nw-teal); color: var(--nw-teal-deep); text-decoration: none; }
.nw-article__follow:active { transform: scale(0.97); }

.nw-article__cover {
    margin: 0 0 26px;
    border-radius: 12px;
    overflow: hidden;
}

.nw-article__cover img {
    display: block;
    width: 100%;
    max-height: 480px;
    object-fit: cover;
}

/* Типографика тела статьи (HTML из редактора) */
.nw-article__content {
    font-size: 16.5px;
    line-height: 1.7;
    color: var(--nw-body);
}

.nw-article__content p { margin: 0 0 1.15em; }

.nw-article__content h2,
.nw-article__content h3 {
    margin: 1.6em 0 0.55em;
    font-weight: 600;
    line-height: 1.3;
    color: var(--nw-ink);
}

.nw-article__content h2 { font-size: 23px; }
.nw-article__content h3 { font-size: 19px; }

.nw-article__content ul,
.nw-article__content ol { margin: 0 0 1.15em; padding-left: 1.35em; }

.nw-article__content li { margin-bottom: 0.4em; }

.nw-article__content a { color: var(--nw-teal-deep); text-decoration: underline; text-underline-offset: 2px; }

.nw-article__content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 0.5em 0 1em;
}

.nw-article__content blockquote {
    margin: 1.4em 0;
    padding: 16px 22px;
    border: 1px solid var(--nw-line);
    border-radius: 10px;
    background: var(--nw-surface);
    font-size: 16px;
    color: var(--nw-ink);
}

.nw-article__content blockquote p:last-child { margin-bottom: 0; }

.nw-article__share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 26px 0;
}

.nw-share__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--nw-muted);
    margin-right: 2px;
}

.nw-share__btn {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border: 1px solid var(--nw-line);
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    font-weight: 500;
    color: var(--nw-ink);
    text-decoration: none;
    cursor: pointer;
    transition: border-color 150ms ease, color 150ms ease, transform 160ms var(--nw-ease-out);
}

.nw-share__btn:hover,
.nw-share__btn:focus { border-color: var(--nw-teal); color: var(--nw-teal-deep); text-decoration: none; }
.nw-share__btn:active { transform: scale(0.97); }

.nw-share__copy--done,
.nw-share__copy--done:hover {
    border-color: var(--nw-teal);
    background: var(--nw-chip-bg);
    color: var(--nw-teal-deep);
}

/* Прочитать ещё: prev/next как мини-навигация */
.nw-article__nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 30px 0 8px;
    padding-top: 22px;
    border-top: 1px solid var(--nw-line);
}

.nw-article__nav a {
    max-width: 46%;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--nw-ink);
    text-decoration: none;
}

.nw-article__nav a:hover { color: var(--nw-teal-deep); text-decoration: none; }

.nw-article__nav .nw-nav__dir {
    display: block;
    margin-bottom: 3px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--nw-muted);
}

.nw-article__nav a.nw-nav--next { margin-left: auto; text-align: right; }

/* ---------- Похожие новости ---------- */

.nw-related { margin: 44px 0 40px; }

.nw-related__title {
    margin: 0 0 18px;
    font-size: 22px;
    font-weight: 600;
    color: var(--nw-ink);
}

.nw-related .nw__grid { margin-bottom: 0; }

/* ---------- Комментарии ---------- */

.nw-comments { margin: 40px 0; }

.nw-comments__title {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 600;
    color: var(--nw-ink);
}

.nw-comments .media,
.nw-comments .nw-comment {
    padding: 14px 18px;
    border: 1px solid var(--nw-line);
    border-radius: 10px;
    margin-bottom: 12px;
    background: #fff;
}

.nw-comments #blog_comment_form {
    padding: 20px;
    border: 1px solid var(--nw-line);
    border-radius: 12px;
    background: var(--nw-surface);
}

.nw-comments #blog_comment_form legend {
    font-size: 16px;
    font-weight: 600;
    color: var(--nw-ink);
    border: 0;
    margin-bottom: 12px;
}

.nw-comments textarea,
.nw-comments input[type="text"] {
    border: 1px solid var(--nw-line);
    border-radius: 8px;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .nw-chip,
    .nw-card,
    .nw-card__media img,
    .nw-empty__link,
    .nw-article__follow,
    .nw__search [type="submit"] {
        transition: none;
    }
    .nw-card:active,
    .nw-chip:active { transform: none; }
    .nw-card:hover .nw-card__media img { transform: none; }
}
