/* cenoutil — Feuille de styles principale
   Palette : vert Crétacé #2d7a4f / blanc craie / bleu mer
*/

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --vert:     #2d7a4f;
  --vert-dk:  #1a5c38;
  --vert-lt:  #e8f3e8;
  --craie:    #f5f2ec;
  --mer:      #7ab3d0;
  --text:     #1a1a1a;
  --text-sec: #555;
  --text-ter: #999;
  --border:   rgba(0,0,0,0.12);
  --bg:       #ffffff;
  --bg-sec:   #f7f5f0;
  --radius:   10px;
  --radius-lg:16px;
  font-size: 16px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-sec);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Layout principal ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ── Top bar ── */
.topbar {
  background: var(--vert);
  color: white;
  padding: 10px 14px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: 52px;
}
.topbar-logo { width: 32px; height: 32px; flex-shrink: 0; }
.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: 0.3px; }
.topbar-sub   { font-size: 10px; opacity: 0.72; margin-top: 1px; letter-spacing: 0.4px; }
.topbar-back {
  background: none; border: none; color: white;
  font-size: 22px; cursor: pointer; padding: 0 6px 0 0;
  line-height: 1;
}

/* ── Écrans (pages) ── */
.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; }

/* ── Contenu scrollable ── */
.scroll-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}
.scroll-content::-webkit-scrollbar { width: 3px; }
.scroll-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Nav bar ── */
.navbar {
  display: flex;
  border-top: 0.5px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px 8px;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 10px; color: var(--text-ter); }
.nav-item.active span { color: var(--vert); font-weight: 600; }
.nav-item.active svg { color: var(--vert); }

/* ── Accueil ── */
.hero {
  background: var(--vert);
  color: white;
  padding: 20px 16px 24px;
  text-align: center;
  flex-shrink: 0;
}
.hero svg { display: block; margin: 0 auto 12px; }
.hero-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.2px;
}
.hero-authors {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 6px;
  line-height: 1.5;
}
.home-cards { padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.home-card {
  background: var(--bg-sec);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.home-card:active { background: #ece9e3; }
.home-card-icon {
  width: 42px; height: 42px;
  background: var(--vert);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.home-card-icon svg { width: 22px; height: 22px; }
.home-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.home-card-sub   { font-size: 11px; color: var(--text-sec); margin-top: 2px; }
.home-card-chev  { color: var(--text-ter); font-size: 20px; margin-left: auto; }
.home-footer {
  padding: 10px 12px 14px;
  font-size: 10px;
  color: var(--text-ter);
  text-align: center;
  line-height: 1.5;
  margin-top: auto;
  border-top: 0.5px solid var(--border);
}

/* ── Infos ── */
.section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-ter);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 14px 0 6px;
}
.info-card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.info-card:active { background: var(--bg-sec); }
.info-card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.info-card-sub   { font-size: 11px; color: var(--text-sec); margin-top: 3px; line-height: 1.4; }
.info-card-img   {
  width: 100%; height: 52px;
  background: var(--bg-sec);
  border-radius: 6px;
  margin-top: 8px;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* ── Page détail info ── */
.info-detail {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.info-detail.active { display: flex; }
.info-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}
.info-detail-content h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--vert);
  margin-bottom: 10px;
  line-height: 1.3;
}
.info-detail-content p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 10px;
}
.info-detail-content figure {
  margin: 14px 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-sec);
  border: 0.5px solid var(--border);
}
.info-detail-content figure img {
  width: 100%;
  display: block;
  max-height: 260px;
  object-fit: cover;
}
.info-detail-content figcaption {
  font-size: 10px;
  color: var(--text-sec);
  padding: 5px 8px 6px;
  font-style: italic;
}

/* ── Carte ── */
#map {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #b8d4b0;
}
.map-status {
  background: var(--bg);
  border-top: 0.5px solid var(--border);
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-height: 32px;
}
.map-dot {
  width: 10px; height: 10px;
  background: var(--vert);
  border-radius: 50%;
  flex-shrink: 0;
}
/* Leaflet marker personnalisé */
.marker-cenoutil {
  width: 18px; height: 18px;
  background: var(--vert);
  border: 2.5px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  cursor: pointer;
}

/* ── Popup marqueur ── */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  padding: 0 !important;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18) !important;
}
.leaflet-popup-content { margin: 0 !important; }
.popup-inner {
  padding: 10px 12px;
  min-width: 160px;
}
.popup-title { font-size: 13px; font-weight: 700; color: var(--text); }
.popup-sub   { font-size: 11px; color: var(--text-sec); margin-top: 2px; }
.popup-photo {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
  background: var(--bg-sec);
}
.popup-btn {
  display: block;
  width: 100%;
  padding: 8px;
  background: var(--vert);
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border: none;
  cursor: pointer;
  letter-spacing: 0.3px;
}

