/* ============================================================
   ONEHSERVICE — DIMENSION 3D
   Cube 3D interactif : 6 faces × services, mouse-follow,
   auto-rotate, scroll boost, ambient lighting cinématique.
   ============================================================ */

.d3 {
  position: relative;
  background: radial-gradient(ellipse at 50% 30%, #15151B 0%, #06060A 70%);
  color: var(--paper, #F4F0E6);
  padding: clamp(120px, 14vw, 200px) var(--pad-x) clamp(120px, 14vw, 200px);
  overflow: hidden;
  isolation: isolate;
}

/* ===== Background layers ===== */
.d3__bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* Grid floor */
.d3__grid {
  position: absolute;
  left: 50%;
  bottom: -10%;
  width: 200%;
  height: 60%;
  transform: translateX(-50%) perspective(700px) rotateX(60deg);
  background-image:
    linear-gradient(to right, rgba(250,204,21,0.18) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(250,204,21,0.18) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 0%, transparent 65%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 0%, transparent 65%);
  animation: d3-grid 18s linear infinite;
}
@keyframes d3-grid {
  to { background-position: 0 60px; }
}

/* Ambient lights */
.d3__light {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}
.d3__light--1 {
  top: 10%; left: 10%;
  width: 400px; height: 400px;
  background: rgba(250, 204, 21, 0.12);
  animation: d3-light-1 8s ease-in-out infinite;
}
.d3__light--2 {
  bottom: 0; right: 5%;
  width: 500px; height: 500px;
  background: rgba(229, 52, 26, 0.08);
  animation: d3-light-2 11s ease-in-out infinite;
}
@keyframes d3-light-1 {
  0%,100% { transform: translate(0,0) scale(1); opacity: 0.7; }
  50%     { transform: translate(40px,30px) scale(1.2); opacity: 1; }
}
@keyframes d3-light-2 {
  0%,100% { transform: translate(0,0) scale(1); opacity: 0.6; }
  50%     { transform: translate(-50px,-40px) scale(1.1); opacity: 1; }
}

/* Stars / dots */
.d3__stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 80% 60%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 45% 75%, rgba(255,255,255,0.6), transparent),
    radial-gradient(2px 2px at 65% 20%, rgba(250,204,21,0.7), transparent),
    radial-gradient(1px 1px at 15% 85%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 90% 40%, rgba(250,204,21,0.5), transparent);
  opacity: 0.6;
}

/* ===== Inner layout ===== */
.d3__inner {
  position: relative;
  z-index: 2;
  max-width: var(--max, 1480px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: clamp(40px, 6vw, 100px);
  align-items: center;
}

/* ===== Head / left side ===== */
.d3__head { display: flex; flex-direction: column; gap: 24px; }
.d3__pre {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--yellow, #FACC15);
}
.d3__pre::before {
  content: '';
  width: 24px; height: 1px;
  background: var(--yellow, #FACC15);
}
.d3__title {
  font-family: var(--font-display, 'Sora', sans-serif);
  font-weight: 800;
  font-size: clamp(40px, 6vw, 88px);
  line-height: 0.96;
  letter-spacing: -0.04em;
  color: var(--paper, #F4F0E6);
}
.d3__title em {
  font-style: italic;
  font-weight: 300;
  color: transparent;
  -webkit-text-stroke: 1.4px var(--yellow, #FACC15);
}
.d3__lead {
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.6;
  color: rgba(244, 240, 230, 0.7);
  max-width: 460px;
}
.d3__hint {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 12px;
  padding: 10px 16px;
  border: 1px solid rgba(250,204,21,0.3);
  border-radius: 999px;
  background: rgba(250,204,21,0.06);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--yellow, #FACC15);
  width: fit-content;
}
.d3__hint-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--yellow, #FACC15);
  box-shadow: 0 0 0 3px rgba(250,204,21,0.25);
  animation: d3-pulse 1.6s infinite;
}
@keyframes d3-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(250,204,21,0.25); }
  50%     { box-shadow: 0 0 0 7px rgba(250,204,21,0); }
}

/* ===== Stage / right side ===== */
.d3__stage {
  position: relative;
  height: clamp(420px, 50vw, 600px);
  perspective: 1400px;
  perspective-origin: 50% 50%;
  display: flex; align-items: center; justify-content: center;
}

.d3__cube {
  position: relative;
  width: clamp(220px, 22vw, 300px);
  height: clamp(220px, 22vw, 300px);
  transform-style: preserve-3d;
  transform: rotateX(-15deg) rotateY(0deg);
  will-change: transform;
}

.d3__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px 20px;
  background: linear-gradient(135deg, rgba(20,20,28,0.92) 0%, rgba(10,10,16,0.96) 100%);
  border: 1px solid rgba(250,204,21,0.28);
  box-shadow:
    inset 0 0 60px rgba(250,204,21,0.08),
    0 0 40px rgba(250,204,21,0.15);
  backface-visibility: visible;
  border-radius: 4px;
}
.d3__face::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(250,204,21,0.8), transparent);
}
.d3__face-num {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(250,204,21,0.7);
}
.d3__face-icon {
  font-size: 56px;
  line-height: 1;
  filter: drop-shadow(0 0 14px rgba(250,204,21,0.4));
}
.d3__face-title {
  font-family: var(--font-display, 'Sora', sans-serif);
  font-weight: 800;
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: -0.02em;
  color: var(--paper, #F4F0E6);
}
.d3__face-meta {
  font-family: var(--font-mono, monospace);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244,240,230,0.55);
}

