/* SnapEnvs early-access landing page. Colours, type, radius and motion come from tokens.css
   (a copy of snap-env/web/ui-kit/tokens). The base rules and `ui-*` classes below are the
   kit's own, copied for the few controls this page uses; everything else is page layout. */

/* ── Base (ui-kit/base.css) ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
p,
dl,
dd,
figure {
  margin: 0;
}

h1,
h2 {
  color: var(--text-strong);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

code {
  font-family: var(--font-mono);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: var(--accent-30);
  color: var(--text-strong);
}

.ui-skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-160%);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  transition: transform var(--duration-base) var(--ease-out);
}

.ui-skip-link:focus {
  transform: none;
}

/* ── Controls (ui-kit/components.css) ───────────────────────────────── */
.ui-icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color var(--duration-base) ease,
    border-color var(--duration-base) ease,
    color var(--duration-base) ease;
}

.ui-btn:hover:not(:disabled) {
  background: var(--panel-raised);
  border-color: var(--border-strong);
  color: var(--text-strong);
}

.ui-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px var(--accent);
}

.ui-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ui-btn--primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.ui-btn--primary:hover:not(:disabled) {
  border-color: transparent;
  background: var(--accent-hover);
  color: var(--on-accent);
}

.ui-btn--ghost {
  background: transparent;
}

.ui-btn--lg {
  min-height: 40px;
  padding: 9px 16px;
  font-size: var(--text-base);
}

.ui-btn--icon {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--text-secondary);
}

.ui-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text-strong);
  font-size: var(--text-md);
  line-height: 1.4;
  transition:
    border-color var(--duration-base) ease,
    box-shadow var(--duration-base) ease;
}

.ui-input::placeholder {
  color: var(--text-muted);
}

.ui-input:hover {
  border-color: var(--border-strong);
}

.ui-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-20);
}

.ui-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ui-input[aria-invalid='true'] {
  border-color: var(--bad-bd);
}

.ui-input--mono {
  font-family: var(--font-mono);
}

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

.ui-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: ui-spin 0.7s linear infinite;
}

.ui-logo {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.ui-logo img {
  width: auto;
  height: 100%;
}

.ui-logo__light {
  display: none !important;
}

:root[data-theme='light'] .ui-logo__dark {
  display: none !important;
}

:root[data-theme='light'] .ui-logo__light {
  display: block !important;
}

/* ── Page frame ─────────────────────────────────────────────────────── */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 1160px;
  margin: 0 auto;
  padding-inline: 24px;
}

/* The same soft teal light the website carries at the top of the page. */
.glow {
  position: absolute;
  inset: 0 0 auto;
  height: 720px;
  overflow: hidden;
  pointer-events: none;
}

.glow::before {
  content: '';
  position: absolute;
  top: -200px;
  left: -160px;
  width: 540px;
  height: 540px;
  border-radius: var(--radius-full);
  background: var(--accent-20);
  filter: blur(120px);
}

