/*
Theme Name: Adaptive Grid Theme
Theme URI: https://example.com/adaptive-grid-theme
Description: Responsive WordPress theme with dark/light modes, likes/dislikes, rating, sorting, and grid layout.
Version: 1.0
Text Domain: adaptive-grid-theme
*/

/* === ПЕРЕМЕННЫЕ === */
:root {
  --z-base: 1;
  --z-overlay: 100;
  --z-header: 1000;
  --z-dropdown: 1100;
  --z-modal: 2000;
  --bg-color: #121212;
  --text-color: #e5e5e5;
  --search-bg: #2c2b2b;
  --search-icon: #ffffff; 
  --subnav-link: #333;
  --subnav-border: #4e3d3d;
  --card-bg: #1e1e1e;
  --accent-color: #e24258;
  --read-more: #2c2b2b;
  --footer-tag-btn: #2c2b2b;
  --border-color: #333;
  --shadow-sm: 0 3px 10px rgba(0,0,0,0.2);
  --shadow-md: 0 12px 28px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.4);
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius-lg: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --accent-color-rgb: 255, 69, 0;
}

html.light-mode {
  --bg-color: #f8fafc;
  --text-color: #000000;
  --search-bg: #f8fafc;
  --search-icon: #202020;
  --search-text: #222222;
  --subnav-link: #ffffff;
  --subnav-border: #e0e0e0;
  --card-bg: #fff;
  --accent-color: #e24258;
  --read-more: #ffffff;
  --footer-tag-btn: #f3f3f3;
  --border-color: #ddd;
  --shadow-sm: 0 3px 10px rgba(0,0,0,0.07);
  --shadow-md: 0 12px 28px rgba(0,0,0,0.12);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.15);
  --accent-color-rgb: 255, 69, 0;
}

/* === ОТКЛЮЧАЕМ ПЕРЕХОДЫ ПРИ ПЕРВОЙ ЗАГРУЗКЕ === */
html.no-transition *,
html.no-transition *::before,
html.no-transition *::after {
  transition: none !important;
  animation: none !important;
}

/* === БАЗОВЫЕ СТИЛИ === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  background: #121212 !important;
  color-scheme: dark;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* === ДОСТУПНОСТЬ === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* === GRID КОНТЕЙНЕР === */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  padding: 24px 20px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Принудительно не меньше 4 колонок на ширине ≥ 1312px */
@media (min-width: 1312px) {
  .grid-container {
    grid-template-columns: repeat(4, minmax(300px, 1fr));
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === ИЗОБРАЖЕНИЯ В КАРТОЧКАХ === */
.compact-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 440px;
}

.post-thumb {
  position: relative;
  width: 100%;
  height: clamp(200px, 35vw, 320px);
  overflow: hidden;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--card-bg);
  display: block;
}

.post-thumb::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #2a2a2a 25%, #333 25%, #333 50%, #2a2a2a 50%, #2a2a2a 75%, #333 75%);
  background-size: 20px 20px;
  animation: shimmer 1.5s infinite linear;
  z-index: 1;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

@keyframes shimmer {
  0% { background-position: 0 0; }
  100% { background-position: 20px 20px; }
}

.post-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  object-position: center;
  transition: transform 0.4s ease, opacity 0.4s ease;
  z-index: 2;
  display: block;
  border: none;
  margin: 0;
  padding: 0;
  opacity: 0;
}

.post-thumb:hover .post-image {
  transform: scale(1.04);
}

.post-image:hover, .action-btn:hover { will-change: transform; }

/* Скрываем shimmer после загрузки */
.post-thumb:not(.loaded)::before { opacity: 1; }
.post-thumb.loaded::before { 
  opacity: 0; 
  pointer-events: none;
}
.post-image { opacity: 0; }
.post-thumb.loaded .post-image { opacity: 1; }

/* ПЕРЕОПРЕДЕЛЯЕМ WordPress-атрибуты */
.post-image[width],
.post-image[height] {
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 768px) {
  .post-thumb { height: 280px; }
  .compact-card { min-height: 380px; }
}

@media (min-width: 1312px) {
  .compact-card { min-height: 460px; }
}

.compact-card .post-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.35;
}

.compact-card .post-title a {
  color: var(--text-color);
  text-decoration: none;
  background: linear-gradient(to right, var(--accent-color), var(--accent-color)) no-repeat;
  background-size: 0% 1.5px;
  background-position: 0 100%;
  transition: background-size 0.3s ease;
}

.compact-card .post-title a:hover {
  color: var(--accent-color);
  background-size: 100% 1.5px;
}

/* === Тайтоы максимум 3 строки === */
.post-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4em;
  max-height: calc(1.4em * 3);
  word-break: break-word;
}

/* Всплывающая подсказка */
.post-title a::after {
  content: attr(data-full-title);
  position: absolute;
  bottom: 100%;
  left: 0;
  transform: translateY(-6px);
  white-space: normal;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.9em;
  line-height: 1.4em;
  max-width: 320px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 10;
}

/* Маленькая стрелочка */
.post-title a::before {
  content: "";
  position: absolute;
  bottom: calc(100% - 6px);
  left: 12px;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  z-index: 9;
}

/* При наведении — показать подсказку */
.post-title a:hover::after,
.post-title a:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(-10px);
}

/* === 📱 Мобильная адаптация === */
@media (max-width: 768px) {
  .post-title {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    overflow: visible;
    text-overflow: unset;
    max-height: none;
    white-space: normal;
  }

  /* Отключаем подсказку на мобильных */
  .post-title a::after,
  .post-title a::before {
    display: none !important;
  }
}

