/* Dégel : la page d'ouverture. La DA du projet (projets/degel/da) : un livre de contes gravé, l'encre, le papier, l'or. */

:root {
  --encre: #1E2630;
  --encre-2: #27313D;
  --papier: #EFE9DC;
  --papier-2: #E4DCCB;
  --or: #C2922E;
  --givre: #8FA2B2;
  --encre-texte: #2A333E;
  --papier-doux: rgba(239, 233, 220, .72);

  --titres: "IM Fell English SC", "Iowan Old Style", Georgia, serif;
  --texte: "EB Garamond", "Iowan Old Style", Georgia, serif;

  /* une seule échelle d'espaces */
  --e1: .5rem;
  --e2: 1rem;
  --e3: 1.5rem;
  --e4: 2.5rem;
  --e5: 4rem;
  --e6: 6.5rem;

  --marge: clamp(1.25rem, 4.5vw, 4.5rem);
  --large: 84rem;

  --encre-courbe: cubic-bezier(0.65, 0, 0.35, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--papier);
  color: var(--encre-texte);
  font: 400 1.1875rem/1.55 var(--texte);
  font-feature-settings: "onum" 1, "liga" 1;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
p { margin: 0; }

h1, h2 {
  font-family: var(--titres);
  font-weight: 400;
  margin: 0;
  letter-spacing: .005em;
  text-wrap: balance;
}
h2 {
  font-size: clamp(2rem, 1.3rem + 2.4vw, 3.25rem);
  line-height: 1.04;
  color: var(--encre);
}

.legende {
  font-family: var(--texte);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  line-height: 1.4;
}

/* Le bouton : un seul par écran, à l'or ; au survol, un second filet gravé apparaît à l'intérieur. */
.bouton {
  display: inline-flex;
  align-items: center;
  min-height: 3.25rem;
  padding: .7rem 1.75rem .8rem;
  background: var(--or);
  color: var(--encre);
  font: 700 1.15rem/1 var(--texte);
  letter-spacing: .01em;
  text-decoration: none;
  border-radius: 3px;
  outline: 1.5px solid transparent;
  outline-offset: -6px;
  transition: outline-color .18s var(--encre-courbe), transform .18s var(--encre-courbe);
}
.bouton:hover { outline-color: var(--encre); }
.bouton:active { transform: translateY(1px); }
.bouton:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
.ouverture .bouton:focus-visible { outline-color: var(--papier); }

a:focus-visible, input:focus-visible { outline: 2px solid var(--or); outline-offset: 4px; }

/* ---------- L'ouverture : la promesse, et le plateau gelé ---------- */

.ouverture {
  position: relative;
  background: var(--encre);
  color: var(--papier);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  grid-template-rows: auto 1fr;
  column-gap: clamp(2rem, 5vw, 6rem);
  padding: var(--e4) max(var(--marge), (100% - var(--large)) / 2) 0;
  min-height: min(100svh, 62rem);
  /* les hachures du papier gravé, très discrètes */
  background-image: repeating-linear-gradient(-45deg, transparent 0 7px, rgba(239, 233, 220, .025) 7px 8px);
}

.ouverture__marque { grid-column: 1; grid-row: 1; width: max-content; align-self: start; }
.ouverture__marque img { width: 44px; height: 44px; }

.ouverture__texte {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  padding-bottom: var(--e5);
  max-width: 34rem;
}
.ouverture__texte .legende { color: var(--or); margin-bottom: var(--e3); }
.ouverture h1 {
  font-size: clamp(4.25rem, 2rem + 7.4vw, 9rem);
  line-height: .86;
  margin-left: -.04em;
  color: var(--papier);
}
.chapeau {
  margin-top: var(--e3);
  font-size: clamp(1.25rem, 1.05rem + .55vw, 1.5rem);
  line-height: 1.42;
  color: var(--papier-doux);
  max-width: 28ch;
}
.ouverture .bouton { margin-top: var(--e4); }

/* le plateau descend sous la ligne de l'ouverture et mord sur la page suivante */
.ouverture__planche {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: end;
  justify-self: end;
  width: min(100%, 42rem, calc((100svh - 8rem) * 608 / 688));
  margin-bottom: calc(-1 * var(--e4));
  position: relative;
  z-index: 1;
}
.ouverture__planche img { width: 100%; background: var(--encre); }
.ouverture__planche figcaption {
  margin-top: var(--e1);
  color: var(--encre);
  opacity: .62;
  text-align: right;
}

/* ---------- Le geste ---------- */

.geste {
  max-width: var(--large);
  margin: 0 auto;
  padding: calc(var(--e6) + var(--e2)) var(--marge) var(--e6);
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  gap: var(--e5) clamp(2rem, 5vw, 5rem);
  align-items: start;
}
.geste__texte { padding-top: var(--e2); }
.geste__texte .legende,
.carte__texte .legende,
.jouer .legende { color: #8A6620; margin-bottom: var(--e2); }
.geste__texte h2 { max-width: 13ch; }
.geste__texte > p { margin-top: var(--e3); max-width: 34ch; }

.gemmes {
  margin-top: var(--e5);
  padding-top: var(--e3);
  border-top: 1px solid rgba(30, 38, 48, .22);
}
.gemmes img { width: min(100%, 17rem); }
.gemmes figcaption { margin-top: var(--e2); font-style: italic; font-size: 1.05rem; max-width: 30ch; }

/* la planche : un cadre d'encre à double filet, comme une planche hors-texte */
.planche {
  background: var(--encre);
  color: var(--papier);
  padding: var(--e4) var(--e4) var(--e3);
  outline: 1px solid var(--encre);
  outline-offset: 5px;
  margin: 6px;
}
.planche__figures {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--e3);
}
.planche__figures li { display: flex; flex-direction: column; gap: var(--e2); }
.planche__figures img { width: 100%; }
.planche__figures p { font-size: 1.02rem; line-height: 1.4; color: var(--papier-doux); max-width: 22ch; }
.planche__num {
  display: block;
  font-family: var(--titres);
  font-size: 1.15rem;
  color: var(--or);
  margin-bottom: .15rem;
}
.planche > figcaption {
  margin-top: var(--e4);
  padding-top: var(--e2);
  border-top: 1px solid rgba(239, 233, 220, .18);
  color: rgba(239, 233, 220, .55);
}

/* ---------- La carte ---------- */

.carte {
  background: var(--encre);
  color: var(--papier);
  padding: var(--e6) var(--marge) var(--e5);
  background-image: repeating-linear-gradient(-45deg, transparent 0 7px, rgba(239, 233, 220, .025) 7px 8px);
}
.carte__texte {
  max-width: var(--large);
  margin: 0 auto var(--e5);
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  column-gap: clamp(2rem, 5vw, 5rem);
  align-items: end;
}
.carte__texte .legende { grid-column: 1 / -1; color: var(--or); }
.carte__texte h2 { color: var(--papier); max-width: 12ch; }
.carte__texte p { color: var(--papier-doux); max-width: 40ch; padding-bottom: .3rem; }

.carte__planche { max-width: min(90rem, (100svh - 9rem) * 1200 / 720); margin: 0 auto; }
.carte__planche > figcaption { margin-top: var(--e3); color: rgba(239, 233, 220, .55); }

/* Le dégel : le printemps se découvre de gauche à droite, chapitre après chapitre.
   Seuls des transform bougent : le voile avance, son contenu recule d'autant. */
.degel {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1200 / 720;
  background: var(--papier);
  outline: 1px solid rgba(239, 233, 220, .5);
  outline-offset: 6px;
}
.degel img { width: 100%; height: 100%; }
.degel__hiver { position: absolute; inset: 0; }
.degel__voile, .degel__piste {
  position: absolute;
  inset: 0;
  transform: translateX(calc((var(--p) - 1) * 100%));
}
.degel__voile {
  overflow: hidden;
  /* le bord du dégel est déchiqueté, comme une glace qui cède */
  -webkit-mask-image: linear-gradient(#000, #000), url(img/bord-degel.svg);
  mask-image: linear-gradient(#000, #000), url(img/bord-degel.svg);
  -webkit-mask-size: calc(100% - 23px) 100%, 24px 100%;
  mask-size: calc(100% - 23px) 100%, 24px 100%;
  -webkit-mask-position: left top, right top;
  mask-position: left top, right top;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
.degel__printemps {
  position: absolute;
  inset: 0;
  transform: translateX(calc((1 - var(--p)) * 100%));
}
.degel__front {
  position: absolute;
  top: 0;
  right: -1px;
  width: 24px;
  height: 100%;
  background: url(img/front-degel.svg) right top / 100% 100% no-repeat;
}
.degel[data-p="0"] .degel__front, .degel[data-p="1"] .degel__front { opacity: 0; }

.degel__chapitres { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; pointer-events: none; }
.degel__chapitres li {
  position: absolute;
  transform: translate(-50%, -52%);
  font: 400 clamp(.6rem, .2rem + .75vw, 1.05rem)/1 var(--titres);
  color: rgba(30, 38, 48, .55);
  transition: color .3s var(--encre-courbe);
}
.degel__chapitres li.degele { color: var(--encre); }

.degel__reglette {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 7.5rem;
  align-items: center;
  gap: var(--e3);
  margin-top: var(--e4);
}
.degel__reglette label { color: rgba(239, 233, 220, .7); }
.degel__reglette output {
  font: 400 1.3rem/1 var(--titres);
  color: var(--papier);
  text-align: right;
}

/* la réglette : un filet gravé, et un médaillon d'or à attraper */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2.75rem;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: rgba(239, 233, 220, .35); border-top: 1px solid rgba(239, 233, 220, .35); }
input[type="range"]::-moz-range-track { height: 3px; background: rgba(239, 233, 220, .35); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -14px;
  border-radius: 50%;
  background: var(--or);
  border: 2px solid var(--encre);
  box-shadow: 0 0 0 1.5px var(--or);
}
input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--or);
  border: 2px solid var(--encre);
  box-shadow: 0 0 0 1.5px var(--or);
}

/* ---------- Où jouer : la page de fin, et son cul-de-lampe ---------- */

.jouer {
  max-width: 44rem;
  margin: 0 auto;
  padding: var(--e6) var(--marge) var(--e6);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.jouer__vignette { width: 72px; height: 72px; margin-bottom: var(--e4); }
.jouer h2 { max-width: 16ch; }
.jouer > p:not(.legende) { margin-top: var(--e3); max-width: 36ch; }
.jouer .bouton { margin-top: var(--e4); }

.colophon {
  border-top: 1px solid rgba(30, 38, 48, .2);
  margin: 0 var(--marge);
  padding: var(--e3) 0 var(--e4);
  text-align: center;
  font-style: italic;
  font-size: 1rem;
  color: rgba(42, 51, 62, .7);
}

/* ---------- Téléphone : pensé pour le pouce, pas réduit ---------- */

@media (max-width: 960px) {
  .geste { grid-template-columns: 1fr; }
  .geste__texte { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--e4); }
  .geste__texte .legende, .geste__texte h2 { grid-column: 1 / -1; }
  .gemmes { margin-top: var(--e3); }
}

@media (max-width: 720px) {
  body { font-size: 1.125rem; }

  .ouverture {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-top: var(--e3);
  }
  .ouverture__texte { padding: var(--e4) 0 var(--e4); }
  .ouverture__texte .legende { margin-bottom: var(--e2); }
  .ouverture .bouton { margin-top: var(--e3); }
  .ouverture__planche {
    width: calc(100% + 2 * var(--marge) - 2rem);
    align-self: center;
    margin-bottom: calc(-1 * var(--e5));
  }

  .geste { padding-top: calc(var(--e5) + var(--e4)); gap: var(--e4); }
  .geste__texte { display: block; }
  .gemmes { margin-top: var(--e4); }

  .planche { padding: var(--e3) var(--e2) var(--e2); margin: 6px 0; }
  .planche__figures { grid-template-columns: 1fr; gap: var(--e3); }
  .planche__figures li { flex-direction: row; align-items: center; gap: var(--e3); }
  .planche__figures img { width: 44%; flex: none; }
  .planche > figcaption { margin-top: var(--e3); }

  .carte { padding-top: var(--e5); }
  .carte__texte { display: block; margin-bottom: var(--e4); }
  .carte__texte p { margin-top: var(--e3); }
  .carte__planche { margin: 0 calc(-1 * var(--marge)); }
  .degel { outline: none; }
  .degel__chapitres { display: none; }
  .degel__reglette { grid-template-columns: minmax(0, 1fr) auto; padding: 0 var(--marge); row-gap: 0; }
  .degel__reglette label { grid-column: 1 / -1; }
  .degel__reglette input { grid-column: 1; }
  .carte__planche > figcaption { padding: 0 var(--marge); }
}
