/* Recap · index · Accueil : le SWITCH (« Accueil » ⇄ « Mon espace ») et la seconde vue « Mon espace »
   (carte d'accueil du jour, matières, dernières activités [aperçu], planning de révision [réel], encouragement). */

/* ---------- les deux vues partagent la mise en page de .content (colonne centrée) ---------- */
#start > .content { position: relative; }
.vw { display: flex; flex-direction: column; align-items: center; width: 100%; }
.vw[hidden] { display: none !important; }
/* la vue « Accueil » mise de côté : elle garde sa géométrie (le moteur d'écriture peut continuer à la mesurer) mais ne prend plus de place et ne se voit plus */
.vw-home.vw-off { position: absolute; left: 0; right: 0; top: 22px; height: 0; overflow: hidden; visibility: hidden; pointer-events: none; }
/* la vue « Mon espace » est un bloc « .rv » pour le moteur (jamais écrite au stylo) : on neutralise son masquage d'apparition */
.js #start .vw-space.rv { opacity: 1; transform: none; filter: none; pointer-events: auto; transition: none; }

/* changement de vue : fondu enchaîné. L'ancienne vue reste en place (« fantôme ») et se dissout pendant que la nouvelle se forme par-dessus :
   d'abord la grande carte (elle se pose en douceur), puis les blocs du dessous l'un après l'autre (--k posé par home-space.js).
   Jamais de vide, jamais d'apparition brusque ; une seule courbe douce, sans rebond. */
@keyframes hs-card  { from { opacity: 0; scale: .955; translate: 0 14px; } }
@keyframes hs-rise  { from { opacity: 0; scale: .985; translate: 0 16px; } }
@keyframes hs-ghost { to   { opacity: 0; scale: .985; } }
.vw-space:not([hidden]) > *, .vw-home.vw-in > * { animation: hs-rise .7s cubic-bezier(.25, .8, .3, 1) calc(.2s + var(--k, 0) * 90ms) backwards; }
.vw-space:not([hidden]) > :first-child, .vw-home.vw-in > :first-child { animation: hs-card .75s cubic-bezier(.25, .8, .3, 1) .14s backwards; }
.vw.vw-ghost { position: absolute; left: 0; right: 0; top: 22px; z-index: 0; pointer-events: none; animation: hs-ghost .3s ease-out forwards; }
.vw.vw-ghost > * { animation: none !important; }

/* ---------- le switch : une pastille « sticker » posée à cheval sur le bord bas de la grande carte (même place dans les deux vues) ---------- */
.vsw { position: absolute; z-index: 5; left: 12px; bottom: -22px; display: flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--card); border: 2px solid color-mix(in srgb, var(--ink) 55%, transparent); box-shadow: 2px 3px 0 color-mix(in srgb, var(--ink) 30%, transparent); }
.vsw-b { position: relative; display: flex; align-items: center; gap: 5px; margin: 0; padding: 6px 11px 6px 9px; border: 0; border-radius: 999px; background: transparent; color: var(--muted);
  font: 400 .92rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .25s ease, color .25s ease, transform .12s ease; }
.vsw-b svg { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.vsw-b[aria-selected="true"] { background: var(--ink); color: var(--card); box-shadow: 0 2px 0 0 color-mix(in srgb, var(--ink) 38%, transparent); }
.vsw-b:active { transform: translateY(1px) scale(.97); }
.vsw-b:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.js #start .pi .vsw.rv { transition: opacity .6s ease; }

/* ---------- carte d'accueil de « Mon espace » : même verre dépoli que la grande carte, en plus large ---------- */
.pi.hs-hero { box-sizing: border-box; width: 100%; max-width: 400px; margin-bottom: 26px; padding: 24px 18px 34px; text-align: start; }
.hs-hero .pi-boy { width: 54%; right: 7%; }
.hs-hero-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
#start .hs-hi { margin: 0; font-family: var(--hd-brush, "Caveat Brush", "Caveat", cursive); font-size: 1.5rem; line-height: 1.1; color: var(--muted); }
.hs-nm { font-weight: 400; color: var(--text); padding: 0 5px; background: linear-gradient(transparent 55%, color-mix(in srgb, var(--h1) 75%, transparent) 55% 92%, transparent 92%); }
#start .pi .hs-h1 { position: relative; width: fit-content; margin: 6px 0 0; font-family: var(--hd-brush, "Caveat Brush", "Caveat", cursive); font-weight: 400; letter-spacing: 0;
  font-size: clamp(1.9rem, 9vw, 2.35rem); line-height: .98; color: var(--ink); text-wrap: balance; }
