/**
 * USA250 Content Library - Design Tokens
 * Centralized design system variables
 * Muted Patriotic Palette
 */

:root {
    /* Primary Colors — Tactile Heritage Palette */
    --color-navy: #1e3a5f;
    --color-navy-light: #2d5a8f;
    --color-burgundy: #800020;
    --color-burgundy-light: #990028;
    --color-cream: #f5f1e8;
    --color-cream-dark: #ebe5d8;

    /* Navy Scale */
    --color-navy-50: #f0f4f8;
    --color-navy-100: #d9e2ec;
    --color-navy-200: #bcccdc;
    --color-navy-300: #9fb3c8;
    --color-navy-400: #829ab1;
    --color-navy-500: #627d98;
    --color-navy-600: #486581;
    --color-navy-700: #334e68;
    --color-navy-800: #243b53;
    --color-navy-900: #102a43;

    /* Burgundy Scale (wine-red, anchored on #800020) */
    --color-burgundy-50: #fef2f4;
    --color-burgundy-100: #fce4ea;
    --color-burgundy-200: #f9c9d5;
    --color-burgundy-300: #f3a3b4;
    --color-burgundy-400: #e87088;
    --color-burgundy-500: #bf0040;
    --color-burgundy-600: #800020;
    --color-burgundy-700: #6b001a;
    --color-burgundy-800: #560015;
    --color-burgundy-900: #40000f;

    /* Neutrals */
    --color-white: #fff;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #6b7280; /* WCAG AA: 4.83:1 on white - same as gray-500 for accessibility */
    --color-gray-500: #6b7280; /* WCAG AA: 4.83:1 on white */
    --color-gray-600: #4b5563; /* WCAG AA: 7.56:1 on white */
    --color-gray-700: #374151;
    --color-gray-900: #111827;

    /* Cream Scale */
    --color-cream-50: #faf9f6;
    --color-cream-100: #f8f6f0;
    --color-cream-200: #f5f1e8;
    --color-cream-300: #ebe5d8;

    /* Gold Scale */
    --color-gold: #c9a961;
    --color-gold-500: #c9a961;
    --color-gold-600: #b89545;

    /* Semantic Colors */
    --color-success: #059669;
    --color-error: #dc2626;
    --color-warning: #d97706;
    --color-info: #2563eb;

    /* Semantic Status — Background / Foreground Pairs */
    --color-success-bg: color-mix(in srgb, var(--color-success) 15%, white);
    --color-success-fg: #065f46;
    --color-error-bg: color-mix(in srgb, var(--color-error) 15%, white);
    --color-error-fg: #991b1b;
    --color-warning-bg: color-mix(in srgb, var(--color-warning) 15%, white);
    --color-warning-fg: #92400e;
    --color-info-bg: color-mix(in srgb, var(--color-info) 12%, white);
    --color-info-fg: #1e40af;

    /* CTA Accent — for primary call-to-action buttons (not error red) */
    --color-accent-cta: var(--color-burgundy);
    --color-red-patriotic: #B31942;

    /* Color Aliases */
    --color-primary: var(--color-navy);
    --color-primary-dark: var(--color-navy-800);

    /* Card States */
    --color-active: var(--color-navy);
    --color-retired: var(--color-gray-300);
    --color-coming-soon: var(--color-burgundy);

    /* Typography — 3 families: Inter (UI), Merriweather (prose), Playfair Display (hero)
       See public/css/fonts.css for the self-hosted @font-face declarations. */
    --font-sans: 'Inter', -apple-system, blinkmacsystemfont, 'Segoe UI', sans-serif;
    --font-body: 'Merriweather', georgia, 'Times New Roman', serif;
    --font-display: 'Playfair Display', georgia, serif;
    --font-heading: var(--font-display);
    --font-serif: var(--font-body);

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-black: 900;

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

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

    /**
     * @deprecated --spacing-* aliases are deprecated as of Phase 79.
     * Use --space-* tokens directly for all new CSS.
     * Existing 236 usages across 12 files continue to work — do not remove.
     * Do not add new --spacing-* references.
     */
    --spacing-xs: var(--space-1);   /* 4px */
    --spacing-sm: var(--space-2);   /* 8px */
    --spacing-md: var(--space-4);   /* 16px */
    --spacing-lg: var(--space-6);   /* 24px */
    --spacing-xl: var(--space-8);   /* 32px */
    --spacing-2xl: var(--space-12); /* 48px */
    --spacing-3xl: var(--space-16); /* 64px */

    /* Font Size Aliases (--font-size-* used by page CSS) */
    --font-size-xs: var(--text-xs);   /* 12px */
    --font-size-sm: var(--text-sm);   /* 14px */
    --font-size-base: var(--text-base); /* 16px */
    --font-size-md: var(--text-base); /* 16px */
    --font-size-lg: var(--text-lg);   /* 18px */
    --font-size-xl: var(--text-xl);   /* 20px */
    --font-size-2xl: var(--text-2xl); /* 24px */
    --font-size-3xl: var(--text-3xl); /* 30px */
    --font-size-4xl: var(--text-4xl); /* 36px */

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Border Radius Aliases (--border-radius-* used by component CSS) */
    --border-radius-sm: var(--radius-sm);
    --border-radius-md: var(--radius-md);
    --border-radius-lg: var(--radius-lg);
    --border-radius-xl: var(--radius-xl);
    --border-radius-2xl: var(--radius-2xl);
    --border-radius-full: var(--radius-full);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 5%);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 10%), 0 2px 4px -1px rgb(0 0 0 / 6%);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 10%), 0 4px 6px -2px rgb(0 0 0 / 5%);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 10%), 0 10px 10px -5px rgb(0 0 0 / 4%);
    --shadow-warm-lg: 0 12px 20px -4px rgb(30 58 95 / 25%), 0 6px 8px -2px rgb(30 58 95 / 12%);

    /* Z-Index Scale */
    --z-base: 1;
    --z-sticky: 100;
    --z-dropdown: 200;
    --z-modal-backdrop: 900;
    --z-modal: 1000;
    --z-modal-above: 1100;
    --z-toast: 1200;
    --z-skip-link: 1300;

    /* Easing Curves */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-hover: cubic-bezier(0.45, 0, 0.40, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Transitions */
    --transition-fast: 0.15s var(--ease-hover);
    --transition-base: 0.2s var(--ease-hover);
    --transition-smooth: 0.3s var(--ease-hover);
    --transition-slow: 0.3s var(--ease-out-expo);

    /* Metallic Texture URLs — Tactile Heritage */
    --texture-ruby-garnet: url('/images/textures/texture-ruby-garnet.webp');
    --texture-gold-polished: url('/images/textures/texture-gold-polished.webp');
    --texture-sapphire: url('/images/textures/texture-sapphire.webp');
    --texture-gold-brushed: url('/images/textures/texture-gold-brushed.webp');
    --texture-bronze-aged: url('/images/textures/texture-bronze-aged.webp');
    --texture-pearl-cream: url('/images/textures/texture-pearl-cream.webp');
    --texture-emerald: url('/images/textures/texture-emerald.webp');
    --texture-rose-gold: url('/images/textures/texture-rose-gold.webp');
}

