/*
  Mobile (max-width: 760px)
  ========================
  目的:
  - スマホでは画面下に固定3ボタン（Music / Teacher / Diary）を表示
  - テキスト表示 + アイコン拡大
  - 3秒操作がなければ透明度を上げる（is-idle）
  - 下固定バーのぶん、本文が隠れないように余白を確保
*/

@media (max-width: 760px) {

    html,
    body {
        overflow-x: clip;
    }

    .site-sidebar {
        display: none;
    }

    /* =========================
     Tokens / knobs
     ========================= */
    :root {
        /* main 下余白（Bottom dock に被らないためのセーフティ） */
        --mobile-main-safe-bottom: 120px;
        --mobile-edge: 12px;
        --mobile-dock-max: 100px;
        --mobile-dock-width-offset: 46px;
        --mobile-badge-offset: -6px;

        /* ロゴ倍率（scale） */
        --brand-logo-scale: 2;

        /* Dock sizing */
        --mbn-wrap: 62px;
        /* 当たり判定（Hit area）を含む円の直径 */
        --mbn-icon: 90px;
        /* 画像アイコンサイズ */
        --mbn-gap: 10px;
        /* 3アイコン間隔 */
        --mbn-pad-y: 10px;
        /* ドック上下padding（縦幅） */
        --mbn-pad-x: 5px;
        /* ドック左右padding */
    }

    /* =========================
     Global spacing
     ========================= */
    main {
        /* アイコンが上に出るぶん、少し多めに確保（必要なら後で調整） */
        padding-bottom: calc(130px + env(safe-area-inset-bottom)) !important;
    }

    /* bottom nav 本体（dock pop style） */
    .mobile-bottom-nav {
        /*
          サイズ調整ポイント（Dock Tuning）
          - --mbn-wrap:  当たり判定（Hit area）も兼ねるアイコン枠の直径
          - --mbn-icon:  画像アイコンのサイズ
          - --mbn-gap:   3アイコンの間隔
          - --mbn-pad-y: バーの上下padding
          - --mbn-pad-x: バーの左右padding
          - --mbn-raise: アイコンがバーから上に出る量（Pop）
          - --mbn-bar-h: 背景バー（Plate）の見た目高さ
        */
        --mbn-wrap: min(var(--mobile-dock-max), calc((100vw - var(--mobile-dock-width-offset)) / 3));
        --mbn-icon: calc(var(--mbn-wrap) - 6px);
        --mbn-gap: 1px;
        --mbn-pad-y: 6px;
        --mbn-pad-x: 10px;

        --mbn-raise: 0px;
        /* ← “上に出る感じ” はまずここ */
        --mbn-bar-h: 44px;
        /* ← バーの厚み（Plate） */

        position: fixed;
        left: var(--mobile-edge);
        right: var(--mobile-edge);
        bottom: calc(10px + env(safe-area-inset-bottom));
        z-index: 800;

        display: flex;
        align-items: flex-end;
        justify-content: center;
        gap: var(--mbn-gap);

        padding: var(--mbn-pad-y) var(--mbn-pad-x);
        border-radius: 999px;

        /* バー背景は疑似要素で描くので、親は透明 */
        background: transparent;
        border: 0;
        box-shadow: none;

        overflow: visible;
        transition: opacity 220ms ease;
    }

    @supports (width: 100dvw) {
        .mobile-bottom-nav {
            --mbn-wrap: min(var(--mobile-dock-max), calc((100dvw - var(--mobile-dock-width-offset)) / 3));
        }
    }

    /* 背景バー（Plate） */
    .mobile-bottom-nav::before {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;

        height: var(--mbn-bar-h);
        border-radius: 999px;

        background: rgba(11, 16, 32, 0.42);
        border: 1px solid rgba(255, 255, 255, 0.12);
        backdrop-filter: blur(14px);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);

        pointer-events: none;
    }

    /* 3秒無操作で薄くする */
    .mobile-bottom-nav.is-idle {
        opacity: 0.35;
    }

    .mbn-item {
        position: relative;
        flex: 0 0 auto;

        display: inline-flex;
        align-items: flex-end;
        justify-content: center;

        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        outline: none;

        /* “バーは薄いが、タップはしやすい” を両立 */
        width: var(--mbn-wrap);
        height: calc(var(--mbn-bar-h) + var(--mbn-raise));
    }

    /* アイコン枠（見た目は透明・当たり判定は維持） */
    .mbn-icon-wrap {
        position: absolute;
        left: 50%;
        bottom: calc(var(--mbn-pad-y) + 2px);

        width: var(--mbn-wrap);
        height: var(--mbn-wrap);
        border-radius: 999px;

        display: grid;
        place-items: center;

        background: transparent;
        border: 0;
        box-shadow: none;

        /* ここが “ドックから上に出る” 本体（Pop） */
        transform: translateX(-50%) translateY(calc(-1 * var(--mbn-raise)));
        transition: transform 120ms ease;
        overflow: visible;
    }

    /* 押したとき（Scale は translate と合成する） */
    .mbn-item:active .mbn-icon-wrap {
        transform: translateX(-50%) translateY(calc(-1 * var(--mbn-raise))) scale(0.98);
    }

    /* アイコン画像（サイズ変更が必ず反映されるよう、クランプ解除） */
    .mbn-icon {
        width: var(--mbn-icon);
        height: var(--mbn-icon);
        max-width: none;
        max-height: none;

        object-fit: contain;
        display: block;
        filter: none;
        transform: none;
    }

    /* アクティブ表示：円は出さず、アイコンだけ軽く発光 */
    .mbn-item.is-active .mbn-icon {
        filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.22)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.18));
    }

    /* テキストをアイコンにかぶせる（アイコンの上げ量に追従） */
    .mbn-label {
        position: absolute;
        left: 50%;
        bottom: calc(8px + var(--mbn-raise));
        transform: translateX(-50%);

        font-family: ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans JP",
            "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
        font-weight: 900;
        font-size: 11px;
        line-height: 1;

        color: rgba(255, 255, 255, 0.94);
        letter-spacing: 0.02em;

        padding: 2px 8px;
        border-radius: 999px;
        background: rgba(11, 16, 32, 0.50);
        backdrop-filter: blur(8px);

        text-shadow:
            0 2px 10px rgba(0, 0, 0, 0.65),
            -1px 0 rgba(0, 0, 0, 0.55),
            1px 0 rgba(0, 0, 0, 0.55),
            0 -1px rgba(0, 0, 0, 0.55),
            0 1px rgba(0, 0, 0, 0.55);

        pointer-events: none;
        white-space: nowrap;
    }

    /* =========================
       Badges (Online dot / Unread count)
       ========================= */
    .mbn-badge {
        position: absolute;
        z-index: 2;
        box-sizing: border-box;
        user-select: none;
        pointer-events: none;
    }

    /* teacher/music: green online dot */
    .mbn-badge--online {
        right: 10px;
        bottom: 10px;

        width: 16px;
        height: 16px;
        border-radius: 999px;

        background: #22c55e;
        border: 2px solid var(--surface);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    }

    .mbn-item:not(.is-online) .mbn-badge--online {
        display: none;
    }

    /* diary: red unread count (x|y) */
    .mbn-badge--count {
        top: var(--mobile-badge-offset);
        right: var(--mobile-badge-offset);

        min-width: 38px;
        height: 20px;
        padding: 0 8px;
        border-radius: 999px;

        display: inline-flex;
        align-items: center;
        justify-content: center;

        font-size: 11px;
        line-height: 1;
        font-weight: 900;

        color: #fff;
        background: #ef4444;
        border: 2px solid var(--surface);
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
        white-space: nowrap;
    }

    .mbn-badge--count[hidden] {
        display: none;
    }
}
