/* ==================================================================
   À table ! — adaptations responsive
   Chargé APRÈS style.css (voir inc/header.php) : style.css reste la
   référence du design, ce fichier ne contient que les ajustements
   liés à la taille d'écran et au tactile.

   Points de rupture (du plus large au plus étroit) :
     1024px  tablette paysage : administration sur une colonne
      820px  tablette / grand mobile : menu repliable, une colonne
      700px  tableaux d'administration affichés en fiches
      560px  mobile
      380px  petit mobile
   ================================================================== */

/* ---------- Tous écrans ---------- */

body { overflow-wrap: break-word; }
img, svg, video { max-width: 100%; height: auto; }

/* Encoches et coins arrondis des téléphones (viewport-fit=cover) */
header.site, main {
  padding-left:  max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}

/* Lien d'évitement, visible seulement au clavier */
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 20;
  background: var(--herb); color: #fff; padding: .55rem 1rem;
  border-radius: var(--radius-s); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 1rem; color: #fff; }

/* Bouton du menu mobile : caché par défaut. Il n'apparaît que si le
   JavaScript est actif (classe .has-toggle ajoutée par app.js) ;
   sans JavaScript, le menu reste simplement affiché en entier. */
.nav-toggle {
  display: none; align-items: center; gap: .6rem;
  font: 600 .95rem var(--sans); color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: .55rem 1rem; min-height: 2.75rem;
}
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block; width: 1.1rem; height: 2px; border-radius: 2px; background: currentColor;
  transition: transform .2s ease, background-color .2s ease;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before,
.nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after  { top: 6px; }
.is-open .nav-toggle-icon { background: transparent; }
.is-open .nav-toggle-icon::before { transform: translateY(6px) rotate(45deg); }
.is-open .nav-toggle-icon::after  { transform: translateY(-6px) rotate(-45deg); }

/* Raccourci vers le panneau d'inscription (utile seulement sur mobile) */
.jump { display: none; }
.scroll-hint { display: none; }

/* Champs date : évite les débordements et l'alignement centré d'iOS */
input[type="datetime-local"], input[type="date"] { min-height: 2.75rem; min-width: 0; }
input::-webkit-date-and-time-value { text-align: left; }
.row2 > label, .stack > label { min-width: 0; }

.actions { flex-wrap: wrap; }

/* Statistiques : la colonne des noms reste visible quand on fait
   défiler le tableau horizontalement */
