/**
 * NPF Fast Mode: skeleton placeholders + 2-column layout (filters left, products right).
 */

/* ARCHIVE HEADER (Worten-like, 3 stacked rows) */
.tnz-archive-head{
  background:#f3f4f6;
  padding:0px 0 28px;
  border-bottom:1px solid #e5e7eb;
}

.tnz-archive-head .tnz-container{
  display:block;
}

.tnz-archive-breadcrumb{
  display:block;
  text-align:left;
  font-size:13px;
  color:#6b7280;
  margin:0 0 18px;
}

.tnz-archive-breadcrumb a{
  color:#6b7280;
  text-decoration:none;
}

.tnz-archive-breadcrumb a:hover{
  text-decoration:underline;
}

.tnz-archive-title{
  display:block;
  text-align:center;
  font-size:clamp(32px,4vw,52px);
  font-weight:900;
  letter-spacing:-1px;
  margin:0;
  color:#111827;
  text-transform:uppercase;
  line-height:1.05;
}

.tnz-archive-title::after{
  content:"";
  display:block;
  width:80px;
  height:4px;
  background:#fed700;
  margin:18px auto 0;
  border-radius:3px;
}

.tnz-archive-subcats{
  display:block;
  margin-top:18px;
  text-align:center;
}

.tnz-archive-subcats .tnz-product-subcats,
.tnz-archive-subcats .tnz-product-subcats__grid{
  justify-content:center;
}

/* space before main archive area (fast mode and full mode) */
#npf-fast-root,
.tnz-archive-head + main{
  margin-top:26px;
}

/* When loading, don't collapse grid */
#npf-fast-root.is-loading {
  opacity: 1;
}

/* Overall layout: 2 columns */
#npf-fast-root .npf-fast-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

/* Sidebar scroll (skeleton + after injection) */
#npf-fast-root #npf-fast-filters {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding-right: 8px;
  box-sizing: border-box;
}

/* Main column: right padding so it doesn't touch the edge */
#npf-fast-root .npf-fast-main {
  min-width: 0;
  padding-right: 12px;
  box-sizing: border-box;
}

/* Base skeleton: darker background, rounded, ready for shimmer */
#npf-fast-root .npf-skel,
#npf-fast-root .npf-skel-card,
#npf-fast-root .npf-skel--filters,
#npf-fast-root .npf-skel--topbar,
#npf-fast-root .npf-skel--products,
#npf-fast-root .npf-skel--pagination,
#npf-fast-root .npf-fast-skeleton--filters,
#npf-fast-root .npf-fast-skeleton--topbar,
#npf-fast-root .npf-fast-skeleton--products,
#npf-fast-root .npf-fast-skeleton--pagination {
  background: #e5e7eb;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}

/* Skeleton: filters full-height emphasis */
#npf-fast-root .npf-skel--filters,
#npf-fast-root .npf-fast-skeleton--filters {
  min-height: calc(100vh - 120px);
  background: #e5e7eb;
}

/* Products skeleton grid: 5 per row, 3 rows (15 cards) */
#npf-fast-root .npf-skel--products,
#npf-fast-root .npf-fast-skeleton--products {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

#npf-fast-root .npf-skel-card {
  height: 340px;
  background: #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

#npf-fast-root .npf-skel--topbar,
#npf-fast-root .npf-fast-skeleton--topbar {
  height: 28px;
  max-width: 280px;
  border-radius: 4px;
  margin-bottom: 1rem;
}

#npf-fast-root .npf-skel--pagination,
#npf-fast-root .npf-fast-skeleton--pagination {
  height: 40px;
  max-width: 240px;
  margin-top: 1.5rem;
  border-radius: 6px;
}

/* Stronger shimmer overlay */
@media (prefers-reduced-motion: no-preference) {
  #npf-fast-root .npf-skel::after,
  #npf-fast-root .npf-skel-card::after,
  #npf-fast-root .npf-skel--filters::after,
  #npf-fast-root .npf-skel--topbar::after,
  #npf-fast-root .npf-skel--pagination::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.9) 45%,
      rgba(255, 255, 255, 0.9) 55%,
      rgba(255, 255, 255, 0) 100%
    );
    transform: translateX(-100%);
    animation: npfShimmer 1.2s infinite;
    pointer-events: none;
  }

  @keyframes npfShimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
  }
}

