/*
Theme Name: BrokeFinds
Theme URI: https://example.com/brokefinds
Author: Your Name
Author URI: https://example.com
Description: A modern product curation & affiliate theme inspired by ThisIsWhyImBroke — but fresh. Masonry grid, affiliate buttons, infinite scroll, dark/light mode.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: brokefinds
Tags: grid-layout, custom-logo, custom-menu, featured-images, translation-ready
*/

/* =========================================
   CSS RESET & VARIABLES
   ========================================= */

:root {
  /* Light mode (default) */
  --bf-bg: #f5f2ec;
  --bf-bg-alt: #eae6dd;
  --bf-surface: #ffffff;
  --bf-surface-hover: #faf9f7;
  --bf-text: #1a1714;
  --bf-text-muted: #6b635a;
  --bf-text-light: #9a928a;
  --bf-accent: #e8503a;
  --bf-accent-hover: #d4422e;
  --bf-accent-soft: rgba(232, 80, 58, 0.08);
  --bf-border: #ddd8d0;
  --bf-border-light: #eae6dd;
  --bf-tag-bg: #f0ece5;
  --bf-tag-text: #6b635a;
  --bf-shadow-sm: 0 1px 3px rgba(26, 23, 20, 0.04);
  --bf-shadow-md: 0 4px 16px rgba(26, 23, 20, 0.06);
  --bf-shadow-lg: 0 8px 32px rgba(26, 23, 20, 0.1);
  --bf-shadow-hover: 0 12px 40px rgba(26, 23, 20, 0.12);
  --bf-radius: 12px;
  --bf-radius-sm: 8px;
  --bf-radius-lg: 20px;
  --bf-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --bf-max-width: 1320px;
  --bf-font-display: 'Clash Display', 'Satoshi', sans-serif;
  --bf-font-body: 'Satoshi', 'DM Sans', sans-serif;
  --bf-font-mono: 'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --bf-bg: #111110;
  --bf-bg-alt: #1a1918;
  --bf-surface: #222120;
  --bf-surface-hover: #2a2928;
  --bf-text: #f0ece5;
  --bf-text-muted: #9a928a;
  --bf-text-light: #6b635a;
  --bf-accent: #f06c58;
  --bf-accent-hover: #f58070;
  --bf-accent-soft: rgba(240, 108, 88, 0.1);
  --bf-border: #2e2d2b;
  --bf-border-light: #222120;
  --bf-tag-bg: #2a2928;
  --bf-tag-text: #9a928a;
  --bf-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --bf-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.25);
  --bf-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
  --bf-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.4);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--bf-font-body);
  background-color: var(--bf-bg);
  color: var(--bf-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--bf-transition), color var(--bf-transition);
}

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

a {
  color: inherit;
  text-decoration: none;
}

/* =========================================
   HEADER & NAVIGATION
   ========================================= */

.bf-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bf-bg);
  border-bottom: 1px solid var(--bf-border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--bf-transition), border-color var(--bf-transition);
}

.bf-header-inner {
  max-width: var(--bf-max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.bf-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--bf-font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  color: var(--bf-text);
  transition: color var(--bf-transition);
}

.bf-logo img {
  height: 36px;
  width: auto;
}

.bf-logo .bf-logo-accent {
  color: var(--bf-accent);
}

/* Nav */
.bf-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bf-nav a {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--bf-text-muted);
  border-radius: var(--bf-radius-sm);
  transition: all var(--bf-transition);
  position: relative;
}

.bf-nav a:hover,
.bf-nav a.current-menu-item > a,
.bf-nav a.current_page_item > a {
  color: var(--bf-text);
  background: var(--bf-accent-soft);
}

.bf-nav a.active,
.bf-nav .current-menu-item > a,
.bf-nav .current_page_item > a {
  color: var(--bf-accent);
  font-weight: 600;
}

/* Header actions */
.bf-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bf-search-toggle,
.bf-theme-toggle,
.bf-menu-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--bf-text-muted);
  border-radius: var(--bf-radius-sm);
  cursor: pointer;
  transition: all var(--bf-transition);
}

.bf-search-toggle:hover,
.bf-theme-toggle:hover,
.bf-menu-toggle:hover {
  background: var(--bf-accent-soft);
  color: var(--bf-accent);
}

.bf-menu-toggle {
  display: none;
}

/* Search overlay */
.bf-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(26, 23, 20, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.bf-search-overlay.active {
  opacity: 1;
  visibility: visible;
}

.bf-search-box {
  width: 90%;
  max-width: 640px;
  background: var(--bf-surface);
  border-radius: var(--bf-radius-lg);
  padding: 8px;
  box-shadow: var(--bf-shadow-lg);
  transform: translateY(-20px);
  transition: transform 0.3s ease;
}

.bf-search-overlay.active .bf-search-box {
  transform: translateY(0);
}

.bf-search-box input {
  width: 100%;
  padding: 16px 24px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  font-family: var(--bf-font-body);
  color: var(--bf-text);
  outline: none;
}

.bf-search-box input::placeholder {
  color: var(--bf-text-light);
}

/* =========================================
   HERO SECTION
   ========================================= */

.bf-hero {
  max-width: var(--bf-max-width);
  margin: 0 auto;
  padding: 64px 24px 48px;
  text-align: center;
}

.bf-hero h1 {
  font-family: var(--bf-font-display);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 16px;
  color: var(--bf-text);
}

.bf-hero h1 .bf-highlight {
  color: var(--bf-accent);
  position: relative;
}

.bf-hero h1 .bf-highlight::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--bf-accent);
  opacity: 0.2;
  border-radius: 3px;
}