.compact-card .post-excerpt {
  margin: 0;
  font-size: 0.88rem;
  color: var(--accent-color);
  line-height: 1.45;
  flex-grow: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

html.light-mode .compact-card .post-excerpt {
  color: #666;
}

/* === МИНИ-ИНДИКАТОР ГОЛОСА === */
.mini-vote-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  margin-top: 8px;
  opacity: 0;
  transform: translateY(5px);
  transition: all 0.3s ease;
  margin-left: auto;
}

.mini-vote-indicator.voted {
  opacity: 1;
  transform: translateY(0);
}

/* Общий поп-эффект */
.vote-text {
  font-weight: 700;
  margin-top: 3px;
  animation: pop 0.4s ease-out;
}

/* ЕДИНСТВЕННЫЕ правила цвета — теперь невозможно перепутать */
.mini-vote-indicator.voted-like {
  color: #22c55e;           /* красит и иконку, и текст */
}

.mini-vote-indicator.voted-dislike {
  color: #ef4444;           /* красит и иконку, и текст */
}

@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

/* === СОВРЕМЕННЫЙ ХЕДЕР === */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease;
  transform: translateY(0);
  will-change: transform;
}

html.light-mode .site-header {
  border-bottom-color: rgba(0,0,0,0.1);
}

.header-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-branding a {
  text-decoration: none;
  color: var(--text-color);
  font-weight: 700;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-branding .site-description {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #aaa;
  opacity: 0.8;
}

html.light-mode .site-branding .site-description {
  color: #666;
}

.nav-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.0rem;
}

.nav-menu a {
  color: var(--text-color);
  text-decoration: none;
  font-weight: 600;
  padding: 0.5rem 0;
  position: relative;
  transition: color 0.3s ease;
  font-size: 17px;
}

.nav-menu a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-color);
  transition: width 0.3s ease;
}

.nav-menu a:hover::after,
.nav-menu a:focus::after {
  width: 100%;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sort-filter-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 0.5rem 0;
}

.sort-filter-form select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border 0.3s ease;
  max-width: 100%;
}

.sort-filter-form select:focus {
  outline: none;
  border-color: var(--accent-color);
}

.sort-filter-form label {
  font-size: 0.9rem;
  color: var(--text-color);
  white-space: nowrap;
}

.sort-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  margin-top: 14px;
}

/* === Мобильное поведение === */
@media (max-width: 640px) {
  .sort-filter-form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .sort-filter-form label {
    display: block;
    margin-bottom: 4px;
  }

  #sort,
  #category {
    width: 100%;
  }

  #sort {
    margin-bottom: 0.75rem;
  }
}

/* === КНОПКА ПЕРЕКЛЮЧЕНИЯ ТЕМЫ (круглая) === */
.theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  color: var(--text-color);
  overflow: hidden;
}

/* Hover эффект */
.theme-toggle:hover {
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
  border-color: var(--accent-color);
}

/* Иконки внутри */
.theme-toggle .sun,
.theme-toggle .moon {
  font-size: 1.3rem;
  position: absolute;
  transition: 
      opacity 0.35s ease,
      transform 0.35s ease;
  will-change: transform, opacity;
}

/* Начальное состояние (тёмная тема) */
.theme-toggle .sun {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
}

.theme-toggle .moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Светлая тема */
html.light-mode .theme-toggle .sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

html.light-mode .theme-toggle .moon {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
}

/* === МОБИЛЬНЫЕ КНОПКИ === */
.mobile-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Сброс стилей кнопки */
.theme-toggle,
.mobile-menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
}

/* Гамбургер */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 0.5rem;
  transition: transform 0.3s ease;
}

.mobile-menu-toggle span {
  width: 25px;
  height: 3px;
  background: var(--text-color);
  border-radius: 3px;
  transition: 0.3s;
}

/* Анимация гамбургера */
.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Мобильная видимость меню */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
}


/* === ОДИНОЧНЫЙ ПОСТ (single.php) === */
.single-post {
  padding: 0rem 0;
  width: 100%;
  overflow-x: hidden;
}

.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
  margin-top: 20px;
}

@media (max-width: 480px) {
  .container {
    padding: 0 0.75rem;
  }
}

@media (max-width: 360px) {
  .container {
    padding: 0 0.5rem;
  }
}

.post-header {
  margin-bottom: 0.1rem;
  text-align: left;
}

.single-post .post-title {
  font-size: 2.2rem;
  margin: 0 0 1rem;
  line-height: 1.2;
  color: var(--text-color);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: left;
  gap: 1rem;
  font-size: 0.95rem;
  color: #aaa;
  margin-bottom: 1.5rem;
}

html.light-mode .post-meta {
  color: #666;
}

.post-meta a {
  color: var(--accent-color);
  text-decoration: none;
}

.post-meta a:hover {
  text-decoration: underline;
}

/* === FEATURED IMAGE — адаптивное отображение === */
.featured-image {
  text-align: left;
  margin: 1.5em 0;
}

.featured-image img {
  display: inline-block;
  height: auto;
  max-width: 100%;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: transform 0.3s ease;
}

.featured-image img:hover {
  transform: scale(1.02);
}

/* Если изображение меньше контейнера — не растягиваем */
.featured-image img[width][height] {
  width: auto;
  max-width: 100%;
}

/* AMP-версия */
amp-img[layout="responsive"] {
  max-width: 100%;
  height: auto;
}

