/* RQuiz — page d'accueil : carrousel 3D des matières (livres en CSS 3D) */

@property --h-glow {
  syntax: '<color>';
  inherits: true;
  initial-value: #7C3AED;
}

.h-hero:has(.h-books) { transition: --h-glow 0.9s ease; }
.h-hero:has(.h-books)::before {
  background: radial-gradient(circle, rgba(124, 58, 237, 0.16) 0%, transparent 70%);
  background: radial-gradient(circle, color-mix(in srgb, var(--h-glow) 20%, transparent) 0%, color-mix(in srgb, var(--h-glow) 8%, transparent) 40%, transparent 70%);
}

.h-books {
  --bw: 168px;
  --bh: 230px;
  --bt: 38px;
  --gap: 210px;
  position: relative;
}

.h-books__stage {
  position: relative;
  height: 500px;
  border-radius: 28px;
  overflow: hidden;
  background: radial-gradient(ellipse 70% 50% at 50% 62%, rgba(124, 58, 237, 0.42), transparent 70%), radial-gradient(ellipse 120% 80% at 50% 0%, #1C1638, #0A0817 75%);
  background: radial-gradient(ellipse 70% 50% at 50% 62%, color-mix(in srgb, var(--h-glow) 45%, transparent), transparent 70%), radial-gradient(ellipse 120% 80% at 50% 0%, #1C1638, #0A0817 75%);
  box-shadow: 0 30px 80px rgba(13, 10, 30, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  perspective: 1200px;
  perspective-origin: 50% 30%;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.h-books__scene {
  position: absolute;
  inset: 18px 0 auto 0;
  height: 340px;
  transform-style: preserve-3d;
  transform: translateY(calc(var(--p, 0) * 34px)) rotateX(calc(var(--p, 0) * 14deg));
}

/* ---------- Podium ---------- */

.h-books__podium {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 280px;
  height: 280px;
  margin: -140px 0 0 -140px;
  border-radius: 50%;
  transform-style: preserve-3d;
  transform: translateY(calc(var(--bh) / 2 + 30px)) rotateX(90deg);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16) 0%, rgba(124, 58, 237, 0.35) 45%, transparent 70%);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16) 0%, color-mix(in srgb, var(--h-glow) 38%, transparent) 45%, transparent 70%);
  border: 2px solid rgba(233, 213, 255, 0.55);
  border-color: color-mix(in srgb, var(--h-glow) 55%, #FFFFFF);
  box-shadow: 0 0 50px rgba(124, 58, 237, 0.55);
  box-shadow: 0 0 50px color-mix(in srgb, var(--h-glow) 60%, transparent), inset 0 0 40px color-mix(in srgb, var(--h-glow) 40%, transparent);
}
.h-books__podium::before {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  transform: translateZ(-18px);
  background: radial-gradient(circle, rgba(10, 8, 23, 0.9), rgba(10, 8, 23, 0.4) 70%);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ---------- Book (carousel position) ---------- */

.h-book {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--bw);
  height: var(--bh);
  margin: calc(var(--bh) / -2) 0 0 calc(var(--bw) / -2);
  transform-style: preserve-3d;
  transform: translateX(calc(var(--d) * var(--gap))) translateZ(calc(var(--ad) * -170px)) rotateY(calc(var(--d) * -32deg));
  transition: transform 0.85s cubic-bezier(0.22, 0.8, 0.24, 1);
  cursor: pointer;
}
.h-books.is-open .h-book:not(.is-active) {
  transform: translateX(calc(var(--d) * (var(--gap) + 70px))) translateZ(calc(var(--ad) * -210px)) rotateY(calc(var(--d) * -32deg));
}
.h-book.is-far { visibility: hidden; }

.h-book__float,
.h-book__body,
.h-book__cover {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.h-book.is-active .h-book__float { animation: h-book-float 6s ease-in-out infinite; }

.h-book__body {
  transform: rotateY(0deg);
  transition: transform 1s cubic-bezier(0.5, 0.05, 0.25, 1);
}
.h-book.is-active .h-book__body { transform: rotateY(24deg); }
.h-book.is-active.is-open .h-book__body { transform: translateX(calc(var(--bw) * 0.36)) rotateY(8deg) rotateX(6deg); }

@keyframes h-book-float {
  0%, 100% { transform: translateY(-8px) rotateY(-6deg); }
  50% { transform: translateY(8px) rotateY(6deg); }
}

/* ---------- Book faces ---------- */

.h-book__face {
  position: absolute;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  filter: brightness(calc(1 - var(--ad) * 0.3));
  transition: filter 0.85s ease;
}

.h-book__cover { transform-origin: left center; transform: translateZ(calc(var(--bt) / 2)); transition: transform 1.05s cubic-bezier(0.55, 0.05, 0.25, 1); }
.h-book.is-open .h-book__cover { transform: translateZ(calc(var(--bt) / 2)) rotateY(-158deg); }

.h-book__cover-front {
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px 16px 16px 22px;
  overflow: hidden;
  border-radius: 3px 10px 10px 3px;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: inset 7px 0 0 rgba(0, 0, 0, 0.16), inset 9px 0 0 rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}
.h-book__cover-front::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.1) 100%);
  pointer-events: none;
}
.h-book__brand { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0.85; }
.h-book__icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-top: auto;
  border-radius: 16px;
  font-size: 1.9rem;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}
