/**
 * Who We Are Phase 5 - Final Integration
 * 全コンポーネントの統合とPhase 5で追加された機能
 */

/* Phase 5で追加されたモーダル修正を含む統合CSS */
@import url('./who-we-are-unified.css');
@import url('./components/modal-fixes.css');

/* Phase 5 追加機能 */

/* デバッグモード */
.debug-mode {
    position: relative;
}

.debug-mode::before {
    content: "🐛 DEBUG MODE";
    position: fixed;
    top: 10px;
    right: 10px;
    background: #ff4444;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10000;
    pointer-events: none;
}

.debug-mode .modal-overlay {
    border: 2px dashed #ff4444;
}

.debug-mode .modal-content {
    border: 2px solid #00ff00;
}

.debug-mode .modal-close {
    border: 2px solid #ffff00;
}

/* テーマ切り替えアニメーション */
:root {
    --theme-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    transition: 
        background-color var(--theme-transition),
        color var(--theme-transition),
        border-color var(--theme-transition),
        box-shadow var(--theme-transition);
}

/* テーマ切り替え時のスムーズな遷移 */
.theme-classic,
.theme-dark,
.theme-pop {
    transition: var(--theme-transition);
}

/* スクロール進捗バー */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    z-index: 9999;
    transition: width 0.1s ease-out;
}

/* パフォーマンス最適化 */
.card,
.btn,
.modal-content,
.lightbox-content {
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* GPU加速の適用 */
.animate-on-scroll,
.parallax-element,
.magnetic-effect {
    transform: translateZ(0);
    will-change: transform;
}

/* レイアウトシフト防止 */
img[data-src] {
    background: var(--color-surface);
    min-height: 200px;
    display: block;
}

img[data-src].loaded {
    min-height: auto;
}

/* アクセシビリティ強化 */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* フォーカス表示の強化 */
.focus-enhanced:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(var(--color-focus-rgb), 0.2);
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
    :root {
        --color-border: #000000;
        --color-text-primary: #000000;
        --color-text-secondary: #333333;
        --color-background: #ffffff;
        --color-surface: #f8f9fa;
    }
    
    .theme-dark {
        --color-border: #ffffff;
        --color-text-primary: #ffffff;
        --color-text-secondary: #cccccc;
        --color-background: #000000;
        --color-surface: #1a1a1a;
    }
    
    .btn,
    .card,
    .modal-content {
        border: 2px solid var(--color-border);
    }
}

/* 透明度削減設定対応 */
@media (prefers-reduced-transparency: reduce) {
    .modal-overlay {
        background: var(--color-overlay-solid, rgba(0, 0, 0, 0.9));
    }
    
    .card,
    .btn {
        backdrop-filter: none;
        background: var(--color-surface);
    }
}

/* モーション削減設定対応 */
@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;
    }
    
    .parallax-element {
        transform: none !important;
    }
    
    .magnetic-effect {
        transform: none !important;
    }
    
    .animate-on-scroll {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* プリント対応 */
@media print {
    .modal-overlay,
    .scroll-progress,
    .debug-mode::before {
        display: none !important;
    }
    
    .card,
    .btn {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    .page-break {
        page-break-before: always;
    }
}

/* 小さな画面での最適化 */
@media (max-width: 480px) {
    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-close {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}

/* 大きな画面での最適化 */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .modal-content {
        max-width: 800px;
    }
}

/* ダークモード自動検出 */
@media (prefers-color-scheme: dark) {
    :root:not(.theme-classic):not(.theme-pop) {
        --color-background: #0d1117;
        --color-surface: #161b22;
        --color-text-primary: #f0f6fc;
        --color-text-secondary: #8b949e;
        --color-border: #30363d;
    }
}

/* Phase 5 特有のユーティリティクラス */
.phase5-enhanced {
    position: relative;
}

.phase5-enhanced::after {
    content: "Phase 5 Enhanced";
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--color-success);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.debug-mode .phase5-enhanced::after {
    opacity: 1;
}

/* エラー状態の表示 */
.error-state {
    border: 2px solid var(--color-error);
    background: rgba(var(--color-error-rgb), 0.1);
    color: var(--color-error);
    padding: 15px;
    border-radius: var(--border-radius-md);
    margin: 10px 0;
}

.error-state::before {
    content: "⚠️ ";
    font-weight: bold;
}

/* 成功状態の表示 */
.success-state {
    border: 2px solid var(--color-success);
    background: rgba(var(--color-success-rgb), 0.1);
    color: var(--color-success);
    padding: 15px;
    border-radius: var(--border-radius-md);
    margin: 10px 0;
}

.success-state::before {
    content: "✅ ";
    font-weight: bold;
}

/* 警告状態の表示 */
.warning-state {
    border: 2px solid var(--color-warning);
    background: rgba(var(--color-warning-rgb), 0.1);
    color: var(--color-warning);
    padding: 15px;
    border-radius: var(--border-radius-md);
    margin: 10px 0;
}

.warning-state::before {
    content: "⚠️ ";
    font-weight: bold;
}

/* ローディング状態 */
.loading-state {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading-state::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-border);
    border-top: 2px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Phase 5 統合完了マーカー */
.who-we-are-phase5-complete {
    --phase5-version: "1.0.0";
    --phase5-build-date: "2025-06-19";
    --phase5-features: "modal-fixes, js-integration, accessibility-audit, performance-optimization";
}

/* 開発者向けの情報表示 */
.debug-mode .who-we-are-phase5-complete::before {
    content: "Phase 5 Complete - v" var(--phase5-version) " (" var(--phase5-build-date) ")";
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 10000;
    pointer-events: none;
}

/* 最終的なパフォーマンス最適化 */
.optimized {
    contain: layout style paint;
}

.optimized img {
    content-visibility: auto;
    contain-intrinsic-size: 300px 200px;
}

/* Phase 5 完了時の統合確認 */
@supports (container-type: inline-size) {
    .phase5-container-query-support::after {
        content: "✅ Container Queries Supported";
    }
}

@supports (backdrop-filter: blur(10px)) {
    .phase5-backdrop-filter-support::after {
        content: "✅ Backdrop Filter Supported";
    }
}

@supports (aspect-ratio: 16/9) {
    .phase5-aspect-ratio-support::after {
        content: "✅ Aspect Ratio Supported";
    }
}

/* 最終的なブラウザ互換性確保 */
@supports not (gap: 20px) {
    .grid-fallback {
        display: block;
    }
    
    .grid-fallback > * {
        margin-bottom: 20px;
    }
}

/* Phase 5 統合テスト用のマーカー */
.phase5-integration-test {
    position: relative;
}

.phase5-integration-test[data-test-status="pass"]::after {
    content: "✅ Test Pass";
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-success);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 0 0 0 4px;
}

.phase5-integration-test[data-test-status="fail"]::after {
    content: "❌ Test Fail";
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-error);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 0 0 0 4px;
}

.phase5-integration-test[data-test-status="warning"]::after {
    content: "⚠️ Test Warning";
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-warning);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 0 0 0 4px;
}