/* ==========================================================================
   Stokly waitlist — mobile first.

   Pure #000000, everything white. The "S" is the only thing on the page that
   carries colour: a soft wide bloom behind a white glyph, lit from wherever
   the cursor is.
   ========================================================================== */

:root {
  --bg:      #000000;
  --text:    #FFFFFF;
  --text-2:  rgba(255,255,255,0.56);
  --text-3:  rgba(255,255,255,0.32);
  --text-4:  rgba(255,255,255,0.18);

  --line:    rgba(255,255,255,0.12);
  --line-2:  rgba(255,255,255,0.08);
  --fill:    rgba(255,255,255,0.05);
  --fill-2:  rgba(255,255,255,0.09);

  /* Knockout on the white button — the app's label colour, not pure black. */
  --knockout: #04060C;
  --down:     #FF5F57;

  /* The glow. PLUS_GRADIENT from the app's lib/subscription.ts. */
  --glow-1: #9BE7FF;
  --glow-2: #4FC1FF;
  --glow-3: #1E5BFF;

  --r-control: 18px;
  --r-chip:    14px;
  --r-pill:    999px;

  --pad:  20px;
  --gap:  14px;
  --maxw: 460px;

  --font: 'SF Pro Rounded', -apple-system, ui-rounded, 'Nunito',
          system-ui, 'Segoe UI', Roboto, sans-serif;

  /* Driven by main.js; these defaults stand in when JS is off. */
  --px: 50%;
  --py: 42%;
  --shift-x: 0px;
  --shift-y: 0px;
  --prox: 0.45;
  --tilt-x: 0deg;
  --tilt-y: 0deg;

  --ease: cubic-bezier(0.22, 0.9, 0.28, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

/* --------------------------------------------------------------------------
   Top bar — the name lives up here now
   -------------------------------------------------------------------------- */

.bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) var(--pad) 16px;
  border-bottom: 1px solid var(--line-2);
}

.bar__name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.bar__status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
}

.bar__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text);
  animation: pulse 2.6s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--pad) calc(28px + env(safe-area-inset-bottom));
  isolation: isolate;
}

/* Ambient light trailing the cursor. Kept very low so black stays black. */
.hero__spot {
  position: absolute;
  inset: -10% 0 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    50vmax 50vmax at var(--px) var(--py),
    rgba(79,193,255,0.10),
    rgba(30,91,255,0.04) 44%,
    transparent 70%
  );
  opacity: calc(0.4 + 0.6 * var(--prox));
}

.col {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* --------------------------------------------------------------------------
   The mark — three quarters of the screen on a phone
   -------------------------------------------------------------------------- */

.lockup {
  transform: perspective(1000px)
             rotateX(var(--tilt-x))
             rotateY(var(--tilt-y));
  will-change: transform;
}

.mark {
  position: relative;
  width: min(75vw, 340px);      /* 3/4 of a phone screen, capped on desktop */
  margin: 6vh auto 5vh;
}

.mark img {
  display: block;
  width: 100%;
  height: auto;
}

/* Two copies of the same glyph. The lower one carries a heavy drop-shadow
   stack; the upper one is the crisp white mark that sits on top of it.
   drop-shadow follows the PNG's alpha, so the light hugs the letterform and
   radiates outward into the black — the counters inside the S stay black,
   which a gradient sitting behind the mark could never do.

   Only opacity and transform move per frame. The filters are static: three
   gaussian blurs are far too expensive to recompute 60 times a second,
   especially on a phone. */
.mark__glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  filter:
    drop-shadow(0 0 10px  rgba(155,231,255,0.72))
    drop-shadow(0 0 34px  rgba(79,193,255,0.62))
    drop-shadow(0 0 76px  rgba(30,91,255,0.55))
    drop-shadow(0 0 140px rgba(30,91,255,0.38));
  opacity: calc(0.42 + 0.58 * var(--prox));
  transform: translate3d(var(--shift-x, 0px), var(--shift-y, 0px), 0);
  will-change: opacity, transform;
}

/* A tight white rim on the mark itself, so it reads as lit rather than as a
   flat cut-out sitting in front of a haze. */
.mark__glyph {
  position: relative;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.30));
}

/* No cursor to follow (phones, tablets). The glow drifts on a keyframe so the
   light still moves, with no JavaScript running per frame — opacity and
   transform only, so it stays on the compositor and barely touches the
   battery. */
.no-pointer .mark__glow {
  animation: drift 11s var(--ease) infinite alternate;
}

@keyframes drift {
  0%   { transform: translate3d(-9px, -5px, 0); opacity: 0.52; }
  50%  { transform: translate3d( 6px,  5px, 0); opacity: 0.92; }
  100% { transform: translate3d( 9px, -3px, 0); opacity: 0.66; }
}

/* Once the gyroscope is driving the glow, the idle drift stops and the mark
   leans with the phone instead. Deliberately outside the phone media query:
   a touch tablet is wider than 700px but still has a gyroscope. */
.motion .mark__glow { animation: none; }

