/* ==========================================================================
   Signal and Noise — the site around the SNR animation: phase nav, copy,
   the SQL window and the phase-04 pieces. Pair with site.js.
   Everything lives inside .stage, which is also the .snr element, and is
   shown or hidden by is-* classes that site.js puts on .stage.
   ========================================================================== */

html, body { margin: 0; background: #0d1117; }

.stage {
  --line: rgba(233, 238, 244, .12);
  --snr-word-top: 17%;
  /* --snr-cy and --snr-lens-h are set from GEO in site.js */
}
@supports (height: 100dvh) { .stage { --snr-height: 100dvh; } }

.sr-only, .phrases {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.is-instant *, .is-instant *::before, .is-instant *::after { transition: none !important; }

/* ---------- nav: the phases of understanding ---------- */
.nav { position: absolute; z-index: 4; top: 0; left: 0; right: 0; padding: 14px var(--snr-gutter) 0; }
.nav ol { display: flex; justify-content: center; align-items: center; list-style: none; }
.nav li { display: flex; align-items: center; }
.nav li + li::before {
  content: ""; width: clamp(14px, 3.4vw, 56px); height: 1px; margin: 0 clamp(8px, 1.4vw, 20px);
  background: var(--line); transition: background-color .5s ease;
}
.nav li.is-done + li::before { background: rgba(58, 224, 200, .6); }
.nav a {
  display: inline-flex; align-items: baseline; gap: .8em; padding: 8px 2px;
  border-bottom: 1px solid transparent;
  font-family: var(--snr-mono); font-size: clamp(10.5px, .85vw, 12.5px); line-height: 1.5;
  letter-spacing: .12em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
  color: var(--snr-ink-soft); transition: color .3s ease, border-color .3s ease;
}
.nav a b { font-weight: 400; color: var(--snr-teal); }
.nav a:hover { color: var(--snr-ink); }
.nav a:focus-visible { outline: 1px solid var(--snr-teal); outline-offset: 4px; }
.nav a[aria-current] { color: #fff; border-bottom-color: var(--snr-teal); text-shadow: 0 0 14px rgba(58, 224, 200, .55); }

/* ---------- the picture: shown piece by piece ---------- */
.stage .snr__word { font-size: clamp(30px, min(4.6vw, 8.5vh), 76px); }
.stage .snr__word, .stage .snr__lens, .stage .snr__lens-cap {
  opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility 0s .45s;
}
.stage.is-noise .snr__word--noise, .stage.is-signal .snr__word--signal, .stage.is-you .snr__word--you,
.stage.is-lens .snr__lens, .stage.is-cap .snr__lens-cap {
  opacity: 1; visibility: visible; transition: opacity .8s ease;
}
/* the blur and jitter belong to the word, not its caption (a filter on the parent blurs both) */
.stage .snr__word--noise { filter: none; animation: none; }
.snr__word--noise > span { display: inline-block; filter: blur(1.4px); animation: snr-jitter .18s steps(2) infinite; }
.snr__word--you {
  left: 50%; transform: translateX(-50%); text-align: center; white-space: nowrap;
  color: #fff; text-shadow: 0 0 20px rgba(58, 224, 200, .6), 0 0 50px rgba(58, 224, 200, .3);
}
.snr__word--you small { text-align: center; }
/* phase 04: noise · you · signal sit in one row, just above the lens */
.stage.geo-low .snr__word { top: auto; bottom: calc(100% - var(--snr-cy) + var(--snr-lens-h) / 2 + 20px); }

/* ---------- copy underneath the picture ---------- */
.copy {
  position: absolute; z-index: 3; left: var(--snr-gutter); right: var(--snr-gutter); bottom: clamp(16px, 4vh, 40px);
  max-height: calc(100% - var(--snr-cy) - var(--snr-lens-h) / 2 - clamp(16px, 4vh, 40px) - 18px); overflow-y: auto;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .4s ease, transform .4s ease, visibility 0s .4s;
}
.stage.is-copy1 .copy--1, .stage.is-copy2 .copy--2, .stage.is-copy3 .copy--3 {
  opacity: 1; visibility: visible; transform: none; transition: opacity .9s ease, transform .9s ease;
}
.copy p {
  max-width: 54ch;
  font-family: var(--snr-display); font-weight: 400; font-size: clamp(14px, 1.08vw, 17px); line-height: 1.55;
  color: rgba(233, 238, 244, .86);
}
.copy h3 { margin-bottom: 10px; }
.copy .copy__formula {
  margin-bottom: 8px;
  font-family: var(--snr-mono); font-size: clamp(11.5px, .9vw, 13px); letter-spacing: .04em; color: var(--snr-teal);
}
.copy--1 { display: grid; grid-template-columns: 1fr 1fr; column-gap: clamp(90px, 13vw, 200px); align-items: start; }
.copy--2, .copy--3 { text-align: center; }
.copy--2 p, .copy--3 p { max-width: 64ch; margin: 0 auto; text-wrap: balance; }
.copy--2 p { max-width: none; }
.copy .copy__lead {
  max-width: 30ch; margin-bottom: 12px;
  font-weight: 500; font-size: clamp(21px, min(2.5vw, 4.4vh), 36px); line-height: 1.12; letter-spacing: -.02em;
  color: #fff; text-shadow: 0 0 24px rgba(58, 224, 200, .35);
}

/* ---------- phase 02: the SQL window ---------- */
.sql {
  position: absolute; z-index: 3; left: 50%; top: clamp(64px, 11vh, 96px); bottom: clamp(84px, 13vh, 120px);
  width: min(1180px, calc(100% - 2 * var(--snr-gutter)));
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px;
  background-color: rgba(13, 17, 23, .74); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 40px 120px -40px rgba(0, 0, 0, .85);
  font-family: var(--snr-mono); font-size: 12px; line-height: 1.5; color: var(--snr-ink);
  opacity: 0; visibility: hidden; transform: translate(-50%, 12px);
  transition: opacity .4s ease, transform .4s ease, visibility 0s .4s, background-color .5s ease, border-color .5s ease, box-shadow .5s ease;
}
.stage.is-sql .sql {
  opacity: 1; visibility: visible; transform: translate(-50%, 0);
  transition: opacity .6s ease, transform .6s ease, background-color .5s ease, border-color .5s ease, box-shadow .5s ease;
}

.sql__bar, .sql__status {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--snr-ink-soft);
  transition: opacity .4s ease;
}
.sql__bar { border-bottom: 1px solid var(--line); }
.sql__bar i { width: 9px; height: 9px; border-radius: 50%; background: rgba(233, 238, 244, .18); }
.sql__file { margin-left: 10px; text-transform: none; letter-spacing: .04em; }
.sql__run {
  margin-left: auto; padding: 2px 11px; border: 1px solid rgba(58, 224, 200, .4); border-radius: 999px;
  color: var(--snr-teal); transition: background-color .4s ease, box-shadow .4s ease;
}
.sql__run::before { content: "\25B6"; margin-right: 7px; font-size: 8px; }
.sql.is-run .sql__run { background-color: rgba(58, 224, 200, .16); box-shadow: 0 0 18px rgba(58, 224, 200, .3); }
.sql__status { justify-content: space-between; padding: 8px 14px; border-top: 1px solid var(--line); }
.sql__done { color: var(--snr-teal); opacity: 0; transition: opacity .4s ease .5s; }
.sql.is-run .sql__done { opacity: 1; }

.sql__body { display: grid; grid-template-columns: minmax(190px, .8fr) minmax(330px, 1.3fr) minmax(210px, .9fr); min-height: 0; }
.sql__pane { position: relative; min-width: 0; min-height: 0; overflow: hidden; padding: 16px 18px; transition: border-color .5s ease; }
.sql__pane + .sql__pane { border-left: 1px solid var(--line); }

/* pane headings: the mapping to noise / filter / signal */
.sql__tag { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; opacity: 0; transform: translateY(4px); transition: opacity .5s ease, transform .5s ease; }
.sql__tag b { font-family: var(--snr-display); font-weight: 500; font-size: clamp(20px, 2vw, 28px); line-height: 1; letter-spacing: -.03em; }
.sql__tag span { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--snr-ink-soft); }
.sql__pane--noise .sql__tag b { color: rgba(233, 238, 244, .6); text-shadow: 2px 0 0 rgba(217, 164, 91, .55), -2px 0 0 rgba(79, 124, 255, .6); }
.sql__pane--filter .sql__tag b { color: var(--snr-teal); }
.sql__pane--signal .sql__tag b { color: #fff; text-shadow: 0 0 18px rgba(58, 224, 200, .6); }
.sql.is-listed .sql__pane--noise .sql__tag, .sql.is-typed .sql__pane--filter .sql__tag, .sql.is-run .sql__pane--signal .sql__tag { opacity: 1; transform: none; }

/* noise: every table at once */
.sql__tables { list-style: none; }
.sql__tables li {
  display: flex; align-items: baseline; gap: 8px; padding: 2px 0; white-space: nowrap; transform-origin: left center;
  opacity: 0; transition: opacity .25s ease; transition-delay: calc(var(--i) * 20ms);
}
.sql.is-listed .sql__tables li { opacity: 1; }
.sql__tables li::before { content: ""; flex: none; align-self: center; width: 6px; height: 6px; border: 1px solid currentColor; opacity: .55; }
.sql__tables span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sql__tables i { font-style: normal; opacity: .5; }
.sql__tables li:nth-child(4n + 1) { color: rgba(217, 164, 91, .92); }
.sql__tables li:nth-child(4n + 2) { color: rgba(138, 165, 255, .92); }
.sql__tables li:nth-child(4n + 3) { color: rgba(58, 224, 200, .85); }
.sql__tables li:nth-child(4n + 4) { color: rgba(170, 183, 200, .92); }
.sql__more {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 18px 10px;
  background: linear-gradient(to bottom, rgba(13, 17, 23, 0), rgba(13, 17, 23, .96) 62%);
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--snr-ink-soft);
  opacity: 0; transition: opacity .4s ease;
}
.sql.is-listed .sql__more { opacity: 1; transition-delay: .5s; }

/* filter: the query, with the WHERE clause picked out */
.sql__code { counter-reset: ln; font-size: clamp(11.5px, .95vw, 13.5px); line-height: 1.8; color: rgba(233, 238, 244, .88); }
.sql__code .ln { display: block; white-space: pre; counter-increment: ln; transform-origin: center top; clip-path: inset(0 100% 0 0); }
.sql__code .ln::before { content: counter(ln); display: inline-block; width: 2ch; margin-right: 2ch; text-align: right; color: rgba(233, 238, 244, .28); }
.sql.is-typed .sql__code .ln { clip-path: inset(0 0 0 0); transition: clip-path .32s steps(18, end); transition-delay: calc(var(--i) * .2s); }
.sql__code b { font-weight: 500; color: #8fa6ff; }
.sql__code u { text-decoration: none; color: var(--snr-teal); }
.sql__code em { font-style: normal; color: var(--snr-amber); }
.sql__where {
  display: block; margin: 3px -10px; padding: 3px 9px; border: 1px solid transparent; border-radius: 8px;
  transition: background-color .6s ease, border-color .6s ease, box-shadow .6s ease;
}
.sql.is-typed .sql__where {
  background-color: rgba(58, 224, 200, .08); border-color: rgba(58, 224, 200, .5);
  box-shadow: 0 0 34px rgba(58, 224, 200, .14), inset 0 0 18px rgba(58, 224, 200, .08);
  transition-delay: 1.9s;
}

/* signal: the result */
.sql__grid { font-size: clamp(12px, 1vw, 14px); }
.sql__row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 8px 4px; border-bottom: 1px solid rgba(233, 238, 244, .09);
  color: #fff; text-shadow: 0 0 14px rgba(58, 224, 200, .45); transform-origin: left center;
  opacity: 0; transition: opacity .4s ease; transition-delay: calc(var(--i) * 90ms);
}
.sql.is-run .sql__row { opacity: 1; }
.sql__row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.sql__row--head { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--snr-ink-soft); text-shadow: none; }

