/* ============================================================
   Loop — landing page
   Tilted vertical video wall: 3 big columns scrolling in
   opposite directions behind centered content.
   Reference: on.design/claim (but tilted + vertical + videos)
   ============================================================ */

/* -------- Tokens -------- */
:root {
  /* Near-black / near-white with a faint cool tint.
     Never pure #000 / #fff by house rule. */
  --bg:          oklch(0.07 0.003 250);
  --bg-raised:   oklch(0.11 0.003 250);
  --bg-elev:     oklch(0.13 0.004 250);
  --fg:          oklch(0.98 0.002 250);
  --fg-strong:   oklch(0.99 0.002 250);
  --muted:       oklch(0.66 0.005 250);
  --muted-quiet: oklch(0.48 0.005 250);
  --rule:        oklch(0.22 0.004 250);
  --rule-soft:   oklch(0.16 0.004 250);
  --signal:      oklch(0.77 0.16 142);

  --sans: "aileron", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --mono: "aileron", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", sans-serif;

  --ease:     cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --gutter: clamp(1rem, 3vw, 2rem);
  --stage-max: 34rem;

  /* Tilt + scroll */
  --tilt: -9deg;
  --col-gap: clamp(0.5rem, 1vw, 0.9rem);
  --tile-gap: clamp(0.5rem, 1vw, 0.9rem);
  --scroll-duration: 95s;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  overflow-x: hidden;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input  { font: inherit; color: inherit; }

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--fg);
  color: var(--bg);
}

/* -------- Top bar -------- */
.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(1rem, 2.2vh, 1.4rem) var(--gutter);
  border-bottom: 1px solid var(--rule-soft);
  background: color-mix(in oklch, var(--bg), transparent 10%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--fg);
  text-decoration: none;
}

.topbar__mark { width: 18px; height: 18px; color: var(--fg); }

.topbar__wordmark {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--muted);
}

.topbar__status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--signal);
  animation: pulse 2.4s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--signal), transparent 40%); }
  50%      { box-shadow: 0 0 0 4px color-mix(in oklch, var(--signal), transparent 92%); }
}

.topbar__status-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10px;
}

.topbar__rule {
  display: inline-block;
  width: 1px;
  height: 10px;
  background: var(--rule);
}

.topbar__time { font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .topbar__status-label { display: none; }
  .topbar__meta { gap: 0.55rem; }
}

/* ============================================================
   TILTED VIDEO WALL
   .wall           — full-bleed absolute container (clips overflow)
   .wall__plane    — the rotated plane; oversized to cover viewport
   .wall__col      — a single vertical column
   .wall__track    — the scrolling content inside the column
   .wall__tile     — one video tile
   .wall__overlay  — radial darkening + vignette
   ============================================================ */
.wall {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.wall__plane {
  /* The plane must be big enough that, once rotated by --tilt,
     it still covers the entire viewport without white corners. */
  position: absolute;
  top: 50%;
  left: 50%;
  width: 160vmax;
  height: 180vmax;
  transform: translate(-50%, -50%) rotate(var(--tilt));
  transform-origin: center center;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--col-gap);
  will-change: transform;
}

.wall__col {
  position: relative;
  overflow: hidden;
  /* Each column flexes its own track vertically */
}

.wall__track {
  display: flex;
  flex-direction: column;
  gap: var(--tile-gap);
  padding-block: var(--tile-gap);
  will-change: transform;
}

.wall__track--up {
  animation: scroll-up var(--scroll-duration) linear infinite;
}
.wall__track--down {
  animation: scroll-down var(--scroll-duration) linear infinite;
}

@keyframes scroll-up {
  /* Track height contains the unique set twice; shift by half. */
  from { transform: translateY(0); }
  to   { transform: translateY(calc(-50% - var(--tile-gap) / 2)); }
}

@keyframes scroll-down {
  from { transform: translateY(calc(-50% - var(--tile-gap) / 2)); }
  to   { transform: translateY(0); }
}

