/* =========================================================================
 * homework.css — Devoirs par matière (enfant + fiche parent) et poésie
 * Largeur téléphone → tablette : aucun défilement horizontal.
 * ========================================================================= */

/* ---- Icône « Devoirs » du tableau de bord enfant ---- */
.hw-home-card { position: relative; }
.hw-home-card.has-new { background: linear-gradient(135deg, #e0f2fe, #ede9fe); }
.hw-count {
  position: absolute; top: -8px; right: -6px; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 999px;
  display: grid; place-items: center; background: var(--danger); color: #fff; font-weight: 700; font-size: 1.05rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .15); border: 3px solid #fff;
}

/* ---- Onglets par matière ---- */
.hw-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.hw-tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 8px 16px;
  border-radius: 999px; background: #fff; color: var(--ink); text-decoration: none; font-weight: 600;
  box-shadow: var(--shadow); border: 3px solid transparent;
}
.hw-tab:active { transform: scale(.97); }
.hw-tab.active { background: var(--primary); color: #fff; border-color: var(--primary-d); }
.hw-tab-icon { font-size: 1.35rem; }
.hw-tab-count {
  min-width: 26px; height: 26px; padding: 0 7px; border-radius: 999px; display: grid; place-items: center;
  background: var(--danger); color: #fff; font-size: .85rem; font-weight: 700;
}
.hw-tab-count.neutral { background: #e7e1f7; color: var(--ink); }
.hw-tab.active .hw-tab-count.neutral { background: rgba(255, 255, 255, .3); color: #fff; }
.hw-practice-tip { margin: -4px 4px 10px; }
.hw-badge.earned { background: #fff3c4; color: #8a5a00; }
.hw-card.state-done { opacity: 1; }
.hw-card.state-done .hw-status small { max-width: 110px; text-align: center; line-height: 1.1; }
.hw-card.state-pending { box-shadow: 0 0 0 3px #ffb703, var(--shadow); }
.hw-card.state-redo { box-shadow: 0 0 0 3px #ff7b00, var(--shadow); }
.hw-list .empty { grid-column: 1 / -1; }

/* ---- Points en attente de correction : en gris, « bientôt validés » ---- */
.pts-pending { display: block; margin-top: 2px; color: #8b88a3; font-weight: 600; font-size: .78rem; white-space: nowrap; }
.kid-points .pts-pending { opacity: .85; color: #6f6c8a; background: rgba(255, 255, 255, .6); border-radius: 99px; padding: 1px 8px; }

/* ---- Famille recomposée : parents liés, cartes grises ---- */
.kid-admin.guest .kid-level, .kid-admin.guest [data-pin], .kid-admin.guest [data-del] { display: none; }
.hw-meta.by { color: #6d3fe0; font-weight: 600; }
.shop-card.cards-card.locked { filter: grayscale(1); opacity: .62; cursor: default; border: 0; font: inherit; text-align: left; }
.cards-soon { text-align: center; padding: 40px 20px; filter: grayscale(1); }
.soon-icon { font-size: 5rem; opacity: .6; }
.parent-link { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.parent-link:first-of-type { border-top: 0; }
.parent-link .perms { display: flex; flex-wrap: wrap; gap: 6px 14px; width: 100%; font-size: .9rem; }
.invite-code { font-size: 2.2rem; letter-spacing: 6px; font-weight: 700; color: #6d3fe0; text-align: center; padding: 10px; background: #f3effd; border-radius: 14px; user-select: all; }

/* ---- Devoir obligatoire ---- */
.hw-badge.mand { background: #fee2e2; color: #991b1b; }

/* ---- Entraînement (devoir déjà réussi) ---- */
.practice-banner {
  margin: 0 0 10px; padding: 10px 16px; border-radius: 16px; background: #e0f2fe; color: #075985;
  font-weight: 600; text-align: center;
}
.is-practice .ex-coins { visibility: hidden; }

/* ---- Poésie : lecture ---- */
.st-poem { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 8px 4px 24px; }
.poem-title { margin: 0; }
.poem-photo-wrap {
  width: 100%; max-width: 900px; max-height: max(220px, calc(100vh - 400px)); overflow: auto; border-radius: 18px; background: #fff;
  box-shadow: var(--shadow); border: 3px solid var(--line); -webkit-overflow-scrolling: touch;
}
.poem-photo-wrap.zoom { max-height: none; }
.poem-photo { display: block; width: 100%; height: auto; cursor: zoom-in; background: #fff; }
.poem-photo-wrap.zoom .poem-photo { cursor: zoom-out; }
.poem-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.poem-actions .btn { max-width: 100%; }
.st-waiting .sent-icon, .st-practice-menu .sent-icon { font-size: 4rem; }

/* ---- Poésie : récitation ---- */
.rec-big {
  width: min(62vw, 230px); aspect-ratio: 1; border-radius: 50%; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: radial-gradient(circle at 35% 30%, #ff7b9c, #e11d48); color: #fff;
  box-shadow: 0 10px 0 #9f1239, 0 20px 36px rgba(225, 29, 72, .35); transition: transform .1s;
}
.rec-big:active { transform: translateY(6px); box-shadow: 0 4px 0 #9f1239, 0 10px 20px rgba(225, 29, 72, .3); }
.rec-big span { font-size: clamp(3rem, 14vw, 5rem); line-height: 1; }
.rec-big b { font-size: clamp(1.2rem, 5vw, 1.7rem); }
.rec-live { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 1.3rem; }
.rec-dot { width: 22px; height: 22px; border-radius: 50%; background: #e11d48; animation: recPulse 1s infinite; }
.rec-dot.paused { animation: none; background: #9ca3af; }
@keyframes recPulse { 50% { transform: scale(1.35); opacity: .55; } }
.rec-time { font-size: clamp(2rem, 9vw, 3.2rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-audio { width: 100%; max-width: 560px; }
.st-recite .st-instr, .st-recite #recBox { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.st-pending-info { margin: 0; padding: 10px 16px; border-radius: 14px; background: #fff3c4; color: #8a5a00; font-weight: 600; }
.redo-comment { margin: 0; padding: 10px 16px; border-radius: 14px; background: #ffe1cc; color: #b54700; font-weight: 600; }

/* ---- Fiche enfant (parent) ---- */
.fiche-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 10px; }
.fiche-head h1 { margin: 0; }
.fiche-title { margin: 22px 0 6px; }
.parent-tabs .hw-tab { min-height: 46px; box-shadow: none; background: #f3effd; }
.parent-tabs .hw-tab.active { background: var(--primary); }
.fiche-hw { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.fiche-hw:first-of-type { border-top: 0; }
.fiche-hw-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.fiche-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.poem-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.poem-pick .btn { cursor: pointer; }
.poem-preview { padding: 8px; border-radius: 14px; background: #faf8ff; border: 2px dashed var(--line); text-align: center; }
.poem-preview .poem-photo { max-height: 320px; width: auto; max-width: 100%; margin: 0 auto; border-radius: 10px; cursor: default; }

/* ---- Vue d'ensemble « Devoirs » (parent, lecture seule) ---- */
.overview-kid .kid-stat-head { flex-wrap: wrap; }
.overview-tab h3 { margin: 14px 0 4px; font-size: 1.05rem; }
.overview-hw { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.overview-hw b { flex: 1 1 180px; overflow-wrap: anywhere; }

/* ---- Corrections : récitation ---- */
.recite-panel { display: flex; flex-direction: column; gap: 8px; }
.recite-text { width: 100%; max-height: 180px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.review-card .rec-audio { max-width: 100%; }
.recite-hint { margin: 0; padding: 8px 12px; border-radius: 12px; background: #e0f2fe; color: #075985; font-size: .9rem; }
.review-card [data-approve][disabled] { opacity: .45; cursor: not-allowed; }

@media (max-width: 600px) {
  .hw-tab { flex: 1 1 calc(33% - 8px); justify-content: center; padding: 8px 10px; }
  .hw-tab-label { font-size: .95rem; }
  .poem-photo-wrap { max-height: max(200px, calc(100vh - 450px)); }
  .poem-actions .btn { flex: 1 1 100%; }
}

/* ---- Téléphone : la grille de cartes de l'accueil ne doit jamais déborder (colonnes réellement flexibles, texte qui passe à la ligne) ---- */
@media (max-width: 520px) {
  .kid-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kid-top .progress-card { grid-column: 1 / -1; }
  .kid-top .shop-card { min-width: 0; padding: 12px; gap: 8px; font-size: 1rem; }
  .kid-top .shop-card > span:not(.shop-icon):not(.msg-dot):not(.hw-count) { min-width: 0; overflow-wrap: anywhere; }
  .kid-top .shop-icon { font-size: 1.8rem; flex: none; }
}

/* Devoirs archivés (3.14) */
.hw-archived { margin-top: 1.2rem; }
.hw-archived > summary { cursor: pointer; list-style: none; padding: .4rem 0; }
.hw-archived > summary::-webkit-details-marker { display: none; }
.hw-archived .hw-card { opacity: .85; }
.fiche-archived > summary { cursor: pointer; padding: .2rem 0; }
.fiche-archived[open] > summary { margin-bottom: .6rem; }

/* Poésie : texte (3.15) et comparatif de la lecture avec le texte */
/* Prompteur : gros vers centrés, vers en cours surligné pendant l'écoute de la lecture modèle */
.prompter { width: 100%; max-width: 680px; max-height: 46vh; overflow-y: auto; scroll-behavior: smooth; background: #1f1b3a; color: #fff; border-radius: 20px; padding: 18px 16px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); }
.prompter.zoom { max-height: 70vh; }
.pr-lines { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; }
.pr-line { margin: 0; text-align: center; font-size: clamp(1.25rem, 3.6vw, 1.85rem); line-height: 1.45; color: rgba(255,255,255,.92); border-radius: 12px; padding: 4px 10px; transition: background .25s, color .25s, transform .25s; }
.pr-gap { margin-top: 18px; }
.pr-past { color: rgba(255,255,255,.45); }
.pr-now { background: #ffd23f; color: #2a2150; font-weight: 700; transform: scale(1.03); }
.pr-model { width: 100%; max-width: 680px; }
.pr-model .rec-audio { width: 100%; }
.poem-model { border: 2px dashed var(--line, #d9d2f0); border-radius: 14px; padding: 10px 14px; }
.poem-text { margin: 0; white-space: pre-wrap; font: inherit; line-height: 1.5; }
.recite-ref { margin: 6px 0; }
.recite-ref .poem-text { font-size: 1rem; background: #fffdf7; border-radius: 10px; padding: 8px 12px; }
.btn.disabled { opacity: .5; pointer-events: none; }

/* Poésie découpée en parties (3.16) */
.poem-part { margin: 0 0 6px; font-weight: 700; color: #6d3fe0; }
.poem-split { border: 2px dashed var(--line, #d9d2f0); border-radius: 14px; padding: 10px 14px; }
.poem-parts-list { margin: 8px 0; padding-left: 1.2rem; }
.learn-ctl { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.recur-box { border: 2px dashed var(--line, #d9d2f0); border-radius: 14px; padding: 10px 14px; }
.hw-badge.recur { background: #e3f2ff; color: #0b5394; }

/* ---------------- Lecture chrono ---------------- */
.lec-text { max-height: 38vh; overflow: auto; padding: 8px 4px; margin: 8px 0; }
.lec-text.big { max-height: 52vh; font-size: 1.25em; }
.lec-clock { text-align: center; font-size: clamp(3rem, 14vw, 6rem); font-weight: 700; color: #1d4e89; line-height: 1; font-variant-numeric: tabular-nums; }
.lec-clock.end { color: #d62839; animation: lec-pulse .5s ease-in-out infinite alternate; }
@keyframes lec-pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
.lec-bar { height: 12px; border-radius: 999px; background: #e3e6ef; overflow: hidden; margin: 8px 0 12px; }
.lec-bar > div { height: 100%; width: 0; background: linear-gradient(90deg, #3a86ff, #8b5cf6); transition: width .1s linear; }
@media (prefers-reduced-motion: reduce) { .lec-clock.end { animation: none; } }
