:root {
  --bg: #f3f1f8;
  --ink: #0c0c0c;
  --mute: #8b8794;
  --line: rgba(12, 12, 12, 0.08);
  --swap: #6b6578;
  --accent: #d92a5b;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-slip: cubic-bezier(0.34, 1.15, 0.48, 1);
  --dur-instant: 120ms;
  --dur-fast: 200ms;
  --dur-base: 320ms;
  --dur-slow: 480ms;
  --shift-text: 0.1em;
  --shift-ui: 8px;
  --stagger-line: 50ms;
  --stagger-list: 40ms;
  --sans: "Inter Tight", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.45;
  overflow-x: clip;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.7rem;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  font-size: 0.75rem;
}

.skip:focus {
  top: 1rem;
}

.stage {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  overflow-x: clip;
}

.stage--page {
  min-height: 0;
}

.main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5vh 4vw;
  position: relative;
  overflow-x: clip;
}

/* La bouche en filigrane au centre, sous la phrase : décor et déclencheur. */
.backdrop {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  width: min(82vh, 62vw);
  padding: 0;
  border: 0;
  background: none;
  line-height: 0;
  cursor: pointer;
  user-select: none;
  opacity: 0.13;
  /* --par-x/--par-y sont pilotées par la parallaxe : passer par des variables
     permet de cumuler le suivi du curseur avec les animations ci-dessous. */
  transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px))) rotate(8deg);
  clip-path: circle(44% at 50% 52%);
  animation: backdrop-float 9s ease-in-out infinite;
  transition: opacity var(--dur-slow) var(--ease-out);
}

.backdrop__img {
  display: block;
  width: 100%;
  height: auto;
  transition: opacity var(--dur-base) var(--ease-out);
}