.stats-table thead th:first-child,
.stats-table tbody th,
.stats-table tfoot th {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}
.stats-table tr.is-selected th { background: #E4EDE0; }

/* ---------- ≤ 1024px : tablette paysage ---------- */
@media (max-width: 1024px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-layout > .panel { max-width: 40rem; }
}

/* ---------- ≤ 820px : tablette portrait, grand mobile ---------- */
@media (max-width: 820px) {
  header.site { align-items: center; padding-top: 1rem; }
  .brand { font-size: 1.4rem; }

  /* Menu repliable */
  header.site.has-toggle .nav-toggle { display: inline-flex; }
  header.site.has-toggle nav { display: none; }
  header.site.has-toggle.is-open nav { display: flex; }
  header.site.has-toggle nav {
    flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-radius: var(--radius-l);
    padding: .4rem; margin-top: .35rem;
    box-shadow: 0 10px 28px rgba(31, 42, 34, .10);
  }
  header.site.has-toggle nav a {
    display: block; padding: .75rem .9rem; border-bottom: 0; border-radius: var(--radius-s);
  }
  header.site.has-toggle nav a:hover { background: var(--paper); }
  header.site.has-toggle nav a[aria-current="page"] {
    background: #E4EDE0; color: var(--herb-2); font-weight: 600;
  }
  header.site.has-toggle nav form.inline {
    display: block; margin-top: .3rem; padding-top: .3rem; border-top: 1px solid var(--line);
  }
  header.site.has-toggle nav button.link {
    display: block; width: 100%; text-align: left; padding: .75rem .9rem; text-decoration: none;
  }

  main { padding-top: 1rem; padding-bottom: 2.5rem; }

  /* Pages repas / partie */
  .event-head { margin-bottom: 1.5rem; }
  .jump { display: block; margin: .9rem 0 0; }
  .event-layout, .profile-layout, .admin-layout { gap: 1.5rem; }
  .menu, .repertoire { padding: 1.25rem 1.1rem .25rem; }
  .panel { padding: 1.1rem; }
  .mine li { flex-wrap: wrap; gap: .25rem 1rem; }
  .manage { gap: .5rem 1.1rem; }

  /* Filtre des types de jeu : une seule ligne qui défile au doigt */
  .type-filter {
    flex-wrap: nowrap; overflow-x: auto; padding-bottom: .4rem;
    scroll-snap-type: x proximity; scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }
  .type-filter a { flex: none; scroll-snap-align: start; }

  /* Statistiques */
  .filters { gap: .75rem; }
  .filters label { min-width: 0; flex: 1 1 100%; }
  .kpis li { flex: 1 1 9rem; }
  .scroll-hint { display: block; margin: 0 0 .5rem; }
  .stats-table thead th.type { min-width: 5rem; }
  .stats-table th, .stats-table td { padding: .6rem .7rem; }
  .bar { min-width: 6rem; }
}

/* ---------- ≤ 700px : tableaux d'administration en fiches ---------- */
@media (max-width: 700px) {
  .table-cards thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr {
    display: flex; flex-direction: column; gap: .3rem;
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--line);
  }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td {
    display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .75rem; align-items: baseline;
    padding: 0; border: 0; overflow-wrap: anywhere;
  }
  .table-cards td::before {
    content: attr(data-label); font-size: .85rem; font-weight: 600; color: var(--muted);
  }
  /* Titre de la fiche (titre du repas, nom du membre) remonté en tête */
  .table-cards td.cell-main { order: -1; display: block; font: 400 1.15rem/1.3 var(--serif); }
  .table-cards td.cell-block { display: block; }
  .table-cards td.cell-main::before,
  .table-cards td.cell-block::before,
  .table-cards td.row-actions::before,
  .table-cards td[colspan]::before { content: none; display: none; }

  .table-cards td.row-actions,
  .table-cards td[colspan] {
    display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.4rem;
    white-space: normal; padding-top: .45rem;
  }
  .table-cards .row-actions > * + * { margin-left: 0; }
  .table-cards td.row-actions:not(:has(*)) { display: none; } /* ex. : sa propre ligne de membre */

  .type-row { flex-wrap: wrap; width: 100%; }
  .type-row input[name="label"] { flex: 1 1 10rem; min-width: 0; }
}

/* ---------- ≤ 560px : mobile ---------- */
@media (max-width: 560px) {
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.25rem; }
  .section-title { margin-top: 2rem; }

  /* Boutons principaux pleine largeur : plus faciles à toucher */
  .stack > .btn,
  .actions .btn,
  .page-head .btn,
  .jump .btn { width: 100%; text-align: center; justify-self: stretch; }
  .page-head { align-items: stretch; }

  .narrow { margin: 1rem auto; }
  .date-card { gap: .9rem; padding: .9rem 1rem; }
  .cal { width: 3.5rem; }
  .cal b { font-size: 1.6rem; }
  .date-body strong { font-size: 1.15rem; }

  .course { padding-left: 1rem; }
  .errors { padding-left: 1.6rem; }
  .danger-zone { text-align: left; }
  .kpis b { font-size: 1.6rem; }
  footer.site { padding: 1.5rem 1rem 2.5rem; }
}

/* ---------- ≤ 380px : petit mobile ---------- */
@media (max-width: 380px) {
  header.site, main {
    padding-left:  max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .brand { font-size: 1.25rem; }
  .date-card { gap: .75rem; padding: .8rem .85rem; }
  .cal { width: 3rem; font-size: .75rem; }
  .cal b { font-size: 1.35rem; }
  .table-cards td { grid-template-columns: 5.5rem minmax(0, 1fr); }
}

/* ---------- Écrans tactiles : zones de clic plus confortables ---------- */
@media (pointer: coarse) {
  button.link, .row-actions a { padding-block: .35rem; }
  .type-filter a { padding: .45rem .9rem; }
  .type-pick span { padding: .5rem .95rem; }
  input[type="color"] { width: 3rem; height: 2.75rem; }
}
