/* =========================================================================
   スマホ用ボトムナビゲーションバー（parts/bottom_nav.php）
   画面下部に常時固定。778px 以下でのみ表示する。

   ホーム／探す／いいね／マイページ の4項目。
   マイページのアイコンにはマスコット（コアラ）を使う。
   アイコン枠の高さを揃えることで、画像とアイコンフォントが混在しても
   ラベルの位置がずれないようにしている。
   ========================================================================= */

.joie-bnav {
    display: none;
}

@media screen and (max-width: 778px) {

    .joie-bnav {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9998;
        background: #fff;
        border-top: 1px solid #ded7cc;
        box-shadow: 0 -2px 12px rgba(76, 72, 67, .14);
        /* iPhone のホームバー分の余白を確保 */
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .joie-bnav-list {
        display: flex;
        align-items: stretch;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .joie-bnav-item {
        flex: 1 1 0;
        min-width: 0;
        list-style: none;
    }

    .joie-bnav-item > a {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        height: 60px;
        color: #4c4843;
        text-decoration: none;
        font-size: 11px;
        font-weight: bold;
        line-height: 1.2;
        letter-spacing: 0.01em;
        -webkit-tap-highlight-color: transparent;
        transition: background-color .15s ease, color .15s ease;
    }

    /* アイコン枠：フォントアイコンも画像も同じ高さにしてラベル位置を揃える */
    .joie-bnav-item > a i,
    .joie-bnav-icon-wrap,
    .joie-bnav-mascot-img,
    .joie-bnav-item > a img.avatar {
        height: 26px;
        line-height: 26px;
    }

    /* マイページ：ログイン中は自分のプロフィール画像を丸く表示する
       ※テーマの get_avatar フィルタが class を上書きするため img.avatar でも拾う */
    .joie-bnav-item > a img.avatar,
    .joie-bnav-item > a .joie-bnav-avatar {
        width: 26px;
        border-radius: 50%;
        object-fit: cover;
        border: 1px solid #ded7cc;
        box-sizing: border-box;
    }

    .joie-bnav-item.is-current > a img.avatar {
        border-color: #f0b244;
    }

    .joie-bnav-item > a i {
        font-size: 23px;
        color: #6f675d;
    }

    .joie-bnav-item > a span {
        white-space: nowrap;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* 現在地 */
    .joie-bnav-item.is-current > a {
        color: #b8860b;
        background: #fdf7ec;
    }

    .joie-bnav-item.is-current > a i {
        color: #d99a1f;
    }

    /* 現在地の目印（バー上端のライン） */
    .joie-bnav-item.is-current > a::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 30px;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: #f0b244;
    }

    .joie-bnav-item > a:active {
        background: #f5efe4;
    }

    /* ハートは常に色を付けて役割を分かりやすく */
    .joie-bnav-item > a i.joie-bnav-heart {
        color: #e0607a;
    }

    .joie-bnav-icon-wrap {
        position: relative;
        display: inline-block;
    }

    /* いいね件数バッジ */
    .joie-bnav-badge {
        position: absolute;
        top: -6px;
        left: 14px;
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        border-radius: 999px;
        background: #e0324b;
        color: #fff;
        font-size: 10px;
        font-weight: bold;
        line-height: 17px;
        text-align: center;
        box-sizing: border-box;
    }

    /* --- マスコット（コアラ）＝マイページのアイコン ---
       縦長画像なので高さ基準。フォントアイコンと視覚的な大きさを揃える。 */
    .joie-bnav-mascot-img {
        display: block;
        width: auto;
    }

    /* ボトムナビの高さぶん、ページ末尾に余白を足して重なりを防ぐ */
    body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    /* 既存の PAGETOP ボタン（コアラ）はボトムナビのマスコットと重複するため隠す */
    #site_footer .totop {
        display: none !important;
    }
}

/* 画面が狭い端末では文字と余白を少し詰める */
@media screen and (max-width: 360px) {
    .joie-bnav-item > a {
        font-size: 10px;
        gap: 3px;
    }
    .joie-bnav-item > a i {
        font-size: 21px;
    }
    .joie-bnav-item > a i,
    .joie-bnav-icon-wrap,
    .joie-bnav-mascot-img,
    .joie-bnav-item > a img.avatar {
        height: 24px;
        line-height: 24px;
    }
    .joie-bnav-item > a img.avatar {
        width: 24px;
    }
}

/* 横向きなど画面が低いときはバーを薄くする */
@media screen and (max-width: 778px) and (max-height: 480px) {
    .joie-bnav-item > a {
        height: 48px;
        font-size: 10px;
    }
    .joie-bnav-item > a i {
        font-size: 19px;
    }
    .joie-bnav-item > a i,
    .joie-bnav-icon-wrap,
    .joie-bnav-mascot-img,
    .joie-bnav-item > a img.avatar {
        height: 22px;
        line-height: 22px;
    }
    .joie-bnav-item > a img.avatar {
        width: 22px;
    }
    body {
        padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
    }
}