.backdrop__img--fork {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.main:has(.puzzle.is-revealed) .backdrop {
  opacity: 0.22;
}

.main:has(.puzzle.is-revealed) .backdrop__img--whole {
  opacity: 0;
}

.main:has(.puzzle.is-revealed) .backdrop__img--fork {
  opacity: 1;
}

.backdrop.is-react {
  animation: backdrop-react var(--dur-slow) var(--ease-slip);
}

.puzzle {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
  text-align: center;
}

.meta {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1.1rem;
  margin: 0 0 3vh;
}

.meta__all {
  font-size: 0.72rem;
  color: var(--mute);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

.meta__all:hover,
.meta__all:focus-visible {
  color: var(--ink);
}

.meta.is-enter {
  animation: meta-rise var(--dur-base) var(--ease-out) both;
}

.kicker,
.cats {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--mute);
}

.kicker {
  font-variant-numeric: tabular-nums;
}

.cats a {
  text-decoration: none;
}

.cats a:hover,
.cats a:focus-visible {
  color: var(--ink);
}

.phrase {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin: 0;
  font-family: var(--serif);
  /* Un corps unique pour toutes les contrepèteries, calibré sur la plus
     longue : 4 lignes de 17 signes tiennent à l'écran sans déborder. */
  font-size: max(1.9rem, min(10vw, 16.5vh));
  font-weight: 500;
  font-variation-settings: "SOFT" 28, "WONK" 0.4, "opsz" 96;
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.line {
  display: block;
  max-width: 100%;
  overflow: visible;
  /* Marge basse pour que les jambages (g, p) ne soient pas rognés
     malgré l'interlignage serré. */
  padding: 0.02em 0.02em 0.12em;
}

.line__inner {
  display: block;
  animation: line-rise var(--dur-base) var(--ease-out) both;
}

.line:nth-child(2) .line__inner {
  animation-delay: var(--stagger-line);
}

.line:nth-child(3) .line__inner {
  animation-delay: calc(var(--stagger-line) * 2);
}

.line:nth-child(4) .line__inner {
  animation-delay: calc(var(--stagger-line) * 3);
}

@keyframes line-rise {
  from {
    opacity: 0;
    transform: translateY(var(--shift-text));
  }
}

@keyframes meta-rise {
  from {
    opacity: 0;
    transform: translateY(calc(var(--shift-ui) * 0.5));
  }
}

.word {
  display: inline;
}

.swap {
  display: inline-grid;
  vertical-align: baseline;
  overflow: visible;
}

.swap > * {
  grid-area: 1 / 1;
  display: block;
  overflow: visible;
  padding-bottom: 0.12em;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-slip);
}

.swap .from,
.swap.remove .layer {
  opacity: 1;
  transform: translateY(0);
}

.swap .to,
.swap.add .layer {
  opacity: 0;
  transform: translateY(var(--shift-text));
  color: var(--swap);
  pointer-events: none;
}

.puzzle.is-revealed .swap .from,
.puzzle.is-revealed .swap.remove .layer {
  opacity: 0;
  transform: translateY(calc(var(--shift-text) * -1));
  pointer-events: none;
}

.puzzle.is-revealed .swap .to,
.puzzle.is-revealed .swap.add .layer {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* —— Micro-interactions de lecture —— */

@media (hover: hover) and (min-width: 720px) {
  /* Curseur « permuter » : la phrase annonce qu'elle est manipulable. */
  .phrase {
    cursor:
      url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='28'%20height='28'%3E%3Cg%20fill='none'%20stroke='%23f3f1f8'%20stroke-width='4'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M5%2010h16M17%206l4%204-4%204M23%2018H7M11%2014l-4%204%204%204'/%3E%3C/g%3E%3Cg%20fill='none'%20stroke='%230c0c0c'%20stroke-width='1.7'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M5%2010h16M17%206l4%204-4%204M23%2018H7M11%2014l-4%204%204%204'/%3E%3C/g%3E%3C/svg%3E")
        14 14,
      pointer;
  }

  /* Seules les syllabes permutables bougent au survol. */
  .phrase .swap:hover {
    animation: word-chew var(--dur-slow) var(--ease-slip);
  }
}

@keyframes word-chew {
  40% {
    transform: translateY(-0.035em) rotate(-1.4deg);
  }

  70% {
    transform: translateY(0.015em) rotate(0.6deg);
  }

  100% {
    transform: none;
  }
}

/* Avant-goût : au survol prolongé du bouton, les syllabes s'impatientent. */
.puzzle.is-itching:not(.is-revealed) .swap {
  animation: swap-itch 1.15s var(--ease-out) infinite;
}

@keyframes swap-itch {
  0%,
  100% {
    transform: none;
  }

  45% {
    transform: translateY(-0.03em) rotate(-1deg);
  }

  72% {
    transform: translateY(0.018em) rotate(0.5deg);
  }
}

/* Bloc de commandes, en haut à droite : révéler, navigation, indice clavier. */
.controls {
  position: absolute;
  z-index: 3;
  top: 4vh;
  right: 4vw;
  display: flex;
  flex-direction: column;
  /* Largeur fixe : bouton, flèches et légende partagent les mêmes bords. */
  align-items: stretch;
  width: 10rem;
  gap: 0.85rem;
}

.reveal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.6rem;
  padding: 0 1rem;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 0.98rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 0 rgba(217, 42, 91, 0.35);
  transition:
    background-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-slip);
}

.reveal:hover,
.reveal:focus-visible {
  background: var(--ink);
  box-shadow: 0 0 0 6px rgba(217, 42, 91, 0.16);
}

.reveal:active {
  transform: scale(0.97);
}

a.reveal {
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 0;
}

.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.4rem;
  min-width: 2.4rem;
  font-size: 1rem;
  text-decoration: none;
  color: var(--mute);
  transition:
    color var(--dur-instant) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--ink);
}

.nav [data-prev]:hover,
.nav [data-prev]:focus-visible {
  transform: translateX(-3px);
}

.nav [data-next]:hover,
.nav [data-next]:focus-visible {
  transform: translateX(3px);
}

.counter {
  margin: 0;
  padding: 0 0.2rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  color: var(--mute);
}

