/*
 * PWA インストール導線の最小 CSS（spec §4.5 仮素材ルール準拠）
 * - マスコット導線: 右下固定、閉じるボタンなし
 * - モーダル: 全画面オーバーレイ + 中央表示、サイズ固定（spec §4.5 C-5）
 * - 正式素材納品後にデザイナーが上書き想定（spec §4.6 ロールバック計画とは独立）
 */

/* ---------- マスコット導線 ---------- */
/* footer-navigation (高さ ~80px) の直上に配置。z-index は 99999 (footer) より上 */
.pwa-mascot-prompt {
    position: fixed;
    right: 10px;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    z-index: 99998;
    pointer-events: none;
}

.pwa-mascot-prompt__mascot {
    pointer-events: auto;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 88px;
    height: 88px;
    overflow: visible;
    line-height: 0;
    display: block;
}

/* iOS Safari (特に iPhone 8) で <img> + object-fit が稀にトリミングされる問題回避のため background-image を使用 */
/* background-image URL は Blade 側で inline style + asset() で注入する（サブパス配信対応） */
.pwa-mascot-prompt__image {
    display: block;
    width: 88px;
    height: 88px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    /* 既存 welcome-page.blade.php の cookie-bounce と同パターン（spec §2.5） */
    animation: pwa-mascot-bounce 0.8s ease-in-out infinite;
}

@keyframes pwa-mascot-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-12px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pwa-mascot-prompt__image {
        animation: none;
    }
}

/* ガチャプレイ / 決済 / 動画再生 / コレクション画面では非表示（spec §2.5） */
.pwa-promo-suppressed .pwa-mascot-prompt,
.pwa-promo-suppressed #pwa-install-modal {
    display: none !important;
}

/* PWA 起動時（standalone モード）はインストール導線・案内 POPUP すべて非表示 */
/* すでにインストール済みなので案内不要 */
@media (display-mode: standalone) {
    .pwa-mascot-prompt,
    #pwa-install-modal,
    .pwa-install-modal-overlay {
        display: none !important;
    }
}

/* iOS Safari standalone モード（`navigator.standalone === true`）対応 */
/* matchMedia('(display-mode: standalone)') は iOS でも動くが念のため JS 経由クラスでも非表示 */
.pwa-standalone .pwa-mascot-prompt,
.pwa-standalone #pwa-install-modal,
.pwa-standalone .pwa-install-modal-overlay {
    display: none !important;
}

/* ---------- インストールモーダル（共通枠） ---------- */
/* footer-navigation の z-index 99999 を超える 100000 で最前面表示 */
.pwa-install-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 16px;
    /* iOS Safari でスクロール可能にする（モーダルが画面より長い場合） */
    overflow-y: auto;
}

.pwa-install-modal-overlay[hidden] {
    display: none;
}

.pwa-install-modal {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 18px 16px;
    width: 100%;
    max-width: 340px;
    /* spec §4.5: 3 ステップ間でサイズ固定（ただし画面高さを超えない） */
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
}

.pwa-install-modal__close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #888;
}

.pwa-install-modal__title {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    text-align: center;
}

.pwa-install-modal__body {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

.pwa-install-modal__cta {
    width: 100%;
    padding: 12px;
    background: #FF6F00;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 15px;
}

/* gummy-btn と組み合わせる場合、高さは gummy-btn 既定（36px）を尊重して幅と margin だけ調整 */
.pwa-install-modal__cta.gummy-btn {
    width: 100%;
    height: 44px;
    border-radius: 22px;
    padding: 0;
    font-size: 15px;
}

/* 「あとで」「戻る」は小さい下線テキストボタン */
.pwa-install-modal__later-link {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 4px 0;
    background: transparent;
    color: #888;
    border: none;
    cursor: pointer;
    font-size: 12px;
    text-align: center;
    text-decoration: underline;
}

.pwa-install-modal__later,
.pwa-install-modal__back {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

.pwa-install-modal__hint {
    margin: 12px 0 0 0;
    padding: 8px 10px;
    background: #FFF8E1;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    color: #666;
}

/* ---------- iOS Safari 3 ステップガイド固有 ---------- */
.pwa-install-modal--ios-safari-guide .pwa-install-modal__header-tag {
    margin: 0;
    color: #FF6F00;
    font-size: 16px;
    text-align: center;
    font-weight: bold;
}

.pwa-install-modal__progress {
    margin: 6px 0 12px 0;
}

.pwa-install-modal__progress-text {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.pwa-install-modal__progress-bar {
    height: 6px;
    background: #eee;
    border-radius: 3px;
    overflow: hidden;
}

.pwa-install-modal__progress-bar-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #FFD54F, #FF6F00);
    transition: width 0.3s ease;
}

.pwa-install-modal__step {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pwa-install-modal__step[hidden] {
    display: none;
}

.pwa-install-modal__step-image {
    flex: 0 0 auto;
    background: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 12px;
    text-align: center;
}

/* 画像トリミングを避けるため自然な縦横比で表示 */
.pwa-install-modal__step-image img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    border-radius: 8px;
}

.pwa-install-modal__thumbnail {
    width: 100%;
    margin-bottom: 12px;
    text-align: center;
}

.pwa-install-modal__thumbnail img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.pwa-install-modal__step-heading {
    margin: 0 0 6px 0;
    font-weight: bold;
    color: #FF6F00;
    font-size: 14px;
}

/* 「ステップN」を太字でオレンジ色に目立たせる */
.pwa-install-modal__step-number {
    font-weight: bold;
    color: #FF6F00;
    font-size: 16px;
}

.pwa-install-modal__step-text {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.pwa-install-modal__buttons {
    margin-top: auto;
}