.bf-hero p {
  font-size: 1.15rem;
  color: var(--bf-text-muted);
  max-width: 520px;
  margin: 0 auto 32px;
  line-height: 1.6;
}

/* Category pills */
.bf-categories {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.bf-cat-pill {
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bf-surface);
  color: var(--bf-text-muted);
  border: 1px solid var(--bf-border);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--bf-transition);
  text-decoration: none;
}

.bf-cat-pill:hover,
.bf-cat-pill.active {
  background: var(--bf-accent);
  color: #fff;
  border-color: var(--bf-accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(232, 80, 58, 0.25);
}

/* =========================================
   PRODUCT GRID (Masonry)
   ========================================= */

.bf-grid-wrap {
  max-width: var(--bf-max-width);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.bf-product-grid {
  column-count: 4;
  column-gap: 20px;
}

/* Single product card */
.bf-card {
  break-inside: avoid;
  margin-bottom: 20px;
  background: var(--bf-surface);
  border-radius: var(--bf-radius);
  overflow: hidden;
  border: 1px solid var(--bf-border-light);
  transition: all var(--bf-transition);
  position: relative;
}

.bf-card:hover {
  box-shadow: var(--bf-shadow-hover);
  transform: translateY(-4px);
  border-color: var(--bf-border);
}

/* Card image */
.bf-card-image {
  position: relative;
  overflow: hidden;
  background: var(--bf-bg-alt);
}

.bf-card-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s ease;
}

.bf-card:hover .bf-card-image img {
  transform: scale(1.04);
}

/* Price badge */
.bf-card-price {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bf-surface);
  color: var(--bf-text);
  font-family: var(--bf-font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 100px;
  box-shadow: var(--bf-shadow-md);
  z-index: 2;
}

/* Card tags */
.bf-card-tags {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.bf-card-tag {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--bf-accent);
  color: #fff;
}

.bf-card-tag.bf-tag-trending {
  background: #8b5cf6;
}

.bf-card-tag.bf-tag-new {
  background: #059669;
}

/* Card body */
.bf-card-body {
  padding: 20px;
}

.bf-card-category {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bf-accent);
  margin-bottom: 8px;
  display: block;
}

.bf-card-title {
  font-family: var(--bf-font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.35;
  margin-bottom: 8px;
  color: var(--bf-text);
  transition: color var(--bf-transition);
}

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

.bf-card-excerpt {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--bf-text-muted);
  margin-bottom: 16px;
}

/* Affiliate button */
.bf-buy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  font-family: var(--bf-font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--bf-accent);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--bf-transition);
  text-decoration: none;
  width: 100%;
  justify-content: center;
}

.bf-buy-btn:hover {
  background: var(--bf-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(232, 80, 58, 0.3);
}

.bf-buy-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--bf-transition);
}

.bf-buy-btn:hover svg {
  transform: translateX(3px);
}

/* Card footer meta */
.bf-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--bf-border-light);
  font-size: 0.78rem;
  color: var(--bf-text-light);
}

.bf-card-share {
  display: flex;
  gap: 6px;
}

.bf-card-share button {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bf-tag-bg);
  color: var(--bf-text-muted);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--bf-transition);
}

.bf-card-share button:hover {
  background: var(--bf-accent);
  color: #fff;
}

/* =========================================
   LOADING & INFINITE SCROLL
   ========================================= */

.bf-loader {
  text-align: center;
  padding: 48px 0;
}

.bf-loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bf-border);
  border-top-color: var(--bf-accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: bf-spin 0.8s linear infinite;
}

@keyframes bf-spin {
  to { transform: rotate(360deg); }
}

.bf-loader-text {
  font-size: 0.85rem;
  color: var(--bf-text-light);
}

/* =========================================
   SINGLE PRODUCT PAGE
   ========================================= */

.bf-single {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.bf-single-image {
  border-radius: var(--bf-radius-lg);
  overflow: hidden;
  margin-bottom: 32px;
  background: var(--bf-bg-alt);
}

.bf-single-image img {
  width: 100%;
}

.bf-single-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.bf-single-category {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bf-accent);
}

.bf-single-price {
  font-family: var(--bf-font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bf-text);
  background: var(--bf-accent-soft);
  padding: 6px 16px;
  border-radius: 100px;
}

.bf-single h1 {
  font-family: var(--bf-font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 20px;
}

.bf-single .bf-single-content {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--bf-text-muted);
  margin-bottom: 32px;
}

.bf-single .bf-buy-btn {
  width: auto;
  padding: 14px 36px;
  font-size: 1rem;
}

/* Related products */
.bf-related {
  max-width: var(--bf-max-width);
  margin: 0 auto;
  padding: 0 24px 80px;
}

