/* ============================================================
   kaleïdo-haïkus — feuille de styles
   ArtsPo Éditions / Harfang — Valentine Hébert & Ignatus
   ============================================================ */

/* Typographies : Clara Sambot, Velvetyne, licence SIL OFL */
@font-face {
  font-family: 'CirrusCumulus';
  src: url('fonts/CirrusCumulus.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'DINdong';
  src: url('fonts/DINdong.woff2') format('woff2');
  font-display: swap;
}
/* Garamond de la maison (pages « les auteurs » et « l'éditeur »),
   comme dans Distillations et Remixes 2025 — Cormorant Project, OFL */
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/CormorantGaramond-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/CormorantGaramond-400-italique.woff2') format('woff2');
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('fonts/CormorantGaramond-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  --papier: #F3EFE6;                 /* blanc-cassé validé */
  --encre: #1d1c1a;
  --encre-douce: #6f6a60;
  --filet: rgba(29, 28, 26, 0.14);
  --voile: rgba(243, 239, 230, 0.78);

  --font-titre: 'CirrusCumulus', Georgia, serif;
  --font-vers: 'DINdong', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-maison: 'Cormorant Garamond', Garamond, Georgia, serif;

  --h-entete: 52px;
  --h-pied: 86px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Valeurs recalculées en pixels entiers par app.js (miseEnPage) */
  --w-figure: 214px;
  --h-bande: 148px;
  --w-texte: 176px;
  --w-accueil: 187px;
  --h-accueil: 129px;

  --duree-tour: 300ms;               /* glissement d'une bande au doigt */
  --duree-tirage: 620ms;             /* glissement au tirage (secouer) */
  --courbe: cubic-bezier(.22, .72, .12, 1);
}

@media (max-height: 500px) and (orientation: landscape) {
  :root { --h-entete: 40px; --h-pied: 58px; }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--papier);
  color: var(--encre);
  font-family: var(--font-vers);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
button:focus-visible, [tabindex]:focus-visible {
  outline: 1px dashed var(--encre-douce);
  outline-offset: 3px;
}

img { display: block; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }

/* ============================================================
   ÉCRAN D'ENTRÉE
   ============================================================ */
#accueil {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  background: var(--papier);
  text-align: center;
  cursor: pointer;
  transition: opacity 650ms ease, visibility 0s linear 650ms;
}
#accueil.sortie { opacity: 0; visibility: hidden; pointer-events: none; }

.figure-accueil {
  width: var(--w-accueil);
  margin-bottom: 30px;
}
.figure-accueil img {
  width: var(--w-accueil);
  height: var(--h-accueil);
  object-fit: cover;
  opacity: 0;
  animation: bande-gauche 900ms var(--courbe) forwards;
}
/* Les trois bandes arrivent de côtés alternés : le carnet qu'on tourne */
.figure-accueil img:nth-child(1) { animation-delay: 120ms; }
.figure-accueil img:nth-child(2) { animation-name: bande-droite; animation-delay: 300ms; }
.figure-accueil img:nth-child(3) { animation-delay: 480ms; }

@keyframes bande-gauche {
  from { opacity: 0; transform: translateX(-38%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes bande-droite {
  from { opacity: 0; transform: translateX(38%); }
  to   { opacity: 1; transform: translateX(0); }
}

#accueil h1 {
  font-family: var(--font-titre);
  font-weight: 400;
  font-size: clamp(2.1rem, 9vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: 0.01em;
  opacity: 0;
  animation: apparition 900ms ease 950ms forwards;
}
#accueil .auteurs {
  margin-top: 10px;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: var(--encre-douce);
  opacity: 0;
  animation: apparition 900ms ease 1150ms forwards;
}
#accueil .entrer {
  margin-top: 34px;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--encre-douce);
  opacity: 0;
  animation: apparition 900ms ease 1500ms forwards, respiration 2.8s ease-in-out 2.4s infinite;
}
@keyframes apparition { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes respiration { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ============================================================
   VUES (kaléidoscope, haïkus 26)
   ============================================================ */
.vue {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  background: var(--papier);
}

.entete {
  flex: 0 0 var(--h-entete);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 10px;
}
.entete .titre {
  font-family: var(--font-titre);
  font-size: 1.3rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.entete > :first-child { justify-self: start; }
.entete > :last-child  { justify-self: end; }
.groupe-droite { display: flex; align-items: center; gap: 4px; }

.lien-discret {
  font-size: 0.8rem;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--encre-douce);
  padding: 12px 6px 8px;             /* DINdong porte haut : on rééquilibre */
  white-space: nowrap;
  transition: color 200ms ease;
}
#btn-sommaire { min-width: 5.6em; text-align: right; }
.lien-discret:hover { color: var(--encre); }

.icone {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--encre-douce);
  transition: color 200ms ease;
}
.icone:hover { color: var(--encre); }
.icone svg { width: 19px; height: 19px; }

/* ---------------- Kaléidoscope ---------------- */
#kaleido {
  opacity: 0;
  transition: opacity 700ms ease;
}
#kaleido.visible { opacity: 1; }

