/* ============================================================
   Leitner — TerraMathica · feuille de style (mobile-first)
   ============================================================ */

:root {
    --green-900: #1b4332;
    --green-700: #2d6a4f;
    --green-500: #40916c;
    --green-300: #95d5b2;
    --green-100: #d8f3dc;
    --sand:      #f6f3ec;
    --surface:   #ffffff;
    --ink:       #1f2421;
    --muted:     #6b7280;
    --accent:    #e07a5f;
    --accent-d:  #c75b41;
    --danger:    #c0392b;
    --ok:        #2e7d32;
    --border:    #e4e0d6;
    --radius:    14px;
    --shadow:    0 6px 20px rgba(27, 67, 50, .08);
    --maxw:      980px;
    font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--sand);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--green-700); }

/* ---------- En-tête ---------- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
    background: var(--green-900);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: #fff; font-weight: 700; }
.brand-mark { font-size: 1.4rem; color: var(--green-300); }
.brand-text small { color: var(--green-300); font-weight: 500; }
.site-nav { display: flex; align-items: center; gap: .6rem; }
.nav-user { font-size: .85rem; opacity: .85; }

/* ---------- Zone principale ---------- */
.site-main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* ---------- Pied de page ---------- */
.site-footer {
    background: #fff;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .82rem;
    text-align: center;
    padding: 1rem;
}

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: .6rem 1.1rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-500); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-d); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-lg { padding: .8rem 1.5rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Cartes / panneaux ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.card h2 { margin-top: 0; }

.grid { display: grid; gap: 1rem; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Hero ---------- */
.hero {
    background: linear-gradient(135deg, var(--green-700), var(--green-900));
    color: #fff;
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    margin-bottom: 1.5rem;
}
.hero h1 { margin: 0 0 .5rem; font-size: clamp(1.6rem, 4vw, 2.4rem); }
.hero p { margin: 0 0 1.2rem; max-width: 60ch; opacity: .95; }
.hero .btn-row { display: flex; flex-wrap: wrap; gap: .7rem; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; margin-bottom: .25rem; }
.input, select.input, textarea.input {
    width: 100%;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: #fff;
}
.input:focus { outline: 2px solid var(--green-300); border-color: var(--green-500); }
.form-msg { min-height: 1.2em; color: var(--danger); font-size: .9rem; }
.hint { color: var(--muted); font-size: .85rem; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--green-100); color: var(--green-900); }
.notice { border-left: 4px solid var(--accent); background: #fff7f3; padding: .8rem 1rem; border-radius: 8px; }

.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li { padding: .35rem 0 .35rem 1.6rem; position: relative; }
.feature-list li::before { content: "✓"; position: absolute; left: 0; color: var(--green-500); font-weight: 700; }

.module-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.module-row:last-child { border-bottom: 0; }
.status-soon { color: var(--muted); font-size: .8rem; }
.status-ready { color: var(--ok); font-size: .8rem; font-weight: 600; }

/* ============================================================
   Flashcard recto/verso animée (réutilisée par le module de révision)
   ============================================================ */
.flashcard {
    perspective: 1400px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
}
.flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 300px;
    transition: transform .55s cubic-bezier(.2, .7, .2, 1);
    transform-style: preserve-3d;
    cursor: pointer;
}
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
    position: absolute;
    inset: 0;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}