.wall__tile {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: var(--bg-elev);
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 40px 90px -40px rgba(0, 0, 0, 0.9),
    0 20px 50px -25px rgba(0, 0, 0, 0.7);

  /* Two-stage reveal:
     1. Tile itself fades in on mount (--ready) so you always see the
        dark rectangle silhouettes of the wall, even if videos are
        still loading or fail to load.
     2. Video inside fades in separately (--video-ready) once its
        first frame is decoded. This prevents "ghost" tiles where a
        slow network makes videos never appear. */
  opacity: 0;
  transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity;

  /* Let the browser skip rendering work for tiles that have scrolled
     outside the rotated plane's visible area. Dimensions hint keeps
     layout stable while they're un-painted. */
  content-visibility: auto;
  contain-intrinsic-size: 420px;
}

.wall__tile--ready {
  opacity: 1;
}

.wall__tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: contrast(1.06) saturate(0.92) brightness(0.86);
  opacity: 0;
  transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

.wall__tile--video-ready video {
  opacity: 1;
}

/* Each column starts at a different phase so the tiles never
   transition in lockstep. */
.wall__col:nth-child(2) .wall__track {
  animation-delay: calc(var(--scroll-duration) * -0.28);
}
.wall__col:nth-child(3) .wall__track {
  animation-delay: calc(var(--scroll-duration) * -0.52);
}
.wall__col:nth-child(4) .wall__track {
  animation-delay: calc(var(--scroll-duration) * -0.76);
}

/* -------- Wall overlay (center spotlight) -------- */
.wall__overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 60% 50% at 50% 50%,
      oklch(0.07 0.003 250 / 0.94) 0%,
      oklch(0.07 0.003 250 / 0.82) 28%,
      oklch(0.07 0.003 250 / 0.55) 58%,
      oklch(0.07 0.003 250 / 0.25) 85%,
      oklch(0.07 0.003 250 / 0.0)  100%
    ),
    linear-gradient(
      180deg,
      var(--bg) 0%,
      transparent 14%,
      transparent 100%
    );
}

/* -------- Stage (centered content on top of wall) -------- */
.stage {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(2.5rem, 6vh, 4.5rem) var(--gutter);
  gap: clamp(1.75rem, 4vh, 2.75rem);
  max-width: var(--stage-max);
  margin: 0 auto;
  width: 100%;
  text-align: center;
}

/* -------- App icon -------- */
.app-icon {
  display: block;
  width: clamp(120px, 16vw, 160px);
  height: auto;
  aspect-ratio: 1 / 1;
  /* Let the browser use high-quality bilinear downscaling for the
     photographic icon. Previous -webkit-optimize-contrast hint was
     actually counterproductive — it's meant for pixel art. */
  image-rendering: auto;
  -ms-interpolation-mode: bicubic;
  /* Subtle hairline outline + layered shadows for depth on dark bg */
  filter:
    drop-shadow(0 0 0.5px rgba(255, 255, 255, 0.35))
    drop-shadow(0 18px 40px rgba(0, 0, 0, 0.55))
    drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  opacity: 0;
  animation: rise 1.1s var(--ease-out) 0.1s forwards;
  user-select: none;
  -webkit-user-drag: none;
}

/* -------- Headline -------- */
.headline {
  opacity: 0;
  animation: rise 1.1s var(--ease-out) 0.2s forwards;
  max-width: none;
}

