/* ═══════════════════════════════════════════════════
   Aléatoire — fortune cinéma InterFilm
   ═══════════════════════════════════════════════════ */

#wheelBg.rw,
.rw {
  --rw-amber: #e4b35a;
  --rw-amber-dim: rgba(228, 179, 90, 0.55);
  --rw-ink: #06060b;
  position: fixed;
  inset: 0;
  z-index: 99996;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) 0 max(1.5rem, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
  background:
    radial-gradient(80% 50% at 50% -10%, rgba(228, 179, 90, 0.14), transparent 55%),
    radial-gradient(50% 40% at 100% 80%, rgba(120, 40, 20, 0.16), transparent 50%),
    rgba(4, 4, 10, 0.96);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.4s var(--ease, ease), visibility 0.4s;
  isolation: isolate;
}

#wheelBg.rw.open,
.rw.open {
  opacity: 1;
  pointer-events: all;
  visibility: visible;
}

#wheelBg.rw[hidden],
.rw[hidden] {
  display: none !important;
}

.rw-ambient {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--rw-ambient-img, none);
  background-size: cover;
  background-position: center 20%;
  opacity: 0;
  filter: saturate(0.8) brightness(0.35);
  transition: opacity 0.8s ease;
  mask-image: linear-gradient(180deg, transparent 0%, #000 20%, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 20%, #000 70%, transparent 100%);
}
.rw-ambient.is-on {
  opacity: 0.5;
  animation: rw-drift 26s ease-in-out infinite alternate;
}

.rw-grain {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.rw-close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 20;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.35s var(--ease, ease);
}
.rw-close:hover {
  color: var(--rw-amber);
  border-color: rgba(228, 179, 90, 0.45);
  background: rgba(228, 179, 90, 0.1);
  transform: rotate(90deg);
}
.rw-close svg {
  width: 18px;
  height: 18px;
}

.rw-shell {
  position: relative;
  z-index: 2;
  width: min(920px, calc(100% - 2.5rem));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.25rem, 3vw, 2rem);
  margin: 0 auto;
  padding-inline: 0;
  animation: rw-rise 0.7s var(--ease, ease) both;
}

/* ── Masthead ── */
.rw-mast {
  text-align: center;
  max-width: 28rem;
}
.rw-brand {
  margin: 0 0 0.3rem;
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  letter-spacing: 0.14em;
  line-height: 1;
  color: #fff;
  text-transform: uppercase;
}
.rw-display {
  margin: 0 0 0.5rem;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.03em;
  line-height: 0.92;
  color: var(--rw-amber);
}
.rw-lede {
  margin: 0;
  font-family: 'Outfit', var(--font), sans-serif;
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(240, 240, 248, 0.55);
}

/* ── Wheel stage ── */
.rw-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 1rem;
  padding: 0.5rem 0 0.25rem;
}
.rw-wheel-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(380px, 78vw);
  max-width: 380px;
  aspect-ratio: 1;
  margin-inline: auto;
  flex: 0 0 auto;
}
.rw-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 136%;
  height: 136%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(228, 179, 90, 0.12);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  animation: rw-orbit 18s linear infinite;
}
.rw-orbit::before,
.rw-orbit::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.rw-orbit::before {
  inset: 14%;
}
.rw-orbit::after {
  inset: -10%;
  border-color: rgba(228, 179, 90, 0.06);
}

.rw-wheel {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 50%;
  padding: 10px;
  box-sizing: border-box;
  background:
    radial-gradient(circle at 50% 40%, rgba(228, 179, 90, 0.08), transparent 55%),
    #08080f;
  box-shadow:
    0 0 0 1px rgba(228, 179, 90, 0.28),
    0 28px 64px rgba(0, 0, 0, 0.65);
}
.rw-wheel.is-spinning {
  box-shadow:
    0 0 0 1px rgba(228, 179, 90, 0.45),
    0 28px 64px rgba(0, 0, 0, 0.65);
}

#wheelCanvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.rw-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: 28px;
  height: 36px;
  color: var(--rw-amber);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.65));
  transition: transform 0.08s ease;
}
.rw-pointer.tick {
  transform: translateX(-50%) rotate(-10deg);
}
.rw-pointer svg {
  width: 100%;
  height: 100%;
  display: block;
}

.rw-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: clamp(78px, 20vw, 100px);
  height: clamp(78px, 20vw, 100px);
  border-radius: 50%;
  border: 2px solid rgba(228, 179, 90, 0.55);
  background: radial-gradient(circle at 35% 28%, #1c1c26 0%, #08080f 72%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 7px rgba(6, 6, 11, 0.88);
  transition: transform 0.25s var(--ease, ease), border-color 0.2s, background 0.2s;
}
.rw-hub:hover:not(:disabled) {
  transform: translate(-50%, -50%) scale(1.05);
  border-color: var(--rw-amber);
  background: radial-gradient(circle at 35% 28%, #262632 0%, #0a0a12 72%);
}
.rw-hub:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.96);
}
.rw-hub:disabled {
  opacity: 0.7;
  cursor: wait;
}
.rw-hub-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--rw-amber);
}

