:root {
  --bg: #05070b;
  --ink: #f3f5f9;
  --ink-muted: #7d8699;
  --accent: #3b6cff;
  --accent-bright: #7a9bff;
  --accent-deep: #1a33b8;
  --line: rgba(255, 255, 255, 0.14);

  --font-display: "Inter Tight", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --gutter: clamp(16px, 2.6vw, 32px);
  --radius-card: clamp(14px, 1.8vw, 22px);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --px: 0;
  --py: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-display);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 10;
}

a {
  color: inherit;
  text-decoration: none;
}

.glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.glow__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
}

.glow__blob--a {
  width: 46vmax;
  height: 46vmax;
  top: -12vmax;
  right: 8vw;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  transform: translate(calc(var(--px) * -50px), calc(var(--py) * -40px));
}

.glow__blob--b {
  width: 40vmax;
  height: 40vmax;
  bottom: -16vmax;
  left: 4vw;
  background: radial-gradient(circle, var(--accent-deep) 0%, transparent 70%);
  transform: translate(calc(var(--px) * 40px), calc(var(--py) * 30px));
}

.scene {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  perspective: 1400px;
}

.card-wrap {
  --reserve: calc(4 * var(--gutter));
  width: min(clamp(290px, 44vw, 600px), calc((100svh - var(--reserve)) * 1.586));
  transform-style: preserve-3d;
  animation: card-in 1.6s var(--ease-out) 0.15s both;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.card-wrap.is-dragging,
.card-wrap.is-dragging * {
  cursor: grabbing;
}

.tilt {
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(calc(var(--py) * -14deg)) rotateY(calc(var(--px) * 18deg));
}

.flip {
  position: relative;
  transform-style: preserve-3d;
}

.card {
  position: relative;
  aspect-ratio: 1.586;
  border-radius: var(--radius-card);
  container-type: inline-size;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.11) 0%, rgba(255, 255, 255, 0.025) 55%, rgba(122, 155, 255, 0.06) 100%),
    rgba(12, 16, 26, 0.55);
  border: 1px solid var(--line);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    calc(var(--px) * -36px) calc(44px + var(--py) * -24px) 90px -24px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  transform: rotateZ(var(--roll, 0deg));
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: border-color 0.3s var(--ease-out);
}

.flip[data-facing="back"] .card--front,
.flip[data-facing="front"] .card--back {
  visibility: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.07) 45%,
    transparent 60%
  );
  background-size: 260% 100%;
  background-position: calc(50% + var(--px) * 45%) 0;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle at calc(50% + var(--px) * 45%) calc(50% + var(--py) * 45%),
    rgba(255, 255, 255, 0.2),
    transparent 55%
  );
  mix-blend-mode: soft-light;
}

.card__content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 6.5cqw 7cqw;
  transform: translate(calc(var(--px) * 5px), calc(var(--py) * 5px));
}

.card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chip {
  width: 9.5cqw;
  aspect-ratio: 1.25;
  border-radius: 1.3cqw;
  background:
    linear-gradient(90deg, transparent 32%, rgba(255, 255, 255, 0.22) 32% 34%, transparent 34% 66%, rgba(255, 255, 255, 0.22) 66% 68%, transparent 68%),
    linear-gradient(0deg, transparent 47%, rgba(255, 255, 255, 0.22) 47% 53%, transparent 53%),
    linear-gradient(140deg, var(--accent-bright), var(--accent) 50%, var(--accent-deep));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.wave {
  width: 6cqw;
  fill: none;
  stroke: var(--accent-bright);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.wave path {
  animation: signal 2.4s ease-in-out infinite;
}

.wave path:nth-child(2) {
  animation-delay: 0.18s;
}

.wave path:nth-child(3) {
  animation-delay: 0.36s;
}

.card__title {
  margin: 3cqw 0 0;
  font-weight: 900;
  font-size: 15cqw;
  white-space: nowrap;
  line-height: 0.88;
  letter-spacing: -0.045em;
  color: var(--accent);
}

.card__foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 4cqw;
  font-family: var(--font-mono);
}

.card__number {
  font-size: 3.6cqw;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--ink);
  white-space: nowrap;
}

.card__info {
  font-size: max(1.75cqw, 7.5px);
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-align: right;
  color: var(--accent-bright);
  white-space: nowrap;
}

.card--back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 5.5cqw;
  transform: rotateY(180deg) rotateZ(var(--roll, 0deg));
}

.card--front:has(.face-btn:hover, .face-btn:focus-visible) {
  border-color: rgba(122, 155, 255, 0.5);
}

.card--front:has(.face-btn:hover, .face-btn:focus-visible) .wave path {
  animation: none;
  opacity: 1;
}

.face-btn {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: none;
  color: var(--ink-muted);
  cursor: inherit;
  -webkit-tap-highlight-color: transparent;
}

.face-btn:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: -6px;
}

.face-btn--back {
  z-index: 1;
}

.face-btn--back svg {
  position: absolute;
  right: 5cqw;
  top: calc(5cqw + 5cqw);
  width: max(18px, 4cqw);
  translate: 0 -50%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: color 0.25s var(--ease-out), rotate 0.5s var(--ease-out);
}

.face-btn--back:hover svg,
.face-btn--back:focus-visible svg {
  color: var(--ink);
  rotate: -40deg;
}

.stripe {
  flex: none;
  height: 10cqw;
  margin-top: 5cqw;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.88), rgba(5, 7, 11, 0.96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.links {
  position: relative;
  z-index: 3;
  margin: auto 0 0;
  padding: 0 7cqw;
  list-style: none;
}

.links li + li .link {
  border-top: 0;
}

.link {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 3cqw;
  min-height: max(44px, 11cqw);
  padding: 0 2.5cqw;
  border-block: 1px solid var(--line);
  font-family: var(--font-mono);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.25s var(--ease-out), color 0.25s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-drag: none;
}

.link__idx {
  font-size: max(1.75cqw, 8px);
  letter-spacing: 0.12em;
  color: var(--accent-bright);
}

.link__name {
  font-size: max(3.6cqw, 13px);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.link__handle {
  justify-self: end;
  font-size: max(2.2cqw, 9px);
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.link__arrow {
  font-size: max(3cqw, 12px);
  color: var(--accent-bright);
  transition: translate 0.3s var(--ease-out);
}

.link:hover,
.link:focus-visible {
  background: var(--accent);
  outline: none;
}

.link:hover :is(.link__idx, .link__handle, .link__arrow),
.link:focus-visible :is(.link__idx, .link__handle, .link__arrow) {
  color: var(--ink);
}

.link:hover .link__arrow,
.link:focus-visible .link__arrow {
  translate: 2px -2px;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(70px) rotateX(55deg) rotateZ(-6deg) scale(0.88);
  }
}

@keyframes signal {
  0%,
  100% {
    opacity: 0.25;
  }
  30% {
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .card-wrap {
    width: min(86vw, 420px, calc((100svh - var(--reserve)) * 1.586));
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-wrap {
    animation: none;
    cursor: default;
  }

  .face-btn {
    cursor: pointer;
  }

  .card,
  .card--back {
    transform: none;
  }

  .card {
    transition: opacity 0.25s linear, visibility 0s;
  }

  .flip[data-facing="back"] .card--front,
  .flip[data-facing="front"] .card--back {
    opacity: 0;
    transition: opacity 0.25s linear, visibility 0s linear 0.25s;
  }

  .wave path {
    animation: none;
    opacity: 1;
  }
}
