
:root {
    --spring-easing: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --glass-blur: blur(16px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);

    /* Border-radius scale */
    --radius-xs:  4px;   /* Micro: legend dots, miniature chips */
    --radius-sm:  6px;   /* Small: .btn-small, editor size btns */
    --radius-md:  8px;   /* Default: .btn, .menu-item-btn */
    --radius-lg:  12px;  /* Medium: .tab-btn, .skin-list-item, dropdowns */
    --radius-xl:  16px;  /* Large: .exercise-card, stat wrappers */
    --radius-2xl: 20px;  /* Panel: .container, .modal-content */
    --radius-pill: 30px; /* Pill: toasts, .diff-btn */
    --radius-full: 50%;  /* Circle: icon buttons */
}

/* ============================================================
   shared.css — Styles communs à toutes les pages du projet C2
   ============================================================ */

/* --- Typographie locale (hors ligne) --- */
@font-face {
    font-family: 'Outfit';
    src: url('../fonts/outfit.woff2') format('woff2');
    font-weight: 400 700;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('../fonts/jetbrains-mono.woff2') format('woff2');
    font-weight: 700;
    font-display: swap;
}

/* --- Accessibilité et Touch (Tablet-First) --- */
body {
    touch-action: manipulation; /* Élimine le délai de 300ms sur mobile */
}

button {
    min-width: 44px;
    min-height: 44px;
}

/* --- Animation d'entrée principale --- */
@keyframes fadeInCascade {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Header unifié --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 15px;
    margin-bottom: 24px;
    width: 100%;
}

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.header-icon {
    background: var(--accent, var(--primary, #2563eb));
    color: white;
    padding: 10px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s var(--spring-easing, ease);
}

.header-icon:hover {
    transform: scale(1.05);
}

.app-header h1 {
    margin-bottom: 0;
    font-size: clamp(1.2rem, 5vw, 1.75rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Boutons d'action --- */
.action-buttons {
    display: flex;
    gap: 8px;
    z-index: 100;
}

/* --- Dropdown Réglages --- */
.settings-dropdown {
    position: relative;
    display: inline-block;
}

.settings-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 110%;
    background: var(--container-bg, rgba(255, 255, 255, 0.95));
    min-width: 60px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.3);
    border: 1px solid var(--card-border, rgba(0, 0, 0, 0.1));
    border-radius: var(--radius-lg);
    z-index: 101;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 10px;
    flex-direction: column;
    gap: 10px;
}

/* Pseudo-element to bridge the gap between button and dropdown to prevent hover loss */
.settings-dropdown-content::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    right: 0;
    height: 15px;
    background: transparent;
}

body.dark .settings-dropdown-content {
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.6);
}

/* Affichage au survol ou au clic sur le bouton déclencheur */
.settings-dropdown:hover .settings-dropdown-content,
.settings-dropdown-content.show {
    display: flex;
    animation: fadeInCascade 0.2s var(--spring-easing, cubic-bezier(0.175, 0.885, 0.32, 1.275)) forwards;
}

.icon-action-btn {
    background: var(--card-bg, rgba(255, 255, 255, 0.8));
    border: 1px solid var(--card-border, rgba(0, 0, 0, 0.1));
    color: var(--text-main, #1e293b);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    min-width: 44px;
    min-height: 44px;
}
body.dark .icon-action-btn {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

.icon-action-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
}
body.dark .icon-action-btn:hover {
    background: rgba(30, 41, 59, 0.9);
}

.settings-dropdown-content .icon-action-btn {
    color: var(--text-main, #1e293b);
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
}
.settings-dropdown-content .icon-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: none;
}
body.dark .settings-dropdown-content .icon-action-btn {
    color: #fff;
    background: transparent;
    border: 1px solid transparent;
}
body.dark .settings-dropdown-content .icon-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* --- Footer commun --- */
footer {
    text-align: center;
    margin-top: 30px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

footer a {
    color: #fff;
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
}

/* --- Impression --- */
@media print {
    .no-print { display: none !important; }
}

/* --- Accessibilité et ancres --- */
:target { scroll-margin-top: 5rem; }

/* --- Accessibilité : Focus Rings --- */
:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.6);
}

