/* =====================================================
   Mot Mystère — Design tokens
   Palette "carnet d'enquête" : papier ivoire, encre indigo,
   cachet de cire bordeaux. Typo display Fraunces + UI Public Sans
   + Space Mono pour les cases/lettres (esprit machine à écrire).
   ===================================================== */
:root {
    --papier: #F5F1E6;
    --papier-fonce: #EAE3D2;
    --encre: #232B4D;
    --encre-claire: #4A5578;
    --sceau: #8C2F39;
    --sceau-clair: #A8434E;
    --correct: #4C7A51;
    --present: #B08726;
    --absent: #B6AF9A;
    --absent-texte: #6F6A5A;
    --ombre: rgba(35, 43, 77, 0.16);

    --font-display: 'Fraunces', Georgia, serif;
    --font-ui: 'Public Sans', system-ui, -apple-system, sans-serif;
    --font-case: 'Space Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--papier);
    color: var(--encre);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- En-tête ---------- */
.site-header {
    width: 100%;
    max-width: 480px;
    text-align: center;
    padding: 28px 20px 16px;
    border-bottom: 1px solid var(--papier-fonce);
}

.eyebrow {
    font-family: var(--font-case);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sceau);
    margin: 0 0 6px;
}

.logo {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 2.4rem;
    margin: 0;
    letter-spacing: -0.01em;
}

.tagline {
    font-size: 0.95rem;
    color: var(--encre-claire);
    margin: 8px 0 14px;
}

.header-actions {
    display: flex;
    justify-content: center;
    gap: 18px;
}

.btn-lien {
    background: none;
    border: none;
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--encre);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    padding: 6px 2px;
}
.btn-lien:hover, .btn-lien:focus-visible { color: var(--sceau); }

/* ---------- Message d'état ---------- */
.message {
    min-height: 1.4em;
    margin: 16px 0 4px;
    font-weight: 600;
    text-align: center;
    padding: 0 16px;
}
.message--erreur { color: var(--sceau); }
.message--succes { color: var(--correct); }

/* ---------- Grille de jeu ---------- */
main {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px 24px;
    flex: 1;
}

.grille {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 8px;
    margin: 12px 0 24px;
    width: 100%;
    max-width: 340px;
}

.ligne {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.case {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-case);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--encre);
    background: #fff;
    border: 2px solid var(--papier-fonce);
    border-radius: 6px;
    text-transform: uppercase;
    transition: transform 0.15s ease;
}

.case--remplie {
    border-color: var(--encre-claire);
    animation: pop 0.1s ease;
}

