/* ============================================================
   deeno-news — тема deeno в фирменной стилистике «deeno UI»:
   светлый холст, индиго-акцент #4F6EF7, серые Tailwind, тонкие
   границы (hairline), плоские карточки, шрифт Inter. Светлый режим.
   Собственный код.
   ============================================================ */

@font-face {
  font-family: 'Inter';
  src: url('/themes/default/assets/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/themes/default/assets/fonts/InterVariable-Italic.woff2') format('woff2');
  font-weight: 100 900; font-style: italic; font-display: swap;
}

:root {
  --canvas: #f9fafb;   --paper: #ffffff;   --frost: #f3f4f6;
  --ink: #111827;      --ink-soft: #1f2937; --mid: #4b5563;  --steel: #6b7280;   --fog: #9ca3af;
  --line: #f3f4f6;     --line-2: #e5e7eb;
  --accent: #4F6EF7;   --accent-deep: #435DD2;  --accent-soft: rgba(79,110,247,.1);
  --radius: 6px;       --radius-card: 12px;
  --shadow: 0 1px 2px rgba(17,24,39,.04);
  --shadow-pop: 0 10px 15px -3px rgba(17,24,39,.1), 0 4px 6px -4px rgba(17,24,39,.1);
  --side-w: 224px;
}

/* Тёмная тема сайта — палитра deeno UI dark (как в дашборде) */
:root[data-theme="dark"] {
  --canvas: #0F1117;   --paper: #1A1D27;   --frost: #252837;
  --ink: #F9FAFB;      --ink-soft: #E5E7EB; --mid: #D1D5DB;  --steel: #9CA3AF;   --fog: #6B7280;
  --line: #2D3144;     --line-2: #374151;
  --accent-soft: rgba(79,110,247,.2);
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --shadow-pop: 0 20px 25px -5px rgba(0,0,0,.5), 0 10px 10px -5px rgba(0,0,0,.4);
}
/* Плавный переход при переключении */
body, .side, .brick, .search-trigger, .side__rss, .mobilebar { transition: background-color .2s, border-color .2s, color .2s; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; line-height: 1.65; color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.02em; margin: 0 0 .5em; }

.preview-bar {
  background: var(--accent); color: #fff; text-align: center;
  font-size: 13px; padding: 8px; position: sticky; top: 0; z-index: 50;
}

/* ── Каркас: сайдбар + контент ── */
.shell { display: flex; align-items: flex-start; min-height: 100vh; }

