/**
 * GeekFight - Custom Styles
 *
 * Basé sur Bootstrap 5.3
 * Respecte WCAG 2.2 AA (contrastes, focus visible, etc.)
 */

/* ==========================================================================
   Variables CSS
   ========================================================================== */

:root {
    /* Couleurs principales */
    --gf-primary: #0d6efd;
    --gf-primary-dark: #0a58ca;
    --gf-secondary: #6c757d;
    --gf-success: #198754;
    --gf-danger: #dc3545;
    --gf-warning: #ffc107;
    --gf-info: #0dcaf0;

    /* Couleurs de fond */
    --gf-bg-light: #f8f9fa;
    --gf-bg-dark: #212529;

    /* Typographie */
    --gf-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --gf-font-size-base: 1rem; /* 16px minimum pour l'accessibilité */
    --gf-line-height: 1.5;

    /* Espacements */
    --gf-spacing-xs: 0.25rem;
    --gf-spacing-sm: 0.5rem;
    --gf-spacing-md: 1rem;
    --gf-spacing-lg: 1.5rem;
    --gf-spacing-xl: 3rem;

    /* Focus ring (accessibilité) */
    --gf-focus-ring-width: 3px;
    --gf-focus-ring-color: rgba(13, 110, 253, 0.5);

    /* Transitions */
    --gf-transition-fast: 150ms ease-in-out;
    --gf-transition-normal: 300ms ease-in-out;
}

/* ==========================================================================
   Base
   ========================================================================== */

html {
    font-size: 100%; /* 16px par défaut, respecte les préférences utilisateur */
}

body {
    font-family: var(--gf-font-family);
    font-size: var(--gf-font-size-base);
    line-height: var(--gf-line-height);
    color: var(--gf-bg-dark);
    background-color: #fff;
}

/* ==========================================================================
   Accessibilité - Skip Link
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--gf-primary);
    color: #fff;
    padding: var(--gf-spacing-sm) var(--gf-spacing-md);
    z-index: 9999;
    transition: top var(--gf-transition-fast);
}

.skip-link:focus {
    top: 0;
    outline: var(--gf-focus-ring-width) solid var(--gf-focus-ring-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Accessibilité - Focus visible
   ========================================================================== */

/* Focus visible sur tous les éléments interactifs */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: var(--gf-focus-ring-width) solid var(--gf-focus-ring-color);
    outline-offset: 2px;
}

/* Supprime l'outline par défaut du navigateur */
:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   Cards avec effet hover
   ========================================================================== */

.hover-lift {
    transition: transform var(--gf-transition-normal), box-shadow var(--gf-transition-normal);
}

.hover-lift:hover,
.hover-lift:focus-within {
    transform: translateY(-4px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Navigation
   ========================================================================== */

.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background-color var(--gf-transition-fast);
}

.nav-link:hover,
.nav-link:focus {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    font-weight: 500;
}

/* ==========================================================================
   Boutons
   ========================================================================== */

.btn {
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.5rem 1.25rem;
    transition: all var(--gf-transition-fast);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}

/* ==========================================================================
   Formulaires
   ========================================================================== */

.form-control,
.form-select {
    border-radius: 0.5rem;
    padding: 0.625rem 1rem;
    border: 1px solid #ced4da;
    transition: border-color var(--gf-transition-fast), box-shadow var(--gf-transition-fast);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--gf-primary);
    box-shadow: 0 0 0 var(--gf-focus-ring-width) var(--gf-focus-ring-color);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.375rem;
}

/* Erreur de validation */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: var(--gf-danger);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    box-shadow: 0 0 0 var(--gf-focus-ring-width) rgba(220, 53, 69, 0.25);
}

/* ==========================================================================
   Alertes
   ========================================================================== */

.alert {
    border-radius: 0.5rem;
    border: none;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    border-radius: 0.75rem;
    overflow: hidden;
}