#start .pi .hs-sub { margin: 10px 0 0; max-width: 24ch; font-size: .8rem; line-height: 1.35; color: var(--text); opacity: .78; }

/* « Rêve · Étudie · Réussis » : les trois mots écrits à la main, penchés, avec l'étoile qui scintille */
.hs-motto { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 22px 4px 0 6px; rotate: -6deg; pointer-events: none;
  font-family: var(--hd-brush, "Caveat Brush", "Caveat", cursive); line-height: 1.02; color: var(--ink); }
.hs-motto span { font-size: 1.28rem; }
.hs-motto span:nth-of-type(2) { margin-inline-start: 14px; color: var(--text); } .hs-motto span:nth-of-type(3) { margin-inline-start: 26px; }
.hs-motto span:nth-of-type(3) { background: linear-gradient(transparent 62%, color-mix(in srgb, var(--h2) 75%, transparent) 62% 94%, transparent 94%); padding-inline-end: 4px; }
.hs-star { position: absolute; top: -2px; left: 8px; width: 30px; height: auto; rotate: -12deg; filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, .3)); animation: hm-twinkle 3.4s ease-in-out infinite; }

/* la classe : une étiquette pointillée comme les puces de l'accueil */
.hs-cls { display: inline-flex; align-items: center; gap: 7px; margin-top: 16px; padding: 6px 12px 6px 9px; max-width: calc(100% - 104px); border: 2px dashed color-mix(in srgb, var(--ink) 60%, transparent);
  border-radius: 14px 18px 14px 18px / 18px 14px 18px 14px; background: color-mix(in srgb, var(--ink) 9%, var(--card)); color: var(--ink); rotate: -1deg; }
.hs-cls svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.hs-cls b { font: 400 1.02rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif; white-space: nowrap; color: var(--text); }
.hs-cls i { font: 400 .78rem/1.05 "Patrick Hand", "Tajawal", system-ui, sans-serif; font-style: normal; color: var(--muted); }

/* ---------- panneaux (activités, planning) : mêmes cartes « doodle » que le reste du site ---------- */
.hs-head { display: flex; align-items: center; gap: 12px; margin: 0 2px 16px; }
.hs-head .hm-h { flex: 1; min-width: 0; margin: 0; }
.hs-more { display: inline-flex; align-items: center; gap: 5px; flex: none; text-decoration: none; color: var(--ink); font: 400 1.02rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; transition: transform .12s ease, opacity .12s ease; }
.hs-more svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.hs-more:active { transform: translateX(2px); opacity: .8; }
.hs-demo { flex: none; padding: 3px 11px 4px; border: 1.8px dashed color-mix(in srgb, var(--muted) 80%, transparent); border-radius: 999px; rotate: -3deg;
  font: 400 .88rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif; color: var(--muted); cursor: help; }
.hs-card { position: relative; margin: 0; padding: 4px 14px; list-style: none; background: var(--card); border: 2.5px solid color-mix(in srgb, var(--ink) 50%, transparent);
  border-radius: 20px 28px 22px 26px / 26px 20px 28px 22px; box-shadow: 3px 4px 0 color-mix(in srgb, var(--ink) 26%, transparent); }
.hs-acts { rotate: -.5deg; } .hs-plan { rotate: .5deg; }

/* ---------- dernières activités (aperçu) ---------- */
.hs-act { display: grid; grid-template-columns: 48px minmax(0, 1fr) 18px; align-items: center; gap: 12px; padding: 11px 0; }
.hs-act + .hs-act { border-top: 2.5px dotted color-mix(in srgb, var(--ink) 28%, transparent); }
.hs-act .ic, .hs-row .ic { display: grid; place-items: center; width: 48px; height: 48px; border: 2px dashed var(--c); background: color-mix(in srgb, var(--c) 14%, var(--card));
  border-radius: 14px 18px 14px 18px / 18px 14px 18px 14px; }
