/* ===================================
   ガンダム02 共通スタイル
   =================================== */

/* 共通設定 */
#gundam02-wrapper,
#gundam02-detail-wrapper {
    width: 100%;
    min-height: 100vh;
    padding-top: 120px; /* ヘッダーとの距離 */
    padding-bottom: 0; /* フッターとの距離 */
}

/* ===================================
   トップページ スタイル
   =================================== */

.gundam02-top {
    background-color: #1e90ff;
    padding: 40px 20px;
}

/* 矢印 + バナー全体の外側ラッパー
   - position:relative + z-index:0 でスタッキングコンテキストを形成
     → 矢印(z-index:1) が コンテナ(z-index:0) より確実に前面に描画される
   - overflow:hidden は設定しない → 矢印がクリップされず画面端に表示される
   - margin:0 -20px で親padding(20px)を打ち消し画面端まで拡張 */
.banner-outer-wrapper {
    position: relative;
    z-index: 0;
    margin-left: -20px;
    margin-right: -20px;
}

/* スライドクリップ専用ラッパー
   - overflow:hidden でペークスライドを画面端でクリップ
   - 矢印は .banner-outer-wrapper の直接の子なのでここでクリップされない
   - position / z-index は不要（矢印の基準は外側ラッパーに委譲） */
.top-image-wrapper {
    overflow: hidden;
}

/* スライダーコンテナ（max-width で中央配置）
   z-index: 0 を設定することでスタッキングコンテキストを明示的に作成し、
   JS により transform が付与されたトラックのスタッキングコンテキストを
   z-index:0 のレイヤー内に封じ込める → 矢印（z-index:1）が確実に前面に出る */
.top-banner-container {
    position: relative;
    z-index: 0;
    max-width: 1000px;
    margin: 0 auto;
}

.top-banner-slider {
    position: relative;
    overflow: visible; /* 左右ペークのため visible に */
    border-radius: 0;
}

.top-banner-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    /* will-change: transform を削除
       GPU コンポジットレイヤー化により矢印（z-index:10）が裏側に隠れる問題を防ぐ
       transition: transform は will-change なしでも現代ブラウザが自動でハードウェア加速する */
}

.top-banner-slide {
    flex: 0 0 calc(100% - 120px); /* 左右60pxずつのぞかせる */
    flex-shrink: 0;
    margin-right: 16px;
    border-radius: 16px;
    overflow: hidden;
    transition: opacity 0.5s ease;
}

/* 矢印ボタン（画像使用・画面端配置）
   z-index: 1 → .top-banner-container（z-index:0）より確実に前面 */
.banner-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    line-height: 0;
}

.banner-arrow img {
    display: block;
    height: 160px; /* 🔧 矢印画像の高さ（調整可能） */
    width: auto;
}

.banner-prev {
    left: 0;
}

.banner-next {
    right: 0;
}

.top-main-image {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
}

/* バナードット（インジケーター） */
.banner-dots {
    text-align: center;
    margin-top: 12px;
    margin-bottom: 60px; /* .top-image-wrapper から移動（ドットが wrapper 外に出たため） */
}

.banner-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    margin: 0 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.banner-dot.active {
    background-color: #ffffff;
}

/* 地域選択セクション */
.region-selection-wrapper {
    max-width: 1000px;
    margin: 0 auto 60px;
    display: flex;
    align-items: flex-start;
    gap: 80px;
}

/* 左側エリア（地域から探す） */
.region-left-wrapper {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.region-title-wrapper {
    flex-shrink: 0;
}

.region-title-image {
    width: 300px;
    height: auto;
}

/* 右側のコンテンツエリア（ボタン） */
.region-content-wrapper {
    flex: 1;
}

.region-buttons-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* 地域ボタン */
.region-button {
    background-color: #ffffff;
    color: #333333;
    border: none;
    border-radius: 32px;
    padding: 0px 0px;
    font-size: 27px;
    font-weight: bold;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    text-align: center;
    width: 100%;
}

.region-button:hover {
    background-color: #ffa07a;
    color: #ffffff;
}

.region-button.active {
    background-color: #ffa07a;
    color: #ffffff;
}

/* コピーライト（共通） */
.copyright-image {
    height: 30px; /* 🔧 サイズ調整可能 */
    width: auto;
    display: block;
}

/* コピーライト：トップページ（地域ボタン押下後の商品グリッド下） */
#gundam02-wrapper .copyright-wrapper {
    max-width: 1000px;   /* .product-list-wrapper と揃える */
    margin: 16px auto 0;
    padding: 0 20px;
}

