/**
 * Mobile Overflow Fix
 * モバイルで右側が切れる問題を修正
 * - グリッドのminmax値を調整
 * - テーブルの横スクロール対応
 * - 全要素の横幅制限
 */

/* ===== 基本的な横幅制限 ===== */
@media (max-width: 576px) {
    /* 全体の横スクロール防止 */
    body {
        overflow-x: hidden;
    }
    
    /* コンテナの横幅を確実に制限 */
    .container {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* セクション全体の横幅制限 */
    section {
        overflow-x: hidden;
    }
    
    /* ===== グリッドレイアウトの修正 ===== */
    
    /* 選ばれる理由カード */
    .reasons-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* 問題セクション */
    .problems-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* FAQグリッド */
    .faq-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* 証明書・資格グリッド */
    .certifications-grid,
    .achievements-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* 統計情報グリッド */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* シミュレーショングリッド */
    .simulation-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* ===== テーブルの横スクロール対応 ===== */
    
    /* 比較表 */
    .comparison-table-wrapper {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding: 0 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }
    
    .comparison-table {
        min-width: 600px; /* 最小幅を設定してスクロール可能に */
    }
    
    /* ===== 画像・動画の横幅制限 ===== */
    img, video {
        max-width: 100%;
        height: auto;
    }
    
    /* ===== フォーム要素の横幅制限 ===== */
    input, textarea, select, button {
        max-width: 100%;
    }
    
    /* ===== 特定要素の調整 ===== */
    
    /* ボタングループ */
    .btn-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        max-width: 100%;
    }
    
    /* CTA要素 */
    .cta-container,
    .cta-box {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* カード要素 */
    .card,
    .reason-card,
    .problem-card,
    .testimonial-card {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* ===== プロセスフロー ===== */
    .process-flow,
    .flow-step {
        max-width: 100%;
        overflow: visible;
    }
    
    /* ===== アコーディオン ===== */
    .accordion-item {
        max-width: 100%;
        overflow: hidden;
    }
    
    .accordion-header {
        max-width: 100%;
        overflow: hidden;
    }
    
    .accordion-title {
        flex: 1;
        min-width: 0;
        overflow: visible;
        white-space: normal;
        word-break: keep-all;
        overflow-wrap: break-word;
    }
    
    .accordion-content {
        max-width: 100%;
        overflow: hidden;
    }
    
    .accordion-content * {
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: keep-all;
    }
    
    /* ===== ワンストップ比較図 ===== */
    .onestop-grid {
        grid-template-columns: 1fr !important;
    }
    
    .flow-diagram {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* ===== 数値グリッド（実績数字） ===== */
    .numbers-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* ===== コンタクトフォーム ===== */
    .contact-grid {
        grid-template-columns: 1fr !important;
    }
    
    .form-row {
        grid-template-columns: 1fr !important;
    }
    
    /* ===== スティッキーCTA ===== */
    .sticky-cta {
        max-width: 100%;
        width: 100%;
        left: 0;
        right: 0;
        box-sizing: border-box;
    }
    
    /* ===== Hero Stats ===== */
    .hero-stats-compact {
        flex-wrap: wrap;
        max-width: 100%;
    }
    
    .stat-compact {
        flex: 1 1 auto;
        min-width: 0; /* flexアイテムの最小幅をリセット */
    }
}

/* ===== 超小型デバイス（320px-360px）対応 ===== */
@media (max-width: 360px) {
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    
    .comparison-table-wrapper {
        margin-left: -12px;
        margin-right: -12px;
    }
    
    /* 文字サイズをさらに調整 */
    body {
        font-size: 14px;
    }
    
    h2 {
        font-size: 24px !important;
    }
    
    h3 {
        font-size: 18px !important;
    }
}
