/* Training Day Athletics — pre-launch page
   Concept: the gym with the lights off. One work light hangs over the logo with
   chalk dust drifting in it, and a blue glow at the floor.
   Signing up throws the breakers: the overhead tubes flicker on and you get
   your number on the list. */

:root {
  --void: #040405;
  --char: #0b0b0e;
  --fg: #f2f3f5;
  --muted: #858893;
  --dim: #7a7e88;
  --line: rgba(255, 255, 255, 0.14);
  --blue: #1f51ff;
  --blue-hi: #3d68ff;
  --blue-glow: rgba(31, 81, 255, 0.45);
  --error: #ff8080;

  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --mono: "Martian Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --logo: url("/assets/logo.svg");
  --beat: 0;          /* 0..1, driven by main.js each frame */
  --reserve: 430px;   /* vertical space kept free for copy + form + footer */
  --mark-min: 240px;
  color-scheme: dark;
}

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

html { background: var(--void); -webkit-text-size-adjust: 100%; }

body {
  position: relative;
  margin: 0;
  min-height: 100svh;
  background: var(--void);
  color: var(--fg);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 42%, transparent 50%, rgba(0, 0, 0, 0.7) 100%);
  z-index: 1;
  transition: opacity 1.2s ease 0.4s;
}

body.is-lit { --reserve: 560px; }

/* no scrollbar flash while the logo shrinks to make room for the card */
html.is-settling { overflow: hidden; }
body.is-lit::after { opacity: 0.5; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- atmosphere ---------- */

.grain {
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 4;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(5) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-3%, 2%); }
  40%  { transform: translate(2%, -4%); }
  60%  { transform: translate(-4%, -1%); }
  80%  { transform: translate(3%, 3%); }
  100% { transform: translate(0, 0); }
}

/* the gym in the dark: slow footage of the plate rack, barely there until the lights come on */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.2;
  -webkit-mask: radial-gradient(95% 85% at 50% 42%, #000 30%, transparent 100%);
  mask: radial-gradient(95% 85% at 50% 42%, #000 30%, transparent 100%);
  transition: opacity 1.4s ease 0.4s;
}

.bg-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fade-in 3s ease 0.3s both;
}

/* a dark pool behind the logo so the black-on-black mark still reads over the plates */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(38% 30% at 50% 32%, rgba(4, 4, 5, 0.75), rgba(4, 4, 5, 0.35) 60%, transparent 100%);
  transition: opacity 1.4s ease 0.4s;
}

/* tall screens: push the plate rack down behind the copy so it clears the logo */
@media (max-aspect-ratio: 3/4) {
  .bg-video { transform: translateY(16%) scale(1.3); }
  .bg::after { background: radial-gradient(75% 26% at 50% 30%, rgba(4, 4, 5, 0.85), rgba(4, 4, 5, 0.4) 60%, transparent 100%); }
}

.is-lit .bg { opacity: 0.5; }
.is-lit .bg::after { opacity: 0.4; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* blue light leaking under a door */
.leak {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(1100px, 130vw);
  height: 46vh;
  transform: translateX(-50%);
  opacity: 0.8;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(50% 100% at 50% 100%, rgba(31, 81, 255, 0.26), transparent 70%),
    radial-gradient(22% 30% at 50% 100%, rgba(140, 165, 255, 0.22), transparent 80%);
}

.leak::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue) 18%, #aebcff 50%, var(--blue) 82%, transparent);
  box-shadow: 0 0 18px 3px var(--blue-glow), 0 0 60px 10px rgba(31, 81, 255, 0.25);
}

/* the work light's cone (behind the logo) and chalk dust (in front), drawn in main.js */
.beam,
.dust {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.beam { z-index: 1; opacity: 0; }
.dust { z-index: 3; }

/* ambient light once the overhead tubes are on */
.room {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(214, 224, 255, 0.16), rgba(214, 224, 255, 0.05) 45%, transparent 75%);
}

.is-lit .room { animation: flicker-on 1.3s linear 0.3s both; }

/* overhead fluorescent tubes: dark fixtures until the lights come on */
.tubes {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: clamp(10px, 3vw, 44px);
  padding-top: 16px;
  pointer-events: none;
  animation: rise 1.6s var(--ease-out) 0.6s both;
}

