/* =========================================================
   Ma Box Aventure — couche « application »
   Barre d'onglets, zones sûres iPhone, hors-ligne, installation.
   Ce fichier ne redéfinit aucune couleur de marque : il réutilise les
   variables de styles.css (avec repli, au cas où elles évoluent).
   ========================================================= */

:root {
  --tabbar-height: 62px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ---------- Bandeau « hors ligne » ---------- */
.offline-banner {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .55rem 1rem;
  background: var(--sun, #ffc233);
  border-bottom: 2px solid var(--sun-deep, #e5a012);
  color: #40290a;
  font-size: .88rem;
  font-weight: 700;
  text-align: center;
}
.offline-banner a { color: inherit; }

/* ---------- Bouton « télécharger pour la forêt » ---------- */
/* Même grammaire que les boutons du site : arête colorée qui s'écrase au clic. */
.offline-save {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .75rem 1.4rem;
  border: 2px dashed var(--forest, #14794f);
  border-radius: var(--radius-pill, 999px);
  background: transparent;
  color: var(--forest, #14794f);
  font: inherit;
  font-size: .93rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .12s ease;
}
.offline-save:hover:not(:disabled) {
  background: color-mix(in srgb, var(--forest, #14794f) 10%, transparent);
  transform: translateY(-1px);
}
.offline-save:active:not(:disabled) { transform: translateY(1px); }
.offline-save:disabled { opacity: .6; cursor: progress; }
.offline-save.is-saved {
  border-style: solid;
  background: var(--leaf-soft, #dcf5e4);
  border-color: var(--moss, #35b06e);
  color: var(--moss-ink, #14734a);
}

/* ---------- Invitation à installer (Android/Chrome) ---------- */
.install-prompt {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  margin: 1.5rem 0;
  border: 2px solid var(--line, #ead9c2);
  border-radius: var(--radius, 18px);
  background: var(--paper, #fff);
  box-shadow: var(--shadow-sm, 0 2px 0 rgba(20, 121, 79, .07));
}
.install-prompt p { margin: 0; font-size: .93rem; }

/* ---------- Page « Installer l'application » ---------- */
#install-state .only-installed,
#install-state .only-ios,
#install-state .only-other { display: none; }
#install-state.state-installed .only-installed { display: block; }
#install-state.state-ios .only-ios { display: block; }
#install-state.state-other .only-other { display: block; }

.steps {
  list-style: none;
  counter-reset: etape;
  padding: 0;
  margin: 1.5rem 0 0;
  display: grid;
  gap: .9rem;
}
.steps li {
  counter-increment: etape;
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1.1rem 1.3rem;
  background: var(--paper, #fff);
  border: 2px solid var(--line, #ead9c2);
  border-radius: var(--radius, 18px);
  box-shadow: var(--shadow-sm, 0 2px 0 rgba(20, 121, 79, .07));
}
/* Pastille numérotée, légèrement de travers : effet autocollant collé à la main. */
.steps li::before {
  content: counter(etape);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--forest, #14794f);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  font-family: var(--font-display, sans-serif);
  transform: rotate(-6deg);
}
.steps li:nth-child(even)::before { transform: rotate(5deg); background: var(--clay-ink, #b23c14); }
.steps li p { margin: 0; }
.steps li p + p { margin-top: .3rem; color: var(--ink-soft, #5a675e); font-size: .9rem; }

.ios-share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5em;
  height: 1.5em;
  vertical-align: -.35em;
  border-radius: 6px;
  background: #f0f0f4;
  color: #0a84ff;
  font-size: .95em;
}

/* ---------- Barre d'onglets (mobile et mode application) ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 70;
  display: none;
  background: color-mix(in srgb, var(--paper, #fff) 95%, transparent);
  backdrop-filter: blur(14px);
  border-top: 2px solid var(--line, #ead9c2);
  padding-bottom: var(--safe-bottom);
}
/* Reprise du ruban de couleurs de l'en-tête, en bas de l'écran. */
.tabbar::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    var(--forest, #14794f) 0 25%, var(--sun, #ffc233) 25% 50%,
    var(--clay, #e2562b) 50% 75%, var(--lake, #1f92cc) 75% 100%);
}
.tabbar-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: var(--tabbar-height);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--ink-soft, #5a6b61);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .01em;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a .tab-icon { font-size: 1.35rem; line-height: 1; transition: transform .18s ease; }
.tabbar a.is-active { color: var(--forest, #14794f); }
.tabbar a.is-active .tab-icon { transform: translateY(-2px) scale(1.08); }
.tabbar a:active .tab-icon { transform: scale(.92); }

@media (max-width: 760px) {
  .tabbar { display: block; }
  body { padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom)); }
  .site-footer { margin-bottom: .5rem; }
  /* Le bandeau cookies remonte pour ne pas passer sous la barre d'onglets. */
  .cookie-banner { bottom: calc(var(--tabbar-height) + var(--safe-bottom) + .75rem); }
}

/* ---------- Ajustements en mode application installée ---------- */
.is-app .site-header { padding-top: var(--safe-top); }

/* Installée, l'application n'a pas à vendre l'application. */
.is-app .install-prompt,
.is-app .install-cta { display: none !important; }

/* Le bandeau cookies n'a de sens que dans un navigateur. */
.is-app .cookie-banner { display: none !important; }

/* En mode application, la barre d'onglets remplace la navigation du haut. */
@media (max-width: 760px) {
  .is-app .nav-burger { display: none; }
  .is-app .site-nav { display: none !important; }
}

/* ---------- Confort tactile ---------- */
@media (pointer: coarse) {
  /* Cibles d'au moins 44 px, recommandation d'Apple — des doigts d'enfant
     et des mains gantées en hiver visent moins bien qu'une souris. */
  .checklist label { min-height: 44px; align-items: center; }
  .checklist input { width: 1.4rem; height: 1.4rem; margin-top: 0; }
  .quiz-option { min-height: 48px; }
  .btn { min-height: 44px; }
}

/* Empêche le zoom automatique d'iOS à la mise au point d'un champ :
   Safari zoome dès que la police descend sous 16 px. */
@supports (-webkit-touch-callout: none) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select,
  textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tabbar a .tab-icon { transition: none; }
}
