/* Off the Chain — see docs/LAUNCHKIT or the launchkit artifact for the rationale.
 *
 * The idea in one line: the page is black on sour lemon, and the *answer*
 * inverts to lemon on black. That inversion is the only loud moment; everything
 * else stays flat and quiet.
 */

:root {
  /* Ground and ink. */
  --sour:  #E9FF4F;   /* the brand ground */
  --ink:   #0D0D08;   /* near-black with a green cast, so it sits on the lemon */
  --ink-70: color-mix(in srgb, var(--ink) 70%, var(--sour));
  --ink-45: color-mix(in srgb, var(--ink) 45%, var(--sour));

  /* Accents are valid hexspeak words, and they carry meaning rather than mood:
     mint marks a value that is exact, pink marks one that is lossy. */
  --coffee: #C0FFEE;  /* exact */
  --facade: #FACADE;  /* lossy / approximate */

  --rule: 2px solid var(--ink);

  --step--1: clamp(0.78rem, 0.74rem + 0.2vw, 0.86rem);
  --step-0:  clamp(0.96rem, 0.92rem + 0.2vw, 1.05rem);
  --step-1:  clamp(1.2rem, 1.1rem + 0.5vw, 1.45rem);
  --step-2:  clamp(1.6rem, 1.4rem + 1vw, 2.2rem);

  --gap: clamp(1.1rem, 0.8rem + 1.4vw, 2rem);
  --pad: clamp(1.1rem, 0.6rem + 2.6vw, 3.25rem);

  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--sour);
  color: var(--ink);
  font-family: Archivo, "Helvetica Neue", Arial, sans-serif;
  font-variation-settings: "wdth" 100;
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 10;
  background: var(--ink); color: var(--sour); padding: 0.6rem 1rem;
}
.skip:focus { left: 0; }

/* Focus is never removed, only restyled. Two-tone so it reads on both grounds. */
:where(a, button, input):focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}
.answer :where(button, input):focus-visible { outline-color: var(--sour); }

/* ── sign in ────────────────────────────────────────────────────────── */

.gate {
  min-height: 100svh;
  display: grid;
  align-content: center;
  padding: var(--pad);
  /* The wordmark runs to the left edge, so the gate manages its own left inset. */
  padding-left: 0;
  overflow-x: clip;
}

/* Asymmetric on purpose: the wordmark is a poster hanging off the left edge and
   the form sits opposite it, rather than both stacked down a centred column. */
.gate-inner {
  display: grid;
  gap: var(--gap);
  align-items: end;
  width: 100%;
  max-width: 78rem;
  margin-inline: auto;
}

@media (min-width: 56rem) {
  .gate-inner {
    grid-template-columns: minmax(0, 1.35fr) minmax(20rem, 0.65fr);
    gap: clamp(2rem, 4vw, 5rem);
  }
}

.gate-brand { padding-left: var(--pad); }
.form { padding-right: var(--pad); }

@media (min-width: 56rem) {
  /* Pull the wordmark past the gutter so it reads as trimmed by the page edge. */
  .gate-brand { padding-left: clamp(0.75rem, 2.2vw, 2.5rem); }
}

/* The wordmark is the type doing work, not labelling it: stacked, expanded,
   tight enough to read as a single block. */
.wordmark {
  margin: 0;
  font-size: clamp(3.4rem, 0.5rem + 13vw, 9.5rem);
  font-weight: 900;
  font-variation-settings: "wdth" 118;
  line-height: 0.82;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.tagline {
  margin: 1.1rem 0 0;
  font-size: var(--step-1);
  max-width: 26ch;
  text-wrap: balance;
}

.form { display: grid; gap: 0.9rem; align-content: end; }

.field { display: grid; gap: 0.35rem; }

label {
  font-size: var(--step--1);
  font-weight: 600;
}

input {
  font: inherit;
  font-family: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: var(--step--1);
  font-variation-settings: "wdth" 87.5;
  width: 100%;
  padding: 0.7rem 0.8rem;
  color: var(--ink);
  background: transparent;
  border: var(--rule);
  border-radius: 3px;
}
input::placeholder { color: var(--ink-45); }

.btn {
  font: inherit;
  font-weight: 800;
  font-variation-settings: "wdth" 108;
  letter-spacing: 0.01em;
  padding: 0.72rem 1.4rem;
  color: var(--sour);
  background: var(--ink);
  border: var(--rule);
  border-radius: 3px;
  cursor: pointer;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 82%, var(--sour)); }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.65; }

