/* =============================================================
   Mega Deals Hub — Main Stylesheet
   Author: Mega Deals Hub
   Description: Styles for the main deals listing page
   ============================================================= */

/* ── DESIGN TOKENS ── */
:root {
  --bg:        #080a10;
  --surface:   #0f1119;
  --glass:     rgba(255, 255, 255, 0.04);
  --border:    rgba(255, 255, 255, 0.08);
  --red:       #ff2d55;
  --orange:    #ff9f0a;
  --cyan:      #00e5ff;
  --text:      #f0f0f5;
  --muted:     rgba(240, 240, 245, 0.45);
  --card-r:    14px;
  --hdr-h:     72px;
  --ease:      cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden;
  min-height: 100vh;
}

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

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

/* ── NOISE OVERLAY ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.025;
  pointer-events: none;
}

/* ── AMBIENT BLOBS ── */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}

.blob-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255, 45, 85, 0.18), transparent 70%);
  top: -200px;
  left: -200px;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.12), transparent 70%);
  bottom: 10%;
  right: -150px;
}

.blob-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 159, 10, 0.10), transparent 70%);
  top: 40%;
  left: 30%;
}

/* ── HEADER ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--hdr-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(8, 10, 16, 0.82);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border-bottom: 1px solid var(--border);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--red), var(--orange));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 45, 85, 0.4);
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 26px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #fff 0%, rgba(255, 255, 255, 0.6) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
  margin: 0 28px;
}

.search-wrap input {
  width: 100%;
  height: 40px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0 44px 0 18px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.search-wrap input:focus {
  border-color: rgba(255, 45, 85, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 45, 85, 0.1);
}

.search-wrap button {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.search-wrap button:hover {
  color: var(--red);
}

.search-wrap button svg {
  width: 16px;
  height: 16px;
}

/* Live badge */
.header-badge {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.25);
  padding: 4px 10px;
  border-radius: 100px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

/* ── TICKER ── */
.ticker-wrap {
  position: relative;
  z-index: 1;
  overflow: hidden;
  background: linear-gradient(90deg, var(--red), var(--orange));
  padding: 8px 0;
}

.ticker-inner {
  display: flex;
  gap: 60px;
  width: max-content;
  animation: ticker 30s linear infinite;
}

.ticker-inner span {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.ticker-inner span::before {
  content: '⚡ ';
}

/* ── SECTION HEADERS ── */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 40px 28px 20px;
  position: relative;
  z-index: 1;
}

.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 36px;
  letter-spacing: 1.5px;
  color: var(--text);
}

.section-accent {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 10px var(--red);
  flex-shrink: 0;
  align-self: center;
  animation: pulse 2s ease-in-out infinite;
}

.section-accent--cyan {
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: none;
}

.section-sub {
  font-size: 13px;
  color: var(--muted);
  font-family: 'Space Mono', monospace;
  margin-left: auto;
}

/* ── PRODUCT GRID ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  padding: 0 28px 40px;
  position: relative;
  z-index: 1;
}

/* ── CARD ── */
.card {
  position: relative;
  border-radius: var(--card-r);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s;
  animation: cardIn 0.5s var(--ease) both;
}

.card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 45, 85, 0.2);
  border-color: rgba(255, 45, 85, 0.25);
}

/* Skeleton placeholders */
.card--skeleton {
  opacity: 0.4;
  pointer-events: none;
}

.card__skeleton-title {
  background: var(--glass);
  height: 36px;
  border-radius: 6px;
}

/* Card image */
.card-img-wrap {
  position: relative;
  height: 200px;
  overflow: hidden;
  background: #12141c;
}

.card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease), filter 0.3s;
}

.card:hover .card-img-wrap img {
  transform: scale(1.07);
  filter: brightness(1.1);
}

/* gradient over image */
.card-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(8, 10, 16, 0.85) 100%);
  pointer-events: none;
}

