/*
Theme Name: add2cart
Theme URI: https://add2cart.com
Author: add2cart
Description: A clean, modern dark theme for shoppable affiliate product grids.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: add2cart
*/

/* =============================================
   RESET & BASE
   ============================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:           #0a0a0a;
  --surface:      #111111;
  --card:         #181818;
  --card-hover:   #1e1e1e;
  --border:       #262626;
  --text:         #f0f0f0;
  --text-muted:   #777;
  --accent:       #ff6b35;
  --accent-hover: #ff8c5a;
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --radius:       12px;
  --ease:         0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

/* =============================================
   HEADER
   ============================================= */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 1.5rem;
}

.site-header__inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.site-logo__mascot {
  display: block;
  height: 45px;
  width: auto;
  flex-shrink: 0;
}

.site-logo__name {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1;
}

.site-logo__name em {
  font-style: normal;
  color: var(--accent);
}

/* Search bar */
.site-search {
  display: flex;
  align-items: center;
  margin-left: auto;
  background: #181818;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--ease), box-shadow var(--ease);
  width: 280px;
  max-width: 100%;
}

.site-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

.site-search__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  padding: 0 12px;
  height: 38px;
  min-width: 0;
}

.site-search__input::placeholder {
  color: var(--text-muted);
}

/* Remove browser default search cancel button */
.site-search__input::-webkit-search-cancel-button,
.site-search__input::-webkit-search-decoration {
  -webkit-appearance: none;
}

.site-search__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 12px;
  height: 38px;
  flex-shrink: 0;
  transition: color var(--ease);
}

.site-search__btn:hover {
  color: var(--accent);
}

/* =============================================
   MAIN LAYOUT
   ============================================= */

.site-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

/* =============================================
   FILTER BAR
   ============================================= */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.775rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.filter-btn:hover {
  background: var(--card);
  color: var(--text);
  border-color: #333;
}

.filter-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-btn--active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.products-grid--loading {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.15s;
}

/* =============================================
   PRODUCT GRID
   ============================================= */

.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

@media (max-width: 1100px) {
  .products-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .products-grid {
    grid-template-columns: 1fr;
  }
}

/* =============================================
   PRODUCT CARD
   ============================================= */

.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform var(--ease), box-shadow var(--ease), background var(--ease), border-color var(--ease);
}

.product-card:hover {
  background: var(--card-hover);
  border-color: #333;
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* Clickable overlay — covers the card but sits below the CTA button */
.product-card__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Image */
.product-card__image-wrap {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #111;
}

.product-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.product-card:hover .product-card__image-wrap img {
  transform: scale(1.06);
}

/* Body */
.product-card__body {
  padding: 0.875rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.75rem;
}

.product-card__title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  /* Clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__desc {
  font-size: 0.78rem;
  color: var(--text-muted, #9ca3af);
  line-height: 1.5;
  margin: 6px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__cta {
  margin-top: auto;
  position: relative;
  z-index: 2; /* sits above overlay */
  display: block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  text-align: center;
  transition: background var(--ease);
}

.product-card__cta:hover {
  background: var(--accent-hover);
}

/* =============================================
   LOAD MORE
   ============================================= */

.load-more-wrap {
  margin-top: 2.5rem;
  text-align: center;
}

#load-more-btn {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.75rem 3rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

#load-more-btn:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

#load-more-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* =============================================
   EMPTY STATE
   ============================================= */

.no-products {
  grid-column: 1 / -1;
  text-align: center;
  padding: 5rem 1rem;
  color: var(--text-muted);
}

.no-products p {
  font-size: 1rem;
  margin-top: 0.5rem;
}

/* =============================================
   SEARCH RESULTS PAGE
   ============================================= */

.search-header {
  padding: 2.5rem 2rem 0;
  max-width: 1440px;
  margin: 0 auto;
}

.search-header__title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
}

.search-header__title em {
  font-style: normal;
  color: var(--text);
}

.search-count {
  max-width: 1440px;
  margin: 0.5rem auto 0;
  padding: 0 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.search-empty {
  max-width: 1440px;
  margin: 3rem auto;
  padding: 0 2rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.search-empty strong {
  color: var(--text);
}

.search-empty__hint {
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* =============================================
   FOOTER
   ============================================= */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
}