.note { margin: 0.2rem 0 0; font-size: var(--step--1); min-height: 1.4em; }
.note[data-tone="bad"] {
  font-weight: 600;
  /* A box rather than red text: the ground is already yellow, and red on
     yellow is the one combination that fails everywhere. */
  background: var(--ink);
  color: var(--facade);
  padding: 0.5rem 0.7rem;
  border-radius: 3px;
}

/* ── explorer ───────────────────────────────────────────────────────── */

.app {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 0 var(--pad);
}

.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: var(--rule);
}

.mark {
  font-weight: 900;
  font-variation-settings: "wdth" 118;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  font-size: var(--step-1);
}

.linkish {
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  background: none;
  border: 0;
  border-bottom: 2px solid var(--ink);
  padding: 0 0 1px;
  color: inherit;
  cursor: pointer;
}

main { padding: var(--gap) 0; display: grid; gap: var(--gap); align-content: start; }

.lookup { display: grid; gap: 0.4rem; max-width: 46rem; }

.lookup-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.lookup-row input { flex: 1 1 20rem; }

.samples { margin: 0.3rem 0 0; font-size: var(--step--1); color: var(--ink-70); }
.sample {
  font: inherit;
  font-weight: 600;
  background: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0;
  color: inherit;
  cursor: pointer;
}

.empty { max-width: 52ch; display: grid; gap: 0.6rem; }
.empty p { margin: 0; }
.empty-lead { font-size: var(--step-2); font-weight: 700; max-width: 18ch; line-height: 1.1; }
.empty-note { color: var(--ink-70); max-width: 46ch; }

/* ── the answer: the one inverted block ─────────────────────────────── */

.answer {
  background: var(--ink);
  color: var(--sour);
  border-radius: 4px;
  padding: var(--pad);
  /* Room for a 21-digit number without the page scrolling sideways. */
  overflow-x: auto;
}

.wei {
  margin: 0;
  /* Condensed and heavy, because the whole point is fitting a very long integer
     at a size that still reads as the headline. */
  font-weight: 800;
  font-variation-settings: "wdth" 68;
  font-size: clamp(2.6rem, 0.4rem + 10.5vw, 7.5rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Thin gaps every three digits, the way a ledger groups them. A comma at this
   size reads as punctuation in a sentence; a gap reads as scale. */
.digits .g + .g { margin-left: 0.22em; }

/* A 26-digit balance is a real value, not an edge case -- the beacon deposit
   contract is one. Stepping the size down keeps it a headline instead of a
   horizontal scroll. */
.wei[data-length="long"]  { font-size: clamp(1.9rem, 0.2rem + 7.6vw, 5.4rem); }
.wei[data-length="epic"]  { font-size: clamp(1.35rem, 0.2rem + 5.6vw, 4rem); }

.wei-unit {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 0.7rem 0 0;
}

.unit {
  font-weight: 700;
  font-size: var(--step-2);
  font-variation-settings: "wdth" 68;
}

.exact {
  font-size: var(--step--1);
  color: var(--coffee);
  font-family: "Martian Mono", ui-monospace, monospace;
  font-variation-settings: "wdth" 87.5;
}

.facts {
  margin: var(--gap) 0 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  padding-top: var(--gap);
  border-top: 2px solid color-mix(in srgb, var(--sour) 30%, var(--ink));
}

.fact > dt {
  font-size: var(--step--1);
  font-weight: 700;
  color: color-mix(in srgb, var(--sour) 62%, var(--ink));
}

.fact > dd {
  margin: 0.25rem 0 0;
  font-family: "Martian Mono", ui-monospace, monospace;
  font-variation-settings: "wdth" 87.5;
  word-break: break-all;
}

.lossy { font-size: var(--step-1); color: var(--facade); }

.addr { font-size: var(--step--1); line-height: 1.7; }
/* Uppercase hex is the EIP-55 checksum bit. Tinting it is information. */
.addr .up { color: var(--coffee); }

.gloss {
  margin: 0.55rem 0 0;
  font-size: var(--step--1);
  line-height: 1.45;
  max-width: 42ch;
  color: color-mix(in srgb, var(--sour) 58%, var(--ink));
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 0;
  border-top: var(--rule);
  font-size: var(--step--1);
  color: var(--ink-70);
}

/* ── motion ─────────────────────────────────────────────────────────── */
/* One moment, and it answers an action: the digits land when a balance
   resolves, so you can see that the number changed. Nothing else animates. */

@keyframes land {
  from { transform: translateY(0.32em); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.answer[data-fresh="true"] .digits .g {
  animation: land 260ms cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
}
