/* Progression (app/pages/collection.js progressFab) : bouton flottant en bas à droite, au-dessus
   de la barre du bas (--bar-height posée en JS), même place que le tri des cartes. Son anneau se
   remplit avec les badges trouvés (--p, ratio posé en JS) ; un toucher ouvre la modal Progression. */
.progress-fab {
    position: fixed;
    right: 1rem;
    bottom: calc(var(--bar-height, 0px) + 1.25rem + env(safe-area-inset-bottom, 0px));
    z-index: 90;
    width: auto;
}

/* Emplacement du bouton dans l'onglet Badges : hors du flux, pas d'espace vide */
.progress-slot {
    display: contents;
}

.progress-button {
    position: relative;
    display: block;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease;
}

.progress-button:active {
    transform: scale(0.94);
}

/* --p déclarée comme nombre : l'anneau (conic-gradient) peut l'animer ; héritée, comme une variable
   classique, pour le remplissage des barres posé sur leur enfant */
@property --p {
    syntax: "<number>";
    inherits: true;
    initial-value: 0;
}

.progress-ring {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: conic-gradient(var(--ColorPrimary) calc(var(--p, 0) * 1turn), var(--ColorRow) 0);
    box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.45);
}

/* Remplissage animé depuis la valeur précédente (--from, posée en JS) */
.progress-ring.filling {
    animation: progress-ring-fill 1s cubic-bezier(0.3, 0.7, 0.3, 1) 0.2s both;
}

@keyframes progress-ring-fill {
    from { --p: var(--from, 0); }
}

.progress-ring-inner {
    display: grid;
    place-items: center;
    width: calc(100% - 0.5rem);
    height: calc(100% - 0.5rem);
    border-radius: 50%;
    background-color: var(--ColorContainer);
    color: var(--ColorPrimary);
    font-size: 1.25rem;
}

.progress-count {
    position: absolute;
    left: 50%;
    bottom: -0.45rem;
    width: auto;
    padding: 0 0.4rem;
    border-radius: 99px;
    background-color: var(--ColorPrimary);
    color: var(--ColorPrimaryText);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transform: translateX(-50%);
}

/* Boosters à réclamer : pastille qui pulse */
.progress-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    background-color: #FFC500;
    box-shadow: 0 0 0 2px var(--ColorContainer);
    animation: progress-dot-pulse 1.4s ease-in-out infinite;
}

/* Palier tout juste atteint : l'icône change de couleur et se balance */
.progress-fab.new .progress-ring-inner i {
    animation: rewardCompletedIcon 1s ease-in-out 4, rewardCompletedColor 1s ease-in-out 4;
}

/* Modal Progression (components/modal.js, #modal-progress) : barre globale et compte, puis les récompenses */
#modal-progress .modal-content .content {
    align-items: stretch;
    justify-content: flex-start;
    gap: 1.25rem;
}

.progress-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.progress-summary .badges {
    flex-shrink: 0;
}

.progress-summary .progress-total {
    flex: 1;
}

.progress-total {
    display: block;
    width: 100%;
    height: 0.55rem;
    border-radius: 99px;
    background-color: var(--ColorRow);
    overflow: hidden;
}

.progress-total span {
    display: block;
    width: calc(var(--p, 0) * 100%);
    height: 100%;
    border-radius: inherit;
    background-color: var(--ColorPrimary);
}

/* Récompenses en cartes de quête */
.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Espacement par le gap de la liste, pas par la marge des li (css/main.css : ul li:not(:last-child)) */
.progress-steps > .progress-quest {
    margin: 0;
}

.progress-quest {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 1rem 1rem 1.1rem;
    overflow: hidden;
    border-radius: var(--BorderRadius);
    background-color: var(--ColorRow);
    box-shadow: var(--Shadow);
}

/* Boosters à réclamer : liseré rose autour de la carte */
.progress-quest.to-claim {
    box-shadow: var(--Shadow), inset 0 0 0 2px var(--ColorPrimary);
}

