/* =========================================================================
   Amorce - vitrine publique (site vitrine en lecture seule)
   Design sobre et editorial, parti pris : theme SOMBRE.
   Typographie 100% systeme (aucune webfont externe : la vitrine reste legere).
   La carte et la grille sont les heros ; palette limitee.
   ========================================================================= */

/* --- Variables de theme (palette volontairement restreinte) --------------- */
:root {
  --bg:        #14161a;   /* fond general, gris tres sombre neutre */
  --bg-soft:   #1c1f24;   /* surfaces (cartes, barre de filtres) */
  --bg-hover:  #262a30;   /* survol discret */
  --border:    #2e333b;   /* filets fins */
  --text:      #e7e9ec;   /* texte principal, presque blanc */
  --text-dim:  #9aa0a8;   /* texte secondaire */
  --accent:    #c9a05a;   /* accent unique, ocre sobre (esprit archive) */
  --accent-ink:#14161a;   /* texte sur accent */
  --danger:    #d98a6a;   /* messages d'erreur, terracotta doux */

  /* Couleurs par categorie (pastilles marqueurs + puces).
     Volontairement desaturees pour rester documentaire, pas criard. */
  --cat-a-classer: #8a94a6;
  --cat-texte:     #6f9e8f;
  --cat-image:     #b98a5e;
  --cat-autre:     #9a7fa8;
  --cat-default:   #7c8492;

  --radius: 6px;
  --maxw: 1200px;
  --gap: 1rem;
}

/* --- Reset leger ---------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
               Arial, "Noto Sans", sans-serif;
  line-height: 1.5;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

img { max-width: 100%; display: block; }

/* --- Conteneur centre ----------------------------------------------------- */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* --- En-tete -------------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 0 1.75rem;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.site-header .subtitle {
  margin: 0.4rem 0 0;
  color: var(--text-dim);
  font-size: 1rem;
}

.site-header .count {
  margin: 0.9rem 0 0;
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
}

.site-header .count strong {
  color: var(--text);
  font-weight: 600;
}

/* --- Titres de section ---------------------------------------------------- */
.section {
  padding: 2rem 0;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

/* --- Barre de filtres (pills) --------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
}

.filter-pill {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-pill:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.filter-pill.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 600;
}

/* Petite pastille de couleur par categorie dans la pill */
.filter-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--cat-default);
}

/* --- Carte ---------------------------------------------------------------- */
#map {
  width: 100%;
  height: 460px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Fond sombre pendant le chargement (la carte est sombre, voir MAP_STYLES dans app.js). */
  background: var(--bg-soft);
  z-index: 0; /* garde la carte sous la lightbox */
}

@media (min-width: 700px) {
  #map { height: 540px; }
}

/* Contenu des bulles Google Maps (InfoWindow, fond blanc) */
.popup-card {
  width: 160px;
}
.popup-card img {
  width: 160px;
  height: 110px;
  object-fit: cover;
  border-radius: 4px;
  background: #000;
}
.popup-card .popup-cat {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: #333;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.popup-card .popup-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block;
  background: var(--cat-default);
}

/* --- Grille des derniers ajouts ------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: 1fr;           /* mobile : 1 colonne */
  gap: var(--gap);
}

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 860px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

.card {
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  transition: border-color 0.15s, transform 0.15s;
  text-align: left;
  padding: 0;
  font: inherit;
  color: inherit;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card .thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #000;
}

.card .meta {
  padding: 0.6rem 0.75rem 0.75rem;
}

.card .meta .author {
  font-size: 0.9rem;
  font-weight: 600;
}

.card .meta .cat {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.card .meta .cat .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cat-default);
}

/* --- Bouton "Charger plus" ------------------------------------------------ */
.load-more-row {
  margin-top: 1.5rem;
  text-align: center;
}

.btn {
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1.4rem;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* --- Etats (chargement, erreur, vide) ------------------------------------- */
.state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.state.error {
  color: var(--danger);
  border-color: var(--danger);
}
.state.hidden { display: none; }

/* --- Lightbox ------------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;                     /* au-dessus de la carte Leaflet */
  background: rgba(10, 11, 13, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.lightbox.hidden { display: none; }

.lightbox-inner {
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lightbox-inner img {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  background: #000;
}

.lightbox-meta {
  padding: 0.9rem 1.1rem 1.1rem;
  border-top: 1px solid var(--border);
}
.lightbox-meta .lb-author {
  font-size: 1rem;
  font-weight: 600;
}
.lightbox-meta .lb-cat {
  font-size: 0.82rem;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.6rem;
}
.lightbox-meta .lb-cat .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--cat-default);
}
.lightbox-meta .lb-note {
  margin: 0.6rem 0 0;
  color: var(--text);
  font-size: 0.95rem;
}
.lightbox-meta .lb-date {
  margin: 0.5rem 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: var(--bg-hover); }

/* --- Pied de page --------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  padding: 2rem 0 3rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.site-footer p { margin: 0.35rem 0; }
.site-footer strong { color: var(--text); font-weight: 600; }

/* --- Encart de presentation de l'app -------------------------------------- */
.encart-app {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 1.4rem 1.5rem;
}

@media (min-width: 860px) {
  .encart-app {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 2.5rem;
  }
  .encart-texte { flex: 1 1 auto; }
  .encart-liens { flex: 0 0 auto; }
}

.encart-titre {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.encart-texte p {
  margin: 0 0 0.6rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  max-width: 62ch;
}
.encart-texte p:last-child { margin-bottom: 0; }
.encart-texte strong { color: var(--text); font-weight: 600; }

/* Mention "reserve aux etudiants" : on la distingue sans crier. */
.encart-note {
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  font-size: 0.9rem;
}

/* Boutons de telechargement */
.encart-liens {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 230px;
}

.btn-store {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.btn-store:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.btn-store-os {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.btn-store-quoi {
  font-size: 0.92rem;
  font-weight: 600;
}

/* Android pas encore distribue : meme gabarit, mais inactif. */
.btn-store.is-attente {
  opacity: 0.55;
  cursor: default;
}
.btn-store.is-attente:hover {
  border-color: var(--border);
  background: var(--bg);
}

/* --- Sous le capot : l'API ------------------------------------------------- */
.api-intro,
.api-astuce {
  color: var(--text-dim);
  max-width: 62ch;
  line-height: 1.55;
}
.api-astuce strong { color: var(--text); font-weight: 600; }

.api-list {
  list-style: none;
  margin: 1.25rem 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}
.api-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.api-url {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.api-url:hover code { color: var(--accent); }
.api-url code { font-size: 0.95rem; }
.api-verb {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
}
.api-role {
  margin: 0.4rem 0 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
