/* =========================================================
   Blog Archive (Premium) — Deliciously Pro
   - Matches global theme variables & components
   - Light/Dark mode friendly
   - Responsive + A11y + ThemeForest-ready
========================================================= */

.tf-blog-archive {
  padding-bottom: clamp(48px, 6vw, 90px);
}

/* ---------------------------
   HERO
--------------------------- */

.tf-blog-hero,
.tf-hero.tf-blog-hero {
  position: relative;
  min-height: clamp(320px, 52vh, 560px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--color-border);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  isolation: isolate;
}

/* Luxury overlay (Dynamic Colors) */
.tf-blog-hero .tf-hero__overlay {
  position: absolute;
  inset: 0;
  /* FIXED: Replaced hardcoded rgba with color-mix to respect user Theme Options */
  background:
    radial-gradient(1200px 500px at 15% 20%, color-mix(in srgb, var(--color-accent), transparent 78%), transparent 55%),
    radial-gradient(900px 420px at 80% 40%, color-mix(in srgb, var(--color-accent), transparent 85%), transparent 60%),
    linear-gradient(180deg, rgba(26, 23, 20, 0.70), rgba(26, 23, 20, 0.55));
}

/* REMOVED: Duplicate .tf-hero__overlay definition causing conflict */

.tf-blog-hero .tf-hero__content {
  position: relative;
  z-index: 2;
  text-align: left;
  padding: clamp(28px, 4.5vw, 56px) 0;
  max-width: 980px;
}

.tf-blog-hero .tf-hero__title {
  margin: 0 0 12px 0;
  color: #fff;
  font-size: clamp(2.05rem, 3.8vw, 3.2rem);
  letter-spacing: -0.03em;
}

.tf-blog-hero .tf-hero__subtitle {
  margin: 0 0 18px 0;
  color: rgba(255, 255, 255, 0.88);
  max-width: 66ch;
  font-size: clamp(1rem, 1.25vw, 1.125rem);
}

.tf-blog-hero .tf-hero__meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--radius-sm, 14px);
  background: rgba(20, 20, 20, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tf-blog-hero .tf-hero__metaItem {
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  font-size: 0.95rem;
}

.tf-blog-hero .tf-hero__dot {
  color: rgba(255, 255, 255, 0.60);
}

/* ---------------------------
   FILTER BAR
--------------------------- */
.tf-blog-filter {
  margin-top: -26px; /* premium overlap on hero */
  margin-bottom: 26px;
  position: relative;
  z-index: 10;
}

.tf-blog-filter__form {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 18px);
  box-shadow: var(--shadow-md);
  padding: 14px;
}

.tf-filter-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.9fr 0.9fr auto;
  gap: 12px;
  align-items: center;
}

.tf-filter-item select,
.tf-filter-item input[type="search"] {
  width: 100%;
  min-height: 44px; /* WCAG Touch Target */
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 14px);
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.12s ease;
  outline: none;
}

.tf-filter-item select:focus,
.tf-filter-item input[type="search"]:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent), transparent 82%);
}

.tf-filter-search input[type="search"]::placeholder {
  color: color-mix(in srgb, var(--color-text-muted), transparent 25%);
}

/* Clear button uses your existing .btn styles if present */
.tf-btn,
.tf-blog-filter .tf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm, 14px);
  font-weight: 700;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.tf-btn:hover {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent), transparent 88%);
}

.tf-btn:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.tf-blog-filter__status {
  margin-top: 10px;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  padding: 0 4px;
}

/* ---------------------------
   RESULTS GRID
--------------------------- */
.tf-blog-results {
  position: relative;
  /* OPTIMIZATION: Improve rendering performance for long lists */
  content-visibility: auto; 
  contain-intrinsic-size: 1000px;
}

.tf-grid-posts,
.tf-grid-events {
  display: grid;
  gap: 22px;
}

.tf-grid-3-2-1 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 992px) {
  .tf-filter-row {
    grid-template-columns: 1fr 1fr;
  }
  .tf-filter-actions {
    grid-column: 1 / -1;
  }
  .tf-grid-3-2-1 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .tf-blog-filter {
    margin-top: -18px;
  }
  .tf-filter-row {
    grid-template-columns: 1fr;
  }
  .tf-grid-3-2-1 {
    grid-template-columns: 1fr;
  }
}
/* =============================
   CONTAINER & GRID
============================= */

.tf-container {
    max-width: 1200px;
    margin-inline: auto;
    width: 100%;
}

.tf-grid {
    display: grid;
    gap: 2rem;
    width: 100%;
}

.tf-grid-3-2-1 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 992px) {
    .tf-grid-3-2-1 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
    .tf-grid-3-2-1 { grid-template-columns: 1fr; }
}

/* =============================
   BASE CARD (SHARED)
============================= */

.tf-card {
    background: var(--tf-bg);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 6px rgba(0,0,0,.05);
    transition: transform .3s ease, box-shadow .3s ease;
}

