/**
 * APS Home Sections — layout styles for widget areas injected into the
 * APS product loop pages (top / featured / bottom).
 *
 * Works with:
 *   • APS_Post_List_Row_Widget (.aps-post-list__scroll / .aps-post-card)
 *   • APS_Products_Row_Widget  (.aps-products-row__list)
 *   • APS_Brands_Row_Widget    (.aps-brands-row__list)
 *   • Platform theme Post List widget (.cs-posts-area)
 *   • Any other theme widget dropped into these areas
 */

/* ── APS Post List Row — custom card design ─────────────────────────────────── */

.aps-post-row__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.aps-post-row__heading {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--cs-light-accent-color, #2958ff);
  flex: 1;
}

.aps-post-row__viewall {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--cs-light-accent-color, #2958ff);
  text-decoration: none;
  margin-left: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}
.aps-post-row__viewall:hover {
  text-decoration: underline;
}

/* Horizontal scroll row — padding gives shadows room to breathe */
.aps-post-list__scroll {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  padding: 10px 6px 16px; /* top/side/bottom so shadows are never clipped */
  margin: -10px -6px -16px; /* pull back so row stays flush with parent */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  align-items: flex-start;
}
.aps-post-list__scroll::-webkit-scrollbar {
  display: none;
}

/* Individual post card */
.aps-post-card {
  flex: 0 0 280px;
  width: 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: var(--cs-layout-background, #fff);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.aps-post-card:hover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

/* Thumbnail — 16:9 ratio */
.aps-post-card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #f0f0f0;
  flex-shrink: 0;
}
.aps-post-card__thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.aps-post-card:hover .aps-post-card__thumb img {
  transform: scale(1.04);
}
.aps-post-card__no-thumb {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #e8ecf0 0%, #d0d7e0 100%);
}

/* Category pill — overlaid bottom-left of image */
.aps-post-card__cat {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: var(--cs-light-accent-color, #2958ff);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 4px;
  line-height: 1.4;
  white-space: nowrap;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Text body */
.aps-post-card__body {
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.aps-post-card__title {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  color: var(--cs-headings-color, #111);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aps-post-card__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: #888;
  margin-top: auto;
  flex-wrap: wrap;
}

.aps-post-card__dot {
  opacity: 0.5;
}

.aps-row-card__body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  flex: 1; /* already there */
}

.aps-row-card__features {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.72rem;
  color: #666;
  line-height: 1.5;
  margin-top: auto; /* ← add this, pushes features to bottom */
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .aps-post-card {
    border-color: rgba(255, 255, 255, 0.08);
  }
}
[data-scheme="dark"] .aps-post-card,
.cs-dark .aps-post-card {
  border-color: rgba(255, 255, 255, 0.08);
}

[data-scheme="dark"] .aps-row-card__title {
  color: #111;
}

/* ── Outer wrapper ──────────────────────────────────────────────────────────── */

.aps-home-sections {
  width: 100%;
  margin-bottom: 24px;
}

/* Each individual widget inside a home section */
.aps-home-section {
  margin-bottom: 28px;
}
.aps-home-section:last-child {
  margin-bottom: 0;
}

/* Section title (widget title rendered by before_title / after_title) */
.aps-home-section .aps-section-title,
.aps-home-section h2.widgettitle,
.aps-home-section .widget-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--cs-light-accent-color, #2958ff);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aps-home-section .aps-section-title a.aps-viewall,
.aps-home-section h2.widgettitle a.aps-viewall {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--cs-light-accent-color, #2958ff);
  text-decoration: none;
}

/* ── APS Products Row ───────────────────────────────────────────────────────── */

.aps-products-row__list {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.aps-products-row__list::-webkit-scrollbar {
  display: none;
}

.aps-home-section__title {
  margin: 0 0 20px;
}

.aps-row-card {
  flex: 0 0 160px;
  min-width: 140px;
  max-width: 180px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  overflow: hidden;
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
  text-decoration: none;
  display: flex;
  flex-direction: column;
}
.aps-row-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.aps-row-card__thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}
.aps-row-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.aps-row-card__body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.aps-row-card__title {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  color: #111;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.aps-row-card__price {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cs-light-accent-color, #2958ff);
  margin-bottom: 6px;
}

.aps-row-card__features {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.72rem;
  color: #666;
  line-height: 1.5;
}
.aps-row-card__features li {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── APS Brands Row ─────────────────────────────────────────────────────────── */

.aps-brands-row__list {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.aps-brands-row__list::-webkit-scrollbar {
  display: none;
}

.aps-brand-badge {
  flex: 0 0 auto;
  min-width: 90px;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 10px;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  background: #fff;
  text-decoration: none;
  color: #333;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}
.aps-brand-badge:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--cs-light-accent-color, #2958ff);
  color: var(--cs-light-accent-color, #2958ff);
}

.aps-brand-badge img {
  max-width: 64px;
  max-height: 36px;
  object-fit: contain;
  display: block;
}

.aps-brand-badge__name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
}

.aps-brand-badge__count {
  font-size: 0.68rem;
  font-weight: 400;
  color: #888;
}

/* ── Platform theme Post List / Post Slider widget — horizontal override ──── */
/*
 * Forces the post grid inside any aps-home-section into a horizontal
 * scrollable row. Targets the exact classes the theme outputs.
 */

/* 1. The grid container — horizontal flex row, cards don't stretch vertically */
.aps-home-section .cs-posts-area__grid,
.aps-home-section .cs-widget-post-list__grid,
.aps-home-section .cs-posts-area {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start !important;
  gap: 16px !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  padding-bottom: 10px !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.aps-home-section .cs-posts-area__grid::-webkit-scrollbar,
.aps-home-section .cs-widget-post-list__grid::-webkit-scrollbar,
.aps-home-section .cs-posts-area::-webkit-scrollbar {
  display: none;
}

/* 2. Each article card — fixed width, natural height */
.aps-home-section .cs-posts-area__grid .cs-entry,
.aps-home-section .cs-widget-post-list__grid .cs-entry,
.aps-home-section .cs-posts-area .cs-entry {
  flex: 0 0 260px !important;
  width: 260px !important;
  min-width: 0 !important;
  max-width: 260px !important;
  margin: 0 !important;
}

/* 3. Card inner — column layout (image top, text bottom), no forced height */
.aps-home-section .cs-posts-area__grid .cs-entry__outer,
.aps-home-section .cs-widget-post-list__grid .cs-entry__outer,
.aps-home-section .cs-posts-area .cs-entry__outer {
  display: flex !important;
  flex-direction: column !important;
  height: auto !important;
}

/* 4. Thumbnail: full width, let the overlay ratio class control aspect ratio */
.aps-home-section .cs-posts-area__grid .cs-entry__thumbnail,
.aps-home-section .cs-widget-post-list__grid .cs-entry__thumbnail,
.aps-home-section .cs-posts-area .cs-entry__thumbnail {
  width: 100% !important;
  flex-shrink: 0 !important;
}

/* 5. Content: full width, natural height */
.aps-home-section .cs-posts-area__grid .cs-entry__content,
.aps-home-section .cs-widget-post-list__grid .cs-entry__content,
.aps-home-section .cs-posts-area .cs-entry__content {
  width: 100% !important;
  flex: 0 0 auto !important;
}

/* ── General widget inside home sections ─────────────────────────────────────── */

/* Reset any hard-coded widths theme widgets may set */
.aps-home-section .widget {
  width: auto;
}

/* ── Responsive tweaks ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  /* APS post card */
  .aps-post-card {
    flex: 0 0 220px;
    width: 220px;
  }
  .aps-post-card__title {
    font-size: 0.78rem;
    -webkit-line-clamp: 2;
  }

  /* APS product row card */
  .aps-row-card {
    flex: 0 0 130px;
    min-width: 120px;
  }

  /* Brand badges */
  .aps-brand-badge {
    min-width: 74px;
    max-width: 100px;
    padding: 10px 8px;
  }

  /* Theme Post List cards */
  .aps-home-section .cs-posts-area__grid .cs-entry,
  .aps-home-section .cs-widget-post-list__grid .cs-entry,
  .aps-home-section .cs-posts-area .cs-entry {
    flex: 0 0 180px !important;
    min-width: 160px !important;
    width: 180px !important;
  }

  .aps-scroll-arrow {
    width: 28px;
    height: 28px;
  }
}

/* ── Scroll arrow buttons ───────────────────────────────────────────────────── */

/* Wrapper injected by JS around each scroll container */
.aps-scroll-wrap {
  position: relative;
}

/* Base arrow button */
.aps-scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #333;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
  /* Hidden until parent is hovered */
  opacity: 0;
  pointer-events: none;
}

/* Show arrows on wrapper hover (desktop) */
.aps-scroll-wrap:hover .aps-scroll-arrow {
  opacity: 1;
  pointer-events: auto;
}

/* Keep hidden if JS marks it as at-edge */
.aps-scroll-wrap:hover .aps-scroll-arrow.aps-arrow--hidden {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Touch / mobile: always show arrows (no hover on touch screens) */
@media (hover: none), (pointer: coarse) {
  .aps-scroll-arrow {
    opacity: 1;
    pointer-events: auto;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  .aps-scroll-arrow.aps-arrow--hidden {
    opacity: 0 !important;
    pointer-events: none !important;
  }
  .aps-scroll-prev {
    left: 2px;
  }
  .aps-scroll-next {
    right: 2px;
  }
}

/* Left arrow */
.aps-scroll-prev {
  left: -14px;
}

/* Right arrow */
.aps-scroll-next {
  right: -14px;
}

/* Hover effect on the button itself */
.aps-scroll-arrow:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  transform: translateY(-50%) scale(1.08);
}

.aps-scroll-arrow svg {
  display: block;
  flex-shrink: 0;
}