.card-img-top {
    aspect-ratio: 3 / 4;
    object-fit: cover;
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
    font-weight: 500;
    padding: 0.375em 0.75em;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer .footer-link {
    color: #adb5bd; /* WCAG AA 4.6:1 on #212529 */
}

footer a:hover,
footer a:focus {
    color: #fff !important;
    text-decoration: underline;
}

/* ==========================================================================
   Statistiques
   ========================================================================== */

.stats-number {
    font-weight: 700;
    font-size: 2rem;
    line-height: 1.2;
}

/* ==========================================================================
   Responsive - Respect des tailles minimales tactiles (44x44px)
   ========================================================================== */

@media (max-width: 767.98px) {
    .btn,
    .nav-link,
    .dropdown-item {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* ==========================================================================
   Duel Arena — Redesign v2
   ========================================================================== */

.duel-arena {
    padding: 2rem 0;
}

/* Barre d'actions : Filtres | Égalité | Passer */
.duel-topbar {
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    padding: 0.5rem 0;
}

.duel-topbar__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.duel-topbar__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    cursor: pointer;
    transition: all var(--gf-transition-normal);
    text-decoration: none;
}

.duel-topbar__btn:hover {
    background: #f0f0f0;
    border-color: #adb5bd;
    color: #212529;
}

.duel-topbar__btn--draw {
    border-color: var(--gf-warning);
    color: #856404;
}

.duel-topbar__btn--draw:hover {
    background: var(--gf-warning);
    color: #000;
}

.duel-topbar__btn--skip {
    border-color: #adb5bd;
    color: var(--gf-secondary);
}

.duel-topbar__btn--skip:hover {
    background: var(--gf-secondary);
    color: #fff;
}

.duel-topbar__btn--filter {
    border-color: var(--gf-primary);
    color: var(--gf-primary);
}

.duel-topbar__btn--filter:hover {
    background: var(--gf-primary);
    color: #fff;
}

.duel-topbar__separator {
    width: 1px;
    height: 24px;
    background: #dee2e6;
}

/* Container de duel : 2 cartes + VS */
.duel-container {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 2rem;
    max-width: 960px;
    margin: 0 auto;
}

/* Carte de jeu */
.duel-card {
    flex: 0 1 400px;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: transform var(--gf-transition-normal), box-shadow var(--gf-transition-normal);
}

@media (hover: hover) {
    .duel-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }

    .duel-card--left:hover {
        box-shadow: 0 8px 24px rgba(13, 110, 253, 0.15);
    }

    .duel-card--right:hover {
        box-shadow: 0 8px 24px rgba(220, 53, 69, 0.15);
    }
}

/* Image cover plein cadre */
.duel-cover {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
}

/* Placeholder quand pas de couverture */
.duel-cover[role="img"] {
    width: 100%;
    aspect-ratio: 3 / 4;
}

/* Overlay gradient en bas */
.duel-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2.5rem 1.25rem 1.25rem;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    color: #fff;
}

.duel-card__name {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.duel-card__meta {
    font-size: 0.8rem;
    opacity: 0.85;
    margin: 0;
}

.duel-card__elo {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.4rem;
    backdrop-filter: blur(4px);
}

/* Bouton Vote (pouce haut) — Haut gauche */
.duel-card__vote {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 5;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    cursor: pointer;
    transition: all var(--gf-transition-normal);
    backdrop-filter: blur(4px);
}

.duel-card--left .duel-card__vote {
    background: rgba(13, 110, 253, 0.7);
}

.duel-card--left .duel-card__vote:hover {
    background: var(--gf-primary);
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(13, 110, 253, 0.5);
}

.duel-card--right .duel-card__vote {
    background: rgba(220, 53, 69, 0.7);
}

.duel-card--right .duel-card__vote:hover {
    background: var(--gf-danger);
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(220, 53, 69, 0.5);
}

/* Bouton "Pas joué" — Haut droite */
.duel-card__skip {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255,255,255,0.85);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--gf-transition-normal);
    backdrop-filter: blur(4px);
}

.duel-card__skip:hover {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border-color: #fff;
}

