/* Public Short Link page (/short-link).
 *
 * Built on theme-dark.css and auth.css (aurora stage, glass card, fields, gold
 * button, ghost buttons, --auth-* tokens), like the Contact us and MQL Lock
 * pages; this file adds the hero layout, the decorative "long link -> short
 * link" loop, the result card and the "How it works" steps.
 *
 * Layout, mobile first: heading and intro, then the form (or the result
 * card), then the decorative loop, then the steps. From 1024px the form sits
 * in its own column on the right.
 *
 * Motion (only transform and opacity, nothing under prefers-reduced-motion):
 * 1. The decorative loop: CSS keyframes sharing one cycle (--sl-loop), paused
 *    by short-link-page.js while it is off screen (.is-offscreen).
 * 2. Scroll reveal of the steps: the hidden start state applies only after
 *    short-link-page.js has put `sl-reveal` on <html>, so without JavaScript
 *    everything is visible. The heading and the intro never animate in.
 * 3. The Copy button's success state and small hover lifts.
 */

.sl-body {
  --sl-max: clamp(64rem, 50rem + 24vw, 84rem);
  --sl-panel: clamp(24rem, 19rem + 12vw, 36rem);
  --sl-gap: clamp(1.5rem, 1rem + 2vw, 3rem);
  --sl-loop: 6.5s;
  --sl-surface: rgba(17, 18, 24, 0.72);
}

/* The sign-in pages animate their card and form in on load; here nothing is
   hidden before JavaScript runs, so those entrance animations are off. */
.sl-body .auth-card,
.sl-body .auth-form > * {
  animation: none;
}

/* ---------------------------------------------------------------- Stage */

.sl-stage {
  display: block;
  min-height: 0;
  padding-block: clamp(1.5rem, 1rem + 3vw, 4.5rem) clamp(3rem, 2rem + 4vw, 6rem);
}

.sl-shell {
  display: grid;
  gap: clamp(3rem, 2rem + 4vw, 6.5rem);
  width: 100%;
  max-width: var(--sl-max);
  margin-inline: auto;
}

/* ----------------------------------------------------------------- Hero */

.sl-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "copy"
    "panel"
    "visual";
  gap: var(--sl-gap);
  align-items: start;
}

.sl-hero__copy {
  grid-area: copy;
  display: grid;
  justify-items: center;
  gap: clamp(0.85rem, 0.6rem + 0.6vw, 1.35rem);
  min-width: 0;
  text-align: center;
}

.sl-hero__panel {
  grid-area: panel;
  width: 100%;
  max-width: 40rem;
  min-width: 0;
  margin-inline: auto;
}

@media (min-width: 1024px) {
  .sl-hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--sl-panel));
    grid-template-areas:
      "copy panel"
      "visual panel";
    column-gap: clamp(2.5rem, 1rem + 4vw, 6rem);
    align-items: center;
  }

  .sl-hero__copy {
    justify-items: start;
    text-align: start;
  }

  .sl-hero__panel {
    max-width: none;
  }
}

.sl-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: var(--auth-gold-soft);
  color: var(--auth-gold);
  font-size: var(--auth-fs-small);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sl-kicker__pulse {
  position: relative;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background-color: var(--auth-gold);
}

.sl-kicker__pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-color: var(--auth-gold);
  opacity: 0;
}