.side {
  width: var(--side-w); flex: none;
  position: sticky; top: 0; height: 100vh;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
/* Шапка сайдбара: название, слоган, поиск */
.side__head { flex: none; padding: 20px 16px; }
.side__logo { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
.side__logo:hover { color: var(--ink); }
.side__logo-img { height: 26px; width: auto; max-width: 40px; flex: none; object-fit: contain; border-radius: 4px; }
.side__tagline { margin: 6px 0 0; font-size: 13px; color: var(--steel); line-height: 1.5; }

/* Оверлей и мобильная шапка — только на узких экранах */
/* Подложка мобильного меню — absolute, НЕ fixed. Safari 26 игнорирует
   theme-color и красит свои панели по background-color фиксированных и липких
   элементов; полупрозрачный fixed-слой давал серую нижнюю панель, а обратно
   цвет не пересчитывался (сэмплинг идёт при отрисовке, правки из JS его не
   запускают). Абсолютные элементы в выборку не попадают. Чтобы absolute
   покрывал вьюпорт при любой прокрутке, на время открытого меню страница
   фиксируется классом .is-locked (он же убирает прокрутку фона под меню). */
.overlay { display: none; position: absolute; top: var(--lock-y, 0px); left: 0; right: 0; height: 100vh; background: rgba(17, 24, 39, .45); z-index: 90; }
body.is-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
.mobilebar { display: none; }
/* Бургер как в админке: серая заливка --frost, без рамки, иконка --ink */
.burger {
  display: inline-flex; width: 40px; height: 40px; flex: none; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius); background: var(--frost); color: var(--ink); cursor: pointer;
}
.burger svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.mobilebar__logo { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.mobilebar__logo-img { height: 24px; width: auto; max-width: 36px; flex: none; object-fit: contain; border-radius: 4px; }

/* ── Поиск: как jump-trigger в админке (серый фон, тонкая рамка) ── */
.search-trigger {
  flex: 1; min-width: 0; height: 38px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--canvas); color: var(--fog);
  font: inherit; font-size: 14px; cursor: pointer;
  transition: border-color .15s;
}
.search-trigger:hover { border-color: var(--line-2); }
.search-trigger svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.side__nav { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 2px; padding: 0 12px 12px; }
.side__nav a {
  display: block; padding: 8px 12px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; color: var(--mid);
  transition: background .15s, color .15s;
}
.side__nav a:hover { background: var(--frost); color: var(--ink); }
.side__nav a.active { background: var(--accent-soft); color: var(--accent); }
.side__group {
  font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em;
  color: var(--fog); padding: 16px 12px 4px;
}

.side__footer { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 8px 14px 14px; }
/* Переключатели темы и языка (как .sidebar__tools дашборда): тема слева, язык справа */
.side__tools { display: flex; align-items: center; }
.side__theme, .side__lang {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; border-radius: var(--radius);
  padding: 6px; font: inherit; font-size: 12px; font-weight: 500; color: var(--fog);
  cursor: pointer; transition: background .15s, color .15s;
}
.side__theme:hover, .side__lang:hover { background: var(--frost); color: var(--steel); }
.side__theme svg, .side__lang svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side__lang { margin-left: auto; }   /* язык — к правому краю */
/* moon в светлой теме, sun — в тёмной */
.side__theme .theme-sun { display: none; }
:root[data-theme="dark"] .side__theme .theme-moon { display: none; }
:root[data-theme="dark"] .side__theme .theme-sun { display: block; }
.side__bottom { display: flex; align-items: center; gap: 8px; }
.side__rss {
  flex: none; display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--canvas); color: var(--fog);
  transition: border-color .15s, color .15s;
}
.side__rss svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side__rss:hover { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ── Правая колонка: контент ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* absolute, а не fixed — по той же причине, что и .overlay: Safari 26 красит
   свои панели по фону фиксированных элементов. Работает в паре с .is-locked
   на body: страница зафиксирована со сдвигом -lockedY, поэтому слой смещаем
   обратно через --lock-y, иначе при прокрученной странице он уезжает вверх
   за экран вместе с полем ввода.
   z-index выше drawer (100) и его подложки (90) — иначе поиск, открытый из
   бокового меню, оказывается ПОД ним. */
.search-overlay {
  position: absolute; top: var(--lock-y, 0px); left: 0; right: 0; height: 100vh; z-index: 120;
  background: rgba(17, 24, 39, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 20px;
}
.search-overlay[hidden] { display: none; }
.search-box {
  width: min(560px, 100%); background: var(--paper);
  border-radius: 8px; box-shadow: var(--shadow-pop); padding: 8px;
}
.search-box__field {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px; border-bottom: 1px solid var(--line);
}
.search-box__icon {
  width: 18px; height: 18px; flex: none; color: var(--fog);
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.search-box__field input {
  flex: 1; min-width: 0; border: none; background: none;
  /* 16px обязательны: на поле мельче Safari в iOS автоматически зумит страницу
     при фокусе, и сайт остаётся увеличенным. Меньше делать нельзя. */
  font-family: inherit; font-size: 16px; color: var(--ink); padding: 8px 0;
}
.search-box__field input:focus { outline: none; box-shadow: none; }
.search-box__field input::placeholder { color: var(--fog); }
.search-box kbd {
  flex: none; font-family: inherit; font-size: 11px; font-weight: 500; color: var(--fog);
  background: var(--frost); border-radius: 4px; padding: 2px 6px; white-space: nowrap;
}
.search-box__hint { margin: 0; padding: 10px 12px 6px; font-size: 13px; color: var(--fog); }

/* ── Контент: как .content админки — padding 24px, во всю ширину ── */
.content { flex: 1; min-width: 0; padding: 24px; }
/* статья и «похожие» — узкая колонка для чтения, по центру рабочей области */
.content > .entry, .content > .related { max-width: 760px; margin-inline: auto; }

/* Шапка списка (поиск/тег/рубрика) */
.list-head { margin-bottom: 20px; }
.list-head__eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.list-head h1 { font-size: 28px; margin: 0; }
.list-head__meta, .list-head__lead { margin: 10px 0 0; color: var(--steel); font-size: 15px; }
.list-empty { color: var(--steel); }

/* ── Сетка карточек ── */
.bricks {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 24px;
}
.brick {
  background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--radius-card);
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s;
}
.brick:hover { box-shadow: var(--shadow-pop); transform: translateY(-2px); }
.brick__thumb { display: block; aspect-ratio: 16 / 9; background: var(--frost); }
.brick__thumb img { width: 100%; height: 100%; object-fit: cover; }
.brick__body { padding: 18px 20px 20px; display: flex; flex-direction: column; flex: 1; }
.brick__meta { margin: 0 0 8px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--fog); }
.brick__meta a { color: var(--accent); font-weight: 600; }
.brick__meta span { flex: none; white-space: nowrap; }
.brick__title { font-size: 19px; margin: 0 0 8px; }
.brick__title a { color: var(--ink); transition: color .12s; }
.brick__title a:hover { color: var(--accent); }
.brick__excerpt { color: var(--mid); font-size: 15px; }
.brick__excerpt p { margin: 0; }
.brick__more { margin-top: 14px; align-self: flex-start; font-size: 14px; font-weight: 600; color: var(--accent); }
.brick__more:hover { color: var(--accent-deep); }

/* ── Пагинация ── */
/* Снизу 0: у контентной колонки уже есть свой отступ 24px, иначе набегает двойной */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 24px auto 0; }
.pagination__num, .pagination__arrow {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 8px; border-radius: var(--radius);
  font-size: 14px; color: var(--mid); border: 1px solid transparent; transition: background .12s, color .12s;
}
.pagination__num:hover, .pagination__arrow:hover { background: var(--accent-soft); color: var(--accent); }
.pagination__num.current { background: var(--accent); color: #fff; }

/* ── Одиночный пост ── */
.entry { max-width: 760px; }
.entry__cover { margin: 0 0 28px; border-radius: var(--radius-card); overflow: hidden; border: 1px solid var(--line-2); }
.entry__cover img { width: 100%; }
.entry__head { margin-bottom: 24px; }
.entry__title { font-size: 38px; margin: 0 0 12px; }
.entry__meta { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--fog); margin: 0; }
.entry__meta a { color: var(--accent); font-weight: 600; }
.entry__content { font-size: 17px; color: var(--ink-soft); }
.entry__content > * + * { margin-top: 1.1em; }
.entry__content h2 { font-size: 26px; margin-top: 1.6em; }
.entry__content h3 { font-size: 21px; margin-top: 1.4em; }
.entry__content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.entry__content ul, .entry__content ol { padding-left: 1.3em; }
.entry__content li { margin: .3em 0; }
.entry__content blockquote {
  margin: 1.4em 0; padding: 4px 18px; border-left: 3px solid var(--accent);
  color: var(--mid); font-style: italic;
}
.entry__content code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .88em;
  background: var(--frost); padding: 2px 6px; border-radius: 4px;
}
.entry__content pre {
  background: #1f2937; color: #e5e7eb; padding: 16px 18px; border-radius: var(--radius);
  overflow-x: auto; font-size: 14px;
}
.entry__content pre code { background: none; padding: 0; color: inherit; }
.entry__content img { border-radius: var(--radius); border: 1px solid var(--line); }
/* Таблица со скруглёнными углами (как код/картинки): внешняя рамка + радиус,
   внутренние линии — правым/нижним бордюром ячеек; overflow скругляет углы */
