/**
 * Responsive Base Styles
 * Core responsive utilities, CSS variables, and breakpoint definitions
 * Mobile-first approach: Base styles are for mobile, enhanced for larger screens
 */

/* ============================================
   CSS Variables and Design Tokens
   ============================================ */
:root {
    /* Breakpoint values (for reference in JavaScript) */
    --breakpoint-mobile: 0;
    --breakpoint-tablet: 640px;
    --breakpoint-tablet-large: 768px;
    --breakpoint-desktop: 1024px;
    --breakpoint-desktop-large: 1280px;
    
    /* Mobile-first font sizes */
    --font-size-xs: 0.75rem;    /* 12px */
    --font-size-sm: 0.875rem;   /* 14px */
    --font-size-base: 1rem;     /* 16px */
    --font-size-lg: 1.125rem;   /* 18px */
    --font-size-xl: 1.25rem;    /* 20px */
    --font-size-2xl: 1.5rem;    /* 24px */
    --font-size-3xl: 1.875rem;  /* 30px */
    
    /* Spacing scale */
    --spacing-xs: 0.25rem;   /* 4px */
    --spacing-sm: 0.5rem;    /* 8px */
    --spacing-md: 1rem;      /* 16px */
    --spacing-lg: 1.5rem;    /* 24px */
    --spacing-xl: 2rem;      /* 32px */
    --spacing-2xl: 3rem;     /* 48px */
    
    /* Touch target minimum */
    --touch-target-min: 44px;
    
    /* Z-index scale */
    --z-index-base: 1;
    --z-index-dropdown: 100;
    --z-index-sticky: 200;
    --z-index-fixed: 300;
    --z-index-modal-backdrop: 999;
    --z-index-modal: 1000;
    --z-index-overlay: 2000;
    --z-index-tooltip: 3000;
}

/* ============================================
   Base Reset and Box Sizing
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    /* Prevent font size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    min-width: 320px; /* Minimum supported width */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Ensure images and media scale properly */
img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

/* Prevent text overflow */
p, h1, h2, h3, h4, h5, h6 {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ============================================
   Responsive Typography Scale
   ============================================ */

/* Mobile base (320px - 639px) */
body {
    font-size: var(--font-size-base); /* 16px */
    line-height: 1.6;
}

h1 { font-size: var(--font-size-3xl); line-height: 1.2; }
h2 { font-size: var(--font-size-2xl); line-height: 1.3; }
h3 { font-size: var(--font-size-xl); line-height: 1.4; }
h4 { font-size: var(--font-size-lg); line-height: 1.5; }
h5 { font-size: var(--font-size-base); line-height: 1.5; }
h6 { font-size: var(--font-size-sm); line-height: 1.5; }

/* Tablet (640px+) */
@media (min-width: 640px) {
    :root {
        --font-size-2xl: 1.75rem;   /* 28px */
        --font-size-3xl: 2.25rem;   /* 36px */
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    :root {
        --font-size-2xl: 2rem;      /* 32px */
        --font-size-3xl: 2.5rem;    /* 40px */
    }
}

/* ============================================
   Fluid Grid System
   ============================================ */
.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
}

@media (min-width: 640px) {
    .container {
        max-width: 640px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 768px;
        padding-left: var(--spacing-lg);
        padding-right: var(--spacing-lg);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */

/* Disable tap highlight on touch devices */
.touch-device * {
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   Accessibility
   ============================================ */

/* Ensure focus indicators are visible */
:focus-visible {
    outline: 2px solid var(--primary-color, #6366f1);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color, #6366f1);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 9999;
}

.skip-to-main:focus {
    top: 0;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    /* Hide non-essential elements when printing */
    .sidebar,
    .hamburger-menu,
    .mobile-overlay,
    .btn,
    button {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
}