.progress-quest-main {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.progress-quest-title {
    margin: 0;
    font-family: var(--FontFocus);
    font-size: 1.05rem;
    line-height: 1.25;
}

.progress-text {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.6;
}

/* Barre découpée en un segment par badge (--segments), badges trouvés au bout du remplissage (--p) */
.progress-quest-meter {
    position: relative;
    padding-bottom: 1.2rem;
    margin-top: 0.25rem;
}

.progress-quest-bar {
    position: relative;
    display: block;
    width: 100%;
    height: 0.7rem;
    overflow: hidden;
    border-radius: 99px;
    background-color: var(--ColorContainer);
}

.progress-quest-bar > span {
    display: block;
    width: calc(var(--p, 0) * 100%);
    height: 100%;
    background-color: var(--ColorPrimary);
}

.progress-quest-bar::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg,
        transparent 0 calc(100% / var(--segments, 1) - 2px),
        var(--ColorRow) calc(100% / var(--segments, 1) - 2px) calc(100% / var(--segments, 1)));
}

.progress-quest-label {
    position: absolute;
    left: clamp(0.5rem, calc(var(--p, 0) * 100%), calc(100% - 0.5rem));
    bottom: 0;
    width: auto;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    transform: translateX(-50%);
}

/* Terminé : calé à droite, sous la fin de la barre */
.progress-quest.done .progress-quest-label {
    left: auto;
    right: 0;
    transform: none;
}

.progress-quest-reward {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}

.progress-quest-image {
    display: grid;
    place-items: center;
    width: 3.75rem;
    height: 3.75rem;
    overflow: hidden;
    border-radius: 50%;
    background-color: var(--ColorContainer);
    box-shadow: inset 0 0 0 2px var(--ColorContainer);
    color: var(--ColorPrimary);
    font-size: 1.5rem;
}

.progress-quest.done .progress-quest-image {
    box-shadow: 0 0 0 3px var(--ColorPrimary);
}

.progress-quest-image img,
.progress-quest-image video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Récompense visible mais atténuée tant que le palier n'est pas atteint */
.progress-quest:not(.done) .progress-quest-image :is(img, video) {
    opacity: 0.35;
}

.progress-quest-qty {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    width: auto;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.progress-quest-qty i {
    color: var(--ColorPrimary);
}

.progress-claim {
    grid-column: 1 / -1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 99px;
    background-color: var(--ColorPrimary);
    color: var(--ColorPrimaryText);
    font: inherit;
    font-family: var(--FontFocus);
    font-weight: 700;
    cursor: pointer;
}

.progress-claim:disabled {
    opacity: 0.6;
}

/* Boosters déjà réclamés : place sous la récompense pour l'étiquette (≈ 1.45rem de haut), qui ne
   colle plus aux boosters */
.progress-quest.claimed {
    padding-bottom: 2.2rem;
}

/* Boosters déjà réclamés : étiquette dans le coin bas droit */
.progress-quest-tag {
    position: absolute;
    right: 0;
    bottom: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    width: auto;
    padding: 0.2rem 0.75rem 0.2rem 0.9rem;
    border-radius: var(--BorderRadius) 0 0 0;
    background-color: var(--ColorPrimary);
    color: var(--ColorPrimaryText);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

@keyframes progress-dot-pulse {
    50% { transform: scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
    .progress-ring.filling {
        animation: none;
    }

    .progress-dot,
    .progress-fab.new .progress-ring-inner i {
        animation: none;
    }
}

@keyframes rewardCompletedColor {
    0%, 100% {
        color: #FF7992;
    }
    25%, 75% {
        color: #FFA242;
    }
    50% {
        color: #FFC500;
    }
}

@keyframes rewardCompletedIcon {
    0% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.2) rotate(10deg);
    }
    50% {
        transform: scale(1) rotate(-10deg);
    }
    75% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}
