/* ==========================================================================
   Frédéric Pluquet — feuille de style
   Direction D : sombre, sobre, chaleureux.
   ========================================================================== */

:root {
  --bg: #141210;
  --surface: #1d1a17;
  --surface-2: #2a2521;
  --line: #2e2925;
  --line-strong: #3a332d;
  --text: #ede8e1;
  --text-soft: #d6cfc5;
  --muted: #a69e93;
  --accent: #f2a65a;
  --accent-ink: #141210;

  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --container: 1080px;
  --gutter: 24px;
  --radius: 14px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  /* Hauteur de l'en-tête sticky, pour que les ancres ne passent pas dessous */
  scroll-padding-top: 76px;
}
@media (max-width: 720px) {
  html { scroll-padding-top: 88px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--text); }
a:hover { color: var(--accent); }
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: var(--gutter);
  top: 12px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  border-radius: 8px;
}

/* ---------- En-tête ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  padding-bottom: 18px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 28px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 16px;
}
.nav a {
  display: inline-block;
  padding: 6px 0;
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover,
.nav a[aria-current="page"] { color: var(--text); }
.nav .nav-cta { color: var(--accent); }

/* Mobile : en-tête compact, menu sur une ligne qui défile au doigt,
   et qui se cache au défilement vers le bas (voir main.js). */
@media (max-width: 720px) {
  .site-header {
    transition: transform .25s ease;
  }
  .site-header.is-hidden { transform: translateY(-100%); }
  .site-header .container {
    flex-wrap: nowrap;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding-top: 10px;
    padding-bottom: 4px;
  }
  .brand { font-size: 18px; }
  .site-header nav {
    margin: 0 calc(-1 * var(--gutter));
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--gutter), #000 calc(100% - 40px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 var(--gutter), #000 calc(100% - 40px), transparent);
  }
  .site-header nav::-webkit-scrollbar { display: none; }
  .nav {
    flex-wrap: nowrap;
    gap: 22px;
    padding: 0 var(--gutter);
    font-size: 15px;
    white-space: nowrap;
  }
  .nav li:last-child { padding-right: var(--gutter); }
  .nav a { padding: 8px 0; }
}
@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .site-header { transition: none; }
}

/* ---------- Accueil : introduction ---------- */

.hero {
  display: flex;
  flex-wrap: wrap-reverse;
  gap: 56px;
  align-items: center;
  padding-top: 72px;
  padding-bottom: 96px;
}
.hero-text { flex: 999 1 480px; min-width: 0; }
.hero-photo { flex: 1 1 260px; max-width: 340px; }

.eyebrow {
  margin: 0 0 20px;
  color: var(--accent);
  font-weight: 600;
  font-size: 17px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(44px, 6.4vw, 80px);
  line-height: 1;
  letter-spacing: -0.035em;
}

.lead {
  margin: 28px 0 0;
  max-width: 560px;
  font-size: clamp(19px, 2vw, 22px);
  color: var(--text-soft);
}

.hero-text .aside {
  margin: 16px 0 0;
  max-width: 560px;
  color: var(--muted);
}

.photo {
  margin: 0;
  border-radius: 24px;
  overflow: hidden;
  background: var(--surface-2);
  transform: rotate(2deg);
  transition: transform 0.4s ease;
}
.photo:hover { transform: rotate(0deg); }
.photo img {
  width: 100%;
  aspect-ratio: 318 / 421;
  object-fit: cover;
}
@media (prefers-reduced-motion: reduce) {
  .photo, .photo:hover { transform: none; transition: none; }
}

/* Portrait vivant (main.js) : canvas photo → pixel art → ASCII,
   inclinaison 3D pilotée par la souris via des variables CSS. */
.photo { position: relative; }
.photo.is-live,
.photo.is-live:hover {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) rotate(var(--rz, 2deg));
  transition: none;
  box-shadow: var(--sx, 0px) var(--sy, 28px) 56px -16px rgba(0, 0, 0, 0.65);
  will-change: transform;
}
.photo-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.photo-glare {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, 0.22), transparent 55%);
  mix-blend-mode: overlay;
}
.photo-mode {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(20, 18, 16, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--text);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* ---------- La scène : la devise dans un terminal ---------- */

.motto { padding-bottom: 120px; }
.motto-label { margin: 0 0 18px; color: var(--muted); }

.terminal {
  border-radius: 16px;
  background: #0c0b0a;
  border: 1px solid var(--line);
  overflow: hidden;
}
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--line);
}
.terminal-bar .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line-strong);
}
.terminal-bar .spacer { flex-grow: 1; }

