/* =================================================================
   BASE.CSS - Core Foundation for All Event Demo Pages
   
   This file contains:
   - Accessibility features (WCAG compliant)
   - Mobile-first responsive system
   - Keyboard navigation support
   - Core layout utilities
   - Typography system
   - Focus management
   ================================================================= */

/* =================================================================
   CSS RESET & FOUNDATION
   ================================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    font-size: 16px; /* Base font size for rem calculations */
}

/* Focus visible for keyboard navigation only */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
    border-radius: 2px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =================================================================
   ACCESSIBILITY UTILITIES
   ================================================================= */

/* Skip to main content link - CRITICAL for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 12px 24px;
    z-index: 100000;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    font-weight: 600;
    font-size: 0.875rem;
}

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

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

/* Make focus visible for interactive elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@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;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
}

/* =================================================================
   MOBILE-FIRST RESPONSIVE SYSTEM
   ================================================================= */

/* Container with responsive padding */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Responsive breakpoints as CSS variables */
:root {
    --breakpoint-xs: 480px;
    --breakpoint-sm: 768px;
    --breakpoint-md: 1024px;
    --breakpoint-lg: 1200px;
    --breakpoint-xl: 1440px;
}

/* Mobile-first grid system */
.grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 480px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .grid-xs-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
    }
    
    .grid-sm-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-sm-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-sm-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-md-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-md-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-md-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .grid-md-5 {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .grid-md-6 {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* =================================================================
   TYPOGRAPHY SYSTEM
   ================================================================= */

/* Responsive typography scale */
h1, .h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.2;
    font-weight: 700;
    margin-bottom: 1rem;
}

h2, .h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    line-height: 1.3;
    font-weight: 600;
    margin-bottom: 0.875rem;
}

h3, .h3 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    line-height: 1.4;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

h4, .h4 {
    font-size: clamp(1.25rem, 2.5vw, 1.5rem);
    line-height: 1.4;
    font-weight: 500;
    margin-bottom: 0.625rem;
}

h5, .h5 {
    font-size: clamp(1.125rem, 2vw, 1.25rem);
    line-height: 1.5;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

h6, .h6 {
    font-size: 1rem;
    line-height: 1.5;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1rem;
}

/* =================================================================
   TOUCH TARGETS (Minimum 44x44px for accessibility)
   ================================================================= */

button,
a.btn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 24px;
}

/* Touch-friendly form inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="date"],
select,
textarea {
    min-height: 44px;
    padding: 12px 16px;
    font-size: 1rem;
}

/* =================================================================
   LAYOUT UTILITIES
   ================================================================= */

/* Sections with consistent spacing */
section {
    padding: 4rem 0;
    position: relative;
}

@media (min-width: 768px) {
    section {
        padding: 5rem 0;
    }
}

@media (min-width: 1024px) {
    section {
        padding: 6rem 0;
    }
}

/* Section headers */
.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title {
    margin-bottom: 1rem;
}

.section-subtitle {
    font-size: 1.125rem;
    opacity: 0.8;
    max-width: 600px;
    margin: 0 auto;
}

/* =================================================================
   CARDS & CONTAINERS
   ================================================================= */

.card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

@media (min-width: 768px) {
    .card {
        padding: 2rem;
    }
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
}

/* =================================================================
   BUTTONS & INTERACTIVE ELEMENTS
   ================================================================= */

.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    text-align: center;
    position: relative;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* Primary button */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Secondary button */
.btn-secondary {
    background: transparent;
    color: inherit;
    border: 2px solid currentColor;
}

/* =================================================================
   FORMS & INPUTS
   ================================================================= */

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-label .required {
    color: #e74c3c;
    margin-left: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
    background: white;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #4A90E2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Error states */
.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: #e74c3c;
}

.form-error {
    color: #e74c3c;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Success states */
.form-input.success,
.form-select.success,
.form-textarea.success {
    border-color: #27ae60;
}

/* =================================================================
   NAVIGATION STRUCTURE
   ================================================================= */

/* Navigation wrapper */
.nav-primary {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Mobile menu toggle (hamburger) */
.nav-toggle {
    display: block;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    z-index: 1001;
}

@media (min-width: 768px) {
    .nav-toggle {
        display: none;
    }
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: currentColor;
    margin: 5px 0;
    transition: all 0.3s;
}

/* Hamburger animation */
.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Navigation menu */
.nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 1rem;
}

.nav-menu.active {
    display: block;
}

@media (min-width: 768px) {
    .nav-menu {
        display: flex;
        position: static;
        box-shadow: none;
        padding: 0;
        gap: 2rem;
        align-items: center;
        justify-content: center;
    }
}

/* =================================================================
   FOOTER STRUCTURE
   ================================================================= */

.footer-primary {
    background: #1a1a1a;
    color: white;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .footer-content {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

.footer-section h4 {
    margin-bottom: 1rem;
}

.footer-bottom {
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

/* =================================================================
   UTILITY CLASSES
   ================================================================= */

/* Display utilities */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

/* Responsive display utilities */
@media (min-width: 768px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
}

@media (min-width: 1024px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
}

/* Text alignment */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

/* Spacing utilities */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }
.mt-5 { margin-top: 3rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 0.5rem !important; }
.pt-2 { padding-top: 1rem !important; }
.pt-3 { padding-top: 1.5rem !important; }
.pt-4 { padding-top: 2rem !important; }
.pt-5 { padding-top: 3rem !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 0.5rem !important; }
.pb-2 { padding-bottom: 1rem !important; }
.pb-3 { padding-bottom: 1.5rem !important; }
.pb-4 { padding-bottom: 2rem !important; }
.pb-5 { padding-bottom: 3rem !important; }

/* Flexbox utilities */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

/* Gap utilities */
.gap-1 { gap: 0.5rem !important; }
.gap-2 { gap: 1rem !important; }
.gap-3 { gap: 1.5rem !important; }
.gap-4 { gap: 2rem !important; }
.gap-5 { gap: 3rem !important; }

/* =================================================================
   DEMO CONTROLS (for showcase)
   ================================================================= */

.demo-return {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    text-decoration: none;
    font-size: 0.875rem;
    z-index: 9999;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.demo-return:hover {
    background: rgba(0,0,0,0.9);
    transform: translateX(-3px);
}

/* =================================================================
   LOADING STATES
   ================================================================= */

.loading {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0,0,0,0.1);
    border-radius: 50%;
    border-top-color: #4A90E2;
    animation: spin 1s ease-in-out infinite;
}

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

/* =================================================================
   PRINT STYLES
   ================================================================= */

@media print {
    .no-print,
    .nav-primary,
    .demo-return,
    .share-buttons {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }
    
    a {
        text-decoration: none;
    }
}