/* ==========================================================================
   GLOBALS.CSS: Core variables and base resets
   ========================================================================== */

/* Font Display Swap - Evita FOIT (Flash of Invisible Text) y CLS */
@font-face {
    font-family: 'Inter';
    font-display: swap;
    size-adjust: 100%;
}

@font-face {
    font-family: 'Poppins';
    font-display: swap;
    size-adjust: 100%;
}

/* Fallback fonts con size-adjust para reducir CLS */
@font-face {
    font-family: 'Inter Fallback';
    src: local('Arial');
    size-adjust: 107%;
    ascent-override: 90%;
    descent-override: 22%;
    line-gap-override: 0%;
}

@font-face {
    font-family: 'Poppins Fallback';
    src: local('Arial');
    size-adjust: 110%;
    ascent-override: 92%;
    descent-override: 30%;
    line-gap-override: 0%;
}

/* FontAwesome - Override font-display for better performance (20ms FCP improvement) */
/* This must be loaded AFTER FontAwesome CSS to override properly */
@font-face {
    font-family: 'Font Awesome 6 Free';
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: local('Font Awesome 6 Free Solid');
}

@font-face {
    font-family: 'Font Awesome 6 Free';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local('Font Awesome 6 Free Regular');
}

@font-face {
    font-family: 'Font Awesome 6 Brands';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: local('Font Awesome 6 Brands Regular');
}