.sl-hero__title {
  max-width: 18ch;
  font-family: var(--font-brand);
  font-size: clamp(2rem, 1.15rem + 2.8vw, 3.75rem);
  font-weight: var(--font-weight-brand);
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.sl-hero__lead {
  max-width: 38em;
  color: var(--auth-muted);
  font-size: clamp(1rem, 0.92rem + 0.35vw, 1.25rem);
  line-height: 1.65;
}

.sl-points {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: start;
}

.sl-points__item {
  display: flex;
  align-items: center;
  gap: 0.7em;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
}

.sl-points__icon {
  flex: 0 0 auto;
  width: 1.75em;
  height: 1.75em;
  padding: 0.38em;
  border: 1px solid var(--auth-line);
  border-radius: 50%;
  background-color: var(--auth-gold-soft);
  color: var(--auth-gold);
}

/* ------------------------------------------------- Decorative loop (hero) */

.sl-visual {
  grid-area: visual;
  display: flex;
  justify-content: center;
  min-width: 0;
}

@media (min-width: 1024px) {
  .sl-visual {
    justify-content: flex-start;
  }
}

.sl-visual__card {
  display: grid;
  gap: 0.5rem;
  width: min(100%, 25rem);
  padding: clamp(1rem, 0.8rem + 0.8vw, 1.5rem);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
  box-shadow: 0 30px 60px -36px rgba(0, 0, 0, 0.9);
}

/* The long address: grey "words" that shrink while it is being shortened. */
.sl-visual__long {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  height: 2.75rem;
  padding: 0 1rem;
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: var(--radius-pill);
  background-color: rgba(255, 255, 255, 0.035);
}

.sl-visual__dot {
  flex: 0 0 auto;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background-color: var(--auth-subtle);
}

.sl-visual__seg {
  height: 0.5rem;
  border-radius: var(--radius-pill);
  background-color: rgba(255, 255, 255, 0.18);
  transform-origin: left center;
}

.sl-visual__seg--1 { flex: 0 0 22%; }
.sl-visual__seg--2 { flex: 0 0 16%; }
.sl-visual__seg--3 { flex: 0 0 24%; }
.sl-visual__seg--4 { flex: 0 0 10%; }
.sl-visual__seg--5 { flex: 0 0 14%; }

/* The chain in the middle, with a spark running down the line. */
.sl-visual__chain {
  position: relative;
  display: grid;
  place-items: center;
  height: 3.25rem;
}

.sl-visual__track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% - 1px);
  width: 2px;
  background: linear-gradient(rgba(255, 255, 255, 0.18), rgba(235, 196, 42, 0.55));
}

.sl-visual__spark {
  position: absolute;
  top: 0;
  left: calc(50% - 0.25rem);
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--auth-gold-strong);
  box-shadow: 0 0 12px 3px var(--auth-gold-glow);
  opacity: 0;
}

.sl-visual__links {
  position: relative;
  width: 6.5rem;
  height: auto;
}

.sl-visual__link {
  stroke-width: 5;
  fill: none;
  /* SVG shapes move around their own box, not the drawing's origin. */
  transform-box: fill-box;
  transform-origin: center;
}

.sl-visual__link--left {
  stroke: var(--auth-gold);
}

.sl-visual__link--right {
  stroke: #7c9cff;
}

/* The short link the address turns into. */
.sl-visual__short {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  height: 3rem;
  padding: 0 0.45rem 0 1rem;
  border: 1px solid rgba(235, 196, 42, 0.45);
  border-radius: var(--radius-pill);
  background-color: var(--auth-gold-soft);
  color: var(--auth-text);
}

.sl-visual__short-icon {
  flex: 0 0 auto;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--auth-gold);
}

.sl-visual__short-text {
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  white-space: nowrap;
}

.sl-visual__short-text b {
  color: var(--auth-gold-strong);
  font-weight: var(--font-weight-bold);
}

.sl-visual__copied {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  background-color: rgba(94, 224, 160, 0.14);
  color: var(--auth-success);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
}

.sl-visual__copied-icon {
  width: 0.9rem;
  height: 0.9rem;
}

/* ------------------------------------------------------------ Form card */

.sl-card__notice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: var(--auth-gap);
  padding: 0.8rem 1rem;
  border: 1px solid rgba(124, 156, 255, 0.35);
  border-radius: var(--auth-radius-sm);
  background-color: rgba(124, 156, 255, 0.1);
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
}

.sl-card__notice-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.1rem;
  color: #9db4ff;
}

/* The anti-spam field is moved out of view (not display: none, which some
   bots skip). */
.sl-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

/* ---------------------------------------------------------- Result card */

.sl-result__badge {
  background: linear-gradient(145deg, #8af5c4, var(--auth-success));
  box-shadow: 0 10px 30px -10px rgba(94, 224, 160, 0.45);
}

.sl-result__note {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: var(--auth-gap);
  padding: 0.8rem 1rem;
  border: 1px solid rgba(235, 196, 42, 0.35);
  border-radius: var(--auth-radius-sm);
  background-color: var(--auth-gold-soft);
  color: var(--auth-text);
  font-size: var(--auth-fs-small);
}

.sl-result__note-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.1rem;
  color: var(--auth-gold);
}