/* ===== Grain Texture Utilities ===== */

.grain-warm,
.grain-neutral {
    position: relative;
}

.grain-warm::after,
.grain-neutral::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-repeat: repeat;
    background-size: 200px 200px;
}

.grain-warm::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.18'/%3E%3C/svg%3E");
    mix-blend-mode: soft-light;
}

.grain-neutral::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.12'/%3E%3C/svg%3E");
    mix-blend-mode: overlay;
}

/* ===== Metallic Texture Animations ===== */
@keyframes texture-glow-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.45; }
}

/* Global utility — kept here because tokens.css is loaded on every page.
   base.css also defines this; the duplicate is intentional so either alone suffices. */
.hidden {
    display: none !important;
}

/**
 * Reduced Motion Support
 * WCAG 2.3.3 Animation from Interactions (Level AAA)
 * Critical for users with vestibular disorders
 */
@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;
    }

    /* Disable specific transforms that can trigger vestibular issues */
    .modal-content,
    .modal-backdrop,
    .card:hover,
    .btn:hover,
    .carousel-image:hover,
    .thumbnail-item:hover,
    .card-image:hover {
        transform: none !important;
    }

    /* Keep focus indicators visible (critical for keyboard navigation) */
    :focus-visible {
        outline: 3px solid var(--color-burgundy) !important;
        outline-offset: 2px !important;
    }
}
