/* ==========================================================================
   Matanza - Mastering Website Horizons
   Editorial Blog Theme
   ========================================================================== */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,800;1,400;1,600&family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- CSS Variables --- */
:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --color-bg: #faf8f5;
  --color-bg-alt: #f2ede6;
  --color-surface: #ffffff;
  --color-text: #2c2520;
  --color-text-secondary: #6b5e54;
  --color-text-muted: #9a8d82;
  --color-accent: #c45d3e;
  --color-accent-hover: #a84830;
  --color-accent-light: #f8e8e2;
  --color-border: #e5ddd4;
  --color-border-light: #efe9e1;
  --color-category: #c45d3e;

  --shadow-sm: 0 1px 3px rgba(44, 37, 32, 0.06);
  --shadow-md: 0 4px 16px rgba(44, 37, 32, 0.08);
  --shadow-lg: 0 8px 32px rgba(44, 37, 32, 0.10);
  --shadow-card: 0 2px 8px rgba(44, 37, 32, 0.05), 0 0 1px rgba(44, 37, 32, 0.08);
  --shadow-card-hover: 0 8px 28px rgba(44, 37, 32, 0.12), 0 0 1px rgba(44, 37, 32, 0.10);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --max-width: 1200px;
  --content-width: 780px;
  --sidebar-width: 340px;
  --gap: 40px;

  --header-height: 56px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-accent-hover);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

ul, ol {
  padding-left: 1.5em;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
}

::selection {
  background: var(--color-accent-light);
  color: var(--color-accent-hover);
}

/* --- Utility --- */
.wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.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;
}

/* --- Sticky Navigation Bar --- */
.primary-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-light);
  height: var(--header-height);
  transition: box-shadow 0.3s ease;
}

.primary-nav.scrolled {
  box-shadow: var(--shadow-md);
}

.primary-nav .wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text);
}

.nav-logo img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.nav-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.nav-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Search Overlay --- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(44, 37, 32, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.search-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.search-box {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 8px;
  width: 90%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  transform: translateY(-10px);
  transition: transform 0.25s ease;
}

.search-overlay.active .search-box {
  transform: translateY(0);
}

.search-box input {
  width: 100%;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 18px;
  padding: 12px 16px;
  background: transparent;
  color: var(--color-text);
}

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

.search-results {
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  display: block;
  padding: 14px 16px;
  border-top: 1px solid var(--color-border-light);
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.15s ease;
}

.search-result-item:hover {
  background: var(--color-bg);
}

.search-result-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--color-heading);
}

.search-result-excerpt {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.search-no-results {
  padding: 20px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 14px;
  border-top: 1px solid var(--color-border-light);
}

/* --- Site Header / Branding --- */
.site-header {
  text-align: center;
  padding: 20px 24px 16px;
  position: relative;
}

.site-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 2px;
  background: var(--color-accent);
  border-radius: 2px;
}

.site-logo {
  display: inline-block;
  margin-bottom: 8px;
}

.site-logo svg {
  width: 48px;
  height: 48px;
}

.site-logo img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.site-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
  color: var(--color-text);
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-description {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --- Main Layout --- */
.site-content {
  padding: 48px 0 80px;
}

.site-content .wrapper {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--gap);
  align-items: start;
}

/* --- Floating Side Ads --- */
.side-ad {
  position: fixed;
  top: calc(var(--header-height) + 24px);
  z-index: 10;
  width: 160px;
}

.side-ad-left {
  left: 12px;
}

.side-ad-right {
  right: 12px;
}

@media (max-width: 1600px) {
  .side-ad {
    display: none;
  }
}

/* --- Article Cards (Homepage) --- */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.post-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  animation: fadeInUp 0.5s ease backwards;
}

.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.15s; }
.post-card:nth-child(4) { animation-delay: 0.2s; }
.post-card:nth-child(5) { animation-delay: 0.25s; }

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

.post-card-image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.post-card:hover .post-card-image img {
  transform: scale(1.03);
}

