/* ============================================================
   STYLE.CSS
   ------------------------------------------------------------
   Esthétique : carnet / archive / table de pensée.
   Fond clair "papier", encre sombre, une touche de rouge
   d'archive pour les accents. Typographie : un serif pour
   les titres (sensation de livre), un sans-serif sobre pour
   le reste.

   Pour changer l'ambiance générale, modifier les variables
   dans :root ci-dessous.
   ============================================================ */

:root {
  --paper:      #eef0fb;
  --paper-2:    #ffffff;
  --ink:        #2e33a6;
  --ink-soft:   #6066c9;
  --accent:     #4750d6;
  --line:       #c9cdf2;
  --serif:      "Iowan Old Style", "Palatino Linotype", "Georgia", serif;
  --sans:       -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono:       "SF Mono", "IBM Plex Mono", "Courier New", monospace;

  --radius:     2px;
  --ease:       cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

* {
  scrollbar-width: none;
}
*::-webkit-scrollbar {
  display: none;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  height: 100vh;
  overflow: hidden;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

.app {
  position: relative;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* texture de fond très légère, façon papier */
.texture {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,0.035) 1px, transparent 0);
  background-size: 14px 14px;
  opacity: .6;
}


/* ============================================================
   VUES — une seule visible à la fois
   ============================================================ */
.view {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity .45s var(--ease), transform .45s var(--ease), visibility .45s;
  display: flex;
  flex-direction: column;
}

.view.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  z-index: 2;
}


/* ============================================================
   ACCUEIL
   ============================================================ */
#view-home {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 8vh 7vw;
  overflow-y: auto;
}

.home-inner {
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.title-image {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
}

/* bouton Explore */
.explore-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 10px 18px;
  background: transparent;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
  align-self: flex-start;
}

.explore-btn:hover {
  background: var(--accent);
  color: var(--paper-2);
}

.explore-btn:active {
  opacity: .85;
}

/* focus clavier visible sur les hotspots */
.map-hotspot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  background: var(--accent);
}

.home-content {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.intro {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  margin: 0;
  text-align: justify;
  flex: 1;
}

/* phrase d'intro numérique — légèrement distincte du corps */
.intro-digital {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--ink-soft);
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  margin-bottom: 1.4em;
  line-height: 1.7;
  text-align: left;
}

.colophon {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: .03em;
  color: var(--ink-soft);
  text-align: center;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* liste des noms — plus d'espace sur mobile */
.colophon-names {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* séparateur asterisques — évoque le passage imprimé → numérique */
.colophon-separator {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 6px 0;
  opacity: .35;
  letter-spacing: .12em;
}

/* note version numérique */
.colophon-digital-note {
  font-style: italic;
  letter-spacing: .08em;
  opacity: .6;
}

@media (min-width: 900px) {
  .home-inner { max-width: 1100px; }

  .home-content {
    flex-direction: row;
    align-items: flex-start;
    gap: 48px;
  }

  .intro {
    font-size: 18px;
    line-height: 1.8;
  }

  .colophon {
    flex: 0 0 280px;
    text-align: left;
    padding-top: 0;
    border-top: none;
    border-left: 1px solid var(--line);
    padding-left: 32px;
  }

  .colophon-names {
    align-items: flex-start;
  }
}

.colophon-line {
  margin: 0;
}

.colophon-thanks {
  margin: 6px 0 0;
  font-style: italic;
}

.home-nav {
  display: flex;
  gap: 12px;
  width: 100%;
}

.nav-card {
  flex: 1;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink);
  transition: transform .25s var(--ease), background .25s var(--ease);
}

.nav-card:active {
  transform: scale(.97);
  background: var(--paper);
}


/* ============================================================
   EN-TÊTES DE VUE (mindmap / cartes)
   ============================================================ */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--paper);
  z-index: 5;
}

.view-header h2 {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: .04em;
  margin: 0;
}

.back-btn, .reset-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  transition: background .2s var(--ease);
}

.back-btn:active, .reset-btn:active {
  background: var(--paper-2);
}

.back-btn, .reset-btn, .zoom-btn {
  font-family: var(--mono);
}

.spacer { width: 36px; height: 36px; }

/* compteur de coordonnées (mono, façon terminal) */
.coord-readout {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 15;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .05em;
  color: var(--ink-soft);
  background: rgba(255,255,255,.75);
  padding: 3px 8px;
  border-radius: 3px;
  pointer-events: none;
  white-space: nowrap;
}


/* ============================================================
   MIND MAP — pan / zoom
   ============================================================ */
.mindmap-viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
  background:
    repeating-linear-gradient(0deg, transparent 0 23px, var(--line) 23px 24px),
    repeating-linear-gradient(90deg, transparent 0 23px, var(--line) 23px 24px);
  background-size: 24px 24px;
  background-color: var(--paper-2);
}

.mindmap-viewport.grabbing {
  cursor: grabbing;
}