.entry__content table {
  display: block; width: fit-content; max-width: 100%; overflow-x: auto; font-size: 15px;
  border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--line-2); border-radius: var(--radius);
}
.entry__content th, .entry__content td {
  border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  padding: 8px 12px; text-align: left;
}
.entry__content th:last-child, .entry__content td:last-child { border-right: none; }
.entry__content tr:last-child td { border-bottom: none; }
.entry__content th { background: var(--frost); font-weight: 600; }
.entry__content hr { border: none; border-top: 1px solid var(--line-2); margin: 2em 0; }
.entry__tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }
.entry__tags a {
  font-size: 13px; color: var(--steel); background: var(--frost);
  padding: 4px 12px; border-radius: 999px; transition: background .12s, color .12s;
}
.entry__tags a:hover { background: var(--accent-soft); color: var(--accent); }

/* ── Похожие ── */
.related { max-width: 760px; margin: 56px auto 0; border-top: 1px solid var(--line-2); padding-top: 32px; }
.related__title { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--steel); margin-bottom: 18px; }
.related__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 20px; }
.related__item { background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .15s; }
.related__item:hover { box-shadow: var(--shadow-pop); }
.related__thumb { display: block; aspect-ratio: 16/9; background: var(--frost); }
.related__thumb img { width: 100%; height: 100%; object-fit: cover; }
.related__item h3 { margin: 0; padding: 14px 16px 6px; font-size: 15px; }
.related__item h3 a { color: var(--ink); transition: color .12s; }
.related__item h3 a:hover { color: var(--accent); }
.related__date { margin: 0; padding: 0 16px 14px; font-size: 12px; color: var(--fog); }

