/**
 * INT CFC Website - Main Stylesheet
 * Design System based on plans/design-specification.md
 */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
    /* Color Palette */
    --primary: #1e3a8a;          /* Deep Blue - Trust, Stability */
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    
    --secondary: #ea580c;        /* Warm Orange - Compassion, Urgency */
    --secondary-dark: #c2410c;
    --secondary-light: #f97316;
    
    --accent: #f3f4f6;           /* Light Gray - Backgrounds */
    --accent-dark: #e5e7eb;
    
    --text: #374151;             /* Dark Gray - Body Text */
    --text-light: #6b7280;
    --text-lighter: #9ca3af;
    
    --success: #16a34a;          /* Green - Success States */
    --warning: #eab308;          /* Yellow - Attention */
    --danger: #dc2626;           /* Red - Critical Alerts */
    
    --white: #ffffff;
    --black: #000000;
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    
    --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 */
    --font-size-4xl: 2.25rem;    /* 36px */
    --font-size-5xl: 3rem;       /* 48px */
    
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;
    
    /* Spacing */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    --space-20: 5rem;     /* 80px */
    
    /* Border Radius */
    --radius-sm: 0.25rem;  /* 4px */
    --radius-md: 0.5rem;   /* 8px */
    --radius-lg: 0.75rem;  /* 12px */
    --radius-xl: 1rem;     /* 16px */
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
    
    /* Container */
    --container-max: 1200px;
    --container-padding: var(--space-6);
}

/* ============================================
   Reset & Base Styles
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--text);
    background-color: var(--white);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    color: var(--primary);
    margin-bottom: var(--space-4);
}

h1 { font-size: var(--font-size-5xl); }
h2 { font-size: var(--font-size-4xl); }
h3 { font-size: var(--font-size-3xl); }
h4 { font-size: var(--font-size-2xl); }
h5 { font-size: var(--font-size-xl); }
h6 { font-size: var(--font-size-lg); }

p {
    margin-bottom: var(--space-4);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-light);
}

/* ============================================
   Layout
   ============================================ */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

.section {
    padding: var(--space-16) 0;
}

.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex {
    display: flex;
}

.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ============================================
   Components - Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--secondary);
    color: var(--white);
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background-color: var(--primary);
    color: var(--white);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-lg);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
}

/* ============================================
   Components - Cards
   ============================================ */
.card {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.card-body {
    padding: var(--space-6);
}

.card-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--primary);
    margin-bottom: var(--space-2);
}

.card-text {
    color: var(--text-light);
    font-size: var(--font-size-base);
    margin-bottom: var(--space-4);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    background-color: var(--accent);
    border-top: 1px solid var(--accent-dark);
}

/* ============================================
   Components - Progress Bar
   ============================================ */
.progress {
    width: 100%;
    height: 8px;
    background-color: var(--accent);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--success);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar.warning { background-color: var(--warning); }
.progress-bar.danger { background-color: var(--danger); }

/* ============================================
   Components - Badges
   ============================================ */
.badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success { background-color: #dcfce7; color: var(--success); }
.badge-warning { background-color: #fef9c3; color: var(--warning); }
.badge-danger { background-color: #fee2e2; color: var(--danger); }
.badge-info { background-color: #dbeafe; color: var(--primary); }

/* ============================================
   Components - Forms
   ============================================ */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text);
    background-color: var(--white);
    border: 1px solid var(--accent-dark);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-light); }

.bg-primary { background-color: var(--primary); }
.bg-secondary { background-color: var(--secondary); }
.bg-accent { background-color: var(--accent); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.hidden { display: none !important; }

/* ============================================
   Responsive Design
   ============================================ */
/* Large tablets and small desktops */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* Tablets and large phones */
@media (max-width: 768px) {
    :root {
        --container-padding: var(--space-4);
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    h1 { font-size: var(--font-size-4xl); }
    h2 { font-size: var(--font-size-3xl); }
    h3 { font-size: var(--font-size-2xl); }
    
    .section {
        padding: var(--space-12) 0;
    }
}

/* Mobile phones - portrait */
@media (max-width: 640px) {
    :root {
        --container-padding: var(--space-3);
    }
    
    body {
        font-size: var(--font-size-sm);
    }
    
    h1 { font-size: var(--font-size-3xl); }
    h2 { font-size: var(--font-size-2xl); }
    h3 { font-size: var(--font-size-xl); }
    
    .section {
        padding: var(--space-8) 0;
    }
    
    .btn {
        padding: var(--space-3) var(--space-5);
        font-size: var(--font-size-sm);
    }
    
    .btn-lg {
        padding: var(--space-4) var(--space-6);
        font-size: var(--font-size-base);
    }
    
    .card-body {
        padding: var(--space-4);
    }
    
    /* Prevent horizontal overflow */
    .container {
        overflow-x: hidden;
    }
    
    /* Navigation adjustments */
    header nav {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    header nav .flex {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Hero section adjustments */
    .hero-stats {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    /* Donation buttons */
    .donation-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }
}

/* Small mobile phones */
@media (max-width: 480px) {
    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
    
    .btn {
        width: 100%;
        margin-bottom: var(--space-2);
    }
    
    .donation-buttons {
        grid-template-columns: 1fr;
    }
}

/* Mobile landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
    /* Prevent horizontal overflow */
    html, body {
        overflow-x: hidden;
        width: 100%;
        min-width: 0;
    }
    
    .section {
        padding: var(--space-4) 0;
    }
    
    .container {
        padding-left: var(--space-2);
        padding-right: var(--space-2);
    }
    
    .hero-section {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-3);
    }
    
    .hero-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-2);
        padding: var(--space-3);
    }
    
    .card-body {
        padding: var(--space-2);
    }
    
    /* Reduce font sizes for landscape */
    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
    h3 { font-size: var(--font-size-lg); }
    
    /* Fix navigation for landscape */
    .mobile-nav {
        padding: var(--space-2) 0;
    }
    
    .nav-links {
        gap: var(--space-2);
    }
    
    .nav-link {
        font-size: var(--font-size-xs);
        padding: var(--space-1) var(--space-2);
    }
    
    .mobile-btn {
        font-size: var(--font-size-xs);
        padding: var(--space-1) var(--space-2);
    }
    
    /* Fix buttons for landscape */
    .btn {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-sm);
    }
    
    /* Fix stats for landscape */
    .stat-number {
        font-size: 1.5rem !important;
    }
    
    .stat-label {
        font-size: var(--font-size-xs);
    }
}

