/* ============================================================
   Allons-y ! — gamified French learning site
   ============================================================ */
:root {
  --blue: #0055A4;      /* tricolore */
  --red: #EF4135;
  --green: #58cc02;
  --green-dark: #46a302;
  --sky: #1cb0f6;
  --orange: #ff9600;
  --purple: #ce82ff;
  --ink: #3c3c46;
  --muted: #8a8a97;
  --line: #e5e5ec;
  --bg: #f6f7fb;
  --card: #ffffff;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}
h1 { font-size: 1.6rem; font-weight: 900; margin: 0.2em 0 0.3em; }
h2 { font-size: 1.2rem; font-weight: 800; margin: 1.2em 0 0.5em; }
.muted { color: var(--muted); margin-top: 0; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- Buttons (chunky, game-like) -------------- */
.btn {
  border: 0; border-radius: 14px; font-weight: 800;
  padding: 10px 18px; background: #e9e9f0; color: var(--ink);
  box-shadow: 0 4px 0 #d0d0da; transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d0d0da; }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); }
.btn.primary:disabled { background: #cfcfd8; box-shadow: 0 4px 0 #b9b9c4; cursor: not-allowed; }
.btn.google { background: #fff; border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn.big { width: 100%; padding: 14px; font-size: 1.05rem; }
.btn.tiny { padding: 5px 10px; font-size: .8rem; border-radius: 10px; box-shadow: 0 2px 0 #d0d0da; }
.btn.tiny.danger { background: #ffe3e0; color: #c0392b; box-shadow: 0 2px 0 #f3c1bc; }

/* ---------------- Demo banner ------------------------------ */
.demo-banner {
  background: #fff5d7; border-bottom: 2px solid #f2d675;
  padding: 8px 16px; font-size: .88rem; text-align: center;
}
.demo-banner code { background: #fdeaa8; padding: 1px 6px; border-radius: 6px; }

/* ---------------- Auth screen ------------------------------ */
.screen-auth {
  min-height: 92vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(0,85,164,.10), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(239,65,53,.10), transparent 40%),
    var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--card);
  border-radius: 24px; padding: 32px; box-shadow: 0 20px 60px rgba(60,60,70,.12);
}
.auth-logo { font-size: 3rem; text-align: center; }
.auth-title { text-align: center; margin: 0; font-size: 2rem; font-weight: 900;
  background: linear-gradient(90deg, var(--blue), var(--red)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-sub { text-align: center; color: var(--muted); margin-top: 6px; }
.auth-tabs { display: flex; background: #eef0f6; border-radius: 12px; padding: 4px; margin: 18px 0 14px; }
.auth-tab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 800; color: var(--muted); }
.auth-tab.active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
#auth-form label { display: block; font-size: .8rem; font-weight: 800; color: var(--muted); margin: 10px 2px 4px; }
#auth-form input {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px;
  font-family: inherit; font-size: 1rem; outline: none;
}
#auth-form input:focus { border-color: var(--sky); }
.auth-error { color: var(--red); font-size: .85rem; min-height: 1.2em; margin: 8px 2px; font-weight: 700; }
#btn-google { margin-top: 10px; }
.demo-creds { margin-top: 18px; border-top: 2px dashed var(--line); padding-top: 12px; text-align: center; }
.demo-creds p { font-size: .78rem; color: var(--muted); margin: 0 0 6px; font-weight: 700; }
.demo-cred { border: 0; background: #eef6ff; color: var(--blue); border-radius: 10px; padding: 6px 10px; margin: 3px; font-size: .8rem; font-weight: 700; }
.demo-cred:hover { background: #dceeff; }

/* ---------------- App header ------------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--card); border-bottom: 2px solid var(--line);
  padding: 10px 20px;
}
.logo { font-weight: 900; font-size: 1.2rem; color: var(--blue); }
.app-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-btn {
  border: 0; background: transparent; padding: 9px 14px; border-radius: 12px;
  font-weight: 800; color: var(--muted); font-size: .95rem;
}
.nav-btn:hover { background: #f0f2f8; }
.nav-btn.active { background: #e7f4ff; color: var(--sky); }
.hdr-right { display: flex; align-items: center; gap: 12px; }
.hdr-stat { font-weight: 800; font-size: .95rem; }
.hdr-user { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--blue), var(--sky)); color: #fff; font-weight: 900;
}

.app-main { max-width: 1000px; margin: 0 auto; padding: 24px 20px 80px; }

/* ---------------- Learning path ---------------------------- */
.group { margin-bottom: 28px; }
.group.locked { opacity: .55; filter: grayscale(.4); }
.group-head {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 2px solid var(--line); border-left: 8px solid var(--gc);
  border-radius: var(--radius); padding: 14px 18px;
}
.group-head h2 { margin: 0; font-size: 1.15rem; }
.group-head h2 small { color: var(--muted); font-weight: 700; }
.group-head > div { flex: 1; }
.group-icon { font-size: 1.8rem; }
.group-count { font-weight: 900; color: var(--gc); }
.group-lock { font-size: 1.3rem; }
.group-progress { height: 8px; background: #edeef4; border-radius: 6px; margin-top: 8px; overflow: hidden; }
.group-bar { height: 100%; background: var(--gc); border-radius: 6px; transition: width .4s; }

.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.unit-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  background: var(--card); border: 2px solid var(--line); border-bottom: 5px solid var(--line);
  border-radius: var(--radius); padding: 18px 12px 12px; transition: transform .1s, border-color .1s;
}
.unit-card:not(.locked):hover { transform: translateY(-3px); border-color: var(--gc); }
.unit-card.done { border-color: var(--gc); }
.unit-card.locked { opacity: .55; cursor: not-allowed; }
.unit-icon { font-size: 2rem; }
.unit-title { font-weight: 800; font-size: .92rem; min-height: 2.4em; }
.unit-stars { color: var(--orange); font-size: 1.05rem; letter-spacing: 2px; }
.unit-score { font-size: .78rem; color: var(--muted); font-weight: 700; }

/* ---------------- Lesson overlay --------------------------- */
.lesson-overlay {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; flex-direction: column; padding: 18px clamp(16px, 8vw, 120px) 30px;
  overflow-y: auto;
}
.lesson-top { display: flex; align-items: center; gap: 14px; }
.lesson-track { flex: 1; height: 14px; background: #e5e6ee; border-radius: 10px; overflow: hidden; }
.lesson-progress { height: 100%; width: 0; background: var(--green); border-radius: 10px; transition: width .4s; }
.lesson-combo { font-weight: 900; color: var(--orange); min-width: 60px; text-align: right; }
.lesson-title { text-align: center; color: var(--muted); font-size: 1rem; margin: 14px 0 4px; }
.lesson-question { flex: 1; max-width: 640px; margin: 0 auto; width: 100%; padding-top: 8px; }
.q-text { font-size: 1.3rem; font-weight: 800; }
.q-hint { color: var(--muted); font-size: .9rem; margin-top: -6px; }

.opts { display: grid; gap: 10px; margin-top: 14px; }
.opt {
  text-align: left; background: var(--card); border: 2px solid var(--line); border-bottom: 4px solid var(--line);
  padding: 14px 16px; border-radius: 14px; font-size: 1.05rem; font-weight: 700;
}
.opt:hover:not(:disabled) { border-color: var(--sky); }
.opt.sel { border-color: var(--sky); background: #e7f4ff; }
.opt:disabled { cursor: default; }

.fill-wrap { margin-top: 14px; }
.fill-input {
  width: 100%; padding: 14px 16px; font-size: 1.15rem; font-family: inherit; font-weight: 700;
  border: 2px solid var(--line); border-radius: 14px; outline: none;
}
.fill-input:focus { border-color: var(--sky); }
.accents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.accent {
  border: 2px solid var(--line); background: var(--card); border-radius: 8px;
  min-width: 34px; padding: 5px 0; font-size: 1rem; font-weight: 800;
}
.accent:hover:not(:disabled) { border-color: var(--sky); background: #e7f4ff; }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.match-item {
  background: var(--card); border: 2px solid var(--line); border-bottom: 4px solid var(--line);
  padding: 12px; border-radius: 12px; font-weight: 700; font-size: .98rem;
}
.match-item.sel { border-color: var(--sky); background: #e7f4ff; }
.match-item.ok { border-color: var(--green); background: #eaffdd; color: var(--green-dark); cursor: default; }
.match-item.bad { border-color: var(--red); background: #ffe9e7; animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px);} 75% { transform: translateX(4px);} }

.order-wrap { margin-top: 14px; }
.order-answer {
  min-height: 58px; border: 2px dashed var(--line); border-radius: 14px; background: #fff;
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; align-items: center;
}
.order-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: center; }
.chip {
  border: 2px solid var(--line); border-bottom: 4px solid var(--line); background: var(--card);
  padding: 8px 14px; border-radius: 12px; font-weight: 800; font-size: 1rem;
}
.chip:hover:not(:disabled) { border-color: var(--purple); }

.feedback {
  max-width: 640px; margin: 14px auto 0; width: 100%;
  border-radius: 14px; padding: 14px 18px; font-size: 1.05rem;
}
.feedback.good { background: #d7ffb8; color: #3f8f00; }
.feedback.bad { background: #ffdfdc; color: #c0392b; }

.lesson-actions { max-width: 640px; margin: 16px auto 0; width: 100%; display: flex; gap: 10px; }

/* Result screen */
.result { text-align: center; padding-top: 4vh; }
.result-stars { font-size: 3.4rem; letter-spacing: 8px; }
.result-score { font-size: 1.2rem; }
.result-xp { color: var(--muted); font-weight: 700; }
.result-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.badge-pill { background: #fff3d6; border: 2px solid #ffd66e; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: .9rem; }
.result-retry { color: var(--red); font-weight: 700; }
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }

/* Confetti */
.confetti-layer { pointer-events: none; position: fixed; inset: 0; overflow: hidden; }
.confetti-layer i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; opacity: .9;
  animation: fall 2.8s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .7; }
}

/* ---------------- Leaderboard ------------------------------ */
.lb-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 18px; margin-bottom: 8px; font-weight: 800;
}
.lb-row.me { border-color: var(--sky); background: #eff8ff; }
.lb-rank { width: 40px; font-size: 1.1rem; }
.lb-name { flex: 1; }
.lb-xp { color: var(--orange); }

/* ---------------- Profile ---------------------------------- */
.profile-stats, .admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0; }
.stat-card {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.stat-card span { font-size: 1.6rem; }
.stat-card strong { font-size: 1.5rem; }
.stat-card small { color: var(--muted); font-weight: 700; }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.badge-card {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 4px;
}
.badge-card.off { opacity: .38; filter: grayscale(1); }
.badge-icon { font-size: 2rem; }
.badge-card small { color: var(--muted); }

/* ---------------- Admin ------------------------------------ */
.admin-groups { display: grid; gap: 8px; }
.admin-group-row { display: flex; align-items: center; gap: 12px; }
.agr-label { width: 180px; font-weight: 800; font-size: .9rem; }
.agr-track { flex: 1; height: 12px; background: #e8e9f0; border-radius: 8px; overflow: hidden; }
.agr-bar { height: 100%; border-radius: 8px; transition: width .4s; }
.agr-pct { width: 48px; text-align: right; font-weight: 800; font-size: .9rem; }

.admin-table-wrap { overflow-x: auto; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 760px; }
.admin-table th {
  text-align: left; padding: 12px 14px; background: #f2f3f9; color: var(--muted);
  font-size: .76rem; text-transform: uppercase; letter-spacing: .5px;
}
.admin-table td { padding: 10px 14px; border-top: 1px solid var(--line); }
.role-pill { padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; background: #e8f8e0; color: var(--green-dark); }
.role-pill.admin { background: #f3e8ff; color: #8f4bd1; }
.admin-actions { white-space: nowrap; }
.admin-actions .btn { margin-right: 4px; }

.detail-card { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px; margin-top: 16px; }
.detail-card h4 { margin: 14px 0 6px; }
.detail-units { display: grid; gap: 6px; }
.detail-unit {
  display: flex; justify-content: space-between; gap: 10px; font-size: .88rem;
  background: #f7f8fc; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 700;
}
.detail-unit.ok { background: #f0ffe4; color: var(--ink); }

/* ---------------- Listening / Speaking --------------------- */
.listen-controls { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.tts-btn {
  background: #e7f4ff; border: 2px solid var(--sky); border-bottom-width: 4px;
  color: var(--sky); border-radius: 14px; padding: 12px 18px; font-weight: 800; font-size: 1rem;
}
.tts-btn:hover:not(:disabled) { background: #d8eeff; }
.tts-btn.slow { border-color: var(--line); color: var(--muted); background: var(--card); }
.mic-btn {
  background: #ffe9e7; border: 2px solid var(--red); border-bottom-width: 4px;
  color: var(--red); border-radius: 14px; padding: 12px 18px; font-weight: 800; font-size: 1rem;
}
.mic-btn.rec { animation: recpulse 1s infinite; }
@keyframes recpulse { 50% { background: var(--red); color: #fff; } }
.speak-target {
  font-size: 1.25rem; font-weight: 800; background: var(--card);
  border: 2px dashed var(--line); padding: 14px 18px; border-radius: 14px; margin: 14px 0 0;
}
.transcript { color: var(--muted); font-weight: 700; min-height: 1.3em; }
.skip-link {
  background: none; border: none; color: var(--muted); text-decoration: underline;
  font-size: .85rem; font-weight: 700; padding: 4px 0; margin-top: 6px;
}
.skip-link:hover { color: var(--ink); }
.feedback.skip { background: #eef0f6; color: var(--muted); }
.feedback .model { margin-top: 10px; font-size: .95rem; border-top: 1px dashed rgba(0,0,0,.15); padding-top: 8px; }

/* ---------------- Reading passages ------------------------- */
.passage {
  background: #fffdf3; border: 2px solid #f2e3b3; border-radius: 14px;
  padding: 14px 18px; margin-bottom: 14px;
}
.passage-label {
  font-size: .72rem; font-weight: 900; color: #b08a2e;
  text-transform: uppercase; letter-spacing: .6px;
}
.passage p { margin: 6px 0 0; line-height: 1.6; font-size: 1.02rem; }

/* ---------------- Writing ---------------------------------- */
.write-input {
  width: 100%; padding: 14px 16px; font-size: 1.05rem; font-family: inherit; font-weight: 600;
  border: 2px solid var(--line); border-radius: 14px; outline: none; resize: vertical; margin-top: 14px;
}
.write-input:focus { border-color: var(--sky); }
.write-meta { color: var(--muted); font-weight: 800; font-size: .85rem; margin-top: 8px; }
.crit { list-style: none; padding: 0; margin: 8px 0 0; }
.crit li { font-size: .9rem; font-weight: 700; color: var(--muted); margin: 4px 0; }

/* ---------------- Responsive ------------------------------- */
@media (max-width: 640px) {
  .app-header { gap: 8px; }
  .app-nav { order: 3; width: 100%; justify-content: space-between; }
  .hdr-user span:not(.avatar) { display: none; }
  .match-grid { gap: 8px; }
  .q-text { font-size: 1.12rem; }
  .agr-label { width: 110px; }
}