.counter.is-tick {
  animation: counter-tick var(--dur-base) var(--ease-out) both;
}

/* Légende des raccourcis : une touche, l'action qu'elle déclenche. */
.hint {
  display: none;
  grid-template-columns: auto auto;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin: 0;
  font-size: 0.68rem;
  color: var(--mute);
}

.hint span {
  justify-self: end;
}

.hint kbd {
  min-width: 3.2rem;
  padding: 0.18rem 0.4rem;
  border: 1px solid var(--line);
  font: inherit;
  color: var(--ink);
  text-align: center;
  transition:
    background-color var(--dur-instant) var(--ease),
    color var(--dur-instant) var(--ease),
    transform var(--dur-instant) var(--ease);
}

/* La touche physique enfonce la touche à l'écran. */
.hint kbd.is-down {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  transform: translateY(1px);
}

.footer {
  padding: 3rem 4.5vw 1.75rem;
  border-top: 1px solid var(--line);
}

.footer-inner {
  width: min(72rem, 100%);
  margin: 0;
}

.footer p {
  margin: 0 0 0.9rem;
  font-size: 0.68rem;
  color: var(--mute);
}

.footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.15rem;
  margin: 0 0 0.85rem;
  padding: 0;
  list-style: none;
}

.footer a {
  display: inline-flex;
  align-items: center;
  min-height: 2.4rem;
  font-size: 0.8rem;
  text-decoration: none;
}

.footer a:hover,
.footer a:focus-visible {
  color: var(--mute);
}

/* —— Accueil : affiche, pas une fiche puzzle —— */

.home {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 100svh;
  padding: 0 5vw 5vh;
  overflow-x: clip;
}

.home .backdrop {
  width: min(58vh, 48vw);
  opacity: 0.1;
  pointer-events: none;
}

.home__bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 3.5vh 0 0;
}

.home__brand,
.home__count {
  margin: 0;
  font-size: 0.72rem;
}

.home__brand span {
  display: block;
  margin-top: 0.15rem;
  color: var(--mute);
}

.home__count a,
.home__all {
  color: var(--mute);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}

.home__count a:hover,
.home__count a:focus-visible,
.home__all:hover,
.home__all:focus-visible {
  color: var(--ink);
}

.home__hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 7vh 0 4vh;
  text-align: center;
}

.home__hero h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.35rem, 6.8vw, 5.2rem);
  font-weight: 500;
  font-variation-settings: "SOFT" 36, "WONK" 0.4, "opsz" 96;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.home__lead {
  max-width: 28rem;
  margin: 1.15rem 0 0;
  font-size: 0.95rem;
  color: var(--mute);
}

.home__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.85rem 1.6rem;
  margin: 1.8rem 0 0;
}

.home__cta .reveal {
  min-width: 10rem;
  padding: 0 1.6rem;
}

.home__all {
  font-size: 0.8rem;
}

.page {
  width: min(48rem, calc(100% - 9vw));
  margin: 0 4.5vw;
  padding: 8vh 0 4.5rem;
}

.page h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 8vw, 6.5rem);
  font-weight: 500;
  font-variation-settings: "SOFT" 40, "opsz" 96;
  letter-spacing: -0.04em;
  line-height: 0.92;
}

.page .lead {
  max-width: 26rem;
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: var(--mute);
}

.list {
  margin: 3rem 0 0;
  padding: 0;
  list-style: none;
}

.list a {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.85rem;
  padding: 1.05rem 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
}

.list[data-stagger] li {
  opacity: 1;
  transform: none;
}

html.is-motion .list[data-stagger]:not(.is-visible) li {
  opacity: 0;
  transform: translateY(var(--shift-ui));
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
  transition-delay: calc(var(--i, 0) * var(--stagger-list));
}

html.is-motion .list[data-stagger].is-visible li {
  opacity: 1;
  transform: translateY(0);
}

.list .num,
.list .txt {
  transition: transform var(--dur-fast) var(--ease);
}