/* Placeholder images using gradients */
.post-card-image .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: white;
  text-align: center;
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.placeholder-1 { background: linear-gradient(135deg, #c45d3e 0%, #e8936f 50%, #d4724e 100%); }
.placeholder-2 { background: linear-gradient(135deg, #3e7ac4 0%, #6fa4e8 50%, #4e87d4 100%); }
.placeholder-3 { background: linear-gradient(135deg, #3ec488 0%, #6fe8b3 50%, #4ed497 100%); }
.placeholder-4 { background: linear-gradient(135deg, #8e3ec4 0%, #b86fe8 50%, #9e4ed4 100%); }
.placeholder-5 { background: linear-gradient(135deg, #c4a03e 0%, #e8c86f 50%, #d4b34e 100%); }
.placeholder-6 { background: linear-gradient(135deg, #c43e6b 0%, #e86f95 50%, #d44e7a 100%); }
.placeholder-7 { background: linear-gradient(135deg, #3ec4c4 0%, #6fe8e8 50%, #4ed4d4 100%); }
.placeholder-8 { background: linear-gradient(135deg, #5d3ec4 0%, #876fe8 50%, #6d4ed4 100%); }
.placeholder-9 { background: linear-gradient(135deg, #c4793e 0%, #e8a36f 50%, #d48c4e 100%); }
.placeholder-10 { background: linear-gradient(135deg, #3e5dc4 0%, #6f87e8 50%, #4e6dd4 100%); }

.post-card-body {
  padding: 24px 28px 28px;
}

.post-card-category {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-category);
  background: var(--color-accent-light);
  padding: 3px 10px;
  border-radius: 3px;
  margin-bottom: 12px;
}

.post-card-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.post-card-title a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.post-card-meta .meta-author a {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.post-card-meta .meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-text-muted);
}

.post-card-excerpt {
  font-size: 15px;
  line-height: 1.7;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-excerpt p {
  margin: 0;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: 0.02em;
  transition: gap 0.2s ease;
}

.read-more:hover {
  gap: 10px;
  color: var(--color-accent-hover);
}

.read-more svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.read-more:hover svg {
  transform: translateX(2px);
}

/* --- Sidebar --- */
.sidebar {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.widget {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.widget-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-border-light);
  position: relative;
}

.widget-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 32px;
  height: 2px;
  background: var(--color-accent);
}

/* Search Widget */
.widget-search .search-form {
  display: flex;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.widget-search .search-form:focus-within {
  border-color: var(--color-accent);
}

.widget-search .search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  background: transparent;
  color: var(--color-text);
}

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

.widget-search .search-btn {
  border: none;
  background: var(--color-accent);
  color: white;
  padding: 10px 16px;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  transition: background 0.2s ease;
}

.widget-search .search-btn:hover {
  background: var(--color-accent-hover);
}

/* Recent Posts Widget */
.recent-posts-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recent-posts-list li {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border-light);
}

.recent-posts-list li:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.recent-posts-list a {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.5;
  display: block;
  transition: color 0.2s ease;
}

.recent-posts-list a:hover {
  color: var(--color-accent);
}

/* Recent Comments Widget */
.no-comments {
  font-size: 14px;
  color: var(--color-text-muted);
  font-style: italic;
}

/* --- Ad Block --- */
.ad-block {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-block-header {
  max-width: var(--max-width);
  margin: 0 auto 0;
  padding: 0 24px;
}

.ad-block-header .ad-block {
  margin-top: -16px;
  margin-bottom: 16px;
}

.ad-block-inline {
  margin: 16px 0;
}

.ad-block-sidebar .ad-block {
  min-height: 250px;
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 32px 0;
  text-align: center;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--color-text-muted);
}

.footer-inner a {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.footer-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color-text-muted);
}

/* --- Scroll to Top --- */
.scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
  z-index: 50;
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-top:hover {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

.scroll-top svg {
  width: 20px;
  height: 20px;
}

/* --- Article Page --- */
.article-page-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--gap);
  align-items: start;
}

.article-page {
  max-width: var(--content-width);
  margin: 0;
  padding: 0;
}

.article-header {
  padding: 48px 0 32px;
  text-align: center;
}

.article-header .post-card-category {
  margin-bottom: 16px;
}

.article-title {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 14px;
  color: var(--color-text-muted);
}

.article-featured-image {
  margin-bottom: 40px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.article-featured-image .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Article Content */
.article-content {
  padding-bottom: 60px;
}

.article-content h2 {
  font-size: 28px;
  font-weight: 700;
  margin: 40px 0 16px;
  letter-spacing: -0.01em;
}

.article-content h3 {
  font-size: 22px;
  font-weight: 600;
  margin: 32px 0 12px;
}

.article-content p {
  margin-bottom: 18px;
  font-size: 17px;
  line-height: 1.75;
}

.article-content ul, .article-content ol {
  margin-bottom: 18px;
  padding-left: 1.5em;
}

.article-content li {
  margin-bottom: 8px;
  line-height: 1.7;
}

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

.article-content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: rgba(196, 93, 62, 0.3);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}

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

.article-content img {
  border-radius: var(--radius-md);
  margin: 24px 0;
  box-shadow: var(--shadow-sm);
}

/* Article Navigation */
.article-nav {
  border-top: 1px solid var(--color-border);
  padding: 32px 0;
  margin-top: 20px;
}

.article-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--color-accent);
}

.article-nav a:hover {
  gap: 12px;
}

/* --- Mobile Off-Canvas --- */
.mobile-menu-toggle {
  display: none;
}

.offcanvas {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100%;
  background: var(--color-surface);
  z-index: 300;
  box-shadow: var(--shadow-lg);
  transition: left 0.3s ease;
  padding: 24px;
}

.offcanvas.active {
  left: 0;
}

.offcanvas-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 37, 32, 0.5);
  z-index: 299;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.offcanvas-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border-light);
}

.offcanvas-close {
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-secondary);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 280px;
    --gap: 28px;
  }
}

@media (max-width: 860px) {
  .site-content .wrapper,
  .article-page-wrapper {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .site-title {
    font-size: 34px;
  }

  .article-title {
    font-size: 30px;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .site-header {
    padding: 40px 16px 36px;
  }

  .site-title {
    font-size: 28px;
  }

  .site-logo img {
    width: 60px;
    height: 60px;
  }

  .post-card-body {
    padding: 18px 20px 22px;
  }

  .post-card-title {
    font-size: 20px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .article-title {
    font-size: 26px;
  }

  .article-content h2 {
    font-size: 24px;
  }

  .article-content h3 {
    font-size: 19px;
  }

  .wrapper {
    padding: 0 16px;
  }

  .footer-inner {
    flex-direction: column;
    gap: 8px;
  }

  .footer-dot {
    display: none;
  }
}
