/**
 * MHCS Alumni System - Master Responsive CSS
 * Comprehensive responsive design for all screen sizes
 * Breakpoints: 320px, 480px, 768px, 1024px, 1440px
 */

/* ========================================
   1. CSS VARIABLES & RESPONSIVE UNITS
   ======================================== */
:root {
    /* Fluid spacing that scales with viewport */
    --space-fluid-xs: clamp(0.25rem, 0.5vw, 0.5rem);
    --space-fluid-sm: clamp(0.5rem, 1vw, 0.75rem);
    --space-fluid-md: clamp(0.75rem, 2vw, 1rem);
    --space-fluid-lg: clamp(1rem, 3vw, 1.5rem);
    --space-fluid-xl: clamp(1.5rem, 4vw, 2rem);
    --space-fluid-2xl: clamp(2rem, 5vw, 3rem);
    
    /* Fluid font sizes */
    --text-fluid-xs: clamp(0.625rem, 1.5vw, 0.75rem);
    --text-fluid-sm: clamp(0.75rem, 2vw, 0.875rem);
    --text-fluid-base: clamp(0.875rem, 2.5vw, 1rem);
    --text-fluid-lg: clamp(1rem, 3vw, 1.125rem);
    --text-fluid-xl: clamp(1.125rem, 4vw, 1.25rem);
    --text-fluid-2xl: clamp(1.25rem, 5vw, 1.5rem);
    --text-fluid-3xl: clamp(1.5rem, 6vw, 1.875rem);
    --text-fluid-4xl: clamp(1.875rem, 8vw, 2.25rem);
    
    /* Touch targets - minimum 44px for accessibility */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;
}

/* ========================================
   2. BASE RESPONSIVE STYLES
   ======================================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: var(--text-fluid-base);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, video, canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ========================================
   3. MOBILE-FIRST BREAKPOINTS
   ======================================== */

/* Extra Small Mobile (320px - 374px) */
@media (max-width: 374px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Small Mobile (375px - 479px) */
@media (min-width: 375px) and (max-width: 479px) {
    html {
        font-size: 15px;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Mobile Landscape & Small Tablets (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .container {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }
    
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet Portrait (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet Landscape & Small Desktop (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .container {
        padding-left: 2rem;
        padding-right: 2rem;
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop (1280px - 1439px) */
@media (min-width: 1280px) and (max-width: 1439px) {
    .container {
        max-width: 1200px;
    }
    
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
}

/* ========================================
   4. RESPONSIVE LAYOUT CLASSES
   ======================================== */

/* Fluid Container */
.container-fluid {
    width: 100%;
    padding-left: var(--space-fluid-md);
    padding-right: var(--space-fluid-md);
    margin-left: auto;
    margin-right: auto;
}

/* Responsive Grid System */
.r-grid {
    display: grid;
    gap: var(--space-fluid-md);
}

.r-grid-1 { grid-template-columns: 1fr; }
.r-grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.r-grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.r-grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }

/* Flex Layout */
.r-flex {
    display: flex;
    gap: var(--space-fluid-md);
}

.r-flex-col {
    flex-direction: column;
}

.r-flex-row {
    flex-direction: row;
    flex-wrap: wrap;
}

.r-flex-center {
    align-items: center;
    justify-content: center;
}

/* Stack on mobile */
@media (max-width: 767px) {
    .r-stack-mobile {
        flex-direction: column !important;
    }
    
    .r-grid-mobile-1 {
        grid-template-columns: 1fr !important;
    }
    
    .r-hide-mobile {
        display: none !important;
    }
}

/* Stack on tablet */
@media (max-width: 1023px) {
    .r-stack-tablet {
        flex-direction: column !important;
    }
}

/* ========================================
   5. RESPONSIVE TYPOGRAPHY
   ======================================== */
.r-h1 {
    font-size: var(--text-fluid-4xl);
    line-height: 1.2;
    font-weight: 700;
}

.r-h2 {
    font-size: var(--text-fluid-3xl);
    line-height: 1.3;
    font-weight: 700;
}

.r-h3 {
    font-size: var(--text-fluid-2xl);
    line-height: 1.4;
    font-weight: 600;
}

.r-text-fluid {
    font-size: var(--text-fluid-base);
}

.r-text-small {
    font-size: var(--text-fluid-sm);
}

/* ========================================
   6. RESPONSIVE COMPONENTS
   ======================================== */

/* Responsive Card */
.r-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-fluid-lg);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 767px) {
    .r-card {
        padding: var(--space-fluid-md);
    }
}

/* Responsive Button */
.r-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-fluid-sm);
    padding: var(--space-fluid-sm) var(--space-fluid-md);
    font-size: var(--text-fluid-base);
    font-weight: 500;
    border-radius: var(--radius-md);
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

@media (max-width: 767px) {
    .r-btn {
        min-height: var(--touch-target-comfortable);
        padding: var(--space-fluid-md) var(--space-fluid-lg);
    }
    
    .r-btn-block-mobile {
        width: 100%;
    }
}

/* Responsive Form */
.r-form-group {
    margin-bottom: var(--space-fluid-md);
}

.r-form-label {
    display: block;
    margin-bottom: var(--space-fluid-sm);
    font-size: var(--text-fluid-sm);
    font-weight: 500;
}

.r-form-input {
    width: 100%;
    padding: var(--space-fluid-sm) var(--space-fluid-md);
    font-size: var(--text-fluid-base);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    min-height: var(--touch-target-comfortable);
    background: var(--bg-white);
}

@media (max-width: 767px) {
    .r-form-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Responsive Table */
.r-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .r-table {
        font-size: var(--text-fluid-sm);
    }
    
    .r-table th,
    .r-table td {
        padding: var(--space-fluid-sm);
    }
}

/* ========================================
   7. MOBILE-SPECIFIC NAVIGATION
   ======================================== */

/* Mobile Header */
.mobile-header {
    display: none;
}

@media (max-width: 1024px) {
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--space-fluid-md);
        background: var(--bg-white);
        border-bottom: 1px solid var(--border-light);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        height: var(--header-height);
    }
    
    .hamburger-menu {
        width: var(--touch-target-comfortable);
        height: var(--touch-target-comfortable);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
    }
    
    .hamburger-line {
        width: 24px;
        height: 2px;
        background: var(--text-primary);
        transition: all 0.3s ease;
    }
    
    .hamburger-menu.active .hamburger-line:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .hamburger-menu.active .hamburger-line:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger-menu.active .hamburger-line:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
    }
}

/* ========================================
   8. SIDEBAR RESPONSIVENESS
   ======================================== */

@media (max-width: 1024px) {
    .alumni-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .alumni-sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .alumni-main {
        margin-left: 0;
        padding-top: var(--header-height);
    }
}

/* ========================================
   9. UTILITY CLASSES
   ======================================== */

/* Touch targets */
.touch-target {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

.touch-target-lg {
    min-height: var(--touch-target-comfortable);
    min-width: var(--touch-target-comfortable);
}

/* Scroll containers */
.scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.scroll-y {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Hide/show utilities */
@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    .show-mobile-flex { display: flex !important; }
}

@media (min-width: 768px) {
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
}

/* ========================================
   10. ACCESSIBILITY
   ======================================== */

/* 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;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --border-medium: #000000;
        --text-primary: #000000;
        --bg-body: #ffffff;
    }
}

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========================================
   11. PRINT STYLES
   ======================================== */
@media print {
    .no-print,
    .alumni-sidebar,
    .mobile-header,
    .sidebar-overlay {
        display: none !important;
    }
    
    .alumni-main {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a {
        text-decoration: underline;
    }
}
