/* 1. Variables de thèmes */
:root {
    --bg: #eeeeee;
    --header-bg: #fdfdfd;
    --text: #1a1a1a;
    --accent: #D92910;
    --darkaccent: #910000;
    --border: #eeeeee;
    --card: #ffffff;
    --hanzi-size: 80px;
}

[data-theme="dark"] {
    --bg: #1d1d1d;
    --header-bg: #1e1e1e;
    --text: #e0e0e0;
    --accent: #910000;
    --darkaccent: #d92910;    
    --border: #1d1d1d;
    --card: #000;
}

/* 2. Reset & Base */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.3s ease;
}

/* 3. Header & Nav */
.main-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.divhanzi {
    /*display: flex;
    gap: 10px;*/
}

/* debut sprite */
.divhanzi.hidden {
    /*display: none; */visibility: hidden
}

.hanzi-sprite {
    width: var(--hanzi-size);
    height: var(--hanzi-size);
    display: inline-block;
    background-repeat: no-repeat;
    background-position: 100% 0; /* Affiche le caractère complet par défaut */
    background-size: auto var(--hanzi-size); /* Force la hauteur à 160, la largeur s'adapte */
    position: relative;
    overflow: hidden;
}

.hanzi-sprite img {
    display: none; /* Cache l'image source qui sert au calcul */
}

.info-only {
    /* On ne met pas display:none car certains navigateurs 
       ne chargeraient pas l'image ou n'auraient pas de naturalWidth */
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}
/* fin sprite */

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: bold;
    font-size: 1.4rem;
    text-decoration: none;
    color: var(--accent);
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-menu a:hover { color: var(--accent); }

/* 4. Bouton Mode Nuit & Mobile */
.theme-toggle {
    background: none;
    border: 1px solid var(--accent);
    color: var(--accent);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
}

/** ajout mute **/

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.action-btn {
    background: var(--border);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.action-btn:hover {
    transform: scale(1.1);
}

/* Style quand le son est coupé */
.is-muted {
    background: #e74c3c !important; /* Rouge discret */
    color: white;
}
/** fin ajout mute **/

@media (max-width: 768px) {
    .nav-menu { display: none; } /* Prévoir un menu burger JS */
}

/* 5. Footer */
.main-footer {
    background: var(--header-bg);
    border-top: 1px solid var(--border);
    padding: 3rem 1rem 1.5rem;
    margin-top: 4rem;
}

.footer-container {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-section h4 {
    color: var(--accent);
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section ul li {
    margin-bottom: 0.6rem;
}

.footer-section ul li a {
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.footer-section ul li a:hover {
    opacity: 1;
    color: var(--accent);
}

.footer-bottom {
    max-width: 1100px;
    margin: 2rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.6;
}

/* Utilitaires pour le JS Agenda */
.btn-agenda {
    display: inline-block;
    padding: 10px 15px;
    background-color: var(--accent);
    color: #fff !important;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    margin-top: 10px;
}


/* Header Layout */
.main-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
}

.logo-img {
    height: 35px;
    width: auto;
    display: block;
}

/* Breadcrumb Styling */
.breadcrumb-wrapper {
    flex: 1;
    margin: 0 1rem;
    overflow: hidden;
}

.breadcrumb {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text);
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none; /* Cache la scrollbar sur Firefox */
}

.breadcrumb::-webkit-scrollbar {
    display: none; /* Cache la scrollbar sur Chrome/Safari */
}

.breadcrumb a {
    text-decoration: none;
    color: var(--text);
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.breadcrumb a:hover {
    opacity: 1;
    color: var(--accent);
}

.breadcrumb .sep {
    margin: 0 8px;
    opacity: 0.3;
    font-weight: 300;
}

.breadcrumb .current-page {
    font-weight: 600;
    color: var(--accent);
}

/* Theme Button */
.theme-toggle {
    background: var(--border);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.theme-toggle:active {
    transform: scale(0.9);
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .breadcrumb-wrapper {
        margin: 0 0.5rem;
    }
    .breadcrumb {
        font-size: 0.8rem;
    }
    .breadcrumb .sep {
        margin: 0 5px;
    }
    /* Sur très petit écran, on peut cacher "Accueil" pour gagner de la place */
    .breadcrumb a:first-child {
        display: none;
    }
    .breadcrumb .sep:first-of-type {
        display: none;
    }
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 1rem;
}

.level-card {
    position: relative; /* Indispensable pour limiter le lien à cette carte */
    background: var(--card);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
}


/* EFFET VISITED : Si l'utilisateur a déjà cliqué sur ce jour */
.level-link:visited {
    color: #95a5a6; /* Gris pour les leçons faites */
}

.level-link:visited::before {
    content: "✓ "; /* Ajoute une petite coche */
    color: #2ecc71;
}



/* Effet au survol du bloc complet */
.level-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.level-card h2 {
    margin: 0;
    color: var(--accent);
}

.level-card p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Style du lien et extension */
.level-link, .level-linkagenda {
    display: inline-block;
    margin: 10px;
    text-decoration: none;
    color: var(--accent);
    font-weight: bold;
    font-size: 0.9rem;
}
/* Style du lien et extension */
.level-link {
    margin-top: 10px;
}

/* C'est ce bloc qui rend toute la carte cliquable */
.level-link::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1; /* Couvre tout le contenu de la carte */
}

/* Optionnel : un petit changement de couleur du lien au survol de la carte */
.level-card:hover .level-link {
    text-decoration: underline;
}


/* Container de la grille des jours */
.hsk-dashboard {
    padding: 2rem 1rem;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    max-width: 1000px;
    margin: 0 auto;
}

/* Carte de jour individuelle */
.day-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 10px;
    text-align: center;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100px;
}

.day-number {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--text);
}

.day-link {
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--accent);
    opacity: 0.8;
}