:root[data-theme='light'] .glow {
  opacity: 0.4;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.top__brand {
  display: inline-flex;
  border-radius: var(--radius-sm);
}

.top__brand .ui-logo {
  height: 30px;
}

/* ── Statement ──────────────────────────────────────────────────────── */
.intro {
  padding-top: clamp(16px, 4vh, 52px);
}

.intro h1 {
  font-size: clamp(2rem, min(5.2vw, 8.2vh), 4.25rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: var(--tracking-tight);
}

.intro__lead {
  max-width: 54ch;
  margin-top: clamp(12px, 2.2vh, 20px);
  color: var(--text-secondary);
  font-size: clamp(1rem, 0.92rem + 0.34vw, 1.1875rem);
  line-height: 1.55;
}

/* ── The session ────────────────────────────────────────────────────── */
/* One terminal session across the full width: the example run, then the prompt that
   collects the email. Each line is a row: gutter glyph, printed text, and on wide
   screens a dotted leader out to a margin note. */
.session {
  --code: clamp(0.8125rem, min(0.6rem + 0.75vw, 2.45vh), 1.1875rem);
  --line: 1.75;
  position: relative;
  z-index: 1;
  margin-top: clamp(20px, 3.8vh, 48px);
  border-block: 1px solid var(--border);
  background: var(--panel);
}

.session__inner {
  padding-top: clamp(18px, 3.2vh, 32px);
  padding-bottom: clamp(22px, 4vh, 40px);
}

.run,
.ask {
  font-family: var(--font-mono);
  font-size: var(--code);
  line-height: var(--line);
  color: var(--text);
}

.row {
  display: grid;
  grid-template-columns: 3ch minmax(0, 1fr);
}

.row__gutter {
  grid-column: 1;
  color: var(--text-muted);
  user-select: none;
}

.row__gutter--ask {
  color: var(--accent-text);
  font-weight: 700;
}

.row__code {
  grid-column: 2;
  min-width: 0;
  overflow-wrap: anywhere;
}

.row__code--cmd {
  color: var(--text-strong);
}

/* JSON properties: indented two characters, wrapped text hangs two more. */
.row__code--in {
  padding-left: 4ch;
  text-indent: -2ch;
}

.row--comment {
  color: var(--text-muted);
}

/* Margin notes and their leaders need a margin: hidden and out of flow until there is one.
   They stay rendered so the run's animation plays once and is not replayed on resize. */
.row__leader,
.row__note {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

.row__typed {
  display: inline-block;
}

.row__cursor {
  display: inline-block;
  width: 1ch;
  height: 1.15em;
  margin-right: -1ch;
  background: var(--text-secondary);
  vertical-align: text-bottom;
  opacity: 0;
}

.tok-key {
  color: var(--text-secondary);
}

.tok-pun {
  color: var(--text-muted);
}

.tok-str {
  color: var(--text);
}

.tok-url {
  color: var(--accent-text);
}

.tok-ok {
  border-radius: 3px;
  color: var(--ok-fg);
  font-weight: 600;
}

/* ── The prompt ─────────────────────────────────────────────────────── */
.ask {
  margin-top: calc(var(--code) * 0.5);
  scroll-margin-top: 28vh;
}

.ask__question {
  color: var(--text-strong);
  font-weight: 600;
}

.row--field {
  margin-top: 10px;
}

.ask__controls {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  font-family: var(--font-sans);
}

.ask__email {
  min-height: 48px;
  padding: 10px 14px;
  font-size: 16px;
}

.ask__email[aria-invalid='true'],
.ask__email[aria-invalid='true']:focus {
  border-color: var(--bad-fg);
  box-shadow: 0 0 0 3px var(--bad-bg);
}

.ask__submit {
  min-height: 48px;
  padding: 10px 20px;
  font-size: 15px;
  gap: 8px;
}

/* Each state's label and icon stay together as one pair; the three pairs share one cell, so
   the button keeps the width of its longest label as it changes. */
.ask__swap {
  display: inline-grid;
  align-items: center;
  justify-items: center;
}

.ask__pair {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ask__swap > * {
  grid-area: 1 / 1;
  visibility: hidden;
}

.ask[data-state='idle'] [data-when='idle'],
.ask[data-state='sending'] [data-when='sending'],
.ask[data-state='done'] [data-when='done'] {
  visibility: visible;
}

.ask[data-state='done'] .ask__submit:disabled {
  border-color: var(--ok-bd);
  background: var(--ok-bg);
  color: var(--ok-fg);
  opacity: 1;
  cursor: default;
}

.row__note--form {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  visibility: visible;
  grid-column: 2;
  margin-top: 12px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
}

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

.ask__error {
  margin-top: 12px;
  color: var(--bad-fg);
}

.ask__error:empty,
.ask__error--fallback {
  display: none;
}

.ask__error--fallback:target {
  display: block;
}

.ask__result {
  display: none;
  margin-top: 14px;
  outline: none;
}

.ask__result.is-shown,
.ask__result:target {
  display: block;
}

.ask__thanks {
  margin-top: 8px;
  color: var(--text-strong);
  font-family: var(--font-sans);
  font-size: clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);
  font-weight: 600;
  line-height: 1.5;
}

/* ── Specification ──────────────────────────────────────────────────── */
.spec {
  padding-top: clamp(64px, 11vh, 112px);
}

.spec h2 {
  font-size: clamp(1.5rem, 1.14rem + 1.5vw, 2.25rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
}

.spec__list {
  margin-top: 28px;
  border-top: 1px solid var(--border);
}

.spec__list > div {
  display: grid;
  gap: 6px;
  padding: 18px 0;
  border-bottom: 1px solid var(--divider);
}

.spec__list dt {
  color: var(--text-strong);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.6;
}

.spec__list dd {
  max-width: 54ch;
  color: var(--text-secondary);
  font-size: 15.5px;
  line-height: 1.6;
}

.spec__cta {
  min-height: 46px;
  margin-top: 32px;
  padding: 10px 20px;
  font-size: 15px;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.foot {
  position: relative;
  z-index: 1;
  margin-top: clamp(64px, 11vh, 104px);
  border-top: 1px solid var(--border);
}

.foot__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 32px;
  padding-top: 26px;
  padding-bottom: 34px;
}

.foot__brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.foot__brand .ui-logo {
  height: 22px;
}

.foot__brand p,
.foot__legal {
  color: var(--text-muted);
  font-size: var(--text-md);
}

/* ── Wider screens ──────────────────────────────────────────────────── */
@media (min-width: 560px) {
  .ask__controls {
    flex-direction: row;
    max-width: 620px;
  }

  .ask__email {
    flex: 1;
    min-width: 0;
  }
}

@media (min-width: 560px) and (max-width: 1039.98px) {
  .run .row__note {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    visibility: visible;
    grid-column: 2;
    max-width: 62ch;
    margin: 1px 0 9px;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13.5px;
    line-height: 1.45;
  }

  .run .row--out .row__note {
    padding-left: calc(var(--code) * 1.2);
  }
}

@media (min-width: 720px) {
  .spec__list > div {
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    gap: 8px 40px;
    padding: 20px 0;
  }
}

/* A margin opens up: notes sit beside the lines they explain, without changing the
   transcript's line rhythm (they take no height in their row). */
@media (min-width: 1040px) {
  .session {
    --note-size: 13.5px;
    --note-line: 1.45;
  }

  .row {
    grid-template-columns: 3ch auto minmax(28px, 1fr) clamp(250px, 24vw, 310px);
  }

  .row__code {
    white-space: nowrap;
  }

  .ask__question,
  .ask__controls,
  .ask__error,
  .ask__thanks {
    grid-column: 2 / 4;
    white-space: normal;
  }

  .row__leader {
    position: static;
    width: auto;
    overflow: visible;
    visibility: visible;
    grid-column: 3;
    align-self: center;
    margin: 0 14px;
    border-top: 1px dotted var(--text-muted);
    transform-origin: left center;
  }

  .row__note,
  .row__note--form {
    position: relative;
    top: calc((var(--code) * var(--line) - var(--note-size) * var(--note-line)) / 2);
    width: auto;
    height: 0;
    overflow: visible;
    visibility: visible;
    grid-column: 4;
    margin-top: 0;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: var(--note-size);
    line-height: var(--note-line);
  }

  .row__note--form {
    top: 14px;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding-inline: 16px;
  }

  .top {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .top__brand .ui-logo {
    height: 26px;
  }

  .intro {
    padding-top: 12px;
  }

  .session {
    --line: 1.65;
    margin-top: 26px;
  }

  .session__inner {
    padding-top: 18px;
    padding-bottom: 26px;
  }
}

@media (max-width: 359px) {
  .session {
    --code: 0.75rem;
  }
}

@media (pointer: coarse) {
  .top .ui-btn--icon {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
}

/* ── Motion ─────────────────────────────────────────────────────────── */
/* The run plays once: the command is typed, the client waits, the result prints, and
   RUNNING settles. Everything is visible without it; the form never waits for it. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  .run .row__typed {
    animation: run-type 0.85s steps(34, end) 0.3s both;
  }

  .run .row__cursor {
    animation:
      run-caret-travel 0.85s steps(34, end) 0.3s both,
      run-caret-life 2.05s steps(1, end) both;
  }

  .run .row--out {
    animation: run-print 1ms linear both;
  }

  .run .row--out:nth-child(3) {
    animation-delay: 2.05s;
  }

  .run .row--out:nth-child(4) {
    animation-delay: 2.11s;
  }

  .run .row--out:nth-child(5) {
    animation-delay: 2.17s;
  }

  .run .row--out:nth-child(6) {
    animation-delay: 2.23s;
  }

  .run .row--out:nth-child(7) {
    animation-delay: 2.29s;
  }

  .run .row--out:nth-child(8) {
    animation-delay: 2.35s;
  }

  .run .tok-ok--live {
    animation: run-settle 1.1s var(--ease-out) 2.25s both;
  }

  .run .row__note {
    animation: run-note 0.6s var(--ease-out) both;
  }

  .run .row__leader {
    animation: run-leader 0.6s var(--ease-out) both;
  }

  .run .row:nth-child(2) :is(.row__note, .row__leader) {
    animation-delay: 1.2s;
  }

  .run .row:nth-child(5) :is(.row__note, .row__leader) {
    animation-delay: 2.5s;
  }

  .run .row:nth-child(7) :is(.row__note, .row__leader) {
    animation-delay: 2.68s;
  }

  .ask__result.is-shown .row {
    animation: run-print 1ms linear both;
  }

  .ask__result.is-shown .row:nth-child(2) {
    animation-delay: 70ms;
  }

  .ask__result.is-shown .row:nth-child(3) {
    animation-delay: 140ms;
  }

  .ask__result.is-shown .row:nth-child(4) {
    animation-delay: 210ms;
  }

  .ask__result.is-shown .row:nth-child(5) {
    animation: run-note 0.6s var(--ease-out) 0.36s both;
  }
}

@keyframes run-type {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes run-caret-travel {
  from {
    transform: translateX(-34ch);
  }
  to {
    transform: none;
  }
}

@keyframes run-caret-life {
  0% {
    opacity: 1;
  }
  60% {
    opacity: 0;
  }
  71% {
    opacity: 1;
  }
  82% {
    opacity: 0;
  }
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes run-print {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes run-settle {
  from {
    background-color: var(--ok-bg);
    box-shadow: 0 0 0 4px var(--ok-bg);
  }
  to {
    background-color: transparent;
    box-shadow: 0 0 0 4px transparent;
  }
}

@keyframes run-note {
  from {
    opacity: 0;
    filter: blur(4px);
  }
  to {
    opacity: 1;
    filter: none;
  }
}

@keyframes run-leader {
  from {
    opacity: 0;
    transform: scaleX(0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
