/* Flipnet — общее оформление сети. Один файл, без сборщика. */

:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #c7d2fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 30px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header__inner {
  display: flex; align-items: center; gap: 16px 24px;
  /* Высота не фиксируется: названия тем длинные, навигация переносится. */
  min-height: 64px; padding: 10px 0; flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.brand span { color: var(--brand); }
.site-nav { display: flex; gap: 8px 20px; flex: 1 1 320px; flex-wrap: wrap; align-items: center; }
.site-nav a { color: var(--muted); font-weight: 500; font-size: 15px; padding: 4px 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--brand); }
.site-auth { display: flex; align-items: center; gap: 10px; }
.site-auth form { margin: 0; }
.user-chip { font-size: 14px; color: var(--muted); white-space: nowrap; }

.btn, button[type="submit"], input[type="submit"] {
  display: inline-block; border-radius: 8px; padding: 8px 16px;
  font-size: 14px; font-weight: 600; line-height: 1.4; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary, input[type="submit"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover, input[type="submit"]:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

.hero { padding: 52px 0 4px; }
.hero h1 { font-size: 38px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; margin: 0 0 12px; }
.hero p { font-size: 17px; color: var(--muted); margin: 0; max-width: 700px; }

.section { padding-top: 36px; margin-top: 36px; border-top: 1px solid var(--line); }
.section:first-of-type { padding-top: 20px; margin-top: 0; border-top: 0; }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section__head h2 { font-size: 21px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.subhead { font-size: 15px; font-weight: 600; color: var(--muted); margin: 22px 0 12px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card {
  display: block; padding: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: inherit;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
a.card:hover { border-color: var(--brand-soft); box-shadow: var(--shadow); transform: translateY(-2px); }
.card__title { font-weight: 600; font-size: 17px; color: var(--ink); margin-bottom: 4px; }
.card__sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.card__text { color: var(--muted); font-size: 14px; margin: 0; }
.card__foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2ff; color: #3730a3; }
.badge--grey { background: #f1f5f9; color: #475569; }

.muted { color: var(--muted); font-size: 14px; }
/* Колонка текста одной ширины у аннотации, тела и сноски об источнике:
   680 пикселов при 17px — это около восьмидесяти знаков в строке, дальше
   глаз теряет начало следующей строки. */
.lead { font-size: 18px; color: var(--muted); margin: 0 0 20px; max-width: 680px; }
.prose { max-width: 680px; font-size: 17px; line-height: 1.75; }
.prose p { margin: 0 0 1.15em; }
.prose p:last-child { margin-bottom: 0; }
.prose a { color: var(--brand); }
.source-note { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); max-width: 680px; }

.empty { color: var(--muted); font-size: 14px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 20px; margin: 0; }

.site-main { padding-bottom: 56px; min-height: 55vh; }
.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; padding: 32px 0 28px; }
/* Подвал в три колонки: о сайте, категории новостей, направления. Средняя
   шире остальных — категорий два десятка, и они сами идут в три столбца. */
.site-footer__grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2.4fr) minmax(0, 1fr); gap: 28px 40px; align-items: start; }
.site-footer__about p { margin: 10px 0 0; max-width: 28ch; line-height: 1.5; }
.site-footer__title { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
.site-footer__links { list-style: none; margin: 0; padding: 0; }
.site-footer__links li { margin: 0 0 6px; break-inside: avoid; }
.site-footer__links--cols { columns: 3; column-gap: 24px; }
.site-footer__links a { color: var(--muted); }
.site-footer__links a:hover { color: var(--brand); }
.site-footer__soon { color: var(--muted); opacity: .75; }
.site-footer__note { margin: 10px 0 0; font-size: 12px; line-height: 1.45; opacity: .8; }

/* Последние заголовки на главной: две колонки ссылок без карточек. */
.headlines { list-style: none; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 20px; }
.headlines__item { padding: 11px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
/* В двух колонках без нижней линии остаются два последних пункта. */
.headlines__item:nth-last-child(-n+2) { border-bottom: none; }
.headlines__title { color: var(--ink); font-weight: 600; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.headlines__title:hover { color: var(--brand); }
.headlines__meta { color: var(--muted); font-size: 12px; }

/* Стандартная форма входа Django */
form table { border-collapse: collapse; }
form table th { text-align: left; padding: 6px 12px 6px 0; font-weight: 600; color: var(--muted); font-size: 14px; }
form table td { padding: 6px 0; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="number"], select, textarea {
  padding: 8px 12px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); min-width: 280px;
}

@media (max-width: 860px) {
  .site-header__inner { height: auto; padding: 12px 0; flex-wrap: wrap; gap: 12px; }
  .site-nav { order: 3; flex-basis: 100%; gap: 14px; overflow-x: auto; }
  .site-footer__grid { grid-template-columns: minmax(0, 1fr); }
  .site-footer__links--cols { columns: 2; }
  .headlines { grid-template-columns: minmax(0, 1fr); }
  .headlines__item:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .headlines__item:last-child { border-bottom: none; }
  .hero h1 { font-size: 28px; }
}

/* Переключатель языка */
.lang-switch { display: flex; margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.lang-switch button.lang-switch__item {
  border: 0; border-radius: 0; background: transparent;
  padding: 7px 11px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; line-height: 1.2;
}
.lang-switch button.lang-switch__item:hover { background: #f1f5f9; color: var(--ink); }
.lang-switch button.lang-switch__item.is-active { background: var(--brand); color: #fff; }

/* Направления: четыре карточки квадратом 2×2.
   Отдельный класс — лента новостей должна остаться резиновой. */
.grid--square {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 760px;
}
.grid--square .card { display: flex; flex-direction: column; aspect-ratio: 1 / 1; }
.grid--square .card__text { flex: 1; overflow: hidden; }
.grid--square .card__foot { margin-top: auto; }

@media (max-width: 720px) {
  /* На узком экране квадрат разваливается — возвращаем колонку. */
  .grid--square { grid-template-columns: minmax(0, 1fr); max-width: none; }
  .grid--square .card { aspect-ratio: auto; }
}

/* Теги: кнопки-фильтры над лентой и метки на карточках */
.tag-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-filter__item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--muted);
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.tag-filter__item:hover { border-color: var(--brand); color: var(--brand); }
.tag-filter__item.is-active {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}
.tag-filter__count { font-size: 11px; opacity: .65; }
.tag-filter__item.is-active .tag-filter__count { opacity: .85; }

/* Ряд уточнений под полосой: подчинён ей по размеру, иначе два ряда
   одинаковых кнопок читаются как один длинный и непонятно, что к чему. */
.tag-filter--refine { margin-top: 10px; align-items: center; gap: 6px; }
.tag-filter--refine .tag-filter__item {
  padding: 4px 10px; font-size: 12px; border-style: dashed;
}
.tag-filter--refine .tag-filter__item.is-active { border-style: solid; }
.tag-filter__label {
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--muted); text-transform: uppercase; margin-right: 2px;
}

.card__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: #f1f5f9; color: var(--muted); font-size: 12px; line-height: 1.6;
}
a.chip--link:hover { background: var(--brand-soft); color: var(--brand-dark); }

/* Карточка материала: ссылка и кнопка «нравится» — соседи */
.card--article { padding: 0; display: flex; flex-direction: column; }
.card--article .card__link { display: block; padding: 18px 18px 0; color: inherit; }
.card--article:hover { border-color: var(--brand-soft); box-shadow: var(--shadow); transform: translateY(-2px); }
.card--article .card__text { margin-bottom: 0; }
.card__actions { margin-top: auto; padding: 14px 18px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__meta { color: var(--muted); font-size: 13px; text-align: right; margin-left: auto; }
.card__actions form { margin: 0; }

.like-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 500; font-family: inherit; color: var(--muted);
  cursor: pointer; line-height: 1.4;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.like-btn:hover { border-color: #fca5a5; color: #dc2626; }
.like-btn__icon { font-size: 15px; line-height: 1; }
.like-btn.is-liked { border-color: #fca5a5; background: #fef2f2; color: #dc2626; font-weight: 600; }
.like-btn__count { font-size: 12px; opacity: .7; }
a.like-btn--muted { text-decoration: none; }

/* Просмотры: пиктограмма глаза и число. Иконка контурная, в currentColor,
   поэтому садится и в строку под карточкой, и в серую строку над
   заголовком, не требуя отдельного цвета. */
.views { color: var(--muted); font-size: 13px; white-space: nowrap; }
.views__icon {
  width: 15px; height: 15px; display: inline-block; margin-right: 4px;
  /* Сдвиг в em, а не в пикселах: глаз остаётся на базовой линии и когда
     размер шрифта в строке другой. */
  vertical-align: -0.22em;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
/* Табличные цифры: иначе число под карточками прыгает по ширине. */
.views__count { font-variant-numeric: tabular-nums; }

/* --- Комплаенс-маркировки --------------------------------------------------
   Плашка иноагента по требованию идёт обособленным блоком и шрифтом вдвое
   больше основного текста. Основной — 16px (см. body выше), поэтому 32px
   задан числом, а не в em: в em его уменьшил бы контекст (.lead, .prose),
   и «вдвое» перестало бы выполняться. Если менять размер в body — менять
   и здесь. */
.marking-banner {
  font-size: 32px;
  line-height: 1.25;
  font-weight: 700;
  background: #111827;
  color: #fff;
  padding: 16px 20px;
  margin: 0 0 20px;
  border-radius: 8px;
  /* Длинная формулировка не должна выезжать за экран на телефоне. */
  overflow-wrap: anywhere;
}

/* Пометка рядом с названием: читаемая, но не спорит с текстом. */
.marking-inline {
  color: var(--muted);
  white-space: normal;
}

/* Сноски — одним блоком в конце материала. */
.marking-footnotes {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.marking-footnotes p { margin: 0 0 8px; }
