/* HRNtrack — styles communs à toutes les pages (variables, en-tête, menu mobile).
   Les styles propres à une page restent dans le <style> de cette page, chargé après ce fichier. */

:root {
    --color-dark: #1A1A1A;
    --color-light: #F5F5F0;
    --color-sand: #EBE7DF;
    --color-border: #D8D2C5;
    --color-gold: #C6A875;
    --color-gold-light: #F9F5EB;
    --color-red: #C0392B;
    --color-green: #6A8C47;
    --color-green-dark: #557235;
    --color-text-sub: #5E5D59;
    --card-bg: #FCFBF8;
    --primary: var(--color-green);
    --primary-dark: var(--color-green-dark);
    --bg-body: var(--color-light);
    --text-main: var(--color-dark);
    --text-sub: var(--color-text-sub);
    --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --nav-height: 75px;
    --nav-height-mobile: 70px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.08);
    --surface: #FFFFFF;                       /* fonds « papier blanc » (cartes, champs) */
    --nav-bg: rgba(216, 210, 197, 0.45);      /* barre du haut translucide */
    --logo-filter: brightness(0);             /* logo en noir */
    color-scheme: light;
}

/* --- MODE SOMBRE ---
   Activé par assets/theme.js (attribut data-theme sur <html>).
   On inverse l'encre et le papier : un bouton « fond --color-dark / texte --color-light »
   devient clair sur sombre automatiquement. Sélecteur plus précis que :root
   pour l'emporter sur les :root propres à certaines pages. */