.case--correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.case--present { background: var(--present); border-color: var(--present); color: #fff; }
.case--absent  { background: var(--absent); border-color: var(--absent); color: var(--absent-texte); }

.case--retournee {
    animation: retourner 0.5s ease forwards;
}

@keyframes pop {
    0% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes retourner {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

.case--secouee { animation: secouer 0.4s ease; }
@keyframes secouer {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
}

/* ---------- Clavier ---------- */
.clavier {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.rangee-clavier {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.touche {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.85rem;
    border: none;
    border-radius: 6px;
    background: var(--papier-fonce);
    color: var(--encre);
    padding: 0;
    height: 52px;
    min-width: 34px;
    flex: 1;
    max-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 0 var(--ombre);
    transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.touche:active { transform: translateY(2px); box-shadow: none; }

.touche--large { max-width: 68px; font-size: 0.7rem; letter-spacing: 0.02em; }

.touche--correct { background: var(--correct); color: #fff; }
.touche--present { background: var(--present); color: #fff; }
.touche--absent  { background: var(--absent-texte); color: #fff; opacity: 0.7; }

/* ---------- Pieds de page ---------- */
.site-footer {
    width: 100%;
    text-align: center;
    padding: 18px;
    font-size: 0.8rem;
    color: var(--encre-claire);
}
.site-footer a { color: var(--encre-claire); }

/* ---------- Emplacements publicitaires ---------- */
.ad-slot {
    width: 100%;
    max-width: 480px;
    min-height: 90px;
    margin: 8px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Modales ---------- */
.modale {
    position: fixed;
    inset: 0;
    background: rgba(35, 43, 77, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
}
.modale[hidden] { display: none; }

.modale-contenu {
    background: var(--papier);
    border-radius: 12px;
    padding: 28px 24px 24px;
    max-width: 380px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.modale-contenu h2 {
    font-family: var(--font-display);
    font-size: 1.4rem;
    margin-top: 0;
}

.resultat-mot {
    font-weight: 700;
    font-size: 0.95rem;
    padding: 10px 12px;
    border-radius: 8px;
    margin: 0 0 8px;
}
.resultat-mot--gagne { background: rgba(76, 122, 81, 0.15); color: var(--correct); }
.resultat-mot--perdu { background: rgba(140, 47, 57, 0.1); color: var(--sceau); }

.modale-fermer {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--encre-claire);
}

.legende { list-style: none; padding: 0; margin: 16px 0; }
.legende li { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.9rem; }

.case-exemple {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-family: var(--font-case);
    font-weight: 700;
    border-radius: 4px;
    color: #fff;
    flex-shrink: 0;
}
.case-exemple--correct { background: var(--correct); }
.case-exemple--present { background: var(--present); }
.case-exemple--absent  { background: var(--absent-texte); }

/* ---------- Statistiques ---------- */
.stats-grille {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    text-align: center;
    margin: 16px 0;
}
.stat-valeur {
    display: block;
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 600;
}
.stat-label {
    display: block;
    font-size: 0.68rem;
    color: var(--encre-claire);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* ---------- Signature : le sceau de partage ---------- */
#bloc-partage {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--papier-fonce);
}

.sceau {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--sceau-clair), var(--sceau) 70%);
    border: none;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(140, 47, 57, 0.35);
    transition: transform 0.15s ease;
    position: relative;
}
.sceau::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px dashed rgba(255,255,255,0.5);
    border-radius: 50%;
}
.sceau:active { transform: scale(0.92) rotate(-4deg); }
.sceau:hover, .sceau:focus-visible { transform: scale(1.04); }

.partage-confirmation {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--correct);
    font-weight: 600;
    min-height: 1.2em;
}

/* ---------- Bannière de consentement cookies ---------- */
.banniere-cookies {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: var(--encre);
    color: #fff;
    padding: 16px 20px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.2);
}
.banniere-cookies[hidden] { display: none; }

.banniere-cookies-contenu {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
}

.banniere-cookies-titre {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    margin: 0;
    flex-basis: 100%;
}

#banniere-cookies-texte {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    flex: 1 1 260px;
    color: #E8E5DA;
}
#banniere-cookies-texte a { color: #fff; text-decoration: underline; }

.banniere-cookies-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.btn-cookie {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 10px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
}

.btn-cookie--principal { background: var(--sceau); color: #fff; }
.btn-cookie--principal:hover, .btn-cookie--principal:focus-visible { background: var(--sceau-clair); }

.btn-cookie--secondaire { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.5); }
.btn-cookie--secondaire:hover, .btn-cookie--secondaire:focus-visible { background: rgba(255,255,255,0.1); }

.btn-lien--footer {
    font-size: inherit;
    font-weight: 400;
    text-decoration: underline;
    color: inherit;
}

@media (max-width: 420px) {
    .banniere-cookies-actions { width: 100%; }
    .btn-cookie { flex: 1; }
}
/* ---------- Accessibilité focus ---------- */
button:focus-visible {
    outline: 3px solid var(--sceau);
    outline-offset: 2px;
}

/* ---------- Responsive ---------- */
@media (max-width: 380px) {
    .logo { font-size: 2rem; }
    .case { font-size: 1.3rem; }
    .touche { height: 46px; font-size: 0.78rem; }
}
