@font-face {
  font-family: "Fraunces";
  src: url("/fonts/fraunces.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

/* Ambiances. « livre » reprend la couverture du livre d'Emma. */
:root,
[data-theme="livre"] {
  --fond: #f8ef8f;
  --papier: #fdf9cf;
  --encre: #6b2c45;
  --titre: #2a8db3;
  --doux: rgba(107, 44, 69, 0.72);
}
[data-theme="lavande"] {
  --fond: #eedffb;
  --papier: #f9f2ff;
  --encre: #3b1242;
  --titre: #7a35a8;
  --doux: rgba(59, 18, 66, 0.72);
}
[data-theme="nuit"] {
  --fond: #24111b;
  --papier: #341a29;
  --encre: #f8ef8f;
  --titre: #6fc4e2;
  --doux: rgba(248, 239, 143, 0.74);
}

* {
  box-sizing: border-box;
}
html {
  background: var(--fond);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100svh;
  background: var(--fond);
  color: var(--encre);
  font-family: "Fraunces", Georgia, serif;
  font-variation-settings: "SOFT" 100;
  font-optical-sizing: auto;
  font-weight: 450;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}
a {
  color: inherit;
}
img {
  display: block;
  max-width: 100%;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="nuit"] .grain {
  mix-blend-mode: screen;
  opacity: 0.1;
}

.page {
  position: relative;
  width: min(100%, 460px);
  margin: 0 auto;
  padding: max(26px, env(safe-area-inset-top)) 22px 56px;
}

/* ---------- Tête ---------- */
.tete {
  position: relative;
}
.portrait {
  position: relative;
  width: 70%;
  aspect-ratio: 4 / 5;
  margin: 6px 0 0 2%;
  border: 1.5px solid var(--encre);
  border-radius: 24px;
  overflow: hidden;
  background: var(--papier);
  box-shadow: 6px 7px 0 var(--encre);
  transform: rotate(-2.5deg);
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.phrase {
  position: absolute;
  top: 34px;
  right: -2px;
  z-index: 2;
  max-width: 44%;
  margin: 0;
  padding: 12px 18px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  transform: rotate(7deg);
}
.phrase span {
  position: relative;
  z-index: 1;
}
.phrase::before {
  content: "";
  position: absolute;
  inset: 4px 6px;
  border-radius: 50%;
  background: var(--fond);
}
.phrase svg {
  position: absolute;
  inset: -4px -6px;
  width: calc(100% + 12px);
  height: calc(100% + 8px);
  overflow: visible;
}

.nom {
  position: relative;
  z-index: 3;
  margin: -0.52em 0 0;
  color: var(--titre);
  font-size: clamp(68px, 23vw, 104px);
  font-weight: 900;
  line-height: 0.84;
  letter-spacing: -0.025em;
  -webkit-text-stroke: 12px var(--fond);
  paint-order: stroke fill;
  overflow-wrap: anywhere;
}
.nom span {
  display: block;
}
.nom span + span {
  padding-left: 0.42em;
}

.signe {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 0 6px;
  color: var(--encre);
}
.signe .trait {
  width: 62%;
  height: 16px;
  overflow: visible;
}
.signe .coeur {
  width: 30px;
  height: 30px;
  overflow: visible;
  transform: rotate(8deg);
}

.dessin {
  fill: none;
  stroke: var(--encre);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.reseaux {
  display: flex;
  gap: 10px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}
.reseaux a {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1.5px solid var(--encre);
  border-radius: 50%;
  background: var(--papier);
  color: var(--encre);
  transition: transform 0.18s ease;
}
.reseaux svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- La ligne et ses gares ---------- */
.ligne {
  position: relative;
  margin: 34px 0 0;
  padding: 4px 0 0 34px;
}
.ligne::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: var(--encre);
  transform-origin: top;
  transform: scaleY(0);
}
.gares {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.gare {
  position: relative;
}
.gare::before {
  content: "";
  position: absolute;
  left: -31px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid var(--encre);
  border-radius: 50%;
  background: var(--fond);
  transition: background-color 0.18s ease;
}
.gare:hover::before,
.gare:focus-within::before {
  background: var(--encre);
}

.carte {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 13px 16px 13px 18px;
  border: 1.5px solid var(--encre);
  border-radius: 18px;
  background: var(--papier);
  box-shadow: 4px 5px 0 var(--encre);
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.carte .txt {
  flex: 1;
  min-width: 0;
}
.carte .titre {
  display: block;
  font-size: 18.5px;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.carte .petite {
  display: block;
  margin-top: 4px;
  color: var(--doux);
  font-size: 14.5px;
  font-weight: 450;
}
.carte .fleche {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}
.carte .vignette {
  flex: none;
  width: 54px;
  height: 78px;
  margin: -4px 0 -4px -4px;
  border: 1.5px solid var(--encre);
  border-radius: 5px;
  object-fit: cover;
  transform: rotate(-4deg);
  background: var(--fond);
}

.barre {
  position: relative;
  white-space: nowrap;
  opacity: 0.62;
}
.barre svg {
  position: absolute;
  left: -4px;
  top: 12%;
  width: calc(100% + 8px);
  height: 86%;
  overflow: visible;
  opacity: 1;
}
.barre .dessin {
  stroke-width: 2.2;
}

.terminus {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 26px 0 0;
  font-size: 19px;
  font-weight: 600;
  font-style: normal;
}
.terminus::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--encre);
}
.terminus .coeur {
  width: 22px;
  height: 22px;
  overflow: visible;
}
.terminus.vide {
  height: 20px;
}

/* ---------- Survol, appui, clavier ---------- */
@media (hover: hover) {
  .carte:hover {
    transform: translate(-2px, -3px);
    box-shadow: 7px 9px 0 var(--encre);
  }
  .carte:hover .fleche {
    transform: translateX(4px);
  }
  .reseaux a:hover {
    transform: translateY(-3px) rotate(-6deg);
    background: var(--encre);
    color: var(--fond);
  }
}
.carte:active {
  transform: translate(3px, 4px);
  box-shadow: 1px 1px 0 var(--encre);
}
a:focus-visible {
  outline: 3px solid var(--titre);
  outline-offset: 3px;
}

/* ---------- Entrée ---------- */
.entre {
  opacity: 0;
  transform: translateY(14px);
}
.pret .entre {
  animation: monte 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}
.portrait.entre {
  transform: rotate(-7deg) translateY(18px) scale(0.96);
}
.pret .portrait.entre {
  animation-name: pose;
}
.pret .ligne::before {
  animation: tire 1.1s cubic-bezier(0.3, 0.7, 0.2, 1) 0.45s both;
}
.pret .dessin {
  animation: trace 0.7s ease-out both;
  animation-delay: calc(var(--d, 0) * 1ms + 500ms);
}
@keyframes monte {
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pose {
  to {
    opacity: 1;
    transform: rotate(-2.5deg);
  }
}
@keyframes tire {
  to {
    transform: scaleY(1);
  }
}
@keyframes trace {
  to {
    stroke-dashoffset: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .entre,
  .portrait.entre {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
  .portrait.entre {
    transform: rotate(-2.5deg);
  }
  .ligne::before {
    transform: none;
    animation: none !important;
  }
  .dessin {
    stroke-dashoffset: 0;
    animation: none !important;
  }
  .carte,
  .reseaux a {
    transition: none;
  }
}

/* ---------- Grand écran : la tête reste, la ligne défile ---------- */
@media (min-width: 940px) {
  .page {
    display: grid;
    grid-template-columns: 400px minmax(0, 440px);
    justify-content: center;
    align-items: start;
    gap: 84px;
    align-content: center;
    width: 100%;
    min-height: 100svh;
    padding: 7vh 40px;
  }
  .tete {
    position: sticky;
    top: 7vh;
  }
  .nom {
    font-size: 104px;
  }
  .ligne {
    margin-top: 44px;
  }
}

.secours {
  display: grid;
  gap: 12px;
  padding: 24px;
  font-size: 18px;
}

@media (max-width: 359px) {
  .page {
    padding-left: 16px;
    padding-right: 16px;
  }
  .carte .titre {
    font-size: 17px;
  }
  .carte .vignette {
    width: 44px;
    height: 64px;
  }
}
