/* =========================================================================
   STYLES — palette volontairement minimale : tout dérive de 4 familles de
   variables (--bg-*, --ink/--muted, --surface/--line, --accent), que le
   moteur de thème (app.js) fait glisser du jour à la nuit.
   ========================================================================= */

:root {
  /* valeurs par défaut = matin clair (recalculées par app.js) */
  --bg-top: #c8e6fa;
  --bg-bottom: #eef8fe;
  --ink: #16283a;
  --muted: rgba(22, 40, 58, 0.6);
  --line: rgba(22, 40, 58, 0.16);
  --surface: rgba(255, 255, 255, 0.5);
  --surface-strong: rgba(255, 255, 255, 0.72);
  --accent: #1273c4;
  --accent-soft: rgba(18, 115, 196, 0.16);
  --on-accent: #ffffff;

  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ==== couches de fond ==================================================== */
#planet, #particles {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}
#planet { z-index: 0; }
#particles { z-index: 1; }

#content { position: relative; z-index: 2; }

/* ==== barre fixe ========================================================= */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 10px clamp(14px, 3vw, 28px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
}

.me { display: flex; align-items: center; gap: 14px; min-width: 0; }

.avatar {
  position: relative;
  width: 52px; height: 52px;
  flex: none;
  border-radius: 50%;
}
.avatar img {
  position: absolute; inset: 3px;
  width: calc(100% - 6px); height: calc(100% - 6px);
  border-radius: 50%;
  object-fit: cover;
  filter: saturate(0.95) contrast(1.05);
  transition: opacity 0.5s ease;
}
#photoB { opacity: 0; }
.avatar-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), transparent 40%, var(--accent) 65%, transparent 90%, var(--accent));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
  animation: spin 9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.idcard { min-width: 0; overflow: hidden; }
