/*
Theme Name: Quiz Theme
Description: Theme chuyên dụng cho website trắc nghiệm và quiz
Author: Nguyễn Minh Thắng
Version: 1.0.0
Text Domain: quiz-theme
*/

/*************** OPTIMIZED CSS FOR PERFORMANCE  ***************/

/* CSS Variables for easy maintenance */
:root {
    --primary-color: rgb(74, 222, 128);
    --primary-dark: rgb(34, 197, 94);
    --secondary-color: rgb(55, 65, 81);
    --secondary-dark: rgb(31, 41, 55);
    --text-color: rgb(55, 65, 81);
    --text-light: #666666;
    --border-color: #e9ecef;
    --bg-light: #f8f9fa;
    --transition-speed: 0.3s;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(74, 222, 128, 0.35);
    --shadow-lg: 0 8px 25px rgba(0,0,0,0.15);
}

/* Performance: Optimize font rendering */
* {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Exception cho Font Awesome - không override font của icons */
.fa,
.fas,
.far,
.fab,
[class*="fa-"],
[class^="fa-"] {
    font-family: "Font Awesome 6 Free", "Font Awesome 6 Pro", "Font Awesome 5 Free", "FontAwesome", sans-serif !important;
    font-display: swap; /* Optimize font loading */
}
.fab {
    font-family: "Font Awesome 6 Brands", "Font Awesome 5 Brands", "FontAwesome", sans-serif !important;
}

/* Base styles with performance optimizations */
body, html {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    color: var(--text-color) !important;
    background-color: #ffffff !important;
    margin: 0;
    padding: 0;
}


/* Smooth Scrolling with performance */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimized Button Styles - using transform for better performance */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease, background var(--transition-speed) ease;
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    transform: translateZ(0); /* Force hardware acceleration */
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
    transform: translateY(-2px) translateZ(0);
    box-shadow: var(--shadow-md);
    outline: none;
}

.btn-default {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
    transition: transform var(--transition-speed) ease, background var(--transition-speed) ease, color var(--transition-speed) ease;
    will-change: transform, background, color;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.btn-default:hover,
.btn-default:focus {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-2px) translateZ(0);
    outline: none;
}

/* Optimized Card Styles - using GPU acceleration */
.subject-card,
.grade-card,
.blog-card {
    border: 1px solid var(--border-color);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease, border-color var(--transition-speed) ease;
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.subject-card:hover,
.grade-card:hover,
.blog-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-8px) translateZ(0);
    box-shadow: var(--shadow-lg);
}

/* Responsive Images with performance */
img {
    max-width: 100%;
    height: auto;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Lazy loading support */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Section Spacing */
.homepage-section {
    position: relative;
}

/* Optimized Link Styles */
a {
    transition: color var(--transition-speed) ease, opacity var(--transition-speed) ease;
    text-decoration: none;
    color: inherit;
}

a:hover,
a:focus {
    text-decoration: none;
    outline: none;
}

/* Header sticky behavior - optimized with GPU acceleration */
#header {
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    transform: translateZ(0);
}

#header.header-sticky-scroll-up {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transform: translateY(0) translateZ(0);
}

#header.header-sticky-scroll-down {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    transform: translateY(-100%) translateZ(0);
    box-shadow: none;
}

#header:not(.header-sticky-scroll-up):not(.header-sticky-scroll-down) {
    position: relative;
    transform: translateY(0) translateZ(0);
}

/* Performance: Optimize form elements */
input,
textarea,
select,
button {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Touch-friendly sizes for mobile */
@media (max-width: 767px) {
    button,
    .btn,
    a.btn {
        min-height: 44px; /* iOS touch target size */
        min-width: 44px;
        padding: 10px 20px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Optimize font sizes for mobile */
    body {
        font-size: 16px; /* Prevent zoom on iOS */
        line-height: 1.6;
    }
    
    h1 { font-size: 28px; line-height: 1.3; }
    h2 { font-size: 24px; line-height: 1.3; }
    h3 { font-size: 20px; line-height: 1.4; }
    h4 { font-size: 18px; line-height: 1.4; }
    h5 { font-size: 16px; line-height: 1.5; }
    h6 { font-size: 14px; line-height: 1.5; }
    
    /* Reduce animations on mobile for better performance */
    .subject-card:hover,
    .grade-card:hover,
    .blog-card:hover {
        transform: translateY(-4px) translateZ(0);
    }
    

    
    /* Better text readability */
    p {
        margin-bottom: 1em;
        line-height: 1.2;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    /* Better spacing on tablets */
    .homepage-section {
        padding: 60px 0;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .homepage-hero {
        padding: 40px 0;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
    }
}

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

/* Focus styles for accessibility */
/* a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
} */

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999999;
}

.skip-link:focus {
    left: 6px;
    top: 7px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: #fff;
    text-decoration: none;
}

/* Common styles for archive, search, single templates */
.btn {
    display: inline-block;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    border: none;
    line-height: 1.5;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-dark) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: #fff;
}

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

.btn-default:hover,
.btn-default:focus {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-2px);
}

.btn-link {
    background: transparent;
    color: var(--primary-color);
    padding: 0;
    border: none;
}

.btn-link:hover,
.btn-link:focus {
    background: transparent;
    color: var(--secondary-color);
    text-decoration: underline;
}

/* Container utility */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Print styles */
@media print {
    * {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    a,
    a:visited {
        text-decoration: underline;
    }
    
    .btn,
    button {
        display: none;
    }
    
    .custom-header,
    .custom-footer {
        display: none;
    }
}