.hs-act:nth-child(even) .ic { border-radius: 18px 14px 18px 14px / 14px 18px 14px 18px; rotate: 1.5deg; } .hs-act:nth-child(odd) .ic { rotate: -1.5deg; }
.hs-act .ic img, .hs-row .ic img { display: block; width: auto; max-width: 78%; height: 36px; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-drag: none;
  filter: drop-shadow(0 2px 1.5px rgba(40, 24, 10, .28)); }
.hs-act .tx { min-width: 0; display: grid; gap: 5px; }
.hs-act .n { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .97rem; font-weight: 600; line-height: 1.2; color: var(--text); }
.hs-act .m { display: flex; align-items: center; gap: 7px; min-width: 0; }
.hs-act .k { flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 6px; border-radius: 999px; font: 400 .84rem/1.1 "Patrick Hand", "Tajawal", system-ui, sans-serif;
  color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); }
.hs-act .k svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hs-act small { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .76rem; line-height: 1.1; color: var(--muted); }
.hs-act .chev { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }

/* ---------- planning de révision (réel : lit l'emploi du temps) ---------- */
.hs-days { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 12px 0 10px; border-bottom: 2.5px dotted color-mix(in srgb, var(--ink) 28%, transparent); }
.hs-dt { position: relative; margin: 0; padding: 8px 0 9px; border: 2px dashed transparent; border-radius: 999px; background: transparent; color: var(--muted);
  font: 400 1rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .2s ease, color .2s ease, transform .12s ease; }
.hs-dt.today { border-color: color-mix(in srgb, var(--ink) 45%, transparent); }
.hs-dt.on { background: var(--ink); color: var(--card); border-color: var(--ink); box-shadow: 0 2px 0 0 color-mix(in srgb, var(--ink) 38%, transparent); }
.hs-dt.has::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--gold); }
.hs-dt:active { transform: scale(.95); }
.hs-dt:focus-visible, .hs-ck:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.hs-rows { margin: 0; padding: 0; list-style: none; }
.hs-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 32px; align-items: center; gap: 10px; padding: 10px 0; animation: hm-pop .5s cubic-bezier(.3, 1.45, .5, 1) calc(var(--i, 0) * 70ms) backwards; }
.hs-row + .hs-row { border-top: 2.5px dotted color-mix(in srgb, var(--ink) 28%, transparent); }
.hs-row .tm { max-width: 6.2rem; font: 400 .88rem/1.2 "Patrick Hand", "Tajawal", system-ui, sans-serif; color: var(--muted); }
.hs-row .ic { width: 46px; height: 46px; }
.hs-row .ic img { height: 34px; }
.hs-row .nm { min-width: 0; display: grid; gap: 2px; }
.hs-row .nm b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 400 1.12rem/1.1 "Patrick Hand", "Tajawal", system-ui, sans-serif; color: var(--text); }
.hs-row .nm small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .8rem; color: var(--muted); unicode-bidi: plaintext; }
.hs-row.done .nm b { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: color-mix(in srgb, var(--c) 70%, transparent); opacity: .6; }
.hs-row.done .ic { opacity: .7; }
.hs-ck { display: grid; place-items: center; width: 30px; height: 30px; margin: 0; padding: 0; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--ink) 55%, transparent); background: transparent;
  color: var(--card); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .2s ease, border-color .2s ease, transform .12s ease; }
