/* Amitié TV 9D — navigation toujours visible sur ordinateur et mouvements doux.
   S'ajoute APRÈS 9C : n'efface ni le logo ni les traductions existantes. */

/* Bureau moyen : logo + langue en haut, TOUS les liens visibles en deuxième ligne.
   Le multiligne est volontaire, pour les libellés malagasy plus longs. */
@media (min-width: 900px) and (max-width: 1579px) {
  .site-header .header-inner {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "identite langue" "liens liens";
    align-items: center;
    column-gap: 16px;
    row-gap: 1px;
    min-height: 0;
    padding-top: 10px;
    padding-bottom: 9px;
  }
  .site-header .brand {
    grid-area: identite;
    margin: 0;
    order: initial;
    justify-self: start;
  }
  .site-header .am-language {
    grid-area: langue;
    margin: 0;
    order: initial;
    justify-self: end;
  }
  .site-header .menu-toggle { display: none; }
  .site-header .primary-nav,
  .site-header .primary-nav.is-open {
    grid-area: liens;
    position: static;
    display: flex;
    flex: 0 1 auto;
    flex-flow: row wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 9px;
    width: 100%;
    max-width: none;
    max-height: none;
    overflow: visible;
    margin: 0;
    padding: 6px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 12px;
  }
  .site-header .primary-nav > a {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    max-width: 100%;
    min-height: 35px;
    margin: 0;
    padding: 7px 9px;
    font-size: 12px;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: normal;
    text-align: center;
    border-radius: 8px;
  }
  .site-header .primary-nav > a.nav-donate {
    margin: 0;
    padding: 9px 13px;
    justify-content: center;
  }
}

/* Très larges écrans : les liens reviennent à côté du logo sur une seule rangée.
   Ils peuvent passer sur deux rangées de liens si une traduction le nécessite. */
@media (min-width: 1580px) {
  .site-header .header-inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 15px;
    padding-top: 9px;
    padding-bottom: 9px;
    min-height: 90px;
  }
  .site-header .brand { order: 1; margin: 0; }
  .site-header .primary-nav,
  .site-header .primary-nav.is-open {
    display: flex;
    position: static;
    flex: 1 1 auto;
    flex-flow: row wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 5px 8px;
    min-width: 0;
    width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    margin: 0 0 0 auto;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    order: 2;
  }
  .site-header .primary-nav > a {
    width: auto;
    flex: 0 0 auto;
    font-size: 12px;
    padding: 8px 6px;
    min-height: 37px;
    white-space: normal;
    text-align: center;
  }
  .site-header .primary-nav > a.nav-donate { margin: 0; padding: 10px 12px; }
  .site-header .am-language { order: 3; margin: 0; }
  .site-header .menu-toggle { display: none; }
}

/* Portable / tablette étroite : petit bouton et volet adapté à la taille réelle. */
@media (max-width: 899px) {
  .site-header .header-inner {
    position: relative;
    display: flex;
    flex-flow: row nowrap;
    justify-content: space-between;
    align-items: center;
    min-height: 73px;
    gap: 10px;
  }
  .site-header .brand { order: 1; margin-right: auto; }
  .site-header .am-language { order: 2; margin: 0; }
  .site-header .menu-toggle { display: flex; order: 3; }
  .site-header .primary-nav {
    order: 4;
    display: none;
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    left: auto;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 2px;
    width: min(390px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: min(76dvh, calc(100dvh - 96px));
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 12px;
    border: 1px solid #368fca;
    border-radius: 0 0 14px 14px;
    background: #071c45;
    box-shadow: 0 18px 34px rgba(1, 8, 32, .58);
    z-index: 80;
  }
  .site-header .primary-nav.is-open { display: flex; animation: am-menu-show .22s ease-out both; }
  .site-header .primary-nav > a {
    display: flex;
    flex: 0 0 auto;
    width: 100%;
    padding: 10px 13px;
    font-size: 14px;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .site-header .primary-nav > a.nav-donate { margin: 7px 0 0; }
}
@media (max-width: 420px) {
  .site-header .brand-copy { display: none; }
  .site-header .brand img { width: 53px; height: 53px; }
  .site-header .header-inner { gap: 8px; }
  .site-header .am-language select { min-width: 56px; }
  .site-header .primary-nav { max-height: calc(100dvh - 100px); }
}

/* Animation discrète : entrée, halos et micro-interactions sans effets agressifs. */
@keyframes am-menu-show {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes am-welcome {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes am-screen-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-7px); }
}
@keyframes am-play-glow {
  0%, 100% { box-shadow: 0 0 0 11px rgba(255, 221, 86, .08), 0 12px 30px rgba(1, 16, 58, .2); }
  50%      { box-shadow: 0 0 0 17px rgba(255, 221, 86, .025), 0 17px 42px rgba(1, 16, 58, .24); }
}
@keyframes am-light-shift {
  0%,100% { transform: translate3d(-3%, 0, 0); opacity: .55; }
  50% { transform: translate3d(5%, -3%, 0); opacity: .85; }
}
.hero { isolation: isolate; }
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at 77% 27%, rgba(48, 215, 248, .12), transparent 34%);
  animation: am-light-shift 14s ease-in-out infinite;
}
.hero-grid { z-index: 1; }
.hero-content { animation: am-welcome .65s both; }
.hero-screen { animation: am-welcome .65s .1s both, am-screen-float 6s ease-in-out .75s infinite; }
.hero-play { animation: am-play-glow 3.5s ease-in-out infinite; }
.site-header .primary-nav > a,
.site-header .brand img,
.site-header .am-language select {
  transition: color .2s ease, background .2s ease, border-color .2s ease, filter .2s ease;
}
.site-header .brand:hover img { filter: brightness(1.12) saturate(1.08); }
.site-header .primary-nav > a:not(.nav-donate):hover { background: rgba(44, 155, 230, .11); }
.btn, .btn-primary, .play-chip, .show-card, .am-card, .am9-result {
  transition: transform .24s ease, box-shadow .24s ease, border-color .24s ease, background .24s ease;
}
.btn:hover, .btn-primary:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0, 14, 50, .22); }
.show-card:hover, .am-card:hover, .am9-result:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 30px rgba(0, 8, 33, .23);
}
/* Animation au défilement : ajout de classes seulement si IntersectionObserver fonctionne. */
.am9d-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .5s ease, transform .5s ease;
}
.am9d-reveal.am9d-visible { opacity: 1; transform: translateY(0); }

/* Accessibilité : désactive les mouvements si la personne préfère moins d'animations. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero::before, .hero-content, .hero-screen, .hero-play,
  .site-header .primary-nav.is-open { animation: none !important; }
  .am9d-reveal, .am9d-reveal.am9d-visible {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .btn, .btn-primary, .show-card, .am-card, .am9-result,
  .site-header .primary-nav > a { transition: none !important; }
}
