/* Modern Demographic Statistics Styling - Enhanced Responsive */
.demographic-stats-area {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    position: relative;
    overflow: hidden;
    padding: 60px 0;
}

.demographic-stats-area::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.03) 0%, transparent 70%);
    animation: float 20s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

.demographic-stats__wrapper {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.demographic-section {
    margin-bottom: 4rem;
}

.demographic-section__title {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 700;
    text-align: center;
    margin-bottom: 2.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    line-height: 1.2;
}

.demographic-section__title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

/* Enhanced Grid System */
.demographic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.demographic-grid--death {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    gap: 2rem;
}

/* Enhanced Card Styling with Better Responsiveness */
.demographic-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: clamp(1rem, 3vw, 2rem);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.demographic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.demographic-card--primary::before {
    background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
}

.demographic-card--success::before {
    background: linear-gradient(135deg, #1cc88a 0%, #13855c 100%);
}

.demographic-card--info::before {
    background: linear-gradient(135deg, #36b9cc 0%, #258391 100%);
}

.demographic-card--warning::before {
    background: linear-gradient(135deg, #f6c23e 0%, #d4a017 100%);
}

.demographic-card--danger::before {
    background: linear-gradient(135deg, #e74a3b 0%, #c0392b 100%);
}

.demographic-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
}

.demographic-card--large {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: clamp(180px, 25vw, 220px);
}

.demographic-card__icon {
    width: clamp(50px, 8vw, 70px);
    height: clamp(50px, 8vw, 70px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.demographic-card:hover .demographic-card__icon {
    transform: scale(1.08) rotate(3deg);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.35);
}

.demographic-card__content {
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.demographic-card__number {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 800;
    color: #2d3748;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.demographic-card__label {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.demographic-card__age {
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    color: #718096;
    font-style: italic;
    line-height: 1.2;
}

.demographic-card__progress {
    margin-top: 1.5rem;
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Enhanced Death Breakdown Section */
.death-breakdown {
    background: rgba(231, 74, 59, 0.05);
    border-radius: 16px;
    padding: clamp(1.5rem, 4vw, 2rem);
    border: 1px solid rgba(231, 74, 59, 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.death-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(0.5rem, 2vw, 0.75rem) 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.death-item:last-child {
    border-bottom: none;
}

.death-item:hover {
    background: rgba(231, 74, 59, 0.02);
    padding-left: 0.5rem;
    border-radius: 8px;
}

.death-label {
    font-weight: 600;
    color: #4a5568;
    font-size: clamp(0.85rem, 2.2vw, 1rem);
    flex: 1;
}

.death-count {
    font-weight: 700;
    color: #e74a3b;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    text-align: right;
    min-width: fit-content;
}

/* Enhanced Summary Section */
.demographic-summary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.9) 100%);
    border-radius: 20px;
    padding: clamp(2rem, 5vw, 3rem) clamp(1rem, 3vw, 2rem);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 2rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: clamp(1rem, 3vw, 2rem);
    text-align: center;
}

.summary-item {
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.7);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.summary-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.9);
}

.summary-number {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 800;
    margin-bottom: 0.5rem;
    line-height: 1.1;
}

.summary-label {
    font-size: clamp(0.8rem, 2vw, 1rem);
    color: #6b7280;
    font-weight: 500;
    line-height: 1.3;
}

/* Dark Mode Support */
html.is-dark-mode .demographic-card,
html.is-dark-mode .demographic-summary,
html.is-dark-mode .death-breakdown {
    background: rgba(45, 55, 72, 0.95);
    color: #e2e8f0;
}

html.is-dark-mode .demographic-card__number {
    color: #e2e8f0;
}

html.is-dark-mode .demographic-card__label {
    color: #cbd5e0;
}

html.is-dark-mode .demographic-card__age {
    color: #a0aec0;
}

html.is-dark-mode .death-label {
    color: #cbd5e0;
}

html.is-dark-mode .summary-label {
    color: #a0aec0;
}

html.is-dark-mode .summary-item {
    background: rgba(74, 85, 104, 0.7);
}

/* Enhanced Responsive Design for All Devices */

/* Large Desktop (1400px and up) */
@media (min-width: 1400px) {
    .demographic-stats__wrapper {
        max-width: 1400px;
    }
    
    .demographic-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2.5rem;
    }
    
    .demographic-grid--death {
        grid-template-columns: 1fr 1.2fr;
        gap: 3rem;
    }
    
    .demographic-section {
        margin-bottom: 5rem;
    }
}

/* Desktop (1200px to 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
    .demographic-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
    
    .demographic-grid--death {
        grid-template-columns: 1fr 1.1fr;
        gap: 2.5rem;
    }
}

/* Large Tablet (992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .demographic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .demographic-grid--death {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablet (768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .demographic-stats-area {
        padding: 50px 0;
    }
    
    .demographic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .demographic-grid--death {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .demographic-card--large {
        min-height: 200px;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .demographic-section {
        margin-bottom: 3rem;
    }
}

/* Mobile Large (576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .demographic-stats-area {
        padding: 40px 0;
    }
    
    .demographic-stats__wrapper {
        padding: 0 20px;
    }
    
    .demographic-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .demographic-grid--death {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .demographic-card {
        padding: 1.5rem;
    }
    
    .demographic-card--large {
        min-height: 180px;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .demographic-section {
        margin-bottom: 2.5rem;
    }
    
    .death-breakdown {
        padding: 1.5rem;
    }
}

/* Mobile Small (up to 575px) */
@media (max-width: 575px) {
    .demographic-stats-area {
        padding: 30px 0;
    }
    
    .demographic-stats__wrapper {
        padding: 0 15px;
    }
    
    .demographic-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .demographic-grid--death {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .demographic-card {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .demographic-card--large {
        min-height: 160px;
    }
    
    .demographic-card__icon {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .demographic-section {
        margin-bottom: 2rem;
    }
    
    .demographic-section__title {
        margin-bottom: 1.5rem;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .demographic-summary {
        padding: 1.5rem 1rem;
        border-radius: 16px;
    }
    
    .death-breakdown {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .death-item {
        padding: 0.5rem 0;
    }
    
    .death-item:hover {
        padding-left: 0.25rem;
    }
}

/* Extra Small Mobile (up to 375px) */
@media (max-width: 375px) {
    .demographic-stats-area {
        padding: 25px 0;
    }
    
    .demographic-stats__wrapper {
        padding: 0 10px;
    }
    
    .demographic-card {
        padding: 0.75rem;
    }
    
    .demographic-card__icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .demographic-summary {
        padding: 1rem 0.75rem;
    }
    
    .death-breakdown {
        padding: 0.75rem;
    }
    
    .summary-item {
        padding: 0.75rem;
    }
}

/* Landscape Mobile Orientation */
@media (max-width: 767px) and (orientation: landscape) {
    .demographic-stats-area {
        padding: 20px 0;
    }
    
    .demographic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .demographic-card--large {
        min-height: 140px;
    }
    
    .demographic-section {
        margin-bottom: 1.5rem;
    }
    
    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Animation Delays for Staggered Effect */
.demographic-card:nth-child(1) { animation-delay: 0.1s; }
.demographic-card:nth-child(2) { animation-delay: 0.2s; }
.demographic-card:nth-child(3) { animation-delay: 0.3s; }
.demographic-card:nth-child(4) { animation-delay: 0.4s; }

/* Enhanced Accessibility & Performance */
@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;
    }
    
    .demographic-stats-area::before {
        animation: none;
    }
    
    .progress-bar::after {
        animation: none;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .demographic-card {
        border: 2px solid #000;
        background: #fff;
    }
    
    .demographic-card__number,
    .demographic-card__label {
        color: #000 !important;
        -webkit-text-fill-color: #000 !important;
    }
    
    .demographic-card__icon {
        background: #000 !important;
        color: #fff !important;
    }
}

/* Print Styles */
@media print {
    .demographic-stats-area {
        background: none !important;
        color: #000 !important;
    }
    
    .demographic-stats-area::before {
        display: none;
    }
    
    .demographic-card {
        background: #fff !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .demographic-card:hover {
        transform: none !important;
    }
    
    .demographic-card__number,
    .demographic-card__label,
    .death-label,
    .summary-label {
        color: #000 !important;
        -webkit-text-fill-color: #000 !important;
    }
    
    .progress-bar::after {
        display: none;
    }
}

/* Focus Management for Accessibility */
.demographic-card:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.summary-item:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .demographic-card:hover {
        transform: none;
    }
    
    .summary-item:hover {
        transform: none;
    }
    
    .death-item:hover {
        background: none;
        padding-left: 0;
    }
    
    /* Increase touch targets */
    .demographic-card {
        min-height: 120px;
    }
    
    .summary-item {
        min-height: 80px;
    }
}

/* Container Queries Support (Future-proofing) */
@supports (container-type: inline-size) {
    .demographic-stats__wrapper {
        container-type: inline-size;
    }
    
    @container (max-width: 600px) {
        .demographic-grid {
            grid-template-columns: 1fr;
        }
    }
    
    @container (min-width: 900px) {
        .demographic-grid {
            grid-template-columns: repeat(2, 1fr);
        }
    }
    
    @container (min-width: 1200px) {
        .demographic-grid {
            grid-template-columns: repeat(4, 1fr);
        }
    }
}