.mindmap-stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#mindmap-image {
  display: block;
  max-width: none;
  width: 1400px;     /* doit correspondre à STAGE_W dans script.js */
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  background: #fff;
}

.zoom-controls {
  display: flex;
  gap: 8px;
}

.zoom-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  transition: background .2s var(--ease);
}

.zoom-btn:active { background: var(--paper-2); }

/* hotspots cliquables sur la big map */
.map-hotspot {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: rgba(71,80,214,.18);
  cursor: pointer;
  z-index: 10;
  pointer-events: auto;
  transition: transform .2s var(--ease), background .2s var(--ease);
}

.map-hotspot:hover,
.map-hotspot:active,
.map-hotspot--highlight {
  background: var(--accent);
  transform: scale(1.2);
}

/* pulsation discrète pour signaler que c'est cliquable */
.map-hotspot::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: .5;
  animation: hotspot-pulse 2.4s ease-out infinite;
}

/* marqueur "déjà visité" : discret, sous les hotspots */
.map-trail-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: .35;
  z-index: 5;
  pointer-events: none;
}

@keyframes hotspot-pulse {
  0%   { transform: scale(.8); opacity: .5; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* traçage du chemin parcouru (big map -> cartes) */
.path-trace-overlay {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  pointer-events: none;
}

.path-trace-line {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 4 6;
  fill: none;
  opacity: .6;
}

.path-trace-dot {
  fill: var(--accent);
  opacity: .8;
}


/* ============================================================
   LISTE DES TEXTES — sous la big map (mobile)
   sur desktop : panneau gauche côte à côte avec la carte
   ============================================================ */
.texts-list {
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding: 10px 14px 16px;
  background: var(--paper-2);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.mindmap-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* mobile : carte + barre nav + liste = 55 / 45 */
.mindmap-body .mindmap-viewport    { order: 1; flex: 1 1 55%; min-height: 0; }
.mindmap-body .mindmap-mobile-nav  { order: 2; flex-shrink: 0; }
.mindmap-body .texts-list          { order: 3; flex: 0 0 38%; min-height: 0; overflow-y: auto; }

/* ---- layout desktop : liste gauche / carte droite ---- */
@media (min-width: 768px) {
  #view-mindmap {
    flex-direction: column;
  }

  .mindmap-body {
    flex-direction: row;
  }

  /* reset mobile order — list comes first in DOM so it's naturally left */
  .mindmap-body .texts-list        { order: 0; }
  .mindmap-body .mindmap-viewport  { order: 0; }

  .texts-list {
    flex: 0 0 300px;
    max-height: none;
    height: 100%;
    border-top: none;
    border-right: 1px solid var(--line);
    overflow-y: auto;
    padding: 18px 16px 32px;
  }

  .mindmap-viewport {
    flex: 1;
  }
}

.texts-list-title {
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.texts-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.texts-list-link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 6px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  transition: background .2s var(--ease);
}

.texts-list-link:active {
  background: var(--paper);
}

/* sur desktop : contenu en bloc (auteur / titre / date empilés) */
@media (min-width: 768px) {
  .texts-list-link {
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px;
  }

  .texts-list-pdf-icon {
    margin-top: 3px;
  }

  /* wrapper texte en colonne */
  .texts-list-text-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .texts-list-author {
    white-space: normal;
    flex-shrink: 1;
  }

  .texts-list-title-text {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    font-size: 13px;
    line-height: 1.4;
  }
}

/* icône PDF à gauche */
.texts-list-pdf-icon {
  flex-shrink: 0;
  width: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  opacity: .9;
  margin-top: 1px;
}
.texts-list-pdf-icon--none {
  opacity: .18;
}

/* année inline après le titre */
.texts-list-year {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--mono);
  letter-spacing: .04em;
}

/* flèches nav dans le titre de la liste */
.texts-list-nav {
  display: inline-flex;
  gap: 4px;
  margin-left: 10px;
  vertical-align: middle;
}

.texts-list-nav-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper-2);
  transition: background .15s var(--ease), color .15s var(--ease);
  line-height: 1;
}

.texts-list-nav-btn:active {
  background: var(--accent);
  color: var(--paper-2);
  border-color: var(--accent);
}

/* élément actif via nav */
.texts-list-item--nav-active .texts-list-link {
  background: var(--paper);
  box-shadow: inset 2px 0 0 var(--accent);
}
.texts-list-item--nav-active .texts-list-author,
.texts-list-item--nav-active .texts-list-title-text {
  color: var(--accent);
}

.texts-list-author {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
}

.texts-list-title-text {
  font-family: var(--serif);
  font-size: 14px;
  flex: 1;
}

/* items sans PDF : légèrement atténués mais toujours cliquables (long press → carte) */
.texts-list-item--disabled .texts-list-title-text,
.texts-list-item--disabled .texts-list-year {
  opacity: .5;
}

