/* Arcade on the profile (js/arcade.js): holographic game cards (fx/holo-card.js), the sockets the
   gems go in, the forge ceremony and the full-screen game. */

/* ---------- HoloCard (React Bits) ---------- */
.holo-card {
  --hc-w: 320px;
  --hc-ratio: 0.716;
  --hc-radius: 14px;
  position: relative;
  display: inline-block;
  width: var(--hc-w);
  max-width: 100%;
  aspect-ratio: var(--hc-ratio);
  border-radius: var(--hc-radius);
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}
.holo-card__shadow {
  position: absolute;
  inset: 10% 7% -4%;
  border-radius: var(--hc-radius);
  background: rgba(0, 0, 0, 0.42);
  filter: blur(26px);
  pointer-events: none;
  will-change: transform;
}
.holo-card__rotor {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}
.holo-card__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--hc-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.holo-card__face--back {
  transform: rotateY(180deg);
}
.holo-card__face img,
.holo-card__face canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.holo-card__face img {
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
.holo-card__face canvas {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.holo-card[data-ready] .holo-card__face canvas {
  opacity: 1;
}

/* ---------- the section ---------- */
.arcade {
  margin-top: clamp(28px, 3vw, 56px);
  scroll-margin-top: calc(var(--g) * 2 + clamp(42px, 3vw, 52px));
}
.arcade-pouch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
}
.arcade-pouch-label {
  margin-right: 6px;
  color: var(--muted);
  font-size: var(--fs-mono);
  text-transform: uppercase;
}
.arcade-pouch-empty {
  color: var(--muted);
  font-size: var(--fs-mono);
  text-transform: uppercase;
}
.arcade-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px 0 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 500 13px/1 var(--display);
  cursor: grab;
  touch-action: none;
  transition:
    border-color 0.2s,
    transform 0.2s var(--ease);
}
.arcade-chip canvas {
  width: 34px;
  height: 34px;
}
.arcade-chip:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}
.arcade-chip.is-wanted {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(16, 16, 16, 0.08);
}
.arcade-chip.is-wanted::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  animation: arcade-blink 1.6s ease-in-out infinite;
}
.codex-gem[data-drag-gem] {
  cursor: grab;
}
body.is-gem-dragging,
body.is-gem-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

.arcade-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(18px, 2vw, 32px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.arcade-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 14px 16px;
  border: 1px solid transparent;
  border-radius: 20px;
  transition:
    opacity 0.3s,
    border-color 0.3s,
    background 0.3s,
    transform 0.4s var(--ease);
}
.arcade-holo {
  width: 100%;
  max-width: 280px;
}
.arcade-holo .holo-card {
  --hc-w: 100%;
  display: block;
}
/* While a gem is dragged: the cards it fits light up, the others step back. */
.arcade-card.is-target {
  border-color: var(--ink);
  border-style: dashed;
  background: var(--bg-2);
}
.arcade-card.is-dim {
  opacity: 0.35;
}
.arcade-card.is-over.is-target {
  border-style: solid;
  transform: scale(1.02);
}
.arcade-card.is-shake {
  animation: arcade-shake 0.42s;
}
.arcade-card.is-socketed .holo-card__face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.85), transparent 65%);
  animation: arcade-flash 0.9s ease-out forwards;
  pointer-events: none;
}

/* The veil: two frosted halves, one per gem. Placing a gem slides its half away. */
.arcade-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.arcade-veil-half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50.5%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.82);
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, rgba(22, 22, 28, 0.94), rgba(8, 8, 11, 0.97));
  transition:
    transform 1.1s cubic-bezier(0.65, 0, 0.2, 1),
    opacity 1.1s ease;
}
.arcade-veil-half.is-left {
  left: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}
