/* ===== Performance Optimizations ===== */

/* ===== Critical CSS Inlining ===== */
.hero {
    contain: layout style paint;
}

.header {
    contain: layout style paint;
}

/* ===== Image Optimization ===== */
img {
    max-width: 100%;
    display: block;
}

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

/* ===== Font Loading Optimization ===== */
@font-face {
    font-family: 'Noto Sans JP';
    font-display: swap;
    src: url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap');
}

@font-face {
    font-family: 'Inter';
    font-display: swap;
    src: url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap');
}

/* ===== Layout Stability ===== */
.aspect-ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.aspect-ratio-4-3 {
    aspect-ratio: 4 / 3;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1 / 1;
}

/* ===== Content Visibility ===== */
.content-visibility-auto {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* ===== Container Queries ===== */
@container (min-width: 300px) {
    .card {
        padding: 1.5rem;
    }
}

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

/* ===== Scroll Behavior ===== */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ===== Focus Management ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}

/* ===== Print Styles ===== */
@media print {
    .header,
    .footer,
    .hero__cta,
    .btn,
    .wave-decoration {
        display: none !important;
    }
    
    .hero {
        min-height: auto;
        padding: 2rem 0;
    }
    
    .section {
        padding: 1rem 0;
        break-inside: avoid;
    }
    
    .card,
    .theme-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: black;
        page-break-after: avoid;
    }
}

/* ===== High Contrast Mode ===== */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #00ff00;
        --text-light: #ffffff;
        --text-gray: #cccccc;
        --border-light: #666666;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
    
    .card,
    .theme-card,
    .criteria-item {
        border: 2px solid var(--border-light);
    }
}

/* ===== Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --dark-bg: #000000;
        --dark-bg-secondary: #111111;
        --text-light: #ffffff;
        --text-gray: #cccccc;
    }
}

/* ===== Mobile Optimizations ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .section {
        padding: 3rem 0;
    }
    
    .hero {
        min-height: 70vh;
        padding: 80px 0 2rem; /* 80px はヘッダー高さに合わせて調整 */
    }
    
    .hero__title {
        font-size: 2.5rem;
    }
    
    .hero__subtitle {
        font-size: 1rem;
    }
    
    .btn {
        min-height: 44px; /* Touch target size */
        padding: 0.75rem 1.5rem;
    }
}

/* ===== Performance Monitoring ===== */
.performance-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff6b6b;
    color: white;
    padding: 0.5rem;
    text-align: center;
    z-index: 9999;
    display: none;
}

.performance-warning.show {
    display: block;
}

/* ===== Resource Hints ===== */
.preload-critical {
    font-display: swap;
}

/* ===== Lazy Loading Placeholder ===== */
.lazy-placeholder {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Critical Resource Optimization ===== */
.critical-resource {
    will-change: transform;
    transform: translateZ(0);
}

/* ===== Memory Optimization ===== */
.low-memory {
    .wave-decoration::before,
    .wave-decoration::after {
        display: none;
    }
    
    .theme-card:hover,
    .criteria-item:hover {
        transform: none;
        box-shadow: none;
    }
}