.headline__title {
  font-family: var(--sans);
  /* Fluid size tuned so the whole line fits on a single row from
     ~320px up to desktop without wrapping. */
  font-size: clamp(1.5rem, 4.2vw, 2.75rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.028em;
  margin: 0 0 clamp(0.9rem, 2vh, 1.2rem);
  color: var(--fg-strong);
  white-space: nowrap;
  text-shadow:
    0 2px 24px rgba(0, 0, 0, 0.85),
    0 0 80px rgba(0, 0, 0, 0.7);
}

.headline__em {
  color: inherit;
  font-weight: inherit;
  margin: 0 0.14em;
}

.headline__lede {
  font-family: var(--sans);
  font-size: clamp(0.95rem, 1.2vw, 1.08rem);
  font-weight: 400;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.55);
  margin: 0;
  max-width: 30rem;
  margin-inline: auto;
  text-wrap: pretty;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

/* -------- Claim form -------- */
.claim {
  position: relative;
  opacity: 0;
  animation: rise 1.1s var(--ease-out) 0.3s forwards;
  width: 100%;
  max-width: 27rem;
}

.claim__row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.14);
  border: 0;
  /* Concentric radius: outer = inner(11) + padding(7) = 18 */
  border-radius: 18px;
  padding: 7px 7px 7px 1.25rem;
  backdrop-filter: blur(32px) saturate(140%);
  -webkit-backdrop-filter: blur(32px) saturate(140%);
  transition: background 0.3s var(--ease);
  box-shadow:
    0 30px 80px -30px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 0 rgba(0, 0, 0, 0.15);
}

.claim__row:focus-within {
  background: rgba(255, 255, 255, 0.22);
}

.claim__input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  padding: 0.72rem 0;
  font-family: var(--sans);
  font-size: 16px;
  color: var(--fg);
  letter-spacing: -0.005em;
}

.claim__input::placeholder {
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--sans);
  font-size: 16px;
}

.claim__submit {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  border-radius: 11px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  transition:
    background 0.25s var(--ease),
    transform 0.25s var(--ease),
    opacity 0.25s var(--ease);
  white-space: nowrap;
}

.claim__submit:hover,
.claim__submit:focus-visible {
  background: color-mix(in oklch, var(--fg), var(--bg) 8%);
}

.claim__submit:active { transform: scale(0.96); }
.claim__submit[disabled] { opacity: 0.5; pointer-events: none; }

.claim__arrow {
  width: 14px;
  height: 14px;
  transition: transform 0.25s var(--ease);
}

.claim__submit:hover .claim__arrow { transform: translateX(2px); }

.claim__error {
  /* Absolute-positioned below the form so it animates in without
     pushing content above it. Stays in layout even when [hidden]
     so the transition plays cleanly in both directions. */
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.6rem);
  margin: 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: color-mix(in oklch, var(--fg), #ff6b6b 55%);
  text-align: center;
  opacity: 0;
  transform: translateY(-4px);
  transition:
    opacity 0.35s var(--ease-out),
    transform 0.35s var(--ease-out);
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.75);
}

.claim__error[hidden] {
  /* Keep the element in layout so opacity/transform can animate. */
  display: block;
}

.claim__error:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
}

.claim__note {
  margin: 0.95rem 0 0;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-quiet);
  text-align: center;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.75);
}

/* -------- Counter -------- */
.counter {
  opacity: 0;
  animation: rise 1.1s var(--ease-out) 0.55s forwards;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted-quiet);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.75);
}

.counter__num {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* -------- Progressive blur + gradient at bottom --------
   Mirrors the StoryPlayer pattern from the consumer app:
   - A full-width blur panel that's masked so the blur fades
     from fully-applied at the bottom to transparent toward the top.
   - A dark vertical gradient stacked on top for text legibility.
   The combination creates a cinematic bottom-up darkening. */
.bottom-fade {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: clamp(18rem, 42vh, 28rem);
  pointer-events: none;
  z-index: 15;
}

.bottom-fade__blur {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  mask-image: linear-gradient(to top, black 0%, black 45%, transparent 85%);
  -webkit-mask-image: linear-gradient(to top, black 0%, black 45%, transparent 85%);
}

.bottom-fade__gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    oklch(0.07 0.003 250 / 0.92) 0%,
    oklch(0.07 0.003 250 / 0.60) 40%,
    oklch(0.07 0.003 250 / 0.0) 80%
  );
}