/* コピーライト：トップページ常時表示（地域ボタン選択前・ページ下部） */
.copyright-top-static {
    max-width: 1000px;
    margin: 40px auto 40px; /* 🔧 上下の余白調整可能 */
    padding: 0 20px;
}

/* コピーライト：商品一覧ページ（全商品の下・main.jpg左端に揃える） */
#gundam02-detail-wrapper .copyright-wrapper {
    max-width: 1200px;       /* .product-section と揃える */
    margin: -60px auto 0;    /* 🔧 product-sectionのmargin-bottom(80px)を打ち消してmain.jpgに近づける */
    padding: 0 20px;         /* .product-section と同じ → main.jpgの左端に揃う */
}

/* カテゴリ一覧エリア */
.product-list-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.product-item {
    background-color: transparent;
    border-radius: 36px; /* 🔧 角丸サイズ（調整可能） */
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.product-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.product-link {
    display: block;
    text-decoration: none;
}

.product-image {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 1 / 1; /* 正方形に統一 */
    object-fit: cover;   /* 余白なくトリミング */
}

/* ===================================
   詳細ページ スタイル
   =================================== */

.gundam02-detail {
    background-color: #ffffff;
    padding: 0;
}

/* 詳細トップ画像 */
.detail-top-image-wrapper {
    max-width: 1200px;
    margin: 0 auto 40px;
    padding: 0 20px;
}

.detail-top-image {
    width: 100%;
    height: auto;
    display: block;
}

/* 商品セクション */
.product-section {
    max-width: 1200px;
    margin: 0 auto 80px;
    padding: 0 20px;
}

.product-title-wrapper {
    margin-bottom: 30px;
    text-align: center;
}

.product-title-image {
    width: 100%;
    max-width: 1100px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.product-content {
    display: flex;
    gap: 20px;
}

/* 商品画像1（左側・大きめ） */
.product-main-image-wrapper {
    flex: 0 0 35%;
}

.product-main-image {
    width: 100%;
    height: auto;
    border-radius: 40px;
    border: 2px solid #cccccc;
}

/* 商品画像2・3（中央・縦2段） */
.product-detail-images {
    flex: 0 0 16%;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.product-detail-image {
    width: 100%;
    height: auto;
    border-radius: 22px;
    border: 2px solid #cccccc;
}

/* 説明テキスト（右側） */
.product-description {
    flex: 1;
    padding: 20px;
    background-color: #ffffff;
    border-radius: 8px;
    box-sizing: border-box;
}

.product-text {
    font-size: 14px;
    line-height: 1;
    color: #333333;
    white-space: pre-line;
}

/* エラーメッセージ */
.error-message,
.no-products {
    max-width: 600px;
    margin: 100px auto;
    padding: 40px;
    text-align: center;
    background-color: #f8f8f8;
    border-radius: 8px;
}

.error-message p,
.no-products p {
    margin: 10px 0;
    font-size: 16px;
    line-height: 1.6;
}

.error-message a,
.no-products a {
    color: #448ECA;
    text-decoration: underline;
}

/* ===================================
   画像拡大モーダル
   =================================== */

/* モーダル背景 */
.image-modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    cursor: default;
    display: flex;
    justify-content: center;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 0.3s, opacity 0.3s ease, background-color 0.3s ease;
}

/* モーダル表示時 */
.image-modal.active {
    visibility: visible;
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.9);
    transition: visibility 0s 0s, opacity 0.3s ease, background-color 0.3s ease;
}

/* 画像コンテナ */
.image-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 拡大画像 */
.image-modal img {
    min-width: 600px;
    max-width: 1200px;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.4s ease, transform 0.4s ease;
    user-select: none;
}

/* 画像表示時のアニメーション */
.image-modal.active img {
    opacity: 1;
    transform: scale(1);
}

/* 閉じるボタン */
.image-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.4s ease;
    user-select: none;
}