/* VS Badge central */
.vs-badge {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gf-primary), var(--gf-danger));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.vs-badge span {
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Indicateur mobile (tap pour swapper) */
.duel-mobile-indicator {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
    color: var(--gf-secondary);
    transition: opacity 0.3s ease;
}

/* Responsive mobile : cartes empilées avec angle */
@media (max-width: 767.98px) {
    .duel-arena {
        padding: 1rem 0;
    }

    .duel-container {
        flex-direction: column;
        align-items: center;
        gap: 0;
        position: relative;
        height: 440px;
        max-width: 320px;
        margin: 0 auto;
    }

    .duel-card {
        position: absolute;
        width: 280px;
        height: 400px;
        transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    .duel-cover {
        height: 100%;
        aspect-ratio: auto;
    }

    /* Carte premier plan (gauche) */
    .duel-card--left {
        z-index: 2;
        transform: rotate(-6deg) translateX(-20px);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
        filter: brightness(1);
    }

    /* Carte arrière-plan (droite) */
    .duel-card--right {
        z-index: 1;
        transform: rotate(7deg) translateX(20px) scale(0.95);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        filter: brightness(0.75);
    }

    /* Swapped states */
    .duel-card--left.is-back {
        z-index: 1;
        transform: rotate(-7deg) translateX(-20px) scale(0.95);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
        filter: brightness(0.75);
    }

    .duel-card--right.is-front {
        z-index: 2;
        transform: rotate(6deg) translateX(20px);
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
        filter: brightness(1);
    }

    /* Bouton vote plus gros en mobile */
    .duel-card__vote {
        width: 56px;
        height: 56px;
        font-size: 1.3rem;
    }

    .duel-card__name {
        font-size: 1.1rem;
    }

    /* VS caché en mobile */
    .duel-vs {
        display: none;
    }

    /* Topbar compacte */
    .duel-topbar__inner {
        gap: 0.5rem;
    }

    .duel-topbar__btn {
        font-size: 0.78rem;
        padding: 0.35rem 0.65rem;
    }

    .duel-topbar__separator {
        display: none;
    }
}

/* Swipe hints (WIN / LOSE) */
.duel-swipe-hint {
    display: none;
}

@media (max-width: 767.98px) {
    .duel-swipe-hint {
        display: block;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        font-size: 1.4rem;
        font-weight: 800;
        letter-spacing: 0.05em;
        padding: 0.5rem 1rem;
        border-radius: 0.75rem;
        opacity: 0;
        transition: opacity 0.15s ease;
        pointer-events: none;
        z-index: 10;
    }

    .duel-swipe-hint--win {
        right: -0.5rem;
        color: #198754;
        background: rgba(25, 135, 84, 0.15);
        border: 2px solid #198754;
    }

    .duel-swipe-hint--lose {
        left: -0.5rem;
        color: #dc3545;
        background: rgba(220, 53, 69, 0.15);
        border: 2px solid #dc3545;
    }

    .duel-swipe-hint--visible {
        opacity: 1;
    }
}

/* Masquer indicateur mobile sur desktop */
@media (min-width: 768px) {
    .duel-mobile-indicator {
        display: none;
    }
}

/* ==========================================================================
   Classements (Rankings)
   ========================================================================== */

.ranking-table th {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.ranking-table tbody tr {
    transition: background-color var(--gf-transition-fast);
}

/* Miniature de couverture dans le tableau */
.ranking-cover {
    width: 40px;
    height: 54px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Numéro de rang */
.rank-number {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gf-secondary);
}

/* Podium : 1er (rouge), 2ème (bleu), 3ème (vert) */
.rank-gold .rank-number {
    color: #dc3545;
    font-weight: bold;
    font-size: 1.3rem;
}

.rank-silver .rank-number {
    color: #0d6efd;
    font-weight: bold;
    font-size: 1.25rem;
}

.rank-bronze .rank-number {
    color: #198754;
    font-weight: bold;
    font-size: 1.2rem;
}

.rank-gold {
    background-color: rgba(220, 53, 69, 0.06);
}

.rank-silver {
    background-color: rgba(13, 110, 253, 0.06);
}

.rank-bronze {
    background-color: rgba(25, 135, 84, 0.06);
}

/* Covers plus grosses pour le podium */
.rank-gold .ranking-cover,
.rank-silver .ranking-cover,
.rank-bronze .ranking-cover {
    width: 60px;
    height: 80px;
}

/* Bouton caddie affilié */
.affiliate-cart-btn {
    line-height: 1;
    vertical-align: baseline;
    text-decoration: none;
}

.affiliate-cart-btn:hover .bi-cart3 {
    color: #146c43 !important;
}

/* Badge Elo */
.elo-badge {
    font-weight: 700;
    font-size: 1rem;
    color: var(--gf-primary);
}

/* Barre de progression win rate */
.ranking-table .progress {
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
}

/* ==========================================================================
   Profil
   ========================================================================== */

.profile-avatar {
    flex-shrink: 0;
}

/* Sidebar profil active */
.list-group-item.active {
    border-color: var(--gf-primary);
}

/* ==========================================================================
   Classements partagés
   ========================================================================== */

/* Card classement partagé */
.shared-ranking-card {
    transition: transform var(--gf-transition-fast), box-shadow var(--gf-transition-fast);
}

.shared-ranking-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
}

/* Aperçu des jeux dans la card */
.shared-ranking-preview .badge {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Métadonnées card */
.shared-ranking-meta {
    font-size: 0.85rem;
}

/* Boutons de réaction */
.reaction-btn {
    transition: all var(--gf-transition-fast);
}

.reaction-btn.active {
    font-weight: 600;
}

.reaction-btn.btn-outline-success.active {
    background-color: var(--gf-success);
    border-color: var(--gf-success);
    color: #fff;
}

.reaction-btn.btn-outline-danger.active {
    background-color: var(--gf-danger);
    border-color: var(--gf-danger);
    color: #fff;
}

.reaction-btn:focus-visible {
    outline: var(--gf-focus-ring-width) solid var(--gf-focus-ring-color);
    outline-offset: 2px;
}

/* Compteurs de réactions */
.reaction-count {
    font-weight: 600;
    font-size: 1.1rem;
}

/* ==========================================================================
   Mode sombre - Préparation (désactivé par défaut)
   ========================================================================== */

/*
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a2e;
        color: #eee;
    }
}
*/

/* ==========================================================================
   Réduction des animations - Accessibilité
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Impression
   ========================================================================== */

@media print {
    .navbar,
    footer,
    .btn,
    .skip-link {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.4;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* ==========================================================================
   AD BLOCKS
   ========================================================================== */
.ad-block {
    background: var(--bs-light, #f8f9fa);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.ad-block__cta a {
    text-decoration: underline;
}

.ad-block__cta a:hover {
    color: var(--bs-primary) !important;
}

.ad-row .ad-block {
    border-bottom: none;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}
