/* Kalma AI — le catalogue en orbite (d'après le prompt « Folio Room », 26/11/2026).
   Douze livres en 3D autour du titre du catalogue. Tout le mouvement est dans orbite.js
   (y compris la place du titre, qui monte en haut du bloc quand on passe en grille) ;
   ici : la scène, le livre (couverture, dos, tranches, première page), la fiche d'un livre ouvert, les commandes. */

.ob {
  --ob-w: clamp(120px, 12.4vw, 220px); /* la largeur d'un livre */
  --ob-h: calc(var(--ob-w) * 1.327);
  --ob-d: calc(var(--ob-w) * 0.085); /* son épaisseur */
  --ob-r: calc(var(--ob-w) * 0.075); /* l'arrondi de ses coins */
  position: relative;
  /* la scène prend toute la largeur de l'écran, quel que soit le cadre du bloc */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  height: clamp(660px, 100svh, 940px);
  /* les livres qui dépassent en bas passent par-dessus le bloc des abonnements, sans être coupés ;
     sur les côtés, ils restent coupés au bord de l'écran */
  z-index: 2;
  overflow-x: clip;
  overflow-y: visible;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.ob.ob-prise {
  cursor: grabbing;
}

.ob.ob-ouvert,
.ob.ob-grille {
  cursor: default;
}

/* ——— Le titre, au centre ——— */
.ob-centre {
  position: absolute;
  inset: 6% 0 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
  transition: opacity 0.45s var(--ease);
}

.ob-milieu {
  width: min(48vw, 640px);
  text-align: center;
  will-change: transform;
}

.ob .builds-head {
  margin: 0;
  padding: 0;
  max-width: none;
}

.ob .builds-title {
  font-size: clamp(34px, 4.5vw, 70px);
}

.ob .builds-sub {
  max-width: 34em;
  margin-left: auto;
  margin-right: auto;
  font-size: clamp(14px, 1.1vw, 16px);
}

.ob.ob-ouvert .ob-centre,
.ob.ob-ouvert .ob-coin {
  opacity: 0;
  pointer-events: none;
}

/* les six familles : un clic donne sa couverture aux douze livres */
.ob-puces {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: clamp(16px, 2.4vh, 26px);
  pointer-events: auto;
}

.ob-puce {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  font: 500 13px/1 var(--font);
  white-space: nowrap;
  color: var(--label);
  cursor: pointer;
  transition:
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.ob-puce:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ob-puce[aria-pressed="true"] {
  background: var(--label);
  box-shadow: none;
  color: #000;
}

/* à partir de la tablette, les six familles tiennent sur une seule ligne (elle peut dépasser un peu le texte, pas les livres) */
@media (min-width: 760px) {
  .ob-puces {
    flex-wrap: nowrap; /* centrée : si la ligne dépasse le texte, elle dépasse autant des deux côtés */
  }
}

@media (min-width: 760px) and (max-width: 1099px) {
  .ob-puce {
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }
}

/* ——— Les livres ——— */
.ob-sol,
.ob-livres {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ob-sol {
  z-index: 2;
}

.ob-livres {
  z-index: 3;
  perspective: 1900px;
}

.ob-ombre {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--ob-w) * 0.84);
  height: calc(var(--ob-h) * 0.13);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  filter: blur(16px);
  opacity: 0;
  will-change: transform, opacity;
}

.ob-livre {
  --open: 0; /* de 0 (fermé) à 1 (couverture grande ouverte) */
  --gx: 0%; /* le reflet glisse sur la couverture quand le livre penche */
  position: absolute;
  left: 0;
  top: 0;
  width: var(--ob-w);
  height: var(--ob-h);
  transform-style: preserve-3d;
  opacity: 0;
  pointer-events: auto;
  cursor: inherit;
  outline: none;
  will-change: transform, opacity;
}

.ob:not(.ob-pret) .ob-livre {
  visibility: hidden;
}

.ob-livre:focus-visible .ob-cv {
  outline: 2px solid var(--label);
  outline-offset: 4px;
}

.ob.ob-grille .ob-livre,
.ob.ob-ouvert .ob-livre {
  cursor: pointer;
}

.ob-3d,
.ob-couv,
.ob-cv,
.ob-dedans,
.ob-page,
.ob-verso {
  position: absolute;
  inset: 0;
}

.ob-3d,
.ob-couv {
  transform-style: preserve-3d;
}

/* la couverture : elle pivote sur sa charnière, à gauche */
.ob-couv {
  transform-origin: left center;
  transform: translateZ(calc(var(--ob-d) / 2)) rotateY(calc(var(--open) * -158deg));
}

.ob-cv,
.ob-dedans {
  overflow: hidden;
  border-radius: var(--ob-r);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.ob-cv {
  background: var(--ob-couv);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.26),
    inset 0 1px 0 1px rgba(255, 255, 255, 0.1),
    0 0 0 1px rgba(0, 0, 0, 0.55);
}

.ob-cv img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* le pli de la charnière */
.ob-cv::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 3.2%;
  z-index: 1;
  width: 1.6%;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.32), rgba(255, 255, 255, 0.16));
}

