/**
 * Azurixlab Smart Post Grid — front-end styles.
 * Per-grid values (columns, gap, colors, ratio) are injected inline by PHP.
 */

.spg-grid {
  --spg-accent: #2563eb;
  --spg-gap: 24px;
  --spg-img-fit: cover;
  --spg-img-pad: 56.25%;
  display: grid;
  gap: var(--spg-gap);
  margin: 0 0 1.5em;
  padding: 0;
  list-style: none;
}

.spg-grid * {
  box-sizing: border-box;
}

/* ---- Card base ---- */
.spg-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

/* ---- Image ---- */
.spg-image {
  display: block;
  overflow: hidden;
}

.spg-image-inner {
  position: relative;
  display: block;
  width: 100%;
  padding-top: var(--spg-img-pad);
  overflow: hidden;
  background: #f1f3f5;
}

.spg-image-inner .spg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--spg-img-fit);
  transition:
    transform 0.5s ease,
    filter 0.4s ease,
    opacity 0.4s ease;
}

/* ---- Body ---- */
.spg-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px 22px;
  flex: 1 1 auto;
}

/* ---- Text alignment ----
 * Left is explicit (not just the default) so it overrides any theme that
 * centres or right-aligns text inside the card. */
.spg-align-left .spg-body,
.spg-align-left .spg-overlay-content {
  text-align: left;
  align-items: flex-start;
}
.spg-align-center .spg-body,
.spg-align-center .spg-overlay-content {
  text-align: center;
  align-items: center;
}
.spg-align-right .spg-body,
.spg-align-right .spg-overlay-content {
  text-align: right;
  align-items: flex-end;
}

/* Make sure the heading and excerpt follow the chosen alignment. */
.spg-align-left .spg-title,
.spg-align-left .spg-excerpt {
  text-align: left;
}
.spg-align-center .spg-title,
.spg-align-center .spg-excerpt {
  text-align: center;
}
.spg-align-right .spg-title,
.spg-align-right .spg-excerpt {
  text-align: right;
}

/* ---- Title ---- */
.spg-title {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.35;
  font-weight: 600;
}

.spg-title a {
  color: #11161c;
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* ---- Head row: date (left) + category (right), just below the image ---- */
.spg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  align-self: stretch; /* stay full-width even when body is centered */
  margin: 0 0 2px;
}

.spg-card-head .spg-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #6b7280;
  white-space: nowrap;
}

.spg-card-head .spg-cat-badge {
  margin: 0;
  align-self: center;
  flex: 0 0 auto;
}
.spg-head-spacer {
  display: inline-block;
}

/* ---- Inline SVG icons (crisp on every OS) ---- */
.spg-ic {
  display: inline-flex;
  align-items: center;
}
.spg-ic svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* ---- Meta (author line) ---- */
.spg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.82rem;
  color: #6b7280;
}

.spg-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---- Tags ---- */
.spg-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.spg-tag-item {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  color: #555;
  background: #dbeafe;
  border-radius: 999px;
}

/* Linked tags keep the badge look (no underline) and gain a hover state. */
a.spg-tag-item {
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
a.spg-tag-item:hover,
a.spg-tag-item:focus {
  color: #fff;
  background: #1d4ed8;
}

.spg-align-left .spg-meta {
  justify-content: flex-start;
}
.spg-align-center .spg-meta {
  justify-content: center;
}
.spg-align-right .spg-meta {
  justify-content: flex-end;
}

/* ---- Excerpt ---- */
.spg-excerpt {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #4b5563;
  margin: 0;
}

/* ---- Category badge ---- */
.spg-cat-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 11px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  background: var(--spg-accent);
  border-radius: 4px;
  text-decoration: none;
  line-height: 1.4;
}

.spg-align-center .spg-cat-badge {
  align-self: center;
}
.spg-align-right .spg-cat-badge {
  align-self: flex-end;
}

/* ---- Read more ---- */
.spg-readmore {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--spg-accent);
  text-decoration: none;
}

.spg-readmore .spg-arrow {
  transition: transform 0.2s ease;
}
.spg-readmore:hover .spg-arrow {
  transform: translateX(4px);
}

/* Read More position — configurable, independent of the card text alignment.
 * align-self overrides the body's align-items for just the button. */
.spg-rm-left .spg-readmore {
  align-self: flex-start;
}
.spg-rm-center .spg-readmore {
  align-self: center;
}
.spg-rm-right .spg-readmore {
  align-self: flex-end;
}

/* =====================================================================
 * HOVER EFFECTS
 * ===================================================================== */
