/* ============================================================
   SortMe — Base CSS: Reset, Design Tokens, Typography
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Colors */
  --clr-primary:       #3B5BDB;
  --clr-primary-dark:  #2f4ac7;
  --clr-primary-light: #748ffc;
  --clr-accent:        #4C6EF5;
  --clr-bg:            #EEF2FF;
  --clr-bg-alt:        #F8F9FF;
  --clr-white:         #FFFFFF;
  --clr-surface:       #FFFFFF;
  --clr-success:       #22C55E;
  --clr-success-bg:    #DCFCE7;
  --clr-warning:       #F59E0B;
  --clr-warning-bg:    #FEF3C7;
  --clr-danger:        #EF4444;
  --clr-danger-bg:     #FEE2E2;
  --clr-text:          #1A1D2E;
  --clr-text-2:        #374151;
  --clr-muted:         #6B7280;
  --clr-border:        #E5E7EB;
  --clr-border-light:  #F3F4F6;
}

[data-theme="dark"] {
  --clr-bg:            #0B0F19;
  --clr-bg-alt:        #111827;
  --clr-white:         #1F2937;
  --clr-surface:       #1F2937;
  --clr-text:          #F9FAFB;
  --clr-text-2:        #D1D5DB;
  --clr-muted:         #9CA3AF;
  --clr-border:        #374151;
  --clr-border-light:  #1F2937;
}

:root {
  /* Gradient */
  --gradient-primary: linear-gradient(135deg, #3B5BDB 0%, #4C6EF5 100%);
  --gradient-card:    linear-gradient(135deg, #3B5BDB 0%, #748ffc 100%);
  --gradient-success: linear-gradient(135deg, #22C55E 0%, #16a34a 100%);

  /* Typography */
  --font:       'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --fs-xs:      0.75rem;
  --fs-sm:      0.875rem;
  --fs-base:    1rem;
  --fs-md:      1.125rem;
  --fs-lg:      1.25rem;
  --fs-xl:      1.5rem;
  --fs-2xl:     1.875rem;
  --fs-3xl:     2.25rem;
  --fw-regular: 400;
  --fw-medium:  500;
  --fw-semi:    600;
  --fw-bold:    700;
  --fw-black:   800;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-2xl: 28px;
  --radius-pill: 50px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 16px rgba(59,91,219,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:  0 8px 32px rgba(59,91,219,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-xl:  0 16px 48px rgba(59,91,219,0.16);
  --shadow-card: 0 2px 20px rgba(59,91,219,0.08);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;

  /* Layout */
  --max-w: 430px;
  --nav-h: 68px;
  --header-h: 60px;
}

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

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

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  color: var(--clr-text);
  background-color: var(--clr-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--dur-normal) var(--ease), color var(--dur-normal) var(--ease);
}

/* Watermark only shows when running as installed PWA / native app */
@media (display-mode: standalone) {
  body {
    background-image: url("data:image/svg+xml,%3Csvg width='120' height='120' xmlns='http://www.w3.org/2000/svg'%3E%3Ctext x='20' y='50' font-family='sans-serif' font-weight='bold' font-size='24' fill='rgba(128,128,128,0.04)'%3E%E2%82%B5%3C/text%3E%3Cpath d='M80,60 C85,45 100,45 105,60 C110,75 110,90 105,105 C100,120 85,120 80,105 C75,90 75,75 80,60 Z M90,65 C85,80 85,95 90,110 C95,110 95,80 90,65' fill='rgba(128,128,128,0.04)'/%3E%3C/svg%3E");
    background-size: 120px 120px;
    background-repeat: repeat;
    background-attachment: fixed;
  }
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-black); line-height: 1.2; }
h2 { font-size: var(--fs-xl);  font-weight: var(--fw-bold);  line-height: 1.3; }
h3 { font-size: var(--fs-lg);  font-weight: var(--fw-semi);  line-height: 1.4; }
h4 { font-size: var(--fs-md);  font-weight: var(--fw-semi);  line-height: 1.4; }
p  { color: var(--clr-muted); line-height: 1.6; }

/* ── App Shell ────────────────────────────────────────────── */
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Mobile-first centered layout */
.page-shell {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--clr-bg);
  position: relative;
}

/* ── Page Transitions ─────────────────────────────────────── */
.page {
  display: none;
  width: 100%;
  min-height: 100vh;
  flex-direction: column;
  animation: slideUp var(--dur-base) var(--ease);
}

.page.active {
  display: flex;
}

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

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: none; }
}

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

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

@keyframes checkPop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: var(--radius-full); }

/* ── Selection ────────────────────────────────────────────── */
::selection { background: rgba(59,91,219,0.15); }