/* ── BADGES ── */
.badge {
  position: absolute;
  z-index: 2;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  line-height: 1.4;
}

.badge--rank {
  top: 10px;
  left: 10px;
  background: linear-gradient(135deg, var(--red), var(--orange));
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 45, 85, 0.4);
}

.badge--off {
  top: 10px;
  left: 10px;
  background: rgba(255, 159, 10, 0.15);
  border: 1px solid rgba(255, 159, 10, 0.4);
  color: var(--orange);
}

.badge--price {
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: #fff;
}

.badge--price s {
  color: var(--muted);
  margin-right: 4px;
}

.badge--stars {
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  color: var(--orange);
  border: 1px solid rgba(255, 159, 10, 0.2);
}

.badge--updated {
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* Card body */
.card-body {
  padding: 12px 14px 14px;
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 36px;
}

/* ── MODAL ── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.2s ease;
}

.modal-box {
  position: relative;
  z-index: 1;
  background: #0f1119;
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  animation: slideUp 0.3s var(--ease);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
}

.modal-img {
  width: 100%;
  height: 260px;
  object-fit: contain;
  background: #12141c;
  padding: 20px;
}

.modal-body {
  padding: 20px 24px 24px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 14px;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.meta-chip {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.meta-chip--price {
  border-color: rgba(255, 159, 10, 0.3);
  color: var(--orange);
}

.meta-chip--stars {
  border-color: rgba(255, 159, 10, 0.2);
  color: var(--orange);
}

.meta-chip--saved {
  color: var(--red);
  border-color: rgba(255, 45, 85, 0.3);
}

.btn-buy {
  display: block;
  width: 100%;
  padding: 14px;
  background: linear-gradient(90deg, var(--red), var(--orange));
  color: #fff;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 1.5px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 8px 24px rgba(255, 45, 85, 0.35);
}

.btn-buy:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(255, 45, 85, 0.2);
}

/* ── LOADER ── */
#load {
  display: none;
  justify-content: center;
  align-items: center;
  padding: 40px;
  position: relative;
  z-index: 1;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── ERROR PAGE ── */
#error-page {
  display: none;
  text-align: center;
  padding: 80px 28px;
  position: relative;
  z-index: 1;
}

#error-page h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 42px;
  color: var(--red);
  margin-bottom: 12px;
}

#error-page p {
  color: var(--muted);
  line-height: 1.6;
}

#error-page a {
  color: var(--cyan);
}

/* ── DIVIDER ── */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0;
  position: relative;
  z-index: 1;
}

/* ── FOOTER ── */
footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  gap: 10px;
}

footer span {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

footer a {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--red);
  transition: color 0.2s;
}

footer a:hover {
  color: var(--orange);
}

/* ── ANIMATIONS ── */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

@keyframes ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ── CARD STAGGER ── */
.card:nth-child(1)   { animation-delay: 0.05s; }
.card:nth-child(2)   { animation-delay: 0.10s; }
.card:nth-child(3)   { animation-delay: 0.15s; }
.card:nth-child(4)   { animation-delay: 0.20s; }
.card:nth-child(5)   { animation-delay: 0.25s; }
.card:nth-child(6)   { animation-delay: 0.30s; }
.card:nth-child(7)   { animation-delay: 0.35s; }
.card:nth-child(8)   { animation-delay: 0.40s; }
.card:nth-child(n+9) { animation-delay: 0.45s; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .section-sub,
  .header-badge { display: none; }

  .search-wrap {
    max-width: 200px;
    margin: 0 12px;
  }

  .logo-text { font-size: 20px; }

  .grid {
    padding: 0 14px 32px;
    gap: 10px;
    grid-template-columns: repeat(2, 1fr);
  }

  .section-header { padding: 28px 14px 14px; }
  .card-img-wrap  { height: 160px; }
}

@media (min-width: 600px) and (max-width: 900px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ── ACCESSIBILITY ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}