/* --------------------------------------------------------------------------
   Copy
   -------------------------------------------------------------------------- */

.tagline {
  margin: 0 0 12px;
  font-size: clamp(24px, 6.4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.2;
  color: var(--text);
}

.sub {
  margin: 0 0 30px;
  max-width: 40ch;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text-2);
}

/* --------------------------------------------------------------------------
   Form ↔ thank-you
   -------------------------------------------------------------------------- */

.panels {
  position: relative;
  width: 100%;
  display: grid;   /* row height = the taller panel, so the swap has no jump */
}

.panel {
  grid-area: 1 / 1;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}

.panel--thanks {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  visibility: hidden;
}

.hero[data-state='thanks'] .panel--form {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  visibility: hidden;
}

.hero[data-state='thanks'] .panel--thanks {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition-delay: 260ms;
}

.form { display: flex; flex-direction: column; }

.field {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 58px;
  padding: 0 18px;
  background: var(--fill);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  transition: border-color 180ms linear, background-color 180ms linear;
}

.field:focus-within {
  border-color: rgba(255,255,255,0.5);
  background: var(--fill-2);
}

.field__icon {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--text-3);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 180ms linear;
}
.field:focus-within .field__icon { stroke: var(--text); }

.field input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;         /* 16px keeps iOS Safari from zooming on focus */
  font-weight: 600;
  letter-spacing: -0.2px;
}
.field input::placeholder { color: var(--text-3); font-weight: 600; }

/* Invalid: rim goes red, nothing moves. The app never uses transforms for
   feedback, only colour and opacity. */
.field.is-error {
  border-color: rgba(255,95,87,0.65);
  background: rgba(255,95,87,0.06);
}
.field.is-error .field__icon { stroke: var(--down); }

.error {
  margin: 0;
  max-height: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  color: var(--down);
  text-align: left;
  opacity: 0;
  transition: max-height 200ms var(--ease), opacity 200ms linear,
              margin 200ms var(--ease);
}
.error.is-shown { max-height: 40px; margin: 9px 2px 0; opacity: 1; }

/* "Already registered" is information, not an error — the person did nothing
   wrong and there is nothing to correct, so it does not go red. */
.error.is-notice { color: var(--text-2); font-weight: 600; }

/* Plain white button. */
.cta {
  margin-top: var(--gap);
  height: 58px;
  width: 100%;
  border: 0;
  border-radius: var(--r-control);
  cursor: pointer;
  background: #FFFFFF;
  color: var(--knockout);
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
  transition: opacity 140ms linear;
  -webkit-tap-highlight-color: transparent;
}
.cta:hover  { opacity: 0.86; }
.cta:active { opacity: 0.68; }

/* Waiting on Supabase. Pointer events off so a double tap cannot fire a
   second insert while the first is still in flight. */
.cta.is-busy,
.cta:disabled {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

.cta__label { display: inline-block; vertical-align: middle; }

.cta__spinner {
  display: none;
  width: 15px;
  height: 15px;
  margin-right: 9px;
  vertical-align: middle;
  border: 2px solid rgba(4,6,12,0.25);
  border-top-color: var(--knockout);
  border-radius: 50%;
  animation: spin 620ms linear infinite;
}
.cta.is-busy .cta__spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.micro {
  margin: 13px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-3);
}

/* Thank-you */

.check { width: 52px; height: 52px; margin: 0 auto 16px; }
.check svg {
  width: 100%; height: 100%;
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

/* The drawn state is what the thanks state declares, and the keyframes animate
   *from* hidden — so a browser that never runs the animation still shows the
   checkmark. Declaring it the other way round fails to an invisible tick. */
.check__ring {
  stroke: var(--text);
  stroke-width: 2;
  opacity: 0.3;
  stroke-dasharray: 145;
  stroke-dashoffset: 145;
}
.check__tick {
  stroke: var(--text);
  stroke-width: 3.2;
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
}

.hero[data-state='thanks'] .check__ring {
  stroke-dashoffset: 0;
  animation: draw-ring 520ms var(--ease) 300ms backwards;
}
.hero[data-state='thanks'] .check__tick {
  stroke-dashoffset: 0;
  animation: draw-tick 380ms var(--ease) 560ms backwards;
}

@keyframes draw-ring { from { stroke-dashoffset: 145; } }
@keyframes draw-tick { from { stroke-dashoffset: 34;  } }

.thanks__title {
  margin: 0 0 9px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.6px;
}

.thanks__body {
  margin: 0 auto;
  max-width: 34ch;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text-2);
}