/* ============================================================
   Modal Statistiques détaillées (ScoreManager)
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg, rgba(255, 255, 255, 0.95));
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-2xl);
    padding: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-color, #1a202c);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.btn-close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-color, #1a202c);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
}

.btn-close-modal:hover {
    opacity: 1;
    transform: scale(1.1);
    background: rgba(0,0,0,0.05);
}

.btn-reset-scores {
    margin-top: 25px;
    padding: 12px 24px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: block;
    width: 100%;
}

.btn-reset-scores:hover {
    background: #c53030;
    transform: scale(1.02);
}

.stat-mode-title {
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--primary-color, #667eea);
    padding-bottom: 5px;
    font-size: 1.2rem;
}

.stat-table-wrapper {
    overflow-x: auto;
}

.stat-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.stat-table th, .stat-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.stat-table th {
    font-weight: bold;
    color: var(--primary-color, #667eea);
}

.stat-pct {
    font-size: 0.85em;
    opacity: 0.7;
    margin-left: 4px;
}

/* Dark mode overrides (si géré par des classes sur body, à ajuster selon le projet) */
body.dark .modal-content {
    background: #2d3748;
    color: #f7fafc;
}

body.dark .btn-close-modal {
    color: #f7fafc;
}

body.dark .stat-table th, body.dark .stat-table td {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.menu-item-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-main, #1e293b);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-md);
    text-align: left;
    transition: background-color 0.2s, transform 0.1s;
    white-space: nowrap;
}

.menu-item-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.menu-item-btn:active {
    transform: scale(0.98);
}

body.dark .menu-item-btn {
    color: #f8fafc;
}

body.dark .menu-item-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}


/* Graphiques Donut */
.stat-mode-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.stat-chart-wrapper {
    display: flex;
    align-items: center;
    gap: 30px;
    background: rgba(0, 0, 0, 0.02);
    padding: 20px;
    border-radius: var(--radius-xl);
    flex-wrap: wrap;
    justify-content: center;
}

body.dark .stat-chart-wrapper {
    background: rgba(255, 255, 255, 0.03);
}

.stat-donut-container {
    position: relative;
    width: 140px;
    height: 140px;
    animation: donutFadeIn 0.5s ease-out forwards;
}