/* ── Fiches détail (descente + observation) — position:fixed, indépendantes ── */
.site-detail,
.obs-detail {
  position: fixed;
  top: 52px;       /* sous la topbar principale */
  left: 0;
  right: 0;
  bottom: 56px;    /* au-dessus de la navbar */
  background: var(--bg);
  z-index: 800;
  display: none;
  flex-direction: column;
  overflow: hidden;
  max-width: 480px;
  margin: 0 auto;
}
.site-detail.active { display: flex; }
.obs-detail.active  { display: flex; }

/* Topbar ocre pour la fiche observation */
.obs-topbar {
  background: #8a6010;
  color: white;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  height: 48px;
}
.obs-topbar-title {
  font-size: 15px;
  font-weight: 600;
}
.btn-back-obs {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  -webkit-tap-highlight-color: rgba(255,255,255,0.2);
}
.btn-back-obs:active { background: rgba(255,255,255,0.18); }
.site-photo {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-sec);
  display: block;
  flex-shrink: 0;
}
.site-content { flex: 1; overflow-y: auto; padding: 14px; -webkit-overflow-scrolling: touch; }
.site-content h2 { font-size: 16px; font-weight: 700; color: var(--vert); margin-bottom: 4px; }
.site-coords { font-size: 11px; color: var(--text-ter); margin-bottom: 10px; font-family: monospace; }
.site-content p { font-size: 13px; line-height: 1.7; color: var(--text); }
.site-access {
  background: var(--vert-lt);
  border-left: 3px solid var(--vert);
  border-radius: 0 6px 6px 0;
  padding: 8px 10px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--vert-dk);
  line-height: 1.5;
}

/* ── Fossiles ── */
.fossil-search-bar {
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.fossil-search-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 0.5px solid var(--border);
  border-radius: 20px;
  background: var(--bg-sec);
  color: var(--text);
  outline: none;
}
.fossil-search-input:focus { border-color: var(--vert); }

.fossil-pills {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 0.5px solid var(--border);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.fossil-pills::-webkit-scrollbar { display: none; }
.pill {
  white-space: nowrap;
  font-size: 11px;
  padding: 4px 11px;
  border-radius: 20px;
  border: 0.5px solid var(--border);
  background: var(--bg);
  color: var(--text-sec);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.pill.active { background: var(--vert); color: white; border-color: var(--vert); }

.fossil-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.fossil-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-ter);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 12px 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-sec);
  position: sticky;
  top: 0;
  z-index: 10;
}
.group-badge {
  background: var(--vert-lt);
  color: var(--vert-dk);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.fossil-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  transition: background 0.12s;
}
.fossil-item:active { background: var(--bg-sec); }
.fossil-thumb {
  width: 48px; height: 48px;
  background: var(--bg-sec);
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.fossil-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fossil-name  { font-size: 13px; font-style: italic; font-weight: 600; color: var(--text); }
.fossil-group { font-size: 11px; color: var(--text-sec); margin-top: 2px; }
.fossil-chev  { color: var(--text-ter); font-size: 18px; margin-left: auto; }

/* ── Fiche fossile (plein écran) ── */
.fossil-detail {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.fossil-detail.active { display: flex; }
.fossil-detail-photo {
  width: 100%;
  height: 240px;
  object-fit: contain;
  background: #1a1a1a;
  display: block;
  flex-shrink: 0;
}
.fossil-detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}
.fossil-detail-name {
  font-size: 18px;
  font-style: italic;
  font-weight: 700;
  color: var(--vert);
  margin-bottom: 2px;
}
.fossil-detail-family {
  font-size: 11px;
  color: var(--text-sec);
  margin-bottom: 12px;
}
.fossil-detail-stage {
  display: inline-block;
  background: var(--vert-lt);
  color: var(--vert-dk);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.fossil-detail-content p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 10px;
}

/* ── Loading / erreur ── */
.loading-screen {
  position: absolute;
  inset: 0;
  background: var(--vert);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: white;
  gap: 16px;
  transition: opacity 0.4s;
}
.loading-screen.hidden { opacity: 0; pointer-events: none; }
.loading-title { font-size: 18px; font-weight: 700; letter-spacing: 1px; }
.loading-sub   { font-size: 12px; opacity: 0.7; }
.loading-bar {
  width: 120px; height: 3px;
  background: rgba(255,255,255,0.25);
  border-radius: 2px;
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  animation: load 1.5s ease-in-out forwards;
}
@keyframes load { from { width: 0; } to { width: 100%; } }

/* ── Utilitaires ── */
.hidden { display: none !important; }
.btn-back {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════
   MARQUEURS — différenciation visuelle
   ══════════════════════════════════════════════════ */

/* Descentes : cercle vert plein */
.marker-descente {
  width: 18px; height: 18px;
  background: #2d7a4f;
  border: 2.5px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  cursor: pointer;
}

/* Observations : cercle ocre */
.marker-observation {
  width: 16px; height: 16px;
  background: #b5820a;
  border: 2.5px solid white;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0,0,0,0.35);
  cursor: pointer;
}

/* Légende carte */
.map-legend {
  position: absolute;
  bottom: 38px;
  left: 8px;
  z-index: 900;
  background: rgba(255,255,255,0.92);
  border: 0.5px solid rgba(0,0,0,0.15);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 10px;
  color: #333;
  line-height: 1.8;
}
.legend-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid white;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
  vertical-align: middle;
  margin-right: 5px;
}