.rw-hint {
  margin: 0;
  font-family: 'Outfit', var(--font), sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(240, 240, 248, 0.35);
  transition: opacity 0.3s;
}
.rw-stage.is-done .rw-hint {
  opacity: 0;
}

/* ── Result reveal ── */
.rw-result {
  width: min(860px, 100%);
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.55s var(--ease, ease), transform 0.55s var(--ease, ease);
}
.rw-result[hidden] {
  display: none !important;
}
.rw-result.is-on {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.rw-reveal {
  position: relative;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  min-height: clamp(260px, 38vw, 340px);
  overflow: hidden;
  background: #050508;
  cursor: default;
}
.rw-reveal-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.rw-reveal-bg {
  width: 100%;
  height: 115%;
  object-fit: cover;
  object-position: center 22%;
  transform: translateY(-4%);
  filter: brightness(0.7) saturate(1.05);
  animation: rw-ken 12s ease-out both;
}
.rw-reveal-bg[hidden] {
  display: none !important;
}
.rw-reveal-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(105deg, rgba(6, 6, 11, 0.97) 0%, rgba(6, 6, 11, 0.75) 40%, rgba(6, 6, 11, 0.25) 70%, transparent 100%),
    linear-gradient(180deg, transparent 40%, rgba(6, 6, 11, 0.88) 100%);
  pointer-events: none;
}
.rw-reveal-copy {
  position: relative;
  z-index: 2;
  grid-column: 1;
  grid-row: 1;
  align-self: end;
  padding: clamp(1.25rem, 3.5vw, 2.25rem);
  max-width: 34rem;
}
.rw-reveal-genre {
  display: block;
  margin: 0 0 0.25rem;
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3rem, 8vw, 5rem);
  line-height: 0.8;
  letter-spacing: 0.04em;
  color: transparent;
  -webkit-text-stroke: 1.4px var(--rw-amber-dim);
  user-select: none;
}
.rw-reveal-tag {
  margin: 0 0 0.65rem;
  font-family: 'Outfit', var(--font), sans-serif;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}
.rw-reveal-tag em {
  font-style: normal;
  color: var(--rw-amber);
}
.rw-reveal-title {
  margin: 0 0 1.15rem;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: clamp(1.55rem, 3.2vw, 2.35rem);
  font-weight: 400;
  line-height: 1.08;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.65);
}
.rw-reveal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.rw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.15rem;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}
.rw-btn--primary {
  background: var(--rw-amber);
  color: #0a0a12;
  border-color: var(--rw-amber);
}
.rw-btn--primary:hover {
  background: #f0c56e;
  transform: translateY(-1px);
}
.rw-btn--ghost {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}
.rw-btn--ghost:hover {
  border-color: rgba(228, 179, 90, 0.5);
  color: var(--rw-amber);
}
.rw-reveal-poster {
  position: relative;
  z-index: 2;
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  justify-self: end;
  padding: clamp(1rem, 3vw, 1.75rem);
}
.rw-reveal-poster img {
  width: min(160px, 30vw);
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7);
  animation: rw-poster-in 0.7s 0.12s var(--ease, ease) both;
}

@keyframes rw-rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes rw-drift {
  from { transform: scale(1.05) translate3d(0, 0, 0); }
  to { transform: scale(1.1) translate3d(-1.2%, 1%, 0); }
}
@keyframes rw-orbit {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
@keyframes rw-ken {
  from { transform: translateY(-4%) scale(1.08); }
  to { transform: translateY(-4%) scale(1); }
}
@keyframes rw-poster-in {
  from { opacity: 0; transform: translateY(14px) rotate(2deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

@media (max-width: 720px) {
  .rw {
    place-items: start center;
    padding-top: calc(var(--mobile-nav-h, 56px) + 0.75rem);
  }
  .rw-reveal {
    grid-template-columns: 1fr;
    min-height: clamp(280px, 70vw, 380px);
  }
  .rw-reveal-copy {
    max-width: 100%;
    padding-right: 7.5rem;
  }
  .rw-reveal-poster {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0;
  }
  .rw-reveal-poster img {
    width: clamp(72px, 20vw, 100px);
  }
  .rw-reveal-genre {
    font-size: clamp(2.4rem, 14vw, 3.6rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rw-shell,
  .rw-ambient.is-on,
  .rw-orbit,
  .rw-reveal-bg,
  .rw-reveal-poster img {
    animation: none !important;
  }
}
