/* =========================================================
   Aviox Blog — Listing Page
   Extends style.css tokens/components — no new palette, no new radii.
   ========================================================= */

/* ---------- Page hero (lean, centered variant) ---------- */
.blog-hero {
  position: relative;
  padding-top: calc(var(--nav-h) + 3rem);
  padding-bottom: 3rem;
  overflow: hidden;
  text-align: center;
}
.blog-hero::before {
  content: "";
  position: absolute; inset: -10% -10% auto -10%;
  height: 130%;
  background: var(--grad-mesh);
  z-index: -2;
  pointer-events: none;
}
.blog-hero-inner { max-width: 680px; margin: 0 auto; }

.page-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  padding: 0.45rem 1rem 0.45rem 0.7rem;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text-soft);
  margin-bottom: 1.4rem;
}
.page-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--grad-accent);
  box-shadow: 0 0 0 3px rgba(0,194,168,0.18);
}

.blog-hero h1 {
  font-size: clamp(2rem, 3.6vw, 2.9rem);
  line-height: 1.14;
  margin-bottom: 1rem;
}
.blog-hero p.lead-text {
  font-size: 1.05rem;
  color: var(--clr-gray);
  max-width: 460px;
  margin: 0 auto;
}

/* ---------- Sticky filter bar ---------- */
.filter-bar-wrap {
  position: sticky;
  top: var(--nav-h);
  z-index: 95;
  background: color-mix(in srgb, var(--clr-bg) 94%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--clr-border);
  box-shadow: 0 8px 24px rgba(17,24,39,0.04);
  padding: 1rem 0;
}
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.filter-search {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
}
.filter-search button[type="submit"] {
  position: absolute; top: 50%; left: 1rem; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; margin: 0; line-height: 1;
  color: var(--clr-gray); font-size: 0.9rem;
  cursor: pointer;
  z-index: 1;
}
.filter-search button[type="submit"]:hover { color: var(--clr-primary); }
.filter-search input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text);
  font-size: 0.9rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.filter-search input:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 4px rgba(108,99,255,0.12);
}
.filter-search input::placeholder { color: var(--clr-gray); }

.filter-select {
  appearance: none;
  -webkit-appearance: none;
  /* Removing native appearance drops a <select>'s normal shrink-to-fit
     sizing in Chromium/Firefox, so without an explicit width it stretches
     to fill the flex row instead of sizing to its content. */
  flex: 0 1 auto;
  width: auto;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* <select> clips its own text if padding + line-height exceed a fixed
     height (it doesn't grow to fit like a normal box) — so height/line-height
     are set explicitly here instead of relying on vertical padding. */
  box-sizing: border-box;
  height: 42px;
  line-height: 38px;
  padding: 0 2.3rem 0 1.1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--clr-border);
  background: var(--clr-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 1rem center;
  color: var(--clr-text-soft);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.25s;
}
@media (max-width: 767.98px) { .filter-select { max-width: none; width: 100%; } }
.filter-select:focus { outline: none; border-color: var(--clr-primary); }
.filter-select:hover { border-color: var(--clr-primary); }

/* ---------- Custom select ----------
   A native <select>'s closed state can be styled (above), but its open
   option list is always rendered by the OS — Chrome, Firefox and
   especially Safari/macOS/iOS each draw it differently and none of it is
   reachable by CSS. script.js progressively enhances every .filter-select
   into the widget below (own HTML/CSS end to end, so it's pixel-identical
   everywhere) and forwards picks back onto the real <select> — so the
   existing onchange="..." behavior in page-blog.php/search.php keeps
   working untouched. If JS doesn't run, the native select above is left
   alone as a fully working fallback. */
.filter-select.cs-native-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  opacity: 0;
  pointer-events: none;
}

.cs-select { position: relative; display: inline-flex; flex: 0 1 auto; }
@media (max-width: 767.98px) { .cs-select { width: 100%; } }