.image-modal.active .image-modal-close {
    opacity: 1;
}

.image-modal-close:hover {
    color: #cccccc;
}

/* 左右の矢印ボタン */
.image-modal-prev,
.image-modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff;
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.4s ease, background-color 0.3s ease;
    user-select: none;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 20px 15px;
    border-radius: 8px;
}

.image-modal.active .image-modal-prev,
.image-modal.active .image-modal-next {
    opacity: 0.7;
}

.image-modal-prev:hover,
.image-modal-next:hover {
    opacity: 1 !important;
    background-color: rgba(0, 0, 0, 0.8);
}

.image-modal-prev {
    left: 20px;
}

.image-modal-next {
    right: 20px;
}

/* 画像インジケーター */
.image-modal-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffffff;
    font-size: 18px;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.4s ease;
    user-select: none;
}

.image-modal.active .image-modal-indicator {
    opacity: 1;
}

/* クリック可能な画像のカーソル */
.product-main-image,
.product-detail-image {
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.product-main-image:hover,
.product-detail-image:hover {
    opacity: 0.8;
}

/* ===================================
   レスポンシブ対応
   =================================== */

/* タブレット（768px - 1023px） */
@media (max-width: 1023px) {
    /* ヘッダー余白調整 */
    #gundam02-wrapper,
    #gundam02-detail-wrapper {
        padding-top: 80px;
    }

    /* トップページ - 地域選択 */
    .region-selection-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .region-left-wrapper {
        gap: 20px;
        align-items: center;
    }

    .region-title-image {
        width: 180px;
    }

    .region-content-wrapper {
        width: 100%;
    }

    .region-buttons-wrapper {
        grid-template-columns: repeat(3, 1fr);
    }


    /* トップページ - カテゴリ一覧 */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    /* 詳細ページ - 商品コンテンツ */
    .product-content {
        flex-wrap: wrap;
        gap: 20px;
    }

    .product-main-image-wrapper {
        flex: 0 0 100%;
    }

    .product-detail-images {
        flex: 0 0 100%;
        flex-direction: row;
        gap: 20px;
    }

    .product-detail-image {
        width: calc(50% - 10px);
    }

    .product-description {
        flex: 0 0 100%;
    }
}

/* ===================================
   スマートフォン（767px以下）
   🔧 ここから下がスマホ版の調整箇所です
   =================================== */
