/* ============================================
   MyMemes — Light & Dark Theme
   Light by default · Dark via [data-theme="dark"]
   Accent: Emerald Green
   ============================================ */

:root {
  --radius: 0.875rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-lg: calc(var(--radius) + 4px);

  /* ---------- LIGHT (default) ---------- */
  --bg: #f4f7f5;
  --bg-card: #ffffff;
  --bg-secondary: #edf2ee;
  --bg-muted: #e5ebe7;
  --fg: #16211b;
  --fg-muted: #61706a;

  --brand: #0e9f6e;
  --brand-light: #0c8a60;
  --brand-dark: #067a53;
  --brand-soft: rgba(14, 159, 110, 0.10);
  --brand-glow: rgba(14, 159, 110, 0.25);

  --border: #e2e9e4;
  --border-strong: #cbd6cf;
  --border-hover: rgba(14, 159, 110, 0.55);

  --shadow-sm: 0 1px 2px rgba(22, 33, 27, 0.06);
  --shadow-md: 0 2px 6px rgba(22, 33, 27, 0.06), 0 10px 28px rgba(22, 33, 27, 0.08);
  --shadow-lg: 0 8px 40px rgba(22, 33, 27, 0.14);

  --header-bg: rgba(255, 255, 255, 0.82);
  --dropdown-bg: rgba(255, 255, 255, 0.96);
  --on-brand: #ffffff;

  --font-sans: 'Inter', 'Cairo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html[data-theme="dark"] {
  --bg: #0d1310;
  --bg-card: #141b17;
  --bg-secondary: #1b241f;
  --bg-muted: #111713;
  --fg: #e8f1eb;
  --fg-muted: #8b9c93;

  --brand: #34d399;
  --brand-light: #6ee7b7;
  --brand-dark: #10a56d;
  --brand-soft: rgba(52, 211, 153, 0.12);
  --brand-glow: rgba(52, 211, 153, 0.35);

  --border: rgba(148, 178, 162, 0.14);
  --border-strong: rgba(148, 178, 162, 0.30);
  --border-hover: rgba(52, 211, 153, 0.55);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.55);

  --header-bg: rgba(13, 19, 16, 0.82);
  --dropdown-bg: rgba(20, 27, 23, 0.97);
  --on-brand: #06281c;
}

/* RTL: swap font priority to Cairo for better Arabic glyphs */
html[dir="rtl"] {
  --font-sans: 'Cairo', 'Inter', system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background-color 0.35s ease, color 0.35s ease;
}

body { display: flex; flex-direction: column; min-height: 100vh; }
main { flex: 1; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 640px) { .container { padding: 0 1.5rem; } }
@media (min-width: 1024px) { .container { padding: 0 2rem; } }

.desktop-only { display: none; }
@media (min-width: 768px) {
  .desktop-only { display: inline-flex; }
  .mobile-only { display: none !important; }
}
.mobile-only { display: inline-flex; }

/* ============================================
   HEADER
   ============================================ */
.glass {
  background: var(--header-bg);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  transition: background-color 0.35s ease, border-color 0.35s ease;
}

#header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

.logo-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.8rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-brand);
  box-shadow: 0 4px 14px var(--brand-glow);
}

.logo-icon-sm {
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-brand);
}

.site-name {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--fg);
}