/* Additional fix for narrow mobile landscape */
@media (max-width: 640px) and (orientation: landscape) {
    .hero-section {
        grid-template-columns: 1fr;
        gap: var(--space-2);
    }
    
    .hero-stats {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-1);
        padding: var(--space-2);
    }
    
    .donation-buttons {
        grid-template-columns: repeat(5, 1fr);
        gap: var(--space-1);
    }
    
    .donation-amount,
    .donation-custom {
        padding: var(--space-1) var(--space-2);
        font-size: var(--font-size-xs);
    }
}

/* Fix horizontal overflow for all mobile devices */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        width: 100%;
        min-width: 0;
    }
    
    html {
        overflow-x: hidden;
    }
    
    img {
        max-width: 100%;
        height: auto;
    }
    
    .flex {
        flex-wrap: wrap;
    }
    
    /* Ensure all content fits within viewport */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix container overflow */
    .container {
        width: 100%;
        padding-left: var(--space-3);
        padding-right: var(--space-3);
        overflow-x: hidden;
    }
    
    /* Fix grid overflow */
    .grid {
        width: 100%;
        min-width: 0;
    }
    
    /* Fix navigation overflow */
    .nav-links {
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Fix hero section overflow */
    .hero-section {
        width: 100%;
        min-width: 0;
    }
    
    /* Fix card overflow */
    .card {
        width: 100%;
        min-width: 0;
    }
}

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

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip to main content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: var(--white);
    padding: var(--space-2) var(--space-4);
    z-index: 100;
    transition: top var(--transition-fast);
}

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

/* ============================================
   Mobile-Specific Styles
   ============================================ */

/* Mobile Navigation */
@media (max-width: 768px) {
    .mobile-nav {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: var(--space-3);
    }
    
    .nav-link {
        font-size: var(--font-size-sm);
        padding: var(--space-2) var(--space-3);
    }
    
    .mobile-btn {
        font-size: var(--font-size-sm);
        padding: var(--space-2) var(--space-4);
    }
    
    .logo-img {
        width: 36px;
        height: 36px;
    }
    
    .brand-text h1 {
        font-size: 1.25rem;
    }
    
    .brand-text p {
        font-size: 0.75rem;
    }
}

/* Hero Section Mobile */
@media (max-width: 768px) {
    .hero-section {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .hero-title {
        font-size: 2rem !important;
        line-height: 1.2;
    }
    
    .hero-description {
        font-size: 1rem !important;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .hero-btn-primary,
    .hero-btn-secondary {
        width: 100%;
        text-align: center;
    }
    
    .hero-stats {
        padding: var(--space-4);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }
    
    .stat-number {
        font-size: 2rem !important;
    }
    
    .stat-label {
        font-size: var(--font-size-sm);
    }
}

/* Project Cards Mobile */
@media (max-width: 768px) {
    .card {
        margin-bottom: var(--space-4);
    }
    
    .card-body {
        padding: var(--space-4);
    }
    
    .card-title {
        font-size: var(--font-size-lg);
        line-height: 1.3;
    }
    
    .card-text {
        font-size: var(--font-size-sm);
    }
}

/* Donation Buttons Mobile */
@media (max-width: 480px) {
    .donation-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
        display: grid;
    }
    
    .donation-amount,
    .donation-custom {
        width: 100%;
    }
}

/* Footer Mobile */
@media (max-width: 768px) {
    footer .grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-6);
    }
}

@media (max-width: 480px) {
    footer .grid-4 {
        grid-template-columns: 1fr;
        gap: var(--space-4);
        text-align: center;
    }
    
    footer ul {
        text-align: center;
    }
}

/* Touch-friendly adjustments */
@media (max-width: 768px) {
    .btn {
        min-height: 44px; /* Minimum touch target size */
        padding: var(--space-3) var(--space-5);
    }
    
    a, button {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Prevent text overflow on mobile */
@media (max-width: 640px) {
    h1, h2, h3 {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    .card-title {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

/* Improve readability on mobile */
@media (max-width: 768px) {
    p {
        line-height: 1.6;
        margin-bottom: var(--space-3);
    }
    
    .section {
        padding: var(--space-8) 0;
    }
}
