/* ─────────────────────────────────────────────────
   KOSMOS — Homepage uniquement
   Fond de gravures dérivantes, vigne animée, widget
   iNaturalist, loader — rien de tout ça n'a de sens
   sur les autres gabarits, d'où un fichier à part
   (voir kosmos_enqueue(), gate is_front_page()).
   ───────────────────────────────────────────────── */

/* ── Loader plein écran — fondu ~300ms après montage (voir home.js) ──── */
.kv-loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: var(--fond);
  opacity: 1;
  transition: opacity 300ms ease;
}
.kv-loader.is-hidden { opacity: 0; pointer-events: none; }
.kv-loader__icon { width: 64px; height: 64px; animation: kv-spin 1.8s linear infinite; }
.kv-loader__label {
  font-family: var(--font-body); font-weight: 700; font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--mousse);
}

/* ── Portrait Humboldt (placeholder) — même langage visuel que les
   avatars colorés de l'Encyclopédie (.enc-avatar) : cercle + initiale,
   à remplacer par une vraie photo plus tard. ── */
.kv-portrait {
  width: 152px; height: 152px;
  margin-top: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--mousse);
  color: #fff;
  font-family: var(--font-display); font-weight: 900; font-size: 56px;
  overflow: hidden; flex-shrink: 0;
}
.kv-portrait img { width: 100%; height: 100%; object-fit: cover; }

/* ── Fond de gravures dérivantes — section #projet ──────────────────────
   Deux calques (arrière/avant le texte), peuplés par home.js. L'opacité
   d'ensemble suit le scroll (scrollGate) ; animation-play-state est
   coupé sur les deux calques quand la section quitte le viewport
   (classe .is-paused, posée par un IntersectionObserver) — le calcul le
   plus coûteux (l'aimant curseur en rAF) est lui aussi arrêté à ce
   moment côté JS, pas seulement les animations CSS. */
.kv-motes-host { position: relative; overflow: visible; isolation: isolate; }
.kv-motes-layer {
  position: absolute; inset: 0; top: -1px;
  pointer-events: none;
  opacity: 0;
}
.kv-motes-layer--back { z-index: 0; }
.kv-motes-layer--front { z-index: 3; }
.kv-mote { position: absolute; will-change: transform; }
.kv-mote__drift, .kv-mote__float { width: 100%; height: 100%; will-change: transform; }
.kv-mote__zoom {
  width: 100%; height: 100%; position: relative;
  pointer-events: auto;
  transition: transform .35s ease;
  will-change: transform;
}
.kv-mote__zoom img { width: 100%; height: 100%; object-fit: contain; display: block; will-change: transform; }
.kv-motes-host.is-paused .kv-mote__drift,
.kv-motes-host.is-paused .kv-mote__float,
.kv-motes-host.is-paused .kv-mote__zoom img {
  animation-play-state: paused;
}

@keyframes kv-current-a {
  0%   { transform: translate(0, 12vh) scale(0.7); opacity: 0; }
  10%  { opacity: 1; }
  55%  { transform: translate(16px, -68vh) scale(1); opacity: 1; }
  82%  { opacity: 0.25; }
  100% { transform: translate(-12px, -155vh) scale(0.88); opacity: 0; }
}
@keyframes kv-current-b {
  0%   { transform: translate(0, 12vh) scale(0.8); opacity: 0; }
  12%  { opacity: 1; }
  52%  { transform: translate(-20px, -62vh) scale(1.06); opacity: 1; }
  80%  { opacity: 0.25; }
  100% { transform: translate(18px, -155vh) scale(0.86); opacity: 0; }
}
@keyframes kv-current-c {
  0%   { transform: translate(0, 12vh) scale(0.75); opacity: 0; }
  14%  { opacity: 1; }
  50%  { transform: translate(10px, -58vh) scale(1); opacity: 1; }
  78%  { opacity: 0.25; }
  100% { transform: translate(-16px, -155vh) scale(0.9); opacity: 0; }
}
@keyframes kv-float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(4px, -8px); } }
@keyframes kv-spin { to { transform: rotate(360deg); } }
@keyframes kv-spin-rev { to { transform: rotate(-360deg); } }

/* ── Vigne animée — section #valeurs ─────────────────────────────────── */
.kv-values-host { position: relative; overflow: hidden; }
.kv-vine-clip {
  position: absolute; left: 0; bottom: 0;
  width: 100%; height: 220px;
  pointer-events: none;
  z-index: 3;
  overflow: hidden;
}
.kv-vine-track {
  position: absolute; bottom: 0; left: 0;
  width: 120%; height: 165%;
  transform: translateX(-100%);
  transition: transform 120ms linear;
}
.kv-vine-img { position: absolute; inset: 0; width: 100%; height: 191%; object-fit: contain; object-position: bottom left; }

/* ── Widget iNaturalist — section #biodiversite ──────────────────────── */
.kv-mini-label {
  display: block;
  font-family: var(--font-body); font-weight: 700; font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--mousse);
  margin: 0 0 16px;
}
.kv-inat-status { font-family: var(--font-editorial); font-style: italic; color: var(--mousse); font-size: 16px; }