.h-book__title { margin-top: 12px; font-size: 1.12rem; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); }
.h-book__level { margin-top: 4px; font-size: 0.7rem; font-weight: 700; opacity: 0.85; }
.h-book__watermark { position: absolute; right: -18px; top: 26px; font-size: 7.5rem; opacity: 0.12; transform: rotate(-12deg); }

.h-book__cover-inside {
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 14px;
  transform: rotateY(180deg);
  border-radius: 10px 3px 3px 10px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.22), transparent 60%), linear-gradient(150deg, var(--c2), var(--c1));
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, 0.08), inset -7px 0 0 rgba(0, 0, 0, 0.14);
  color: #FFFFFF;
  text-align: center;
}
.h-book__cover-inside .h-book__brand { position: absolute; top: 16px; }
.h-book__inside-icon { font-size: 2.6rem; opacity: 0.9; }
.h-book__inside-text { font-size: 0.92rem; font-weight: 800; line-height: 1.2; }
.h-book__levels { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 120px; }
.h-book__levels span { padding: 1px 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); font-size: 0.56rem; font-weight: 800; }
.h-book__levels span:last-child { background: #FFFFFF; color: var(--c2); }

.h-book__face--back {
  inset: 0;
  border-radius: 10px 3px 3px 10px;
  transform: rotateY(180deg) translateZ(calc(var(--bt) / 2));
  background: linear-gradient(150deg, var(--c2), var(--c1));
}
.h-book__face--spine {
  top: 0;
  left: calc((var(--bw) - var(--bt)) / 2);
  width: var(--bt);
  height: 100%;
  display: grid;
  place-items: center;
  transform: rotateY(-90deg) translateZ(calc(var(--bw) / 2));
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.25), rgba(255, 255, 255, 0.12) 45%, rgba(0, 0, 0, 0.2)), var(--c2);
}
.h-book__face--spine span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: #FFFFFF;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.h-book__face--pages {
  top: 4px;
  left: calc((var(--bw) - var(--bt)) / 2 + 2px);
  width: calc(var(--bt) - 4px);
  height: calc(100% - 8px);
  transform: rotateY(90deg) translateZ(calc(var(--bw) / 2 - 4px));
  background: repeating-linear-gradient(90deg, #F6F1E6 0 2px, #DDD5C4 2px 3px);
}
.h-book__face--top,
.h-book__face--bottom {
  left: 2px;
  top: calc((var(--bh) - var(--bt)) / 2 + 2px);
  width: calc(var(--bw) - 6px);
  height: calc(var(--bt) - 4px);
  background: repeating-linear-gradient(0deg, #F6F1E6 0 2px, #DDD5C4 2px 3px);
}
.h-book__face--top { transform: rotateX(90deg) translateZ(calc(var(--bh) / 2 - 4px)); }
.h-book__face--bottom { transform: rotateX(-90deg) translateZ(calc(var(--bh) / 2 - 4px)); }

.h-book__page {
  top: 4px;
  left: 2px;
  width: calc(var(--bw) - 6px);
  height: calc(100% - 8px);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px 16px;
  border-radius: 2px 8px 8px 2px;
  transform: translateZ(calc(var(--bt) / 2 - 2px));
  background: linear-gradient(90deg, #E9E2D3 0, #FBF8F1 10%), #FBF8F1;
  color: #2A2540;
}
.h-book__page-title { font-size: 0.86rem; font-weight: 800; line-height: 1.2; color: var(--c2); }
.h-book__page ul { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.h-book__page li { display: flex; gap: 6px; font-size: 0.7rem; font-weight: 600; line-height: 1.3; }
.h-book__page li i { color: var(--c1); font-size: 0.85rem; flex-shrink: 0; }
.h-book__page-foot { margin-top: auto; padding-top: 8px; border-top: 1px dashed #D6CDB9; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em; color: #7A7290; }

/* ---------- Caption & controls ---------- */

.h-books__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 74px;
  padding: 0 1.5rem;
  text-align: center;
  color: #FFFFFF;
}
.h-books__name { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; transition: opacity 0.3s ease, transform 0.3s ease; }
.h-books__name.is-changing { opacity: 0; transform: translateY(6px); }
.h-books__meta { margin-top: 0.2rem; font-size: 0.9rem; color: #C9C3E6; }

.h-books__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}
.h-books__arrow {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.h-books__arrow:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.4); }
.h-books__dots { display: flex; gap: 0.45rem; }
.h-books__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: width 0.3s ease, background 0.3s ease;
}
.h-books__dot.is-active { width: 24px; background: #FFFFFF; }
.h-books :focus-visible { outline: 2px solid #FFFFFF; outline-offset: 3px; }
html:not(.js) .h-books__controls { display: none; }

/* ---------- Matières: scroll story ---------- */

.h-story { position: relative; transition: --h-glow 0.9s ease; }
.h-story::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 55% 45% at 25% 55%, color-mix(in srgb, var(--h-glow) 14%, transparent), transparent 70%);
}
.h-story > .h-container { position: relative; }

.h-story__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3.5rem; align-items: start; }
.h-story__aside { position: sticky; top: max(88px, calc(50vh - 184px)); }
.h-story__stage { --bw: 180px; --bh: 246px; --bt: 40px; height: 440px; }
.h-story__stage .h-books__scene { inset: 24px 0 auto 0; height: 330px; }