/* -------- Bottom center: socials + privacy -------- */
.foot {
  position: fixed;
  left: 50%;
  bottom: clamp(0.75rem, 2vh, 1.25rem);
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.foot__socials {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.foot__social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: rgba(255, 255, 255, 1);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.foot__social svg {
  width: 20px;
  height: 20px;
  display: block;
}

.foot__social:hover,
.foot__social:focus-visible {
  opacity: 0.78;
}

.foot__social:active {
  transform: scale(0.92);
}

.foot__privacy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.45);
  text-decoration: none;
  transition: color 0.25s var(--ease);
}

.foot__privacy:hover,
.foot__privacy:focus-visible {
  color: rgba(255, 255, 255, 0.9);
}

/* -------- Afterword (post-submit) -------- */
.afterword {
  position: fixed;
  inset: 0;
  background: color-mix(in oklch, var(--bg), transparent 2%);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  display: grid;
  place-content: center;
  padding: var(--gutter);
  z-index: 50;
  animation: fadeIn 0.65s var(--ease-out);
  text-align: center;
}

.afterword[hidden] { display: none; }

.afterword__inner { max-width: 32rem; }

.afterword__overline {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.afterword__headline {
  font-family: var(--sans);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 1.25rem;
  color: var(--fg-strong);
}

.afterword__ordinal {
  display: inline-block;
  min-width: 4ch;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.afterword__body {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 2rem;
}

.afterword__refer { margin-bottom: 2rem; }

.afterword__link-row {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.35rem 0.35rem 0.35rem 1rem;
  max-width: 24rem;
  margin: 0 auto;
}

.afterword__refer-url {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--fg);
  background: transparent;
  padding: 0.6rem 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  user-select: all;
}

.afterword__copy {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.95rem;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  transition: background 0.2s var(--ease);
  white-space: nowrap;
}

.afterword__copy:hover {
  background: color-mix(in oklch, var(--fg), var(--bg) 8%);
}

.afterword__copy-icon { width: 13px; height: 13px; }

.afterword__back {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  transition: color 0.2s var(--ease);
}

.afterword__back:hover { color: var(--fg); }

/* -------- Motion keyframes -------- */
@keyframes rise {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* -------- Smaller screens: 4 narrow columns, tiles dialed down -------- */
@media (max-width: 720px) {
  :root {
    --tilt: -9deg;
    --scroll-duration: 60s;
    --col-gap: 0.4rem;
    --tile-gap: 0.4rem;
  }
  .wall__plane {
    grid-template-columns: repeat(4, 1fr);
    /* Plane covers the tilted viewport without corner gaps.
       On mobile (vh > vw), we need enough width to cover the
       viewport after rotation — use vw + buffer instead of vmax. */
    width: 180vw;
    height: 240vh;
  }
  /* All 4 columns visible on mobile — no hiding */
  .wall__col:nth-child(4) { display: block; }
  .wall__col:nth-child(2) .wall__track {
    animation-delay: calc(var(--scroll-duration) * -0.28);
  }
  .wall__col:nth-child(3) .wall__track {
    animation-delay: calc(var(--scroll-duration) * -0.52);
  }
  .wall__col:nth-child(4) .wall__track {
    animation-delay: calc(var(--scroll-duration) * -0.76);
  }
}

@media (max-width: 520px) {
  .stage { gap: clamp(1.5rem, 3vh, 2.25rem); padding-top: clamp(1.5rem, 3vh, 2.5rem); }
  .claim__row   { padding: 0.4rem 0.4rem 0.4rem 1rem; }
  .claim__submit{ padding: 0 0.95rem; }
}

/* -------- Reduced motion -------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .wall__track { animation: none; transform: translateY(-25%); }
  .headline, .claim, .counter { opacity: 1; }
}