.tubes i {
  --d: 0.3s;
  position: relative;
  display: block;
  width: clamp(52px, 13vw, 190px);
  height: 5px;
  border-radius: 3px;
  background: #16171b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.tubes i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 280%;
  height: 60vh;
  transform: translateX(-50%);
  background: radial-gradient(50% 40% at 50% 0%, rgba(215, 225, 255, 0.14), transparent 70%);
  opacity: 0;
}

/* center tube catches first, the rest follow outward */
.tubes i:nth-child(2) { --d: 0.46s; }
.tubes i:nth-child(4) { --d: 0.58s; }
.tubes i:nth-child(1) { --d: 0.74s; }
.tubes i:nth-child(5) { --d: 0.84s; }

.is-lit .tubes i { animation: tube-on 1.3s linear var(--d) both; }
.is-lit .tubes i::after { animation: flicker-on 1.3s linear var(--d) both; }

@keyframes tube-on {
  0%, 5%, 11%, 19%   { background: #16171b; box-shadow: none; }
  6%, 10%, 14%, 18%,
  24%, 100%          { background: #f3f6ff; box-shadow: 0 0 10px 1px rgba(230, 238, 255, 0.9), 0 0 42px 8px rgba(200, 215, 255, 0.28); }
}

@keyframes flicker-on {
  0%, 5%, 11%, 19%   { opacity: 0; }
  6%, 10%            { opacity: 0.8; }
  14%, 18%           { opacity: 0.6; }
  24%, 100%          { opacity: 1; }
}

/* ---------- chrome ---------- */

/* sits in the stage's bottom padding and moves down if content runs long */
.foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px 12px;
  padding: 14px 16px max(18px, env(safe-area-inset-bottom));
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  pointer-events: none;
}

.credit {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
  transition: color 0.2s ease;
}

.credit:hover,
.credit:focus-visible { color: var(--fg); }
.credit:focus-visible { outline: 1px solid var(--blue); outline-offset: 3px; }

/* phones: stack the credit under the copyright */
@media (max-width: 560px) {
  .foot { flex-direction: column; padding-top: 10px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .foot-sep { display: none; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

/* ---------- stage ---------- */

.stage {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 3.4vh, 36px);
  padding: 44px 16px 84px;
  text-align: center;
}

/* ---------- the mark ---------- */

.mark {
  position: relative;
  margin: 0;
  /* fill what the copy, form and footer leave free, keeping the logo's 713:611 ratio */
  width: max(var(--mark-min), min(88vw, 640px, calc((100svh - var(--reserve)) * 1.167)));
  aspect-ratio: 713 / 611;
  font-size: inherit;
  transition: width 0.8s var(--ease-out) 0.2s;
  animation: emerge 2.6s var(--ease-out) 0.4s both;
}

.mark-layer,
.mark-emboss {
  position: absolute;
  inset: 0;
  display: block;
}

.mark-layer {
  -webkit-mask: var(--logo) center / contain no-repeat;
  mask: var(--logo) center / contain no-repeat;
}

/* pressed-in edge so the dark logo reads as an object, not a hole */
.mark-emboss {
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.045)) drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.9));
}

.mark-base {
  background: linear-gradient(180deg, #08080a 0%, #040405 70%);
}

.mark-sheen {
  background: linear-gradient(
    105deg,
    transparent 41%,
    rgba(255, 255, 255, 0.14) 46%,
    rgba(255, 255, 255, 0.65) 50%,
    rgba(255, 255, 255, 0.14) 54%,
    transparent 59%
  );
  background-size: 250% 100%;
  background-position: 100% 0;
  animation: sheen 6s ease-in-out 2.2s infinite;
}

/* sweep takes ~1.8s, then a ~4s pause */
@keyframes sheen {
  0%        { background-position: 100% 0; }
  30%, 100% { background-position: 0% 0; }
}

/* under the overhead lights the logo reads as brushed steel, lit from above */
.mark-lit {
  background: linear-gradient(180deg, #f5f6f9 0%, #c9cdd6 30%, #858a95 66%, #43464f 100%);
  opacity: 0;
}

.is-lit .mark-lit { animation: logo-lit 1.3s linear 0.3s both; }

.is-lit .mark-emboss {
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.7));
  transition: filter 0.8s ease 0.5s;
}

