/* ==========================================================================
   153 — Stack Pages
   Navigation en pile façon mobile (3 niveaux) : la nouvelle page glisse
   par-dessus depuis la droite avec une ombre portée sur son bord gauche,
   pendant que la page précédente recule (scale 0.94) et s'assombrit
   (voile ::after). Le bouton retour dépile en inverse. Easing type iOS
   (cubic-bezier(0.32, 0.72, 0, 1)).
   Racine : .stack-pages — états .is-top / .is-under pilotés par anim.js,
   pages hors pile inertes (attribut inert).
   Démo CONTENUE dans la zone (pages absolues dans la racine relative,
   jamais de fixed).
   ========================================================================== */

.stack-pages {
  --stkp-accent: var(--ml-accent, #7c8cff);
  --stkp-ease: cubic-bezier(0.32, 0.72, 0, 1);

  position: relative;
  width: min(320px, 100%);
  height: 236px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--ml-surface, #151a24);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--ml-fg, #e8eaf2);
}

/* --- Pages ------------------------------------------------------------------ */

.stack-pages__page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--ml-surface, #151a24);
  transform: translateX(103%); /* au repos : hors champ à droite */
  transition: transform 0.45s var(--stkp-ease);
  outline: none;
}

.stack-pages__page.is-top {
  transform: none;
}

.stack-pages__page.is-under {
  transform: scale(0.94);
}

/* Voile d'assombrissement de la page qui recule */
.stack-pages__page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--ml-bg, #0d1017) 55%, black);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--stkp-ease);
}

.stack-pages__page.is-under::after {
  opacity: 0.55;
}

/* Empilement : l'ordre des niveaux est fixe, la page 3 passe toujours
   au-dessus de la 2, elle-même au-dessus de la 1. Ombre portée sur le bord
   gauche des pages qui glissent par-dessus. */
.stack-pages__page--1 { z-index: 1; }

.stack-pages__page--2 {
  z-index: 2;
  box-shadow: -18px 0 36px rgba(0, 0, 0, 0.45);
}

.stack-pages__page--3 {
  z-index: 3;
  box-shadow: -18px 0 36px rgba(0, 0, 0, 0.45);
}

/* --- En-tête ------------------------------------------------------------------ */

.stack-pages__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stack-pages__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: -6px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--stkp-accent);
  cursor: pointer;
  transition: background 0.2s ease;
}

.stack-pages__back:hover {
  background: rgba(255, 255, 255, 0.07);
}

.stack-pages__back:focus-visible {
  outline: 2px solid var(--stkp-accent);
  outline-offset: 2px;
}

.stack-pages__back svg {
  display: block;
  width: 13px;
  height: 13px;
}

.stack-pages__page-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 650;
  letter-spacing: 0.005em;
}

/* --- Corps : lignes ------------------------------------------------------------- */

.stack-pages__body {
  flex: 1;
  min-height: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stack-pages__row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  font-family: inherit;
  font-size: 0.76rem;
  text-align: left;
}

/* seules les lignes-boutons naviguent ; les lignes statiques habillent */
button.stack-pages__row {
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

button.stack-pages__row:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: color-mix(in srgb, var(--stkp-accent) 35%, transparent);
}

button.stack-pages__row:focus-visible {
  outline: 2px solid var(--stkp-accent);
  outline-offset: 2px;
}

.stack-pages__row-label { flex: 1; }

.stack-pages__row-value {
  font-size: 0.68rem;
  color: var(--ml-muted, #8b91a3);
}

.stack-pages__chevron {
  display: block;
  width: 11px;
  height: 11px;
  color: var(--ml-muted, #8b91a3);
  flex: none;
}

/* Interrupteur décoratif (lignes statiques de la démo) */
.stack-pages__switch {
  position: relative;
  width: 26px;
  height: 15px;
  border-radius: 999px;
  flex: none;
  background: rgba(255, 255, 255, 0.12);
}

.stack-pages__switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ml-muted, #8b91a3);
}

.stack-pages__switch.is-on {
  background: color-mix(in srgb, var(--stkp-accent) 45%, transparent);
}

.stack-pages__switch.is-on::before {
  left: auto;
  right: 2px;
  background: var(--stkp-accent);
}

.stack-pages__note {
  margin: 2px 2px 0;
  font-size: 0.68rem;
  line-height: 1.5;
  color: var(--ml-muted, #8b91a3);
}

/* --- Reduced motion ---------------------------------------------------------------
   Glissement et recul quasi instantanés ; le JS raccourcit aussi son verrou. --- */

@media (prefers-reduced-motion: reduce) {
  .stack-pages__page,
  .stack-pages__page::after {
    transition-duration: 0.01s;
  }

  .stack-pages__back,
  button.stack-pages__row {
    transition: none;
  }
}