.spg-hover-zoom .spg-card:hover .spg-img {
  transform: scale(1.08);
}
.spg-hover-zoom-out .spg-img {
  transform: scale(1.08);
}
.spg-hover-zoom-out .spg-card:hover .spg-img {
  transform: scale(1);
}
.spg-hover-grayscale .spg-img {
  filter: grayscale(100%);
}
.spg-hover-grayscale .spg-card:hover .spg-img {
  filter: grayscale(0);
}
.spg-hover-lift .spg-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.spg-hover-lift .spg-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
}
.spg-hover-overlay .spg-image-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--spg-accent);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}
.spg-hover-overlay .spg-card:hover .spg-image-inner::after {
  opacity: 0.35;
}

/* =====================================================================
 * STYLE 01 — Classic Card (default look already covers it)
 * ===================================================================== */
.spg-style-grid-01 .spg-card {
  border: 1px solid #eceff2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* =====================================================================
 * STYLE 02 — Image Overlay (text over image, dark gradient)
 * ===================================================================== */
.spg-style-grid-02 .spg-overlay-wrap {
  position: relative;
  min-height: 320px;
  display: flex;
}
.spg-style-grid-02 .spg-image,
.spg-style-grid-02 .spg-image-inner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding-top: 0;
}
.spg-style-grid-02 .spg-image-inner .spg-img {
  position: absolute;
}
.spg-style-grid-02 .spg-overlay-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.05) 0%,
    rgba(0, 0, 0, 0.78) 100%
  );
  z-index: 1;
}
.spg-style-grid-02 .spg-overlay-content {
  position: relative;
  z-index: 2;
  margin-top: auto;
  padding: 22px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.spg-style-grid-02 .spg-title a,
.spg-style-grid-02 .spg-meta,
.spg-style-grid-02 .spg-card-head .spg-date,
.spg-style-grid-02 .spg-readmore {
  color: #fff;
}
.spg-style-grid-02 .spg-meta,
.spg-style-grid-02 .spg-card-head .spg-date {
  opacity: 0.9;
}
.spg-style-grid-02 .spg-title a:hover {
  color: #e5e7eb;
}
.spg-style-grid-02 .spg-tag-item {
  color: #11161c;
  background: rgba(255, 255, 255, 0.95);
}
.spg-style-grid-03 .spg-title {
  font-size: 1.22rem;
}
.spg-style-grid-03 .spg-cat-badge {
  background: transparent;
  color: var(--spg-accent);
  padding: 0;
  font-size: 0.74rem;
}

/* =====================================================================
 * STYLE 04 — Horizontal List (image left, content right)
 * ===================================================================== */
.spg-style-grid-04 .spg-card {
  flex-direction: row;
  border: 1px solid #eceff2;
  align-items: stretch;
}
.spg-style-grid-04 .spg-image {
  flex: 0 0 42%;
  max-width: 42%;
}
.spg-style-grid-04 .spg-image-inner {
  height: 100%;
  padding-top: 0;
  min-height: 150px;
}
.spg-style-grid-04 .spg-image-inner .spg-img {
  position: absolute;
}
.spg-style-grid-04 .spg-body {
  justify-content: center;
}
@media (max-width: 480px) {
  .spg-style-grid-04 .spg-card {
    flex-direction: column;
  }
  .spg-style-grid-04 .spg-image {
    flex-basis: auto;
    max-width: 100%;
  }
  .spg-style-grid-04 .spg-image-inner {
    min-height: 0;
    padding-top: var(--spg-img-pad);
  }
}

/* =====================================================================
 * STYLE 05 — Bottom Gradient (overlay + excerpt, lighter)
 * ===================================================================== */
.spg-style-grid-05 .spg-overlay-wrap {
  position: relative;
  min-height: 360px;
  display: flex;
  border-radius: 10px;
  overflow: hidden;
}
.spg-style-grid-05 .spg-image,
.spg-style-grid-05 .spg-image-inner {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding-top: 0;
}
.spg-style-grid-05 .spg-image-inner .spg-img {
  position: absolute;
}
.spg-style-grid-05 .spg-overlay-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 30%,
    rgba(15, 23, 42, 0.85) 100%
  );
  z-index: 1;
}
.spg-style-grid-05 .spg-overlay-content {
  position: relative;
  z-index: 2;
  margin-top: auto;
  padding: 24px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.spg-style-grid-05 .spg-title a,
.spg-style-grid-05 .spg-meta,
.spg-style-grid-05 .spg-card-head .spg-date,
.spg-style-grid-05 .spg-excerpt,
.spg-style-grid-05 .spg-readmore {
  color: #fff;
}
.spg-style-grid-05 .spg-excerpt,
.spg-style-grid-05 .spg-card-head .spg-date {
  opacity: 0.9;
}

/* =====================================================================
 * STYLE 06 — Meta Focused (accent top border, prominent meta)
 * ===================================================================== */
.spg-style-grid-06 .spg-card {
  border: 1px solid #eceff2;
  border-top: 3px solid var(--spg-accent);
}
.spg-style-grid-06 .spg-body {
  padding-top: 20px;
}
.spg-style-grid-06 .spg-card-head .spg-date {
  font-weight: 600;
  color: var(--spg-accent);
}
.spg-style-grid-06 .spg-title {
  font-size: 1.1rem;
}

/* =====================================================================
 * STYLE 07 — Featured + Grid
 * Latest post spans the full row as a two-column feature (image left,
 * content right); remaining posts flow into the normal grid below.
 * ===================================================================== */
.spg-card.spg-featured {
  grid-column: 1 / -1; /* span every column of the grid */
  flex-direction: row;
  align-items: stretch;
  border: 1px solid #eceff2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.spg-card.spg-featured .spg-image {
  flex: 0 0 50%;
  max-width: 50%;
}
.spg-card.spg-featured .spg-image-inner {
  height: 100% !important; /* beat the per-grid #id inline ratio rule */
  min-height: 320px;
  padding-top: 0 !important;
}
.spg-card.spg-featured .spg-image-inner .spg-img {
  position: absolute;
}
.spg-card.spg-featured .spg-body {
  flex: 1 1 50%;
  justify-content: center;
  gap: 14px;
  padding: 30px 34px;
}
.spg-card.spg-featured .spg-title {
  font-size: 1.9rem;
}
.spg-card.spg-featured .spg-excerpt {
  font-size: 1rem;
}

/* Featured card stacks to a single column on tablet / mobile. */
@media (max-width: 768px) {
  .spg-card.spg-featured {
    flex-direction: column;
  }
  .spg-card.spg-featured .spg-image {
    flex-basis: auto;
    max-width: 100%;
  }
  .spg-card.spg-featured .spg-image-inner {
    min-height: 0;
    height: auto !important;
    padding-top: var(--spg-img-pad) !important;
  }
  .spg-card.spg-featured .spg-body {
    padding: 22px 20px;
  }
  .spg-card.spg-featured .spg-title {
    font-size: 1.5rem;
  }
}

/* =====================================================================
 * PAGINATION (Load More / Prev|Next / Numbered)
 * ===================================================================== */
.spg-wrap {
  --spg-accent: #2563eb;
}

.spg-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 26px 0 4px;
}

