/* ==========================================================================
   joy.css — piezas de juego compartidas: cursor, dado 3D, notas con cinta,
   rodillo, destellos, reto final. Todo respeta prefers-reduced-motion.
   ========================================================================== */

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- etiqueta que sigue al cursor ---------- */
.cursor-label {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  opacity: 0;
  scale: 0.6;
  transition: opacity 160ms ease, scale 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 16px rgba(10, 70, 255, 0.25);
}
.cursor-label.is-on { opacity: 1; scale: 1; }
@media (hover: none) { .cursor-label { display: none; } }

/* elementos magnéticos: el transform lo lleva GSAP */
[data-magnetic] { will-change: transform; }

/* ---------- dado 3D ---------- */
.dice3d {
  --size: 22px;
  --pip: calc(var(--size) * 0.18);
  display: inline-block;
  width: var(--size);
  height: var(--size);
  perspective: calc(var(--size) * 8);
  flex: none;
}
.dice3d__tilt, .dice3d__cube { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; }
.dice3d__tilt { transform: rotateX(-22deg) rotateY(28deg); }
.dice3d__face {
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: 22%;
  box-shadow: inset 0 0 0 1px rgba(11, 11, 13, 0.12), inset 0 calc(var(--size) * -0.06) 0 rgba(11, 11, 13, 0.08);
  backface-visibility: hidden;
}
.dice3d .pip {
  position: absolute;
  width: var(--pip);
  height: var(--pip);
  margin: calc(var(--pip) / -2) 0 0 calc(var(--pip) / -2);
  border-radius: 50%;
  background: var(--color-deep-cobalt);
}
.pip--c { left: 50%; top: 50%; }
.pip--tl { left: 27%; top: 27%; }
.pip--tr { left: 73%; top: 27%; }
.pip--ml { left: 27%; top: 50%; }
.pip--mr { left: 73%; top: 50%; }
.pip--bl { left: 27%; top: 73%; }
.pip--br { left: 73%; top: 73%; }

/* ---------- escenario de técnicas: dado + una nota + "ver todas" ---------- */
.technique-stage__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: var(--space-lg);
}
.phase-card__shuffle[disabled] { cursor: default; opacity: 1; }