.cs-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: auto;
  max-width: 220px;
  box-sizing: border-box;
  height: 42px;
  padding: 0 1.1rem;
  appearance: none;
  -webkit-appearance: none;
  border-radius: var(--radius-pill);
  border: 1px solid var(--clr-border);
  background-color: var(--clr-surface);
  color: var(--clr-text-soft);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.25s;
}
@media (max-width: 767.98px) { .cs-select-trigger { max-width: none; width: 100%; } }
.cs-select-trigger:hover,
.cs-select-trigger:focus { border-color: var(--clr-primary); background-color: var(--clr-surface); color: var(--clr-text-soft); }
.cs-select-trigger:focus-visible { outline: 2.5px solid var(--clr-accent); outline-offset: 2px; }
.cs-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-select-trigger i {
  font-size: 0.7rem;
  color: var(--clr-gray);
  flex-shrink: 0;
  transition: transform 0.25s var(--ease-premium);
}
.cs-select.open .cs-select-trigger i { transform: rotate(180deg); }

.cs-select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 280px;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 120;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  /* visibility must flip the instant this opens (delay: 0s) so a script can
     focus an option right away — flipping it only at the END of a shared
     0.2s transition (the naive version) means the item is still computed
     as hidden for that whole 0.2s, and focusing a hidden element silently
     no-ops. Closing keeps the 0.2s delay so it stays interactive/visible
     through the fade-out instead of vanishing abruptly. */
  transition: opacity 0.2s var(--ease-premium), transform 0.2s var(--ease-premium), visibility 0s linear 0.2s;
}
.cs-select.open .cs-select-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity 0.2s var(--ease-premium), transform 0.2s var(--ease-premium), visibility 0s linear 0s;
}

.cs-select-menu li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--clr-text-soft);
  cursor: pointer;
  white-space: nowrap;
  outline: none;
  transition: background 0.15s, color 0.15s;
}
.cs-select-menu li:hover,
.cs-select-menu li:focus,
.cs-select-menu li.focused { background: var(--clr-surface-2); color: var(--clr-text); }
.cs-select-menu li[aria-selected="true"] { color: var(--clr-primary); font-weight: 600; background: rgba(108,99,255,0.08); }
.cs-select-menu .cs-check { display: none; color: var(--clr-primary); font-size: 0.8rem; }
.cs-select-menu li[aria-selected="true"] .cs-check { display: inline-block; }

.filter-sort {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}
@media (max-width: 767.98px) { .filter-sort { margin-left: 0; } }

/* ---------- Content layout ---------- */
.listing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 991.98px) { .listing-layout { grid-template-columns: 1fr; } }

.listing-grid.masonry { columns: 3 260px; }
@media (max-width: 1199.98px) { .listing-grid.masonry { columns: 2 260px; } }
@media (max-width: 575.98px) { .listing-grid.masonry { columns: 1; } }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 1.75rem; position: sticky; top: calc(var(--nav-h) + 84px); }
@media (max-width: 991.98px) { .sidebar { position: static; } }

.widget {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.6rem;
  box-shadow: var(--shadow-sm);
}
.widget h5 {
  font-size: 1rem;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.widget h5 i { color: var(--clr-primary); }

/* trending list */
.trend-item {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--clr-border);
  transition: transform 0.3s var(--ease-premium);
}
.trend-item:last-child { border-bottom: none; padding-bottom: 0; }
.trend-item:first-child { padding-top: 0; }
.trend-item:hover { transform: translateX(4px); }
.trend-rank {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--clr-border);
  width: 26px;
  flex-shrink: 0;
}
.trend-item img {
  width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0;
}
.trend-body h6 { font-size: 0.88rem; line-height: 1.35; margin: 0 0 0.3rem; }
.trend-body h6 a:hover { color: var(--clr-primary); }
.trend-body span { font-size: 0.75rem; color: var(--clr-gray); }

