/* The custom plan with add-ons that snap on like magnets: the Studio plan of Tidewell, a made-up site builder, on a
   near black page, and under it a tray of add-ons. Everything is measured on one unit, --k (one pixel of the design,
   400 by 520), so the whole piece fits the width and the height of the window. The chips live in a layer of their
   own over the stage: the script moves them (.chip) and the CSS only dresses their face (.chip__face). */
:root {
  --page: #0b0b0e;           /* the page */
  --card: #141519;           /* the body of the card */
  --edge: rgba(255, 255, 255, 0.075); /* the 1px edges at rest */
  --ink: #eeeef2;            /* the words */
  --muted: #868893;          /* the small words */
  --accent: #6d6bff;         /* the magnet: its field, the docked chips, the line */
  --accent-soft: #b9b8ff;    /* the light side of the accent */
  --chip: #1b1c22;           /* the chips in the tray */
  --button: #f3f3f6;         /* the button */
  --button-ink: #0b0b0e;     /* the words on the button */
  --k: min(100vw / 392, 100vh / 556, 1.3px);
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(60% 45% at 50% 34%, rgba(109, 107, 255, 0.1), transparent 70%),
    var(--page);
}

.build {
  width: calc(360 * var(--k));
  display: grid;
  gap: calc(16 * var(--k));
  opacity: 0;
}

/* ---- the card: .plan is moved by the script (its spring), .plan__card is the body ---- */
.plan {
  position: relative;
  z-index: 1;
}

.plan__card {
  position: relative;
  padding: calc(18 * var(--k)) calc(18 * var(--k)) calc(18 * var(--k));
  border-radius: calc(22 * var(--k));
  background: linear-gradient(180deg, #17181d, var(--card) 40%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px var(--edge),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 calc(18 * var(--k)) calc(40 * var(--k)) calc(-14 * var(--k)) rgba(0, 0, 0, 0.8),
    0 calc(40 * var(--k)) calc(90 * var(--k)) calc(-30 * var(--k)) rgba(40, 38, 120, 0.45);
  overflow: hidden;
}

.plan__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.06;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* a soft light that follows the pointer over the card, and the edge that catches it */
.plan__shine {
  --mx: 50%;
  --my: 0%;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(calc(220 * var(--k)) circle at var(--mx) var(--my), rgba(185, 184, 255, 0.09), transparent 70%);
}

.plan__shine::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(calc(160 * var(--k)) circle at var(--mx) var(--my), rgba(185, 184, 255, 0.5), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.plan__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc(12.5 * var(--k));
}

.plan__brand {
  display: inline-flex;
  align-items: center;
  gap: calc(7 * var(--k));
  font-weight: 620;
  font-stretch: 105%;
  letter-spacing: -0.01em;
}

.plan__mark {
  width: calc(18 * var(--k));
  height: calc(18 * var(--k));
  fill: none;
  stroke: var(--accent-soft);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.plan__chip {
  padding: calc(4 * var(--k)) calc(9 * var(--k));
  border-radius: 999px;
  color: var(--muted);
  font-size: calc(11 * var(--k));
  font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--edge);
}

.plan__row {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: calc(18 * var(--k));
}

.plan__title {
  display: grid;
  gap: calc(4 * var(--k));
}

.plan__name {
  font-size: calc(26 * var(--k));
  font-weight: 640;
  font-stretch: 112%;
  letter-spacing: -0.025em;
  line-height: 1;
}

.plan__count {
  color: var(--muted);
  font-size: calc(12 * var(--k));
  font-weight: 450;
}

.plan__price {
  display: flex;
  align-items: flex-start;
  margin: 0;
  line-height: 1;
}

.plan__cur {
  margin-top: calc(4 * var(--k));
  margin-right: calc(1 * var(--k));
  color: var(--muted);
  font-size: calc(18 * var(--k));
  font-weight: 500;
}

.plan__digits {
  display: flex;
  font-size: calc(44 * var(--k));
  font-weight: 620;
  font-stretch: 96%;
  letter-spacing: -0.04em;
}

/* one digit: a window one line high with a strip from 0 to 9 inside */
.digit {
  position: relative;
  display: block;
  width: 0.58em;
  height: 1em;
  overflow: hidden;
  text-align: center;
}

.digit.is-narrow {
  width: 0.42em;
}

.digit__strip {
  display: block;
}

.digit__strip span {
  display: block;
  height: 1em;
  line-height: 1;
}

.plan__per {
  align-self: flex-end;
  margin-left: calc(3 * var(--k));
  margin-bottom: calc(4 * var(--k));
  color: var(--muted);
  font-size: calc(12.5 * var(--k));
  font-weight: 500;
}

/* ---- the dock: where the magnet holds the add-ons ---- */
.dock {
  --field: 0;
  position: relative;
  height: calc(126 * var(--k));
  margin-top: calc(16 * var(--k));
  border-radius: calc(15 * var(--k));
  background: rgba(255, 255, 255, 0.018);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), inset 0 1px 6px rgba(0, 0, 0, 0.35);
}