#scene {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#composition {
  width: calc(var(--w-figure) + var(--w-texte));
  display: flex;
  flex-direction: column;
}

/* Une bande : figure à gauche, vers à droite. Hauteurs entières
   calculées en JS pour que les trois images se raccordent sans filet. */
.bande {
  position: relative;
  height: var(--h-bande);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.bande:active { cursor: grabbing; }

.bande-track {
  position: absolute; top: 0; left: 0;
  height: 100%;
  width: calc(3 * (var(--w-figure) + var(--w-texte)));
  display: flex;
  will-change: transform;
}

.bande-item {
  flex: 0 0 calc(var(--w-figure) + var(--w-texte));
  height: 100%;
  display: flex;
}
.bande-item .illu {
  flex: 0 0 var(--w-figure);
  height: 100%;
  overflow: hidden;
}
.bande-item .illu img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bande-item .vers {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 0 30px 0 16px;            /* à droite : place de la flèche */
  font-size: clamp(15px, min(4.2vw, calc(var(--h-bande) * 0.15)), 26px);
  line-height: 1.32;
  hyphens: manual;
  overflow-wrap: break-word;
}

/* Flèches discrètes aux bords de la bande */
.fleche {
  position: absolute; top: 50%; z-index: 3;
  width: 28px; height: 28px;
  margin-top: -14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--encre);
  opacity: 0.32;
  transition: opacity 200ms ease, background-color 200ms ease;
}
.fleche svg { width: 14px; height: 14px; }
/* À gauche, la flèche est posée sur l'image : trait clair et ombre
   légère, lisible sur les fonds clairs comme sur les noirs */
.fleche.gauche {
  left: 3px;
  color: var(--papier);
  opacity: 0.75;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.6));
}
.fleche.droite { right: 2px; }
.fleche:hover, .fleche:focus-visible { opacity: 0.9; }
@media (hover: hover) and (pointer: fine) {
  .bande:hover .fleche { opacity: 0.6; }
  .bande:hover .fleche.gauche { opacity: 1; }
}

/* ---------------- Pied : secouer + compteur ---------------- */
.pied {
  flex: 0 0 var(--h-pied);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
}
#btn-secouer {
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 6px 14px;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  color: var(--encre);
}
#btn-secouer svg { width: 17px; height: 17px; }
#btn-secouer.secoue svg { animation: secousse 520ms ease; }
@keyframes secousse {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-14deg); }
  45% { transform: rotate(12deg); }
  70% { transform: rotate(-6deg); }
}
#compteur {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--encre-douce);
  font-variant-numeric: tabular-nums;
}
@media (max-height: 500px) and (orientation: landscape) {
  .pied { flex-direction: row; gap: 18px; }
}

/* ---------------- Haïkus 26 ---------------- */
#h26 {
  z-index: 20;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 520ms var(--courbe), visibility 0s linear 520ms;
  box-shadow: -1px 0 0 var(--filet);
}
#h26.ouvert {
  transform: none;
  visibility: visible;
  transition: transform 520ms var(--courbe), visibility 0s;
}

#defileur {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  outline: none;
}
#defileur::-webkit-scrollbar { display: none; }

.page {
  height: var(--h-page, 100%);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  padding: 18px 28px;
}
.page .categorie {
  align-self: start;
  margin-top: 6px;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--encre-douce);
}
.page .haiku {
  font-size: clamp(20px, 5.6vw, 30px);
  line-height: 1.5;
  max-width: 20em;
}
.page .numero {
  align-self: end;
  margin-bottom: 6px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--encre-douce);
  font-variant-numeric: tabular-nums;
}

.page-titre .bloc {
  grid-row: 2;
  text-align: center;
}
.page-titre h2 {
  font-family: var(--font-titre);
  font-weight: 400;
  font-size: clamp(2.6rem, 12vw, 4rem);
  line-height: 1.1;
}
.page-titre .auteur {
  margin-top: 12px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: var(--encre-douce);
}
.page-titre .invite {
  grid-row: 3;
  align-self: end;
  margin-bottom: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--encre-douce);
}
.page-titre .invite svg {
  width: 18px; height: 18px;
  animation: invite 2.4s ease-in-out infinite;
}
@keyframes invite { 0%, 100% { transform: translateY(3px); opacity: .45; } 50% { transform: translateY(-3px); opacity: 1; } }

/* Pages « les auteurs » et « l'éditeur » : Garamond de la maison.
   Cormorant a un petit œil : les corps sont un peu plus forts qu'en DINdong. */
.page-auteurs, .page-editeur { font-family: var(--font-maison); }
.page-auteurs .categorie { font-size: 0.9rem; letter-spacing: 0.14em; }

