/* The invitation (joinpista.com/invite). One page that moves through five states, set on <body>:
   is-intro  two lines in the dark, then the spotlight comes on
   is-card   the card lands in the light            → "Open your invitation"
   is-code   the card turns to its back              → the code from the card
   is-welcome the card is filled in and ringed       → who they are
   is-done   their member card                                                    */

.invite { display: flex; flex-direction: column; }
.invite .top { position: relative; z-index: 2; display: flex; justify-content: center; padding: 26px 20px 0; opacity: 0; transition: opacity 1s var(--ease) .4s; }
.invite:not(.is-intro) .top { opacity: 1; }
.invite .foot { opacity: 0; transition: opacity 1s var(--ease) 1.2s; }
.invite:not(.is-intro) .foot { opacity: 1; }

.invite-main { position: relative; z-index: 1; flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 22px 20px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; }

/* ---- the spotlight switches on ---- */
.invite .beam, .invite .floor { opacity: 0; }
.invite .lit .beam, .invite.lit .beam { animation: switch-on 1.1s steps(1) forwards, breathe 7s ease-in-out 1.2s infinite; }
.invite.lit .floor { animation: fade-in 1.4s var(--ease) .15s forwards; }
@keyframes switch-on { 0% { opacity: .55 } 9% { opacity: 0 } 16% { opacity: .8 } 22% { opacity: .2 } 30%, 100% { opacity: 1 } }
@keyframes breathe { 50% { opacity: .82 } }
@keyframes fade-in { to { opacity: 1 } }

/* ---- the two lines ---- */
.lines { position: fixed; inset: 0; z-index: 3; display: grid; place-content: center; gap: 10px; padding: 24px; pointer-events: none; }
.line { margin: 0; text-wrap: balance; font-size: clamp(30px, 7.4vw, 54px); font-weight: 700; letter-spacing: -.045em; line-height: 1.05; opacity: 0; transform: translateY(14px); filter: blur(8px); }
.line.l2 { color: var(--red); }
.is-intro .line { animation: line-in 1.1s var(--ease) forwards; }
.is-intro .line.l2 { animation-delay: 1.5s; }
.lines.out { animation: lines-out .7s var(--ease) forwards; }
@keyframes line-in { to { opacity: 1; transform: none; filter: none; } }
@keyframes lines-out { to { opacity: 0; transform: translateY(-12px); filter: blur(10px); } }
.is-intro .lines.out .line { opacity: 1; transform: none; filter: none; animation: none; }

/* ---- the card ---- */
.scene { width: 100%; perspective: 1400px; margin: 14px 0 30px; transition: margin .9s var(--ease); }
.card3d {
  --rx: 0deg; --ry: 0deg;
  position: relative; width: min(100%, 480px); margin: 0 auto; aspect-ratio: 1200 / 777; outline: 0;
  opacity: 0; transform: translateY(-70px) rotateX(38deg) rotateZ(-6deg) scale(.86);
  transition: opacity 1.1s var(--ease), transform 1.4s var(--ease), width .9s var(--ease);
}
.is-intro .card3d { visibility: hidden; }
.invite:not(.is-intro) .card3d { opacity: 1; transform: rotateX(var(--rx)) rotateY(var(--ry)); }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform 1.15s cubic-bezier(.3, .1, .1, 1); animation: float 6s ease-in-out infinite; }
@keyframes float { 50% { translate: 0 -7px; } }
.is-code .card-inner, .is-welcome .card-inner, .is-done .card-inner { transform: rotateY(180deg); }

.face { position: absolute; inset: 0; border-radius: 3.6% / 5.6%; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 50px 90px -30px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 255, 255, .07); }
.face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.back { transform: rotateY(180deg); background: #fff; overflow: visible; }
.back img { border-radius: inherit; }

.sheen { position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .22) 48%, transparent 60%); transform: translateX(-120%); }
.invite:not(.is-intro) .sheen { animation: sheen 1.6s var(--ease) 1s forwards; }
@keyframes sheen { to { transform: translateX(120%); } }

/* handwriting on the back of the card, placed on the printed lines */
.hand { position: absolute; font-family: "Caveat", "Bradley Hand", "Noteworthy", cursive; font-weight: 600; color: #1F3FBF; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; clip-path: inset(0 100% 0 0); }
.hand.write { animation: write .9s steps(14, end) forwards; }
.hand.h-code { left: 60.4%; top: 40.6%; height: 19%; width: 33%; display: flex; align-items: center; font-size: clamp(16px, 6.4cqw, 34px); letter-spacing: .04em; }
.hand.h-by { left: 66.6%; top: 79%; width: 28%; font-size: clamp(12px, 4.4cqw, 24px); }
.hand.h-by.write { animation-delay: 1.1s; }
@keyframes write { to { clip-path: inset(0 0 0 0); } }
.card3d { container-type: inline-size; }

/* the red ring that closes around the card once the code is right */
.ring { position: absolute; inset: -3.5%; width: 107%; height: 107%; overflow: visible; pointer-events: none; }
.ring rect { fill: none; stroke: var(--red); stroke-width: 1; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; filter: drop-shadow(0 0 10px rgba(254, 58, 36, .9)); opacity: 0; }
.is-welcome .ring rect, .is-done .ring rect { animation: ring 1.3s var(--ease) 1.4s forwards; }
@keyframes ring { 0% { opacity: 1; stroke-dashoffset: 100; } 100% { opacity: 1; stroke-dashoffset: 0; } }

.card3d.shake { animation: shake .5s; }
@keyframes shake { 20% { translate: -10px 0 } 40% { translate: 9px 0 } 60% { translate: -6px 0 } 80% { translate: 3px 0 } }

/* once they are in, the card steps back and makes room */
.is-welcome .scene { margin: 0 0 22px; }
.is-welcome .card3d { width: min(70%, 300px); transition-delay: 0s, 0s, 2.6s; }
.is-done .scene { display: none; }

/* ---- panels ---- */
.panel { width: 100%; display: grid; justify-items: center; gap: 16px; animation: panel-in .9s var(--ease) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(16px); } }
.p-open { animation-delay: 1.3s; }
.is-intro .p-open { visibility: hidden; animation: none; }
.panel h1 { margin: 0; text-wrap: balance; font-size: clamp(30px, 7.6vw, 44px); line-height: 1.04; letter-spacing: -.045em; font-weight: 800; max-width: 14ch; }
.panel .lede { margin: 0; color: var(--muted); font-size: 16.5px; max-width: 30em; }
.p-welcome { animation-delay: 2.4s; text-align: left; justify-items: stretch; }
.p-welcome .eyebrow, .p-welcome h1, .p-welcome .lede { text-align: center; justify-self: center; }
.p-welcome h1 { max-width: none; }