/* Для узких изображений — не на всю ширину */
@media (min-width: 768px) {
  .featured-image img {
    max-width: min(800px, 100%);
  }
}

.post-content p {
  margin: 0.2rem 0;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 2rem 0 1rem;
  color: var(--text-color);
}

.post-content a {
  color: #e24258;
  text-decoration: underline;
}

.post-content a:hover {
  color: #e5e5e5;
}

html.light-mode .post-content a:hover {
  color: #222121;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 0.5rem 0.2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.post-content blockquote {
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  background: var(--card-bg);
  border-left: 4px solid var(--accent-color);
  border-radius: 0 8px 8px 0;
  font-style: italic;
}

.post-tags {
  margin: 2rem 0;
  line-height: 1.6;
}

.post-tags strong {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

html.light-mode .post-tags strong {
  color: #555;
}

.tags-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tag-button {
  display: inline-block;
  padding: 0.25rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-color);
  background: #2d2b2b;
  border: 1.5px solid rgb(101 100 99 / 35%);
  border-radius: 0.5rem;
  text-decoration: none;
  transition: all 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.tag-button:hover {
  background: var(--accent-color);
  color: #ffffff !important;
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(var(--accent-color-rgb), 0.4);
}

html.light-mode .tag-button {
  background: #f0f0f0;
  border-color: rgb(197 197 197 / 25%);
  color: #2d2d2d;
}

html.light-mode .tag-button:hover {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  box-shadow: 0 6px 16px rgba(255, 69, 0, 0.3);
}

/* === ВЗАИМОДЕЙСТВИЕ === */
.post-interactions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2rem 0;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.post-interactions .likes-dislikes {
  flex: 1;
  max-width: 300px;
  display: flex;
  gap: 0.75rem;
}

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  border: 2px solid var(--accent-color);
  color: var(--accent-color);
  padding: 0.65rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.38s cubic-bezier(0.22, 0.61, 0.36, 1),
    box-shadow 0.38s ease,
    border-color 0.38s ease;
  will-change: transform;
}

.action-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--hover-color, var(--accent-color));
  transform: translateX(-100%);
  transition: transform 0.38s cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: -1;
}

.action-btn .icon,
.action-btn .count {
  position: relative;
  z-index: 1;
  transition: color 0.38s ease;
}

/* === LIKE === */
.action-btn.like-btn {
  --hover-color: #22c55e;
  --active-color: #16a34a;
}

.action-btn.like-btn:hover,
.action-btn.like-btn.voted {
  color: white !important;
  border-color: #22c55e !important;
}

.action-btn.like-btn:hover::before,
.action-btn.like-btn.voted::before {
  background: #22c55e;
  transform: translateX(0);
}

.action-btn.like-btn.voted {
  background: #22c55e !important;
}

.action-btn.like-btn.voted::before {
  background: #16a34a;
}

/* === DISLIKE === */
.action-btn.dislike-btn {
  --hover-color: #ef4444;
  --active-color: #dc2626;
}

.action-btn.dislike-btn:hover,
.action-btn.dislike-btn.voted {
  color: white !important;
  border-color: #ef4444 !important;
}

.action-btn.dislike-btn:hover::before,
.action-btn.dislike-btn.voted::before {
  background: #ef4444;
  transform: translateX(0);
}

.action-btn.dislike-btn.voted {
  background: #ef4444 !important;
}

.action-btn.dislike-btn.voted::before {
  background: #dc2626;
}

/* === ГАРАНТИЯ: БЕЛЫЙ ТЕКСТ ПРИ HOVER И VOTED === */
.action-btn:hover .icon,
.action-btn:hover .count,
.action-btn.voted .icon,
.action-btn.voted .count {
  color: white !important;
}

/* === АНИМАЦИЯ === */
.action-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.22);
}

.action-btn.voted:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 28px rgba(0,0,0,0.28);
}

