/*
  The scroll story's look (assets/scroll-story.js sets `--sx`, 0 to 1, on each `[data-sx-p]` element).
  Before the script runs, and without it, decorative motion shows today's still look and every reveal shows its finished
  state: `--sx` falls back to 0 for movement and to 1 for reveals. The pins exist only where the script can drive them,
  motion is allowed and the screen is wide (`--pin` classes are also left out in the theme editor).
*/

/* ── Big hero: the outer lines part, the outlined line fills ── */

.kx-hero--sx .kx-hero__line { will-change: transform; }
.kx-hero--sx .kx-hero__title > :first-child { transform: translateX(calc(var(--sx, 0) * -8%)); }
.kx-hero--sx .kx-hero__title > :last-child:not(:first-child) { transform: translateX(calc(var(--sx, 0) * 6%)); }
[dir="rtl"] .kx-hero--sx .kx-hero__title > :first-child { transform: translateX(calc(var(--sx, 0) * 8%)); }
[dir="rtl"] .kx-hero--sx .kx-hero__title > :last-child:not(:first-child) { transform: translateX(calc(var(--sx, 0) * -6%)); }

/* The fill is the line's own colour, mixed from the band's ground to its text colour, so the outline (stroke under the
   fill, base.css) stays whole at every moment and nothing is drawn twice. It is complete a third of the way out. */
.kx-hero--sx .kx-hero__line--outline {
  color: color-mix(in srgb, var(--color-text) calc(min(1, var(--sx, 0) * 3.4) * 100%), var(--color-background));
}

/* ── Marquee: tilted bands tilt further as they pass ── */

.kx-marquee--sx { overflow-x: clip; overflow-y: visible; padding-block: 40px; }
/* Wide enough to cover the 3% sideways shift and the extra tilt, and no wider: a band only repeats its words to fill
   the screen width, so a wider row could show the end of a band of short words. */
.kx-marquee--sx .kx-marquee__row { margin-inline: calc(-40px - 4vw); will-change: transform; }
.kx-marquee--sx .kx-marquee__row { transform: rotate(calc(-2deg - var(--sx, 0) * 2deg)) translateX(calc(var(--sx, 0) * -3%)); }
.kx-marquee--sx .kx-marquee__row.is-reverse { transform: rotate(calc(-2deg + var(--sx, 0) * 2deg)) translateX(calc(var(--sx, 0) * 3%)); }
[dir="rtl"] .kx-marquee--sx .kx-marquee__row { transform: rotate(calc(2deg + var(--sx, 0) * 2deg)) translateX(calc(var(--sx, 0) * 3%)); }
[dir="rtl"] .kx-marquee--sx .kx-marquee__row.is-reverse { transform: rotate(calc(2deg - var(--sx, 0) * 2deg)) translateX(calc(var(--sx, 0) * -3%)); }

/* ── Stat cards: numbers count with the scroll, outlined until they arrive ── */

.sx-armed [data-sx-count]:not(.is-done) {
  color: var(--color-background);
  -webkit-text-stroke: 2px var(--color-text);
  paint-order: stroke fill;
}
[data-sx-count] { font-variant-numeric: tabular-nums; transition: color 0.4s; }

/* ── Build story: a site builds itself ── */

.sx-build { position: relative; }
.sx-build__stage {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 56px;
  align-items: center;
  max-width: var(--page-width, 1200px);
  margin-inline: auto;
  padding: 80px 20px;
}
.sx-build__captions { display: grid; gap: 40px; }
.sx-build__caption h2 {
  margin-block: 10px 16px;
  font-size: clamp(2.5rem, 4.8vw, 4.25rem);
  font-weight: 700;
  line-height: 0.94;
  text-wrap: balance;
  letter-spacing: -0.05em;
}
.sx-build__caption p { max-width: 36ch; color: var(--color-text-secondary); font-size: 1.125rem; }
.sx-build__progress { display: none; height: 4px; max-width: 360px; border-radius: 4px; background: var(--color-card-background); overflow: hidden; }
.sx-build__progress span { display: block; height: 100%; background: var(--color-text); transform-origin: left; transform: scaleX(var(--sx, 0)); }
[dir="rtl"] .sx-build__progress span { transform-origin: right; }

