/* ==========================================================================
   Medal Badge - Frontend v2.0
   ========================================================================== */

/* ── 共通 ── */
.medal {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
}

.medal--left {
    top: -10px;
    left: -10px;
}

.medal--right {
    top: -10px;
    right: -10px;
}

.medal__body {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* ── メダル本体（金・銀共通） ── */
.medal__circle {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: medal-float 3s ease-in-out infinite;
}

/* 外枠リング */
.medal__circle::before {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    padding: 4px;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
}

/* 光沢オーバーレイ */
.medal__circle::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, .5) 0%,
            rgba(255, 255, 255, .1) 30%,
            transparent 50%,
            rgba(255, 255, 255, .05) 80%,
            rgba(255, 255, 255, .2) 100%);
    pointer-events: none;
}

.medal__icon {
    font-size: 32px;
    line-height: 1;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .3));
}

/* ── ラベル（金・銀・殿堂入り共通） ── */
.medal__label {
    display: block;
    margin-top: 3px;
    padding: 2px 12px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .06em;
    white-space: nowrap;
    text-align: center;
    line-height: 1.5;
    color: #fff;
    position: relative;
}

/* ==========================================================================
   金メダル
   ========================================================================== */
.medal--gold .medal__circle {
    background: conic-gradient(from 0deg,
            #fde68a, #f59e0b, #d97706, #92400e,
            #d97706, #fbbf24, #fde68a, #f59e0b,
            #d97706, #fde68a);
    border: 3px solid #92400e;
    box-shadow:
        0 0 0 2px rgba(251, 191, 36, .4),
        0 4px 15px rgba(217, 119, 6, .5),
        inset 0 2px 4px rgba(255, 255, 255, .3),
        inset 0 -2px 4px rgba(146, 64, 14, .3);
    animation: medal-float 3s ease-in-out infinite, medal-shine-gold 4s ease-in-out infinite;
}

.medal--gold .medal__circle::before {
    background: linear-gradient(135deg, #fde68a, #d97706, #fbbf24, #92400e);
}

.medal--gold .medal__label {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 2px 8px rgba(217, 119, 6, .4);
}

/* ==========================================================================
   銀メダル
   ========================================================================== */
.medal--silver .medal__circle {
    background: conic-gradient(from 0deg,
            #f1f5f9, #94a3b8, #64748b, #334155,
            #64748b, #cbd5e1, #f1f5f9, #94a3b8,
            #64748b, #f1f5f9);
    border: 3px solid #334155;
    box-shadow:
        0 0 0 2px rgba(148, 163, 184, .4),
        0 4px 15px rgba(100, 116, 139, .5),
        inset 0 2px 4px rgba(255, 255, 255, .4),
        inset 0 -2px 4px rgba(51, 65, 85, .3);
    animation: medal-float 3s ease-in-out infinite, medal-shine-silver 4s ease-in-out infinite;
}

.medal--silver .medal__circle::before {
    background: linear-gradient(135deg, #e2e8f0, #64748b, #cbd5e1, #475569);
}

.medal--silver .medal__label {
    background: linear-gradient(135deg, #94a3b8, #64748b);
    box-shadow: 0 2px 8px rgba(100, 116, 139, .4);
}

/* ==========================================================================
   リボン（旧：銅）
   ========================================================================== */
.medal--ribbon {
    pointer-events: none;
    overflow: hidden;
}

.medal--ribbon.medal--left {
    top: -8px;
    left: -8px;
    width: 120px;
    height: 120px;
}

.medal--ribbon.medal--right {
    top: -8px;
    right: -8px;
    width: 120px;
    height: 120px;
}

.medal--ribbon .medal__body {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.medal--ribbon .medal__ribbon-band {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 170px;
    padding: 7px 0;
    background: linear-gradient(180deg,
            #f87171 0%,
            #ef4444 15%,
            #dc2626 50%,
            #b91c1c 85%,
            #991b1b 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
    box-shadow:
        0 2px 8px rgba(185, 28, 28, .5),
        inset 0 1px 0 rgba(255, 255, 255, .25),
        inset 0 -1px 0 rgba(0, 0, 0, .2);
    z-index: 1;
}

/* 左上リボン */
.medal--ribbon.medal--left .medal__ribbon-band {
    top: 20px;
    left: -38px;
    transform: rotate(-45deg);
    transform-origin: center;
}

/* 右上リボン */
.medal--ribbon.medal--right .medal__ribbon-band {
    top: 20px;
    right: -38px;
    transform: rotate(45deg);
    transform-origin: center;
}

/* ── 折り返し（リボンが画像の裏に回り込む表現） ── */
.medal--ribbon .medal__ribbon-fold-1,
.medal--ribbon .medal__ribbon-fold-2 {
    position: absolute;
    width: 0;
    height: 0;
    z-index: 0;
}

/* 左上：左辺の折り返し */
.medal--ribbon.medal--left .medal__ribbon-fold-1 {
    bottom: 0;
    left: 0;
    border-style: solid;
    border-width: 0 10px 10px 0;
    border-color: transparent #7f1d1d transparent transparent;
}

/* 左上：下辺の折り返し */
.medal--ribbon.medal--left .medal__ribbon-fold-2 {
    bottom: 0;
    right: 0;
    border-style: solid;
    border-width: 10px 10px 0 0;
    border-color: #7f1d1d transparent transparent transparent;
}

/* 右上：右辺の折り返し */
.medal--ribbon.medal--right .medal__ribbon-fold-1 {
    bottom: 0;
    right: 0;
    border-style: solid;
    border-width: 0 0 10px 10px;
    border-color: transparent transparent transparent #7f1d1d;
}

/* 右上：下辺の折り返し */
.medal--ribbon.medal--right .medal__ribbon-fold-2 {
    bottom: 0;
    left: 0;
    border-style: solid;
    border-width: 10px 0 0 10px;
    border-color: #7f1d1d transparent transparent transparent;
}

/* ==========================================================================
   殿堂入り
   ========================================================================== */
.medal--halloffame .medal__circle {
    width: 70px;
    height: 70px;
    background: conic-gradient(from 0deg,
            #e9d5ff, #a855f7, #7c3aed, #4c1d95,
            #7c3aed, #c084fc, #e9d5ff, #a855f7,
            #7c3aed, #e9d5ff);
    border: 3px solid #4c1d95;
    box-shadow:
        0 0 0 3px rgba(168, 85, 247, .3),
        0 0 20px rgba(124, 58, 237, .4),
        0 0 40px rgba(168, 85, 247, .2),
        0 4px 16px rgba(124, 58, 237, .5),
        inset 0 2px 4px rgba(255, 255, 255, .3),
        inset 0 -2px 4px rgba(76, 29, 149, .3);
    animation: medal-float 3s ease-in-out infinite, halloffame-glow 3s ease-in-out infinite;
}

.medal--halloffame .medal__circle::before {
    background: linear-gradient(135deg, #e9d5ff, #7c3aed, #c084fc, #4c1d95);
}

.medal--halloffame .medal__icon {
    font-size: 36px;
}

.medal--halloffame .medal__label {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    box-shadow: 0 0 12px rgba(168, 85, 247, .5), 0 2px 8px rgba(124, 58, 237, .4);
}

/* リボン飾り（殿堂入り用） */
.medal__ribbon-top {
    position: relative;
    width: 50px;
    height: 16px;
    margin-bottom: -6px;
    z-index: 0;
}

.medal__ribbon-top::before,
.medal__ribbon-top::after {
    content: "";
    position: absolute;
    top: 0;
    width: 30px;
    height: 16px;
}

.medal__ribbon-top::before {
    left: 0;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    border-radius: 4px 0 0 0;
    transform: skewY(-8deg);
    transform-origin: top left;
}

.medal__ribbon-top::after {
    right: 0;
    background: linear-gradient(135deg, #9333ea, #7c3aed);
    border-radius: 0 4px 0 0;
    transform: skewY(8deg);
    transform-origin: top right;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes medal-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

@keyframes medal-shine-gold {

    0%,
    100% {
        filter: brightness(1) saturate(1);
    }

    50% {
        filter: brightness(1.15) saturate(1.1);
    }
}

@keyframes medal-shine-silver {

    0%,
    100% {
        filter: brightness(1) saturate(1);
    }

    50% {
        filter: brightness(1.2) saturate(1.05);
    }
}

@keyframes halloffame-glow {

    0%,
    100% {
        box-shadow:
            0 0 0 3px rgba(168, 85, 247, .3),
            0 0 20px rgba(124, 58, 237, .4),
            0 0 40px rgba(168, 85, 247, .2),
            0 4px 16px rgba(124, 58, 237, .5),
            inset 0 2px 4px rgba(255, 255, 255, .3),
            inset 0 -2px 4px rgba(76, 29, 149, .3);
    }

    50% {
        box-shadow:
            0 0 0 4px rgba(168, 85, 247, .5),
            0 0 30px rgba(124, 58, 237, .6),
            0 0 60px rgba(168, 85, 247, .3),
            0 6px 20px rgba(124, 58, 237, .6),
            inset 0 2px 4px rgba(255, 255, 255, .4),
            inset 0 -2px 4px rgba(76, 29, 149, .3);
    }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media(max-width:600px) {
    .medal--left {
        top: -6px;
        left: -6px;
    }

    .medal--right {
        top: -6px;
        right: -6px;
    }

    .medal__circle {
        width: 50px;
        height: 50px;
    }

    .medal__icon {
        font-size: 24px;
    }

    .medal__label {
        font-size: 8px;
        padding: 1px 7px;
    }

    .medal--halloffame .medal__circle {
        width: 54px;
        height: 54px;
    }

    .medal--halloffame .medal__icon {
        font-size: 28px;
    }

    .medal__ribbon-top {
        width: 38px;
        height: 13px;
    }

    .medal__ribbon-top::before,
    .medal__ribbon-top::after {
        width: 22px;
        height: 13px;
    }

    /* リボン（モバイル） */
    .medal--ribbon.medal--left,
    .medal--ribbon.medal--right {
        width: 90px;
        height: 90px;
    }

    .medal--ribbon .medal__ribbon-band {
        width: 130px;
        padding: 4px 0;
        font-size: 9px;
    }

    .medal--ribbon.medal--left .medal__ribbon-band {
        top: 15px;
        left: -32px;
    }

    .medal--ribbon.medal--right .medal__ribbon-band {
        top: 15px;
        right: -32px;
    }
}