/* ==============================
   スコープベースリセット
   他ページの base CSS との干渉を避けるため
   .rank-trigger / .rank-panel 配下のみに限定する
   ============================== */
.rank-trigger,
.rank-trigger *,
.rank-trigger *::before,
.rank-trigger *::after,
.rank-panel,
.rank-panel *,
.rank-panel *::before,
.rank-panel *::after,
.rank-overlay {
    box-sizing: border-box;
}

.rank-panel a,
.rank-trigger a {
    text-decoration: none;
    color: inherit;
}

/* ==============================
   .header-middle-nav への組み込み
   ============================== */
.header-nav-li-rank {
    list-style: none;
    display: flex;
    align-items: center;
    width: 50px;
    height: 50px;
}

/* site.css で a::before に装飾が付いている場合に非表示 */
.header-middle-nav li.header-nav-li-rank a::before {
    display: none;
}

/* ==============================
   ランクトリガー (ホバー対象アイコン)
   isolation で z-index スタッキングコンテキストを独立させる
   ============================== */
.rank-trigger {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    isolation: isolate;
}

.rank-trigger__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.rank-trigger:focus .rank-trigger__icon {
    transform: scale(1.05);
}

/* ==============================
   ランクステータスパネル
   ============================== */
.rank-panel {
    line-height: 1.5;
    position: absolute;
    top: calc(100% + 12px);
    right: -10px;
    width: 360px;
    background: #fff;
    color: #333;
    border-radius: 5px;
    box-shadow: 0 0 3px rgba(51, 51, 51, 0.3);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.25s, visibility 0.25s, transform 0.25s;
    z-index: 200;
}

/* ホバー / フォーカスで表示 */
.rank-trigger:hover .rank-panel,
.rank-trigger:focus-within .rank-panel,
.rank-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* トリガーとパネルの隙間を埋める透明ブリッジ
   (マウス移動中に mouseleave が発火しないように) */
.rank-panel::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
}

/* ==============================
   パネル ヘッダー
   ============================== */