.list a:hover .txt,
.list a:focus-visible .txt {
  color: var(--mute);
  transform: translateX(4px);
}

.list a:hover .num,
.list a:focus-visible .num {
  transform: translateX(-2px);
}

.list li:last-child a {
  border-bottom: 1px solid var(--line);
}

.list .num {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--mute);
}

.list .txt {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.missing {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 70svh;
  padding: 8vh 5vw 12vh;
}

.missing h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3rem, 9vw, 7rem);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.04em;
}

.missing p {
  margin: 1rem 0 0;
  color: var(--mute);
}

.missing__kicker {
  margin: 0 0 1.2rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.14em;
}

.missing__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  margin-top: 1.6rem;
}

.missing a {
  font-size: 0.8rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.missing a:hover,
.missing a:focus-visible {
  border-bottom-color: currentcolor;
}

@media (max-width: 719px) {
  /* Symétrique haut/bas pour garder le centrage, tout en dégageant
     la place du bloc de commandes. */
  .main {
    padding: 13vh 6vw;
  }

  .main .backdrop {
    width: 128vw;
    opacity: 0.1;
  }

  .home {
    padding: 0 6vw 4vh;
  }

  .home .backdrop {
    width: 90vw;
  }

  .home__hero {
    padding: 5vh 0 3vh;
  }

  .controls {
    top: 2.5vh;
    right: 5vw;
    width: 8.5rem;
    gap: 0.7rem;
  }

  .reveal {
    min-height: 3rem;
    font-size: 0.88rem;
  }
}

@media (min-width: 720px) {
  .hint {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .list[data-stagger] li,
  html.is-motion .list[data-stagger]:not(.is-visible) li {
    opacity: 1;
    transform: none;
  }

  .swap .to,
  .swap.add .layer {
    opacity: 0;
    transform: none;
  }

  .puzzle.is-revealed .swap .from,
  .puzzle.is-revealed .swap.remove .layer {
    display: none;
  }

  .puzzle.is-revealed .swap .to,
  .puzzle.is-revealed .swap.add .layer {
    opacity: 1;
    transform: none;
  }

  .puzzle:not(.is-revealed) .swap .to,
  .puzzle:not(.is-revealed) .swap.add .layer {
    display: none;
  }
}

@keyframes backdrop-float {
  0%,
  100% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px))) rotate(8deg);
  }

  50% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px) - 10px))
      rotate(7deg);
  }
}

@keyframes backdrop-react {
  0% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px))) rotate(8deg)
      scale(1);
  }

  35% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px))) rotate(3deg)
      scale(1.04);
  }

  100% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px))) rotate(8deg)
      scale(1);
  }
}

@keyframes counter-tick {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--dur-base);
  animation-timing-function: var(--ease-out);
}

html[data-nav="next"] ::view-transition-old(root) {
  animation-name: vt-out-left;
}

html[data-nav="next"] ::view-transition-new(root) {
  animation-name: vt-in-right;
  animation-timing-function: var(--ease);
}

html[data-nav="prev"] ::view-transition-old(root) {
  animation-name: vt-out-right;
}

html[data-nav="prev"] ::view-transition-new(root) {
  animation-name: vt-in-left;
  animation-timing-function: var(--ease);
}

html:not([data-nav]) ::view-transition-old(root) {
  animation-name: slide-out;
}

html:not([data-nav]) ::view-transition-new(root) {
  animation-name: slide-in;
  animation-timing-function: var(--ease);
}

/* La page sortante est aspirée vers la bouche, la suivante en ressort. */
@keyframes vt-out-left {
  from {
    clip-path: circle(130% at 50% 52%);
  }

  to {
    opacity: 0;
    transform: translateX(calc(var(--shift-ui) * -1.5)) scale(0.94);
    clip-path: circle(0% at 50% 52%);
  }
}

@keyframes vt-in-right {
  from {
    opacity: 0;
    transform: translateX(var(--shift-ui)) scale(1.03);
    clip-path: circle(0% at 50% 52%);
  }

  to {
    opacity: 1;
    transform: none;
    clip-path: circle(140% at 50% 52%);
  }
}