#npf-fast-root.is-loading .npf-skel-card {
  opacity: 0.9;
}

/* Injected filters: don't overflow */
#npf-fast-root #npf-fast-filters * {
  max-width: 100%;
}

/* After injection: keep same layout (filters left, products right) */
#npf-fast-root:not(.is-skeleton) .npf-fast-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
}

/* Ensure injected filters container behaves like sidebar */
#npf-fast-root:not(.is-skeleton) #npf-fast-filters {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding-right: 8px;
  box-sizing: border-box;
}

/* Force 5 columns for the injected product grid (NPF output uses .npf-grid) */
#npf-fast-root #npf-fast-products .npf-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

#npf-fast-root #npf-fast-products .npf-grid > * {
  min-width: 0;
}

/* Responsive breakpoints */
@media (max-width: 1200px) {
  #npf-fast-root .npf-fast-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  #npf-fast-root .npf-skel--products,
  #npf-fast-root .npf-fast-skeleton--products {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  #npf-fast-root #npf-fast-products .npf-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  /* Match specificity of #npf-fast-root:not(.is-skeleton) .npf-fast-layout so this override wins */
  #npf-fast-root:not(.is-skeleton) .npf-fast-layout {
    display: block;
    position: relative;
  }

  /* Match specificity of #npf-fast-root:not(.is-skeleton) #npf-fast-filters so this override wins */
  #npf-fast-root:not(.is-skeleton) #npf-fast-filters {
    position: absolute;
    left: -9999px;
    top: 0;
    width: 1px;
    min-width: 0;
    overflow: visible;
    padding: 0;
  }

  #npf-fast-root .npf-fast-main {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #npf-fast-root .npf-skel--products,
  #npf-fast-root .npf-fast-skeleton--products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #npf-fast-root #npf-fast-products .npf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Ensure NPF plugin mobile filters button is visible (plugin shows it at 768px; theme mobile = 900px) */
  #npf-fast-filters #npf-open-filters {
    display: inline-block !important;
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 9000;
  }
}

/* Defensive: grid children don't overflow */
#npf-fast-root .npf-fast-layout > * {
  max-width: 100%;
}

/* No-JS fallback message */
.npf-fast-noscript-msg {
  margin: 1rem 0;
  padding: 0.5rem 0;
}

.npf-fast-err {
  margin: 0.5rem 0;
  color: #6b7280;
  font-size: 0.9rem;
}

/* Subcategories skeleton placeholder (shown when archive changes) */
.tnz-subcats-skel {
  display: none;
  margin-top: 18px;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.tnz-subcats-skel .tnz-subcat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tnz-subcats-skel .tnz-subcat-dot {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  background: #e2e8f0;
  position: relative;
  overflow: hidden;
}

.tnz-subcats-skel .tnz-subcat-label {
  width: 74px;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  margin-top: 8px;
}

#tnz-archive-head.tnz-subcats-loading #tnz-archive-subcats-inner {
  display: none;
}

#tnz-archive-head.tnz-subcats-loading #tnz-archive-subcats-skel {
  display: flex;
}

/* --- TNZ Fast Mode Skeleton: clean (no background plate) --- */

/* Ensure skeleton wrappers never paint a full background */
.npf-skel,
.npf-skel--products,
.npf-skel--filters,
.npf-skel--topbar,
.npf-skel--pagination,
#npf-fast-filters,
#npf-fast-topbar,
#npf-fast-products,
#npf-fast-pagination {
  background: transparent !important;
  box-shadow: none !important;
}

/* Products placeholder grid should look normal, only cards are skeleton */
#npf-fast-products {
  background: transparent !important;
}

/* Product placeholder card */
.npf-skel-card {
  height: 340px;
  border-radius: 12px;
  background: #e2e8f0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Shimmer only on cards */
@media (prefers-reduced-motion: no-preference) {
  .npf-skel-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0) 0%,
      rgba(255, 255, 255, 0.85) 50%,
      rgba(255, 255, 255, 0) 100%
    );
    transform: translateX(-100%);
    animation: npfShimmer 1.2s infinite;
  }

  @keyframes npfShimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
  }
}
