/* ============================================================
   Wallpaper App — Base Styles & Design Tokens
   ============================================================
   Design tokens (CSS custom properties) for colors, spacing,
   typography, and shadows. All component styles reference
   these tokens so theming is centralized.
   ============================================================ */

/* --- Design Tokens ----------------------------------------- */
:root,
html[data-theme="dark"] {
  /* Colors — Background */
  --color-bg-primary: #0F172A;
  --color-bg-secondary: #1E293B;
  --color-bg-elevated: rgba(255, 255, 255, 0.05);
  --color-nav-bg: rgba(30, 41, 59, 0.85);

  /* Colors — Brand */
  --color-accent: #3B82F6;
  --color-accent-hover: #2563EB;
  --color-accent-glow: rgba(59, 130, 246, 0.39);
  --color-accent-muted: rgba(59, 130, 246, 0.2);
  --color-accent-active-bg: rgba(59, 130, 246, 0.1);
  --color-accent-soft: #60A5FA;

  /* Colors — Text */
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #D1D5DB; /* Lighter secondary */
  --color-text-muted: #9CA3AF; /* Lighter muted */
  --color-text-placeholder: #9CA3AF; /* Lighter placeholder */
  --color-text-on-accent: #FFFFFF;

  /* Colors — Border */
  --color-border-subtle: rgba(255, 255, 255, 0.1);
  --color-border-medium: rgba(107, 114, 128, 0.5);

  /* Colors — Overlay */
  --color-overlay-light: rgba(0, 0, 0, 0.2);
  --color-overlay-medium: rgba(0, 0, 0, 0.3);
  --color-overlay-heavy: rgba(0, 0, 0, 0.6);
  --color-overlay-gradient-end: rgba(0, 0, 0, 0.8);

  /* Colors — Interactive */
  --color-hover-bg: rgba(255, 255, 255, 0.06);
  --color-icon-btn-bg: rgba(255, 255, 255, 0.1);
  --color-icon-btn-bg-hover: rgba(255, 255, 255, 0.2);
  --color-card-shadow: rgba(0, 0, 0, 0.3);
  --color-modal-overlay: rgba(0, 0, 0, 0.85);
  --color-modal-shadow: rgba(0, 0, 0, 0.5);

  /* Colors — Status */
  --color-favorite: #F87171;
  --color-favorite-bg: rgba(248, 113, 113, 0.2);
  --color-error: #F87171;

  /* Colors — Featured */
  --color-featured-badge-bg: rgba(59, 130, 246, 0.3);
  --color-featured-badge-border: rgba(59, 130, 246, 0.4);
  --color-featured-badge-text: #93C5FD;
  --color-featured-description: #D1D5DB;
  --color-featured-download-bg: rgba(255, 255, 255, 0.1);
  --color-featured-download-border: rgba(255, 255, 255, 0.2);
  --color-featured-download-hover: rgba(255, 255, 255, 0.2);

  /* Colors - Resolution Badge */
  --color-resolution-bg: rgba(0, 0, 0, 0.3);
  --color-resolution-text: #FFFFFF;
  --color-card-btn-bg: rgba(0, 0, 0, 0.2);

  /* Colors — Skeleton / Shimmer */
  --color-skeleton-shimmer: rgba(255, 255, 255, 0.06);
  --color-skeleton-shimmer-card: rgba(255, 255, 255, 0.04);
  --color-card-placeholder: rgba(255, 255, 255, 0.03);

  /* Colors — Pagination */
  --color-dot-inactive: rgba(148, 163, 184, 0.4);
  --color-dot-inactive-hover: rgba(148, 163, 184, 0.7);

  /* Colors — Settings */
  --color-settings-card-bg: #2b2d35;
  --color-settings-card-border: #3a3d46;
  --color-settings-hover-bg: #374151;
  --color-settings-icon: #4a90e2;
  --color-settings-section-label: #a1a1aa;
  --color-settings-value: #a1a1aa;
  --color-settings-chevron: #a1a1aa;

  /* Colors — Card actions on overlay */
  --color-card-fav-default: rgba(255, 255, 255, 0.7);
  --color-card-dl-default: rgba(255, 255, 255, 0.8);
  --color-modal-btn-icon: rgba(255, 255, 255, 0.7);
  --color-modal-close-bg: rgba(0, 0, 0, 0.4);
  --color-modal-close-hover: rgba(0, 0, 0, 0.6);
}