.rank-panel__header {
    background: linear-gradient(135deg, #51bbe7 0%, #1a6cd1 100%);
    padding: 20px 18px;
    color: #fff;
}

.rank-panel__user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rank-panel__avatar {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rank-panel__avatar img {
    width: 50px;
    height: 50px;
    filter: drop-shadow(0 3px 8px rgba(22, 80, 152, 0.3));
}

.rank-panel__user-info {
    flex: 1;
    min-width: 0;
}

.rank-panel__user-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-panel__user-rank {
    font-size: 13px;
    margin-top: 3px;
    opacity: 0.95;
}

/* ==============================
   パネル ボディ
   ============================== */
.rank-panel__body {
    padding: 18px 16px;
    background: linear-gradient(135deg, rgba(81, 187, 231, 0.1) 0%, rgba(26, 108, 209, 0.1) 100%);
}

.rank-panel__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.rank-panel__section-title {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #2e87d8;
}

.rank-panel__section-note {
    font-size: 10px;
    color: #999;
}

/* ==============================
   ドーナツグラフ 2カード
   ============================== */
.rank-panel__charts {
    display: flex;
    gap: 20px;
}

.chart-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.chart-card__graph {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

/* 12時位置から描画開始するため -90deg 回転 */
.donut {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.donut__bg {
    fill: none;
    stroke: #e8eef3;
    stroke-width: 17;
}

/* ストロークの色は HTML 側で stroke="url(#...)" 指定 */
.donut__fg {
    fill: none;
    stroke-width: 17;
    stroke-linecap: butt;
    stroke-dasharray: 323.58;
    stroke-dashoffset: 323.58;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* 親の -90deg を打ち消す逆回転 */
.donut__icon,
.donut__yen {
    transform: rotate(90deg);
    transform-origin: 60px 60px;
}

.chart-card__badge {
    display: inline-block;
    background: #2e87d8;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 2em;
    white-space: nowrap;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.chart-card__info {
    flex: 1;
    min-width: 0;
}

.chart-card__label {
    font-size: 10px;
    color: #777;
    line-height: 1.2;
}

.chart-card__value {
    font-size: 18px;
    font-weight: 700;
    color: #2e87d8;
    line-height: 1.2;
    overflow-wrap: break-word;
    letter-spacing: 0.03em;
}

.chart-card__progress {
    font-size: 10px;
    color: #999;
    margin-top: 1px;
}

/* ==============================
   ボーナスチャレンジボタン
   ============================== */
.rank-panel__bonus {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    padding: 10px 30px;
    background: #fff;
    border: 1px solid #e1ebf2;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    color: #2e87d8;
    transition: background 0.2s, box-shadow 0.2s;
}

.rank-panel__bonus:hover {
    background: #f4f8fb;
    box-shadow: 0 2px 6px rgba(75, 163, 227, 0.15);
}

.rank-panel__bonus::after,
.rank-panel__point::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-top: 2px solid currentColor;
    transform: translateY(-50%) rotate(45deg);
}

.rank-panel__bonus::after {
    right: 14px;
}

.rank-panel__point::after {
    right: 30px;
}

/* ==============================
   利用可能ポイント
   ============================== */
.rank-panel__point {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin: 15px -16px -18px;
    padding: 12px 46px 16px 16px;
    border-top: 1px solid #eef2f5;
    color: inherit;
    background: #fff;
}

.rank-panel__point-label {
    font-size: 13px;
    color: #333;
    flex: 1;
}

.rank-panel__point-value {
    font-size: 20px;
    font-weight: 700;
    color: #ff8a3d;
    letter-spacing: 0.03em;
}

.rank-panel__point-unit {
    font-size: 10px;
    margin-left: 2px;
    font-weight: 600;
}

/* ==============================
   モバイル用オーバーレイ
   ============================== */
.rank-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.rank-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* ==============================
   モバイル: スライドインパネル
   ============================== */
@media (max-width: 768px) {
    /* デスクトップのホバー表示を無効化 */
    .rank-trigger:hover .rank-panel,
    .rank-trigger:focus-within .rank-panel {
        opacity: 0;
        visibility: hidden;
        transform: translateX(-100%);
    }

    .rank-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: auto;
        width: calc(100vw - 32px);
        height: 100dvh;
        border-radius: 0;
        overflow: hidden;
        overflow-y: auto;
        opacity: 1;
        visibility: visible;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .rank-panel.is-open {
        transform: translateX(0);
    }
}

/* ==============================
   site.css の
   .header-middle-nav li[class*="header-nav-li"] a (詳細度 0,2,2)
   による干渉対策 — 詳細度 (0,3,1) 以上で上書き
   ============================== */
.header-middle-nav .header-nav-li-rank .rank-panel a,
.header-middle-nav .header-nav-li-rank .rank-trigger a {
    color: inherit;
    text-decoration: none;
}

.header-middle-nav .header-nav-li-rank .rank-panel__bonus {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    padding: 10px 30px;
    background: #fff;
    border: 1px solid #e1ebf2;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    color: #2e87d8;
    transition: background 0.2s, box-shadow 0.2s;
}

.header-middle-nav .header-nav-li-rank .rank-panel__bonus:hover {
    background: #f4f8fb;
    box-shadow: 0 2px 6px rgba(75, 163, 227, 0.15);
}

.header-middle-nav .header-nav-li-rank .rank-panel__point {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin: 15px -16px -18px;
    padding: 12px 46px 16px 16px;
    border-top: 1px solid #eef2f5;
    color: inherit;
    background: #fff;
}

@media (max-width: 576px) {
    .header-nav-li-rank,
    .header-nav-li-rank img {
        width: 46px;
        height: 46px;
    }
    .header-nav-li-mypage {
        display: none;
    }
}