.code-form { width: 100%; max-width: 380px; display: grid; gap: 12px; }
.code-form label { font-size: 15px; color: var(--muted); }
.code-input { display: flex; align-items: center; height: 64px; border-radius: 16px; background: var(--field); box-shadow: inset 0 0 0 1.5px var(--line); padding: 0 18px; transition: box-shadow .15s; }
.code-input:focus-within { box-shadow: inset 0 0 0 2px #fff; }
.code-input.err { box-shadow: inset 0 0 0 2px var(--red); }
.code-input span { font-size: 24px; font-weight: 600; color: var(--dim); letter-spacing: .04em; }
.code-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: #fff; font: inherit; font-size: 24px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; padding: 0 0 0 2px; }
.msg { margin: 0; min-height: 1.4em; color: var(--red-soft); font-size: 14px; }
.msg:empty { min-height: 0; }

.join-form { display: grid; gap: 14px; margin-top: 10px; }
.field { display: grid; gap: 7px; }
.field label { font-size: 13.5px; font-weight: 600; }
.field input, .field select {
  width: 100%; height: 54px; border: 0; outline: 0; border-radius: 14px; padding: 0 16px;
  background: var(--field); color: #fff; font: inherit; font-size: 16px; box-shadow: inset 0 0 0 1.5px var(--line); transition: box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%); background-position: right 22px center, right 16px center; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.field select option { color: #111; }
.field input:focus, .field select:focus { box-shadow: inset 0 0 0 2px #fff; }
.field.err input, .field.err select { box-shadow: inset 0 0 0 2px var(--red); }
.join-form .btn { margin-top: 6px; }

/* the country picker: type to search, pick from the list */
.combo { position: relative; }
.combo input { padding-right: 16px; }
.combo.has-flag input { padding-left: 50px; }
.combo-flag { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 22px; line-height: 1; pointer-events: none; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); max-height: min(300px, 46vh); overflow-y: auto; overscroll-behavior: contain;
  margin: 0; padding: 6px; list-style: none; border-radius: 16px; background: #1B1D24; box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .8), inset 0 0 0 1px rgba(255, 255, 255, .1);
}
.combo-list li { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.combo-list li .f { font-size: 22px; line-height: 1; width: 26px; text-align: center; }
.combo-list li.on, .combo-list li:hover { background: rgba(255, 255, 255, .08); }
.combo-list li[aria-selected="true"] { color: var(--red-soft); }
.combo-list .combo-empty { color: var(--muted); cursor: default; font-size: 14.5px; }
.combo-list .combo-empty:hover { background: none; }
.fine { margin: 0; text-align: center; font-size: 12.5px; color: var(--dim); }

/* ---- their member card ---- */
.p-done { gap: 22px; padding-top: 10px; }
.member {
  position: relative; width: min(100%, 400px); aspect-ratio: 1200 / 777; border-radius: 3.6% / 5.6%; overflow: hidden; text-align: left;
  padding: 7% 7.5%; display: flex; flex-direction: column;
  background: radial-gradient(120% 90% at 100% 0%, rgba(254, 58, 36, .35), transparent 55%), linear-gradient(160deg, #1B1D24, #0E0F13 70%);
  box-shadow: 0 50px 90px -30px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 255, 255, .09);
  animation: member-in 1.4s var(--ease) both;
}
.member::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .16) 48%, transparent 60%); transform: translateX(-120%); animation: sheen 1.8s var(--ease) 1s forwards; }
@keyframes member-in { from { opacity: 0; transform: perspective(900px) rotateX(30deg) translateY(30px) scale(.9); } }
.m-top { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--red-soft); }
.m-top .mark { width: 18px; height: 22px; color: var(--red); }
.m-act { margin: auto 0 4px; font-size: clamp(24px, 7vw, 32px); font-weight: 800; letter-spacing: -.04em; line-height: 1.05; }
.m-name { margin: 0; color: var(--muted); font-size: 14.5px; }
.m-foot { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 12.5px; color: var(--dim); }
.done-title { margin-top: 6px !important; }

.noscript { position: fixed; inset: auto 16px 16px; z-index: 9; margin: 0; padding: 14px 16px; border-radius: 12px; background: #1B1D24; color: #fff; text-align: center; }

@media (min-width: 720px) {
  .invite-main { padding-top: 40px; }
}
@media (max-height: 700px) and (max-width: 719px) {
  .scene { margin: 4px 0 18px; }
  .card3d { width: min(100%, 340px); }
}
@media (prefers-reduced-motion: reduce) {
  .card-inner { animation: none; }
  .hand { clip-path: none; }
}