.stat-donut {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.stat-donut-circle {
    fill: none;
    stroke-width: 18;
    stroke-linecap: butt;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-donut-bg {
    fill: none;
    stroke: rgba(0, 0, 0, 0.05);
    stroke-width: 18;
}

body.dark .stat-donut-bg {
    stroke: rgba(255, 255, 255, 0.1);
}

.stat-legend {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.stat-legend-color {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
}

.color-success-1st { background-color: #22c55e; stroke: #22c55e; }
.color-success-more { background-color: #f59e0b; stroke: #f59e0b; }
.color-mistakes { background-color: #ef4444; stroke: #ef4444; }

body.dark .color-success-1st { background-color: #16a34a; stroke: #16a34a; }
body.dark .color-success-more { background-color: #d97706; stroke: #d97706; }
body.dark .color-mistakes { background-color: #b91c1c; stroke: #b91c1c; }

.stat-legend-label {
    color: var(--text-secondary);
}

.stat-legend-value {
    font-weight: 700;
    margin-left: auto;
}

@keyframes donutFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}



/* ============================================================
   Mobile Bottom Tab Bar (Espace, Simulateur, Pilotage, etc.)
   ============================================================ */
@media (max-width: 600px) {
    /* Fix for position: fixed failing inside animated containers */
    body:has(.tabs) > main,
    body:has(.nav-bar) > main,
    body:has(.tab-bar) > main {
        transform: none !important;
        animation: none !important;
        backdrop-filter: none !important;
    }

    body {
        padding-bottom: 90px !important; /* Prevent content from being hidden behind the bar */
    }

    body > .tabs, body > .nav-bar, body > .tab-bar, .container > .tabs {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 10px !important;
        background: var(--container-bg, rgba(255, 255, 255, 0.9)) !important;
        backdrop-filter: var(--glass-blur, blur(16px)) !important;
        -webkit-backdrop-filter: var(--glass-blur, blur(16px)) !important;
        border-top: var(--glass-border, 1px solid rgba(255, 255, 255, 0.2)) !important;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1) !important;
        z-index: 1000 !important;
        display: flex !important;
        justify-content: center !important;
        gap: 8px !important;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0 !important;
    }

    /* Make buttons expand to fill the bar */
    body > .tabs > *, body > .nav-bar > *, body > .tab-bar > *, .container > .tabs > * {
        flex: 1 !important;
        text-align: center !important;
        min-width: 0 !important; /* allows flex to shrink below intrinsic width if needed */
        font-size: 12px !important;
        padding: 8px 4px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-direction: column !important;
    }

    body.dark .tabs, body.dark .nav-bar, body.dark .tab-bar {
        background: rgba(30, 41, 59, 0.9) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5) !important;
    }

    .settings-dropdown-content {
        right: 0 !important;
        left: auto !important;
    }

    /* Fix containing block issues on mobile for fixed bottom bars */
    body > header, body > .container, .container {
        transform: none !important;
        animation: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

/* TBI (Tableau Blanc Interactif) & Large Screens Optimization */
@media (min-width: 1200px) {
  :root {
    --container-max-width: 1400px;
  }

  body {
    font-size: 18px; /* Bump base font size for better readability from afar */
  }

  .container {
    max-width: var(--container-max-width) !important;
  }

  /* Increase base interactive element sizes slightly */
  button, select, input {
    font-size: 1.1em;
  }

  .tbi-side-by-side {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
  }
}

/* ============================================================
   Unified Toast Notification (c2-toast / toast.js)
   ============================================================ */
#c2-toast-container {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.c2-toast {
    padding: 10px 20px;
    border-radius: var(--radius-pill, 30px);
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    transition: opacity 0.3s var(--spring-easing, ease),
                transform 0.3s var(--spring-easing, ease);
    text-align: center;
    max-width: min(90vw, 450px);
    white-space: pre-wrap;
}

.c2-toast.success { background: rgba(16, 185, 129, 0.95); }
.c2-toast.error   { background: rgba(239, 68, 68, 0.95); }
.c2-toast.warn    { background: rgba(245, 158, 11, 0.95); }
.c2-toast.info    { background: rgba(99, 102, 241, 0.95); }

.c2-toast i {
    flex-shrink: 0;
}

.c2-toast.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}



/* ============================================================
   Boutons (Standardisés)
   ============================================================ */
.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s var(--spring-easing, ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn:active:not(:disabled) {
    transform: scale(0.95) translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    min-height: auto;
    min-width: auto;
}

.btn-primary, .btn-new {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled), .btn-new:hover:not(:disabled) {
    background: var(--accent-dark, var(--accent-hover, #4f46e5));
}

.btn-success, .btn-check {
    background: var(--success);
    color: #fff;
}

.btn-success:hover:not(:disabled), .btn-check:hover:not(:disabled) {
    background: #059669;
}

.btn-clear {
    background: var(--bb-blue, #3b82f6);
    color: #fff;
}

.btn-clear:hover:not(:disabled) {
    background: var(--bb-blue-shadow, #2563eb);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--card-border, #e2e8f0);
    color: var(--text-muted);
}

.btn-outline:hover:not(:disabled) {
    background: var(--card-bg, #f1f5f9);
    color: var(--text-main);
    border-color: var(--text-secondary, #cbd5e1);
}

.btn-outline-error {
    background: transparent;
    border: 2px solid #fca5a5;
    color: #ef4444;
}

.btn-outline-error:hover:not(:disabled) {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #f87171;
}

body.dark .btn-outline {
    border-color: #334155;
    color: #cbd5e1;
}

body.dark .btn-outline:hover:not(:disabled) {
    background: #334155;
    color: #f8fafc;
}

body.dark .btn-outline-error {
    border-color: #991b1b;
    color: #f87171;
}

body.dark .btn-outline-error:hover:not(:disabled) {
    background: #450a0a;
    color: #fca5a5;
}

/* ============================================================
   Navigation par onglets (Standardisée)
   ============================================================ */
.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    border: 2px solid #e2e8f0;
    background: var(--card-bg);
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--spring-easing, ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    min-height: 44px;
}

.tab-btn:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

.tab-btn:active {
    transform: scale(0.95);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

body.dark .tab-btn {
    background: var(--card-bg);
    border-color: #334155;
    color: #94a3b8;
}

body.dark .tab-btn:hover {
    border-color: #475569;
}

body.dark .tab-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============================================================
   Instructions (Standardisée)
   ============================================================ */
.game-instruction {
    text-align: center;
    color: var(--text-main);
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 15px;
}

.fa-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: currentColor;
    overflow: visible;
}
.header-icon svg {
    width: 24px;
    height: 24px;
}
