/* ============================================
   Хлебная Библиотека — Design System
   Based on Mealie Connect, Terracotta accent
   ============================================ */

:root {
  /* Colors */
  --bg: #faf6ef;
  --surface: #fffdf9;
  --surface-2: #f3ece1;
  --surface-3: #ebe2d4;

  --text: #171310;
  --text-2: #554b43;
  --muted: #8a7e73;

  --accent: #c9663f;
  --accent-hover: #b85a35;
  --accent-soft: rgba(201, 102, 63, 0.10);
  --accent-glow: rgba(201, 102, 63, 0.35);

  --inverse-bg: #171310;
  --inverse-fg: #fffdf9;
  --band-bg: #12100e;

  --border: rgba(23, 19, 16, 0.09);
  --border-strong: rgba(23, 19, 16, 0.16);
  --hover: rgba(23, 19, 16, 0.05);

  /* Blog colors */
  --crucide: #3b6ea5;
  --crucide-soft: rgba(59, 110, 165, 0.10);
  --solnce-pek: #c9663f;
  --solnce-pek-soft: rgba(201, 102, 63, 0.10);

  /* Favorites */
  --favorite: #d4a017;
  --favorite-soft: rgba(212, 160, 23, 0.12);

  /* Typography */
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Radii */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-2xl: 40px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(23, 19, 16, 0.04);
  --shadow-md: 0 2px 6px rgba(23, 19, 16, 0.05), 0 18px 40px rgba(23, 19, 16, 0.08);
  --shadow-lg: 0 10px 30px rgba(23, 19, 16, 0.08), 0 50px 100px -20px rgba(23, 19, 16, 0.22);
  --shadow-card: 0 10px 30px rgba(23, 19, 16, 0.08), 0 50px 100px -20px rgba(23, 19, 16, 0.18);
  --shadow-accent: 0 14px 30px -14px var(--accent-glow);

  /* Effects */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   HEADER
   ============================================ */
.header {
  background: linear-gradient(135deg, #2a5aa6 0%, #3b6ea5 50%, #4a7fb8 100%);
  color: var(--inverse-fg);
  padding: clamp(20px, 4vw, 32px) clamp(20px, 5vw, 48px);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-emoji {
  font-size: clamp(2rem, 5vw, 2.5rem);
}

.header h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--inverse-fg);
}

.header-subtitle {
  color: rgba(255, 253, 249, 0.6);
  font-size: 14.5px;
  font-weight: 450;
  margin-top: 4px;
}

/* ============================================
   NAVIGATION
   ============================================ */
.nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: clamp(16px, 3vw, 24px) clamp(20px, 5vw, 48px);
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* Search */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  padding: 14px 18px 14px 48px;
  background: var(--surface);
  border: 1px solid rgba(23, 19, 16, 0.12);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
  min-height: 52px;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 20px;
  height: 20px;
}

.clear-search {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius-full);
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  transition: var(--transition);
}

.clear-search:hover {
  background: var(--surface-3);
  color: var(--text);
}

.clear-search.visible {
  display: flex;
}

/* Filters */
.filter-section {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.filter-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.filter-btn {
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 550;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface);
  color: var(--text-2);
  min-height: 40px;
}

.filter-btn:hover {
  background: var(--hover);
  border-color: var(--border-strong);
}

.filter-btn.all {
  background: var(--inverse-bg);
  color: var(--inverse-fg);
  border-color: transparent;
}

.filter-btn.all.active {
  background: var(--inverse-bg);
  box-shadow: var(--shadow-md);
}

.filter-btn.crucide {
  background: var(--crucide-soft);
  color: var(--crucide);
  border-color: transparent;
}

.filter-btn.crucide.active {
  background: var(--crucide);
  color: white;
  box-shadow: 0 8px 20px -8px rgba(59, 110, 165, 0.5);
}

.filter-btn.solnce-pek {
  background: var(--solnce-pek-soft);
  color: var(--solnce-pek);
  border-color: transparent;
}

.filter-btn.solnce-pek.active {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-accent);
}

.filter-btn.favorites {
  background: var(--favorite-soft);
  color: #92700c;
  border-color: transparent;
}

.filter-btn.favorites.active {
  background: var(--favorite);
  color: white;
  box-shadow: 0 8px 20px -8px rgba(212, 160, 23, 0.5);
}

.filter-btn.category {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: transparent;
}

.filter-btn.category.active {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-accent);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px) clamp(20px, 5vw, 48px);
}

