/* Adaptations mobile / tablette / impression. À charger en dernier. */

@media (max-width: 900px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 700; box-shadow: var(--shadow-lg);
    border-radius: 0; transform: none;
    transition: transform .3s var(--ease);   /* le tiroir glisse : il bascule en transform */
  }
  #sidebar.collapsed { transform: translateX(-100%); box-shadow: none; }
  #sidebar-backdrop.visible { display: block; position: fixed; inset: 0; z-index: 650; background: rgba(20, 18, 15, .4); }
  .yt-card { flex-direction: column; align-items: stretch; max-width: none; }
  .yt-thumb { width: 100%; }
  .yt-info { padding: 12px 16px; }
  :root { --sidebar-w: min(300px, 84vw); }
}

@media (max-width: 760px) {
  .home-cols { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; }
  .module-card { min-height: 158px; }
  .module-card .mc-body { min-height: 158px; padding: 15px; }
  .module-card .mc-title { font-size: 17px; }
  .module-card .mc-emoji { font-size: 26px; }
}

@media (max-width: 540px) {
  body { font-size: 15.5px; }
  #topbar { min-height: 54px; padding-top: max(0px, env(safe-area-inset-top)); }
  #breadcrumb { font-size: 12.5px; }
  /* Barre du haut d'un téléphone : ☰, fil d'Ariane, synchro, « ⋯ », 🔍.
     Guide, Outils, Brouillon et Thème se replient dans le menu « ⋯ » : à neuf
     boutons, le fil d'Ariane n'avait plus la place d'un mot. */
  #topbar { gap: 4px; position: relative; z-index: 600; }
  #breadcrumb { flex: 1 1 auto; }
  #topbar-plus { display: flex; font-size: 20px; }
  #topbar-plus[aria-expanded="true"] { background: var(--panel-2); }
  .topbar-menu {
    display: none; position: absolute; right: max(8px, env(safe-area-inset-right)); top: calc(100% + 6px);
    flex-direction: column; align-items: stretch; gap: 2px; min-width: 220px; padding: 6px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--r);
    box-shadow: var(--shadow-lg);
  }
  .topbar-menu.ouvert { display: flex; }
  .topbar-menu .topbar-spacer { display: none; }
  .topbar-menu .topbar-nav, .topbar-menu .topbar-btn {
    width: auto; height: 44px; padding: 0 12px; justify-content: flex-start; gap: 10px;
    border: 0; border-radius: 10px; font-size: 15px; font-weight: 600; font-family: inherit; color: var(--text);
  }
  .topbar-menu .topbar-btn[data-libelle]::after {
    content: attr(data-libelle); font-size: 15px; font-weight: 600;
  }
  /* « Présenter » sert à projeter (iPad, ordinateur) : pas sur un téléphone. */
  #app.vue-cours #present-btn { display: none; }
  .quiz-body { padding: 8px 14px 16px; }
  .quiz-scorebar { padding: 12px 14px; gap: 10px; }
  .toggle-body, .card-body { padding: 6px 15px 13px; }
  .callout { padding: 13px 15px; }
  .home-panel { padding: 22px; }
  .home-hero { flex-direction: column; align-items: flex-start; gap: 10px; text-align: left; }
  .listing-item { padding: 12px 14px; }
}

/* Très grands écrans : la colonne de lecture s'élargit encore un peu (confort),
   l'accueil garde sa largeur (bornée par .home). */
@media (min-width: 1500px) { #app.reading .content-inner { max-width: 1100px; } }

@media (pointer: coarse) {
  .nav-cours { padding: 11px 11px; }
  details.nav-seq > summary, details.nav-seance > summary { padding: 12px 8px; }
  .quiz-opt { padding: 14px 16px; }
  .topbar-btn { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  /* `iteration-count: 1` est indispensable : sans lui, les animations infinies
     (spinner, squelettes, témoin de synchro) tourneraient des milliers de fois
     par seconde au lieu de s'arrêter. */
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  #sidebar, #sidebar-hotzone, #sidebar-backdrop, #topbar, #search-overlay,
  #preview-popover, #toast { display: none !important; }
  /* base.css enferme le défilement dans #content : à l'impression, c'est la
     page entière qui doit pouvoir s'étendre, sinon seul le premier écran sort. */
  html, body { overflow: visible !important; height: auto !important; }
  #app { display: block !important; height: auto; }
  #content { overflow: visible !important; }
}