.sl-result__copy {
  display: grid;
  gap: 0.4rem;
}

.sl-result__field {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

/* The field and the Copy button are stacked, so the whole short URL is
   always readable, even in the narrow card column. */
.sl-result__row {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.sl-result__input {
  min-width: 0;
  color: var(--auth-gold-strong);
  padding-inline: clamp(0.7rem, 0.5rem + 0.6vw, 1rem);
  font-family: var(--font-mono);
  /* Small enough on a 360px phone to show https://<site>/s/<hash> whole. */
  font-size: clamp(0.78rem, 0.55rem + 1vw, 1.2rem);
  text-overflow: ellipsis;
  cursor: text;
}

.sl-result__copy-button {
  padding: 0 1.35rem;
}

.sl-result__copy-icon,
.sl-result__done-icon {
  width: 1.15rem;
  height: 1.15rem;
}

.sl-result__done-icon {
  display: none;
}

/* Copied: copy-text.js marks the status line `.is-success`; the button turns
   green with a tick until the label resets. (:has() only adds the colour; the
   "Copied" label and the spoken status work everywhere.) */
.sl-result__copy:has(.is-success) .sl-result__copy-button {
  background: linear-gradient(135deg, #8af5c4, var(--auth-success));
}

.sl-result__copy:has(.is-success) .sl-result__copy-icon {
  display: none;
}

.sl-result__copy:has(.is-success) .sl-result__done-icon {
  display: inline;
}

.sl-result__status {
  min-height: 1.4em;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
}

.sl-result__status.is-success {
  color: var(--auth-success);
}

.sl-result__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.sl-result__action {
  flex: 1 1 11rem;
  justify-content: center;
  min-height: 48px;
  text-decoration: none;
}

.sl-result__original {
  margin-top: var(--auth-gap);
  padding-top: var(--auth-gap);
  border-top: 1px solid var(--auth-line);
}

.sl-result__label {
  margin-bottom: 0.35rem;
  color: var(--auth-subtle);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* A very long link wraps anywhere and scrolls inside its own box. */
.sl-result__long {
  max-height: 10.5em;
  overflow-y: auto;
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------- How it works */

.sl-steps {
  display: grid;
  justify-items: center;
  gap: clamp(1.25rem, 1rem + 1.2vw, 2.25rem);
}

.sl-steps__title {
  font-family: var(--font-brand);
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.5rem);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.02em;
  text-align: center;
}

.sl-steps__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(0.9rem, 0.6rem + 1vw, 1.5rem);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 720px) {
  .sl-steps__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.sl-step {
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.6rem;
  padding: clamp(1.25rem, 1rem + 1vw, 2rem);
  overflow: hidden;
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius);
  background-color: var(--sl-surface);
}

.sl-step:hover {
  border-color: var(--auth-line-strong);
}

.sl-step__icon {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 14px;
  background-color: var(--auth-gold-soft);
  color: var(--auth-gold);
}

.sl-step__icon svg {
  width: 1.4rem;
  height: 1.4rem;
}

/* The big faint step number in the corner. */
.sl-step__number {
  position: absolute;
  top: 0.6rem;
  right: 1.1rem;
  color: rgba(255, 255, 255, 0.07);
  font-family: var(--font-brand);
  font-size: clamp(2.5rem, 2rem + 1.5vw, 3.5rem);
  line-height: 1;
}

.sl-step__title {
  font-size: clamp(1.05rem, 0.98rem + 0.3vw, 1.25rem);
  font-weight: var(--font-weight-bold);
}

.sl-step__text {
  color: var(--auth-muted);
  font-size: var(--auth-fs-small);
  line-height: 1.6;
}

/* --------------------------------------------------------------- Motion */

@media (prefers-reduced-motion: no-preference) {
  .sl-kicker__pulse::after {
    animation: sl-ping 2.4s var(--auth-ease) infinite;
  }

  .sl-visual__seg {
    animation: sl-shrink var(--sl-loop) var(--auth-ease) infinite;
  }

  .sl-visual__seg--2 { animation-delay: 80ms; }
  .sl-visual__seg--3 { animation-delay: 160ms; }
  .sl-visual__seg--4 { animation-delay: 240ms; }
  .sl-visual__seg--5 { animation-delay: 320ms; }

  .sl-visual__spark {
    animation: sl-spark var(--sl-loop) ease-in-out infinite;
  }

  .sl-visual__link--left {
    animation: sl-join-left var(--sl-loop) var(--auth-ease) infinite;
  }

  .sl-visual__link--right {
    animation: sl-join-right var(--sl-loop) var(--auth-ease) infinite;
  }

  .sl-visual__short {
    animation: sl-arrive var(--sl-loop) var(--auth-ease) infinite;
  }

  .sl-visual__copied {
    animation: sl-copied var(--sl-loop) var(--auth-ease) infinite;
  }

  /* Off screen (short-link-page.js) the loop waits where it is. */
  .sl-visual.is-offscreen *,
  .sl-visual.is-offscreen *::after {
    animation-play-state: paused;
  }

  .sl-result__badge {
    animation: sl-pop 600ms var(--auth-ease) both;
  }

  .sl-result__copy-button {
    transition: transform var(--transition-fast);
  }

  .sl-result__copy:has(.is-success) .sl-result__copy-button {
    animation: sl-pop 420ms var(--auth-ease);
  }

  .sl-step {
    transition: transform var(--transition-normal);
  }

  .sl-step:hover {
    transform: translateY(-3px);
  }

  /* Scroll reveal: only once short-link-page.js has marked <html>. */
  .sl-reveal [data-reveal] {
    transition: opacity 650ms var(--auth-ease), transform 650ms var(--auth-ease);
  }

  .sl-reveal [data-reveal]:not(.is-revealed) {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
  }

  .sl-reveal .sl-step:nth-child(2) { transition-delay: 90ms; }
  .sl-reveal .sl-step:nth-child(3) { transition-delay: 180ms; }

  /* After the reveal, the hover lift reacts at once. */
  .sl-reveal .sl-step.is-revealed:hover {
    transition-delay: 0ms;
  }
}

@keyframes sl-ping {
  0% { opacity: 0.7; transform: scale(1); }
  80%, 100% { opacity: 0; transform: scale(2.6); }
}

/* One cycle of the loop: the long address shrinks (0-35%), a spark runs down
   the chain while the two links join (25-50%), the short link arrives
   (40-55%), "Copied" shows (60-88%), then everything resets. */
@keyframes sl-shrink {
  0%, 12% { opacity: 1; transform: scaleX(1); }
  35%, 86% { opacity: 0.25; transform: scaleX(0.15); }
  100% { opacity: 1; transform: scaleX(1); }
}

@keyframes sl-spark {
  0%, 24% { opacity: 0; transform: translateY(0); }
  30% { opacity: 1; }
  48% { opacity: 1; transform: translateY(2.75rem); }
  54%, 100% { opacity: 0; transform: translateY(2.75rem); }
}

@keyframes sl-join-left {
  0%, 22% { transform: translateX(-7px) rotate(-6deg); }
  45%, 86% { transform: translateX(0) rotate(0deg); }
  100% { transform: translateX(-7px) rotate(-6deg); }
}

@keyframes sl-join-right {
  0%, 22% { transform: translateX(7px) rotate(6deg); }
  45%, 86% { transform: translateX(0) rotate(0deg); }
  100% { transform: translateX(7px) rotate(6deg); }
}

@keyframes sl-arrive {
  0%, 40% { opacity: 0.5; transform: scale(0.95); }
  52% { opacity: 1; transform: scale(1.02); }
  58%, 90% { opacity: 1; transform: scale(1); }
  100% { opacity: 0.5; transform: scale(0.95); }
}

@keyframes sl-copied {
  0%, 58% { opacity: 0; transform: translateY(4px); }
  64%, 86% { opacity: 1; transform: translateY(0); }
  94%, 100% { opacity: 0; transform: translateY(0); }
}

@keyframes sl-pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