/* le reflet */
.ob-cv::after {
  content: "";
  position: absolute;
  inset: 0 -40%;
  z-index: 2;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.26) 48%, transparent 64%);
  mix-blend-mode: soft-light;
  transform: translateX(var(--gx));
}

.ob-et,
.ob-nom {
  position: absolute;
  z-index: 3;
  color: var(--ob-tx);
}

.ob-et {
  left: 9%;
  top: 6%;
  padding: 0.42em 0.7em;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  font: 500 calc(var(--ob-w) * 0.052) / 1 var(--font);
  color: #f5f5f7;
}

.ob-nom {
  left: 9%;
  right: 7%;
  bottom: 6%;
  display: grid;
  gap: 0.25em;
  font: 500 calc(var(--ob-w) * 0.092) / 1.08 "Geist", "Inter", sans-serif;
  letter-spacing: -0.03em;
  text-shadow: 0 1px 12px var(--ob-couv), 0 0 3px var(--ob-couv);
}

.ob-nom small {
  font: 500 calc(var(--ob-w) * 0.05) / 1 var(--font);
  letter-spacing: 0;
  opacity: 0.7;
}

/* l'intérieur de la couverture */
.ob-dedans {
  border-radius: var(--ob-r);
  background: var(--ob-garde);
  transform: rotateY(180deg);
}

/* la première page */
.ob-page {
  display: flex;
  flex-direction: column;
  gap: calc(var(--ob-w) * 0.035);
  padding: calc(var(--ob-w) * 0.1) calc(var(--ob-w) * 0.09) calc(var(--ob-w) * 0.09) calc(var(--ob-w) * 0.11);
  border-radius: calc(var(--ob-r) * 0.9);
  background: #f4f4f1;
  box-shadow: inset calc(var(--ob-w) * 0.06) 0 calc(var(--ob-w) * 0.07) calc(var(--ob-w) * -0.04) rgba(0, 0, 0, 0.3);
  transform: translateZ(calc(var(--ob-d) / 2 - 1.5px));
  color: #141414;
}

.ob-p-cat,
.ob-p-etat {
  font: 500 calc(var(--ob-w) * 0.046) / 1.2 var(--font);
  color: #77756f;
}

.ob-page b {
  font: 600 calc(var(--ob-w) * 0.088) / 1.1 "Geist", "Inter", sans-serif;
  letter-spacing: -0.03em;
}

.ob-page p {
  font-size: calc(var(--ob-w) * 0.052);
  line-height: 1.4;
  color: #4a4944;
}

.ob-p-etat {
  margin-top: auto;
}

/* le dos, les tranches */
.ob-verso {
  border-radius: var(--ob-r);
  background: var(--ob-dos);
  transform: translateZ(calc(var(--ob-d) / -2)) rotateY(180deg);
}

.ob-tranche,
.ob-gouttiere {
  position: absolute;
  left: 50%;
  top: var(--ob-r);
  width: var(--ob-d);
  height: calc(100% - var(--ob-r) * 2);
  margin-left: calc(var(--ob-d) / -2);
}

.ob-tranche {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.3), rgba(255, 255, 255, 0.14) 45%, rgba(0, 0, 0, 0.22)), var(--ob-dos);
  transform: rotateY(-90deg) translateZ(calc(var(--ob-w) / 2));
}