.kv-inat-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 56px; }
.kv-inat-metric { padding: 24px 24px 28px; border: 1px solid var(--foret); }
.kv-inat-metric__label { margin-bottom: 14px; }
.kv-inat-metric__value { font-family: var(--font-body); font-weight: 500; font-size: 38px; color: var(--feuillage); }

.kv-inat-recent { display: grid; grid-template-columns: repeat(7, 1fr); gap: 20px; margin-bottom: 56px; }
@media (max-width: 900px) { .kv-inat-recent { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .kv-inat-recent { grid-template-columns: repeat(2, 1fr); } }
.kv-inat-card {
  display: block; text-decoration: none; color: var(--foret);
  border-radius: 14px; overflow: hidden;
  background: #FFFFFF;
  box-shadow: 0 8px 20px rgba(26, 46, 28, .14);
  transition: transform 150ms ease-out, box-shadow 150ms ease-out;
}
.kv-inat-card:hover { transform: translateY(-3px); box-shadow: 0 14px 28px rgba(26, 46, 28, .22); text-decoration: none; }
.kv-inat-card__photo { aspect-ratio: 1 / 1; background: var(--brume); overflow: hidden; }
.kv-inat-card__photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kv-inat-card__body { padding: 12px 14px 14px; }
.kv-inat-card__group { font-family: var(--font-body); font-weight: 700; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--mousse); margin-bottom: 4px; }
.kv-inat-card__name { font-family: var(--font-body); font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv-inat-card__latin { font-family: var(--font-editorial); font-style: italic; font-size: 12px; color: var(--mousse); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.kv-inat-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 48px; margin-bottom: 56px; }
.kv-inat-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--brume); }
.kv-inat-row__avatar { width: 44px; height: 44px; background: var(--brume); flex-shrink: 0; display: block; overflow: hidden; border-radius: 8px; }
.kv-inat-row__avatar--round { border-radius: 50%; }
.kv-inat-row__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kv-inat-row__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-body); font-size: 15px; color: var(--foret); }
.kv-inat-row__label em { font-family: var(--font-editorial); font-style: italic; color: var(--mousse); font-size: 13px; }
.kv-inat-row__count { font-family: var(--font-body); font-weight: 700; color: var(--foret); flex-shrink: 0; }
.kv-inat-more { background: none; border: none; padding: 12px 0 0; cursor: pointer; font-family: var(--font-body); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--feuillage); }

.kv-inat-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 48px; }
.kv-inat-histogram { display: flex; align-items: flex-end; gap: 5px; height: 150px; border-bottom: 1px solid var(--foret); }
.kv-inat-histogram__col { flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.kv-inat-histogram__bar { width: 100%; max-width: 20px; background: var(--foret); min-height: 2px; }
.kv-inat-histogram-labels { display: flex; gap: 5px; margin-top: 6px; }
.kv-inat-histogram-labels span { flex: 1; text-align: center; font-family: var(--font-body); font-size: 9px; letter-spacing: .04em; color: var(--mousse); text-transform: uppercase; }

.kv-inat-group-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.kv-inat-group-row__dot { width: 10px; height: 10px; flex-shrink: 0; }
.kv-inat-group-row__label { width: 100px; flex-shrink: 0; font-family: var(--font-body); font-size: 13px; color: var(--foret); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-inat-group-row__track { flex: 1; height: 8px; background: var(--brume); position: relative; }
.kv-inat-group-row__fill { position: absolute; left: 0; top: 0; height: 100%; }
.kv-inat-group-row__count { width: 22px; text-align: right; font-family: var(--font-body); font-weight: 700; font-size: 12px; color: var(--foret); }

.kv-inat-footer { margin-top: 40px; display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 12px; }
.kv-inat-credit { font-family: var(--font-body); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--mousse); }

/* ── Encyclopédie — encart de mise en avant en demi-largeur ─────────── */
.kv-encyclo {
  background: linear-gradient(180deg, #f8f6ef 0%, #ffffff 100%);
}
.kv-encyclo__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 28px;
  align-items: stretch;
}
@media (max-width: 900px) { .kv-encyclo__grid { grid-template-columns: 1fr; } }
.kv-encyclo__card,
.kv-encyclo__panel {
  border: 1px solid var(--line);
  background: #fffdf8;
  box-shadow: 0 14px 40px rgba(17, 41, 23, .05);
}
.kv-encyclo__card { padding: 36px 34px 34px; }
.kv-encyclo__panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 100%;
  padding: 30px 28px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.kv-encyclo__panel::after {
  content: "";
  position: absolute;
  inset: auto -20% -30% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(111, 148, 116, .16), rgba(111, 148, 116, 0) 68%);
  pointer-events: none;
}
.kv-encyclo__kicker {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--feuillage);
}
.kv-encyclo__title {
  display: block;
  max-width: 13ch;
  font-family: var(--font-display);
  font-size: clamp(28px, 3.5vw, 44px);
  line-height: .95;
  letter-spacing: -.03em;
  color: var(--foret);
}
.kv-encyclo__text {
  display: block;
  max-width: 28ch;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--mousse);
}
.kv-encyclo__panel .kv-link {
  margin-top: auto;
  position: relative;
  z-index: 1;
}
