/* Profil d'un joueur (app/features/profile.js, modal #modal-profile) */

#modal-profile .modal-content .content {
    justify-content: flex-start;
}

/* En-tête à gauche, bouton Réagir à droite (icône seule en petit format) */
#modal-profile .profile-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

#modal-profile .profile-top > .profile-hero {
    flex: 1;
    min-width: 0;
}

/* Trop étroit : avatar et bouton sur une ligne, nom et chips dessous */
@container modalContent (max-width: 479px) {
    #modal-profile .profile-top {
        flex-wrap: wrap;
    }

    #modal-profile .profile-top > .profile-hero {
        display: contents;
    }

    #modal-profile .profile-hero-info {
        order: 1;
        flex-basis: 100%;
    }
}

#modal-profile .profile {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
    box-sizing: border-box;
}

/* En-tête (modal profil et page Compte) : avatar cerclé à la couleur du rang */
.profile-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.profile-hero-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-width: 0;
}

/* Nom et titre serrés, le rang un peu détaché */
.profile-hero-info > p,
.profile-identity > p {
    line-height: 1.2;
}

.profile-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

/* Chips réduites (.badges.small) : rang et résumé des réactions, centrés sur la ligne ; la chip
   fantôme du chargement à leur taille (pas de saut à l'arrivée des réactions) */
.profile-chips {
    align-items: center;
}

.profile-chips > .skeleton.chip {
    height: 1.7rem;
    border-radius: 0.5rem;
}

.profile-avatar {
    /* Hauteur explicite : Safari iOS déforme le cercle avec aspect-ratio dans un flex */
    width: 6rem;
    height: 6rem;
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 4px;
    border-radius: 100%;
    background: var(--ColorPrimary);
    animation: profile-pop 0.4s ease-out both;
}

.profile-avatar.gold { background: linear-gradient(135deg, #e3c077, #b3843f); }
.profile-avatar.silver { background: linear-gradient(135deg, #bdc0c5, #8a8f92); }
.profile-avatar.bronze { background: linear-gradient(135deg, #e3ab82, #b36b4b); }
.profile-avatar.grey { background: var(--ColorContainer); }

.profile-avatar > img,
.profile-avatar > video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 100%;
    border: 3px solid var(--ColorBackground);
    box-sizing: border-box;
    background: var(--ColorBackground);
}

/* Nom du joueur (profil, Compte) : police des titres, 28 px */
.profile-name {
    font-family: var(--FontFocus);
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    line-height: 1.1;
}

.profile-name .badges {
    font-family: var(--FontPrincipale);
    font-size: var(--FontSize-s) !important;
    padding: 4px 8px;
}

/* Collection par édition (modal profil, éditions précédentes de la page Collection) */
.profile-edition {
    border-radius: var(--BorderRadius);
    background-color: var(--ColorRow);
    padding: 0.75rem;
}

.profile-edition summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
}

.profile-edition summary::-webkit-details-marker {
    display: none;
}

.profile-edition summary::before {
    content: '\f054';
    font-family: 'Font Awesome 6 Pro', 'Font Awesome 6 Free', 'Font Awesome 5 Pro', 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 0.75em;
    color: var(--ColorTextAlt);
    transition: var(--Transition);
}

.profile-edition[open] summary::before {
    transform: rotate(90deg);
}

.profile-edition-name {
    flex: 1;
    min-width: 0;
}

.profile-badges {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(3.5rem, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.profile-badges > img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
}

/* Stats d'un joueur (app/features/showcase.js statsGrid) : modal profil et page Compte.
   Valeur dans la police du texte (pas celle des titres), couleurs de texte uniquement */
.player-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.player-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.75rem;
    border-radius: var(--BorderRadius);
    background-color: var(--ColorRow);
}

.player-stat > i {
    margin-bottom: 0.25rem;
    color: var(--ColorTextAlt);
}

.player-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.player-stat-label {
    font-size: 0.875rem;
    font-weight: 600;
}

/* Valeur en texte (date d'inscription, sans coupure possible) : taille réduite par paliers de
   2 px quand la tuile est étroite (tailles en pixels pairs uniquement) */
.player-stat {
    container-type: inline-size;
}

.player-stat-value.text {
    white-space: nowrap;
}

@container (max-width: 9rem) {
    .player-stat-value.text {
        font-size: 1.25rem;
    }
}

@container (max-width: 7.5rem) {
    .player-stat-value.text {
        font-size: 1.125rem;
    }
}

@container (max-width: 6.75rem) {
    .player-stat-value.text {
        font-size: 1rem;
    }
}

/* Modal du profil : badges de l'édition en cours, 6 par ligne au plus (moins sur petit écran) */
#modal-profile .profile-badges {
    grid-template-columns: repeat(auto-fill, minmax(max(3.5rem, calc((100% - 5 * 0.5rem) / 6)), 1fr));
}

/* Modal du profil : 3 tuiles par ligne, 2 sur téléphone (comme la page Compte) */
#modal-profile .player-stats {
    grid-template-columns: repeat(3, 1fr);
}

@media screen and (max-width: 600px) {
    #modal-profile .player-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Vitrine (cartes choisies dans la page Compte) : la carte s'adapte à la largeur de sa case */
.showcase {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 9rem));
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
}

.showcase-card {
    position: relative;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

/* Emplacement vide de sa vitrine (page Compte) : case de carte en pointillés, « + » au centre */
.showcase-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 63 / 88;
    padding: 0;
    border: 2px dashed var(--ColorTextAlt);
    border-radius: 0.6rem;
    background: none;
    color: var(--ColorTextAlt);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--Transition);
}