.h-story__book {
  transform: translateX(-70px) rotateY(-110deg);
  visibility: hidden;
  transition: transform 0.75s cubic-bezier(0.22, 0.8, 0.24, 1), visibility 0s linear 0.75s;
}
.h-story__book.is-past { transform: translateX(70px) rotateY(110deg); }
.h-story__book.is-active { transform: none; visibility: visible; transition: transform 0.75s cubic-bezier(0.22, 0.8, 0.24, 1), visibility 0s; }
html:not(.js) .h-story__book:first-child { visibility: visible; transform: none; }
.h-story .h-story__book .h-book__body {
  transform: translateX(calc(var(--o, 0) * var(--bw) * 0.36)) rotateY(calc(var(--ry, 24) * 1deg));
  transition: transform 0.15s linear;
}
.h-story .h-story__book .h-book__cover {
  transform: translateZ(calc(var(--bt) / 2)) rotateY(calc(var(--o, 0) * -158deg));
  transition: transform 0.15s linear;
}

.h-story__counter {
  position: absolute;
  left: 1.5rem;
  right: 1.5rem;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #FFFFFF;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.h-story__total { color: #A9A4C6; font-weight: 700; }
.h-story__bar { flex: 1; height: 4px; margin-left: 0.4rem; border-radius: 999px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.h-story__bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--h-glow); transition: width 0.15s linear; }

.h-story__panel {
  min-height: 72vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 1rem;
  padding: 2rem 0;
}
.js .h-story__panel { opacity: 0.3; transition: opacity 0.45s ease; }
.js .h-story__panel.is-active { opacity: 1; }
.h-story__head { display: flex; align-items: center; gap: 1rem; }
.h-story__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  font-size: 1.7rem;
  color: #FFFFFF;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  box-shadow: 0 12px 28px color-mix(in srgb, var(--c1) 35%, transparent);
}
.h-story__num { font-size: 0.9rem; font-weight: 800; letter-spacing: 0.12em; color: var(--h-muted); }
.h-story__title { font-size: clamp(1.9rem, 3vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.h-story__text { max-width: 470px; color: var(--h-muted); font-size: 1.08rem; }
.h-story__topics { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.h-story__topics li {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--c1) 35%, transparent);
  background: color-mix(in srgb, var(--c1) 9%, transparent);
}
.h-story__topics li::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c1); }
.h-story__meta { display: flex; align-items: center; gap: 0.45rem; font-size: 0.92rem; font-weight: 600; color: var(--h-muted); }
.h-story__meta i { color: var(--h-success); font-size: 1.1rem; }
.h-story__cta { margin-top: 0.4rem; }

/* ---------- RQuiz band: medal and tilt ---------- */