:root {
    /* Breakpoints - Sistema simplificado */
    --breakpoint-mobile: 768px;
    --breakpoint-tablet: 1024px;
    --breakpoint-desktop: 1280px;
    /* Aliases para compatibilidad */
    --breakpoint-small: 480px;
    --breakpoint-medium: 640px;
    --breakpoint-mobile-max: 767px;
    --breakpoint-tablet-min: 768px;
    --breakpoint-tablet-max: 1023px;
    --breakpoint-desktop-min: 1024px;

    /* Colors */
    --color-background: #141418;
    --color-surface: #1C1C21;
    --color-surface-alt: #25252D;
    --color-primary: #F1F5F9;
    --color-primary-soft: #94A3B8;
    --color-white: #ffffff;
    --color-accent: #D87352;
    /* Live Site Terracota */
    --color-accent-rgb: 216, 115, 82;
    /* RGB version for rgba() usage */
    --color-accent-hover: #c86542;
    --color-accent-soft: rgba(216, 115, 82, 0.2);
    --color-accent-05: rgba(216, 115, 82, 0.05);
    --color-accent-08: rgba(216, 115, 82, 0.08);
    --color-accent-10: rgba(216, 115, 82, 0.1);
    --color-accent-12: rgba(216, 115, 82, 0.12);
    --color-accent-15: rgba(216, 115, 82, 0.15);
    --color-accent-20: rgba(216, 115, 82, 0.2);
    --color-accent-25: rgba(216, 115, 82, 0.25);
    --color-accent-30: rgba(216, 115, 82, 0.3);
    --color-accent-40: rgba(216, 115, 82, 0.4);
    --color-text: #F1F5F9;
    --color-text-primary: #F1F5F9;
    --color-text-secondary: #94A3B8;
    --color-text-tertiary: rgba(255, 255, 255, 0.5);
    --color-bg-primary: #141418;
    --color-bg-secondary: #1C1C21;
    --color-muted: #64748B;
    --color-line: rgba(255, 255, 255, 0.08);
    --color-accent-muted: rgba(216, 115, 82, 0.35);

    /* White opacity scale */
    --color-white-03: rgba(255, 255, 255, 0.03);
    --color-white-05: rgba(255, 255, 255, 0.05);
    --color-white-08: rgba(255, 255, 255, 0.08);
    --color-white-10: rgba(255, 255, 255, 0.1);
    --color-white-15: rgba(255, 255, 255, 0.15);
    --color-white-20: rgba(255, 255, 255, 0.2);
    --color-white-30: rgba(255, 255, 255, 0.3);
    --color-white-40: rgba(255, 255, 255, 0.4);
    --color-white-50: rgba(255, 255, 255, 0.5);
    --color-white-60: rgba(255, 255, 255, 0.6);
    --color-white-70: rgba(255, 255, 255, 0.7);
    --color-white-80: rgba(255, 255, 255, 0.8);
    --color-white-90: rgba(255, 255, 255, 0.9);

    /* Black opacity scale */
    --color-black-10: rgba(0, 0, 0, 0.1);
    --color-black-20: rgba(0, 0, 0, 0.2);
    --color-black-30: rgba(0, 0, 0, 0.3);
    --color-black-40: rgba(0, 0, 0, 0.4);
    --color-black-50: rgba(0, 0, 0, 0.5);
    --color-black-60: rgba(0, 0, 0, 0.6);

    /* Specific color scales (usado en formularios y componentes) */
    --color-form-blue: rgb(31, 59, 77);
    --color-form-blue-02: rgba(31, 59, 77, 0.02);
    --color-form-blue-03: rgba(31, 59, 77, 0.03);
    --color-form-blue-04: rgba(31, 59, 77, 0.04);
    --color-form-blue-05: rgba(31, 59, 77, 0.05);
    --color-form-blue-06: rgba(31, 59, 77, 0.06);
    --color-form-blue-08: rgba(31, 59, 77, 0.08);
    --color-form-blue-10: rgba(31, 59, 77, 0.1);
    --color-form-blue-12: rgba(31, 59, 77, 0.12);
    --color-form-blue-15: rgba(31, 59, 77, 0.15);
    --color-form-blue-20: rgba(31, 59, 77, 0.2);
    --color-form-blue-25: rgba(31, 59, 77, 0.25);
    --color-form-blue-30: rgba(31, 59, 77, 0.3);
    --color-form-blue-38: rgba(31, 59, 77, 0.38);
    --color-form-blue-70: rgba(31, 59, 77, 0.7);
    --color-overlay: rgba(18, 18, 20, 0.85);

    /* Navbar colors */
    --color-navbar: rgb(20, 20, 24);
    --color-navbar-88: rgba(20, 20, 24, 0.88);
    --color-navbar-95: rgba(20, 20, 24, 0.95);
    --color-navbar-96: rgba(20, 20, 24, 0.96);

    /* State colors */
    --color-error: #dc2626;
    --color-error-light: rgba(220, 38, 38, 0.1);
    --color-success: #22c55e;
    --color-success-bg: rgba(34, 197, 94, 0.1);
    --color-success-border: rgba(34, 197, 94, 0.3);
    --color-success-dark: rgb(22, 163, 74);

    /* Third-party colors */
    --color-whatsapp: #25d366;

    /* Utility colors */
    --color-black: #000000;

    /* Z-index scale - Sistema predecible y escalable */
    --z-behind: -1;
    --z-default: 0;
    --z-content: 1;
    --z-breadcrumbs: 10;
    --z-navbar: 100;
    --z-floating-actions: 200;
    --z-mobile-menu: 300;
    --z-modal-backdrop: 400;
    --z-tooltip: 500;

    /* Shadows */
    --shadow-sm: 0 12px 30px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 18px 48px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
    --shadow-accent: 0 10px 30px -5px rgba(224, 122, 95, 0.3);
    --shadow-accent-btn: 0 4px 16px rgba(216, 115, 82, 0.25);
    --shadow-accent-btn-hover: 0 6px 24px rgba(216, 115, 82, 0.35);
    --shadow-focus: 0 0 0 4px rgba(54, 93, 116, 0.15);
    --shadow-whatsapp: 0 18px 42px rgba(37, 211, 102, 0.35);

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, rgba(20, 20, 24, 0.95) 0%, rgba(28, 28, 33, 0.95) 100%);
    --gradient-accent: linear-gradient(135deg, #F97316 0%, #EC4899 100%);
    --gradient-surface: linear-gradient(180deg, rgba(28, 28, 33, 0.95) 0%, rgba(20, 20, 24, 0.98) 100%);

    /* Border Radius */
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-card: 16px;
    /* Card y elementos medianos - valor más usado */
    --radius-md: 18px;
    --radius-lg: 28px;
    --radius-full: 999px;
    --radius-circle: 50%;

    /* Typography - Con fallbacks optimizados para reducir CLS */
    --font-base: "Inter", "Inter Fallback", "DM Sans", system-ui, -apple-system, sans-serif;
    --font-body: "Inter", "Inter Fallback", "DM Sans", system-ui, -apple-system, sans-serif;
    --font-heading: "Inter", "Inter Fallback", "Work Sans", sans-serif;
    --font-heading-alt: "Inter", "Inter Fallback", sans-serif;

    /* Typography Scale */
    --text-2xs: 0.7rem;
    --text-xs: 0.75rem;
    --text-caption: 0.8125rem;
    --text-sm: 0.85rem;
    --text-sm-md: 0.875rem;
    --text-body-sm: 0.9rem;
    --text-body: 0.95rem;
    --text-base: 1rem;
    --text-md: 1.05rem;
    --text-md-lg: 1.1rem;
    --text-lg-sm: 1.125rem;
    --text-lg: 1.15rem;
    --text-lg-xl: 1.2rem;
    --text-xl: 1.25rem;
    --text-xl-2: 1.3rem;
    --text-2xl: 1.5rem;
    --text-2xl-3: 1.8rem;
    --text-3xl: clamp(2rem, 3.6vw, 2.8rem);
    --text-4xl: clamp(2.6rem, 5vw, 3.8rem);
    --title-page-size: clamp(2rem, 6vw, 3.5rem);
    --title-page-size-lg: clamp(2.5rem, 7vw, 4rem);

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

    /* Line Heights */
    --leading-tight: 1.15;
    --leading-snug: 1.2;
    --leading-comfortable: 1.3;
    --leading-normal: 1.5;
    --leading-relaxed: 1.6;
    --leading-loose: 1.7;

    /* Spacing */
    --spacing-xxxs: 4px;
    --spacing-xxs: 6px;
    --spacing-xxs-alt: 10px;
    --spacing-xs: 12px;
    --spacing-sm: 18px;
    --spacing-md: 24px;
    --spacing-lg: 36px;
    --spacing-xl: 48px;
    --spacing-xxxl: 64px;
    --spacing-xxl: 72px;
    --spacing-2xl: 96px;
    --spacing-navbar: 72px;

    --max-width: 1140px;
    --section-padding-md: clamp(48px, 10vw, 120px);
    --section-padding: clamp(60px, 12vw, 140px);
    --section-padding-bottom-extra: 160px;

    /* Icon sizes */
    --icon-sm: 16px;
    --icon-md: 18px;
    --icon-lg: 24px;
    --icon-xl: 32px;
    --icon-2xl: 40px;
    --icon-3xl: 48px;
    --icon-4xl: 56px;

    /* Floating button sizes */
    --floating-btn-size: 48px;
    --floating-btn-size-lg: 54px;

    /* Border widths */
    --border-thin: 1px;
    --border-md: 2px;
    --border-thick: 3px;

    /* Transitions */
    --transition-base: 0.25s ease;
    --transition-slow: 0.3s ease;
}