html[data-theme="light"] {
  /* Colors — Background */
  --color-bg-primary: #F8FAFC;
  --color-bg-secondary: #FFFFFF;
  --color-bg-elevated: #F1F5F9;
  --color-nav-bg: rgba(255, 255, 255, 0.88);

  /* Colors — Brand */
  --color-accent: #2563EB;
  --color-accent-hover: #1D4ED8;
  --color-accent-glow: rgba(37, 99, 235, 0.25);
  --color-accent-muted: rgba(37, 99, 235, 0.12);
  --color-accent-active-bg: rgba(37, 99, 235, 0.08);
  --color-accent-soft: #3B82F6;

  /* Colors — Text */
  --color-text-primary: #0F172A;
  --color-text-secondary: #475569;
  --color-text-muted: #94A3B8;
  --color-text-placeholder: #94A3B8;
  --color-text-on-accent: #FFFFFF;

  /* Colors — Border */
  --color-border-subtle: #E2E8F0;
  --color-border-medium: #CBD5E1;

  /* Colors — Overlay */
  --color-overlay-light: rgba(0, 0, 0, 0.05);
  --color-overlay-medium: rgba(0, 0, 0, 0.15);
  --color-overlay-heavy: rgba(0, 0, 0, 0.4);
  --color-overlay-gradient-end: rgba(0, 0, 0, 0.7);

  /* Colors — Interactive */
  --color-hover-bg: rgba(0, 0, 0, 0.04);
  --color-icon-btn-bg: rgba(0, 0, 0, 0.06);
  --color-icon-btn-bg-hover: rgba(0, 0, 0, 0.1);
  --color-card-shadow: rgba(0, 0, 0, 0.1);
  --color-modal-overlay: rgba(0, 0, 0, 0.6);
  --color-modal-shadow: rgba(0, 0, 0, 0.2);

  /* Colors — Status */
  --color-favorite: #EF4444;
  --color-favorite-bg: rgba(239, 68, 68, 0.12);
  --color-error: #EF4444;

  /* Colors — Featured */
  --color-featured-badge-bg: rgba(37, 99, 235, 0.25);
  --color-featured-badge-border: rgba(37, 99, 235, 0.35);
  --color-featured-badge-text: #BFDBFE;
  --color-featured-description: #D1D5DB;
  --color-featured-download-bg: rgba(255, 255, 255, 0.2);
  --color-featured-download-border: rgba(255, 255, 255, 0.3);
  --color-featured-download-hover: rgba(255, 255, 255, 0.35);

  /* Colors - Resolution Badge */
  --color-resolution-bg: rgba(255, 255, 255, 0.7);
  --color-resolution-text: #0F172A;
  --color-card-btn-bg: rgba(255, 255, 255, 0.6);

  /* Colors — Skeleton / Shimmer */
  --color-skeleton-shimmer: rgba(0, 0, 0, 0.06);
  --color-skeleton-shimmer-card: rgba(0, 0, 0, 0.04);
  --color-card-placeholder: rgba(0, 0, 0, 0.03);

  /* Colors — Pagination */
  --color-dot-inactive: rgba(100, 116, 139, 0.3);
  --color-dot-inactive-hover: rgba(100, 116, 139, 0.55);

  /* Colors — Settings */
  --color-settings-card-bg: #F1F5F9;
  --color-settings-card-border: #E2E8F0;
  --color-settings-hover-bg: #E2E8F0;
  --color-settings-icon: #2563EB;
  --color-settings-section-label: #64748B;
  --color-settings-value: #64748B;
  --color-settings-chevron: #94A3B8;

  /* Colors — Card actions on overlay */
  --color-card-fav-default: rgba(255, 255, 255, 0.7);
  --color-card-dl-default: rgba(255, 255, 255, 0.8);
  --color-modal-btn-icon: rgba(0, 0, 0, 0.5);
  --color-modal-close-bg: rgba(0, 0, 0, 0.3);
  --color-modal-close-hover: rgba(0, 0, 0, 0.5);
}

:root {

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

  /* Border Radius */
  --radius-sm: 0.5rem;    /* 8px */
  --radius-md: 0.75rem;   /* 12px */
  --radius-lg: 1rem;      /* 16px */
  --radius-xl: 1.5rem;    /* 24px */
  --radius-2xl: 2rem;     /* 32px */
  --radius-full: 9999px;

  /* Typography */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-size-xs: 0.625rem;   /* 10px */
  --font-size-sm: 0.75rem;    /* 12px */
  --font-size-base: 0.875rem; /* 14px */
  --font-size-lg: 1.25rem;    /* 20px */
  --font-size-xl: 1.5rem;     /* 24px */
  --font-size-2xl: 1.875rem;  /* 30px */

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.25);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.35);
  --shadow-accent: 0 4px 14px 0 var(--color-accent-glow);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-overlay: 30;
  --z-modal: 40;
  --z-nav: 50;
}

/* --- Reset & Base ------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem); /* Space for fixed bottom nav */
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

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

/* --- Utility: Hidden Scrollbar ----------------------------- */
.custom-scrollbar::-webkit-scrollbar {
  display: none;
}

.custom-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* --- Utility: Screen Reader Only --------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Utility: Hidden --------------------------------------- */
.hidden {
  display: none !important;
}

.hidden-on-home {
  display: none !important;
}

/* --- Page Transitions ---------------------------------------- */
@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen:not(.hidden) {
  animation: screen-fade-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}