:root[data-theme="dark"] {
    --color-dark: #ECE9E2;
    --color-light: #161615;
    --color-sand: #24231F;
    --color-border: #3A3833;
    --color-gold-light: #2B261C;
    --color-text-sub: #A8A49B;
    --card-bg: #1E1D1A;
    --surface: #232220;
    --nav-bg: rgba(30, 29, 26, 0.85);
    --logo-filter: brightness(0) invert(1);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

:root[data-theme="dark"] img:not(.site-logo) {
    filter: brightness(0.92);   /* adoucit les images très claires sur fond sombre */
}

*, *::before, *::after {
    box-sizing: border-box;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 3rem;
    height: var(--nav-height);
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-logo-group {
    display: flex;
    align-items: center;
}

.site-logo {
    height: 100px;
    width: auto;
    filter: var(--logo-filter);
    transition: opacity 0.25s ease;
    display: block;
}

.site-logo:hover {
    opacity: 0.75;
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-link {
    text-decoration: none;
    color: var(--color-dark);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: all 0.25s ease;
    display: inline-block;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-auth-trigger {
    background: transparent;
    border: 1px solid var(--color-dark);
    color: var(--color-dark);
    padding: 0.5rem 1.2rem;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-auth-trigger:hover {
    background: var(--color-dark);
    color: var(--color-light);
}

.lang-toggle {
    display: flex;
    border: 1px solid var(--color-border);
    cursor: pointer;
    background: var(--color-sand);
}

.lang-option {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-sub);
    transition: all 0.2s ease;
}

.lang-option.active {
    background: var(--color-dark);
    color: var(--color-light);
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--color-dark);
}

.mobile-menu-btn svg {
    width: 26px;
    height: 26px;
    stroke: var(--color-dark);
}

.mobile-drawer {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-light);
    border-top: 1px solid var(--color-border);
    flex-direction: column;
    padding: 2rem;
    gap: 1.5rem;
    z-index: 999;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.mobile-drawer.open {
    display: flex;
}

.mobile-drawer .mobile-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 992px) {
    .top-nav { padding: 0 1.5rem; }
    .nav-center, .nav-right .btn-auth-trigger, .nav-right .lang-toggle { display: none; }
    .mobile-menu-btn { display: block; }
}

/* --- ACCESSIBILITÉ --- */

/* Le sélecteur de langue est un vrai <button> : on retire les styles par défaut du navigateur */
button.lang-toggle {
    padding: 0;
    font: inherit;
    color: inherit;
}

/* Contour visible quand on navigue au clavier (pas au clic souris) */
:focus-visible {
    outline: 2px solid var(--color-dark);
    outline-offset: 2px;
}

.modal-overlay :focus-visible {
    outline-color: var(--color-green);
}

/* Cartes cliquables (collection, nouveautés) accessibles au clavier */
[role="button"][tabindex]:focus-visible {
    outline: 2px solid var(--color-dark);
    outline-offset: 3px;
}

/* Sur mobile, un champ en dessous de 16px fait zoomer iOS automatiquement au focus */
@media (max-width: 992px) {
    input, select, textarea { font-size: 16px; }
}

/* Respecte le réglage système « réduire les animations » */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- BOUTON CLAIR / SOMBRE --- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0; /* ne pas se faire écraser quand la barre du menu est pleine (page Collection) */
    padding: 0;
    border: 1px solid var(--color-border);
    background: var(--color-sand);
    color: var(--color-dark);
    cursor: pointer;
    transition: border-color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--color-dark); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (max-width: 992px) {
    .nav-right .theme-toggle { display: none; }
}

/* Écrans moyens : on resserre la barre pour que le menu ne touche pas le logo */
@media (min-width: 993px) and (max-width: 1240px) {
    .top-nav { padding: 0 1.5rem; }
    .nav-center { gap: 0.95rem; }
    .nav-right { gap: 0.6rem; }
    .nav-center .nav-link { font-size: 0.76rem; letter-spacing: 0.05em; }
}
/* 6 liens + boutons : sous 1 140 px, le bouton « Soutenir » de la barre est masqué (il reste dans le menu mobile et le pied de page) */
@media (min-width: 993px) and (max-width: 1140px) {
    .nav-right a.btn-auth-trigger[href*="ko-fi"] { display: none; }
}

/* --- APPLICATION INSTALLABLE (PWA) --- */
.pwa-install[hidden] { display: none !important; }

/* --- FENÊTRES NATIVES <dialog> (modern-web-guidance : dialog, prevent-page-scroll-under-modal-dialog) ---
   La <dialog> couvre tout l'écran et sert elle-même de fond assombri (classe .modal-overlay de chaque page) ;
   le navigateur gère le focus, la touche Échap et rend le reste de la page inerte. */
dialog.hrn-dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    box-sizing: border-box;
    color: inherit;
    overflow: auto;
}
dialog.hrn-dialog[open] { display: flex; }
dialog.hrn-dialog:modal { overscroll-behavior: contain; }   /* le défilement ne passe pas à la page derrière */
dialog.hrn-dialog::backdrop {
    background: transparent;   /* le fond assombri est la fenêtre elle-même */
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Texte lu par les lecteurs d'écran mais invisible à l'écran (libellés des champs) */
/* Lien « Aller au contenu » : caché jusqu'au premier Tab */
.skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 5000;
    background: var(--color-dark); color: var(--color-light); padding: 10px 14px;
    font: 600 0.8rem var(--font-sans); text-decoration: none; transition: top 0.15s ease;
}
.skip-link:focus { top: 8px; }
[tabindex="-1"]:focus { outline: none; }
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Messages affichés dans une fenêtre ouverte (à la place des notifications en bas de page) */
.dialog-msg:empty { display: none; }
.dialog-msg {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: 0.8rem;
    line-height: 1.45;
    text-align: left;
    background: var(--color-sand);
    border-left: 4px solid #9CA3AF;
    color: var(--text-main);
}
.dialog-msg.success { border-left-color: #6A8C47; }
.dialog-msg.error { border-left-color: #C0392B; }

/* --- RECHERCHE GLOBALE (Ctrl + K) --- */
.search-trigger svg { width: 17px; height: 17px; }
dialog.gsearch { background: rgba(26, 26, 26, 0.6); backdrop-filter: blur(3px); align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.gsearch-box { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--color-border); box-shadow: 0 20px 60px rgba(0,0,0,0.35); padding: 14px; max-height: 75vh; display: flex; flex-direction: column; }
.gsearch-form { display: flex; gap: 8px; }
.gsearch-form input { flex: 1; margin: 0; padding: 12px 14px; font: inherit; font-size: 1rem; border: 1px solid var(--color-border); background: var(--surface); color: var(--text-main); outline: none; }
.gsearch-form input:focus { border-color: var(--color-dark); }
.gsearch-close { background: none; border: 1px solid var(--color-border); color: var(--text-main); cursor: pointer; width: 44px; font-size: 1rem; }
.gsearch-results { list-style: none; margin: 10px 0 0; padding: 0; overflow-y: auto; }
.gsearch-results a { display: flex; align-items: center; gap: 12px; padding: 8px; text-decoration: none; color: var(--text-main); border-bottom: 1px solid var(--color-sand); }
.gsearch-results a:hover, .gsearch-results a:focus-visible { background: var(--color-sand); outline: none; }
.gsearch-results img { width: 44px; height: 44px; object-fit: contain; background: var(--color-sand); flex-shrink: 0; }
.gsearch-results strong { display: block; font-size: 0.88rem; }
.gsearch-results small { display: block; font-size: 0.74rem; color: var(--text-sub); }
.gsearch-empty { padding: 14px 8px; color: var(--text-sub); font-size: 0.85rem; }
.gsearch-hint { margin: 10px 0 0; font-size: 0.7rem; color: var(--text-sub); }
@media (max-width: 992px) { .nav-right .search-trigger { display: none; } }

/* --- CHOIX DE LA LANGUE (FR · EN · ES · DE · 中文) --- */
.lang-select {
    font: 600 0.75rem var(--font-sans);
    letter-spacing: 0.06em;
    color: var(--color-dark);
    background: var(--color-sand);
    border: 1px solid var(--color-border);
    padding: 7px 26px 7px 10px;
    cursor: pointer;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%;
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
    height: 34px;
}
.lang-select:hover, .lang-select:focus-visible { border-color: var(--color-dark); }
@media (max-width: 992px) { .nav-right .lang-select { display: none; } }
/* Chinois : la police Poppins n'a pas les caractères chinois, le système prend le relais */
:root:lang(zh) body { font-family: 'Poppins', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif; }