/* Le lien invisible qui couvre toute la carte */
.day-link::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1;
}

/* EFFET VISITED : Si l'utilisateur a déjà cliqué sur ce jour */
.day-link:visited {
    color: #95a5a6; /* Gris pour les leçons faites */
}

.day-link:visited::before {
    content: "✓ "; /* Ajoute une petite coche */
    color: #2ecc71;
}

/* Au survol de la carte */
.day-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

/* Responsive mobile : grille plus compacte */
@media (max-width: 480px) {
    .days-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 colonnes sur mobile */
        gap: 10px;
    }
    .day-card { padding: 15px 5px; min-height: 80px; }
    .day-number { font-size: 0.9rem; }
    .day-link { font-size: 0.7rem; }
}




/* cards */
/* Masquage de base */
.word-card {
    display: none; /* Cache les 39 autres cartes */
    background: var(--card);
    border: 2px solid var(--border);
    padding: 0.5rem;
    border-radius: 5px;
    text-align: center;
    min-height: 580px;
}

.word-card.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Logique des étapes (Steps) */
.step-content { 
    transition: opacity 0.3s ease; 
}

/* Cache les parties selon l'étape actuelle de la carte */
.word-card.step-0 .part-1, 
.word-card.step-0 .part-2 { 
    opacity: 0; 
    visibility: hidden; 
}

.word-card.step-1 .part-2 { 
    opacity: 0; 
    visibility: hidden; 
}

/* Style du contenu */
.mot { font-size: 5rem; color: var(--text); cursor: pointer; display: block;margin: -10px 0 -5px 0;}
.pinyin { font-size: 1.8rem; color: var(--darkaccent); display: block; margin-top: 10px; font-weight: 600; }
.tradfr { font-size: 1.4rem;}
.part-2 hr { margin: 1.5rem 0; opacity: 0.2; }
.ex0 { font-size: 1.6rem; color: var(--text); }
.ex1 { font-size: 1.6rem; color: var(--text);opacity: 0.9; }
.hsklevel { font-size: 1rem; color: var(--text); }


/* ---- course control ---- */

/* Container des contrôles */
.course-controls-v2 {
    display: flex;
    align-items: center;
    gap: 10px;
}
.control-btn-main {
    flex: 1;
}
#exercise-app{
      background: var(--card);
}
.controls {
  max-width: 1000px;
  margin: 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 100;
  background: var(--card);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

/*
.auto-mode #goBtn {
    display: none;
}
.auto-mode #prevBtn {
    visibility: hidden;
}
*/
.icon-pause {
    display: none;
}
.auto-mode .icon-play {
    display: none;
}
.auto-mode .icon-pause {
    display: block;
}

#speedBtn {
    align-items: center;
    justify-content: center;

    min-width: 48px;
    height: 48px;

    border-radius: 14px;
    border: none;
    color:var(--text);
    background: var(--header-bg);

    font-weight: 600;
   /* font-size: 13px;*/

    cursor: pointer;

    user-select: none;
}

#speedLabel {
    font-variant-numeric: tabular-nums;
}
.flash {
    transform: scale(1.08);
    transition: transform 0.12s ease;
}



/* Bouton Retour Circulaire */
.control-btn-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.control-btn-circle:hover:not(:disabled) {
    background: var(--border);
    transform: scale(1.05);
}

.control-btn-circle:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.progress-wrapper {
    margin-top: 10px;
}

.progress-track {
    width: 100%;
    height: 4px;

    background: var(--border);
    border-radius: 999px;

    overflow: hidden;
}

#progress-bar {
    height: 100%;
   /* background: linear-gradient(90deg, #2ecc71, #27ae60);*/
    background: linear-gradient(90deg, #FFDE00, #C86F00);
    width: 20%;
    transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#progress-text {
    display: block;

    margin-top: 6px;

    font-size: 12px;
    text-align: center;

    /*color: #777;*/
}

/* Bouton Principal (Suivant/OK) */
.control-btn-main {
    width: 100%;
    height: 52px;
    padding: 0 25px;
    border-radius: 16px;
    border: none;
    background: var(--accent);
    color: white;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(192, 57, 43, 0.3);
    transition: all 0.2s ease;
}

.control-btn-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(192, 57, 43, 0.4);
}

.control-btn-main:active {
    transform: translateY(0);
}

/* Etat spécial quand on termine une carte (étape 2) */
.is-step-complete {
/*    background: #2ecc71 !important;*/
    background: #0000cc !important;
    box-shadow: 0 4px 15px rgba(00, 00, 208, 0.3) !important;
}

/* Icone animation */
.icon-next {
    transition: transform 0.2s ease;
}
.control-btn-main:hover .icon-next {
    transform: translateX(3px);
}