.idcard h1 { font-size: 1.02rem; font-weight: 750; letter-spacing: 0.01em; white-space: nowrap; }
.tagline {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.links { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.loc {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.links a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 8px;
  color: var(--muted);
  transition: color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.links a:hover { color: var(--accent); background: var(--accent-soft); transform: translateY(-2px); }

/* ---- mini-circuit "Resume" dans la barre, à droite du nom ---- */
#miniCircuit {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-left: 6px;
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.25s, box-shadow 0.3s, transform 0.3s var(--ease);
}
#miniCircuit:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 26px var(--accent-soft);
}
.mini-label {
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.mini-wires { display: flex; align-items: center; gap: 7px; }
.mini-kets {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 42px;
  padding: 3px 0;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 600;
  color: var(--accent);
}
.mini-rail { position: relative; }
.mwire {
  position: absolute;
  left: -6px; right: -8px;
  height: 1.5px;
  background: var(--line);
}
.mwire-top { top: 10px; }
.mwire-bot { bottom: 10px; }
.mini-gates {
  position: relative;
  display: flex;
  height: 42px;
  /* l'écart horizontal (proportionnel aux dates) est posé par app.js */
}
.mgate {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: 1.2px solid var(--accent);
  border-radius: 6px;
  background: var(--surface-strong);
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  overflow: hidden;
}
.mgate img {
  display: block;
  width: 14px; height: 14px;
  object-fit: contain;
  border-radius: 3px;
}
/* chronologie de gauche à droite : expériences sur le fil du haut, éducation en bas */
.mgate.exp { align-self: flex-start; }
.mgate.edu { align-self: flex-end; }
.mgate.both { align-self: center; position: relative; }
.mgate.both::before {
  content: "";
  position: absolute;
  top: -11px; bottom: -11px;
  left: 50%;
  width: 1.5px;
  background: var(--accent);
  opacity: 0.5;
  z-index: -1;
}

/* ---- contrôles ---- */
.controls { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 600;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s var(--ease);
}
.pill:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 4px 18px var(--accent-soft); }

#langBtn .lang-sep { opacity: 0.4; margin: 0 1px; }
#langBtn span { opacity: 0.45; transition: opacity 0.2s, color 0.2s; }
#langBtn.fr .lang-fr, #langBtn.en .lang-en { opacity: 1; color: var(--accent); }

#potatoBtn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.skywrap {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.sky-icon { color: var(--muted); flex: none; }
.sky-icon.sun { color: #e8a021; }
.sky-icon.moon { color: #8d86c9; }

#sky {
  appearance: none; -webkit-appearance: none;
  width: clamp(68px, 9vw, 110px);
  height: 7px;
  border-radius: 999px;
  /* le jour n'occupe que le début de la course : la nuit domine */
  background: linear-gradient(90deg, #aadcff 0%, #ffd9a0 13%, #e08e5e 28%, #7c5ba6 48%, #10142e 100%);
  outline-offset: 4px;
  cursor: ew-resize;
}
#sky::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px var(--accent-soft), 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
#sky::-webkit-slider-thumb:hover { transform: scale(1.2); }
#sky::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}

/* ==== héros ============================================================== */
.hero {
  padding: calc(11vh + 70px) clamp(18px, 6vw, 90px) 10vh;
  max-width: 780px;
}

.ket-line {
  font-family: var(--mono);
  font-size: clamp(0.82rem, 1.6vw, 1rem);
  color: var(--accent);
  margin-bottom: 18px;
  animation: fadeUp 0.9s var(--ease) both;
}
.hero h2 {
  font-size: clamp(2.1rem, 5.4vw, 3.7rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.06;
  animation: fadeUp 0.9s 0.12s var(--ease) both;
}
.hero-sub {
  margin-top: 18px;
  max-width: 52ch;
  font-size: clamp(0.95rem, 1.7vw, 1.08rem);
  color: var(--muted);
  line-height: 1.6;
  animation: fadeUp 0.9s 0.24s var(--ease) both;
}

.gateset { margin-top: 44px; animation: fadeUp 0.9s 0.36s var(--ease) both; }
.gateset-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 12px;
}
.gateset-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 5px 13px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
  transition: transform 0.25s var(--ease), border-color 0.2s, box-shadow 0.3s;
}
.chip:hover { transform: translateY(-3px) rotate(-1deg); border-color: var(--accent); box-shadow: 0 8px 24px var(--accent-soft); }
.chip .g {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1.5px solid var(--accent);
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: var(--accent-soft);
}

.scroll-hint {
  margin-top: 60px;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  animation: fadeUp 0.9s 0.5s var(--ease) both;
}
.scroll-hint svg { animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* ==== circuit ============================================================ */
.circuit {
  max-width: 660px;
  margin: 0 0 0 clamp(0px, 3vw, 44px);
  padding: 0 18px 60px;
}

/* les kets ouvrent et ferment le circuit */
.rail-heads {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.rail-heads.top { margin-bottom: 30px; }
.rail-heads.bottom { margin-top: 30px; }
.rail-head { display: flex; justify-content: center; }
.ket {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  backdrop-filter: blur(8px);
}

#wires {
  position: relative;
  padding: 10px 0 0;
}
.rail {
  position: absolute;
  top: -30px; bottom: -30px;
  width: 2px;
  background: var(--line);
  overflow: hidden;
}
.rail-left { left: calc(25% - 1px); }
.rail-right { left: calc(75% - 1px); }
.rail::after {
  content: "";
  position: absolute;
  left: -2px;
  width: 6px; height: 110px;
  border-radius: 3px;
  background: linear-gradient(180deg, transparent, var(--accent), transparent);
  animation: railPulse 6.5s linear infinite;
}
.rail-right::after { animation-delay: -3.2s; }
@keyframes railPulse {
  from { top: -120px; }
  to { top: 100%; }
}

/* ---- une porte du circuit ---- */
.entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(30px) scale(0.97);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.entry.in { opacity: 1; transform: none; }
/* l'espacement vertical (proportionnel aux dates) est posé par app.js */
.entry.edu { width: 50%; }
.entry.exp { width: 50%; margin-left: 50%; }
.entry.both { width: 100%; position: relative; }

/* pont horizontal de la porte à 2 qubits */
.entry.both::before {
  content: "";
  position: absolute;
  top: 33px;
  left: 25%; right: 25%;
  height: 2px;
  background: var(--line);
}
.entry.both .qnode {
  position: absolute;
  top: 33px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 12px var(--accent-soft);
}
.entry.both .qnode.l { left: 25%; }
.entry.both .qnode.r { left: 75%; }

.gate {
  position: relative;
  z-index: 1;
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  background: var(--surface-strong);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
  transition: box-shadow 0.3s, transform 0.3s var(--ease);
}
.gate-glyph {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--accent);
}
.gate .logowrap {
  width: 50px; height: 50px;
  display: grid; place-items: center;
  overflow: hidden;
  border-radius: 8px;
}
.gate .logowrap img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: 8px;
  /* niveaux + duotone deux couleurs (#logoDuotone) appliqués par app.js */
  filter: grayscale(1);
}

.entry:hover .gate, .entry.pinned .gate {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 10px 34px var(--accent-soft);
}

.card {
  margin-top: 14px;
  width: min(304px, calc(100% - 10px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.07);
  transition: transform 0.3s var(--ease), border-color 0.25s, box-shadow 0.3s;
}
.entry:hover .card, .entry.pinned .card {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 14px 40px var(--accent-soft);
}
.card .track-tag {
  display: none;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--accent);
  margin-bottom: 5px;
}
.card .period {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}
.card h3 { font-size: 0.98rem; font-weight: 700; line-height: 1.3; }
.card .org { font-size: 0.82rem; color: var(--muted); margin-top: 3px; font-weight: 600; }
.card .desc { font-size: 0.82rem; color: var(--muted); line-height: 1.55; margin-top: 9px; }
.card .place {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 11px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
}
.card .place .hint { opacity: 0; transition: opacity 0.25s; font-weight: 500; }
.entry:hover .place .hint, .entry.pinned .place .hint { opacity: 0.8; }

footer {
  padding: 60px 18px 34px;
  text-align: center;
  font-size: 0.74rem;
  font-family: var(--mono);
  color: var(--muted);
}

/* ==== panneau de détail — entre le circuit et la planète ================= */
#detail {
  position: fixed;
  top: 50%;
  /* juste à droite du circuit (~660px + marge), sans sortir de l'écran */
  left: min(700px, calc(100vw - 710px));
  z-index: 11;
  width: min(690px, calc(100vw - 40px));
  max-height: min(86vh, 920px);
  overflow-y: auto;
  padding: 34px 38px 38px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--surface-strong);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28), 0 0 0 6px var(--accent-soft);
  opacity: 0;
  transform: translateY(-50%) translateX(26px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.45s var(--ease);
}
#detail.open { opacity: 1; transform: translateY(-50%); pointer-events: auto; }
#detailClose {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 0.85rem;
  transition: border-color 0.2s, background 0.2s;
}
#detailClose:hover { border-color: var(--accent); background: var(--accent-soft); }
#detail .d-track {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 8px;
}
#detail .d-period {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}
#detail .d-title { margin-top: 7px; font-size: 1.7rem; font-weight: 750; line-height: 1.25; }
#detail .d-org { margin-top: 6px; font-size: 1.12rem; font-weight: 600; color: var(--muted); }
#detail .d-more { margin-top: 16px; font-size: 1.16rem; line-height: 1.68; color: var(--ink); opacity: 0.88; }
#detail .d-photos {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
#detail .d-photos:empty { display: none; }
#detail .d-photos img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 11px;
  border: 1px solid var(--line);
}
#detail .d-place {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 7px 15px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 650;
}