.ob-gouttiere {
  background: repeating-linear-gradient(90deg, #efeee9 0 1px, #cfcdc6 1px 2px);
  transform: rotateY(90deg) translateZ(calc(var(--ob-w) / 2 - 2px));
}

.ob-tete,
.ob-pied {
  position: absolute;
  left: var(--ob-r);
  top: 50%;
  width: calc(100% - var(--ob-r) * 2);
  height: var(--ob-d);
  margin-top: calc(var(--ob-d) / -2);
  background: repeating-linear-gradient(0deg, #efeee9 0 1px, #cfcdc6 1px 2px);
}

.ob-tete {
  transform: rotateX(90deg) translateZ(calc(var(--ob-h) / 2 - 2px));
}

.ob-pied {
  transform: rotateX(-90deg) translateZ(calc(var(--ob-h) / 2 - 2px));
}

/* ——— Les commandes, dans les coins ——— */
.ob-coin {
  position: absolute;
  z-index: 5;
  transition: opacity 0.35s var(--ease);
}

/* en bas, au milieu : la phrase d'aide et le choix Orbite / Grille, dans une même barre.
   Son fond la garde lisible quand un livre passe derrière. */
.ob-barre {
  left: 50%;
  bottom: clamp(18px, 3vh, 34px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 4px 4px 20px;
  border-radius: 999px;
  background: rgba(20, 20, 22, 0.86);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transform: translateX(-50%);
  white-space: nowrap;
}

.ob-aide {
  font-size: var(--t-footnote);
  color: var(--label-2);
  pointer-events: none;
}

.ob-vues {
  display: flex;
}

.ob-vues button {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  font: 500 13px/1 var(--font);
  color: var(--label-2);
  cursor: pointer;
  transition:
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}

.ob-vues button[aria-pressed="true"] {
  background: var(--label);
  color: #000;
}

.ob-bulle {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 8;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f5f5f7;
  font: 500 12.5px/1 var(--font);
  white-space: nowrap;
  color: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s var(--ease);
}

.ob-bulle.ob-la {
  opacity: 1;
}

.ob button:focus-visible {
  outline: 2px solid var(--label);
  outline-offset: 3px;
}

/* ——— Un livre ouvert : sa fiche ——— */
.ob-fiche {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  z-index: 6;
  pointer-events: none;
}

.ob-f-panneau {
  position: absolute;
  left: 57%;
  top: 50%;
  width: min(36%, 440px);
  transform: translateY(-50%);
  cursor: default;
}

.ob-f-panneau > * {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.3s var(--ease),
    transform 0.3s var(--ease);
}

.ob.ob-ouvert .ob-f-panneau,
.ob.ob-ouvert .ob-f-ferme,
.ob.ob-ouvert .ob-f-nav {
  pointer-events: auto;
}

.ob.ob-ouvert .ob-f-panneau > * {
  opacity: 1;
  transform: none;
  transition:
    opacity 0.55s var(--ease),
    transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.ob.ob-ouvert .ob-f-panneau > :nth-child(1) { transition-delay: 0.3s; }
.ob.ob-ouvert .ob-f-panneau > :nth-child(2) { transition-delay: 0.38s; }
.ob.ob-ouvert .ob-f-panneau > :nth-child(3) { transition-delay: 0.46s; }
.ob.ob-ouvert .ob-f-panneau > :nth-child(4) { transition-delay: 0.54s; }

.ob-f-cat {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--t-footnote);
  color: var(--label-2);
}

.ob-f-cat em {
  padding: 0.4em 0.7em;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  font: 500 11px/1 var(--font);
  font-style: normal;
  color: #c9c9ce;
}

.ob-f-t {
  margin-top: 14px;
  font: 500 clamp(30px, 3.6vw, 56px) / 1.04 "Geist", "Inter", sans-serif;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.ob-f-p {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: var(--t-subhead);
  line-height: 1.5;
  color: var(--label-2);
}

.ob-f-a {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.ob-f-a button {
  height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font: 500 15px/1 var(--font);
  cursor: pointer;
  transition:
    background-color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}

.ob-f-a button:active {
  transform: scale(0.97);
}

.ob-f-plein {
  background: var(--label);
  color: #000;
}

.ob-f-plein:hover {
  background: #dcdce0;
}

.ob-f-trait {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26);
  color: var(--label);
}

.ob-f-trait:hover {
  background: rgba(255, 255, 255, 0.08);
}

.ob-f-ferme,
.ob-f-nav button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
}

.ob-f-ferme,
.ob-f-nav {
  position: absolute;
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.ob.ob-ouvert .ob-f-ferme,
.ob.ob-ouvert .ob-f-nav {
  opacity: 1;
}

.ob-f-ferme {
  left: clamp(20px, 3.4vw, 56px);
  top: 84px;
  background: var(--label);
  color: #000;
}

.ob-f-nav {
  left: 50%;
  bottom: clamp(18px, 3vh, 34px);
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}

.ob-f-nav button {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
  color: var(--label);
}

.ob-f-nav button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ob-fiche svg {
  width: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ——— Téléphone ——— */
@media (max-width: 759px) {
  .ob {
    --ob-w: min(25vw, 120px);
    height: clamp(680px, 100svh, 860px);
  }

  .ob-milieu {
    width: calc(100% - 26vw - 12px);
  }

  /* en grille, les livres sont sous le titre : il reprend la largeur */
  .ob.ob-grille .ob-milieu {
    width: calc(100% - 40px);
  }

  .ob .builds-title {
    font-size: 8vw;
  }

  .ob .builds-sub {
    font-size: 13.5px;
  }

  .ob-puce {
    height: 34px;
    padding: 0 11px;
    font-size: 12.5px;
  }

  .ob-aide {
    display: none;
  }

  .ob-barre {
    padding-left: 4px;
  }

  .ob-f-panneau {
    left: 20px;
    right: 20px;
    top: auto;
    bottom: 84px;
    width: auto;
    transform: none;
  }

  .ob-f-t {
    font-size: 28px;
  }

  .ob-f-ferme {
    left: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ob-centre,
  .ob-f-panneau > * {
    transition: none !important;
  }
}
