/**
 * OYA Estate モバイル最適化CSS v3.0
 * タッチ操作、レスポンシブデザイン、パフォーマンス最適化
 */

/* ===== モバイルファーストのベーススタイル ===== */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: #f8f9fa;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== タッチ操作の最適化 ===== */
.touch-optimized {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* ボタンのタッチ最適化 */
button, .btn, .nav-item, .mobile-nav-item {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

/* リンクのタッチ最適化 */
a {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* ===== レスポンシブデザイン ===== */

/* モバイル（〜768px） */
@media (max-width: 768px) {
    /* コンテナの調整 */
    .container {
        padding: 10px;
        max-width: 100%;
    }
    
    /* フォントサイズの最適化 */
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 2rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
        margin-bottom: 0.8rem;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
        margin-bottom: 0.6rem;
    }
    
    /* ナビゲーションのモバイル対応 */
    .nav-menu {
        display: none !important;
    }
    
    #mobileMenuToggle {
        display: block !important;
    }
    
    #mobileMenu.active {
        display: block !important;
    }
    
    /* カードレイアウトの調整 */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .card {
        padding: 20px;
        margin-bottom: 15px;
    }
    
    /* フォームの最適化 */
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-control {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
        border-radius: 8px;
        border: 1px solid #ddd;
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* テーブルの最適化 */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
    }
    
    /* ボタンの最適化 */
    .btn {
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    /* モーダルの最適化 */
    .modal {
        padding: 20px;
    }
    
    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }
}

/* タブレット（769px〜1024px） */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 20px;
        max-width: 100%;
    }
    
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .nav-menu {
        display: flex !important;
    }
    
    #mobileMenuToggle {
        display: none !important;
    }
}

/* デスクトップ（1025px〜） */
@media (min-width: 1025px) {
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 40px 20px;
    }
    
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 30px;
    }
    
    .nav-menu {
        display: flex !important;
    }
    
    #mobileMenuToggle {
        display: none !important;
    }
}

/* ===== スワイプ操作の対応 ===== */
.swipe-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.swipe-container::-webkit-scrollbar {
    display: none;
}

.swipe-item {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* ===== タッチジェスチャーの最適化 ===== */
.touch-gesture {
    touch-action: pan-x pan-y;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* ===== パフォーマンス最適化 ===== */
.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lazy-load.loaded {
    opacity: 1;
}

/* 画像の最適化 */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* 動画の最適化 */
video {
    max-width: 100%;
    height: auto;
}

/* ===== アクセシビリティの向上 ===== */
.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 {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* キーボードナビゲーション */
.keyboard-navigation *:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* ===== ダークモード対応 ===== */
@media (prefers-color-scheme: dark) {
    body {
        background: #1a1a1a;
        color: #ffffff;
    }
    
    .card {
        background: #2d2d2d;
        color: #ffffff;
    }
    
    .form-control {
        background: #2d2d2d;
        color: #ffffff;
        border-color: #555;
    }
}

/* ===== 高DPIディスプレイ対応 ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .icon {
        background-size: contain;
        background-repeat: no-repeat;
    }
}

/* ===== 印刷対応 ===== */
@media print {
    .nav-menu,
    #mobileMenuToggle,
    #mobileMenu {
        display: none !important;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ===== アニメーション最適化 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== モバイル特有のスタイル ===== */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

/* ===== タッチフィードバック ===== */
.touch-feedback {
    transition: all 0.1s ease;
}

.touch-feedback:active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* ===== スクロール最適化 ===== */
.smooth-scroll {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ===== モバイルメニューの最適化 ===== */
#mobileMenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    padding: 60px 20px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-nav-item {
    display: block;
    padding: 15px 20px;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.mobile-nav-item:hover,
.mobile-nav-item:active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

/* ===== パフォーマンス最適化 ===== */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* GPU加速の活用 */
.gpu-accelerated {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* ===== ユーティリティクラス ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

/* ===== レスポンシブ画像 ===== */
.responsive-img {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: cover;
}

/* ===== フレックスボックス最適化 ===== */
.flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.align-start {
    align-items: flex-start;
}

.align-end {
    align-items: flex-end;
}

/* ===== グリッド最適化 ===== */
.grid {
    display: grid;
}

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

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.gap-5 { gap: 3rem; }

/* モバイルでのグリッド調整 */
@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}
