/* ===========================================================================
   Newpoets — общий слой: токены, сброс, шапка, подвал, кнопки.
   Подключается на каждой странице; поверх него идёт CSS конкретной страницы.

   Раньше это был копипаст в трёх файлах (index.css / library.css / cabinet.css),
   которые успели разъехаться. Здесь оставлено ровно то, что действительно
   общее; различия страниц живут в их собственных файлах.
   =========================================================================== */

:root {
    /* Палитра брендбука. Имена соответствуют значениям — прежние --gold,
       --vermillion, --ink достались от «бумажно-чернильной» темы и путали. */
    --brand: #0ad1c9;
    /* Тиффани — акцентный бирюзовый */
    --brand-dark: #0ba8a2;
    /* тёмно-бирюзовый — фон hero, панелей, подвала */
    --brand-glow: #0ccec6;
    /* светлая точка радиального градиента */
    --accent: #ef4056;
    /* коралловый */

    --surface: #eaf8f7;
    /* фон страницы */
    --surface-raised: #ffffff;
    /* карточки, «бумага» */
    --surface-header: rgba(246, 243, 234, 0.92);
    /* полупрозрачная шапка */

    --text: #000000;
    --text-muted: #3d4a49;
    --text-on-brand: #ffffff;
    --text-muted-on-brand: #d6eeec;

    /* Хайрлайны и тени. Отдельным токеном, потому что в разметке это
       два десятка rgba() с одним и тем же цветом и разной прозрачностью. */
    --rule-rgb: 32, 35, 63;

    --brand-gradient: radial-gradient(ellipse 900px 500px at 18% -10%,
            var(--brand-glow) 0%, var(--brand-dark) 55%);

    --radius: 14px;
    --serif: "PT Serif", Georgia, serif;
    --sans: "Golos Text", "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--sans);
    background: var(--surface);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
}

img,
svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

/* .work-row задан как grid, .feed-item — как block; без !important атрибут
   hidden проигрывает им по порядку каскада. */
[hidden] {
    display: none !important;
}

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 28px;
}

.eyebrow {
    font-family: var(--mono);
    font-size: 12.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 500;
}

/* Ссылка «пропустить к содержимому» — видна только с клавиатуры. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--brand-dark);
    color: var(--text-on-brand);
    padding: 12px 20px;
    border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
    left: 0;
}

/* ---------- Шапка ---------- */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface-header);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(var(--rule-rgb), 0.08);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    gap: 24px;
}

.logo {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 21px;
    display: flex;
    align-items: center;
    gap: 9px;
    /* Без этого на узком экране шапка не помещается, и .logo как flex-элемент
       сжимается до нулевой ширины — логотип пропадает совсем. */
    flex-shrink: 0;
}

.logo-mark {
    height: 34px;
    width: auto;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(18px, 2vw, 30px);
    font-size: 14.5px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

.nav-links a {
    opacity: 0.78;
    transition: opacity .2s;
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.current {
    opacity: 1;
}

.nav-links a.current {
    color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.cabinet-link {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14.5px;
    font-weight: 600;
    opacity: 0.85;
    transition: opacity .2s;
    white-space: nowrap;
}

.cabinet-link:hover {
    opacity: 1;
}

.cabinet-link.current {
    opacity: 1;
    color: var(--accent);
}

.cabinet-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Аватар в шапке — инициалы на круге, цвет приходит инлайном из
   User.avatar_color и детерминирован по id. Файлов аватаров проект
   не хранит (бриф, ответ №9). */
.avatar-mini {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--text-on-brand);
}

.nav-cta {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 14px;
    background: var(--brand-dark);
    color: var(--text-on-brand);
    padding: 10px 20px;
    border-radius: 999px;
    white-space: nowrap;
    transition: background .2s;
}

.nav-cta:hover {
    background: var(--accent);
}

/* ---------- Кнопки ---------- */
.btn {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 15px;
    padding: 14px 26px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-on-brand);
}

.btn-primary:hover {
    transform: translateY(-2px);
    /* тень раньше была от старого кирпичного #C1421B — теперь от коралла */
    box-shadow: 0 10px 24px -8px rgba(239, 64, 86, 0.55);
}

.btn-ghost {
    background: transparent;
    color: var(--text-on-brand);
    border: 1.5px solid rgba(237, 233, 218, 0.35);
}

.btn-ghost:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.btn-dark {
    background: var(--brand-dark);
    color: var(--text-on-brand);
}

.btn-dark:hover {
    background: var(--accent);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--brand-dark);
    border: 1.5px solid rgba(var(--rule-rgb), 0.25);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------- Секции ---------- */
section {
    padding: 96px 0;
}

.section-head {
    max-width: 640px;
    margin-bottom: 56px;
}

.section-head .eyebrow {
    color: var(--accent);
    margin-bottom: 14px;
    display: block;
}

.section-head h2 {
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1.12;
    margin-bottom: 16px;
}

.section-head p {
    color: var(--text-muted);
    font-size: 16.5px;
}

/* ---------- Карточка-«рукопись» ----------
   Базовая форма. Наклон, отступы и размер текста задаются на странице:
   на лендинге карточка крупнее и повёрнута сильнее, чем в кабинете. */
.manuscript {
    position: relative;
    background: var(--surface-raised);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
}

.manuscript::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background: repeating-linear-gradient(180deg, transparent 0 37px, rgba(var(--rule-rgb), 0.06) 37px 38px);
    pointer-events: none;
}

