/* =====================================================
   DealIQ — Design Tokens & Styles
   Art direction: Deal-hunting energy. Warm darks, 
   punchy orange accent for urgency, clean card UI.
   ===================================================== */

:root {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 180ms var(--ease);

  /* Fonts */
  --font-display: 'Space Grotesk', 'Helvetica Neue', sans-serif;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;

  /* Content widths */
  --content-wide: 1200px;
}

/* ===== LIGHT MODE (default) ===== */
:root, [data-theme="light"] {
  --color-bg:          #fafaf8;
  --color-surface:     #ffffff;
  --color-surface-2:   #f5f4f0;
  --color-border:      #e5e3de;
  --color-text:        #1a1a18;
  --color-text-muted:  #6b6a66;
  --color-text-faint:  #a8a7a3;
  --color-accent:      #e8590c;
  --color-accent-hover:#d14b08;
  --color-accent-soft: #fff3ed;
  --color-deal-green:  #16a34a;
  --color-deal-red:    #dc2626;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
}

/* ===== DARK MODE ===== */
[data-theme="dark"] {
  --color-bg:          #111110;
  --color-surface:     #1a1918;
  --color-surface-2:   #222120;
  --color-border:      #333230;
  --color-text:        #e8e7e3;
  --color-text-muted:  #9c9b97;
  --color-text-faint:  #5a5955;
  --color-accent:      #f97316;
  --color-accent-hover:#fb923c;
  --color-accent-soft: #2a1f14;
  --color-deal-green:  #4ade80;
  --color-deal-red:    #f87171;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:          #111110;
    --color-surface:     #1a1918;
    --color-surface-2:   #222120;
    --color-border:      #333230;
    --color-text:        #e8e7e3;
    --color-text-muted:  #9c9b97;
    --color-text-faint:  #5a5955;
    --color-accent:      #f97316;
    --color-accent-hover:#fb923c;
    --color-accent-soft: #2a1f14;
    --color-deal-green:  #4ade80;
    --color-deal-red:    #f87171;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  }
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.02em;
}

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

.header-nav {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
}
.header-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  white-space: nowrap;
  border: 1px solid transparent;
}

.nav-tab:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

.nav-tab.active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-color: color-mix(in srgb, var(--color-accent) 20%, transparent);
}

.header-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.theme-toggle:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

/* ===== HERO ===== */
.hero {
  padding: clamp(var(--space-12), 6vw, var(--space-20)) var(--space-5);
  text-align: center;
}

.hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-deal-green);
  background: color-mix(in srgb, var(--color-deal-green) 8%, var(--color-bg));
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid color-mix(in srgb, var(--color-deal-green) 20%, transparent);
  margin-bottom: var(--space-6);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-deal-green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: var(--space-4);
}

.gradient-text {
  background: linear-gradient(135deg, var(--color-accent) 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 540px;
  margin: 0 auto var(--space-8);
  line-height: 1.6;
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--color-border);
}

/* ===== AD SLOTS ===== */
.ad-slot {
  max-width: var(--content-wide);
  margin: 0 auto var(--space-8);
  padding: 0 var(--space-5);
}

.ad-placeholder {
  background: var(--color-surface-2);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

/* ===== DEALS SECTION ===== */
.deals-section {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-5) var(--space-12);
}

.deals-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sort-select {
  appearance: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6a66' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* ===== DEALS GRID ===== */
.deals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-5);
}

/* ===== DEAL CARD ===== */
.deal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
}

.deal-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.deal-card-top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  flex: 1;
}

.deal-emoji {
  font-size: 2.5rem;
  line-height: 1;
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.deal-emoji img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 6px;
  background: #fff;
  border-radius: inherit;
}

.deal-info {
  flex: 1;
  min-width: 0;
}

.deal-category-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

.deal-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--space-1);
  color: var(--color-text);
}

.deal-description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.deal-rating {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.deal-rating svg {
  color: #f59e0b;
  display: inline;
}

.deal-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.deal-pricing {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.deal-price {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-deal-green);
  font-variant-numeric: tabular-nums;
}

.deal-original-price {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}

.deal-discount {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-deal-red) 10%, var(--color-bg));
  color: var(--color-deal-red);
}

.deal-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  border: 1px solid color-mix(in srgb, var(--color-accent) 15%, transparent);
}

.deal-cta:hover {
  background: var(--color-accent);
  color: #fff;
}

.deal-cta svg {
  width: 14px;
  height: 14px;
  display: inline;
}

/* ===== SKELETON LOADING ===== */
.deal-card.skeleton {
  padding: var(--space-5);
  min-height: 220px;
}

.skeleton-img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 14px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  margin-top: var(--space-3);
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-text.short {
  width: 60%;
}

@keyframes shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== HOW IT WORKS ===== */
.how-section {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: clamp(var(--space-12), 6vw, var(--space-20)) var(--space-5);
  text-align: center;
}

.how-section .section-title {
  margin-bottom: var(--space-10);
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-6);
}

.how-card {
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.how-icon {
  font-size: 2rem;
  margin-bottom: var(--space-4);
}

.how-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.how-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
}

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-10) var(--space-5);
  background: var(--color-surface-2);
}

.footer-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.footer-logo {
  font-size: var(--text-base);
}

.footer-tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.footer-disclosure {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.6;
  max-width: 640px;
}

.footer-copyright {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-16) var(--space-4);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.empty-state p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  max-width: 320px;
  margin: 0 auto;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .header-nav {
    order: 3;
    width: 100%;
    padding-bottom: var(--space-1);
  }

  .hero-stats {
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .stat-divider {
    width: 48px;
    height: 1px;
  }

  .deals-grid {
    grid-template-columns: 1fr;
  }

  .deals-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .deal-card-top {
    padding: var(--space-4);
  }
  
  .deal-card-bottom {
    padding: var(--space-3) var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-2);
  }
}