@keyframes vt-out-right {
  from {
    clip-path: circle(130% at 50% 52%);
  }

  to {
    opacity: 0;
    transform: translateX(calc(var(--shift-ui) * 1.5)) scale(0.94);
    clip-path: circle(0% at 50% 52%);
  }
}

@keyframes vt-in-left {
  from {
    opacity: 0;
    transform: translateX(calc(var(--shift-ui) * -1)) scale(1.03);
    clip-path: circle(0% at 50% 52%);
  }

  to {
    opacity: 1;
    transform: none;
    clip-path: circle(140% at 50% 52%);
  }
}

@keyframes slide-out {
  to {
    opacity: 0;
    transform: translateY(calc(var(--shift-ui) * -1));
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(var(--shift-ui));
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  html.is-fourchu .phrase,
  html.is-fourchu .page h1,
  html.is-fourchu .home__hero h1,
  html.is-fourchu .list .txt {
    animation: none;
    text-shadow: none;
  }
}

/* —— Mode fourchu (site entier en dérapage) —— */

html.is-fourchu {
  --bg: #f8e6ef;
  --ink: #140810;
  --mute: #7a5c72;
  --swap: #8b3d68;
}

html.is-fourchu body {
  background: var(--bg);
}

html.is-fourchu body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: none;
  opacity: 0.35;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(20, 8, 16, 0.04) 3px,
    rgba(20, 8, 16, 0.04) 4px
  );
}

html.is-fourchu body::after {
  content: "";
  position: fixed;
  inset: -20vmax;
  z-index: 9989;
  pointer-events: none;
  opacity: 0.18;
  background: radial-gradient(circle at 78% 12%, rgba(224, 80, 120, 0.55), transparent 42%);
  animation: wtf-pulse 1.4s ease-in-out infinite alternate;
}

html.is-fourchu .phrase,
html.is-fourchu .page h1,
html.is-fourchu .home__hero h1,
html.is-fourchu .list .txt {
  text-shadow:
    0.06em 0 0 rgba(255, 40, 110, 0.42),
    -0.06em 0 0 rgba(50, 90, 255, 0.38);
  animation: wtf-text-shake 0.55s steps(3, end) both;
}

html.is-fourchu .stage {
  animation: wtf-stage-tilt 0.7s var(--ease-slip) both;
}

html.is-fourchu .backdrop {
  opacity: 0.3;
  animation:
    wtf-backdrop-spin 0.9s var(--ease-slip) both,
    backdrop-float 9s ease-in-out 1s infinite;
}

html.is-fourchu .hint {
  letter-spacing: 0.12em;
  text-transform: lowercase;
}

html.is-fourchu .footer {
  border-top-color: rgba(139, 61, 104, 0.22);
}

html.is-fourchu .footer a {
  text-shadow: 0.04em 0 0 rgba(255, 40, 110, 0.25);
}

html.has-tasted:not(.is-fourchu) body {
  background: linear-gradient(180deg, #f3f1f8 0%, #f7eef4 100%);
}

html.has-tasted:not(.is-fourchu) .list a:hover .txt,
html.has-tasted:not(.is-fourchu) .list a:focus-visible .txt {
  text-shadow:
    0.04em 0 0 rgba(255, 40, 110, 0.28),
    -0.04em 0 0 rgba(50, 90, 255, 0.22);
}

@keyframes wtf-pulse {
  from {
    transform: scale(1);
    opacity: 0.14;
  }

  to {
    transform: scale(1.08);
    opacity: 0.24;
  }
}

@keyframes wtf-text-shake {
  0% {
    transform: translate(-6px, 2px) skewX(-2deg);
  }

  33% {
    transform: translate(5px, -2px) skewX(2deg);
  }

  66% {
    transform: translate(-3px, 1px);
  }

  100% {
    transform: none;
  }
}

@keyframes wtf-stage-tilt {
  0% {
    transform: rotate(-0.6deg) scale(0.995);
  }

  50% {
    transform: rotate(0.5deg) scale(1.008);
  }

  100% {
    transform: none;
  }
}

@keyframes wtf-backdrop-spin {
  0% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px))) rotate(8deg)
      scale(1);
  }

  40% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px)))
      rotate(-18deg) scale(1.18);
  }

  100% {
    transform: translate(calc(-50% + var(--par-x, 0px)), calc(-50% + var(--par-y, 0px))) rotate(8deg)
      scale(1.05);
  }
}