/* popular categories */
.cat-tag-list { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text-soft);
  transition: all 0.25s var(--ease-premium);
}
.cat-tag span { color: var(--clr-gray); font-weight: 500; }
.cat-tag:hover { background: var(--grad-primary); color: #fff; border-color: transparent; }
.cat-tag:hover span { color: rgba(255,255,255,0.8); }

/* newsletter widget - compact vertical variant */
.widget-newsletter {
  background: var(--clr-text);
  border: none;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  text-align: left;
}
[data-theme="dark"] .widget-newsletter { background: var(--clr-surface); border: 1px solid var(--clr-border); }
.widget-newsletter::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.09) 1px, transparent 0);
  background-size: 20px 20px;
  -webkit-mask-image: radial-gradient(80% 100% at 100% 0%, #000 0%, transparent 70%);
  mask-image: radial-gradient(80% 100% at 100% 0%, #000 0%, transparent 70%);
}
.widget-newsletter .wn-icon {
  position: relative; z-index: 1;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--grad-accent);
  display: flex; align-items: center; justify-content: center;
  color: #06342E; font-size: 1.1rem;
  margin-bottom: 1rem;
}
.widget-newsletter h5, .widget-newsletter p { position: relative; z-index: 1; color: #fff; }
.widget-newsletter h5 { margin-bottom: 0.5rem; }
.widget-newsletter p { color: rgba(255,255,255,0.62); font-size: 0.85rem; margin-bottom: 1.1rem; }
.widget-newsletter form {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 0.6rem;
}
.widget-newsletter input {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 0.85rem;
}
.widget-newsletter input::placeholder { color: rgba(255,255,255,0.4); }
.widget-newsletter input:focus { outline: none; border-color: var(--clr-accent); }
.widget-newsletter button {
  border: none;
  background: var(--clr-accent);
  color: #06342E;
  font-weight: 700;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  cursor: pointer;
  transition: transform 0.3s var(--ease-premium), background 0.3s;
}
.widget-newsletter button:hover { transform: translateY(-2px); background: #06D9BB; }

/* advertisement placeholder */
.widget-ad {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  gap: 0.6rem;
  min-height: 220px;
  border: 1.5px dashed var(--clr-border);
  background: var(--clr-surface-2);
  box-shadow: none;
}
.widget-ad i { font-size: 1.6rem; color: var(--clr-gray); }
.widget-ad span.ad-label {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--clr-gray); font-weight: 700;
}
.widget-ad p { font-size: 0.8rem; color: var(--clr-gray); margin: 0; }

/* top authors mini list */
.author-mini-item {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--clr-border);
}
.author-mini-item:last-child { border-bottom: none; padding-bottom: 0; }
.author-mini-item:first-child { padding-top: 0; }
.author-mini-item img {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 3px var(--clr-surface-2);
}
.author-mini-item .ami-name { font-size: 0.88rem; font-weight: 600; }
.author-mini-item .ami-role { font-size: 0.73rem; color: var(--clr-gray); }
.author-mini-item .ami-follow {
  margin-left: auto;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--clr-border);
  background: transparent;
  color: var(--clr-text-soft);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.25s;
  flex-shrink: 0;
}
.author-mini-item .ami-follow:hover, .author-mini-item .ami-follow.following {
  background: var(--grad-primary); color: #fff; border-color: transparent;
}

/* ---------- Pagination ---------- */
.pagination-premium {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 46px; height: 46px;
  padding: 0 1.1rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text-soft);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.3s var(--ease-premium);
}
.page-btn:hover { transform: translateY(-3px); border-color: var(--clr-primary); color: var(--clr-primary); box-shadow: var(--shadow-sm); }
.page-btn.active { background: var(--grad-primary); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn:disabled:hover { transform: none; border-color: var(--clr-border); color: var(--clr-text-soft); box-shadow: none; }
.page-dots { color: var(--clr-gray); padding: 0 0.3rem; }

/* results row above grid */
.results-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: 0.75rem;
}
.results-row .count { color: var(--clr-gray); font-size: 0.9rem; }
.results-row .count strong { color: var(--clr-text); }