.hs-ck svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; transition: stroke-dashoffset .3s ease .05s; }
.hs-ck[aria-checked="true"] { background: var(--ink); border-color: var(--ink); }
.hs-ck[aria-checked="true"] svg { stroke-dashoffset: 0; }
.hs-ck:active { transform: scale(.9); }
.hs-empty { display: grid; justify-items: center; gap: 4px; padding: 20px 8px 18px; text-align: center; }
.hs-empty img { display: block; width: auto; height: 54px; margin-bottom: 2px; filter: drop-shadow(0 3px 2px rgba(40, 24, 10, .26)); animation: hm-bob 5.5s ease-in-out infinite; }
.hs-empty b { font: 400 1.2rem/1.1 var(--hd-brush, "Caveat Brush", "Caveat", cursive); color: var(--ink); }
.hs-empty small { font-size: .78rem; color: var(--muted); }
.hs-empty a { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px 8px 14px; text-decoration: none; color: var(--card); background: var(--ink); border-radius: 999px;
  box-shadow: 0 3px 0 0 color-mix(in srgb, var(--ink) 38%, transparent); font: 400 1rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
.hs-empty a svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; }
.hs-prog { display: flex; align-items: center; gap: 10px; padding: 10px 0 12px; border-top: 2.5px dotted color-mix(in srgb, var(--ink) 28%, transparent); }
.hs-prog[hidden] { display: none; }
.hs-prog .bar { flex: 1; height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 16%, transparent); overflow: hidden; }
.hs-prog .bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--ink); transition: width .5s cubic-bezier(.3, 1.2, .5, 1); }
.hs-prog small { font: 400 .92rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif; color: var(--muted); white-space: nowrap; }

/* ---------- encouragement : post-it pointillé avec la coupe posée sur son coin ---------- */
.hs-cheer { margin-top: 52px; padding: 20px 18px 18px; background: color-mix(in srgb, var(--accent) 13%, var(--card)); border: 2.5px dashed color-mix(in srgb, var(--ink) 55%, transparent);
  border-radius: 6px 22px 8px 20px; rotate: 1deg; box-shadow: 0 12px 22px rgba(0, 0, 0, .14); }
.hs-cup { position: absolute; z-index: 2; inset-inline-end: 16px; top: -36px; width: 72px; height: auto; rotate: 7deg; pointer-events: none; user-select: none; -webkit-user-drag: none;
  filter: drop-shadow(0 3px 2px rgba(40, 24, 10, .26)) drop-shadow(0 10px 8px rgba(40, 24, 10, .16)); animation: hm-bob 5.5s ease-in-out infinite; }
#start .hs-cheer-t { margin: 0; padding-inline-end: 84px; font-family: var(--hd-brush, "Caveat Brush", "Caveat", cursive); font-size: 1.7rem; line-height: 1.05; color: var(--ink); }
#start .hs-cheer-s { margin: 6px 0 0; padding-inline-end: 84px; font-size: .9rem; line-height: 1.35; color: var(--text); }
.hs-cheer-tag { display: inline-block; margin-top: 12px; padding: 4px 13px 5px; rotate: -3deg; border-radius: 9px 14px 9px 14px; background: color-mix(in srgb, var(--gold) 55%, var(--card));
  border: 2px solid color-mix(in srgb, var(--gold) 80%, var(--ink)); font: 400 1.05rem/1 "Patrick Hand", "Tajawal", system-ui, sans-serif; color: var(--text); }
.vw-space { padding-bottom: 14px; }

@media (max-width: 360px) {
  .vsw-b { padding: 6px 9px 6px 7px; font-size: .86rem; } .vsw-b svg { width: 14px; height: 14px; }
  .pi.hs-hero { padding-inline: 14px; } .hs-cls i { display: none; } .hs-motto span { font-size: 1.12rem; }
  .hs-row { gap: 8px; } .hs-row .tm { max-width: 5.4rem; font-size: .82rem; }
}
@media (min-width: 700px) { .pi.hs-hero { max-width: 460px; } }
@media (prefers-reduced-motion: reduce) {
  .vw-space:not([hidden]) > *, .vw-home.vw-in > *, .vw.vw-ghost, .hs-row, .hs-star, .hs-cup, .hs-empty img { animation: none !important; }
  .vsw-b, .hs-dt, .hs-ck, .hs-prog .bar i { transition: none; }
}

/* latest activity : each row is a real link to the lesson / exercise the student opened */
a.hs-act { text-decoration: none; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .15s ease, opacity .15s ease; }
a.hs-act:active { transform: scale(.98); opacity: .8; }
a.hs-act:focus-visible { outline: 2.5px solid var(--c); outline-offset: 3px; border-radius: 12px; }
.hs-act .ic svg { display: block; }