@keyframes wtf-rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
}

/* —— Couche expérimentale : découvertes —— */

.wtf-toast {
  position: fixed;
  left: 4.5vw;
  bottom: calc(4.5rem + env(safe-area-inset-bottom));
  z-index: 9995;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  max-width: min(22rem, 82vw);
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.wtf-toast.is-on {
  opacity: 1;
  transform: translateY(0);
}

.wtf-toast__dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--swap);
}

.wtf-toast__sub {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--mute);
}

.counter.is-clickable {
  cursor: pointer;
}

.kicker.is-cross {
  color: var(--swap);
  transform: scale(1.35);
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease-slip);
}

.reveal.is-fleeing {
  transform: translateX(-6.5rem) rotate(-4deg);
  transition: transform 0.32s var(--ease-slip);
}

.phrase.is-idle .line__inner {
  animation: wtf-idle-sway 2.6s var(--ease-out) both;
}

@keyframes wtf-idle-sway {
  0%,
  100% {
    transform: none;
  }

  25% {
    transform: translateX(-4px) rotate(-0.4deg);
  }

  60% {
    transform: translateX(3px) rotate(0.3deg);
  }
}

html.is-inverted body {
  transform: scaleX(-1);
  transition: transform 0.5s var(--ease-slip);
}

/* Traces laissées par les découvertes */

html[data-wtf-tier="1"] .list a:hover .txt,
html[data-wtf-tier="1"] .list a:focus-visible .txt {
  text-shadow: 0.03em 0 0 rgba(255, 40, 110, 0.25);
}

html[data-wtf-tier="2"] .kicker::after,
html[data-wtf-tier="3"] .kicker::after {
  content: " ◆";
  color: var(--swap);
  font-size: 0.7em;
}

html[data-wtf-tier="2"] .counter,
html[data-wtf-tier="3"] .counter {
  color: var(--swap);
}

html[data-wtf-tier="3"] .backdrop {
  filter: saturate(1.15);
  opacity: 0.18;
}

/* Fausse erreur système */

.wtf-error {
  position: fixed;
  right: 2.5vw;
  bottom: 2.5vh;
  z-index: 9996;
  width: min(21rem, 86vw);
  border: 1px solid #140810;
  background: #f3f1f8;
  box-shadow: 4px 4px 0 rgba(20, 8, 16, 0.85);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-slip);
}

.wtf-error.is-on {
  opacity: 1;
  transform: translateY(0);
}

.wtf-error__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.4rem 0.35rem 0.6rem;
  background: #140810;
  color: #f8e6ef;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.wtf-error__x {
  color: inherit;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0 0.25rem;
}

.wtf-error__body {
  padding: 0.9rem;
  font-size: 0.78rem;
}

.wtf-error__body p {
  margin: 0 0 0.5rem;
}

.wtf-error__ok {
  margin-top: 0.4rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid #140810;
  font-size: 0.72rem;
}

.wtf-error__ok:hover {
  background: #140810;
  color: #f8e6ef;
}

/* Chambre des découvertes */

