/**
 * toBrand Design System
 * Version: 2.0.0
 *
 * A modern design system for q.tobrand.io
 * Inspired by industry leaders: Flowcode, QR Tiger, Beaconstac
 */

/* ============================================
   1. CSS RESET & BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--tb-font-primary);
    font-size: var(--tb-font-size-base);
    line-height: 1.6;
    color: var(--tb-text-primary);
    background-color: var(--tb-bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* RTL Support */
[dir="rtl"] body {
    font-family: var(--tb-font-arabic);
}

/* ============================================
   2. DESIGN TOKENS - LIGHT THEME (Default)
   ============================================ */
:root {
    /* === Brand Colors === */
    --tb-pink: #e5007e;
    --tb-pink-light: #ff4da6;
    --tb-pink-dark: #b80064;

    --tb-purple: #81358a;
    --tb-purple-light: #a855b3;
    --tb-purple-dark: #5c2663;

    --tb-blue: #129fed;
    --tb-blue-light: #4db8f5;
    --tb-blue-dark: #0d7ec4;

    /* === Gradient Presets === */
    --tb-gradient-primary: linear-gradient(135deg, var(--tb-pink) 0%, var(--tb-purple) 100%);
    --tb-gradient-secondary: linear-gradient(135deg, var(--tb-purple) 0%, var(--tb-blue) 100%);
    --tb-gradient-accent: linear-gradient(135deg, var(--tb-pink) 0%, var(--tb-blue) 100%);
    --tb-gradient-brand: linear-gradient(135deg, var(--tb-pink) 0%, var(--tb-purple) 50%, var(--tb-blue) 100%);

    /* === Semantic Colors === */
    --tb-success: #10b981;
    --tb-success-light: #34d399;
    --tb-success-dark: #059669;
    --tb-success-bg: rgba(16, 185, 129, 0.1);

    --tb-warning: #f59e0b;
    --tb-warning-light: #fbbf24;
    --tb-warning-dark: #d97706;
    --tb-warning-bg: rgba(245, 158, 11, 0.1);

    --tb-danger: #ef4444;
    --tb-danger-light: #f87171;
    --tb-danger-dark: #dc2626;
    --tb-danger-bg: rgba(239, 68, 68, 0.1);

    --tb-info: #3b82f6;
    --tb-info-light: #60a5fa;
    --tb-info-dark: #2563eb;
    --tb-info-bg: rgba(59, 130, 246, 0.1);

    /* === Background Colors === */
    --tb-bg-primary: #f8fafc;
    --tb-bg-secondary: #ffffff;
    --tb-bg-tertiary: #f1f5f9;
    --tb-bg-elevated: #ffffff;
    --tb-bg-overlay: rgba(0, 0, 0, 0.5);
    --tb-bg-glass: rgba(255, 255, 255, 0.8);
    --tb-bg-glass-border: rgba(255, 255, 255, 0.3);

    /* === Text Colors === */
    --tb-text-primary: #0f172a;
    --tb-text-secondary: #475569;
    --tb-text-tertiary: #94a3b8;
    --tb-text-muted: #cbd5e1;
    --tb-text-inverse: #ffffff;
    --tb-text-link: var(--tb-pink);
    --tb-text-link-hover: var(--tb-pink-dark);

    /* === Border Colors === */
    --tb-border-light: #e2e8f0;
    --tb-border-default: #cbd5e1;
    --tb-border-dark: #94a3b8;
    --tb-border-focus: var(--tb-pink);

    /* === Typography === */
    --tb-font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --tb-font-arabic: 'IBM Plex Sans Arabic', 'Inter', sans-serif;
    --tb-font-mono: 'Fira Code', 'Consolas', monospace;

    /* Font Sizes */
    --tb-font-size-xs: 0.75rem;    /* 12px */
    --tb-font-size-sm: 0.875rem;   /* 14px */
    --tb-font-size-base: 1rem;     /* 16px */
    --tb-font-size-lg: 1.125rem;   /* 18px */
    --tb-font-size-xl: 1.25rem;    /* 20px */
    --tb-font-size-2xl: 1.5rem;    /* 24px */
    --tb-font-size-3xl: 1.875rem;  /* 30px */
    --tb-font-size-4xl: 2.25rem;   /* 36px */
    --tb-font-size-5xl: 3rem;      /* 48px */

    /* Font Weights */
    --tb-font-weight-light: 300;
    --tb-font-weight-normal: 400;
    --tb-font-weight-medium: 500;
    --tb-font-weight-semibold: 600;
    --tb-font-weight-bold: 700;

    /* Line Heights */
    --tb-line-height-tight: 1.25;
    --tb-line-height-normal: 1.5;
    --tb-line-height-relaxed: 1.75;

    /* === Spacing Scale === */
    --tb-space-0: 0;
    --tb-space-1: 0.25rem;   /* 4px */
    --tb-space-2: 0.5rem;    /* 8px */
    --tb-space-3: 0.75rem;   /* 12px */
    --tb-space-4: 1rem;      /* 16px */
    --tb-space-5: 1.25rem;   /* 20px */
    --tb-space-6: 1.5rem;    /* 24px */
    --tb-space-8: 2rem;      /* 32px */
    --tb-space-10: 2.5rem;   /* 40px */
    --tb-space-12: 3rem;     /* 48px */
    --tb-space-16: 4rem;     /* 64px */
    --tb-space-20: 5rem;     /* 80px */
    --tb-space-24: 6rem;     /* 96px */

    /* === Border Radius === */
    --tb-radius-none: 0;
    --tb-radius-sm: 4px;
    --tb-radius-md: 8px;
    --tb-radius-lg: 12px;
    --tb-radius-xl: 16px;
    --tb-radius-2xl: 24px;
    --tb-radius-3xl: 32px;
    --tb-radius-full: 9999px;

    /* === Shadows === */
    --tb-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --tb-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --tb-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
    --tb-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.04);
    --tb-shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    --tb-shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);
    --tb-shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);

    /* Colored Shadows */
    --tb-shadow-pink: 0 10px 40px rgba(229, 0, 126, 0.25);
    --tb-shadow-purple: 0 10px 40px rgba(129, 53, 138, 0.25);
    --tb-shadow-blue: 0 10px 40px rgba(18, 159, 237, 0.25);

    /* === Transitions === */
    --tb-transition-fast: 150ms ease;
    --tb-transition-normal: 250ms ease;
    --tb-transition-slow: 350ms ease;
    --tb-transition-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* === Z-Index Scale === */
    --tb-z-dropdown: 100;
    --tb-z-sticky: 200;
    --tb-z-fixed: 300;
    --tb-z-modal-backdrop: 400;
    --tb-z-modal: 500;
    --tb-z-popover: 600;
    --tb-z-tooltip: 700;
    --tb-z-toast: 800;

    /* === Breakpoints (for reference) === */
    --tb-breakpoint-sm: 640px;
    --tb-breakpoint-md: 768px;
    --tb-breakpoint-lg: 1024px;
    --tb-breakpoint-xl: 1280px;
    --tb-breakpoint-2xl: 1536px;

    /* === Container Widths === */
    --tb-container-sm: 640px;
    --tb-container-md: 768px;
    --tb-container-lg: 1024px;
    --tb-container-xl: 1280px;

    /* === Animation Durations === */
    --tb-duration-instant: 50ms;
    --tb-duration-fast: 150ms;
    --tb-duration-normal: 300ms;
    --tb-duration-slow: 500ms;
    --tb-duration-slower: 700ms;
}