/* Calculée dynamiquement par JS pour matcher la taille du cube,
   fallback statique pour le SSR. */
.d3__face--front  { transform: translateZ(150px); }
.d3__face--back   { transform: translateZ(-150px) rotateY(180deg); }
.d3__face--right  { transform: rotateY(90deg)  translateZ(150px); }
.d3__face--left   { transform: rotateY(-90deg) translateZ(150px); }
.d3__face--top    { transform: rotateX(90deg)  translateZ(150px); }
.d3__face--bottom { transform: rotateX(-90deg) translateZ(150px); }

/* Shadow under cube */
.d3__shadow {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(180px, 18vw, 240px);
  height: 20px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.6) 0%, transparent 70%);
  filter: blur(10px);
  animation: d3-shadow 4s ease-in-out infinite;
}
@keyframes d3-shadow {
  0%,100% { transform: translateX(-50%) scale(1); opacity: 0.6; }
  50%     { transform: translateX(-50%) scale(0.85); opacity: 0.4; }
}

/* ===== Responsive ===== */
@media (max-width: 980px) {
  .d3__inner {
    grid-template-columns: 1fr;
    gap: 60px;
  }
  .d3__head { text-align: center; align-items: center; }
  .d3__lead { margin: 0 auto; }
  .d3__stage { height: clamp(380px, 60vw, 480px); }
  .d3__cube {
    width: clamp(180px, 40vw, 240px);
    height: clamp(180px, 40vw, 240px);
  }
  /* Adjuster les translations 3D pour les petits cubes */
  .d3__face--front  { transform: translateZ(110px); }
  .d3__face--back   { transform: translateZ(-110px) rotateY(180deg); }
  .d3__face--right  { transform: rotateY(90deg)  translateZ(110px); }
  .d3__face--left   { transform: rotateY(-90deg) translateZ(110px); }
  .d3__face--top    { transform: rotateX(90deg)  translateZ(110px); }
  .d3__face--bottom { transform: rotateX(-90deg) translateZ(110px); }
  .d3__face-icon { font-size: 44px; }
}
@media (max-width: 480px) {
  .d3 { padding-top: 80px; padding-bottom: 80px; }
  .d3__cube {
    width: 180px; height: 180px;
  }
  .d3__face--front  { transform: translateZ(90px); }
  .d3__face--back   { transform: translateZ(-90px) rotateY(180deg); }
  .d3__face--right  { transform: rotateY(90deg)  translateZ(90px); }
  .d3__face--left   { transform: rotateY(-90deg) translateZ(90px); }
  .d3__face--top    { transform: rotateX(90deg)  translateZ(90px); }
  .d3__face--bottom { transform: rotateX(-90deg) translateZ(90px); }
  .d3__face { padding: 14px 12px; }
  .d3__face-icon { font-size: 32px; }
  .d3__face-title { font-size: 16px; }
  .d3__light--1 { width: 240px; height: 240px; }
  .d3__light--2 { width: 280px; height: 280px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .d3__cube { animation: none !important; transform: rotateY(-30deg) rotateX(-15deg); }
  .d3__grid { animation: none !important; }
  .d3__light--1, .d3__light--2 { animation: none !important; }
  .d3__shadow { animation: none !important; }
}