.wtf-room {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
  background: rgba(20, 8, 16, 0.92);
  color: #f8e6ef;
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.wtf-room.is-on {
  opacity: 1;
}

.wtf-room__inner {
  width: min(30rem, 100%);
  animation: wtf-rise var(--dur-slow) var(--ease-slip) both;
}

.wtf-room__kicker {
  margin: 0 0 0.6rem;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  color: rgba(248, 230, 239, 0.6);
}

.wtf-room__title {
  margin: 0 0 1.6rem;
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
}

.wtf-room__list {
  margin: 0 0 1.4rem;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
}

.wtf-room__list li {
  display: flex;
  gap: 0.7rem;
  padding: 0.42rem 0;
  border-bottom: 1px solid rgba(248, 230, 239, 0.12);
  color: rgba(248, 230, 239, 0.42);
}

.wtf-room__list li.is-found {
  color: #f8e6ef;
}

.wtf-room__hint {
  margin: 0 0 1.4rem;
  font-size: 0.72rem;
  color: rgba(248, 230, 239, 0.55);
}

.wtf-room__close {
  padding: 0.5rem 1.1rem;
  border: 1px solid rgba(248, 230, 239, 0.4);
  color: inherit;
  font-size: 0.75rem;
}

.wtf-room__close:hover {
  background: #f8e6ef;
  color: #140810;
}

.wtf-room__row {
  display: flex;
  gap: 0.5rem;
}

.wtf-room__day {
  padding: 0.5rem 1.1rem;
  border: 1px solid rgba(248, 230, 239, 0.4);
  color: inherit;
  font-size: 0.75rem;
}

.wtf-room__day:hover {
  background: #f8e6ef;
  color: #140810;
}

/* —— Sélectionner la phrase laisse voir la couche du dessous —— */

.puzzle.is-peeking:not(.is-revealed) .swap .from,
.puzzle.is-peeking:not(.is-revealed) .swap.remove .layer {
  opacity: 0.16;
}

.puzzle.is-peeking:not(.is-revealed) .swap .to,
.puzzle.is-peeking:not(.is-revealed) .swap.add .layer {
  opacity: 0.85;
  transform: none;
  color: var(--accent);
}

/* —— Menu contextuel de la bouche —— */

.wtf-menu {
  position: fixed;
  z-index: 9997;
  display: flex;
  flex-direction: column;
  width: 11.5rem;
  padding: 0.3rem;
  border: 1px solid var(--ink);
  background: var(--bg);
  box-shadow: 3px 3px 0 rgba(12, 12, 12, 0.8);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-slip);
}

.wtf-menu.is-on {
  opacity: 1;
  transform: none;
}

.wtf-menu button {
  padding: 0.45rem 0.55rem;
  font-size: 0.75rem;
  text-align: left;
}