/* === РЕЙТИНГ === */
.post-rating {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.stars {
  display: inline-flex;
  gap: 2px;
  vertical-align: middle;
}

/* Полная звезда */
.full-star::before {
  content: '★';
  color: gold;
}

/* Половинка звезды */
.half-star::before {
  content: '⭐';
  color: gold;
}

/* Пустая звезда */
.empty-star::before {
  content: '☆';
  color: #555;
}

html.light-mode .empty-star::before { color: #ccc; }

.rating-text {
  color: #aaa;
  font-size: 0.9rem;
}

html.light-mode .rating-text { color: #666; }

.no-rating {
  color: #999;
  font-style: italic;
  font-size: 0.9rem;
}

/* === НАВИГАЦИЯ ПО ПОСТАМ === */
.post-navigation {
  display: flex;
  justify-content: space-between;
  margin: 3rem 0;
  font-size: 0.95rem;
}

.post-navigation a {
  display: block;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-color);
  transition: all 0.3s ease;
  max-width: 100%;
  box-shadow: var(--shadow-sm);
}

.post-navigation a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: var(--accent-color);
  color: white;
}

.post-navigation span {
  display: block;
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.post-navigation strong {
  font-weight: 600;
  font-size: 1rem;
}

/* === КОММЕНТАРИИ === */
.comments-area {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.comment-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.comment {
  background: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.comment-author {
  font-weight: 600;
  color: var(--accent-color);
}

.comment-metadata {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 0.5rem;
}

.comment-content p {
  margin: 0.5rem 0;
}

/* === СОЦКНОПКИ === */
.social-share {
  margin: 2rem 0;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.2s ease;
}

.social-btn:hover {
  transform: translateY(-2px);
}

.social-btn.twitter { background: #1DA1F2; }
.social-btn.facebook { background: #1877F2; }
.social-btn.linkedin { background: #0A66C2; }
.social-btn.pinterest { background: #E60023; }

/* === ПОХОЖИЕ ПОСТЫ === */
.related-posts {
  margin: 3rem 0;
  padding: 2rem 0;
  border-top: 1px solid var(--border-color);
}

.related-posts h3 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  color: var(--text-color);
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.related-card {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease;
}

.related-card:hover {
  transform: translateY(-4px);
}

.related-thumb {
  display: block;
  overflow: hidden;
}

.related-thumb img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.related-thumb:hover img {
  transform: scale(1.05);
}

.related-card h4 {
  margin: 0.75rem 1rem;
  font-size: 1.1rem;
}

.related-card h4 a {
  color: var(--text-color);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3em;
  max-height: calc(1.3em * 2);
  position: relative;
  cursor: help;
  word-break: break-word;
  transition: color 0.2s ease;
  cursor: pointer;
}

.related-card h4 a:hover {
  color: var(--accent-color);
}

/* Подсказка при наведении */
.related-card h4 a::after {
  content: attr(data-full-title);
  position: absolute;
  bottom: 100%;
  left: 0;
  transform: translateY(-6px);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.4em;
  max-width: 280px;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 10;
}

.related-card h4 a::before {
  content: "";
  position: absolute;
  bottom: calc(100% - 6px);
  left: 12px;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  z-index: 9;
}

.related-card h4 a:hover::after,
.related-card h4 a:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateY(-10px);
}

/* Описание */
.related-excerpt {
  margin: 0 1rem 1rem;
  font-size: 0.9rem;
  color: #aaa;
  line-height: 1.5;
}

html.light-mode .related-excerpt {
  color: #666;
}

/* === AMP ОПТИМИЗАЦИЯ === */
amp-img {
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: block;
  width: 100%;
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 768px) {
  .grid-container {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .post-image {
    height: 200px;
  }

  .compact-card .post-content {
    padding: 0.75rem;
  }

  .compact-card .post-title {
    font-size: 1.1rem;
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    overflow: visible;
    text-overflow: unset;
    max-height: none;
    white-space: normal;
  }

  /* Отключаем подсказку на мобильных */
  .post-title a::after,
  .post-title a::before {
    display: none !important;
  }

  .compact-card .post-excerpt {
    font-size: 0.85rem;
    -webkit-line-clamp: 2;
  }

  .single-post .post-title {
    font-size: 1.8rem;
  }

  .post-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .post-interactions {
    flex-direction: column;
    gap: 1rem;
  }

  .post-interactions .likes-dislikes {
    max-width: 100%;
  }

  .post-navigation {
    flex-direction: column;
    gap: 1rem;
  }

  .post-navigation a {
    max-width: 100%;
  }

  .nav-menu,
  .header-controls {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    flex-direction: column;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
  }

  .nav-menu.active,
  .header-controls.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .header-container {
    padding: 0.75rem 1rem;
  }

  .nav-menu {
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    flex-direction: column;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
  }

  .nav-menu.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav-menu li:first-child {
    margin-top: 0.5rem;
  }
}

@media (max-width: 480px) {
  .post-image {
    height: 140px;
  }
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .35s ease, backdrop-filter .35s ease;
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  z-index: 9990;
}

.mobile-overlay.active {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* === ПОИСК === */
.search-results-page {
  padding: 2rem 0;
}

.page-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.page-title {
  font-size: 2rem;
  margin: 0 0 1rem;
  color: var(--text-color);
}

.page-title span {
  color: var(--accent-color);
  font-weight: 700;
}

.search-form-wrapper {
  max-width: 500px;
  margin: 0 auto;
}

.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: #666;
}

.no-results p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

/* === ПАГИНАЦИЯ === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin: 3.5rem auto 2rem;
  padding: 0 1rem;
  flex-wrap: wrap;
  max-width: 1400px;
  font-family: inherit;
}

.pagination a,
.pagination span {
  min-width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  color: var(--text-color);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.pagination a::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-color);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: -1;
}

.pagination a span,
.pagination span {
  position: relative;
  z-index: 1;
  transition: color 0.35s ease;
}

.pagination a:hover::before {
  transform: scaleX(1);
}

.pagination a:hover {
  color: white !important;
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* Текущая страница */
.pagination .current {
  background: var(--accent-color);
  color: white !important;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  pointer-events: none;
}

/* Кнопки «Предыдущая» и «Следующая» */
.pagination .prev,
.pagination .next {
  font-weight: 700;
  min-width: 120px;
  border: 2px solid var(--accent-color);
  background: transparent;
  color: var(--accent-color);
}

.pagination .prev:hover,
.pagination .next:hover {
  background: var(--accent-color);
  color: white !important;
  border-color: var(--accent-color);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* Точки (...) */
.pagination .dots {
  background: transparent;
  box-shadow: none;
  color: #999;
  cursor: default;
  min-width: auto;
  padding: 0 0.5rem;
}

.pagination .dots:hover {
  transform: none;
  background: transparent;
  color: #999;
}

/* Мобильная адаптация */
@media (max-width: 640px) {
  .pagination {
    gap: 0.5rem;
  }

  .pagination a,
  .pagination span {
    min-width: 42px;
    height: 42px;
    font-size: 0.9rem;
  }

  .pagination .prev,
  .pagination .next {
    min-width: 100px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {

  .pagination .prev span,
  .pagination .next span { display: none; }
}

/* === САЙДБАР === */
.sidebar {
  background: var(--card-bg);
  padding: 1.0rem;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  height: fit-content;
  position: sticky;
  top: 2rem;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.widget {
  background: var(--bg-color);
  padding: 1.25rem;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.widget-title {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  color: var(--accent-color);
  font-weight: 600;
  position: relative;
  padding-bottom: 0.5rem;
}

.widget-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--accent-color);
}

/* Виджеты */
.widget ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.widget ul li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.widget ul li:last-child {
  border-bottom: none;
}

.widget ul li a {
  color: var(--text-color);
  text-decoration: none;
  transition: color 0.3s ease;
}

.widget ul li a:hover {
  color: var(--accent-color);
}

/* Адаптивность */
@media (max-width: 992px) {
  .sidebar {
    position: static;
    margin-top: 2rem;
  }
}

/* === КОНТЕНТ + САЙДБАР === */
.content-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  align-items: start;
}

.box-main-content {
  background: var(--card-bg);
  padding: 16px;
  border-radius: 14px;
  width: 100%;
  box-sizing: border-box;
}

.main-content {
  order: 1;
  background: var(--bg-color);
  padding: 0.5rem 1.2rem;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

@media (max-width: 480px) {
  .box-main-content {
    padding: 12px;
  }

  .main-content {
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 360px) {
  .box-main-content {
    padding: 8px;
  }

  .main-content {
    padding: 0.5rem;
  }
}

.sidebar .widget {
  background: var(--bg-color);
  padding: 1.25rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.sidebar .widget-title {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  color: var(--accent-color);
  font-weight: 600;
  position: relative;
  padding-bottom: 0.5rem;
}

.sidebar .widget-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--accent-color);
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 992px) {
  .content-with-sidebar {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .sidebar {
    order: 1;
    position: static;
    margin-top: 2rem;
  }

  .main-content {
    order: 2;
  }
}

@media (max-width: 768px) {
  .content-with-sidebar {
    gap: 1.5rem;
  }
}

/* === УЛУЧШЕНИЯ КАРТОЧКИ === */
.compact-card:nth-child(1) { animation-delay: 0.1s; }
.compact-card:nth-child(2) { animation-delay: 0.2s; }
.compact-card:nth-child(3) { animation-delay: 0.3s; }

/* Больше отступа между картинкой и контентом */
.post-content {
  padding: 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-grow: 1;
  position: relative;
}

/* Кликабельная категория */
.post-category {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-color);
  background: rgba(var(--accent-color-rgb), 0.1);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  text-decoration: none;
  align-self: flex-start;
  transition: all 0.3s ease;
}

.post-category:hover {
  background: var(--accent-color);
  color: white;
  transform: translateY(-1px);
}

.post-date {
  color: #888;
  font-style: italic;
}

/* Кнопка "Читать далее" */
.read-more-btn {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--read-more);
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 1.1rem;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.read-more-btn:hover {
  background: #ea4e64;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

html.light-mode .read-more-btn:hover {
  background: #e24258;
}

/* Адаптивность кнопки */
@media (max-width: 480px) {
  .read-more-btn {
    width: 100%;
    justify-content: center;
  }

  .post-category {
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
  }
}

.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
}

/* === КРАСИВЫЕ ТЕГИ === */
.widget_tag_cloud,
.tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.5rem 0;
}

.widget_tag_cloud a,
.tagcloud a {
  display: inline-block;
  background: #2d2b2b;
  color: var(--accent-color);
  font-size: 0.9rem !important;
  font-weight: 600;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  transition: all 0.3s ease;
  line-height: 1;
  border: 1px solid #362e2e;
}

.widget_tag_cloud a:hover,
.tagcloud a:hover {
  background: var(--accent-color);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 3px 10px rgba(var(--accent-color-rgb), 0.4);
}

html.light-mode .widget_tag_cloud a,
html.light-mode .tagcloud a {
  background: #f0f0f0;
  color: #333;
  border: 1px solid #e6e6e6;
}

html.light-mode .widget_tag_cloud a:hover,
html.light-mode .tagcloud a:hover {
  background: var(--accent-color);
  color: #fff;
}

/* === СТРАНИЦА ВСЕХ ТЕГОВ === */
.alphabet-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2rem 0;
  justify-content: center;
  font-weight: 600;
}

.alphabet-link {
  display: inline-block;
  width: 40px;
  height: 40px;
  line-height: 40px;
  text-align: center;
  background: var(--card-bg);
  color: var(--text-color);
  border-radius: 50%;
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.alphabet-link:hover,
.alphabet-link[aria-current="true"] {
  background: var(--accent-color);
  color: white;
}

.tag-section {
  margin-bottom: 2.5rem;
}

.tag-letter {
  font-size: 1.8rem;
  margin: 1.5rem 0 1rem;
  color: var(--accent-color);
  border-bottom: 2px solid;
  display: inline-block;
}

.tag-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--card-bg);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-color);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
}

.tag-item:hover {
  background: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.tag-count {
  font-weight: 600;
  opacity: 0.8;
  font-size: 0.85em;
  background: rgba(var(--accent-color-rgb), 0.25);
  padding: 2px 6px;
  border-radius: 4px;
}

.no-tags {
  text-align: center;
  padding: 3rem;
  font-size: 1.1rem;
  color: #666;
}

/* Адаптивность */
@media (max-width: 640px) {
  .tag-letter {
    font-size: 1.3rem;
  }

  .alphabet-link {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
  }
}

/* === ФУТЕР === */
.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 3rem 1rem 1rem;
  margin-top: 3rem;
  transition: background 0.3s ease, color 0.3s ease;
}

.footer-container {
  max-width: 1380px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

/* Заголовки в футере */
.footer-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-color);
  margin-bottom: 0.5rem;
}

.footer-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--accent-color);
}

.footer-text {
  font-size: 0.95rem;
  color: #aaa;
  line-height: 1.6;
}

html.light-mode .footer-text {
  color: #666;
}

/* Меню в футере */
.footer-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-menu li {
  list-style-type: none;
}

.footer-menu a {
  text-decoration: none;
  color: var(--text-color);
  transition: color 0.3s ease;
}

.footer-menu a:hover {
  color: var(--accent-color);
}

/* Теги */
.footer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.footer-tags a {
  background: rgba(var(--accent-color-rgb), 0.08);
  color: var(--text-color);
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.3s ease;
}

.footer-tags a:hover {
  background: var(--accent-color);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(var(--accent-color-rgb), 0.4);
}

/* Соцсети */
.footer-social {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(var(--accent-color-rgb), 0.1);
  color: var(--accent-color);
  transition: all 0.3s ease;
  font-size: 1rem;
  text-decoration: none;
}

.social-icon:hover {
  background: var(--accent-color);
  color: #fff;
  transform: translateY(-2px);
}

/* Форма подписки */
.subscribe-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.subscribe-form input {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-color);
  transition: border 0.3s ease;
}

.subscribe-form input:focus {
  outline: none;
  border-color: var(--accent-color);
}

.subscribe-form button {
  background: var(--accent-color);
  color: #fff;
  border: none;
  padding: 0.65rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.subscribe-form button:hover {
  background: #4CAF50;
  transform: translateY(-2px);
}

html.light-mode .subscribe-form button:hover {
  background: #4CAF50;
}

/* Нижняя полоса */
.footer-bottom {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: #777;
}

html.light-mode .footer-bottom {
  color: #aaa;
}

/* Адаптивность */
@media (max-width: 768px) {
  .footer-container {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .footer-container {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-social {
    justify-content: center;
  }

  .subscribe-form {
    align-items: center;
  }

  .subscribe-form input {
    width: 100%;
    max-width: 280px;
  }
}

/* === КНОПКА "ВВЕРХ" === */
#backToTop {
  position: fixed;
  bottom: calc(1.8rem + env(safe-area-inset-bottom, 0));
  right: 1rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 4px 15px rgba(var(--accent-color-rgb), 0.4);
  cursor: pointer;
  opacity: 0;
  transform: translateY(40px);
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 999;
}

#backToTop svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
}

#backToTop.show {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

#backToTop:hover {
  background: #e03e00;
  transform: translateY(-3px);
}

html.light-mode #backToTop:hover {
  background: #e03e00;
}

@media (min-width: 768px) {
  #backToTop { bottom: 1.8rem; }
}

/* === СТИЛЬ ФОРМЫ КОММЕНТАРИЕВ === */
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.comment-form input:invalid { border-color: #ef4444; }
.comment-form input:valid { border-color: #22c55e; }
.comment-form p {
  margin: 0;
  width: 100%;
  max-width: 100%;
}

.comment-form label {
  display: block;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form textarea {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.comment-form input:focus,
.comment-form textarea:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(58, 140, 255, 0.3);
  outline: none;
}

.comment-form textarea {
  resize: vertical;
  min-height: 120px;
}

.submit-button {
  align-self: flex-start;
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
}

.submit-button:hover {
  background: #4CAF50;
  transform: translateY(-2px);
}

.comment-form-comment label {
  display: none;
}

.comment-form textarea::placeholder {
  color: #888;
}

/* === ВИДЖЕТ: ПОПУЛЯРНЫЕ ПОСТЫ === */
.widget-popular-posts ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.popular-post-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  transition: transform 0.2s ease;
}

.popular-post-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.popular-post-item:hover {
  transform: translateX(4px);
}

.popular-post-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  width: 100%;
}

.popular-thumb {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.popular-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.popular-post-item:hover .popular-thumb img {
  transform: scale(1.1);
}

.popular-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.popular-title {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
}

.popular-title a {
  color: inherit;
  text-decoration: none;
}

.popular-title a:hover {
  color: var(--accent-color);
}

.popular-category {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--accent-color);
  background: rgba(var(--accent-color-rgb), 0.12);
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 4px;
  max-width: fit-content;
}

.popular-views {
  font-size: 0.8rem;
  color: #bbb;
  font-weight: 500;
}

html.light-mode .popular-views {
  color: #888;
}

.popular-views::before {
  content: "👁 ";
  margin-right: 4px;
  opacity: 0.7;
}

/* Адаптивность */
@media (max-width: 992px) {
  .popular-thumb {
    width: 100px;
    height: 100px;
  }

  .popular-title {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .popular-post-item {
    gap: 10px;
    padding: 10px 0;
  }

  .popular-thumb {
    width: 100px;
    height: 100px;
  }

  .popular-title {
    font-size: 0.85rem;
  }

  .popular-category {
    font-size: 0.6rem;
  }
}

/* === SUBHEADER MENU === */
.subnav-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 10px 0;
  list-style: none;
  margin: 0;
}

.subnav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.8rem;
  font-weight: 500;
  font-size: 15px;
  color: var(--text-color);
  border-radius: 12px;
  transition: all 0.3s ease;
  text-decoration: none;
  background: var(--subnav-link);
  border: 1px solid var(--subnav-border);
  white-space: nowrap;
}

.subnav-link:hover,
.subnav-item.current-menu-item .subnav-link {
  background: var(--accent-color) !important;
  color: white !important;
  box-shadow: 0 4px 12px rgba(255, 69, 0, 0.3);
}

/* Десктоп: выпадающее подменю */
.has-submenu {
  position: relative;
}

.submenu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.3s ease;
  padding: 12px 0;
  margin-top: 8px;
  z-index: 1001;
}

.has-submenu:hover > .submenu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.submenu .subnav-link {
  padding: 10px 20px;
  margin: 0 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  justify-content: flex-start;
}

.submenu .subnav-link:hover {
  background: rgba(var(--accent-color-rgb), 0.15);
}

/* === МОБИЛЬНАЯ ВЕРСИЯ (≤868px) === */
@media (max-width: 868px) {
  .subnav-menu {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 12px;
    padding: 12px 16px;
  }

  /* Главные пункты */
  .subnav-link {
    flex: 1 1 auto;
    min-width: 120px;
    justify-content: center;
    font-size: 14px;
    padding: 0.6rem 0.9rem;
  }

  /* Выпадашки превращаются в аккордеон */
  .has-submenu {
    position: relative;
  }

  .submenu {
    position: static;
    transform: none;
    background: transparent;
    box-shadow: none;
    padding: 8px 0 0;
    margin-top: 4px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    display: none;
    width: 100%;
  }

  .has-submenu.open > .submenu {
    display: block;
  }

  .submenu .subnav-link {
    margin: 0;
    padding: 0.7rem 1.5rem;
    font-size: 14px;
    background: rgba(var(--accent-color-rgb), 0.08);
    border-radius: 10px;
  }

  .submenu .subnav-link:hover {
    background: rgba(var(--accent-color-rgb), 0.2);
  }
}

/* === ОПТИМИЗАЦИЯ: ПЕРЕХОДЫ === */
html:not(.no-transition) {
  --global-transition: background-color .3s ease, 
                       border-color .3s ease, 
                       color .3s ease;
}

/* === АДАПТАЦИЯ ДЛЯ СЛАБЫХ УСТРОЙСТВ === */
@media (prefers-reduced-motion: reduce) {
  .post-thumb::before { display: none; }
  * { animation: none !important; transition-duration: .01ms !important; }
}

/* === БЕЗОПАСНЫЙ BACKDROP === */
@supports not (backdrop-filter: blur(0)) {
  .site-header { background: var(--card-bg); }
  .mobile-overlay.active { background: rgba(0,0,0,0.85); }
}

.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;
}