/* ============================================
   3. FOCUS & ACCESSIBILITY
   ============================================ */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--tb-pink);
    outline-offset: 2px;
}

/* Skip to content link for accessibility */
.tb-skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    background: var(--tb-pink);
    color: var(--tb-text-inverse);
    padding: var(--tb-space-2) var(--tb-space-4);
    z-index: var(--tb-z-toast);
    text-decoration: none;
    font-weight: var(--tb-font-weight-medium);
    border-radius: 0 0 var(--tb-radius-md) 0;
    transition: top var(--tb-transition-fast);
}

.tb-skip-link:focus {
    top: 0;
}

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

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   4. TYPOGRAPHY UTILITIES
   ============================================ */
.tb-text-xs { font-size: var(--tb-font-size-xs); }
.tb-text-sm { font-size: var(--tb-font-size-sm); }
.tb-text-base { font-size: var(--tb-font-size-base); }
.tb-text-lg { font-size: var(--tb-font-size-lg); }
.tb-text-xl { font-size: var(--tb-font-size-xl); }
.tb-text-2xl { font-size: var(--tb-font-size-2xl); }
.tb-text-3xl { font-size: var(--tb-font-size-3xl); }
.tb-text-4xl { font-size: var(--tb-font-size-4xl); }
.tb-text-5xl { font-size: var(--tb-font-size-5xl); }