/* Shared button / link look */
.spg-pagination a,
.spg-pagination button,
.spg-page-num,
.spg-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 14px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  color: #1f2937;
  text-decoration: none;
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.spg-pagination a:hover,
.spg-page-num:hover,
.spg-page-btn:hover {
  border-color: var(--spg-accent);
  color: var(--spg-accent);
}

.spg-page-num.spg-current {
  background: var(--spg-accent);
  border-color: var(--spg-accent);
  color: #fff;
  cursor: default;
}

.spg-pagination .spg-disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

.spg-page-dots {
  display: inline-flex;
  align-items: flex-end;
  min-width: 24px;
  height: 40px;
  padding: 0 2px;
  color: #9ca3af;
}

.spg-page-status {
  padding: 0 10px;
  font-size: 0.88rem;
  color: #6b7280;
}

/* Load More */
.spg-pagination-loadmore {
  margin-top: 28px;
}
.spg-loadmore {
  min-width: 180px;
  height: 46px;
  padding: 0 28px;
  font-size: 0.95rem;
  color: #fff;
  background: var(--spg-accent);
  border: 1px solid var(--spg-accent);
  border-radius: 999px;
}
.spg-loadmore:hover {
  color: #fff;
  filter: brightness(0.94);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}
.spg-loadmore.spg-loading {
  opacity: 0.7;
  cursor: wait;
}
.spg-loadmore.spg-loading::after {
  content: "";
  width: 15px;
  height: 15px;
  margin-left: 10px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spg-spin 0.7s linear infinite;
}
@keyframes spg-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Cards appended via Load More fade in. */
.spg-just-loaded {
  animation: spg-fade-in 0.35s ease both;
}
@keyframes spg-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* =====================================================================
 * Generic responsive nicety: tighten gap on phones.
 * ===================================================================== */
@media (max-width: 640px) {
  .spg-grid {
    --gap-min: 16px;
    gap: 16px;
  }
  .spg-pagination a,
  .spg-pagination button,
  .spg-page-num,
  .spg-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 11px;
    font-size: 0.85rem;
  }
}