.section {
  margin-bottom: clamp(40px, 8vw, 80px);
  animation: fadeIn 0.4s var(--ease);
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.section-icon {
  font-size: clamp(1.8rem, 4vw, 2.2rem);
}

.section-title {
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.section-subtitle {
  font-size: 14px;
  color: var(--accent);
  font-weight: 550;
  margin-top: 2px;
}

.section-count {
  margin-left: auto;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

/* ============================================
   POST CARDS
   ============================================ */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  display: flex;
  flex-direction: column;
  position: relative;
  font-family: var(--font);
  font-size: inherit;
  box-shadow: var(--shadow-sm);
  contain: layout style;
}

.post-card:hover {
  box-shadow: var(--shadow-card);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.post-card-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

.post-arrow {
  color: var(--accent);
  margin-top: 2px;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  opacity: 0.7;
  transition: var(--transition);
}

.post-card:hover .post-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.post-title {
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.4;
  font-weight: 500;
  flex: 1;
}

.post-card:hover .post-title {
  color: var(--accent);
}

.post-blog-badge {
  margin-top: 16px;
  padding-left: 30px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.blog-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

.blog-badge.crucide {
  background: var(--crucide-soft);
  color: var(--crucide);
}

.blog-badge.solnce-pek {
  background: var(--solnce-pek-soft);
  color: var(--accent);
}

.blog-badge.favorite {
  background: var(--favorite-soft);
  color: #92700c;
}

/* Favorite button on card */
.post-favorite-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
  color: var(--muted);
  z-index: 10;
}

.post-card:hover .post-favorite-btn {
  opacity: 1;
}

.post-favorite-btn:hover {
  background: var(--favorite-soft);
  border-color: var(--favorite);
  color: var(--favorite);
  transform: scale(1.08);
}

.post-favorite-btn.active {
  opacity: 1;
  background: var(--favorite);
  color: white;
  border-color: var(--favorite);
  box-shadow: 0 4px 12px -4px rgba(212, 160, 23, 0.4);
}

.post-favorite-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   POST VIEW
   ============================================ */
.post-view {
  display: none;
}

.post-view.active {
  display: block;
}

.post-header {
  background: linear-gradient(135deg, #2a5aa6 0%, #3b6ea5 50%, #4a7fb8 100%);
  color: var(--inverse-fg);
  padding: clamp(24px, 4vw, 40px) clamp(20px, 5vw, 48px);
}

.post-header-content {
  max-width: 900px;
  margin: 0 auto;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 253, 249, 0.7);
  background: rgba(255, 253, 249, 0.08);
  border: 1px solid rgba(255, 253, 249, 0.12);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  transition: var(--transition);
  min-height: 44px;
}

.back-btn:hover {
  color: white;
  background: rgba(255, 253, 249, 0.14);
  border-color: rgba(255, 253, 249, 0.2);
}

.back-icon {
  width: 16px;
  height: 16px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* Теги на странице поста — белый фон с цветной окантовкой */
.post-meta .blog-badge {
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid currentColor;
}

.post-meta .blog-badge.crucide {
  color: #3b6ea5;
}

.post-meta .blog-badge.solnce-pek {
  color: #c9663f;
}

.post-meta .blog-badge.favorite {
  color: #d4a017;
}

.post-category {
  color: rgba(255, 253, 249, 0.6);
  font-size: 13.5px;
  font-weight: 500;
}

.post-subcategory {
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 550;
}

.post-view h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
}

.post-favorite-btn-header {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 253, 249, 0.08);
  border: 1px solid rgba(255, 253, 249, 0.15);
  border-radius: var(--radius-full);
  padding: 10px 18px;
  cursor: pointer;
  transition: var(--transition);
  color: rgba(255, 253, 249, 0.8);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 550;
  min-height: 44px;
}

.post-favorite-btn-header:hover {
  background: rgba(255, 253, 249, 0.14);
  border-color: rgba(255, 253, 249, 0.25);
  color: white;
}

.post-favorite-btn-header.active {
  background: var(--favorite);
  color: white;
  border-color: var(--favorite);
  box-shadow: 0 8px 20px -8px rgba(212, 160, 23, 0.5);
}

.post-favorite-btn-header svg {
  width: 16px;
  height: 16px;
}

/* Post body */
.post-body {
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px) clamp(20px, 5vw, 48px);
}

.post-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: clamp(24px, 5vw, 48px);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-2);
}

.post-content p {
  margin-bottom: 1.1em;
}

.post-content p:last-child {
  margin-bottom: 0;
}

.post-content h3.post-subtitle {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 2em;
  margin-bottom: 0.6em;
  padding-bottom: 0.3em;
  border-bottom: 2px solid var(--accent-soft);
  letter-spacing: -0.015em;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  margin: 1.2em 0;
  box-shadow: var(--shadow-md);
}

.post-content .post-image-wrapper {
  text-align: center;
  margin: 1.5em 0;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 3px;
  transition: var(--transition);
}

.post-content a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent);
}

.post-content b,
.post-content strong {
  font-weight: 600;
  color: var(--text);
}

/* Post navigation */
.post-navigation {
  margin-top: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  min-height: 52px;
}

.nav-btn.back {
  background: var(--surface-2);
  color: var(--text);
}

.nav-btn.back:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}

.nav-btn.original {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-accent);
}

.nav-btn.original:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 18px 36px -14px var(--accent-glow);
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  background: linear-gradient(135deg, #2a5aa6 0%, #3b6ea5 50%, #4a7fb8 100%);
  color: rgba(255, 253, 249, 0.7);
  padding: clamp(32px, 6vw, 48px) clamp(20px, 5vw, 48px);
  margin-top: clamp(48px, 10vw, 96px);
  text-align: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.footer p {
  font-size: 14.5px;
  margin-bottom: 8px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 14px;
  color: rgba(255, 253, 249, 0.5);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: clamp(48px, 10vw, 80px) 20px;
}

.empty-emoji {
  font-size: clamp(3rem, 8vw, 4rem);
  margin-bottom: 16px;
}

.empty-text {
  color: var(--muted);
  font-size: 17px;
  font-weight: 500;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
  .posts-grid {
    grid-template-columns: 1fr;
  }

  .post-content {
    font-size: 15.5px;
    padding: 20px;
    border-radius: var(--radius-lg);
  }

  .post-content h3.post-subtitle {
    font-size: 1.15rem;
  }

  .post-view h1 {
    font-size: 1.6rem;
  }

  .post-navigation {
    flex-direction: column;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
  }

  .filter-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

html {
  scroll-behavior: smooth;
}
