/**
 * mls_mascot.css — サイトマスコット専用スタイル (FTP Edition)
 *
 * 位置付け: page-feature 用 CSS
 * 設定元: stn_page_table.extra_settings.mascot
 * 描画: mls_render_mascot_html() (mls_mascot_renderer.php)
 * 派生元: chuken本体 mallink/ml_style/mls_mascot.css
 *
 * Phase 3a: hover_mode (float/static) + entrance_style (default/dramatic_cross) +
 *           吹き出し位置 4方向（top/bottom/left/right）対応
 */

/* =========================
   コンテナ
========================= */
.mls-mascot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 20px auto 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.mls-mascot.is-active {
    opacity: 1;
    pointer-events: auto;
}
.mls-mascot.is-closed {
    display: none;
}

/* 吹き出し位置ごとのレイアウト */
.mls-mascot[data-mascot-bubble-pos="top"]    { flex-direction: column; }
.mls-mascot[data-mascot-bubble-pos="bottom"] { flex-direction: column-reverse; }
.mls-mascot[data-mascot-bubble-pos="left"]   { flex-direction: row; }
.mls-mascot[data-mascot-bubble-pos="right"]  { flex-direction: row-reverse; }

/* =========================
   画像
========================= */
.mls-mascot-img {
    display: block;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    /* width はインラインスタイルで指定 */
}

/* =========================
   クリックリンク
========================= */
.mls-mascot-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    line-height: 0; /* img 下の余白除去 */
}

/* =========================
   吹き出し
========================= */
.mls-mascot-bubble {
    position: relative;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 8px 28px 8px 12px;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 200px;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s;
}
.mls-mascot-bubble:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

/* AD ラベル */
.mls-mascot-ad {
    display: inline-block;
    background: #dd3333;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 4px;
    vertical-align: middle;
}

/* × 閉じるボタン */
.mls-mascot-close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    z-index: 2;
}
.mls-mascot-close:hover {
    background: #f0f0f0;
    color: #333;
}

/* =========================
   hover_mode 別アニメ
   - static: 静止
   - float:  上下 + 左右揺れ合成
   - mouse_follow / mouse_avoid は Phase 3b で JS 実装
========================= */
.mls-mascot.is-active[data-mascot-hover="float"] .mls-mascot-link {
    animation: mascot-float 4s ease-in-out infinite, mascot-sway 6s ease-in-out infinite;
    transform-origin: center center;
}

/* アニメ速度バリエーション */
.mls-mascot.is-active[data-mascot-hover="float"][data-mascot-speed="slow"] .mls-mascot-link {
    animation-duration: 6s, 9s;
}
.mls-mascot.is-active[data-mascot-hover="float"][data-mascot-speed="fast"] .mls-mascot-link {
    animation-duration: 2.5s, 4s;
}

@keyframes mascot-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-16px); }
}

@keyframes mascot-sway {
    0%, 100% { transform: translateX(0)    rotate(-3deg); }
    25%      { transform: translateX(-8px) rotate(3deg); }
    75%      { transform: translateX(8px)  rotate(-2deg); }
}

/* =========================
   entrance_style 別アニメ
   entrance の間は .is-entering クラス（JS で付与→duration 後に外す）
========================= */
.mls-mascot.is-entering[data-mascot-entrance="default"] {
    animation: mascot-entrance-default 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.mls-mascot.is-entering[data-mascot-entrance="dramatic_cross"] {
    animation: mascot-entrance-dramatic-cross 2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes mascot-entrance-default {
    0%   { opacity: 0; transform: translateX(60px); }
    100% { opacity: 1; transform: translateX(0); }
}

@keyframes mascot-entrance-dramatic-cross {
    0%   { opacity: 0; transform: translate(-90vw, -60vh) rotate(-540deg) scale(0.3); }
    40%  { opacity: 1; transform: translate(-40vw, -20vh) rotate(-180deg) scale(0.8); }
    70%  { transform: translate(20px, 30px) rotate(45deg) scale(1.15); }
    85%  { transform: translate(-10px, -8px) rotate(-15deg) scale(0.95); }
    100% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
}

/* =========================
   モバイル（Phase 3b 以降で拡充）
========================= */
@media (max-width: 867px) {
    /* mobile_mode=hide: モバイルでは非表示 */
    .mls-mascot[data-mascot-mobile="hide"] {
        display: none !important;
    }

    /* mobile_mode=fab: 画面右下に固定配置（Floating Action Button 風） */
    .mls-mascot[data-mascot-mobile="fab"] {
        position: fixed !important;
        right: 12px;
        bottom: 12px;
        z-index: 9000;
        margin: 0;
        /* 縦並び (吹き出し上 + 画像下) で右下に */
        align-items: flex-end;
    }
    /* fab 時の画像幅: モバイル向けに小さく */
    .mls-mascot[data-mascot-mobile="fab"] .mls-mascot-img {
        width: 80px !important;
    }
    /* fab 時の吹き出し: 右下基準で出やすく + 横幅制限 */
    .mls-mascot[data-mascot-mobile="fab"] .mls-mascot-bubble {
        max-width: 200px;
        font-size: 12px;
    }

    /* mobile_mode=continue（既定）はデスクトップ動作を継承 */
}