.bf-related h2 {
  font-family: var(--bf-font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 28px;
  text-align: center;
}

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

.bf-footer {
  background: var(--bf-bg-alt);
  border-top: 1px solid var(--bf-border-light);
  padding: 48px 24px;
  transition: all var(--bf-transition);
}

.bf-footer-inner {
  max-width: var(--bf-max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
}

.bf-footer-brand p {
  font-size: 0.9rem;
  color: var(--bf-text-muted);
  margin-top: 12px;
  line-height: 1.6;
  max-width: 300px;
}

.bf-footer h4 {
  font-family: var(--bf-font-display);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
  color: var(--bf-text);
}

.bf-footer ul {
  list-style: none;
}

.bf-footer ul li {
  margin-bottom: 10px;
}

.bf-footer ul a {
  font-size: 0.88rem;
  color: var(--bf-text-muted);
  transition: color var(--bf-transition);
}

.bf-footer ul a:hover {
  color: var(--bf-accent);
}

.bf-footer-bottom {
  max-width: var(--bf-max-width);
  margin: 32px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--bf-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--bf-text-light);
}

/* Affiliate disclosure */
.bf-disclosure {
  max-width: var(--bf-max-width);
  margin: 0 auto;
  padding: 0 24px;
  font-size: 0.78rem;
  color: var(--bf-text-light);
  text-align: center;
  margin-bottom: 32px;
}

/* =========================================
   PAGINATION (fallback for no-JS)
   ========================================= */

.bf-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 32px 0 64px;
}

.bf-pagination a,
.bf-pagination span {
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--bf-radius-sm);
  background: var(--bf-surface);
  border: 1px solid var(--bf-border);
  color: var(--bf-text-muted);
  transition: all var(--bf-transition);
}

.bf-pagination a:hover {
  background: var(--bf-accent);
  color: #fff;
  border-color: var(--bf-accent);
}

.bf-pagination .current {
  background: var(--bf-accent);
  color: #fff;
  border-color: var(--bf-accent);
}

/* =========================================
   ANIMATIONS
   ========================================= */

@keyframes bf-fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bf-card {
  animation: bf-fadeInUp 0.5s ease both;
}

.bf-card:nth-child(1) { animation-delay: 0.05s; }
.bf-card:nth-child(2) { animation-delay: 0.1s; }
.bf-card:nth-child(3) { animation-delay: 0.15s; }
.bf-card:nth-child(4) { animation-delay: 0.2s; }
.bf-card:nth-child(5) { animation-delay: 0.25s; }
.bf-card:nth-child(6) { animation-delay: 0.3s; }
.bf-card:nth-child(7) { animation-delay: 0.35s; }
.bf-card:nth-child(8) { animation-delay: 0.4s; }

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 1200px) {
  .bf-product-grid {
    column-count: 3;
  }
}

@media (max-width: 900px) {
  .bf-product-grid {
    column-count: 2;
  }

  .bf-footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .bf-nav {
    display: none;
  }

  .bf-menu-toggle {
    display: flex;
  }

  .bf-header-inner {
    height: 60px;
  }

  .bf-hero {
    padding: 40px 24px 32px;
  }

  .bf-hero h1 {
    font-size: 1.8rem;
  }
}

@media (max-width: 560px) {
  .bf-product-grid {
    column-count: 1;
    max-width: 440px;
    margin: 0 auto;
  }

  .bf-footer-inner {
    grid-template-columns: 1fr;
  }

  .bf-footer-bottom {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

/* =========================================
   MOBILE MENU
   ========================================= */

.bf-mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: var(--bf-bg);
  padding: 80px 32px 32px;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.bf-mobile-menu.active {
  transform: translateX(0);
}

.bf-mobile-menu-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bf-tag-bg);
  border-radius: 50%;
  cursor: pointer;
  color: var(--bf-text);
  font-size: 1.4rem;
}

.bf-mobile-menu a {
  display: block;
  padding: 16px 0;
  font-family: var(--bf-font-display);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--bf-text);
  border-bottom: 1px solid var(--bf-border-light);
  transition: color var(--bf-transition);
}

.bf-mobile-menu a:hover {
  color: var(--bf-accent);
}

/* =========================================
   WIDGET AREAS
   ========================================= */

.widget {
  margin-bottom: 24px;
}

.widget-title {
  font-family: var(--bf-font-display);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* WP defaults */
.alignleft { float: left; margin: 0 1.5em 1.5em 0; }
.alignright { float: right; margin: 0 0 1.5em 1.5em; }
.aligncenter { display: block; margin: 0 auto 1.5em; }

.wp-caption { max-width: 100%; }
.wp-caption-text { font-size: 0.82rem; color: var(--bf-text-muted); padding: 8px 0; }

.screen-reader-text {
  clip: rect(1px, 1px, 1px, 1px);
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
}

/* =========================================
   BACK TO TOP
   ========================================= */

.bf-back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bf-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(232, 80, 58, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: all var(--bf-transition);
  z-index: 999;
}

.bf-back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.bf-back-to-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(232, 80, 58, 0.4);
}