/* --- Base Reset --- */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    background-color: var(--color-background);
    color: var(--color-text);
}

body {
    margin: 0;
    font-family: var(--font-base);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    font-weight: var(--weight-normal);
    -webkit-font-smoothing: antialiased;
    background-color: var(--color-background);
}

p {
    margin: 0 0 var(--spacing-sm) 0;
    max-width: 65ch;
    color: var(--color-text-secondary);
}

a {
    color: inherit;
    text-decoration: none;
    transition: all var(--transition-base);
}

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    margin: 0 0 var(--spacing-md);
    color: var(--color-primary);
    line-height: var(--leading-tight);
    font-weight: 400;
}

em {
    font-family: var(--font-heading);
    font-style: italic !important;
    color: var(--color-accent);
}

/* --- Basic Layout Utils --- */
section {
    padding: var(--section-padding) 0;
    position: relative;
    overflow: hidden;
}

.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--color-line), transparent);
    margin: 0;
    border: none;
    opacity: 0.6;
}

.container {
    width: min(calc(100% - 16px), var(--max-width));
    margin: 0 auto;
    padding: 0 8px;
}

/* Visibility Utilities */
.mobile-only {
    display: block;
}

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

.desktop-only {
    display: none;
}

@media (min-width: 1024px) {
    .desktop-only {
        display: block;
    }
}