@media (hover: hover) {
    .showcase-empty:hover {
        border-color: var(--ColorPrimary);
        color: var(--ColorPrimary);
    }
}

/* Liste de ses cartes pour un emplacement (plein écran, css/trades.css .trade-layer) : carte déjà
   posée à un autre emplacement */
.showcase-in {
    position: absolute;
    left: 50%;
    bottom: 0.4rem;
    z-index: 2;
    width: auto;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    background: var(--ColorPrimary);
    color: var(--ColorPrimaryText);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    transform: translateX(-50%);
}

@keyframes profile-pop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.profile-edition.not-played .profile-edition-name {
    color: var(--ColorTextAlt);
}

/* Réaction (app/features/reactions.js) : bouton, ligne d'emojis à l'appui long, résumé */
#modal-profile .profile-reactions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

#modal-profile .profile-react {
    position: relative;
}

#modal-profile .profile-reaction {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 2px solid transparent;
    border-radius: 2rem;
    background-color: var(--ColorRow);
    color: var(--ColorText);
    font: inherit;
    font-family: var(--FontFocus);
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--Transition);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

#modal-profile .profile-reaction.mine {
    border-color: var(--ColorPrimary);
    background-color: var(--ColorPrimary10);
    color: var(--ColorPrimary);
}

#modal-profile .profile-reaction-emoji {
    font-size: 1.25rem;
    line-height: 1;
}

#modal-profile .profile-reaction.pop .profile-reaction-emoji {
    display: inline-block;
    animation: profile-reaction-pop 0.4s ease-out;
}

#modal-profile .profile-reaction-picker {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    display: flex;
    gap: 0.25rem;
    padding: 0.35rem;
    border-radius: 2rem;
    background-color: var(--ColorContainer);
    box-shadow: var(--Shadow);
    z-index: 2;
    animation: profile-picker-in 0.2s ease-out;
}

@container modalContent (max-width: 639px) {
    #modal-profile .profile-reaction {
        width: 3rem;
        height: 3rem;
        padding: 0;
        justify-content: center;
        font-size: 1.25rem;
    }

    #modal-profile .profile-reaction-label {
        display: none;
    }

    /* Emoji seul : centré dans le rond */
    #modal-profile .profile-reaction-emoji {
        text-align: center;
    }
}

#modal-profile .profile-reaction-picker[hidden] {
    display: none;
}

#modal-profile .profile-reaction-picker > button {
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 100%;
    background: transparent;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease-out;
    -webkit-tap-highlight-color: transparent;
}

#modal-profile .profile-reaction-picker > button.mine {
    background-color: var(--ColorPrimary10);
}

#modal-profile .profile-reaction-picker > button.hover,
#modal-profile .profile-reaction-picker > button:focus-visible {
    transform: scale(1.35) translateY(-4px);
}

@media (hover: hover) {
    #modal-profile .profile-reaction:hover {
        border-color: var(--ColorPrimary50);
    }

    #modal-profile .profile-reaction-picker > button:hover {
        transform: scale(1.35) translateY(-4px);
    }
}

/* Résumé dans la ligne des chips de l'en-tête */
#modal-profile [data-reactions-summary] {
    display: contents;
}

#modal-profile .profile-reaction-summary {
    gap: 0.5rem;
}

#modal-profile .profile-reaction-emojis {
    display: inline-flex;
    gap: 0.2rem;
    line-height: 1;
}

@keyframes profile-reaction-pop {
    50% { transform: scale(1.6) rotate(-10deg); }
}

@keyframes profile-picker-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.9); }
}

@media (prefers-reduced-motion: reduce) {
    .profile-avatar,
    #modal-profile .profile-reaction.pop .profile-reaction-emoji,
    #modal-profile .profile-reaction-picker { animation: none; }
}

/* Page Compte (app/pages/account.js) : même en-tête que le profil, nom en 24 px, actions à droite
   (dessous sur mobile) */
.account-top .profile-name {
    font-size: 1.5rem;
}

.account-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    width: 100%;
}

.account-top > .profile-hero {
    flex: 1 1 20rem;
    min-width: 0;
}

.account-avatar {
    position: relative;
    padding: 0;
    border: none;
    background: none !important;
    cursor: pointer;
}

/* Sans cercle de rang ici : l'avatar seul */
.account-avatar > img,
.account-avatar > video {
    border: none;
}

