/**
 * Mobile Critical Fix - 最優先の緊急修正
 * この設定が最後に読み込まれ、全てを上書きします
 */

/* ===== ロゴサイズの絶対的制御 ===== */
@media screen and (max-width: 768px) {
    /* あらゆる方法でロゴを小さくする */
    .header .logo img,
    .header .logo-image,
    .header img[src*="logo"],
    img.logo-image,
    .logo > img,
    header img {
        height: 32px !important;
        max-height: 32px !important;
        min-height: auto !important;
        width: auto !important;
    }
    
    /* ヘッダー自体を小さく */
    .header,
    header,
    #header {
        padding: 6px 0 !important;
        min-height: auto !important;
        height: auto !important;
    }
}

@media screen and (max-width: 576px) {
    .header .logo img,
    .header .logo-image,
    .header img[src*="logo"],
    img.logo-image,
    .logo > img,
    header img {
        height: 28px !important;
        max-height: 28px !important;
    }
    
    .header,
    header,
    #header {
        padding: 5px 0 !important;
    }
}

@media screen and (max-width: 375px) {
    .header .logo img,
    .header .logo-image,
    .header img[src*="logo"],
    img.logo-image,
    .logo > img,
    header img {
        height: 26px !important;
        max-height: 26px !important;
    }
}

/* ===== ヒーローセクションの絶対的制御 ===== */
@media screen and (max-width: 768px) {
    /* ヒーローの高さを制御 */
    .hero,
    section.hero,
    #hero,
    [id="hero"],
    section[class*="hero"] {
        min-height: 0 !important;
        max-height: none !important;
        height: auto !important;
        padding-top: 60px !important;
        padding-bottom: 40px !important;
        position: relative !important;
    }
    
    /* 背景画像が確実に表示されるように */
    .hero-background,
    .hero .hero-background {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 0 !important;
    }
    
    .hero-image,
    .hero .hero-image {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background-image: url('../images/hero-mountains-original.jpg') !important;
        background-size: cover !important;
        background-position: center 40% !important;
        background-repeat: no-repeat !important;
        z-index: 0 !important;
    }
    
    .hero-overlay,
    .hero .hero-overlay {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 1 !important;
        background: linear-gradient(to bottom, 
            rgba(30, 58, 138, 0.3) 0%, 
            rgba(30, 58, 138, 0.55) 100%) !important;
    }
    
    /* ヒーローコンテンツ */
    .hero-content,
    .hero .container:not(.hero-background *),
    .hero > .container {
        padding-top: 10px !important;
        margin-top: 0 !important;
        position: relative !important;
        z-index: 10 !important;
    }
    
    /* タイトルのサイズ */
    .hero-title-new,
    .hero .hero-title-new,
    .hero h1 {
        font-size: 34px !important;
        line-height: 1.2 !important;
        margin-bottom: 20px !important;
    }
    
    /* サブタイトル */
    .hero-subtitle-new,
    .hero .hero-subtitle-new {
        font-size: 15px !important;
        margin-bottom: 30px !important;
    }
}

@media screen and (max-width: 576px) {
    .hero,
    section.hero,
    #hero {
        padding-top: 55px !important;
        padding-bottom: 30px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .hero-title-new,
    .hero h1 {
        font-size: 26px !important;
    }
    
    .hero-subtitle-new {
        font-size: 14px !important;
        margin-bottom: 25px !important;
    }
    
    /* CTAボタン */
    .btn-hero-primary {
        padding: 16px 28px !important;
        font-size: 15px !important;
    }
}

@media screen and (max-width: 375px) {
    .hero,
    section.hero,
    #hero {
        padding-top: 50px !important;
    }
    
    .hero-title-new,
    .hero h1 {
        font-size: 23px !important;
    }
    
    .hero-subtitle-new {
        font-size: 13px !important;
    }
}