.replay {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
}
.replay:hover { color: var(--text); border-color: var(--muted); }

.terminal-body {
  margin: 0;
  padding: clamp(24px, 4vw, 48px);
  min-height: 7.5em;
  font-family: var(--font-mono);
  font-size: clamp(17px, 2.4vw, 30px);
  line-height: 1.5;
  white-space: pre-wrap;
}
.prompt { color: var(--accent); }
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  vertical-align: -0.2em;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}

/* ---------- Chapitres ---------- */

.chapter {
  display: flex;
  flex-wrap: wrap;
  gap: 32px 64px;
  padding-bottom: 120px;
  scroll-margin-top: 24px;
}
.chapter h2 {
  flex: 1 1 260px;
  margin: 0;
  font-size: 44px;
  line-height: 1;
}
.chapter h2 .dot { color: var(--accent); }
.chapter-body { flex: 2 1 480px; min-width: 0; }
.chapter-body > p { margin: 0 0 16px; color: var(--text-soft); line-height: 1.7; }
.chapter-body > p:last-child { margin-bottom: 0; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}
.tags li {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px;
  color: var(--text-soft);
}

.timeline {
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.timeline li {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.timeline .when {
  flex: 0 0 140px;
  color: var(--muted);
  font-size: 16px;
}
.timeline .what { flex: 1 1 260px; min-width: 0; }

.cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}
.card {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  align-items: baseline;
  padding: 20px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: background 0.2s ease;
}
.card:hover { background: var(--surface-2); color: var(--text); }
.card-name {
  flex: 0 0 150px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
}
.card-desc {
  flex: 1 1 260px;
  min-width: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 16px;
}
.card-arrow { color: var(--accent); }

.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 12px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.text-link:hover { text-decoration: underline; }

.bands {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 560px) {
  .bands { grid-template-columns: 1fr; }
}
.bands a {
  display: block;
  height: 100%;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease;
}
.bands a:hover,
.bands a:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--line);
}
.bands a:hover strong::after,
.bands a:focus-visible strong::after { content: " ↗"; }
.bands strong {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
}
.bands span { color: var(--muted); font-size: 15px; }

/* ---------- Pied de page / contact ---------- */

.site-footer { border-top: 1px solid var(--line); }
.site-footer .container { padding-top: 96px; padding-bottom: 48px; }
.site-footer h2 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 26px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  text-decoration: none;
  font-weight: 500;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover { color: var(--accent-ink); filter: brightness(1.08); }
.btn svg { width: 20px; height: 20px; }

.copyright {
  margin: 80px 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* ---------- Page Publications ---------- */

.page-intro { padding-top: 72px; padding-bottom: 64px; }
.page-intro h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
}
.page-intro p { margin: 24px 0 0; max-width: 640px; color: var(--text-soft); }

.pub-group {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 64px;
  padding-bottom: 72px;
}
.pub-group h2 {
  flex: 1 1 200px;
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  color: var(--muted);
}
.pub-list {
  flex: 3 1 560px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.pub {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.pub-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.3;
  letter-spacing: -0.015em;
}
.pub-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}
.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.pub-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}
.pub-links a:hover { background: var(--surface-2); }

/* ---------- Petits écrans ---------- */

/* Dès que la photo passe au-dessus du texte (texte 480px + photo 260px
   + espace 56px + marges 48px = 844px), on la centre. */
@media (max-width: 843px) {
  .hero-photo { margin-inline: auto; }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  .hero { padding-top: 32px; padding-bottom: 72px; gap: 40px; }
  .hero-photo { max-width: 240px; }
  .motto, .chapter { padding-bottom: 80px; }
  .chapter h2 { font-size: 36px; }
  .site-footer .container { padding-top: 72px; }
}

/* ==========================================================================
   Easter eggs (eggs.js)
   ========================================================================== */

/* Terminal interactif */
.terminal { cursor: text; }
.terminal:focus-within { border-color: var(--accent); }
.terminal.is-interactive .terminal-body .cursor { display: none; }
.term-shell {
  max-height: 340px;
  overflow-y: auto;
  padding: 0 clamp(24px, 4vw, 48px) clamp(20px, 3vw, 32px);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-soft);
}
.term-shell[hidden] { display: none; }
.term-line { white-space: pre-wrap; overflow-wrap: anywhere; }
.term-line.is-echo { margin-top: 8px; color: var(--text); }
.term-line.is-error { color: #e98b7a; }
.term-line.is-muted { color: var(--muted); }
.term-line a { color: var(--accent); }
.term-form { display: flex; align-items: baseline; margin-top: 8px; }
.term-form .prompt { white-space: pre; }
.term-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  caret-color: var(--accent);
  outline: none;
}
@media (max-width: 600px) {
  .term-shell { font-size: 16px; } /* évite le zoom automatique d'iOS */
}