.h-medal { width: 72px; height: 72px; perspective: 600px; }
.h-medal__coin { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: h-medal-spin 7s linear infinite; }
.h-medal__edge,
.h-medal__face { position: absolute; inset: 0; border-radius: 50%; }
.h-medal__edge { transform: translateZ(calc(var(--z) * 1px)); background: linear-gradient(135deg, #B7791F, #F6C453 45%, #92400E); }
.h-medal__face { display: grid; place-items: center; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.h-medal__face--front { transform: translateZ(4px); padding: 5px; background: linear-gradient(135deg, #FDE68A, #F59E0B 50%, #B45309); }
.h-medal__face--front img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.h-medal__face--back { transform: rotateY(180deg) translateZ(4px); background: radial-gradient(circle at 35% 30%, #FEF3C7, #F59E0B 55%, #B45309); color: #78350F; font-size: 2rem; }
@keyframes h-medal-spin {
  0% { transform: translateY(0) rotateY(0deg); }
  50% { transform: translateY(-5px) rotateY(180deg); }
  100% { transform: translateY(0) rotateY(360deg); }
}

.h-band__card.is-tilting { transition: transform 0.12s ease-out; }
.h-band__card { position: relative; }
.h-band__card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.12), transparent 45%);
}
.h-band__card.is-tilting::after { opacity: 1; }

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .h-books { max-width: 560px; }
}

@media (max-width: 900px) {
  .h-story__grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .h-story__aside { top: 72px; z-index: 2; margin: 0 -1.5rem; padding: 0.5rem 1.5rem 1rem; background: var(--h-surface); }
  .h-story__stage.h-books__stage { --bw: 112px; --bh: 154px; --bt: 26px; height: 250px; border-radius: 20px; }
  .h-story__stage .h-books__scene { inset: 6px 0 auto 0; height: 190px; }
  .h-story__stage .h-books__podium { width: 170px; height: 170px; margin: -85px 0 0 -85px; transform: translateY(calc(var(--bh) / 2 + 14px)) rotateX(90deg); }
  .h-story__stage .h-book__cover-front { padding: 9px 9px 9px 14px; }
  .h-story__stage .h-book__icon { width: 36px; height: 36px; border-radius: 10px; font-size: 1.15rem; }
  .h-story__stage .h-book__title { margin-top: 8px; font-size: 0.74rem; }
  .h-story__stage .h-book__level, .h-story__stage .h-book__brand { font-size: 0.5rem; }
  .h-story__stage .h-book__watermark { font-size: 4.5rem; }
  .h-story__stage .h-book__page { padding: 9px 7px 7px 9px; }
  .h-story__stage .h-book__page-title { font-size: 0.6rem; }
  .h-story__stage .h-book__page ul { margin-top: 5px; gap: 3px; }
  .h-story__stage .h-book__page li { font-size: 0.48rem; gap: 3px; }
  .h-story__stage .h-book__page li i { font-size: 0.6rem; }
  .h-story__stage .h-book__page-foot { font-size: 0.42rem; }
  .h-story__stage .h-book__inside-icon { font-size: 1.6rem; }
  .h-story__stage .h-book__inside-text { font-size: 0.6rem; }
  .h-story__stage .h-book__levels { gap: 2px; max-width: 84px; }
  .h-story__stage .h-book__levels span { font-size: 0.4rem; padding: 0 4px; }
  .h-story__counter { bottom: 14px; font-size: 0.85rem; }
  .h-story__panel { min-height: 62vh; padding: 1.5rem 0; }
}

@media (max-width: 720px) {
  .h-books { --bw: 136px; --bh: 186px; --bt: 30px; --gap: 158px; }
  .h-books__stage { height: 430px; border-radius: 22px; }
  .h-books__scene { height: 290px; }
  .h-books__podium { width: 220px; height: 220px; margin: -110px 0 0 -110px; }
  .h-book__cover-front { padding: 12px 12px 12px 18px; }
  .h-book__icon { width: 46px; height: 46px; border-radius: 13px; font-size: 1.5rem; }
  .h-book__title { font-size: 0.92rem; }
  .h-book__watermark { font-size: 6rem; }
  .h-book__page { padding: 13px 10px 10px 12px; }
  .h-book__page-title { font-size: 0.74rem; }
  .h-book__page ul { margin-top: 8px; gap: 6px; }
  .h-book__page li { font-size: 0.6rem; }
  .h-book__page-foot { font-size: 0.52rem; }
  .h-books__caption { bottom: 68px; }
  .h-books__name { font-size: 1.35rem; }
  .h-books__meta { font-size: 0.82rem; }
}

@media (prefers-reduced-motion: reduce) {
  .h-book.is-active .h-book__float { animation: none; }
  .h-hero:has(.h-books),
  .h-book,
  .h-book__body,
  .h-book__cover,
  .h-book__face,
  .h-books__name { transition-duration: 0.01s; }
  .h-books__scene { transform: none; }
  .h-story,
  .h-story__book,
  .h-story .h-story__book .h-book__body,
  .h-story .h-story__book .h-book__cover,
  .h-story__bar span,
  .js .h-story__panel { transition-duration: 0.01s; }
  .h-medal__coin { animation: none; }
}
