/* The festival registration form with the ticket that tears off its counterfoil: the sign up card of Halflight, a
   motion and design festival, on black. A graphite card with a fine grain, a 1px edge that catches the light and
   layered shadows; the form on one side, the foil ticket still joined to its counterfoil on the other. The foil takes
   the colour of the pass: steel for Day, champagne for Full, lilac for Patron. */
:root {
  --page: #000000;           /* the page */
  --card: #101013;           /* the card, graphite */
  --edge: rgba(255, 255, 255, 0.075); /* the 1px edges */
  --ink: #ececef;            /* the words */
  --muted: #85858f;          /* the small words */
  --field: rgba(255, 255, 255, 0.035); /* the fields */
  --wrong: #ff7a6b;          /* a field that is not right */
  --button: #f2efe9;         /* the button */
  --button-ink: #0c0c0e;     /* the words on the button */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  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 {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
}

/* the wrap is GSAP's (entrance) and the container for the layout; the card is CSS's */
.wrap {
  width: min(740px, 94vw);
  container-type: inline-size;
  opacity: 0;
}

.card {
  --t1: #e4e8ee;
  --t2: #9aa4b1;
  --t3: #ffffff;
  --tink: #252a32;
  --tsoft: rgba(37, 42, 50, 0.58);
  position: relative;
  display: grid;
  grid-template-columns: minmax(230px, 0.82fr) 1.18fr;
  grid-template-areas: 'form book';
  align-items: center;
  gap: clamp(18px, 3.4vw, 34px);
  padding: clamp(16px, 4vh, 30px) clamp(16px, 3.6vw, 30px);
  border-radius: 24px;
  background:
    radial-gradient(90% 70% at 100% 0%, color-mix(in srgb, var(--t1, #cfd5dd) 9%, transparent), transparent 62%),
    radial-gradient(70% 60% at 0% 100%, rgba(255, 255, 255, 0.025), transparent 60%),
    var(--card);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 12px 28px -10px rgba(0, 0, 0, 0.7),
    0 40px 90px -30px color-mix(in srgb, var(--t2, #8f99a6) 22%, transparent);
  transition: box-shadow 0.6s ease;
}

/* a grain over the card, very fine */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%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");
  mix-blend-mode: overlay;
}

/* ---------------------------------------------------------------- the book: counterfoil and ticket */
.book {
  grid-area: book;
  position: relative;
  display: flex;
  width: 100%;
  aspect-ratio: 2.3 / 1;
  container-type: inline-size;
  --n: 3.3cqi;               /* the big notches at the ends of the perforation */
  --hole: 0.62cqi;           /* the holes of the perforation */
  --step: 2.5cqi;            /* how far apart the holes are */
  perspective: 900px;
}

.book__piece {
  position: relative;
  height: 100%;
  filter: drop-shadow(0 1px 0.5px rgba(0, 0, 0, 0.55)) drop-shadow(0 10px 16px rgba(0, 0, 0, 0.5));
}

.book__piece--stub {
  width: 19%;
  z-index: 1;
}

.book__piece--ticket {
  width: 81%;
  z-index: 2;
}

/* the deeper shadow once the ticket is free: GSAP fades it in */
.ticket__lift {
  position: absolute;
  inset: 12% 6% -4% 6%;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.75);
  filter: blur(18px);
  opacity: 0;
  z-index: -1;
}

/* both faces: the foil with a 1px edge, cut by the notches and the half holes of the perforation */
.stub,
.ticket {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 2.6cqi;
  color: var(--tink);
  background:
    linear-gradient(118deg, color-mix(in srgb, var(--t3) 55%, transparent) 0%, transparent 34%),
    linear-gradient(135deg, var(--t1) 0%, color-mix(in srgb, var(--t1) 50%, var(--t2)) 48%, var(--t2) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  -webkit-mask-composite: source-in, source-in;
  mask-composite: intersect;
  -webkit-mask-repeat: no-repeat, no-repeat, repeat-y;
  mask-repeat: no-repeat, no-repeat, repeat-y;
  -webkit-mask-size: 100% 100%, 100% 100%, 100% var(--step);
  mask-size: 100% 100%, 100% 100%, 100% var(--step);
}

.ticket {
  -webkit-mask-image:
    radial-gradient(circle var(--n) at 0 0, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--n) at 0 100%, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--hole) at 0 50%, #0000 calc(var(--hole) - 0.5px), #000 var(--hole));
  mask-image:
    radial-gradient(circle var(--n) at 0 0, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--n) at 0 100%, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--hole) at 0 50%, #0000 calc(var(--hole) - 0.5px), #000 var(--hole));
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 4.2cqi 4.6cqi 3.8cqi 5.4cqi;
}

.stub {
  -webkit-mask-image:
    radial-gradient(circle var(--n) at 100% 0, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--n) at 100% 100%, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--hole) at 100% 50%, #0000 calc(var(--hole) - 0.5px), #000 var(--hole));
  mask-image:
    radial-gradient(circle var(--n) at 100% 0, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--n) at 100% 100%, #0000 calc(var(--n) - 0.5px), #000 var(--n)),
    radial-gradient(circle var(--hole) at 100% 50%, #0000 calc(var(--hole) - 0.5px), #000 var(--hole));
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  background:
    linear-gradient(118deg, color-mix(in srgb, var(--t3) 35%, transparent) 0%, transparent 40%),
    linear-gradient(135deg, color-mix(in srgb, var(--t1) 82%, #7d7d84), color-mix(in srgb, var(--t2) 80%, #55555c));
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
  gap: 1.6cqi;
  padding: 0 1.5cqi 0 0;
}

.stub > span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
}

.stub__brand {
  font-size: 2.3cqi;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stub__year {
  font-size: 2.2cqi;
  font-weight: 500;
  color: var(--tsoft);
  letter-spacing: 0.1em;
}

.stub__code {
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 1.9cqi;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--tsoft);
}

/* a security pattern of fine rings from a corner, and the grain of the foil */
.ticket__guilloche {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background:
    repeating-radial-gradient(circle at 112% 118%, transparent 0 0.7cqi, color-mix(in srgb, var(--tink) 40%, transparent) 0.7cqi 0.82cqi),
    repeating-radial-gradient(circle at -14% -30%, transparent 0 0.9cqi, rgba(255, 255, 255, 0.7) 0.9cqi 1cqi);
  -webkit-mask-image: linear-gradient(115deg, #000 0%, transparent 46%, transparent 58%, #000 100%);
  mask-image: linear-gradient(115deg, #000 0%, transparent 46%, transparent 58%, #000 100%);
  pointer-events: none;
}

.ticket__grain {
  position: absolute;
  inset: 0;
  opacity: 0.22;
  mix-blend-mode: soft-light;
  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='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* the light on the foil: GSAP moves it across */
.ticket__sheen {
  position: absolute;
  top: -40%;
  bottom: -40%;
  left: 0;
  width: 46%;
  background: linear-gradient(100deg, transparent 0%, color-mix(in srgb, var(--t3) 60%, transparent) 46%, rgba(255, 255, 255, 0.75) 50%, color-mix(in srgb, var(--t3) 60%, transparent) 54%, transparent 100%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.ticket > :not(i) {
  position: relative;
}

.ticket__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2cqi;
}

.ticket__brand {
  display: flex;
  align-items: center;
  gap: 1.6cqi;
  line-height: 1.05;
}

.ticket__brand b {
  display: block;
  font-size: 3cqi;
  font-weight: 750;
  font-stretch: 120%;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ticket__brand em {
  display: block;
  font-style: normal;
  font-size: 2.1cqi;
  font-weight: 500;
  color: var(--tsoft);
  margin-top: 0.5cqi;
}

.ticket__mark {
  width: 4.6cqi;
  height: 4.6cqi;
  flex: none;
}

.ticket__mark path {
  fill: var(--tink);
}

.ticket__mark circle {
  fill: none;
  stroke: var(--tink);
  stroke-width: 1.4;
}

.ticket__pass {
  display: inline-block;
  overflow: hidden;
  padding: 0.9cqi 1.9cqi;
  border-radius: 999px;
  font-size: 2cqi;
  font-weight: 650;
  font-stretch: 112%;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tink) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.16);
}

.ticket__pass-in {
  display: inline-block;
}

/* the name, engraved: the letter is darker than the foil, with a light edge below and a shadow above */
.ticket__name {
  position: relative;
  align-self: end;
  min-height: 9.4cqi;
  display: flex;
  align-items: flex-end;
  font-size: 7.4cqi;
  font-weight: 620;
  font-stretch: 104%;
  letter-spacing: -0.015em;
  line-height: 1;
  white-space: pre;
}

.ticket__letters {
  display: inline-flex;
  color: color-mix(in srgb, var(--tink) 88%, var(--t2));
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55),
    0 -0.5px 0 rgba(0, 0, 0, 0.35),
    0 0 0.5px rgba(0, 0, 0, 0.2);
}

.ticket__letters > span {
  display: inline-block;
  white-space: pre;
}

.ticket__ph {
  position: absolute;
  left: 0;
  bottom: 0;
  color: color-mix(in srgb, var(--tink) 26%, transparent);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* the engraving head: a thin line of light that walks along the name while it is written */
.ticket__stylus {
  position: absolute;
  left: 0;
  bottom: -0.4cqi;
  width: 1.5px;
  height: 8.6cqi;
  border-radius: 2px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0), #ffffff 40%, rgba(255, 255, 255, 0.9) 70%, rgba(255, 255, 255, 0));
  box-shadow: 0 0 6px 0 color-mix(in srgb, var(--t3) 80%, transparent);
  opacity: 0;
}

.ticket__mail {
  min-height: 3.4cqi;
  margin-top: 1.2cqi;
  font-size: 2.3cqi;
  font-weight: 500;
  color: var(--tsoft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket__foot {
  display: flex;
  align-items: flex-end;
  gap: 3.6cqi;
  margin-top: 2.2cqi;
  padding-top: 2.4cqi;
  border-top: 1px solid color-mix(in srgb, var(--tink) 16%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.ticket__cell {
  display: flex;
  flex-direction: column;
  gap: 0.6cqi;
  line-height: 1.2;
  font-size: 2.4cqi;
  font-weight: 600;
  white-space: nowrap;
}

.ticket__cell small {
  font-size: 1.7cqi;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tsoft);
}

/* the price on drums: each digit is a window over a column from 0 to 9 */
.price {
  display: inline-flex;
  align-items: flex-end;
  height: 1.2em;
  line-height: 1.2;
  margin: -0.1em 0;
}

.price__drum {
  position: relative;
  display: inline-block;
  width: 0.62em;
  height: 1.2em;
  overflow: hidden;
  text-align: center;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 86%, transparent);
}

.price__col {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  flex-direction: column;
}

.price__col > span {
  height: 1.2em;
}

.ticket__issue {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.8cqi;
}

.bars {
  width: 15cqi;
  height: 3.6cqi;
  overflow: visible;
}

.bars rect {
  fill: var(--tink);
}

.ticket__code {
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 2.1cqi;
  font-weight: 560;
  letter-spacing: 0.08em;
  white-space: pre;
  color: var(--tink);
}

.ticket__code.is-empty {
  font-family: inherit;
  font-size: 1.8cqi;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--tsoft);
}

/* the tear: a hairline of light along the perforation, drawn from top to bottom */
.seam {
  position: absolute;
  left: 19%;
  top: var(--n);
  bottom: var(--n);
  width: 4px;
  height: calc(100% - var(--n) * 2);
  margin-left: -2px;
  overflow: visible;
  pointer-events: none;
  z-index: 3;
}

.seam path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 2px color-mix(in srgb, var(--t3) 90%, transparent));
}

/* ---------------------------------------------------------------- the form */
.form {
  grid-area: form;
  display: grid;
  gap: 10px;
  min-width: 0;
}

.form__title {
  margin: 0 0 2px;
  font-size: clamp(17px, 2.6vw, 21px);
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
}

.form__row {
  display: grid;
  gap: 10px;
}

.field {
  position: relative;
  display: block;
  padding: 7px 12px 7px;
  border-radius: 12px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: box-shadow 0.25s ease, background-color 0.25s ease;
  cursor: text;
}

.field:focus-within,
.field.is-focus {
  background: rgba(255, 255, 255, 0.05);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--t1, #cfd5dd) 55%, transparent),
    0 0 0 3px color-mix(in srgb, var(--t1, #cfd5dd) 12%, transparent);
}

.field.is-wrong {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--wrong) 70%, transparent), 0 0 0 3px color-mix(in srgb, var(--wrong) 14%, transparent);
}

.field__label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field__input {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 520;
  caret-color: var(--t1, #cfd5dd);
}

.field__input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

/* the kind of pass: three choices with a pill that slides on a spring */
.passes {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border-radius: 12px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--edge);
}

.passes__pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--t1, #e4e8ee), var(--t2, #9aa4b1));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.2), 0 4px 10px -4px rgba(0, 0, 0, 0.6);
}

.passes__opt {
  position: relative;
  display: grid;
  place-items: center;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 560;
  color: var(--muted);
  transition: color 0.3s ease;
}

.passes__opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.passes__opt span {
  display: inline-block;
}

.passes__opt.is-on {
  color: var(--tink, #252a32);
}

.passes__opt:has(input:focus-visible) {
  outline: 2px solid color-mix(in srgb, var(--t1, #cfd5dd) 70%, transparent);
  outline-offset: 1px;
}

@media (hover: hover) {
  .passes__opt:not(.is-on):hover {
    color: var(--ink);
  }
}

/* the button: GSAP owns .btn (press, width), CSS owns the body */
.btn {
  position: relative;
  display: block;
  width: 100%;
  height: 44px;
  margin-top: 2px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--t1, #cfd5dd) 70%, transparent);
  outline-offset: 3px;
  border-radius: 13px;
}

.btn__body {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, var(--button));
  color: var(--button-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 8px 18px -8px color-mix(in srgb, var(--t1, #cfd5dd) 50%, transparent);
}

.btn__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.9) 50%, transparent 70%);
  transform: translateX(-110%);
  mix-blend-mode: soft-light;
}

.btn__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 640;
  font-stretch: 106%;
  white-space: nowrap;
}

.btn__face--wait,
.btn__face--done {
  opacity: 0;
}

.btn__spin {
  width: 18px;
  height: 18px;
}

.btn__spin circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 14 30;
}

.btn__check {
  width: 18px;
  height: 18px;
}

.btn__check path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 1;
}

/* ---------------------------------------------------------------- narrow: the ticket on top, the form below */
@container (max-width: 560px) {
  .card {
    grid-template-columns: 1fr;
    grid-template-areas: 'book' 'form';
    gap: 14px;
  }

  .form {
    gap: 8px;
  }

  .form__title {
    display: none;
  }

  .form__row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .field {
    padding: 6px 10px;
  }

  .field__input {
    font-size: 13.5px;
  }

  .btn {
    height: 42px;
  }
}

@media (max-height: 460px) {
  .card {
    padding-top: 14px;
    padding-bottom: 14px;
  }
}