/* Дополнительно: убираем конфликт с --read-more в светлой теме */
.read-more-btn {
  background: var(--read-more);
  color: #fff;
}
/*
html.light-mode .read-more-btn {
  background: #ffffff;
  color: #1b1b1b;
}
*/
/* Плавность как у Apple 2025 */
.read-more-btn,
.post-category {
  will-change: transform, background, box-shadow;
}

/* === Горизонтальное выравнивание картинок === */
.post-content figure {
  display: inline-block;
  margin: 8px;
  text-align: center;
}

.post-content figure img {
  height: auto;
  border-radius: 8px;
}

.post-content figcaption {
  font-size: 0.8rem;
  color: #666;
  margin-top: 4px;
}

/* === ГОРИЗОНТАЛЬНАЯ ГАЛЕРЕЯ СКРИНШОТОВ === */
.screenshot-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin: 0.5rem 0;
    padding: 0.5rem 0;
    justify-content: flex-start;
    align-items: start;
}

.screenshot-gallery .screenshot-link {
    display: block;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: max-content;
}

.screenshot-gallery .screenshot-link:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    z-index: 2;
}

.screenshot-gallery .bbcode-img,
.screenshot-gallery img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 220px;
    display: block;
    border-radius: 10px;
    transition: transform 0.3s ease;
}