.technique-stage__toggle {
  appearance: none;
  background: none;
  border: none;
  padding: 10px 4px;
  font-weight: var(--fw-medium);
  color: var(--scene-accent, var(--color-accent));
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.technique-stage__toggle:hover { text-decoration-thickness: 2px; }
.technique-stage__toggle .arrow { display: inline-block; margin-left: 4px; transition: transform var(--motion-fast); }
.technique-stage__toggle[aria-expanded="true"] .arrow { transform: rotate(180deg); }

/* la ranura donde cae la técnica elegida */
.technique-slot { max-width: 560px; padding-top: 14px; }
.technique-slot[hidden] { display: none; }

.technique-slot__empty {
  appearance: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: var(--space-lg) var(--space-md);
  border: 2px dashed rgba(10, 70, 255, 0.28);
  border-radius: var(--radius-md);
  background: rgba(125, 183, 255, 0.08);
  color: var(--color-text-muted);
  font-size: 1rem;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.technique-slot__empty:hover { background: rgba(125, 183, 255, 0.16); border-color: rgba(10, 70, 255, 0.5); }
.technique-slot__empty strong { color: var(--color-text); font-size: 1.15rem; }
.technique-slot__empty .dice3d { margin-bottom: 8px; transition: rotate 400ms cubic-bezier(0.34, 1.56, 0.64, 1); }
.technique-slot__empty:hover .dice3d { rotate: 14deg; }

/* el rodillo de la tragaperras */
.technique-reel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 150px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: #fff;
  box-shadow: inset 0 18px 18px -12px rgba(0, 0, 0, 0.35), inset 0 -18px 18px -12px rgba(0, 0, 0, 0.35);
}
.technique-reel__row {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 150px;
  overflow: hidden;
}
.technique-reel--multi .technique-reel__row { height: 96px; }
.technique-reel--multi .technique-reel__row + .technique-reel__row { border-top: 1px solid rgba(255, 255, 255, 0.2); }
.technique-reel__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: var(--fw-bold);
  opacity: 0.65;
  margin-bottom: 4px;
}
.technique-reel__name {
  display: block;
  padding: 0 var(--space-md);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: var(--fw-bold);
  text-align: center;
}
.technique-reel__row.is-stopped .technique-reel__name { color: #fff; }

/* ---------- técnicas como notas pegadas con cinta ---------- */
.technique-list {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 36px 24px;
  padding-top: 14px;
}
.technique-list[hidden] { display: none; }

.technique-card {
  position: relative;
  padding-top: 26px;
  background: var(--color-surface);
  border: 1px solid rgba(11, 11, 13, 0.06);
  box-shadow: 0 2px 6px rgba(11, 11, 13, 0.06), 0 10px 22px rgba(11, 11, 13, 0.05);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 340ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 340ms ease, filter 0s;
  will-change: transform;
}
.technique-card:hover,
.technique-card:focus-within {
  transform: rotate(0deg) translateY(-6px);
  box-shadow: var(--shadow-card-hover);
  z-index: 1;
}

.technique-card--featured { padding: 30px var(--space-lg) var(--space-md); }
.technique-card--featured h4 { font-size: 1.35rem; }

/* etiqueta "tu técnica" en la vista de todas */
.technique-card--picked { border-color: rgba(10, 70, 255, 0.35); }
.technique-card__badge {
  position: absolute;
  top: -11px;
  right: 16px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: var(--fw-medium);
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

/* la cinta: tira recortada y plana, a caballo sobre el borde superior */
.technique-card::before {
  content: '';
  position: absolute;
  top: -12px;
  left: var(--tape-x, 18%);
  width: 58px;
  height: 30px;
  background: url('../assets/tape-1.png') center / 100% 100% no-repeat;
  transform: rotate(var(--tape-rot, -4deg));
  opacity: 0.95;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(11, 11, 13, 0.18));
}
.technique-card--tape-2::before {
  background-image: url('../assets/tape-2.png');
  width: 62px;
  height: 23px;
  top: -9px;
}
.technique-card--featured::before { width: 72px; height: 37px; top: -15px; }
.technique-card--featured.technique-card--tape-2::before { width: 78px; height: 29px; top: -12px; }

/* al caer la carta, la cinta se "estampa" un instante después */
.technique-card.is-slapped::before { animation: tape-slap 420ms cubic-bezier(0.2, 1.4, 0.4, 1) 260ms both; }
@keyframes tape-slap {
  from { opacity: 0; transform: rotate(calc(var(--tape-rot, -4deg) - 14deg)) scale(1.7) translateY(-14px); }
  to { opacity: 0.95; transform: rotate(var(--tape-rot, -4deg)) scale(1); }
}

/* ---------- reto final ---------- */
.reto { max-width: 760px; text-align: center; }
.reto__title { font-size: clamp(2.2rem, 5vw, 3.75rem); }
.reto__title span { color: var(--color-accent); white-space: nowrap; }
.reto__intro { font-size: 1.1rem; max-width: 46ch; margin: 0 auto var(--space-lg); }
.reto__stage .technique-stage__controls { justify-content: center; }
.reto__stage .phase-card__shuffle { font-size: 1.05rem; font-weight: var(--fw-bold); padding: 14px 28px 14px 20px; background: var(--color-accent); color: #fff; border-radius: var(--radius-md); }
.reto__stage .phase-card__shuffle:hover { background: var(--color-accent); box-shadow: var(--shadow-card-hover); }
.reto__slot { margin: 0 auto; text-align: left; }
.reto__slot .technique-slot__empty { text-align: center; }
.reto-note__tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 6px;
}
.reto-note__challenge {
  font-size: 1.2rem;
  font-weight: var(--fw-bold);
  color: var(--color-accent) !important;
  margin: 4px 0 12px;
  display: inline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.reto-note__challenge + .technique-card__desc { margin-top: 12px; }
.reto-note__go {
  display: block;
  margin-top: 12px;
  background: none;
  border: none;
  padding: 0;
  font-weight: var(--fw-bold);
  color: var(--color-accent);
}
.reto-note__go:hover { text-decoration: underline; }
.reto__foot { margin-top: var(--space-lg); }
.reto__credit { margin-top: var(--space-md); font-size: 0.85rem; opacity: 0.6; }

/* ---------- destellos al hacer clic ---------- */
.sparkle-layer { position: fixed; inset: 0; z-index: 250; pointer-events: none; }
.sparkle {
  position: absolute;
  width: 12px;
  height: 2px;
  margin-top: -1px;
  border-radius: 2px;
  background: var(--color-sky-blue);
  transform-origin: 0 50%;
}
.sparkle:nth-child(2n) { background: var(--color-deep-cobalt); }

/* ---------- ¡eureka! ---------- */
.eureka-flash {
  position: fixed;
  inset: 0;
  z-index: 280;
  display: grid;
  place-items: center;
  background: rgba(247, 248, 250, 0.92);
  pointer-events: none;
}
.eureka-flash span { font-size: clamp(2.6rem, 8vw, 5rem); font-weight: var(--fw-bold); color: var(--color-accent); }

/* ---------- carrusel arrastrable ---------- */
.carousel__track { flex: 1 1 0%; min-width: 0; }
.carousel__track.is-drag {
  overflow: hidden;
  scroll-snap-type: none;
  cursor: grab;
}
.carousel__track.is-drag.is-dragging { cursor: grabbing; }
.carousel__track.is-drag.is-dragging .ref-card { pointer-events: none; }
.carousel__strip { display: flex; gap: var(--space-md); width: max-content; will-change: transform; }
.carousel__track.is-drag .ref-card { scroll-snap-align: none; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .technique-card { transform: none; }
  .technique-card:hover, .technique-card:focus-within { transform: none; }
}

/* ---------- retos de clase (escena final) ---------- */
.reto-class { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm); margin-top: var(--space-xl); text-align: left; }
.reto-brief {
  display: flex;
  flex-direction: column;
  padding: 20px 22px 22px;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid rgba(11, 11, 13, 0.06);
}
.reto-brief__title { margin: 0 0 8px; font-size: 1.2rem; font-weight: var(--fw-medium); letter-spacing: -0.02em; line-height: 1.2; }
.reto-brief__text { margin: 0 0 var(--space-sm); font-size: 0.95rem; line-height: 1.45; }
.reto-brief__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.chip-btn {
  appearance: none;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(10, 70, 255, 0.3);
  background: rgba(125, 183, 255, 0.12);
  color: var(--color-accent);
  font-size: 0.88rem;
  font-weight: var(--fw-medium);
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}
.chip-btn:hover { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.chip-btn--ghost { background: none; border-style: dashed; }
@media (max-width: 640px) {
  .reto-class { grid-template-columns: 1fr; margin-top: var(--space-lg); }
}