.site-tagline {
  font-size: 0.65rem;
  color: var(--fg-muted);
  margin-top: -2px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.search-bar {
  position: relative;
  flex: 1;
  max-width: 28rem;
  margin: 0 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  color: var(--fg);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s, background-color 0.35s ease, box-shadow 0.2s;
}
html[dir="rtl"] .search-bar input { padding: 0.55rem 2.5rem 0.55rem 1rem; }
.search-bar input:focus {
  border-color: var(--brand);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.search-bar input::placeholder { color: var(--fg-muted); }

.search-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0.75rem;
  color: var(--fg-muted);
  pointer-events: none;
}
html[dir="rtl"] .search-icon { left: auto; right: 0.75rem; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid transparent;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  color: var(--fg-muted);
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.icon-btn:hover {
  background: var(--bg-secondary);
  color: var(--brand);
}

/* Theme toggle — sun/moon swap */
#theme-btn { position: relative; overflow: hidden; }
#theme-btn .icon-sun,
#theme-btn .icon-moon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
#theme-btn .icon-moon { transform: translateY(0) rotate(0deg); opacity: 1; }
#theme-btn .icon-sun  { transform: translateY(150%) rotate(90deg); opacity: 0; }
html[data-theme="dark"] #theme-btn .icon-moon { transform: translateY(-150%) rotate(-90deg); opacity: 0; }
html[data-theme="dark"] #theme-btn .icon-sun  { transform: translateY(0) rotate(0deg); opacity: 1; }

.mobile-search { padding: 0 1rem 1rem; }
.mobile-search .search-bar { margin: 0; max-width: none; }

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */
.lang-switcher { position: relative; }

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.42rem 0.7rem;
  border-radius: 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--fg);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
.lang-btn:hover { border-color: var(--border-hover); color: var(--brand); }
.lang-btn .chevron { transition: transform 0.25s; color: var(--fg-muted); }
.lang-btn:hover .chevron { color: var(--brand); }
.lang-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  inset-inline-end: 0;
  width: 11rem;
  background: var(--dropdown-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 100;
  animation: dropIn 0.18s ease;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 0.8rem;
  font-size: 0.875rem;
  color: var(--fg);
  transition: background 0.15s;
}
.lang-item:hover { background: var(--bg-secondary); }
.lang-item.active { color: var(--brand); font-weight: 600; }

.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.3rem;
  border-radius: 0.3rem;
  font-size: 0.62rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand);
  margin-inline-end: 0.625rem;
  letter-spacing: 0.03em;
}

/* ============================================
   HERO
   ============================================ */
.hero {
  position: relative;
  overflow: hidden;
  padding: 3.5rem 0 2.5rem;
}
@media (min-width: 640px) { .hero { padding: 5.5rem 0 3.5rem; } }

.hero-glow {
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 900px;
  height: 480px;
  background: radial-gradient(ellipse at center, var(--brand-soft) 0%, transparent 65%);
  border-radius: 50%;
  filter: blur(50px);
  pointer-events: none;
}

.hero-content {
  position: relative;
  text-align: center;
  max-width: 48rem;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 1rem;
  border-radius: 9999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.hero-title {
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.12;
  letter-spacing: -0.03em;
}
@media (min-width: 640px) { .hero-title { font-size: 3.2rem; } }
@media (min-width: 1024px) { .hero-title { font-size: 3.9rem; } }

.hero-sub {
  font-size: 1.05rem;
  color: var(--fg-muted);
  margin-bottom: 2.25rem;
  line-height: 1.7;
}
@media (min-width: 640px) { .hero-sub { font-size: 1.2rem; } }

.hero-stats {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 1rem 0.5rem;
  box-shadow: var(--shadow-md);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 1.4rem;
}
@media (min-width: 640px) { .stat { padding: 0 2.4rem; } }

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.02em;
}
@media (min-width: 640px) { .stat-value { font-size: 1.8rem; } }

.stat-label {
  font-size: 0.72rem;
  color: var(--fg-muted);
  font-weight: 500;
  margin-top: 0.15rem;
}

.stat-divider {
  width: 1px;
  background: var(--border);
  margin: 0.2rem 0;
}

/* ============================================
   CATEGORIES
   ============================================ */
.categories-section { padding: 2rem 0 1.5rem; }

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-header h3 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to var(--dir-end, right), transparent, var(--border-strong), transparent);
}
html[dir="rtl"] .section-line { --dir-end: left; }

.category-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
}
.category-list::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: 9999px;
  font-size: 0.83rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.cat-btn:hover {
  border-color: var(--border-hover);
  color: var(--brand);
  transform: translateY(-1px);
}
.cat-btn.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: var(--on-brand);
  border-color: transparent;
  box-shadow: 0 4px 14px var(--brand-glow);
}
.cat-btn.active:hover { color: var(--on-brand); transform: none; }
.cat-btn .cat-count {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.65;
}

/* ============================================
   SORT BAR
   ============================================ */
.sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.results-info {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-weight: 500;
}

.sort-buttons {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.25rem;
  box-shadow: var(--shadow-sm);
}

.sort-label {
  font-size: 0.75rem;
  color: var(--fg-muted);
  padding: 0 0.4rem;
}