.tb-font-light { font-weight: var(--tb-font-weight-light); }
.tb-font-normal { font-weight: var(--tb-font-weight-normal); }
.tb-font-medium { font-weight: var(--tb-font-weight-medium); }
.tb-font-semibold { font-weight: var(--tb-font-weight-semibold); }
.tb-font-bold { font-weight: var(--tb-font-weight-bold); }

.tb-text-primary { color: var(--tb-text-primary); }
.tb-text-secondary { color: var(--tb-text-secondary); }
.tb-text-tertiary { color: var(--tb-text-tertiary); }
.tb-text-muted { color: var(--tb-text-muted); }
.tb-text-inverse { color: var(--tb-text-inverse); }

.tb-text-pink { color: var(--tb-pink); }
.tb-text-purple { color: var(--tb-purple); }
.tb-text-blue { color: var(--tb-blue); }
.tb-text-success { color: var(--tb-success); }
.tb-text-warning { color: var(--tb-warning); }
.tb-text-danger { color: var(--tb-danger); }

/* Gradient Text */
.tb-text-gradient {
    background: var(--tb-gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   5. HEADINGS
   ============================================ */
h1, h2, h3, h4, h5, h6,
.tb-h1, .tb-h2, .tb-h3, .tb-h4, .tb-h5, .tb-h6 {
    font-weight: var(--tb-font-weight-semibold);
    line-height: var(--tb-line-height-tight);
    color: var(--tb-text-primary);
    margin-bottom: var(--tb-space-4);
}

h1, .tb-h1 { font-size: var(--tb-font-size-4xl); }
h2, .tb-h2 { font-size: var(--tb-font-size-3xl); }
h3, .tb-h3 { font-size: var(--tb-font-size-2xl); }
h4, .tb-h4 { font-size: var(--tb-font-size-xl); }
h5, .tb-h5 { font-size: var(--tb-font-size-lg); }
h6, .tb-h6 { font-size: var(--tb-font-size-base); }

/* ============================================
   6. LINKS
   ============================================ */
a {
    color: var(--tb-text-link);
    text-decoration: none;
    transition: color var(--tb-transition-fast);
}

a:hover {
    color: var(--tb-text-link-hover);
}

/* ============================================
   7. SELECTION
   ============================================ */
::selection {
    background: var(--tb-pink);
    color: var(--tb-text-inverse);
}

/* ============================================
   8. SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--tb-bg-tertiary);
    border-radius: var(--tb-radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--tb-border-default);
    border-radius: var(--tb-radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--tb-border-dark);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--tb-border-default) var(--tb-bg-tertiary);
}

/* ============================================
   9. CONTAINER
   ============================================ */
.tb-container {
    width: 100%;
    max-width: var(--tb-container-xl);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--tb-space-4);
    padding-right: var(--tb-space-4);
}

@media (min-width: 640px) {
    .tb-container {
        padding-left: var(--tb-space-6);
        padding-right: var(--tb-space-6);
    }
}

@media (min-width: 1024px) {
    .tb-container {
        padding-left: var(--tb-space-8);
        padding-right: var(--tb-space-8);
    }
}

/* ============================================
   10. GLASS EFFECT UTILITIES
   ============================================ */
.tb-glass {
    background: var(--tb-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--tb-bg-glass-border);
}

.tb-glass-dark {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   11. ANIMATED BACKGROUND
   ============================================ */
/* Perf: transform-driven (GPU compositor) instead of background-position,
   which forces a full-viewport repaint every frame on low-end/integrated GPUs.
   The slight scale() keeps the gradient covering its box while it translates. */
.tb-bg-animated {
    background: var(--tb-gradient-brand);
    background-size: 200% 200%;
    will-change: transform;
    animation: tb-gradient-shift 15s ease infinite;
}

@keyframes tb-gradient-shift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1.1); }
    50% { transform: translate3d(3%, -2%, 0) scale(1.1); }
}

/* Subtle version for backgrounds */
.tb-bg-animated-subtle {
    position: relative;
    overflow: hidden;
}

.tb-bg-animated-subtle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--tb-gradient-brand);
    background-size: 200% 200%;
    will-change: transform;
    animation: tb-gradient-shift 20s ease infinite;
    opacity: 0.05;
    z-index: -1;
}

@media (prefers-reduced-motion: reduce) {
    .tb-bg-animated,
    .tb-bg-animated-subtle::before { animation: none; }
}