.tf-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(0,0,0,.08);
}

/* Media */
.tf-card__media {
    aspect-ratio: 16/9;
    overflow: hidden;
}

.tf-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s ease;
}

.tf-card:hover .tf-card__image {
    transform: scale(1.05);
}

/* Content */
.tf-card__content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.tf-card__meta {
    font-size: .85rem;
    color: var(--tf-text-muted);
    margin-bottom: .5rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.tf-card__title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.4;
    margin-bottom: .75rem;
}

.tf-card__title a {
    color: inherit;
    text-decoration: none;
}

.tf-card__title a:hover {
    color: var(--tf-primary);
}

.tf-card__excerpt {
    color: var(--tf-text-muted);
    line-height: 1.6;
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

.tf-card__footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--tf-bg-alt);
}


/* ---------------------------
   POST CARD
--------------------------- */
/* FIXED: Removed duplicate .card styles. 
   Use .tf-post-card as the primary hook. 
   If legacy .card is needed, keep it strictly separate or use a mixin. */

.tf-post-card {
  background: var(--color-surface);
  border: 1px solid color-mix(in srgb, var(--color-border), transparent 25%);
  border-radius: var(--radius-md, 18px);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

.tf-post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--color-accent), var(--color-border) 60%);
}

/* Thumbnail */
.tf-post-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--color-muted-surface);
  overflow: hidden;
}

.tf-post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
  transition: transform 0.6s ease;
}

.tf-post-card:hover .tf-post-thumb img {
  transform: scale(1.08);
}

/* Category badge */
.tf-post-badge {
  position: absolute;
  left: 14px;
  top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm, 14px);
  background: rgba(20, 20, 20, 0.40);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

.tf-post-body {
  padding: 18px 18px 16px;
}

.tf-post-title {
  margin: 0 0 10px 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.tf-post-title a {
  color: var(--color-text);
  text-decoration: none;
}

.tf-post-title a:hover {
  color: var(--color-accent-dark);
}

/* Meta row */
.tf-post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.92rem;
  color: var(--color-text-muted);
}

.tf-post-excerpt {
  margin: 0;
  color: var(--color-text-muted);
}

/* Footer */
.tf-post-footer {
  padding: 14px 18px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tf-readmore {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--color-accent);
}

.tf-readmore:hover {
  color: var(--color-accent-dark);
}

.tf-post-comments {
  font-weight: 700;
  color: var(--color-text-muted);
}

/* ---------------------------
   PAGINATION
--------------------------- */
.tf-pagination {
  margin-top: 26px;
}

.tf-pagination .page-numbers {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--color-bg, #ffffff);
  border: 0px solid var(--color-accent, #c9a96a); /* Note: 0px border removes visual line but keeps layout */
  border-radius: 20px;
  justify-content: center;
}

.tf-pagination .page-numbers li {
  margin: 0;
}

.tf-pagination .page-numbers a,
.tf-pagination .page-numbers span {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: var(--radius-sm, 14px);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.tf-pagination .page-numbers a:hover {
  border-color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent), transparent 90%);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px); /* Added micro-interaction */
}

.tf-pagination .page-numbers .current {
  border-color: var(--color-accent);
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent-dark));
  color: var(--color-bg);
}

/* ---------------------------
   AJAX OVERLAY 
--------------------------- */
/* REMOVED: Duplicate .tf-blog-results wrapper defined here */

.tf-ajax-overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-md, 18px);
  z-index: 50;
}

body.dark-mode .tf-ajax-overlay {
  background: rgba(20, 20, 20, 0.7);
}

.tf-ajax-overlay.is-loading {
  display: grid;
}

.tf-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-accent);
  animation: tfSpin 0.85s linear infinite;
}

@keyframes tfSpin {
  to { transform: rotate(360deg); }
}


/* ---------------------------
   EMPTY STATE
--------------------------- */
.no-posts-message,
.no-events-message {
  margin-top: 18px;
  padding: 22px;
  border-radius: var(--radius-md, 18px);
  border: 1px solid var(--color-border);
  background: var(--color-muted-surface);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------
   A11Y: Focus + Reduced motion
--------------------------- */
.tf-blog-archive a:focus-visible,
.tf-blog-archive button:focus-visible,
.tf-blog-archive input:focus-visible,
.tf-blog-archive select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-accent), transparent 50%);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  /* REMOVED: html { scroll-behavior: auto; } - Belongs in global.css */
  
  .tf-post-thumb img,
  .tf-post-card,
  .tf-grid-posts .card,
  .tf-pagination .page-numbers a,
  .tf-spinner {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------------------------
   RTL support
--------------------------- */
[dir="rtl"] .tf-blog-hero .tf-hero__content { text-align: right; }
[dir="rtl"] .tf-post-badge { left: auto; right: 14px; }
[dir="rtl"] .tf-post-footer { flex-direction: row-reverse; }