/* buildbox.run. The colors are the init wizard's: the cube's faces and
   pieces from internal/wizard/banner.go, brass for commands as in
   internal/console. Light and dark follow the system, as the wizard does. */

@font-face {
  font-family: "Sora";
  src: url("fonts/sora.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "Red Hat Mono";
  src: url("fonts/red-hat-mono.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --bg: light-dark(#F3F6F5, #0B1A1E);
  --text: light-dark(#1A3632, #CFDEDB);
  --strong: light-dark(#0F3B38, #F0F7F5);
  --muted: light-dark(#4F6A66, #8FA7A3);
  --line: light-dark(#D3DFDC, #1D3337);
  --panel: light-dark(#E2ECE9, #10262B);
  --link: light-dark(#167A6C, #3DBBA5);
  --brass: light-dark(#8A5A22, #E0B15A);
  --select: light-dark(#B5E6DB, #17574F);

  --face-t: light-dark(#0F3B38, #17574F);
  --face-l: light-dark(#167A6C, #1C8C7A);
  --face-r: light-dark(#1F9E8A, #2BB8A0);
  --piece-0: light-dark(#0F3B38, #17574F);
  --piece-1: light-dark(#1A8574, #239E8A);
  --piece-2: light-dark(#2FA592, #3DBBA5);
  --piece-3: light-dark(#5FC4B0, #86D9C7);
  --piece-4: light-dark(#8ED8C8, #9FE2D3);
  --piece-5: light-dark(#B5E6DB, #C8F2E8);
  --wordmark-from: light-dark(#0F3B38, #2BB8A0);
  --wordmark-to: light-dark(#1F9E8A, #B4ECDF);

  /* The terminal is dark in both themes, like the screenshots. */
  --term-bg: light-dark(#0C1E23, #0F2429);
  --term-edge: light-dark(#0C1E23, #1D3337);
  --term-text: #D3E0DD;
  --term-strong: #F2F7F6;
  --term-muted: #8BA29E;
  --term-faint: #5F7773;
  --term-brass: #E0B15A;
  --term-moss: #8FCBB0;

  --sans: "Sora", ui-sans-serif, system-ui, sans-serif;
  --mono: "Red Hat Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* One pixel of the cube and the wordmark. */
  --px: clamp(6px, 2vw, 12px);
  --gutter: clamp(16px, 4vw, 40px);
  --measure: 34rem;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--select);
  color: var(--strong);
}

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

h2,
h3 {
  color: var(--strong);
  font-weight: 600;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

h3 {
  font-size: 1.0625rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

p,
dd {
  text-wrap: pretty;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

code {
  font-family: var(--mono);
  font-size: 0.97em;
  color: var(--brass);
}

:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
  border-radius: 3px;
}

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

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: 0.5rem 0.75rem;
  background: var(--strong);
  color: var(--bg);
  border-radius: 6px;
  z-index: 10;
}

.skip:focus {
  top: 12px;
}

/* Header */

.top {
  display: flex;
  justify-content: flex-end;
  padding: 20px var(--gutter);
}

.top-link {
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
}

.top-link:hover {
  color: var(--strong);
}

/* Hero: init's loading screen, at web scale. */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(8px, 4vh, 48px) var(--gutter) clamp(72px, 12vh, 136px);
  text-align: center;
}

.cube {
  width: calc(42 * var(--px));
  height: calc(26 * var(--px));
  display: block;
}

.face-t { fill: var(--face-t); }
.face-l { fill: var(--face-l); }
.face-r { fill: var(--face-r); }
.p0 { fill: var(--piece-0); }
.p1 { fill: var(--piece-1); }
.p2 { fill: var(--piece-2); }
.p3 { fill: var(--piece-3); }
.p4 { fill: var(--piece-4); }
.p5 { fill: var(--piece-5); }
.wordmark-from { stop-color: var(--wordmark-from); }
.wordmark-to { stop-color: var(--wordmark-to); }

.wordmark {
  margin-top: calc(2 * var(--px));
  line-height: 0;
}

.wordmark svg {
  width: calc(33 * var(--px));
  height: calc(6 * var(--px));
}

.tagline {
  margin-top: calc(2.5 * var(--px));
  color: var(--muted);
  font-family: var(--mono);
  font-size: clamp(0.9375rem, 0.85rem + 0.3vw, 1.0625rem);
  letter-spacing: 0.01em;
}

.lede {
  max-width: 30ch;
  margin-top: clamp(28px, 5vh, 48px);
  color: var(--strong);
  font-size: clamp(1.3125rem, 1rem + 1.2vw, 1.75rem);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.install {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  margin-top: 32px;
  padding: 6px 6px 6px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: left;
}

.install-command {
  overflow-x: auto;
  padding: 8px 0;
  font-size: clamp(0.8125rem, 0.75rem + 0.3vw, 0.9375rem);
  white-space: nowrap;
  scrollbar-width: none;
}

.install-prompt {
  color: var(--muted);
  user-select: none;
}

.copy,
.replay {
  flex: none;
  min-width: 5.5rem;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--strong);
  color: var(--bg);
  font: 500 0.875rem/1.4 var(--sans);
  cursor: pointer;
}

.copy:hover,
.replay:hover {
  background: var(--link);
}

.needs {
  max-width: 44ch;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Sections */

.section {
  width: min(100% - 2 * var(--gutter), 72rem);
  margin-inline: auto;
  padding-block: clamp(64px, 9vw, 112px);
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  gap: 16px;
  max-width: var(--measure);
  margin-bottom: clamp(36px, 5vw, 56px);
}

.section-head p {
  color: var(--muted);
}

/* The run: four commands and a replay of create. */

.run {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(40px, 6vw, 88px);
  align-items: start;
}

.run-text > p {
  max-width: var(--measure);
  margin-top: 16px;
  color: var(--muted);
}

.steps {
  display: grid;
  gap: 24px;
  margin-top: 40px;
  padding: 0;
  list-style: none;
}

/* Each step is a piece drifting off the cube: darker first, lighter last. */
.steps li {
  position: relative;
  padding-left: 30px;
}

.steps li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 12px;
  height: 12px;
  background: var(--piece-1);
}

.steps li:nth-child(2)::before { background: var(--piece-2); }
.steps li:nth-child(3)::before { background: var(--piece-3); }
.steps li:nth-child(4)::before { background: var(--piece-4); }

.steps li > code {
  font-size: 1rem;
  font-weight: 500;
}

.steps p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.steps p code {
  font-size: 0.95em;
}

.term {
  container-type: inline-size;
  min-width: 0;
  position: sticky;
  top: 32px;
}

.term-screen {
  overflow-x: auto;
  padding: 1.6em 1.5em;
  background: var(--term-bg);
  border: 1px solid var(--term-edge);
  border-radius: 14px;
  color: var(--term-text);
  font-family: var(--mono);
  /* 64 columns fit from about 620px; narrower screens scroll. */
  font-size: clamp(11px, 2.3cqi, 14px);
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--term-faint) transparent;
}

.term-screen .ln {
  min-height: 1lh;
  white-space: pre;
}

.term-screen b {
  color: var(--term-strong);
  font-weight: 600;
}

.term-screen .t-brass,
.term-screen b.t-brass {
  color: var(--term-brass);
}

.t-muted { color: var(--term-muted); }
.t-faint { color: var(--term-faint); }
/* ✓ and the spinner come from a fallback font; hold them to one column. */
.t-icon {
  display: inline-block;
  width: 1ch;
  color: var(--term-moss);
  text-align: center;
}

.t-icon.is-spinning { color: var(--term-brass); font-weight: 600; }

.t-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.15em;
  margin-bottom: -0.2em;
  background: var(--term-muted);
}

.t-cursor[hidden] {
  display: none;
}

.ln.is-pending {
  visibility: hidden;
}

.term-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 40px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.replay {
  min-width: 0;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--strong);
  font-size: 0.8125rem;
}

.replay:hover {
  background: var(--panel);
}

.replay[hidden] {
  display: none;
}

/* The box: what the agent has inside, and what stays out. */

.box-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(40px, 6vw, 88px);
  align-items: start;
}

.inside {
  --u: clamp(12px, 1.6vw, 18px);
  position: relative;
}

/* The panel's corner is bitten off in steps, like the cube's. */
.inside-panel {
  padding: clamp(28px, 4vw, 48px);
  padding-right: calc(3 * var(--u) + 16px);
  background: var(--panel);
  clip-path: polygon(
    0 0,
    calc(100% - 3 * var(--u)) 0,
    calc(100% - 3 * var(--u)) var(--u),
    calc(100% - 2 * var(--u)) var(--u),
    calc(100% - 2 * var(--u)) calc(2 * var(--u)),
    calc(100% - var(--u)) calc(2 * var(--u)),
    calc(100% - var(--u)) calc(3 * var(--u)),
    100% calc(3 * var(--u)),
    100% 100%,
    0 100%
  );
}

/* Pieces leave the bite in pairs, darker first, as the hero's do. */
.bit {
  position: absolute;
  width: var(--u);
  height: var(--u);
}

.bit-1 {
  right: calc(-1.5 * var(--u));
  top: calc(1.25 * var(--u));
  background: var(--piece-0);
}

.bit-2 {
  right: calc(-1.5 * var(--u));
  top: calc(-0.25 * var(--u));
  background: var(--piece-1);
}

.bit-3 {
  right: calc(-3 * var(--u));
  top: calc(-0.25 * var(--u));
  background: var(--piece-2);
}

.bit-4 {
  right: calc(-3 * var(--u));
  top: calc(-1.75 * var(--u));
  background: var(--piece-3);
}

.facts {
  display: grid;
  gap: 22px;
  margin-top: 24px;
}

.facts dt {
  color: var(--strong);
  font-weight: 600;
  font-size: 0.9375rem;
}

.facts dt code {
  font-size: 1em;
  font-weight: 500;
}

.facts dd {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9375rem;
  max-width: 36rem;
}

.outside {
  padding-top: clamp(28px, 4vw, 48px);
}

.outside h3 {
  color: var(--muted);
}

/* Commands */

.command-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.command-list > div {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 8px 32px;
  padding-block: 18px;
  border-bottom: 1px solid var(--line);
}

.command-list dt code {
  font-size: 0.9375rem;
  font-weight: 500;
}

.command-list dd {
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Footer */

.foot {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px 32px;
  align-items: center;
  width: min(100% - 2 * var(--gutter), 72rem);
  margin-inline: auto;
  padding-block: 40px 56px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.foot-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--strong);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.foot-mark svg {
  width: 20px;
  height: 22px;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 24px;
}

.foot-links a {
  color: var(--muted);
  text-decoration: none;
}

.foot-links a:hover {
  color: var(--strong);
  text-decoration: underline;
}

.foot-note {
  grid-column: 1 / -1;
  font-size: 0.8125rem;
}

/* Narrow screens */

@media (max-width: 880px) {
  .run,
  .box-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .term {
    position: static;
  }

  .outside {
    padding-top: 0;
  }

  /* Room on the right for the pieces once the panel spans the column. */
  .inside {
    margin-right: calc(4 * var(--u));
  }
}

@media (max-width: 560px) {
  .command-list > div {
    grid-template-columns: minmax(0, 1fr);
  }

  .foot {
    grid-template-columns: minmax(0, 1fr);
  }

  .foot-links {
    justify-content: flex-start;
  }

  .install {
    flex-direction: column;
    align-items: stretch;
    padding: 6px;
  }

  /* The whole command stays visible, broken after the owner if need be. */
  .install-command {
    padding: 10px 12px 6px;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