.sort-btn {
  padding: 0.35rem 0.85rem;
  border-radius: 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-muted);
  transition: all 0.2s;
}
.sort-btn:hover { color: var(--brand); }
.sort-btn.active {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 2px 8px var(--brand-glow);
}

/* ============================================
   SOUNDS GRID
   ============================================ */
.sounds-section { padding-bottom: 3rem; }

.sounds-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}
@media (min-width: 640px) { .sounds-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .sounds-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .sounds-grid { grid-template-columns: repeat(4, 1fr); } }

.sound-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease,
              background-color 0.35s ease;
  box-shadow: var(--shadow-sm);
}
.sound-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}
.sound-card.playing {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 2rem);
}

.card-cat {
  font-size: 0.73rem;
  color: var(--fg-muted);
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-color {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  flex-shrink: 0;
  margin-inline-start: 0.5rem;
  border: 1px solid var(--border);
}

.play-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.72rem;
  border-radius: 0.8rem;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand);
  transition: all 0.2s;
}
.play-btn:hover {
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 4px 14px var(--brand-glow);
}
.play-btn.playing {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: var(--on-brand);
  box-shadow: 0 4px 14px var(--brand-glow);
}

.play-wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: 0.35rem;
  height: 20px;
}
.play-wave span {
  display: inline-block;
  width: 3px;
  height: 4px;
  background: currentColor;
  border-radius: 9999px;
  animation: soundwave 0.8s ease-in-out infinite;
}
.play-wave span:nth-child(2) { animation-delay: 0.1s; }
.play-wave span:nth-child(3) { animation-delay: 0.2s; }
.play-wave span:nth-child(4) { animation-delay: 0.3s; }
.play-wave span:nth-child(5) { animation-delay: 0.15s; }

@keyframes soundwave {
  0%, 100% { height: 4px; }
  50% { height: 18px; }
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.85rem;
}

.card-plays {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.73rem;
  color: var(--fg-muted);
  font-weight: 500;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border-radius: 0.55rem;
  color: var(--fg-muted);
  transition: all 0.15s;
}
.card-action:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.card-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.65rem;
}

.tag {
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  background: var(--bg-secondary);
  color: var(--fg-muted);
  border-radius: 9999px;
}

/* Skeleton */
.card-skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  position: relative;
  overflow: hidden;
}
.card-skeleton::before {
  content: '';
  display: block;
  height: 1.25rem;
  background: var(--bg-muted);
  border-radius: 0.3rem;
  width: 75%;
  margin-bottom: 0.85rem;
}
.card-skeleton::after {
  content: '';
  display: block;
  height: 2.6rem;
  background: var(--bg-muted);
  border-radius: 0.6rem;
  margin-top: 0.5rem;
}
.card-skeleton::before, .card-skeleton::after {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 5rem 1rem;
}

.empty-icon {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--brand-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  margin-bottom: 1.25rem;
}

.empty-state h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--fg-muted);
  margin-bottom: 1.5rem;
}

.btn-outline {
  padding: 0.55rem 1.25rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border-strong);
  color: var(--fg);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-card);
  transition: all 0.2s;
}
.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

/* Infinite scroll trigger */
.load-more-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 0;
}

.loading-more, .all-loaded {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.spinner-wrap {
  position: relative;
  width: 3rem;
  height: 3rem;
}

.spinner {
  width: 100%;
  height: 100%;
  border: 2px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--brand);
}

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