.thanks__mail {
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.linkbtn {
  margin-top: 18px;
  height: 36px;
  padding: 0 14px;
  background: none;
  border: 0;
  border-radius: var(--r-chip);
  color: var(--text-3);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: color 140ms linear;
  -webkit-tap-highlight-color: transparent;
}
.linkbtn:hover { color: var(--text-2); }

/* --------------------------------------------------------------------------
   Feature strip — stacked on a phone
   -------------------------------------------------------------------------- */

.features {
  display: grid;
  gap: 22px;
  width: 100%;
  margin: 40px 0 0;
  padding: 30px 0 0;
  list-style: none;
  border-top: 1px solid var(--line-2);
}

.feature {
  display: grid;
  grid-template-columns: 20px 1fr;
  column-gap: 13px;
  text-align: left;
}

.feature__icon {
  grid-row: 1 / 3;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  fill: none;
  stroke: var(--text-2);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feature__title {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.2px;
  color: var(--text);
}

.feature__body {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-top: 44px;
}

.socials { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.social {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  transition: color 160ms linear, background-color 160ms linear;
  -webkit-tap-highlight-color: transparent;
}
.social:hover { color: var(--text); background: var(--fill); }
.social[data-soon] { cursor: not-allowed; }

.social__glyph { width: 16px; height: 16px; fill: currentColor; }
.social__glyph--stroke { fill: none; stroke: currentColor; stroke-width: 1.7; }
.social__glyph--stroke .dot { fill: currentColor; stroke: none; }

.legal {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-4);
}

/* --------------------------------------------------------------------------
   Focus rings — keyboard only
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid #FFFFFF;
  outline-offset: 3px;
  border-radius: var(--r-chip);
}
.field:focus-within { outline: none; }

/* --------------------------------------------------------------------------
   Wider screens
   -------------------------------------------------------------------------- */

@media (min-width: 700px) {
  :root { --maxw: 760px; }

  .bar { padding-left: 32px; padding-right: 32px; }

  .hero { min-height: calc(100svh - 62px); justify-content: center; }

  .mark { margin: 4vh auto 4vh; }

  .col > .tagline,
  .col > .sub,
  .col > .panels { max-width: 460px; }

  .features {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
    margin-top: 46px;
    padding-top: 34px;
  }

  .feature { display: block; }
  .feature__icon { margin: 0 0 11px; }
}

/* --------------------------------------------------------------------------
   Phone only — the desktop layout above is deliberately left alone
   -------------------------------------------------------------------------- */

@media (max-width: 699px) {
  /* No rule under the bar; the mark's own light is the only separation. */
  .bar { border-bottom: 0; }

  /* On a narrow screen 50vmax is measured against the *height*, so the
     ambient wash reached the corners and tinted them blue. Sized off vmin
     and dimmed so it stays a pool of light behind the mark. */
  .hero__spot {
    background: radial-gradient(
      42vmin 42vmin at var(--px) var(--py),
      rgba(79,193,255,0.055),
      rgba(30,91,255,0.02) 46%,
      transparent 68%
    );
    opacity: calc(0.3 + 0.4 * var(--prox));
  }

  /* Tighter and softer: the widest 140px shadow is dropped entirely, since
     that was what spilled colour across the whole viewport. */
  .mark__glow {
    filter:
      drop-shadow(0 0 8px  rgba(155,231,255,0.52))
      drop-shadow(0 0 24px rgba(79,193,255,0.40))
      drop-shadow(0 0 54px rgba(30,91,255,0.30));
    opacity: calc(0.38 + 0.42 * var(--prox));
  }

  .mark__glyph { filter: drop-shadow(0 0 5px rgba(255,255,255,0.24)); }

  @keyframes drift {
    0%   { transform: translate3d(-9px, -5px, 0); opacity: 0.44; }
    50%  { transform: translate3d( 6px,  5px, 0); opacity: 0.72; }
    100% { transform: translate3d( 9px, -3px, 0); opacity: 0.52; }
  }

  /* Tap the mark: the light swells and settles. */
  .mark { cursor: pointer; -webkit-tap-highlight-color: transparent; }

  .mark.is-pulsing .mark__glow {
    animation: pulse-glow 900ms var(--ease);
  }
  .mark.is-pulsing .mark__glyph {
    animation: pulse-glyph 900ms var(--ease);
  }

  @keyframes pulse-glow {
    0%   { opacity: 0.38; transform: scale(1); }
    22%  { opacity: 1;    transform: scale(1.09); }
    100% { opacity: 0.38; transform: scale(1); }
  }

  @keyframes pulse-glyph {
    0%, 100% { filter: drop-shadow(0 0 5px  rgba(255,255,255,0.24)); }
    22%      { filter: drop-shadow(0 0 16px rgba(255,255,255,0.75)); }
  }

}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .lockup     { transform: none; }
  .bar__dot   { animation: none; opacity: 1; }
  .hero__spot { opacity: 0.5; }
  .mark__glow { opacity: 0.7; animation: none; transform: none; }

  .mark.is-pulsing .mark__glow,
  .mark.is-pulsing .mark__glyph { animation: none; }

  /* The spinner still needs to read as "working", so it stays visible and
     simply does not rotate. */
  .cta__spinner { animation: none; }

  .hero[data-state='thanks'] .check__ring,
  .hero[data-state='thanks'] .check__tick { animation: none; }

  .panel { transition-duration: 1ms; }
  .hero[data-state='thanks'] .panel--thanks { transition-delay: 0ms; }
}