/* Konami code : mini-jeu fred.run */
html.is-game-open { overflow: hidden; }
.game {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 11, 10, 0.88);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.game[hidden] { display: none; }
.game-panel {
  width: min(820px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  overflow: hidden;
  background: var(--bg);
}
.game-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 8px 8px 18px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 13px;
}
.game-title { color: var(--accent); }
.game-help { flex: 1; color: var(--muted); }
.game-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.game-close:hover { color: var(--text); border-color: var(--muted); }
.game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 400 / 150;
  image-rendering: pixelated;
  touch-action: manipulation;
  cursor: pointer;
}
@media (max-width: 600px) {
  .game-help { display: none; }
}

/* Portrait cliqué 5 fois */
.hero-photo { position: relative; }
.hero-photo { -webkit-user-select: none; user-select: none; }
.photo-bubble { -webkit-user-select: none; user-select: none; }
.hero-photo.is-spinning { animation: egg-spin 1.1s cubic-bezier(0.5, 0, 0.2, 1); }
@keyframes egg-spin {
  from { transform: perspective(900px) rotateY(0deg); }
  to { transform: perspective(900px) rotateY(360deg); }
}
.photo-bubble {
  position: absolute;
  top: -14px;
  left: -10px;
  z-index: 2;
  padding: 8px 14px;
  border-radius: 14px 14px 14px 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.6) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.2s ease;
}
.photo-bubble.is-in { opacity: 1; transform: none; }

/* 10 clics : la photo tremble */
.hero-photo.is-shaking { animation: egg-shake 0.65s linear; }
@keyframes egg-shake {
  0%, 100% { transform: none; }
  10%, 50%, 90% { transform: translate(-5px, 1px) rotate(-1.5deg); }
  30%, 70% { transform: translate(5px, -1px) rotate(1.5deg); }
}

/* 15 clics : le portrait explose en pixels (canvas plein écran) */
.hero-photo.is-exploded .photo { visibility: hidden; }
.pixel-burst {
  position: fixed;
  inset: 0;
  z-index: 45;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* 20 clics : mini-terminal « café » sur la photo */
.photo-term {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 18px;
  background: rgba(12, 11, 10, 0.86);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}
.photo-term-out {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
}
.photo-term-form { display: flex; margin-top: 4px; color: var(--accent); }
.photo-term-form[hidden] { display: none; }
.photo-term-form input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  caret-color: var(--accent);
  outline: none;
}
@media (max-width: 600px) {
  .photo-term { font-size: 16px; } /* évite le zoom automatique d'iOS */
}

/* Batucada et points des titres */
.chapter h2 { position: relative; }
.page-intro h1 .dot { color: var(--accent); }
.chapter h2 .dot,
.page-intro h1 .dot {
  display: inline-block;
  cursor: pointer;
  transform-origin: 50% 80%;
  transition: opacity 0.4s ease;
}
.chapter h2 .dot.is-gone,
.page-intro h1 .dot.is-gone { opacity: 0; transition: none; }
.chapter h2 .dot.is-beat { animation: dot-beat 0.25s ease-out; }
@keyframes dot-beat { 40% { transform: scale(1.8); } }
.beat-word {
  position: absolute;
  bottom: 100%;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  animation: beat-word 0.9s ease-out forwards;
}
@keyframes beat-word {
  from { opacity: 1; transform: translateY(10px) scale(0.8); }
  to { opacity: 0; transform: translateY(-40px) scale(1.2); }
}
/* Couche plein écran, au-dessus de l'en-tête : la pile peut se former en haut. */
.dot-pile {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
}
/* Chaque point est une bille positionnée par transform (voir eggs.js). */
.falling-dot {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: auto;
  cursor: pointer;
  will-change: transform;
}

/* Petit message en bas de l'écran */
.egg-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.egg-toast.is-in { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .hero-photo.is-spinning,
  .hero-photo.is-shaking,
  .chapter h2 .dot.is-beat,
  .beat-word { animation: none; }
  .photo-bubble,
  .egg-toast,
  .falling-dot { transition: none !important; }
}