.flashcard-face .face-tag {
    position: absolute; top: .8rem; left: .8rem;
    font-size: .72rem; letter-spacing: 1px; text-transform: uppercase;
    color: var(--muted);
}
.flashcard-front { background: #fff; }
.flashcard-back { transform: rotateY(180deg); background: var(--green-100); }
.flashcard-face .card-text { font-size: 1.3rem; }
.flashcard-face img, .flashcard-face video { max-width: 100%; max-height: 230px; border-radius: 8px; }
.flashcard-face iframe { width: 100%; height: 200px; border: 0; border-radius: 8px; }
.face-content { width: 100%; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.flip-hint { text-align: center; color: var(--muted); font-size: .85rem; margin-top: .6rem; }

@media (prefers-reduced-motion: reduce) {
    .flashcard-inner { transition: none; }
}

/* ---------- Utilitaires ---------- */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.list-item { padding: .6rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.list-item:last-child { border-bottom: 0; }
.pin-reveal .pin-code { font-size: 1.6rem; font-weight: 800; letter-spacing: 4px; color: var(--green-900); }
.muted { color: var(--muted); }
.editing { display: grid; gap: .5rem; width: 100%; }
.back-link { display: inline-block; margin-bottom: .5rem; }

/* ---------- Révision (élève) ---------- */
.review { max-width: 560px; margin: 0 auto; }
.review-top { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.progress { flex: 1; height: 8px; background: var(--green-100); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--green-500); transition: width .3s ease; }
.answer-actions { display: flex; gap: .8rem; margin-top: 1.2rem; }
.answer-actions .btn { flex: 1; }
.flashcard { cursor: pointer; }

/* ---------- Graphique de progression (élève) ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 1.2rem; margin-top: .5rem; font-size: .85rem; color: var(--muted); }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }
.dot-ok { background: var(--green-500); }
.dot-ko { background: var(--accent); }
.boxes-wrap { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
.boxes-chart { flex: 0 0 auto; }
.boxes-legend { flex-direction: column; gap: .4rem; align-items: flex-start; }

/* ---------- Navigation élève : burger, tiroir, tuiles ---------- */
.header-left { display: flex; align-items: center; gap: .6rem; }
.burger { background: transparent; border: 1px solid rgba(255,255,255,.45); color: #fff; border-radius: 8px; font-size: 1.15rem; line-height: 1; padding: .35rem .6rem; cursor: pointer; }
.burger:hover { background: rgba(255,255,255,.12); }

.drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
.drawer { position: fixed; top: 0; left: 0; height: 100%; width: 290px; max-width: 86vw; background: var(--surface); box-shadow: 2px 0 18px rgba(0,0,0,.18); z-index: 30; padding: 1rem 1rem 2rem; overflow-y: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.drawer h3 { margin: 1.1rem 0 .4rem; }

/* ---------- Fenêtre modale (gestion d'un jeu perso) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 40; }
.modal {
    position: fixed; z-index: 45;
    left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(640px, 94vw); max-height: 88vh; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .3); padding: 1.1rem 1.2rem 1.3rem;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .4rem; }
.modal-head strong { font-size: 1.1rem; }

.tiles { display: grid; grid-template-columns: 1fr; gap: .8rem; }
@media (min-width: 560px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; transition: transform .06s ease, box-shadow .15s ease; }
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(27,67,50,.12); }
.tile h3 { margin: .35rem 0 .2rem; }
.tile-due { display: inline-block; margin-top: .5rem; }
.tile .badge { margin-left: .3rem; }

/* ---------- Parcours des cartes : vue recto | verso côte à côte ---------- */
.subject-group > h3 { margin: 1.3rem 0 .5rem; padding-bottom: .2rem; border-bottom: 2px solid var(--green-100); }
.deck-group > h4 { margin: .9rem 0 .4rem; color: var(--green-700); }

.browse-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: .8rem; margin-bottom: .7rem; }
.browse-card.is-selected { outline: 2px solid var(--green-500); }
.browse-card.is-owned { border-color: var(--green-500); background: var(--green-100); }
.browse-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; flex-wrap: wrap; }
.browse-head label { display: flex; align-items: center; gap: .45rem; font-weight: 600; cursor: pointer; }
.browse-head .owned-badge { margin-left: auto; background: var(--green-500); color: #fff; }
.swatch-owned { display: inline-block; width: 14px; height: 14px; border-radius: 3px; background: var(--green-100); border: 1px solid var(--green-500); }
.browse-actions { margin-top: .6rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.card-pair { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 560px) { .card-pair { grid-template-columns: 1fr 1fr; } }
.pair-face { border: 1px solid var(--border); border-radius: 10px; padding: .55rem .7rem; background: #fff; }
.pair-face.is-verso { background: var(--green-100); }
.pair-face .face-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: .25rem; }
.pair-face .pair-text { white-space: pre-wrap; }
.pair-face img { max-width: 100%; max-height: 130px; border-radius: 6px; display: block; margin-top: .3rem; }