@media (max-width: 767px) {
    /* ヘッダー余白調整 */
    #gundam02-wrapper,
    #gundam02-detail-wrapper {
        padding-top: 80px; /* 🔧 調整可能: ヘッダーとの距離 */
        padding-bottom: 120px; /* 🔧 調整可能: フッターとの距離 */
    }

    /* ===== トップページ ===== */

    .gundam02-top {
        padding: 20px 0; /* 🔧 左右の余白を0に（上下のみ余白を残す） */
    }

    /* 📱 トップ画像（ローテーションバナー）の調整 */
    .banner-outer-wrapper {
        margin-left: 0;  /* 親の左右padding=0なので打ち消し不要 */
        margin-right: 0;
        margin-bottom: 30px; /* 🔧 画像下の余白 */
    }
    .top-image-wrapper {
        padding: 0;
    }

    .top-banner-slider {
        border-radius: 0; /* 🔧 スマホでは角丸を無効化 */
    }

    .top-banner-slide {
        flex: 0 0 calc(100% - 80px); /* 🔧 スマホでは両側40pxのぞかせる */
        margin-right: 12px;
    }

    .banner-arrow img {
        height: 50px; /* 🔧 スマホ用矢印サイズ */
    }

    .banner-prev { left: 0; }
    .banner-next { right: 0; }

    .top-main-image {
        max-width: 100%;
        width: 100%;
    }

    /* 📱 「地域から探す」の調整 */
    .region-selection-wrapper {
        margin-bottom: 30px;
        gap: 20px;
        padding: 0;
        flex-direction: column;
        align-items: center;
    }

    .region-left-wrapper {
        gap: 20px;
        align-items: center;
    }

    .region-title-wrapper {
        text-align: center;
    }

    .region-title-image {
        width: 150px; /* 🔧 画像の横幅 */
        max-width: 100%;
    }

    .region-content-wrapper {
        width: 100%;
    }

    /* 📱 地域ボタンの調整 */
    .region-buttons-wrapper {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px; /* 🔧 ボタン間の余白 */
        padding: 0 10px;
    }

    .region-button {
        font-size: 13px; /* 🔧 ボタンの文字サイズ */
        padding: 8px 8px; /* 🔧 ボタンの内側余白（上下 左右） */
        white-space: normal; /* スマホは折り返し許可 */
    }

    /* 📱 カテゴリ一覧の調整 */
    .product-list-wrapper {
        padding: 20px 10px; /* 🔧 一覧エリア全体の余白（上下 左右） */
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr); /* 2列表示 */
        gap: 10px;
        padding: 0 10px;
    }

    .product-item {
        border-radius: 20px; /* 🔧 スマホ用の角丸（PC版とは独立して調整可能） */
    }

    /* ===== 詳細ページ ===== */

    /* 📱 詳細トップ画像の調整 */
    .detail-top-image-wrapper {
        margin-bottom: 40px;
        padding: 0;
    }

    .detail-top-image {
        width: 100%;
    }

    /* 📱 商品セクション全体 */
    .product-section {
        margin-bottom: 40px;
        padding: 0 10px;
    }

    /* 📱 商品タイトル画像の調整 */
    .product-title-wrapper {
        margin-bottom: 20px;
        text-align: center;
        padding: 0 10px;
    }

    .product-title-image {
        max-width: 100%;
        width: 100%;
    }

    /* 📱 商品コンテンツ */
    .product-content {
        flex-wrap: wrap;
        gap: 15px;
    }

    /* 📱 商品画像1（メイン画像）の調整 */
    .product-main-image-wrapper {
        flex: 0 0 100%;
        text-align: center;
    }

    .product-main-image {
        max-width: 88%; /* 🔧 横幅 */
        width: 100%;
        border-radius: 16px; /* 🔧 角丸のサイズ */
    }

    /* 📱 商品画像2・3（詳細画像）の調整 */
    .product-detail-images {
        flex: 0 0 100%;
        flex-direction: row;
        gap: 15px;
        justify-content: center;
    }

    .product-image-wrapper {
        flex: 0 0 calc(50% - 7.5px);
        max-width: 200px; /* 🔧 各画像の最大横幅 */
    }

    .product-detail-image {
        width: 100%;
        border-radius: 16px; /* 🔧 角丸のサイズ */
    }

    /* 📱 説明テキストの調整 */
    .product-description {
        flex: 0 0 100%;
        padding: 15px;
    }

    .product-text {
        font-size: 14px; /* 🔧 テキストサイズ */
        line-height: 1;
    }

    /* 📱 画像拡大モーダル（スマホ版） */
    .image-modal img {
        min-width: 150px;
        max-width: 95%;
        max-height: 95vh;
    }
}

/* ===================================
   極小スマートフォン（480px以下）
   🔧 さらに小さい画面用の調整箇所
   =================================== */
@media (max-width: 480px) {
    .region-title-image {
        width: 120px; /* 🔧 調整可能: さらに小さいタイトル画像 */
    }

    .region-button {
        font-size: 14px; /* 🔧 調整可能: さらに小さいボタン文字 */
        padding: 8px 16px; /* 🔧 調整可能: さらに小さいボタン余白 */
    }
}
