/* Recap · index · page Matières (Subjects) : cartes doodle */
  /* ---------- subjects: doodle cards (2 columns), twinkling star ---------- */
  .stack { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: calc(var(--pic-h, 68px) / 2 + 16px) 16px; padding: calc(var(--pic-h, 68px) / 2 + 8px) 2px 24px; margin-top: 10px; }
  .card { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px;
    min-height: 22px; padding: calc(var(--pic-h, 68px) / 2 + 10px) 8px 14px; text-decoration: none; color: var(--text); rotate: -1.5deg;
    background: var(--card); border: 2.5px solid var(--c); border-radius: 20px 48px 24px 42px / 42px 20px 48px 24px; box-shadow: 3px 5px 0 color-mix(in srgb, var(--c) 35%, transparent);
    transition: transform .12s ease, opacity .12s ease; -webkit-tap-highlight-color: transparent; }
  .card:nth-child(even) { rotate: 1.8deg; border-radius: 44px 22px 40px 24px / 22px 44px 24px 40px; } .card:nth-child(3n) { rotate: -.6deg; }
  .card:active { transform: scale(.96); opacity: .7; }
  /* the 3D object straddles the top edge of the card: half outside the frame, half inside (centred, the name sits below it);
     child of .card, so it follows its tilt, entrance and tape; a soft contact shadow sits under it */
  .stack { --pic-h: 68px; }
  .card .pic { position: absolute; z-index: 2; left: 50%; translate: -50% 0; bottom: calc(100% - var(--pic-h) / 2); height: var(--pic-h); pointer-events: none; }
  .card .pic::before { content: ""; position: absolute; z-index: 0; left: 4%; right: 4%; bottom: -4px; height: 12px; border-radius: 50%; filter: blur(2.5px);
    background: radial-gradient(ellipse at 50% 50%, rgba(10,30,20,.50) 0, rgba(10,30,20,.28) 45%, rgba(10,30,20,0) 74%); }
  .card .pic img { position: relative; z-index: 1; display: block; height: 100%; width: auto; max-width: calc(var(--pic-h, 68px) * .95); object-fit: contain; user-select: none; -webkit-user-drag: none; transform-origin: 50% 100%;
    filter: drop-shadow(0 2px 1.5px rgba(10,30,20,.30)) drop-shadow(0 5px 4px rgba(10,30,20,.16)); transition: transform .25s cubic-bezier(.3, 1.5, .5, 1); }
  .card:active .pic img { transform: translateY(-4px) scale(1.05) rotate(-2deg); }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .card .pic::before { background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,.72) 0, rgba(0,0,0,.42) 45%, rgba(0,0,0,0) 74%); }
    :root:not([data-theme="light"]) .card .pic img { filter: drop-shadow(0 2px 1.5px rgba(0,0,0,.5)) drop-shadow(0 5px 4px rgba(0,0,0,.3)); }
  }
  :root[data-theme="dark"] .card .pic::before { background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,.72) 0, rgba(0,0,0,.42) 45%, rgba(0,0,0,0) 74%); }
  :root[data-theme="dark"] .card .pic img { filter: drop-shadow(0 2px 1.5px rgba(0,0,0,.5)) drop-shadow(0 5px 4px rgba(0,0,0,.3)); }
  .card .lbl { position: relative; isolation: isolate; padding: 0 8px; font-family: var(--hd-brush); font-weight: 400; letter-spacing: 0; font-size: 1.3rem; color: var(--c); line-height: 1.05; padding-bottom: 4px; }
  [dir="rtl"] .card .lbl, :lang(ar) .card .lbl { font-family: var(--hd-ar); font-weight: 700; }
  .card .lbl::before { content: ""; position: absolute; z-index: -1; left: -4px; right: -4px; bottom: 0; height: 52%; rotate: -1.2deg; border-radius: 3px 9px 4px 10px; background: color-mix(in srgb, var(--c) 34%, transparent); }
  /* chevron element is unused visually (tape removed) */
  .card .chev { display: none; }
  /* corner star : twinkles, turns and glows */
  .card::after { content: "✦"; position: absolute; right: 16px; top: 10px; font-size: 1.05rem; color: var(--c); text-shadow: 0 0 8px color-mix(in srgb, var(--c) 70%, transparent);
    animation: star-spark 2.8s ease-in-out infinite; }
  .card:nth-child(2n)::after { animation-delay: -.9s; } .card:nth-child(3n)::after { animation-delay: -1.8s; } .card:nth-child(5n)::after { animation-delay: -2.3s; }
  @keyframes star-spark { 0%, 100% { rotate: 14deg; scale: .8; opacity: .45; } 50% { rotate: 104deg; scale: 1.3; opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .card::after { animation: none; opacity: .65; rotate: 14deg; } }

  /* ---------- elegant arrival : plays when the reveal engine adds .in to the card ----------
     card drops in and settles → icon pops → the marker bar under the name sweeps to its end */
  .card .lbl::before { transform-origin: left center; }
  [dir="rtl"] .card .lbl::before { transform-origin: right center; }
  /* Calm, ordered entrance. --qd = extra stagger used when every card gets .in at once (screen already seen this session, .quick);
     on the first visit the reveal engine adds .in card after card, so --qd stays 0.
     Sequence inside one card: card settles -> picture drops -> name marker sweeps -> lesson count rises (number counts up) -> tags one by one. */
  .card.chain { --qd: 0s; transform: none; translate: 0 0; scale: 1; transition: opacity .5s ease, transform .12s ease; }
  .quick .card.chain { --qd: calc(.32s + var(--qi, 0) * .16s); }
  #subjects .stack > .card.chain.in { animation: card-in .85s cubic-bezier(.22, .8, .3, 1) var(--qd) backwards; }
  .card.chain.in:active { transform: scale(.96); opacity: .7; transition: opacity .12s ease, transform .12s ease; }
  .card.chain:not(.in) .lbl::before { transform: scaleX(0); }
  .card.chain.in .lbl::before { animation: marker-sweep .8s cubic-bezier(.4, .1, .2, 1) calc(.55s + var(--qd)) both; }
  .card.chain.in .pic img { animation: pic-drop .85s cubic-bezier(.34, 1.45, .64, 1) calc(.38s + var(--qd)) both; }
  .card.chain.in .pic::before { animation: pic-ground .85s ease calc(.38s + var(--qd)) both; }
  .card.chain.in .cnt.on { animation: info-in .6s ease calc(.95s + var(--qd)) backwards; }
  .card.chain.in .tags i { animation: info-in .55s ease calc(1.15s + var(--qd) + var(--ti, 0) * .09s) backwards; }
  .card .tags i:nth-child(2) { --ti: 1; } .card .tags i:nth-child(3) { --ti: 2; } .card .tags i:nth-child(4) { --ti: 3; }
  @keyframes card-in { from { opacity: 0; translate: 0 22px; scale: .93; } }
  @keyframes info-in { from { opacity: 0; translate: 0 7px; } }
  @keyframes marker-sweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes pic-drop { from { opacity: 0; transform: translateY(-40px) rotate(-3deg); } to { opacity: 1; transform: none; } }
  @keyframes pic-ground { 0% { opacity: 0; transform: scaleX(.45); } 55% { opacity: 0; transform: scaleX(.6); } 100% { opacity: 1; transform: none; } }
  /* the page-wide quick fade-ups would fight this entrance (double movement = the "deformed" look) */
  #subjects .stack > .card.chain:not(.in) { animation: none; }
  #subjects.quick > .content { animation: none; }
  @media (prefers-reduced-motion: reduce) {
    .card.chain.in, .card.chain.in .lbl::before, .card.chain.in .pic img, .card.chain.in .pic::before, .card.chain.in .cnt.on, .card.chain.in .tags i { animation: none; }
  }

  /* 7 matières : la dernière carte, seule sur sa ligne, se centre au lieu de rester collée à gauche */
  .stack > .card:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 8px); box-sizing: border-box; }

  /* nom de matière trop long (ex. Histoire-Géographie) : une seule ligne qui défile sur le côté, comme les titres du reste du site.
     le surlignage (::before) ne peut pas suivre le défilement : il est remplacé par un fond « local » qui couvre tout le texte */
  .card { min-width: 0; }
  .card .lbl.ts { scrollbar-width: none; }
  .card .lbl.ts::-webkit-scrollbar { display: none; height: 0; }
  .card .lbl.ts { flex: none; max-width: 100%; box-sizing: border-box; padding: 0 8px; }
  .card .lbl.ts::before { left: 0; right: 0; }
  .card .lbl.ovf { text-align: start; padding-bottom: 4px; }
  .card .lbl.ovf::before { left: 0; right: 0; }
  .card .lbl.ovf::before { display: none; }
  .card .lbl.ovf { background: linear-gradient(color-mix(in srgb, var(--c) 34%, transparent), color-mix(in srgb, var(--c) 34%, transparent)) left bottom 4px / 100% 52% no-repeat; background-attachment: local; }
  .card .lbl.ovf, .card .lbl.ts { touch-action: pan-x pan-y; }

  /* ---------- extra info on each subject card : lesson count (from the data files) + what the subject contains ---------- */
  .card .info { display: flex; flex-direction: column; align-items: center; gap: 7px; width: 100%; margin-top: 2px; }
  .card .cnt { display: inline-flex; align-items: center; gap: 5px; min-height: 1.1rem; font-size: .72rem; font-weight: 800; color: var(--muted); opacity: 0; }
  .card .cnt.on { opacity: 1; }   /* the row is always in the layout (no height jump when the number arrives) */
  .card .cnt b { display: inline-block; text-align: center; font-variant-numeric: tabular-nums; }
  .card .cnt svg { width: 14px; height: 14px; fill: none; stroke: var(--c); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
  .card .cnt b { font: 700 1.1rem/1 "Caveat", "Segoe Print", cursive; color: var(--c); }
  .card .tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .card .tags i { font-style: normal; font-size: .62rem; font-weight: 700; line-height: 1.2; padding: 2px 8px; border-radius: 999px; color: var(--text);
    background: color-mix(in srgb, var(--c) 10%, transparent); border: 1.5px solid color-mix(in srgb, var(--c) 28%, transparent); }