.manuscript-tag {
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}

.manuscript-text {
    font-family: var(--serif);
    font-style: italic;
    line-height: 1.55;
    /* Стихи: переносы строк значимы, текст хранится сырым (ARCHITECTURE.md, 4.4). */
    white-space: pre-wrap;
}

.manuscript-author {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
}

/* ---------- Фильтр по рубрикам ---------- */
.filter-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-pill {
    font-family: var(--sans);
    font-size: 13.5px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 999px;
    border: 1.5px solid rgba(var(--rule-rgb), 0.16);
    color: var(--text-muted);
    cursor: pointer;
    transition: all .2s ease;
    background: transparent;
}

.filter-pill:hover {
    border-color: var(--brand-dark);
}

.filter-pill.active {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: var(--text-on-brand);
}

/* ---------- Полоса призыва ---------- */
.cta-band {
    background: var(--surface-raised);
    border-radius: 24px;
    padding: 64px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.cta-band h2 {
    font-family: var(--serif);
    font-size: clamp(28px, 4vw, 40px);
    margin-bottom: 16px;
}

.cta-band p {
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 32px;
    font-size: 16px;
}

.cta-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.cta-actions.left {
    justify-content: flex-start;
}

/* ---------- Подвал ---------- */
footer {
    background: var(--brand-dark);
    color: var(--text-muted-on-brand);
    padding: 56px 0 32px;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 36px;
    margin-bottom: 28px;
    border-bottom: 1px solid rgba(237, 233, 218, 0.12);
    flex-wrap: wrap;
    gap: 24px;
}

.footer-logo-mark {
    height: 26px;
    width: auto;
    margin-bottom: 10px;
    /* логотип одноцветный — на тёмном подвале перекрашиваем в белый */
    filter: brightness(0) invert(1);
}

.footer-about {
    font-size: 13.5px;
    max-width: 280px;
}

.footer-links {
    display: flex;
    gap: 48px;
    flex-wrap: wrap;
}

.footer-links h4 {
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brand);
    margin-bottom: 14px;
    font-weight: 500;
}

.footer-links ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 9px;
    font-size: 14px;
}

.footer-links a:hover {
    color: var(--text-on-brand);
}

.footer-bottom {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    flex-wrap: wrap;
    gap: 12px;
}

/* ---------- Появление при скролле ---------- */
.reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s ease, transform .7s ease;
}

.reveal.in {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Полное меню требует около 1000px полезной ширины. Прячем его раньше, чем
   браузер начнёт переносить двухсловные пункты или теснить блок кабинета. */
@media (max-width:1100px) {
    .nav-links {
        display: none;
    }
}

@media (max-width:920px) {
    .cta-band {
        padding: 40px 24px;
    }
}

@media (max-width:560px) {
    section {
        padding: 64px 0;
    }

    /* Шапка на телефоне: логотип + иконка кабинета + кнопка. С подписью
       «Кабинет» и десктопными отступами кнопка не влезает даже в 390px. */
    .nav {
        padding: 16px 20px;
        gap: 16px;
    }

    .header-actions {
        gap: 14px;
    }

    .cabinet-link-label {
        display: none;
    }

    .footer-top {
        flex-direction: column;
    }
}