/* =====================================================================
 * STYLE 08 & 09 — Single post per row (image one side, content the other)
 * 08: image left / content right.   09: image right / content left.
 * Always one post per row, regardless of the column settings.
 * ===================================================================== */
.spg-style-grid-08,
.spg-style-grid-09 {
  grid-template-columns: 1fr !important;
}
.spg-style-grid-08 .spg-card,
.spg-style-grid-09 .spg-card {
  flex-direction: row;
  align-items: center;
  gap: 34px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.spg-style-grid-09 .spg-card {
  flex-direction: row-reverse;
}

.spg-style-grid-08 .spg-image,
.spg-style-grid-09 .spg-image {
  flex: 0 0 42%;
  max-width: 42%;
  border-radius: 16px;
  overflow: hidden;
}
.spg-style-grid-08 .spg-image-inner,
.spg-style-grid-09 .spg-image-inner {
  border-radius: 16px;
}
.spg-style-grid-08 .spg-body,
.spg-style-grid-09 .spg-body {
  flex: 1 1 auto;
  justify-content: center;
  gap: 12px;
  padding: 4px 0;
}
.spg-style-grid-08 .spg-title,
.spg-style-grid-09 .spg-title {
  font-size: 1.6rem;
  line-height: 1.3;
}
/* Category + date sit together at the start of the row. */
.spg-style-grid-08 .spg-card-head,
.spg-style-grid-09 .spg-card-head {
  justify-content: flex-start;
  gap: 12px;
}

/* Stack to a single column on phones / tablets. */
@media (max-width: 768px) {
  .spg-style-grid-08 .spg-card,
  .spg-style-grid-09 .spg-card {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .spg-style-grid-08 .spg-image,
  .spg-style-grid-09 .spg-image {
    flex-basis: auto;
    max-width: 100%;
  }
}

/* =====================================================================
 * FILTER BAR (category dropdown + tag tabs) — AJAX, no page reload.
 * ===================================================================== */
.spg-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 0 0 22px;
}

.spg-filter-cat-wrap {
  position: relative;
  flex: 0 0 auto;
}
.spg-filter-cat {
  height: 42px;
  min-width: 190px;
  padding: 0 38px 0 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #1f2937;
  background: #fff;
  border: 1px solid #e2e6ea;
  border-radius: 999px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}
.spg-filter-cat:focus {
  outline: none;
  border-color: var(--spg-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.spg-filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.spg-filter-tag {
  height: 36px;
  padding: 0 16px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  color: #374151;
  background: #f1f3f5;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease;
}
.spg-filter-tag:hover {
  color: var(--spg-accent);
  border-color: var(--spg-accent);
}
.spg-filter-tag.is-active {
  color: #fff;
  background: var(--spg-accent);
  border-color: var(--spg-accent);
}

/* Desktop: overflow tags flow inline as if the wrapper weren't there, and the
   "…more" toggle is hidden. On mobile (below) the wrapper becomes a dropdown. */
.spg-filter-tags-extra {
  display: contents;
}
.spg-filter-more {
  display: none;
}

/* Grid dims briefly while an AJAX filter request is in flight. */
.spg-grid.spg-grid-loading {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* "No results" message after filtering spans the full grid width. */
.spg-no-results {
  grid-column: 1 / -1;
  margin: 0;
  padding: 28px 0;
  text-align: center;
  color: #6b7280;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .spg-filter {
    gap: 10px 6px;
  }
  .spg-filter-cat {
    width: 100%;
    min-width: 0;
  }

  /* Collapse the tag tabs: keep "All" + the first tag inline; the rest live in
     a dropdown revealed by the "…more" toggle. */
  .spg-filter-tags {
    position: relative;
    gap: 5px !important;
    flex-wrap: nowrap;
  }
  .spg-filter-tags-extra {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 30;
    flex-direction: column;
    gap: 6px;
    min-width: 190px;
    max-height: 60vh;
    padding: 10px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e6ea;
    border-radius: 12px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
  }
  .spg-filter-tags-extra.is-open {
    display: flex;
  }
  .spg-filter-tags-extra .spg-filter-tag {
    width: 100%;
    height: auto;
    padding: 9px 14px;
    justify-content: flex-start;
  }
  .spg-filter-more {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    color: var(--spg-accent);
    background: #f1f3f5;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
  }
  .spg-filter-more.is-open,
  .spg-filter-more.has-active {
    color: #fff;
    background: var(--spg-accent);
  }
}