.dock::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px dashed rgba(255, 255, 255, 0.11);
  opacity: calc(1 - var(--field) * 0.7);
}

.dock__field {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: var(--field);
  background: radial-gradient(80% 90% at 50% 50%, rgba(109, 107, 255, 0.16), transparent 75%);
  box-shadow: inset 0 0 0 1px rgba(109, 107, 255, 0.65), 0 0 calc(26 * var(--k)) rgba(109, 107, 255, 0.28);
}

.dock__hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(6 * var(--k));
  color: var(--muted);
  font-size: calc(12 * var(--k));
  font-weight: 460;
}

.dock__hint svg {
  width: calc(14 * var(--k));
  height: calc(14 * var(--k));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- the button ---- */
.plan__btn {
  position: relative;
  display: block;
  width: 100%;
  margin-top: calc(16 * var(--k));
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.plan__btn-face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(8 * var(--k));
  height: calc(44 * var(--k));
  border-radius: calc(13 * var(--k));
  background: var(--button);
  color: var(--button-ink);
  font-size: calc(14 * var(--k));
  font-weight: 600;
  font-stretch: 104%;
  overflow: hidden;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), inset 0 1px 0 #fff, 0 6px 16px -8px rgba(185, 184, 255, 0.55);
}

.plan__btn-sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(109, 107, 255, 0.28), transparent);
  transform: translateX(-120%);
  pointer-events: none;
}

.plan__btn-icon {
  width: calc(16 * var(--k));
  height: calc(16 * var(--k));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.plan__check {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.plan__btn:focus-visible .plan__btn-face {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* ---- the tray ---- */
.tray {
  position: relative;
}

.tray__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 calc(4 * var(--k));
  font-size: calc(12 * var(--k));
}

.tray__label {
  font-weight: 600;
}

.tray__note {
  color: var(--muted);
}

.tray__well {
  height: calc(132 * var(--k));
  margin-top: calc(8 * var(--k));
  border-radius: calc(18 * var(--k));
  background: rgba(255, 255, 255, 0.022);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.045), inset 0 2px 10px rgba(0, 0, 0, 0.4);
}

/* ---- the chips ---- */
.chips {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.chip {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.chip.is-held {
  cursor: grabbing;
  z-index: 2;
}

.chip__face {
  --lift: 0;
  display: flex;
  align-items: center;
  gap: calc(7 * var(--k));
  height: calc(32 * var(--k));
  padding: 0 calc(11 * var(--k)) 0 calc(5 * var(--k));
  border-radius: 999px;
  background: linear-gradient(180deg, #22232a, var(--chip));
  font-size: calc(12.5 * var(--k));
  font-weight: 540;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 calc((4 + var(--lift) * 14) * var(--k)) calc((10 + var(--lift) * 22) * var(--k)) calc(-4 * var(--k)) rgba(0, 0, 0, calc(0.5 + var(--lift) * 0.2));
  transition: background 0.35s ease, color 0.35s ease;
}

.chip__icon {
  display: grid;
  place-items: center;
  width: calc(22 * var(--k));
  height: calc(22 * var(--k));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: background 0.35s ease;
}

.chip__icon svg {
  width: calc(13 * var(--k));
  height: calc(13 * var(--k));
  fill: none;
  stroke: var(--accent-soft);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.35s ease;
}

.chip__price {
  color: var(--muted);
  font-weight: 500;
  transition: color 0.35s ease;
}

/* held by the magnet: the chip takes the accent */
.chip.is-docked .chip__face {
  background: linear-gradient(180deg, #2b2a5c, #22214a);
  box-shadow:
    inset 0 1px 0 rgba(185, 184, 255, 0.22),
    inset 0 0 0 1px rgba(109, 107, 255, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 calc(6 * var(--k)) calc(16 * var(--k)) calc(-6 * var(--k)) rgba(109, 107, 255, 0.55);
}

.chip.is-docked .chip__icon {
  background: var(--accent);
}

.chip.is-docked .chip__icon svg {
  stroke: #fff;
}

.chip.is-docked .chip__price {
  color: var(--accent-soft);
}

@media (hover: hover) {
  .chip:hover .chip__face {
    background: linear-gradient(180deg, #282930, #1f2027);
  }

  .chip.is-docked:hover .chip__face {
    background: linear-gradient(180deg, #33326a, #262553);
  }

  .plan__btn:hover .plan__btn-face {
    background: #fff;
  }
}

.chip:focus-visible .chip__face {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* the ring left where a chip lands */
.ring {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  border-radius: 999px;
  box-shadow: 0 0 0 1px var(--accent-soft), 0 0 calc(14 * var(--k)) rgba(109, 107, 255, 0.6);
  pointer-events: none;
}

/* ---- the field line ---- */
.lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

.lines__path {
  fill: none;
  stroke: var(--accent-soft);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-dasharray: 2 5;
  opacity: 0;
}

/* the drawn pointer of the autopilot */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: calc(22 * var(--k));
  height: calc(22 * var(--k));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ghost path {
  fill: #fff;
  stroke: #0b0b0e;
  stroke-width: 1.4;
  stroke-linejoin: round;
}
