/* ==========================================================
   Tokens : sombre par défaut, clair en option.
   Les sketches p5 lisent aussi ces variables.
   ========================================================== */
:root {
  --bg: #0b0b0c;
  --surface: #131315;
  --border: #2c2c30;
  --text: #f4f4f5;
  --text-dim: #b8b8be; /* contraste ~9:1 sur le fond */
  --text-faint: #83838b; /* contraste ~5:1 (lisible, conforme WCAG AA) */
  --accent: #ffffff; /* blanc pur : met en valeur sans couleur */
  --dot: rgba(255, 255, 255, 0.075); /* points de la trame de fond */

  /* police "informatique" (monospace) pour tout le site */
  --sans: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #fbfbfa;
  --surface: #f2f2f0;
  --border: #dcdcd7;
  --text: #0f0f11;
  --text-dim: #4a4a50; /* contraste ~8.5:1 */
  --text-faint: #6f6f76; /* contraste ~5:1 */
  --accent: #000000; /* noir pur en thème clair */
  --dot: rgba(0, 0, 0, 0.1);
  color-scheme: light;
}

/* ==========================================================
   Base
   ========================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  /* trame de points fixe et discrète : donne de la texture sans gêner la lecture */
  background-color: var(--bg);
  background-image: radial-gradient(circle at center, var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  transition:
    background 0.3s,
    color 0.3s;
}

a {
  color: inherit;
  text-decoration: none;
}
::selection {
  background: var(--accent);
  color: var(--bg);
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

/* Paysage animé (p5) : fixe, derrière tout le site, ne capte pas la souris.
   Un peu atténué pour accompagner le texte sans le concurrencer. */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
}
#bg canvas {
  display: block;
}
.page {
  position: relative;
  z-index: 1;
  /* halo léger couleur du fond : efface les points juste sous les lettres,
     sans flouter le texte */
  text-shadow: 0 0 2px var(--bg), 0 0 6px var(--bg);
}


.mono {
  font-family: var(--mono);
}
.dim {
  color: var(--text-dim);
}
.faint {
  color: var(--text-faint);
}

/* Lien : un trait qui se dessine de gauche à droite au survol */
.link {
  color: var(--text);
  background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0% 1px;
  border-bottom: 1px solid var(--border);
  transition: background-size 0.35s var(--ease);
}
.link:hover {
  background-size: 100% 1px;
}

/* ==========================================================
   Apparition en cascade au chargement
   (chaque élément .reveal reçoit --i depuis main.js)
   ========================================================== */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  filter: blur(4px);
  animation: arrive 0.7s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes arrive {
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

/* ==========================================================
   En-tête
   ========================================================== */
.head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.head h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.theme-btn {
  padding: 2px 0;
  border: none;
  background: none;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.2s;
}
.theme-btn:hover {
  color: var(--text);
}

.role {
  margin: 0;
  color: var(--text-dim);
}

/* Ligne de statut façon monitoring */
.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}
.status__dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.status__dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: ping 2s var(--ease) infinite;
}
@keyframes ping {
  70%,
  100% {
    transform: scale(2.6);
    opacity: 0;
  }
}
#pulse {
  width: 96px;
  height: 18px;
}
#pulse canvas {
  display: block;
}
#latency {
  color: var(--text-dim);
  min-width: 7ch;
}

.intro {
  margin: 28px 0 0;
  color: var(--text-dim);
}

/* ==========================================================
   Blocs : label à gauche, contenu à droite
   ========================================================== */
.block {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 16px;
  margin-top: 44px;
}
.label {
  margin: 0;
  padding-top: 2px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-faint);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li + li {
  margin-top: 6px;
}
.list--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.list--inline li + li {
  margin-top: 0;
}

.logo {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 6px;
}
:root:not([data-theme='light']) .logo--invert {
  filter: invert(1);
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.row .faint {
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  padding-top: 2px;
}

/* ==========================================================
   Projets : lignes qui se déplient
   ========================================================== */
.proj {
  margin: 0 -10px;
}
.proj + .proj {
  margin-top: 2px;
}

.proj__row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 5px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s;
}
.proj__row:hover,
.proj.open .proj__row {
  background: var(--surface);
}
.proj__name {
  font-weight: 600; /* comme les titres des articles */
  white-space: nowrap;
}
.proj__sum {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proj__year {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}
.proj__icon {
  font-family: var(--mono);
  color: var(--text-faint);
  transition:
    transform 0.4s var(--ease),
    color 0.2s;
}
.proj.open .proj__icon {
  transform: rotate(45deg);
  color: var(--accent);
}

/* Dépliage fluide : grid 0fr -> 1fr */
.proj__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.5s var(--ease);
}
.proj.open .proj__panel {
  grid-template-rows: 1fr;
}
.proj__inner {
  overflow: hidden;
  min-height: 0;
}
.proj__content {
  padding: 8px 10px 14px;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 0.4s var(--ease),
    transform 0.4s var(--ease);
}
.proj.open .proj__content {
  opacity: 1;
  transform: none;
  transition-delay: 0.1s;
}
.proj__content p {
  margin: 0 0 14px;
  color: var(--text-dim);
  line-height: 1.85; /* même confort de lecture que le contenu des articles */
}

.proj__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.proj__meta .links {
  margin-left: auto;
  display: flex;
  gap: 12px;
}

.fig {
  aspect-ratio: 16 / 9; /* même format que les vidéos de démo */
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface);
  cursor: crosshair;
}
.fig canvas {
  display: block;
}

/* Vidéo de démo d'un projet (remplace la figure animée quand elle existe) */
.demo {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
}

/* ==========================================================
   Pied de page
   ========================================================== */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 72px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
}
kbd {
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
}

/* ==========================================================
   Responsive + accessibilité
   ========================================================== */
/* Le panneau masque ce qui dépasse (animation d'ouverture) : on élargit sa zone visible
   vers la gauche (et on compense avec le padding) pour que le média puisse déborder. */
.proj__inner {
  margin-left: calc(-84px - 16px);
  padding-left: calc(84px + 16px);
}

/* Vidéo / figure d'un projet : pleine largeur du contenu.
   Elles débordent sur la colonne des labels (84px + 16px d'espace) pour être plus grandes. */
.proj__content .demo,
.proj__content .fig {
  width: calc(100% + 84px + 16px);
  margin-left: calc(-84px - 16px);
}

@media (max-width: 520px) {
  /* sur mobile, une seule colonne : pas de débordement */
  .proj__content .demo,
  .proj__content .fig {
    width: 100%;
    margin-left: 0;
  }
  .proj__inner {
    margin-left: 0;
    padding-left: 0;
  }
  .page {
    padding: 32px 16px 48px;
  }
  .block {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .proj__sum {
    display: none;
  }
  .foot span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    animation: none;
    opacity: 1;
    transform: none;
    filter: none;
  }
  .status__dot::after {
    animation: none;
  }
  .proj__panel,
  .proj__content,
  .link {
    transition: none;
  }
}

/* ==========================================================
   Barres de défilement (tout le site)
   ========================================================== */
* {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--border) transparent;
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
} /* Chrome, Edge, Safari */
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--bg); /* donne un effet "fin" */
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}
::-webkit-scrollbar-corner {
  background: transparent;
}
