/* ====== Тема и базовые стили ====== */
:root {
  --brand: #3f51b5;
  --bg: #f2f3f5;
  --text: #111;
  --muted: #666;
  --card: #fff;
}

html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
.layout { flex: 1; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
img, video { max-width: 100%; height: auto; border-radius: 6px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
p { margin: .6em 0; }
/* Якоря не прячутся под липкой шапкой */
h2, h3, h4 { scroll-margin-top: 84px; }

/* ====== Подвал ====== */
.site-footer { margin-top: 40px; }
.site-footer .wrap {
  max-width: 980px; margin: 0 auto; padding: 12px 20px;
  font-size: 0.85em;
}
.site-footer p { margin: 0; }

/* ====== Шапка ====== */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  background: var(--brand); color: #fff;
}
.site-header .wrap {
  display: flex; align-items: center; gap: 16px;
  max-width: 980px; margin: 0 auto; padding: 12px 20px;
}
.brand a { color: #fff; font-weight: 700; text-decoration: none; }
.site-tagline { color: rgba(255,255,255,0.75); font-size: 0.75em; display: block; margin-top: 2px; }

/* Скрыто визуально, но доступно для поисковиков и скринридеров */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Поиск в шапке (форма Pagefind) */
.site-search { display: flex; gap: 8px; margin-left: auto; }
.site-search input[type="search"] {
  width: 100%;
  max-width: 420px;
  padding: 6px 10px;
  border: 1px solid #d6d8e0;
  border-radius: 999px;
}
.site-search button {
  border: 1px solid #d6d8e0;
  background: #eef2ff;
  color: #3f51b5;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

/* ====== Макет (контейнер) ====== */
/* По умолчанию — одна колонка, лента по центру. Сайдбар показывается сверху
   на узких экранах, чтобы не мешал чтению. */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 20px;
}

/* Когда архив раскрыт — включаем 2 колонки на средних ширинах */
.layout.side-open { grid-template-columns: 260px minmax(0, 1fr); }

/* Сайдбар — позиционирование и стили */
.sidebar { position: sticky; top: 72px; align-self: start; }
.archive summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.08rem;
}
.year-list { list-style: none; padding: 8px 0 0; margin: 0; }
.year-list li { margin: 6px 0; }
.year-list a { text-decoration: none; }
.year-list a:hover { text-decoration: underline; }

/* Соцсети в сайдбаре */
.social-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
}
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-radius: 8px;
  text-decoration: none;
  color: #1f2937;
  font-weight: 600;
  font-size: .95rem;
  transition: background-color .15s ease, color .15s ease;
  align-self: flex-start;
}
.social-link svg {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}
.social-link:hover { text-decoration: none; }
.social-link--youtube { color: #c4302b; }
.social-link--youtube:hover { background: #fde8e7; color: #a21b17; }
.social-link--telegram { color: #0088cc; }
.social-link--telegram:hover { background: #e3f2fd; color: #006699; }
/* Неактивная страница — приглушённый серый */
.social-link--inactive { color: #9ca3af; opacity: .7; }
.social-link--inactive:hover { background: #f3f4f6; color: #6b7280; opacity: 1; }

/* ====== Левая панель (очень широкие экраны) ======
   На очень широких экранах выносим сайдбар отдельно слева,
   чтобы он не сдвигал и не опускал основную ленту. Контент остаётся по центру. */
@media (min-width: 1360px) {
  /* На больших экранах всегда одна центральная колонка,
     а .sidebar превращаем в независимую колонку слева. */
  .layout, .layout.side-open { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;                 /* выводим из потока, не смещает контент */
    top: 72px;                       /* отступ под фиксированную шапку */
    left: calc(50vw - 660px);        /* 50vw - (380 контент-полуширина + 20 зазор + 260 ширина сайдбара) */
    width: 260px;
    max-height: calc(100vh - 96px);  /* чтобы сайдбар полностью помещался */
    overflow: auto;
    z-index: 10;
  }
}

/* ====== Карточки постов ====== */
main { max-width: 760px; margin: 0 auto; padding: 0; }
.post {
  background: var(--card);
  border-radius: 8px;
  padding: 18px;
  margin: 20px auto;
  max-width: 760px;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.post h1,
.post h2,
.post h2 a {
  color: var(--text);
}
.post h2 { margin-top: 0; }
.post .date { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }

/* Фото, подставленные скриптом */
.post-photo { margin: 8px 0; }
.post-photo img { display: block; max-width: 100%; height: auto; border-radius: 6px; }

/* Пейджер (навигация страниц ленты) */
.pager { display: flex; gap: 12px; justify-content: center; margin: 24px 0; }
.pager a {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 999px;
  padding: 8px 14px; text-decoration: none;
}
.pager a:hover { background: #f3f4f6; }

/* ====== VK Comments (кнопка и контейнеры) ====== */
.vkcom-bar { display: flex; justify-content: flex-end; margin-top: 8px; }
.vkcom-toggle {
  border: 1px solid #d6d8e0;
  background: #eef2ff;
  color: #3f51b5;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .9rem;
  cursor: pointer;
}
.vkcom-toggle.loading { opacity: .6; cursor: progress; }
.vkcom-box { margin-top: 8px; border-top: 1px dashed #e5e7eb; padding-top: 8px; }
.vkcom-list .item {
  background: #fff;
  border: 1px solid #eef0f4;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.vkcom-list .item a { color: #3f51b5; }
.vkcom-list .item__tertiary { color: #666; font-size: .85rem; margin-top: 6px; }
.vkcom-list img { max-width: 100%; height: auto; border-radius: 6px; }

/* ====== Адаптив для мобильных ====== */
@media (max-width: 900px) {
  .layout, .layout.side-open { grid-template-columns: 1fr; }
  .sidebar { position: static; } /* возвращаем обычный поток */
}
@media (max-width: 720px) {
  .site-header .wrap { gap: 10px; padding: 10px 12px; }
  .searchbox { flex: 1 1 auto; min-width: 140px; }
  .post { margin: 12px auto; padding: 14px; max-width: 100%; }
}
/* assets/css/styles.css */
.pagefind-ui__result-metadata { margin-top: 6px; font-size: .9rem; color:#666; }
/* если хотите показывать только значение без «date:» */
.pagefind-ui__result-metadata dt { display:none; }


/* ====== Sidebar navigation (Статьи и т.д.) ====== */
.articles-nav { margin-bottom: 4px; }

/* ====== Articles listing ====== */
.articles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}
.article-card {
  background: var(--card);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.article-card__meta .date {
  font-size: 0.8rem;
  color: var(--muted);
}
.article-card__title {
  font-size: 1.1rem;
  margin: 0;
  line-height: 1.4;
}
.article-card__title a {
  color: var(--text);
  text-decoration: none;
}
.article-card__title a:hover {
  text-decoration: underline;
}
.article-card__desc {
  font-size: 0.9rem;
  color: #555;
  margin: 0;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.article-tag {
  background: #eef2ff;
  color: var(--brand);
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Article layout extras */
.article-description {
  font-size: 1.05rem;
  color: var(--muted);
  font-style: italic;
  border-left: 3px solid var(--brand);
  padding-left: 12px;
  margin: 0.5em 0 1.2em;
}
.article-back {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.9rem;
}

figure.media { margin: 1.25rem 0; }
figure.media img, figure.media video {
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
figure.media-audio {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  padding: 0.9rem 1rem;
  background: #f7f8fc;
  border: 1px solid #dbe1f4;
  border-radius: 12px;
}
figure.media-audio audio {
  width: 100%;
  max-width: 100%;
  min-height: 40px;
  height: 40px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
figure.media-audio figcaption {
  text-align: center;
  font-weight: 600;
  color: #4b5563;
}
figure.media-youtube {
  max-width: 100%;
}
figure.media-youtube .youtube-card {
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: 16 / 9;
  color: #fff;
  text-decoration: none;
}
figure.media-youtube .youtube-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}
figure.media-youtube .youtube-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 1rem;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.5));
  transition: background 0.18s ease;
}
figure.media-youtube .youtube-card:hover .youtube-card-overlay,
figure.media-youtube .youtube-card:focus-visible .youtube-card-overlay {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.38));
}
figure.media-youtube .youtube-play {
  width: 68px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 0, 0, 0.92);
  position: relative;
  flex: 0 0 auto;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}
figure.media-youtube .youtube-play::before {
  content: "";
  position: absolute;
  left: 28px;
  top: 14px;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #fff;
}
figure.media-youtube .youtube-card-text {
  font-weight: 700;
  font-size: 1.05rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
figure.media-youtube .youtube-card:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.95);
  outline-offset: 3px;
}
@media (max-width: 640px) {
  figure.media-youtube .youtube-card-overlay {
    gap: 10px;
  }
  figure.media-youtube .youtube-play {
    width: 58px;
    height: 42px;
    border-radius: 12px;
  }
  figure.media-youtube .youtube-play::before {
    left: 24px;
    top: 12px;
    border-top-width: 9px;
    border-bottom-width: 9px;
    border-left-width: 14px;
  }
  figure.media-youtube .youtube-card-text {
    font-size: 0.95rem;
  }
}
/* Vertical videos: keep a reasonable viewport-friendly size */
figure.media-video video {
  width: auto;
  max-width: min(100%, 480px);
  max-height: 75vh;
}
figure.media figcaption { color: #666; font-size: .9rem; margin-top: .4rem; }

/* ── User-text block (raw HTML override in posts) ── */
.user-text { margin: .5rem 0 .75rem; font-size: .95rem; color: #1e293b; }
.user-text p { margin: .35rem 0; }

/* ── Film / Telegram full-version button ── */
a.film-fullver {
  display: inline-block;
  margin-top: .5rem;
  padding: .45rem 1.1rem;
  background: #1e293b;
  color: #f1f5f9 !important;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
a.film-fullver:hover { background: #0f172a; }

/* ====== Подпись «Из дневника» на коротких постах ====== */
.post-vk-origin {
  margin: 28px 0 0;
  padding: 10px 16px;
  font-size: .85rem;
  color: var(--muted);
  border-left: 3px solid rgba(63, 81, 181, .3);
  border-radius: 0 6px 6px 0;
  background: rgba(63, 81, 181, .04);
}
.post-vk-origin__icon {
  margin-right: 6px;
}

/* ====== 404: Граница №1 поста ====== */
.error-404 {
  display: flex;
  align-items: stretch;
  gap: 48px;
  max-width: 1400px;
  margin: 20px auto 40px;
  padding: 0 24px;
  min-height: calc(100vh - 140px);
}

/* Левая колонка — картинка */
.error-404__art {
  flex: 0 0 62%;
  margin: 0;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #0a1420;
  align-self: center;
  box-shadow:
    0 0 0 2px rgba(94, 234, 212, .35),
    0 0 0 10px rgba(15, 23, 42, .92),
    0 30px 80px -16px rgba(0, 0, 0, .7),
    0 0 120px -40px rgba(94, 234, 212, .35);
  outline: 1px solid rgba(94, 234, 212, .22);
  outline-offset: -18px;
  transition: transform .4s ease, box-shadow .4s ease;
}
.error-404__art:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 2px rgba(94, 234, 212, .5),
    0 0 0 10px rgba(15, 23, 42, .92),
    0 36px 90px -16px rgba(0, 0, 0, .75),
    0 0 160px -40px rgba(94, 234, 212, .55);
}
.error-404__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-height: calc(100vh - 120px);
  border-radius: 0;
  margin: 0;
}

/* Правая колонка — контент */
.error-404__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 0;
  text-align: left;
}

.error-404__code {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: clamp(72px, 9vw, 120px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #5eead4 0%, #38bdf8 50%, #6366f1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.error-404__title {
  margin: 6px 0 14px;
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 700;
  color: var(--text);
}

.error-404__subtitle {
  margin: 0 0 24px;
  font-size: clamp(14px, 1.3vw, 16px);
  line-height: 1.65;
  color: var(--muted);
}

.error-404__nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 20px;
}
.error-404__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  border: 1.5px solid rgba(15, 23, 42, .12);
  transition: transform .15s, border-color .15s, box-shadow .15s, filter .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.error-404__btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, .55);
  box-shadow: 0 6px 18px -8px rgba(56, 189, 248, .55);
}
.error-404__btn svg { flex: none; }

.error-404__nav .error-404__btn {
  justify-content: center;
}

.error-404__btn--primary {
  grid-column: 1 / -1;
  justify-content: center;
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px -6px rgba(56, 189, 248, .6);
}
.error-404__btn--primary:hover {
  color: #fff;
  filter: brightness(1.07);
  border-color: transparent;
}

.error-404__hint {
  margin: 0 0 16px;
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
}
.error-404__hint a {
  color: var(--muted);
  border-bottom: 1px dashed rgba(102,102,102,.4);
}
.error-404__hint a:hover {
  color: var(--brand);
  border-bottom-color: var(--brand);
  text-decoration: none;
}

.error-404__ps {
  margin: 0;
  padding: 14px 18px;
  font-size: .83rem;
  line-height: 1.55;
  color: var(--muted);
  background: rgba(94, 234, 212, .06);
  border-left: 3px solid rgba(56, 189, 248, .55);
  border-radius: 0 8px 8px 0;
}
.error-404__ps-label {
  font-weight: 700;
  color: #0ea5e9;
  letter-spacing: .04em;
  margin-right: 4px;
}
.error-404__ps-quote {
  display: inline;
  font-style: italic;
  color: var(--text);
  quotes: none;
}
.error-404__ps-quote::before,
.error-404__ps-quote::after { content: ""; }
.error-404__ps-wink {
  display: inline-block;
  margin-top: 3px;
  font-size: .8rem;
  color: rgba(102,102,102,.8);
}

/* Планшет: чуть уменьшаем картинку */
@media (max-width: 1100px) {
  .error-404 { gap: 32px; }
  .error-404__art { flex: 0 0 56%; outline-offset: -14px; }
}

/* Мобильные: стек */
@media (max-width: 760px) {
  .error-404 {
    flex-direction: column;
    gap: 24px;
    min-height: auto;
    padding: 0 16px;
  }
  .error-404__art {
    flex: none;
    outline-offset: -10px;
    border-radius: 12px;
  }
  .error-404__art img { max-height: 60vw; }
  .error-404__content { text-align: center; }
  .error-404__nav { justify-content: center; }
}