.account-avatar-edit {
    position: absolute;
    right: -0.25rem;
    bottom: -0.25rem;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 100%;
    background-color: var(--ColorText);
    color: var(--ColorBackground);
    font-size: 0.9rem;
    box-shadow: var(--Shadow);
    transition: var(--Transition);
}

@media (hover: hover) {
    .account-avatar:hover .account-avatar-edit {
        transform: scale(1.1);
    }
}

.account-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .account-actions {
        flex-direction: row;
        width: 100%;
    }

    .account-actions > .btn {
        flex: 1;
        justify-content: center;
    }
}

/* Lien discret vers l'édition passée, en bas à droite de la carte */
.profile-edition-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    margin: 0.75rem 0 0 auto;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    background-color: var(--ColorPrimary10);
    color: var(--ColorPrimary);
    font-family: var(--FontFocus);
    font-size: 0.875rem;
    text-decoration: none;
    transition: var(--Transition);
}

.profile-edition-link > i {
    font-size: 0.8em;
    transition: transform 0.2s ease-out;
}

@media (hover: hover) {
    .profile-edition-link:hover {
        background-color: var(--ColorPrimary);
        color: var(--ColorBackground);
    }

    .profile-edition-link:hover > i {
        transform: translateX(3px);
    }
}

/* Bouton « Proposer un échange » (app/features/trades.js) */
/* Actions envers le joueur, à droite de l'en-tête : Réagir puis Échanger */
#modal-profile .profile-actions {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Le choix des réactions s'aligne sur le bord droit du groupe (pas sur « Réagir », qui n'y est plus) */
#modal-profile .profile-actions .profile-react {
    position: static;
}

#modal-profile .profile-actions .profile-reaction-picker {
    width: max-content;
    max-width: 100cqw;
    flex-wrap: wrap;
    justify-content: center;
}

/* Même largeur pour les deux pastilles */
#modal-profile .profile-actions .profile-reactions,
#modal-profile .profile-actions .profile-react,
#modal-profile .profile-actions .profile-reaction {
    width: 100%;
    justify-content: center;
}

#modal-profile .profile-actions .profile-reaction > *,
#modal-profile .profile-trade > * {
    flex: 0 0 auto;
    width: auto;
}

/* Le conteneur de « Réagir » s'étire comme « Échanger » */
#modal-profile .profile-actions .profile-reactions {
    display: flex;
}

#modal-profile .profile-actions .profile-react {
    flex: 1 1 auto;
    display: flex;
}

/* Même hauteur pour les deux pastilles (icône ou emoji) */
#modal-profile .profile-actions .profile-reaction,
#modal-profile .profile-trade {
    box-sizing: border-box;
    min-height: 2.75rem;
}

/* Même pastille que « Réagir » (.profile-reaction) */
#modal-profile .profile-trade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 2px solid transparent;
    border-radius: 2rem;
    background-color: var(--ColorRow);
    color: var(--ColorText);
    font: inherit;
    font-family: var(--FontFocus);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease;
}

#modal-profile .profile-trade:active {
    transform: scale(0.96);
}

/* Emplacement du bouton d'échange : transparent pour la mise en page */
#modal-profile .profile-trade-slot {
    display: contents;
}

/* Proposition déjà en attente vers ce joueur : bouton vers l'onglet Échanges */
#modal-profile .profile-trade.pending {
    opacity: 0.75;
}

/* Joueur sans carte : grisé mais cliquable, pour expliquer pourquoi */
#modal-profile .profile-trade.disabled {
    opacity: 0.45;
}

/*
 * Étroit : avatar à gauche, nom, titre et chips dessous à sa droite, puis les actions côte à côte
 * en pleine largeur, avec leur texte (remplace la mise en page en rond plus haut).
 */
@container modalContent (max-width: 639px) {
    #modal-profile .profile-top {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
    }

    #modal-profile .profile-top > .profile-hero {
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-areas:
            "avatar identity"
            "avatar chips";
        align-content: center;
        column-gap: 1rem;
        row-gap: 0.5rem;
    }

    #modal-profile .profile-top .profile-hero-info {
        display: contents;
    }

    #modal-profile .profile-top .profile-avatar {
        grid-area: avatar;
    }

    #modal-profile .profile-top .profile-identity {
        grid-area: identity;
        align-self: end;
        min-width: 0;
    }

    #modal-profile .profile-top .profile-chips {
        grid-area: chips;
        align-self: start;
        margin-top: 0;
    }

    /* Deux colonnes égales */
    #modal-profile .profile-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    #modal-profile .profile-actions > * {
        min-width: 0;
    }

    #modal-profile .profile-actions .profile-reactions,
    #modal-profile .profile-actions .profile-react,
    #modal-profile .profile-actions .profile-reaction,
    #modal-profile .profile-trade {
        width: 100%;
        height: auto;
        padding: 0.6rem 0.75rem;
        justify-content: center;
        font-size: inherit;
    }

    #modal-profile .profile-actions .profile-reactions,
    #modal-profile .profile-actions .profile-react {
        padding: 0;
    }

    #modal-profile .profile-actions .profile-reaction-label,
    #modal-profile .profile-trade-label {
        display: inline;
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}