/* Page « les auteurs » */
.page-auteurs { overflow-y: auto; }
.page-auteurs .bios {
  grid-row: 2;
  width: 100%;
  max-width: 23rem;
  display: flex; flex-direction: column;
  gap: 26px;
}
.bio p {
  font-size: clamp(19px, 5.2vw, 22px);
  line-height: 1.42;
}
.bio em { font-style: italic; }
.bio .liens {
  margin-top: 6px;
  display: flex; flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
.bio .liens a {
  color: var(--encre-douce);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(29, 28, 26, 0.3);
  overflow-wrap: anywhere;
}
.bio .liens a:hover { color: var(--encre); }

/* Page « l'éditeur » */
.page-editeur .bloc {
  grid-row: 2;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.page-editeur .logo { width: 96px; height: 96px; margin-bottom: 28px; opacity: 0.9; }
.page-editeur .editeur { font-size: 1.75rem; font-weight: 400; letter-spacing: 0.1em; }
.page-editeur .collection {
  margin-top: 8px;
  font-size: 1.05rem;
  font-style: italic;
  color: var(--encre-douce);
}
.page-editeur .isbn {
  margin-top: 14px;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--encre-douce);
}
.page-editeur .visiter {
  margin-top: 34px;
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 12px 24px;
  border: 1px solid rgba(29, 28, 26, 0.25);
  border-radius: 99px;
  color: var(--encre);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: background-color 200ms ease;
}
.page-editeur .visiter:hover { background: rgba(29, 28, 26, 0.05); }
.page-editeur .credits {
  margin-top: 40px;
  max-width: 22rem;
  font-size: 0.95rem;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: var(--encre-douce);
  text-wrap: balance;                /* pas de « (Ignatus) » orphelin sur sa ligne */
}
/* chaque mention reste d'un tenant : le retour à la ligne se fait au « · » */
.page-editeur .credits .mention { display: inline-block; }
.page-editeur .credits .sep { margin: 0 0.55em; }
.page-editeur .credits em { font-style: italic; display: inline-block; }   /* titres d'un tenant */
/* Écrans étroits : une mention par ligne, sans « · » en début de ligne */
@media (max-width: 359px) {
  .page-editeur .credits .sep { display: none; }
  .page-editeur .credits .mention { display: block; }
}
.page-editeur .visiter svg { width: 17px; height: 17px; }

/* Lien discret vers les mentions légales, sous les crédits */
.page-editeur .lien-mentions {
  margin-top: 22px;
  font-family: var(--font-maison);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  color: var(--encre-douce);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: rgba(29, 28, 26, 0.3);
  padding: 6px 4px;
}
.page-editeur .lien-mentions:hover { color: var(--encre); }

/* Feuille des mentions légales : recouvre la lecture, sous l'en-tête */
#mentions {
  position: absolute;
  inset: calc(var(--h-entete) + var(--safe-top)) 0 0 0;
  z-index: 6;
  background: var(--papier);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 28px calc(36px + var(--safe-bottom));
  font-family: var(--font-maison);
  outline: none;
  animation: apparition 300ms ease;
}
#mentions[hidden] { display: none; }
#mentions .mentions-entete,
#mentions .mentions-corps { max-width: 26rem; margin: 0 auto; }
#mentions .mentions-entete {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--filet);
}
#mentions h2 { font-size: 1.45rem; font-weight: 400; letter-spacing: 0.04em; }
#mentions .mentions-entete .lien-discret { font-family: var(--font-vers); }
#mentions section { margin-top: 22px; }
#mentions h3 {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--encre-douce);
  margin-bottom: 6px;
}
#mentions p { font-size: 1.08rem; line-height: 1.5; }

/* Sommaire : feuille qui recouvre la lecture */
#sommaire {
  position: absolute;
  inset: calc(var(--h-entete) + var(--safe-top)) 0 0 0;
  z-index: 5;
  background: var(--papier);
  overflow-y: auto;
  padding: 18px 28px calc(28px + var(--safe-bottom));
  animation: apparition 300ms ease;
}
#sommaire[hidden] { display: none; }
#sommaire ol {
  list-style: none;
  max-width: 26rem;
  margin: 0 auto;
}
#sommaire li + li { border-top: 1px solid var(--filet); }
#sommaire li.apres { margin-top: 22px; border-top: 1px solid rgba(29, 28, 26, 0.35); }
#sommaire button {
  width: 100%;
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px;
  padding: 14px 2px;
  text-align: left;
  font-size: 1.02rem;
  text-transform: lowercase;
}
#sommaire button .nb {
  font-size: 0.75rem;
  color: var(--encre-douce);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------------- Toast ---------------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--h-pied) + var(--safe-bottom) + 10px);
  z-index: 60;
  transform: translateX(-50%) translateY(8px);
  max-width: calc(100vw - 32px);
  padding: 8px 16px;
  border-radius: 99px;
  background: var(--encre);
  color: var(--papier);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  :root { --duree-tour: 1ms; --duree-tirage: 1ms; }
  .figure-accueil img, #accueil h1, #accueil .auteurs, #accueil .entrer {
    animation: none; opacity: 1;
  }
  #h26, #h26.ouvert, #kaleido { transition: none; }
  .page-titre .invite svg, #btn-secouer.secoue svg { animation: none; }
}