.arcade-veil-half.is-right {
  right: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.arcade-veil-half.is-left.is-open {
  transform: translateX(-104%) rotate(-4deg);
  opacity: 0;
}
.arcade-veil-half.is-right.is-open {
  transform: translateX(104%) rotate(4deg);
  opacity: 0;
}
.arcade-veil-lock {
  font-size: 30px;
  line-height: 1;
  opacity: 0.7;
}
.arcade-veil-name {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
}
/* Half open: a seam of light where the open half meets the closed one. */
.arcade-veil-seam {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(180deg, transparent, #fff 20%, #fff 80%, transparent);
  box-shadow: 0 0 18px 4px rgba(255, 255, 255, 0.6);
  opacity: 0;
  transition: opacity 0.6s 0.5s;
}
.arcade-card.is-half .arcade-veil-seam {
  opacity: 1;
  animation: arcade-seam 2.4s ease-in-out 1.1s infinite;
}

.arcade-sockets {
  display: flex;
  align-items: center;
  gap: 10px;
}
.arcade-plus {
  color: var(--faint);
  font: 400 18px/1 var(--mono);
}
.arcade-socket {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 92px;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.arcade-socket canvas {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  outline: 1px dashed var(--border);
  outline-offset: 2px;
  filter: brightness(0) drop-shadow(0 0 1px var(--rarity));
  opacity: 0.5;
  transition:
    filter 0.5s,
    opacity 0.5s,
    outline-color 0.3s;
}
.arcade-socket.is-ready canvas {
  filter: none;
  opacity: 0.55;
  outline: 1.5px dashed var(--rarity);
  animation: arcade-breathe 2s ease-in-out infinite;
}
.arcade-socket.is-set canvas {
  filter: none;
  opacity: 1;
  outline: 1.5px solid var(--rarity);
  animation: none;
}
.arcade-socket:disabled {
  opacity: 1;
  cursor: default;
}
.arcade-socket:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 12px;
}
.arcade-socket-name {
  font: 500 13px/1.1 var(--display);
}
.arcade-socket-state {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}
.arcade-socket.is-ready .arcade-socket-state {
  color: var(--ink);
}

.arcade-meta {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
}
.arcade-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
}
.arcade-name .mono {
  color: var(--muted);
  font-size: var(--fs-mono);
}
.arcade-name strong {
  font: 600 18px/1.1 var(--display);
  letter-spacing: -0.02em;
}
.arcade-kind {
  color: var(--muted);
  font-size: 13px;
}
.arcade-status {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-mono);
  text-transform: uppercase;
}
.arcade-card.is-forged .arcade-status {
  color: var(--ink);
}

/* The gem under the pointer while dragging. */
.arcade-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  width: 64px;
  height: 64px;
  pointer-events: none;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}
.arcade-ghost canvas {
  width: 100%;
  height: 100%;
  animation: arcade-lift 0.25s var(--ease) both;
}