/* phase 03: the window lets go of its contents (site.js animates the rows and lines themselves) */
.sql.is-melting { overflow: visible; background-color: transparent; border-color: transparent; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.sql.is-melting .sql__pane { overflow: visible; border-color: transparent; }
.sql.is-melting .sql__bar, .sql.is-melting .sql__status, .sql.is-melting .sql__more { opacity: 0; transition: opacity .4s ease; }
.sql.is-melting .sql__where { background-color: transparent; border-color: transparent; box-shadow: none; transition-delay: 0s; }
.sql.is-melting .sql__code .ln { clip-path: none; }

/* ---------- phase 04: phrases that melt into noise, and the mission ---------- */
.phrase {
  position: absolute; z-index: 3; max-width: min(44vw, 640px); pointer-events: none;
  font-family: var(--snr-display); font-weight: 500; font-size: clamp(19px, min(2.3vw, 4.2vh), 34px); line-height: 1.2; letter-spacing: -.01em;
  color: var(--snr-ink); text-shadow: 0 0 14px rgba(13, 17, 23, .9);
}
.phrase .w { display: inline-block; white-space: nowrap; }
.phrase .l { display: inline-block; opacity: 0; transition: opacity .35s ease; }
.phrase.is-in .l { opacity: 1; }

.mission {
  position: absolute; z-index: 3; right: var(--snr-gutter); top: calc(var(--snr-cy) + min(10vh, 84px) + clamp(28px, 5vh, 52px));
  max-width: min(42vw, 600px); text-align: right; text-wrap: balance;
  font-family: var(--snr-display); font-weight: 500; font-size: clamp(20px, min(2.6vw, 4.6vh), 40px); line-height: 1.12; letter-spacing: -.02em;
  color: #fff; text-shadow: 0 0 20px rgba(58, 224, 200, .55), 0 0 50px rgba(58, 224, 200, .25);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: opacity .45s ease, transform .45s ease, visibility 0s .45s;
}
.stage.is-mission .mission { opacity: 1; visibility: visible; transform: none; transition: opacity 1s ease, transform 1s ease; }

/* ---------- small screens / reduced motion ---------- */
@media (max-width: 860px) {
  .nav a span { display: none; }
  .nav a[aria-current] span { display: inline; }
  .stage .snr__lens-cap { display: block; }
  .stage .snr__word small { max-width: 34vw; }
  .snr__word--you small { margin-left: auto; margin-right: auto; }
  .copy--1 { grid-template-columns: 1fr; row-gap: 16px; }
  .sql { bottom: clamp(96px, 15vh, 130px); }
  .sql__body { grid-template-columns: 1fr; grid-template-rows: minmax(90px, 1fr) auto auto; }
  .sql__pane + .sql__pane { border-left: 0; border-top: 1px solid var(--line); }
  .sql__pane { padding: 12px 14px; }
  .sql__tag { flex-direction: row; align-items: baseline; gap: 10px; margin-bottom: 10px; }
  .sql__code { line-height: 1.6; }
  .sql__row { padding: 4px; }
  .phrase { max-width: calc(100% - 2 * var(--snr-gutter)); }
  .mission { max-width: 78vw; }
}
@media (prefers-reduced-motion: reduce) {
  .stage *, .stage *::before, .stage *::after { transition: none !important; }
  .snr__word--noise > span { animation: none; }
  /* nothing melts, so the phrases are listed where the noise is */
  .stage[data-phase="4"] .phrases {
    left: var(--snr-gutter); top: calc(var(--snr-cy) + min(10vh, 84px) + clamp(28px, 5vh, 52px));
    width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; list-style: none;
    max-width: 40vw; font-size: 10.5px; line-height: 1.9; letter-spacing: .12em; text-transform: uppercase; color: var(--snr-ink-soft);
  }
}