/* ══════════════════════════════════════════════════
   FICHE OBSERVATION
   ══════════════════════════════════════════════════ */

/* obs-detail géré dans le bloc commun ci-dessus */

/* Photo : hauteur naturelle (contain), pas de troncature */
.obs-photo-wrap {
  width: 100%;
  background: #111;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Pas de max-height ici : l'image s'affiche entièrement dans le flux scrollable */
}
.obs-photo {
  width: 100%;
  height: auto;
  object-fit: contain;   /* ← image entière visible, pas de troncature */
  display: block;
  cursor: zoom-in;
}
/* Bouton zoom photo */
.obs-photo-zoom {
  position: absolute;
  bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.55);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
}

/* Photo en plein écran (tap sur zoom) */
.obs-photo-fullscreen {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.obs-photo-fullscreen.active { display: flex; }
.obs-photo-fullscreen img {
  max-width: none;
  width: auto;
  height: auto;
  max-height: 100vh;
  cursor: zoom-out;
}
.obs-fullscreen-close {
  position: fixed;
  top: 12px; right: 14px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 2001;
}

/* Contenu structuré — tout scrolle ensemble (photo + champs) */
.obs-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.obs-header {
  padding: 12px 14px 10px;
  border-bottom: 0.5px solid var(--border);
}
.obs-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 3px;
}
.obs-coords {
  font-size: 10px;
  color: var(--text-ter);
  font-family: monospace;
  letter-spacing: 0.3px;
}

.obs-fields {
  padding: 0 14px 14px;
}

.obs-field {
  padding: 10px 0;
  border-bottom: 0.5px solid var(--border);
}
.obs-field:last-child { border-bottom: none; }

.obs-field-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-ter);
  margin-bottom: 4px;
}

.obs-field-value {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}

/* Badge stratigraphique */
.obs-strat-badge {
  display: inline-block;
  background: var(--vert-lt);
  color: var(--vert-dk);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 12px;
  border-left: 3px solid var(--vert);
}

/* Liste fossiles en chips */
.obs-fossiles-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}
.obs-fossile-chip {
  background: #fff8ee;
  border: 0.5px solid #ddb96a;
  color: #7a4e00;
  font-size: 11px;
  font-style: italic;
  padding: 3px 9px;
  border-radius: 12px;
}

/* Méta (date, observateurs) */
.obs-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.obs-meta-item { flex: 1; min-width: 120px; }

/* Popup observation */
.popup-obs-inner {
  padding: 10px 12px;
  min-width: 170px;
}
.popup-obs-badge {
  display: inline-block;
  background: #fff3d6;
  color: #7a4e00;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 8px;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Figure en tête de page info (Stratigraphie, Paléontologie) ── */
.info-figure-tete {
  margin: 0 0 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-sec);
  border: 0.5px solid var(--border);
}
.info-figure-tete img {
  width: 100%;
  height: auto;          /* hauteur naturelle — pas de troncature */
  display: block;
  object-fit: contain;
}

/* ── Géolocalisation — point de position pulsant ── */
.geo-dot {
  width: 16px;
  height: 16px;
  background: #1a73e8;
  border: 2.5px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(26,115,232,0.5);
  animation: geo-pulse 2s ease-out infinite;
  position: relative;
}
.geo-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(26,115,232,0.18);
  animation: geo-ring 2s ease-out infinite;
}
@keyframes geo-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(26,115,232,0.45); }
  70%  { box-shadow: 0 0 0 10px rgba(26,115,232,0); }
  100% { box-shadow: 0 0 0 0 rgba(26,115,232,0); }
}
@keyframes geo-ring {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Masquer le bouton boussole quand une fiche est ouverte */
.site-detail.active ~ #btn-geolocate,
.obs-detail.active  ~ #btn-geolocate { display: none; }