.screenshot-gallery .screenshot-link:hover .bbcode-img,
.screenshot-gallery .screenshot-link:hover img {
    transform: scale(1.03);
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .screenshot-gallery {
        gap: 0.75rem;
    }
    .screenshot-gallery .bbcode-img,
    .screenshot-gallery img {
        max-height: 180px;
    }
}

@media (max-width: 480px) {
    .screenshot-gallery {
        grid-template-columns: 1fr;
        justify-content: center;
        gap: 0.5rem;
    }
    .screenshot-gallery .screenshot-link {
        margin: 0 auto;
    }
    .screenshot-gallery .bbcode-img,
    .screenshot-gallery img {
        max-height: 160px;
        max-width: 100%;
    }
}

/* === ИСПРАВЛЕНИЯ ДЛЯ УЗКИХ ЭКРАНОВ === */
@media (max-width: 480px) {
  .comment-form {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .comment-form input[type="text"],
  .comment-form input[type="email"],
  .comment-form textarea {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .comment-form p {
    width: 100%;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .comment-form .comment-form-author,
  .comment-form .comment-form-email,
  .comment-form .comment-form-url {
    width: 100%;
    float: none;
    margin-right: 0;
  }

  .submit-button {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* === ЭКСТРЕМАЛЬНО УЗКИЕ ЭКРАНЫ (менее 360px) === */
@media (max-width: 360px) {
  .single-post {
    padding: 0;
    margin: 0;
  }

  .container {
    padding: 0 8px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .box-main-content {
    padding: 8px !important;
    margin: 0;
    border-radius: 8px;
  }

  .main-content {
    padding: 0.5rem !important;
  }

  /* Форма комментариев - экстремальные меры */
  .comment-form * {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .comment-form input,
  .comment-form textarea {
    font-size: 16px !important;
  }

  /* Исправление для чекбокса "Save my name..." */
  .comment-form-cookies-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
  }

  .comment-form-cookies-consent input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    flex-shrink: 0;
    margin-top: 2px;
  }

  .comment-form-cookies-consent label {
    font-size: 0.8rem;
    line-height: 1.3;
  }
}

/* === ДОПОЛНИТЕЛЬНАЯ ЗАЩИТА ОТ ВЫПАДАНИЯ === */
@media (max-width: 320px) {
  html, body {
    min-width: 280px;
    overflow-x: hidden;
  }

  .single-post * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Принудительное ограничение для всех контейнеров */
  .container > * {
    max-width: 100% !important;
  }

  /* Особое внимание к длинным словам */
  .post-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
  }

  .comment-form label {
    font-size: 0.85rem;
  }
}

/* === ИСПРАВЛЕНИЕ ДЛЯ WordPress-SPECIFIC ЭЛЕМЕНТОВ === */
.comment-body {
  width: 100%;
  max-width: 100%;
}

.comment-meta,
.comment-content {
  width: 100%;
  max-width: 100%;
}

/* Гарантия что комментарии не вылазят */
.comment-list .comment {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Исправление для reply ссылок */
.comment-reply-link {
  white-space: nowrap;
  font-size: 0.8rem;
}

@media (max-width: 360px) {
  .comment-reply-link {
    font-size: 0.75rem;
    padding: 4px 8px;
  }
}

body.menu-open {
  overflow: hidden;
  touch-action: none;
}

/* Дополнительная страховка для iOS */
body.menu-open .site-header,
body.menu-open .mobile-overlay.active {
  position: fixed;
  width: 100%;
}

/* === BREADCRUMBS – ПОЛНАЯ СОВМЕСТИМОСТЬ С ТЕМОЙ === */
.breadcrumbs {
    font-size: 0.92rem;
    margin: 1.2rem 0 0.5rem;
    padding: 0 1rem;
    color: #aaa;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    line-height: 1.4;
    overflow: hidden;
}

html.light-mode .breadcrumbs {
    color: #666;
}

.breadcrumbs a {
    color: inherit;
    text-decoration: none;
    padding: 0.15rem 0;
    border-bottom: 1px solid transparent;
    transition: all 0.25s ease;
    opacity: 0.9;
}

.breadcrumbs a:hover {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    opacity: 1;
}

.breadcrumbs .sep {
    color: #777;
    font-weight: 700;
    user-select: none;
    opacity: 0.7;
}

html.light-mode .breadcrumbs .sep {
    color: #999;
}

.breadcrumbs .current {
    color: var(--text-color);
    font-weight: 600;
    opacity: 1;
}

html.light-mode .breadcrumbs .current {
    color: #222;
}

/* Маленькая стрелочка вместо текста (по желанию) */
.breadcrumbs .sep {
	content: '→';
    font-size: 1.0em;
}

/* Если хочешь стрелку потоньше */
.breadcrumbs .sep::before {
    margin: 0 0.4rem;
    font-weight: 400;
    opacity: 0.7;
}

/* Адаптивность */
@media (max-width: 640px) {
    .breadcrumbs {
        font-size: 0.88rem;
        gap: 0.4rem 0.8rem;
        padding: 0 0.75rem;
    }
}

@media (max-width: 480px) {
    .breadcrumbs {
        margin: 1rem 0;
        font-size: 0.85rem;
    }
}
/* ✅ ДОБАВЛЕНО: Стили для печати */
@media print {
  /* Скрываем ненужные элементы */
  .site-header,
  .site-footer,
  .sidebar,
  .post-interactions,
  .social-share,
  .post-navigation,
  .related-posts,
  .comments-area,
  #backToTop,
  .mobile-menu-toggle,
  .theme-toggle,
  .sort-wrapper,
  .breadcrumbs,
  .widget,
  .pagination {
    display: none !important;
  }
  
  /* Оптимизация контента для печати */
  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
    line-height: 1.5;
  }
  
  .container,
  .main-content,
  .post-content {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    background: white !important;
  }
  
  /* Заголовки */
  .post-title,
  h1, h2, h3, h4, h5, h6 {
    color: black !important;
    page-break-after: avoid;
  }
  
  /* Изображения */
  .featured-image img,
  .post-content img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
  
  /* Ссылки - показываем URL */
  .post-content a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
    word-wrap: break-word;
  }
  
  /* Теги */
  .post-tags {
    page-break-inside: avoid;
  }
  
  .tag-button {
    border: 1px solid #ccc !important;
    background: white !important;
    color: black !important;
  }
  
  /* Мета-информация */
  .post-meta {
    color: #666 !important;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }
  
  /* Предотвращаем разрывы страниц */
  blockquote,
  pre,
  figure {
    page-break-inside: avoid;
  }
  
  /* Убираем тени и эффекты */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }
}

/* Печать в альбомной ориентации для широких изображений */
@media print and (orientation: landscape) {
  .featured-image img {
    max-height: 80vh;
  }
}

/* ==========================================
   CSS для уведомлений (добавить в style.css)
   ========================================== */

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.notification {
    font-family: inherit;
    font-size: 0.95rem;
    max-width: 320px;
    word-wrap: break-word;
}

@media (max-width: 640px) {
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}
.statistic {text-align: center;width: fit-content;margin: auto;margin-top: 5px;}