/* ==== étiquette de lieu ================================================== */
#placeChip {
  position: fixed;
  right: 26px; bottom: 24px;
  z-index: 9;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface-strong);
  backdrop-filter: blur(12px);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 650;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.35s, transform 0.35s var(--ease);
  pointer-events: none;
}
#placeChip.show { opacity: 1; transform: none; }

/* ==== animations génériques ============================================= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* ==== mode patate ======================================================== */
body.potato #topbar,
body.potato .card,
body.potato .chip,
body.potato .ket,
body.potato #detail,
body.potato #miniCircuit,
body.potato #placeChip { backdrop-filter: none; -webkit-backdrop-filter: none; }
body.potato .rail::after { animation: none; opacity: 0; }
body.potato .avatar-ring { animation: none; }
body.potato .scroll-hint svg { animation: none; }
body.potato .entry { transition-duration: 0.25s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01s !important; transition-duration: 0.01s !important; }
}

/* ==== responsive ========================================================= */
@media (max-width: 940px) {
  #miniCircuit { display: none; }
}

@media (max-width: 820px) {
  .tagline { max-width: 38vw; }

  /* la planète règne sur la moitié haute ; le contenu défile
     dans les 80% inférieurs de l'écran, sans jamais recouvrir le haut */
  body { overflow: hidden; }
  #content {
    position: fixed;
    top: 20vh; bottom: 0; left: 0; right: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .hero { padding-top: 31vh; padding-bottom: 4vh; }
  .circuit { margin: 0 auto; }

  /* éducation à gauche, expérience à droite (symétrique), cartes au milieu */
  .rail-left { left: 29px; }
  .rail-right { left: auto; right: 29px; }
  .entry, .entry.edu, .entry.exp, .entry.both { width: 100%; margin-left: 0; margin-top: 26px !important; }
  .entry { align-items: flex-start; gap: 12px; }
  .entry.edu { flex-direction: row; }
  .entry.exp { flex-direction: row-reverse; }
  .entry.both { flex-direction: column; align-items: center; }
  .entry.both::before { left: 29px; right: 29px; }
  .entry.both .qnode.l { left: 29px; }
  .entry.both .qnode.r { left: auto; right: 29px; transform: translate(50%, -50%); }
  .gate { flex: none; margin-top: 4px; }
  .card { margin-top: 0; flex: 1; min-width: 0; width: auto; }
  .entry.both .card { margin-top: 14px; flex: none; width: min(304px, calc(100% - 90px)); }

  #placeChip { right: 50%; bottom: auto; top: 74px; transform: translate(50%, -6px); }
  #placeChip.show { transform: translate(50%, 0); }

  /* la fenêtre de détail laisse la moitié supérieure de la planète visible */
  #detail {
    top: auto;
    bottom: 0;
    left: 0; right: 0;
    width: auto;
    max-height: 68vh;
    border-radius: 22px 22px 0 0;
    padding: 24px 22px 30px;
    transform: translateY(30px);
  }
  #detail.open { transform: none; }
  #detail .d-title { font-size: 1.3rem; }
  #detail .d-org { font-size: 1rem; }
  #detail .d-more { font-size: 1rem; }
}

@media (max-width: 640px) {
  #topbar { padding: 8px 10px; gap: 8px; }
  .me { gap: 9px; }
  .avatar { width: 40px; height: 40px; }
  .tagline { display: none; }
  .links { display: none; }
  .controls { gap: 5px; }
  .pill { padding: 6px 9px; font-size: 0.72rem; }
  .skywrap { padding: 5px 8px; gap: 5px; }
  #sky { width: 58px; }
  #potatoBtn span { display: none; }
  .idcard h1 { font-size: 0.9rem; }

}