@keyframes logo-lit {
  0%, 5%, 11%, 19%   { opacity: 0; }
  6%, 10%            { opacity: 0.7; }
  14%, 18%           { opacity: 0.55; }
  24%, 100%          { opacity: 0.92; }
}

@keyframes emerge {
  from { opacity: 0; transform: scale(1.03); filter: blur(6px); }
  to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- signup ---------- */

.signup {
  width: min(460px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.headline {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(32px, 4.2vw, 50px);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  animation: rise 1.2s var(--ease-out) 1.5s both;
}

.headline em {
  font-style: normal;
  color: var(--blue);
  text-shadow: 0 0 22px rgba(31, 81, 255, 0.6);
}

/* opacity belongs to the intro animation, so the post-signup swap fades via filter */
.headline { transition: filter 0.3s ease; }
.headline.is-swapping { filter: opacity(0) blur(4px); }

.sub {
  margin: 14px 0 24px;
  max-width: 38ch;
  font-size: 12px;
  line-height: 1.75;
  color: var(--muted);
  transition: color 0.3s ease;
  animation: rise 1.2s var(--ease-out) 1.65s both;
}

/* opacity belongs to the intro animation, so fade text via colour when swapping it */
.sub.is-swapping { color: transparent; }

.form {
  position: relative;
  width: 100%;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(6px);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  animation: rise 1.2s var(--ease-out) 1.8s both;
}

/* the focus glow beats with the pulse */
.form:focus-within {
  border-color: var(--blue);
  box-shadow:
    0 0 0 1px var(--blue),
    0 0 calc(18px + var(--beat) * 26px) rgba(31, 81, 255, calc(0.18 + var(--beat) * 0.3));
}

.form[hidden] { display: none; }

.form.is-leaving {
  pointer-events: none;
  animation: rise 1.2s var(--ease-out) 1.8s both, leave 0.35s ease forwards;
}

@keyframes leave {
  to { opacity: 0; transform: translateY(6px) scale(0.98); }
}

/* once the intro has played, drop it so re-showing the form (after a failed save)
   doesn't replay the delayed fade-in */
.form.intro-done { animation: none; }
.form.intro-done.is-error { animation: shake 0.4s ease; }
.form.intro-done.is-leaving { animation: leave 0.35s ease forwards; }

/* keep the intro animation in the list so toggling the error class doesn't replay it */
.form.is-error {
  border-color: var(--error);
  box-shadow: none;
  animation: rise 1.2s var(--ease-out) 1.8s both, shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}

.input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: 400 16px/1 var(--mono);
  letter-spacing: -0.02em;
  caret-color: var(--blue);
}

.input::placeholder { color: var(--dim); opacity: 1; }
.input:focus { outline: none; }
.input:disabled { color: var(--muted); }

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.button {
  flex: none;
  min-width: 112px;
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 0;
  background: var(--blue);
  color: #fff;
  font: 800 19px/1 var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.button:hover { background: var(--blue-hi); box-shadow: 0 0 28px var(--blue-glow); }
.button:active { transform: translateY(1px); }
.button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.button:disabled { cursor: default; }
.button[aria-busy="true"] .button-label { animation: blink 0.9s ease-in-out infinite; }

.note {
  min-height: 1.75em;
  margin: 14px 0 0;
  font-size: 11px;
  line-height: 1.75;
  color: var(--dim);
  animation: rise 1.2s var(--ease-out) 1.95s both;
}

.note.is-error { color: var(--error); }

/* holds the form, then the card; its height glides between them (set in main.js)
   in step with the logo shrinking, so nothing on the page jumps */
.swap {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: height 0.8s var(--ease-out) 0.2s;
}

.note.is-fading { color: transparent; transition: color 0.25s ease; }

/* shows in the card's spot only if the save is slow */
.printing {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.printing.is-on { opacity: 1; }
.printing span { margin-left: 6px; animation: blink 0.9s ease-in-out infinite; }

/* ---------- the list card ---------- */

.pass-wrap {
  width: min(340px, 100%);
  margin-top: 2px;
  animation: pass-in 1.1s var(--ease-out) 0.55s both;
}

.pass-wrap[hidden] { display: none; }

@keyframes pass-in {
  from { opacity: 0; transform: perspective(900px) rotateX(-75deg) translateY(24px); }
  to   { opacity: 1; transform: perspective(900px) rotateX(0) translateY(0); }
}

/* holo foil: black card, shifting blue/violet foil cut into fine lines,
   a giant outlined number behind, and a foil-printed number in front */
.pass {
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  isolation: isolate;
  aspect-ratio: 1.586;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 16px 18px 14px;
  overflow: hidden;
  border-radius: 16px;
  background: #07070a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.09),
    0 40px 70px -30px rgba(0, 0, 0, 0.95),
    0 0 60px -14px rgba(120, 160, 255, 0.45);
  text-align: left;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transition: transform 0.3s var(--ease-out);
  --foil-ink: linear-gradient(115deg, #8fb0ff, #3d68ff, #1f51ff, #6f9dff, #dfe9ff, #2f5cff);
}

.pass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(115deg, #1f51ff, #6fe3ff, #3d68ff, #ffffff, #6f8cff, #1f51ff);
  background-size: 300% 300%;
  opacity: 0.26;
  -webkit-mask: repeating-linear-gradient(115deg, #000 0 2px, rgba(0, 0, 0, 0.3) 2px 5px);
  mask: repeating-linear-gradient(115deg, #000 0 2px, rgba(0, 0, 0, 0.3) 2px 5px);
  animation: holo 7s ease-in-out infinite alternate;
}

@keyframes holo {
  from { background-position: 0% 50%; }
  to   { background-position: 100% 50%; }
}

.pass-big {
  position: absolute;
  right: -12px;
  bottom: -34px;
  z-index: -1;
  font: 800 210px/0.8 var(--display);
  letter-spacing: -0.02em;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(170, 195, 255, 0.35);
  pointer-events: none;
}

.pass-top { display: flex; align-items: center; gap: 10px; }

/* the flexing athlete from the logo, cropped to its round medallion */
.pass-logo {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--foil-ink);
  background-size: 300% 300%;
  -webkit-mask: var(--logo) 50% 53% / 96px auto no-repeat;
  mask: var(--logo) 50% 53% / 96px auto no-repeat;
  filter: drop-shadow(0 0 6px rgba(170, 190, 255, 0.3));
  animation: holo 7s ease-in-out infinite alternate;
}

.pass-brand,
.pass-chip {
  font: 500 8.5px/1.35 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.pass-brand { color: #aab3c8; }

.pass-chip {
  margin-left: auto;
  padding: 5px 8px;
  border: 1px solid rgba(180, 200, 255, 0.55);
  border-radius: 3px;
  color: #dfe6ff;
}

.pass-mid { align-self: end; display: flex; align-items: baseline; gap: 8px; }

.pass-no {
  font: 800 22px/1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9fb3ff;
}

.pass-number {
  font: 800 72px/0.82 var(--display);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  background: var(--foil-ink);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: holo 7s ease-in-out infinite alternate;
}

.pass-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-top: 10px;
  font: 400 9px/1.4 var(--mono);
  letter-spacing: 0.08em;
  color: #9097a8;
}

.pass-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pass-date { flex: none; text-transform: uppercase; }

/* ---------- layout tweaks ---------- */

@media (max-width: 520px) {
  .sub { font-size: 11.5px; }
  .tubes i:nth-child(1), .tubes i:nth-child(5) { display: none; }
  .pass-number { font-size: 64px; }
  .button { min-width: 96px; padding: 0 16px; }
}

@media (max-width: 340px) {
  .form { flex-direction: column; }
  .button { width: 100%; }
}

/* short laptop windows: tighten so the list card still fits without scrolling */
@media (max-height: 760px) {
  :root { --mark-min: 170px; }
  body.is-lit { --reserve: 520px; }
  .stage { gap: 18px; padding-bottom: 60px; }
  .sub { margin: 10px 0 16px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .stage { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  .grain { animation: none; }
  .mark-sheen { display: none; }
}