/* ---------- the forge ---------- */
body.forge-open,
body.arcade-open {
  overflow: hidden;
}
.forge {
  --charge: 0;
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, calc(var(--charge) * 0.14)), transparent calc(25% + var(--charge) * 30%)),
    #050507;
  color: #fff;
  opacity: 0;
  outline: none;
  transition: opacity 0.4s ease;
}
.forge.is-in {
  opacity: 1;
}
.forge.is-out {
  opacity: 0;
}
.forge-dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.forge-gem {
  position: absolute;
  top: calc(40% - 110px);
  left: calc(50% - 110px);
  width: 220px;
  height: 220px;
  pointer-events: none;
}
.forge.is-revealed .forge-gem {
  opacity: 0;
  transition: opacity 0.6s;
}
.forge-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.forge.is-burst .forge-flash {
  animation: forge-flash 1.1s ease-out;
}
.forge-ring {
  position: absolute;
  top: 40%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.forge.is-burst .forge-ring {
  animation: forge-ring 1.2s cubic-bezier(0.1, 0.7, 0.2, 1);
}
.forge-card {
  position: absolute;
  top: 40%;
  left: 50%;
  width: min(340px, 62vw, 40vh);
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  transition:
    transform 1.3s cubic-bezier(0.2, 1.4, 0.3, 1),
    opacity 0.4s;
}
.forge-card .holo-card {
  --hc-w: 100%;
  display: block;
}
.forge.is-revealed .forge-card {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
.forge-text {
  position: absolute;
  left: 50%;
  bottom: clamp(20px, 5vh, 56px);
  width: min(560px, calc(100% - 32px));
  transform: translateX(-50%);
  text-align: center;
  animation: forge-rise 0.7s var(--ease) both;
}
.forge-kicker {
  margin: 0 0 6px;
  color: rgba(255, 255, 255, 0.6);
  font-size: var(--fs-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.forge-title {
  margin: 0;
  font: 650 clamp(30px, 4vw, 54px) / 1 var(--display);
  letter-spacing: -0.035em;
}
.forge-sub {
  margin: 8px 0 18px;
  color: rgba(255, 255, 255, 0.7);
}
.forge-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.forge .button.primary,
.arcade-play .button.primary {
  background: #fff;
  border-color: #fff;
  color: #101010;
}
.forge .button.secondary {
  border-color: rgba(255, 255, 255, 0.5);
  background: transparent;
  color: #fff;
}

/* ---------- playing ---------- */
.arcade-play {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 16px;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%), #050507;
  color: #fff;
  opacity: 0;
  outline: none;
  transition: opacity 0.25s ease;
}
.arcade-play.is-in {
  opacity: 1;
}
.arcade-play-top {
  display: flex;
  align-items: center;
  gap: clamp(14px, 3vw, 40px);
  width: min(720px, 100%);
}
.arcade-play-title {
  flex: 1;
  display: grid;
  margin: 0;
}
.arcade-play-title .mono,
.arcade-play-score .mono {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  text-transform: uppercase;
}
.arcade-play-title strong {
  font: 600 20px/1.1 var(--display);
}
.arcade-play-score {
  display: grid;
  margin: 0;
  text-align: right;
}
.arcade-play-score strong {
  font: 500 22px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}
.arcade-play-actions {
  display: flex;
  gap: 6px;
}
.arcade-play-icon {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: transparent;
  color: #fff;
  font-size: 13px;
}
.arcade-play-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}
.arcade-play-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}
.arcade-play-canvas {
  display: block;
  max-width: 100%;
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 30px 80px -20px color-mix(in srgb, var(--accent) 45%, transparent);
  touch-action: none;
}
.arcade-play-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  background: rgba(5, 5, 7, 0.55);
  border-radius: 14px;
}
.arcade-play-msg[hidden] {
  display: none;
}
.arcade-play-msg .mono {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.arcade-play-msg-title {
  max-width: 22ch;
  margin: 0 0 6px;
  font: 600 clamp(20px, 2.4vw, 28px) / 1.15 var(--display);
}
.arcade-pad {
  display: none;
  gap: 8px;
}
.arcade-pad-btn {
  min-width: 58px;
  height: 52px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font: 500 18px/1 var(--mono);
  touch-action: none;
  user-select: none;
}
.arcade-pad-btn:active {
  background: rgba(255, 255, 255, 0.2);
}
.arcade-play-help {
  margin: 0;
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
  text-align: center;
  text-transform: uppercase;
}
@media (pointer: coarse) {
  .arcade-pad {
    display: flex;
  }
}

/* ---------- motion ---------- */
@keyframes arcade-blink {
  50% {
    opacity: 0.2;
  }
}
@keyframes arcade-breathe {
  50% {
    opacity: 0.9;
    outline-offset: 5px;
  }
}
@keyframes arcade-shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}
@keyframes arcade-flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes arcade-seam {
  50% {
    opacity: 0.45;
  }
}
@keyframes arcade-lift {
  from {
    transform: scale(0.6) rotate(-12deg);
  }
  to {
    transform: scale(1.1) rotate(6deg);
  }
}
@keyframes forge-flash {
  0% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}
@keyframes forge-ring {
  0% {
    opacity: 1;
    transform: scale(0.2);
  }
  100% {
    opacity: 0;
    transform: scale(40);
    border-width: 0.5px;
  }
}
@keyframes forge-rise {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .arcade-chip.is-wanted::after,
  .arcade-socket.is-ready canvas,
  .arcade-card.is-half .arcade-veil-seam,
  .arcade-card.is-shake,
  .forge.is-burst .forge-ring {
    animation: none;
  }
  .arcade-veil-half,
  .forge-card {
    transition-duration: 0.01s;
  }
}