.loading-more p, .all-loaded p {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.all-loaded {
  flex-direction: row;
  gap: 0.75rem;
}

.line-dec {
  width: 2.5rem;
  height: 1px;
  background: linear-gradient(to var(--dir-end, right), transparent, var(--border-strong), transparent);
}
html[dir="rtl"] .line-dec { --dir-end: left; }

/* ============================================
   FOOTER
   ============================================ */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  margin-top: auto;
  padding: 2rem 0;
  transition: background-color 0.35s ease;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
@media (min-width: 640px) { .footer-inner { flex-direction: row; } }

.footer-logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.footer-logo span {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.footer-credit {
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-align: center;
}
.footer-credit a {
  color: var(--brand);
  font-weight: 600;
}
.footer-credit a:hover { text-decoration: underline; }

.footer-plays {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* ============================================
   HERO TITLE GRADIENT (subtle, not "AI-looking")
   ============================================ */
.text-shimmer {
  background: linear-gradient(100deg,
    var(--fg) 20%,
    var(--brand) 50%,
    var(--fg) 80%);
  background-size: 220% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 6s ease-in-out infinite;
}

@keyframes shimmer {
  0% { background-position: 220% center; }
  100% { background-position: -220% center; }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* ============================================
   GIF SITE — EXTRA STYLES
   ============================================ */

/* Switch-site button (header) */
.switch-site-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: var(--on-brand);
  border: 1px solid transparent;
  transition: all 0.2s;
  box-shadow: 0 2px 8px var(--brand-glow);
  white-space: nowrap;
}
.switch-site-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--brand-glow);
  color: var(--on-brand);
}
html[dir="rtl"] .switch-site-btn svg { transform: scaleX(-1); }

/* GIF grid: square-ish cards instead of wide */
.gifs-grid {
  grid-template-columns: 1fr;
}
@media (min-width: 480px) { .gifs-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .gifs-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .gifs-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1280px) { .gifs-grid { grid-template-columns: repeat(5, 1fr); } }

/* GIF card — image-centric layout */
.gif-card {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  gap: 0.5rem;
}

.gif-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gif-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg-muted);
  transition: transform 0.35s ease;
}
.gif-card:hover .gif-thumb { transform: scale(1.04); }

.gif-thumb-blur {
  position: absolute; inset: 0;
  background: var(--bg-muted);
  filter: blur(20px);
  z-index: 0;
}
.gif-thumb { position: relative; z-index: 1; }

.gif-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.5rem;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0) 50%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.gif-card:hover .gif-overlay,
.gif-card.playing .gif-overlay { opacity: 1; }

.gif-badge-live {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--brand);
  color: #fff;
  pointer-events: auto;
}
.gif-badge-live .live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff;
  animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse { 0%,100%{opacity:1;}50%{opacity:0.4;} }

.gif-badge-gif {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 0.35rem;
  font-size: 0.62rem;
  font-weight: 800;
  background: rgba(0,0,0,0.55);
  color: #fff;
  letter-spacing: 0.04em;
  pointer-events: auto;
}

.gif-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0.25rem 0.25rem;
}

.gif-card-title {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 1.05rem;
}

.gif-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-weight: 500;
  gap: 0.4rem;
}

.gif-card-cat {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60%;
}

.gif-card-plays {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.gif-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.25rem 0.4rem;
}

.gif-action {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.5rem 0.3rem;
  border-radius: 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--bg-secondary);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  transition: all 0.18s;
}
.gif-action:hover {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
  box-shadow: 0 3px 10px var(--brand-glow);
}
.gif-action.primary {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: transparent;
}
.gif-action.primary:hover {
  background: var(--brand);
  color: var(--on-brand);
}
.gif-action.copied {
  background: var(--brand);
  color: var(--on-brand);
  border-color: var(--brand);
}

/* Skeleton for GIF cards — taller */
.gif-skeleton::before { height: 100%; position: absolute; inset: 0; width: 100%; border-radius: var(--radius-sm); margin: 0; }
.gif-skeleton { aspect-ratio: 1/1; padding: 0; }
.gif-skeleton::after { display: none; }

/* Lightbox modal for full-size GIF view */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(8, 12, 10, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox-inner {
  position: relative;
  max-width: 640px;
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.lightbox.open .lightbox-inner { transform: translateY(0) scale(1); }
.lightbox-img {
  width: 100%; max-height: 70vh; object-fit: contain;
  background: var(--bg-muted); display: block;
}
.lightbox-body {
  padding: 1rem 1.2rem 1.2rem;
}
.lightbox-title {
  font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem;
  color: var(--fg);
}
.lightbox-actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem;
}
.lightbox-close {
  position: absolute;
  top: 0.6rem; right: 0.6rem;
  width: 2.4rem; height: 2.4rem;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.18s;
  z-index: 5;
}
.lightbox-close:hover { background: var(--brand); }

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.75rem 1.25rem;
  background: var(--brand);
  color: var(--on-brand);
  border-radius: 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Hero stat color tweak for GIF site */
#stat-gifs { color: var(--brand); }