/* ===== ビューポート全体の制御（実機対応強化） ===== */
@media screen and (max-width: 768px) {
    /* 横スクロール完全防止 */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
    }
    
    /* bodyのpadding-topを削除 */
    body {
        padding-top: 0 !important;
    }
    
    /* 全てのコンテナ要素の横幅制御 */
    div,
    section,
    main,
    header,
    footer {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* ===== フッターの改行・空欄修正（削除：下部に統合） ===== */

/* ===== コンタクトセクションの修正 ===== */
@media screen and (max-width: 768px) {
    .contact-guarantee {
        display: flex !important;
        gap: 12px !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 15px !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .contact-guarantee i {
        flex-shrink: 0 !important;
        font-size: 20px !important;
    }
    
    .contact-guarantee > div {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .contact-guarantee strong,
    .contact-guarantee p {
        max-width: 100% !important;
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
        display: block !important;
    }
    
    .contact-guarantee p {
        font-size: 13px !important;
        line-height: 1.6 !important;
        margin: 5px 0 0 0 !important;
    }
}

@media screen and (max-width: 576px) {
    .contact-guarantee {
        padding: 12px !important;
        gap: 10px !important;
    }
    
    .contact-guarantee strong {
        font-size: 14px !important;
    }
    
    .contact-guarantee p {
        font-size: 12px !important;
    }
}

/* ===== フッターの修正（削除：下部に統合） ===== */

/* ===== コンタクトセクションの修正（最強設定） ===== */
@media screen and (max-width: 768px) {
    .contact-wrapper,
    .contact-info,
    .contact-phone-box,
    .contact-benefits,
    .contact-guarantee {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }
    
    .contact-info {
        padding: 20px 15px !important;
    }
    
    .contact-phone-box {
        padding: 20px 15px !important;
        margin: 15px 0 !important;
    }
    
    .contact-benefits {
        padding: 20px 15px !important;
        margin: 15px 0 !important;
    }
    
    .contact-benefits ul {
        padding-left: 0 !important;
        margin: 10px 0 !important;
    }
    
    .contact-benefits li {
        display: flex !important;
        align-items: flex-start !important;
        gap: 8px !important;
        margin-bottom: 8px !important;
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
    }
    
    .contact-benefits li i {
        flex-shrink: 0 !important;
        margin-top: 3px !important;
    }
}

@media screen and (max-width: 576px) {
    .contact-info {
        padding: 15px 10px !important;
    }
    
    .contact-phone-box {
        padding: 15px 10px !important;
        margin: 12px 0 !important;
    }
    
    .contact-benefits {
        padding: 15px 10px !important;
        margin: 12px 0 !important;
    }
    
    .contact-benefits h4 {
        font-size: 15px !important;
        margin-bottom: 10px !important;
    }
    
    .contact-benefits li {
        font-size: 12px !important;
        margin-bottom: 6px !important;
        line-height: 1.4 !important;
    }
    
    .contact-guarantee {
        display: flex !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 12px 10px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .contact-guarantee i {
        flex-shrink: 0 !important;
        font-size: 18px !important;
        margin-top: 2px !important;
    }
    
    .contact-guarantee > div {
        flex: 1 !important;
        min-width: 0 !important;
        width: 100% !important;
    }
    
    .contact-guarantee strong {
        display: block !important;
        font-size: 13px !important;
        line-height: 1.4 !important;
        margin-bottom: 4px !important;
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
    }
    
    .contact-guarantee p {
        display: block !important;
        font-size: 11px !important;
        line-height: 1.5 !important;
        margin: 0 !important;
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
    }
}

/* ===== フッターの改行・空白問題を修正（第7回・確実に適用） ===== */
@media screen and (max-width: 768px) {
    /* リストの基本設定 */
    .footer .footer-links ul,
    .footer .footer-contact ul,
    .footer-links ul,
    .footer-contact ul,
    .footer ul,
    footer ul {
        padding: 0 !important;
        margin: 0 !important;
        list-style: none !important;
    }
    
    /* リスト項目 - 適度な間隔（5px） - 詳細度を上げて確実に適用 */
    .footer .footer-links li,
    .footer .footer-contact li,
    .footer .footer-links > ul > li,
    .footer .footer-contact > ul > li,
    .footer-links li,
    .footer-contact li,
    .footer li,
    .footer-links > ul > li,
    .footer-contact > ul > li,
    footer li,
    footer .footer-links li,
    footer .footer-contact li {
        margin: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 5px !important;
        padding: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        line-height: 1.4 !important;
    }
    
    .footer .footer-links li:last-child,
    .footer .footer-contact li:last-child,
    .footer-links li:last-child,
    .footer-contact li:last-child {
        margin-bottom: 0 !important;
    }
    
    /* リンク - 読みやすい設定 - 詳細度を上げる */
    .footer .footer-links a,
    .footer .footer-contact a,
    .footer .footer-links li a,
    .footer .footer-contact li a,
    .footer-links a,
    .footer-contact a,
    .footer a,
    .footer-links li a,
    .footer-contact li a,
    footer a,
    footer .footer-links a,
    footer .footer-contact a {
        display: block !important;
        word-break: keep-all !important;
        overflow-wrap: break-word !important;
        line-height: 1.4 !important;
        padding: 2px 0 !important;
        padding-top: 2px !important;
        padding-bottom: 2px !important;
        margin: 0 !important;
        font-size: 13px !important;
    }
    
    /* フッターセクション全体の間隔 */
    .footer .footer-links,
    .footer .footer-contact,
    .footer-links,
    .footer-contact {
        margin-bottom: 20px !important;
    }
    
    .footer .footer-links h4,
    .footer .footer-contact h4,
    .footer-links h4,
    .footer-contact h4 {
        margin-bottom: 10px !important;
        margin-top: 0 !important;
        font-size: 15px !important;
        line-height: 1.3 !important;
    }
}

@media screen and (max-width: 576px) {
    /* 小さい画面：やや狭く（4px） - 詳細度を上げる */
    .footer .footer-links li,
    .footer .footer-contact li,
    .footer-links li,
    .footer-contact li,
    .footer li,
    .footer-links > ul > li,
    .footer-contact > ul > li,
    footer li,
    footer .footer-links li,
    footer .footer-contact li {
        margin-bottom: 4px !important;
        line-height: 1.3 !important;
    }
    
    .footer .footer-links a,
    .footer .footer-contact a,
    .footer-links a,
    .footer-contact a,
    .footer a,
    .footer-links li a,
    .footer-contact li a,
    footer a,
    footer .footer-links a,
    footer .footer-contact a {
        font-size: 12px !important;
        line-height: 1.3 !important;
        padding: 1px 0 !important;
    }
    
    .footer .footer-links,
    .footer .footer-contact,
    .footer-links,
    .footer-contact {
        margin-bottom: 18px !important;
    }
    
    .footer .footer-links h4,
    .footer .footer-contact h4,
    .footer-links h4,
    .footer-contact h4 {
        margin-bottom: 8px !important;
        font-size: 14px !important;
    }
}

@media screen and (max-width: 375px) {
    /* 超小型画面：バランスを保つ（3px） - 詳細度を上げる */
    .footer .footer-links li,
    .footer .footer-contact li,
    .footer-links li,
    .footer-contact li,
    .footer li,
    footer li,
    footer .footer-links li,
    footer .footer-contact li {
        margin-bottom: 3px !important;
        line-height: 1.25 !important;
    }
    
    .footer .footer-links a,
    .footer .footer-contact a,
    .footer-links a,
    .footer-contact a,
    footer a,
    footer .footer-links a,
    footer .footer-contact a {
        font-size: 11px !important;
        line-height: 1.25 !important;
    }
    
    .footer .footer-links h4,
    .footer .footer-contact h4,
    .footer-links h4,
    .footer-contact h4 {
        margin-bottom: 7px !important;
        font-size: 13px !important;
    }
}

/* ===== ヒーロー背景画像の確実な表示 ===== */
@media screen and (max-width: 768px) {
    .hero-background,
    .hero .hero-background {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: -1 !important;
    }
    
    .hero-image,
    .hero .hero-image {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background-image: url('../images/hero-mountains-original.jpg') !important;
        background-size: cover !important;
        background-position: center 40% !important;
        background-repeat: no-repeat !important;
        z-index: -2 !important;
    }
    
    .hero-overlay,
    .hero .hero-overlay {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: -1 !important;
        background: linear-gradient(to bottom, rgba(30, 58, 138, 0.25) 0%, rgba(30, 58, 138, 0.5) 100%) !important;
    }
    
    .hero-content {
        position: relative !important;
        z-index: 1 !important;
    }
}

/* ===== 最終確認用の設定 ===== */
/* デバッグが必要な場合は以下のコメントを外す */
/*
@media screen and (max-width: 768px) {
    .hero {
        border: 3px solid red !important;
    }
    
    .logo-image {
        border: 3px solid blue !important;
    }
    
    .contact-guarantee {
        border: 2px solid green !important;
    }
}
*/