.wtf-menu button:hover,
.wtf-menu button:focus-visible {
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

/* —— Le bas de page qui n'existe pas —— */

.main .puzzle {
  transition: transform var(--dur-slow) var(--ease-slip);
}

.main.is-nudged .puzzle {
  transform: translateY(-1.8rem);
}

.wtf-floor {
  position: absolute;
  left: 50%;
  bottom: 2.5vh;
  z-index: 2;
  margin: 0;
  padding: 0 6vw;
  font-size: 0.72rem;
  color: var(--mute);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 6px);
  pointer-events: none;
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.main.is-nudged .wtf-floor {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* —— Écran de veille —— */

.wtf-saver {
  position: fixed;
  inset: 0;
  z-index: 9994;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0c0b10;
  color: #f3f1f8;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}

.wtf-saver.is-on {
  opacity: 1;
}

.wtf-saver__mouth {
  position: absolute;
  width: min(74vh, 62vw);
  height: auto;
  opacity: 0.2;
  animation: saver-drift 15s ease-in-out infinite;
}

.wtf-saver__line {
  position: relative;
  max-width: 24ch;
  margin: 0;
  padding: 0 6vw;
  font-family: var(--serif);
  font-size: clamp(2rem, 6.5vw, 4.5rem);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.03em;
  text-align: center;
  animation: saver-breathe 7s ease-in-out infinite;
}

.wtf-saver__logo {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(243, 241, 248, 0.35);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  will-change: left, top;
  animation:
    dvd-x 13s linear infinite alternate,
    dvd-y 8.5s linear infinite alternate;
}

@keyframes saver-drift {
  0%,
  100% {
    transform: translate(-4%, 2%) rotate(6deg);
  }

  50% {
    transform: translate(4%, -3%) rotate(-4deg);
  }
}

@keyframes saver-breathe {
  0%,
  100% {
    opacity: 0.9;
  }

  50% {
    opacity: 0.45;
  }
}

@keyframes dvd-x {
  to {
    left: calc(100% - 11.5rem);
  }
}

@keyframes dvd-y {
  to {
    top: calc(100% - 2.2rem);
  }
}

/* —— Fausse mise à jour, vrai mode nuit —— */

.wtf-update {
  position: fixed;
  left: 2.5vw;
  top: 2.5vh;
  z-index: 9996;
  width: min(20rem, 86vw);
  border: 1px solid var(--ink);
  background: var(--bg);
  box-shadow: 4px 4px 0 rgba(12, 12, 12, 0.8);
  opacity: 0;
  transform: translateY(-10px);
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-slip);
}

.wtf-update.is-on {
  opacity: 1;
  transform: none;
}

.wtf-update__bar {
  padding: 0.35rem 0.6rem;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.wtf-update__body {
  padding: 0.9rem;
  font-size: 0.78rem;
}

.wtf-update__body p {
  margin: 0 0 0.5rem;
}

.wtf-update__track {
  height: 3px;
  margin: 0.85rem 0;
  background: var(--line);
  overflow: hidden;
}

.wtf-update__track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.wtf-update.is-installing .wtf-update__track span {
  width: 100%;
  transition: width 1.45s linear;
}

.wtf-update.is-installing .wtf-update__row {
  opacity: 0.3;
  pointer-events: none;
}

.wtf-update__row {
  display: flex;
  gap: 0.5rem;
}

.wtf-update__go,
.wtf-update__skip {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--ink);
  font-size: 0.72rem;
}

.wtf-update__go:hover {
  background: var(--ink);
  color: var(--bg);
}

.wtf-update__skip {
  border-color: var(--line);
  color: var(--mute);
}

/* —— Mode nuit (installé par la fausse mise à jour) —— */

html.is-night {
  --bg: #0c0b10;
  --ink: #f2eff7;
  --mute: #8a8496;
  --line: rgba(242, 239, 247, 0.14);
  --swap: #b9a6cd;
}

html.is-night body {
  background: var(--bg);
  color: var(--ink);
}

html.is-night.has-tasted:not(.is-fourchu) body {
  background: linear-gradient(180deg, #0c0b10 0%, #17111c 100%);
}

html.is-night .backdrop {
  opacity: 0.3;
  filter: invert(1);
}

html.is-night .wtf-menu,
html.is-night .wtf-update,
html.is-night .wtf-error {
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.55);
}

html.is-night .wtf-error {
  border-color: var(--line);
  background: #14121a;
  color: var(--ink);
}

html.is-night.is-fourchu {
  --bg: #1a0c16;
  --ink: #ffe3f0;
  --mute: #b98aa8;
  --swap: #ff8fc0;
}

/* Traces plus visibles quand beaucoup de secrets sont tombés. */
html[data-wtf-tier="3"] .phrase {
  text-shadow:
    0.02em 0 0 rgba(255, 40, 110, 0.2),
    -0.02em 0 0 rgba(50, 90, 255, 0.16);
}

html[data-wtf-tier="3"] .hint kbd {
  letter-spacing: 0.08em;
}

@media (prefers-reduced-motion: reduce) {
  html.is-inverted body {
    transform: none;
  }

  .phrase.is-idle .line__inner {
    animation: none;
  }

  .reveal.is-fleeing {
    transform: none;
  }

  .main.is-nudged .puzzle {
    transform: none;
  }

  /* L'aperçu par sélection reste possible : ce n'est pas du mouvement. */
  .puzzle.is-peeking:not(.is-revealed) .swap .to,
  .puzzle.is-peeking:not(.is-revealed) .swap.add .layer {
    display: block;
  }
}