/* ── Подвал контента ── */
.content__footer {
  border-top: 1px solid var(--line); padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 13px; color: var(--steel);
}
.content__social { display: flex; gap: 14px; align-items: center; list-style: none; margin: 0; padding: 0; }
.content__social a { display: inline-flex; color: var(--fog); transition: color .12s; }
.content__social a:hover { color: var(--accent); }
.content__social svg { display: block; width: 18px; height: 18px; }

/* ── Плавающая кнопка «Редактировать» ── */
.edit-fab {
  /* Отступы как у всплывающих элементов админки (16px), плюс запас под
     нижнюю панель браузера на телефонах */
  position: fixed; z-index: 40;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-pop);
}
.edit-fab:hover { background: var(--accent-deep); }
.edit-fab svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── 404 ── */
.error-page { max-width: 560px; margin: 12vh auto; text-align: center; padding: 40px; }
.error-page__code { font-size: 72px; font-weight: 800; color: var(--accent); margin: 0; letter-spacing: -0.04em; }
.error-page h1 { font-size: 24px; margin: 8px 0 12px; }
.error-page__text { color: var(--steel); }
.error-page__home { color: var(--accent); font-weight: 600; }

/* ============================================================
   Конструкции контента (редактор + плагины) — под палитру deeno UI
   ============================================================ */
mark { background: #fde68a; color: #111827; padding: 0 3px; border-radius: 3px; }
.c-red { color: #dc2626; } .c-orange { color: #ea580c; } .c-yellow { color: #ca8a04; }
.c-green { color: #16a34a; } .c-blue { color: #2563eb; } .c-purple { color: #7c3aed; } .c-gray { color: #6b7280; }
.md-left { text-align: left; } .md-center { text-align: center; } .md-right { text-align: right; } .md-justify { text-align: justify; }
.md-video { position: relative; padding-bottom: 56.25%; height: 0; margin: 1.6em 0; }
.md-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }
.dn-toc a:hover, .dn-share a:hover { color: var(--accent); }

/* ============================================================
   Мобильная версия: сайдбар — выезжающий слева drawer + оверлей
   (поведение как в админке: бургер слева, меню открывается слева)
   ============================================================ */
@media (max-width: 860px) {
  /* Ширина drawer — 2/3 экрана, как сайдбар админки на мобильном */
  :root { --side-w: 66.6667vw; }
  /* Сайдбар — фиксированный drawer за левым краем экрана */
  .side {
    position: fixed; top: 0; bottom: 0; height: auto;
    left: calc(-1 * var(--side-w)); z-index: 100;
    transition: left .22s ease; border-right: 1px solid var(--line-2);
    box-shadow: var(--shadow-pop);
  }
  .shell.sidebar-open .side { left: 0; }
  .shell.sidebar-open .overlay { display: block; }

  /* Мобильная шапка с бургером слева */
  .mobilebar {
    display: flex; align-items: center; gap: 12px;
    height: 56px; padding: 0 16px;
    background: var(--paper); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 40;
  }

  .main { min-height: 100vh; }
  .content { padding: 16px; }
  .content__footer { padding: 16px; }
  .entry__title { font-size: 30px; }
  .list-head h1 { font-size: 24px; }
}