.texts-list-item.highlight .texts-list-link {
  background: var(--paper);
}

.texts-list-item--pulse .texts-list-link {
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--accent);
  transition: box-shadow .4s var(--ease), background .2s var(--ease);
}

.texts-list-item.highlight .texts-list-author,
.texts-list-item.highlight .texts-list-title-text {
  color: var(--accent);
}

.texts-list-item.selected .texts-list-link {
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}




/* ============================================================
   CONSTELLATION DE CARTES
   ============================================================ */
.cards-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 16px 14px 40px;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
    padding: 24px 28px 60px;
  }
}
@media (min-width: 1000px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1600px;
    margin: 0 auto;
    gap: 40px;
    padding: 32px 48px 80px;
  }
}


/* ============================================================
   CARTE — recto/verso uniquement, clic = retourner / revenir
   ============================================================ */
.card-block {
  width: 100%;
  animation: rise .5s var(--ease) both;
  border-radius: 8px;
  transition: box-shadow .4s var(--ease);
}

.card-block--highlight {
  box-shadow: 0 0 0 3px var(--accent);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* recto/verso, clic = retournement (et reclic = retour) */
.flip-card {
  position: relative;
  width: 100%;
  aspect-ratio: 0.715;
  perspective: 1800px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(46,51,166,.08);
  overflow: hidden;
}

.flip-inner {
  position: absolute;
  inset: 0;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .7s var(--ease);
}

.flip-inner.flipped {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--paper-2);
  overflow: hidden;
}

.flip-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.flip-back {
  transform: rotateY(180deg);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--mono);
}

.card-counter {
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.card-back-to-map {
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  transition: background .2s var(--ease);
}

.card-back-to-map:active {
  background: var(--paper);
}


/* ============================================================
   Petits écrans très étroits
   ============================================================ */
@media (max-width: 360px) {
  .title { font-size: 38px; }
}


/* ============================================================
   TABBAR — navigation fixe, présente sur les 3 vues
   ============================================================ */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0 8px;
  font-family: var(--mono);
  color: var(--ink-soft);
  transition: color .2s var(--ease), background .2s var(--ease);
}

.tabbar-item:active {
  background: var(--paper);
}

.tabbar-icon {
  font-size: 18px;
  line-height: 1;
}

.tabbar-label {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tabbar-item.active {
  color: var(--accent);
}

.tabbar-item.active .tabbar-icon {
  transform: scale(1.1);
}


/* compense la hauteur de la tabbar dans chaque vue */
.view {
  padding-bottom: 56px;
}

#view-home {
  padding-bottom: calc(8vh + 56px);
}

/* ============================================================
   MIND MAP — contrôles
   ============================================================ */
/* ====== BARRE NAV MOBILE entre carte et liste ====== */
.mindmap-mobile-nav {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  order: 2;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
  touch-action: manipulation;
}

@media (min-width: 768px) {
  .mindmap-mobile-nav { display: none; }
}

.mobile-nav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-family: var(--mono);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-2);
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s var(--ease), color .15s var(--ease);
  flex-shrink: 0;
}

.mobile-nav-btn:active {
  background: var(--accent);
  color: var(--paper-2);
  border-color: var(--accent);
}

/* bouton audio en overlay haut droit du viewport */
.viewport-audio-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 15;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(46,51,166,.1);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}

.viewport-audio-btn:active,
.viewport-audio-btn.playing {
  background: var(--accent);
  color: var(--paper-2);
  border-color: var(--accent);
}

/* sidebar desktop — reste inchangée */
.mindmap-sidebar {
  display: none;
}

@media (min-width: 768px) {
  .mindmap-sidebar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 0 0 52px;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    background: var(--paper-2);
    padding: 16px 0;
  }
}

.sidebar-nav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-family: var(--mono);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-2);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
  flex-shrink: 0;
}

.sidebar-nav-btn:hover {
  background: var(--paper);
  transform: scale(1.08);
}

.sidebar-nav-btn:active {
  background: var(--accent);
  color: var(--paper-2);
  border-color: var(--accent);
}

.sidebar-divider {
  width: 20px;
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.sidebar-audio-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-2);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
  flex-shrink: 0;
}

.sidebar-audio-btn:hover {
  background: var(--paper);
}

.sidebar-audio-btn:active,
.sidebar-audio-btn.playing {
  background: var(--accent);
  color: var(--paper-2);
  border-color: var(--accent);
}
.map-audio-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(46,51,166,.07);
  transition: background .15s var(--ease), color .15s var(--ease);
  cursor: pointer;
  flex-shrink: 0;
}

.map-audio-btn:active,
.map-audio-btn.playing {
  background: var(--accent);
  color: var(--paper-2);
  border-color: var(--accent);
}
.map-ctrl-divider {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 3px;
  flex-shrink: 0;
}

/* icône vue d'ensemble légèrement plus petite */
.map-ctrl-reset svg {
  display: block;
}