.sx-mock {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  aspect-ratio: 4 / 3.1;
  border: 1.5px solid var(--color-text);
  border-radius: 18px;
  background: var(--color-background);
  box-shadow: 14px 14px 0 var(--color-text);
}
.sx-mock__bar { display: flex; flex: none; align-items: center; gap: 6px; height: 34px; padding-inline: 12px; border-block-end: 1.5px solid var(--color-text); font-size: 0.75rem; color: var(--color-text-secondary); }
.sx-mock__bar i { width: 9px; height: 9px; border: 1.5px solid var(--color-text); border-radius: 50%; }
.sx-mock__url { flex: 1; max-width: 280px; margin-inline-start: 12px; padding: 2px 12px; border: 1px solid var(--color-border); border-radius: 9999px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sx-mock__body { display: grid; flex: 1; align-content: start; gap: 12px; padding: 16px; overflow: hidden; }
.sx-mock__nav { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.sx-mock__nav i { width: 70px; height: 20px; border-radius: 9999px; background: var(--color-text); }
.sx-mock__hero { position: relative; display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; align-items: center; padding: 18px; border-radius: 12px; background: color-mix(in srgb, var(--color-accent) 30%, var(--color-background)); }
.sx-mock__heading { min-height: 2em; margin: 0; font-size: clamp(1rem, 2.2vw, 1.875rem); line-height: 1; letter-spacing: -0.03em; }
.sx-mock__heading.is-editing { outline: 2px dashed var(--color-text); outline-offset: 4px; border-radius: 4px; }
.sx-mock__heading.is-editing::after { content: "|"; font-weight: 400; animation: sx-caret 0.8s step-end infinite; }
.sx-mock__photo { aspect-ratio: 1; border: 1.5px solid var(--color-text); border-radius: 10px; background: var(--color-accent); }
.sx-mock__cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sx-mock__cards i { height: 56px; border: 1.5px solid var(--color-text); border-radius: 10px; background: var(--color-card-background); }
.sx-mock__form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.sx-mock__form i { height: 26px; border: 1px solid var(--color-border); border-radius: 8px; }
.sx-mock__form i:last-child { width: 80px; border-radius: 9999px; background: var(--color-text); }
.sx-mock__live { position: absolute; inset-block-start: -16px; inset-inline-end: -16px; z-index: 1; padding: 6px 14px; border: 1.5px solid var(--color-text); border-radius: 9999px; background: var(--color-accent); color: var(--color-accent-text, #000); font-size: 0.8125rem; font-weight: 700; }
@keyframes sx-caret { 50% { opacity: 0; } }

/* ── Steps: illustrations (both layouts) ── */

.sx-ill { position: relative; width: 100%; max-width: 300px; aspect-ratio: 300 / 190; }
.sx-ill > * { position: absolute; transition: opacity 0.5s, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); transition-delay: var(--sx-delay, 0s); }
.sx-armed .sx-card:not(.is-in) .sx-pop { opacity: 0; transform: translateY(22px) scale(0.92); }
.sx-ill__theme { inset-block-start: 0; width: 30%; height: 64%; display: grid; align-content: start; gap: 5px; padding: 7px; border: 1.5px solid currentColor; border-radius: 10px; background: var(--color-background); }
.sx-ill__theme i { display: block; height: 7px; border-radius: 4px; background: var(--color-card-background); }
.sx-ill__theme i:first-child { height: 26px; background: var(--color-border); }
.sx-ill__theme:nth-child(1) { inset-inline-start: 0; }
.sx-ill__theme:nth-child(2) { inset-inline-start: 35%; }
.sx-ill__theme:nth-child(2) i:first-child { background: var(--color-accent); }
.sx-ill__theme:nth-child(3) { inset-inline-start: 70%; }
.sx-ill__theme:nth-child(2) { outline: 3px solid currentColor; outline-offset: 3px; transition: outline-color 0.3s 0.7s; }
.sx-armed .sx-card:not(.is-in) .sx-ill__theme:nth-child(2) { outline-color: transparent; }
.sx-ill__pick { inset-block-start: 8%; inset-inline-start: 55%; z-index: 1; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--color-text); color: var(--color-background); font-size: 14px; font-weight: 700; }
.sx-ill__url, .sx-ill__domain { inset-inline: 0; inset-block-end: 0; display: flex; justify-content: space-between; gap: 8px; padding: 7px 14px; border: 1.5px solid currentColor; border-radius: 9999px; background: var(--color-background); font-size: 0.8125rem; font-weight: 500; }
.sx-ill__url b, .sx-ill__domain b { font-weight: 600; }
.sx-ill__page { inset: 0; display: grid; align-content: start; gap: 8px; padding: 12px; border: 1.5px solid currentColor; border-radius: 12px; background: var(--color-background); overflow: hidden; }
.sx-ill__title { justify-self: start; outline: 2px dashed var(--color-accent); outline-offset: 4px; border-radius: 4px; font-size: 1.125rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; }
.sx-ill__block { display: flex; align-items: center; height: 30px; padding-inline: 10px; border: 1.5px solid currentColor; border-radius: 8px; background: var(--color-card-background); font-size: 0.6875rem; transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 1.2s; }
.sx-ill__block--a { background: var(--color-accent); color: var(--color-accent-text, #000); }
/* Two sections swap places: the accent one starts on top and is dragged below. */
.sx-armed .sx-card:not(.is-in) .sx-ill__block--a { transform: translateY(-38px); }
.sx-armed .sx-card:not(.is-in) .sx-ill__block--b { transform: translateY(38px); }
.sx-ill__list { inset-block-start: 0; inset-inline-start: 0; width: 56%; display: grid; gap: 6px; }
.sx-ill__row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1.5px solid currentColor; border-radius: 8px; font-size: 0.6875rem; transition: opacity 0.4s, transform 0.5s; }
.sx-ill__row::before { content: ""; flex: none; width: 14px; height: 14px; border-radius: 4px; background: var(--color-accent); }
.sx-ill__row:nth-child(2) { transition-delay: 0.25s; }
.sx-ill__row:nth-child(3) { transition-delay: 0.5s; }
.sx-armed .sx-card:not(.is-in) .sx-ill__row { opacity: 0; transform: translateX(-16px); }
.sx-ill__form { inset-block-start: 6%; inset-inline-end: 0; width: 38%; display: grid; gap: 6px; padding: 8px; border: 1.5px solid currentColor; border-radius: 10px; }
.sx-ill__form i { display: block; height: 14px; border: 1px solid var(--color-border); border-radius: 5px; }
.sx-ill__form i:last-child { width: 60%; border: 0; background: var(--color-accent); }

.step .sx-ill { margin-block-end: 20px; color: var(--color-text); }

/* ── Steps: the sideways layout ── */

.sx-steps { position: relative; width: 100vw; margin-inline: calc(50% - 50vw); }
.sx-steps__stage { display: flex; flex-direction: column; justify-content: center; gap: 32px; }
.sx-steps__stage > .band-head { width: 100%; max-width: var(--page-width, 1200px); margin-inline: auto; padding-inline: 20px; }
.sx-steps__track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 16px;
  width: 100%;
  max-width: var(--page-width, 1200px);
  margin: 0 auto;
  padding: 0 20px;
  list-style: none;
}
.sx-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  padding: 30px;
  border: 1.5px solid var(--color-text);
  border-radius: var(--radius-shell, 28px);
  --sx-ground: var(--color-card-background);
  --sx-ink: var(--color-text);
  background: var(--sx-ground);
  color: var(--sx-ink);
}
.sx-card:nth-child(3n + 2) { --sx-ground: color-mix(in srgb, var(--color-accent) 30%, var(--color-background)); }
.sx-card:nth-child(3n + 3) { --sx-ground: var(--color-text); --sx-ink: var(--color-background); --color-text-secondary: color-mix(in srgb, var(--color-background) 72%, transparent); }
.sx-card:nth-child(3n + 3) .sx-ill > *, .sx-card:nth-child(3n + 3) .sx-ill__page { background: transparent; }
.sx-card:nth-child(3n + 3) .sx-ill__url, .sx-card:nth-child(3n + 3) .sx-ill__domain { border-color: var(--color-accent); }
.sx-card__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.sx-card__top .sx-ill { flex: 0 1 58%; }
/* The number is drawn like every outline in this theme: the card's own ground as the fill, the stroke under it. */
.sx-card__number { font-family: var(--font-heading); font-size: clamp(5rem, 9vw, 8.75rem); font-weight: 700; line-height: 0.8; letter-spacing: -0.06em; color: var(--sx-ground); -webkit-text-stroke: 4px var(--sx-ink); paint-order: stroke fill; }
.sx-card__title { margin-block-end: 10px; font-size: clamp(1.5rem, 2.4vw, 2.125rem); line-height: 1.05; letter-spacing: -0.03em; }
.sx-card__text { max-width: 40ch; color: var(--color-text-secondary); }

/* ── Pricing: the plans rise with the scroll and are level once the row is fully on screen ── */

/* ── FAQ: a giant question mark that turns and fills ── */

.faq-band--art .band__inner { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 48px; align-items: start; }
.faq-band--art .band__inner > .band-head { grid-column: 1 / -1; }
.faq-band--art .faq { max-width: none; }
.sx-qmark {
  position: sticky;
  inset-block-start: calc(var(--sx-head, 0px) + 24px);
  font-family: var(--font-heading);
  font-size: clamp(14rem, 28vw, 25rem);
  font-weight: 800;
  line-height: 0.85;
  text-align: center;
  color: color-mix(in srgb, var(--color-accent) calc(min(1, max(0, var(--sx, 0.5) * 1.6 - 0.3)) * 100%), var(--color-background));
  -webkit-text-stroke: 3px var(--color-text);
  paint-order: stroke fill;
  transform: rotate(calc(var(--sx, 0.5) * 50deg - 25deg)) scale(calc(0.8 + var(--sx, 0.5) * 0.3));
  user-select: none;
}

/* ── Footer: the closing headline grows and its accent words fill ── */

.site-footer__title-accent {
  color: color-mix(in srgb, var(--color-accent) calc(min(1, max(0, (var(--sx, 1) - 0.3) / 0.6)) * 100%), var(--color-background));
  -webkit-text-stroke: 3px var(--color-text);
  paint-order: stroke fill;
}
.site-footer--sx .site-footer__title { transform: scale(calc(0.84 + min(1, var(--sx, 1) / 0.6) * 0.16)); transform-origin: left center; }
[dir="rtl"] .site-footer--sx .site-footer__title { transform-origin: right center; }

/* ── Wide screens with motion and a script: the pins and the rise ── */

@media (scripting: enabled) and (prefers-reduced-motion: no-preference) and (min-width: 900px) {
  .sx-build--pin { height: 420svh; }
  .sx-build--pin .sx-build__stage {
    position: sticky;
    inset-block-start: var(--sx-head, 0px);
    height: calc(100svh - var(--sx-head, 0px));
    padding-block: 0;
  }
  .sx-build--pin .sx-build__captions { position: relative; min-height: 360px; }
  .sx-build--pin .sx-build__caption { position: absolute; inset: 0; opacity: 0; transform: translateY(30px); transition: opacity 0.4s, transform 0.4s; }
  .sx-build--pin .sx-build__caption.is-on { opacity: 1; transform: none; }
  .sx-build--pin .sx-build__progress { display: block; }
  .sx-build--pin [data-sx-t] {
    --sx-k: clamp(0, calc((var(--sx, 1) - var(--sx-t)) * 9), 1);
    opacity: var(--sx-k);
    transform: translateY(calc((1 - var(--sx-k)) * 50px)) scale(calc(0.94 + var(--sx-k) * 0.06));
  }

  /* An estimate of the pinned length, so a link to a later band lands near it before the script measures it. */
  .sx-steps--pin { height: calc(100svh + 70vw); }
  .sx-steps--pin .sx-steps__stage {
    position: sticky;
    inset-block-start: var(--sx-head, 0px);
    height: calc(100svh - var(--sx-head, 0px));
    overflow-x: clip;
  }
  /* The sideways row needs the script to move it: until it runs (or if it never loads) the cards stay a grid. */
  .sx-armed .sx-steps--pin .sx-steps__track {
    display: flex;
    max-width: none;
    padding-inline: max(20px, calc((100vw - var(--page-width, 1200px)) / 2 + 20px)) 0;
    transform: translateX(var(--sx-tx, 0px));
    will-change: transform;
  }
  /* A flex row's end padding is not part of its scroll width, so the end margin is a spacer: the last card stops on
     the page's edge, as the first one starts on it. */
  .sx-armed .sx-steps--pin .sx-steps__track::after {
    content: "";
    flex: none;
    width: max(4px, calc((100vw - var(--page-width, 1200px)) / 2 + 4px));
  }
  .sx-armed .sx-steps--pin .sx-card { flex: none; width: min(640px, 70vw); min-height: min(400px, calc(100svh - var(--sx-head, 0px) - 220px)); }

  .plans--sx .plan { transform: translateY(calc((1 - clamp(0, calc((var(--sx, 1) - var(--sx-d, 0)) / (1 - var(--sx-d, 0))), 1)) * 160px)); }
}

@media (max-width: 899px) {
  .sx-build__stage { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-block: 56px; }
  .sx-mock { box-shadow: 8px 8px 0 var(--color-text); }
  .sx-card__top { flex-direction: column; }
  .sx-card__top .sx-ill { flex: none; }
  .faq-band--art .band__inner { grid-template-columns: minmax(0, 1fr); }
  .sx-qmark { position: relative; inset-block-start: 0; font-size: 12rem; }
}

@media (prefers-reduced-motion: reduce) {
  .kx-hero--sx .kx-hero__title > *,
  .kx-marquee--sx .kx-marquee__row,
  .site-footer--sx .site-footer__title,
  .sx-qmark { transform: none !important; }
  .kx-hero--sx .kx-hero__line--outline { color: var(--color-background); }
  .kx-marquee--sx .kx-marquee__row { transform: rotate(-2deg) !important; }
  [dir="rtl"] .kx-marquee--sx .kx-marquee__row { transform: rotate(2deg) !important; }
  .sx-mock__heading.is-editing::after { animation: none; }
}
