/* Agent Rules. Night on a canal: ink-blue ground, one lantern amber. */

@font-face {
  font-family: "Geist";
  src: url("fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --ground: #090b10;
  --surface: #10131b;
  --raised: #1a1f2c;
  --raised-hover: #232a3a;
  --line: rgb(214 224 255 / 0.1);
  --line-strong: rgb(214 224 255 / 0.18);
  --ink: #f2f1ee;
  --ink-2: #b2b7c6;
  --ink-3: #8b91a3;
  --lantern: #ff8a3d;
  --lantern-hover: #ffa262;
  --lantern-ink: #1d0d02;
  --ok: #7ed3a0;
  --stop: #ff8f86;

  --sans: "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pad: 32px;
}

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

html {
  height: 100%;
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}

/* One screen. The card scrolls inside itself rather than the page. */
body {
  height: 100vh;
  height: 100svh;
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
p,
ul,
pre {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

h1 {
  font-weight: 550;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
}

code,
pre,
kbd {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

code {
  font-size: 0.88em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

::selection {
  background: var(--lantern);
  color: var(--lantern-ink);
}

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

.wrap {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* --------------------------------------------------------------- painting -- */
/* The painting is the page. It covers whatever shape the screen is. */
.art {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #0b1226 url("art/lock.png") 50% 100% / cover no-repeat;
  image-rendering: pixelated;
}

.art canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 100%;
  image-rendering: pixelated;
}

/* Keeps the headline readable over the sky without hiding the scene. */
.veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgb(9 11 16 / 0.9) 0%,
    rgb(9 11 16 / 0.66) 24%,
    rgb(9 11 16 / 0.2) 48%,
    rgb(9 11 16 / 0.06) 68%,
    rgb(9 11 16 / 0.5) 100%
  );
}

.top,
main {
  position: relative;
  z-index: 2;
}

/* The hero keeps its height; the stage takes what is left and may shrink. */
main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.skip {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 20;
  padding: 12px 16px;
  background: var(--lantern);
  color: var(--lantern-ink);
  border-radius: 4px;
}

.skip:focus {
  top: 16px;
}

/* ------------------------------------------------------------------ header */
.top {
  padding-block: 14px;
}

.top-row {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 44px;
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-size: 1.25rem;
  font-weight: 550;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 160ms var(--ease);
}

.mark:hover {
  color: var(--lantern-hover);
}

.top nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.top nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 12px;
  border-radius: 4px;
  font: 400 13px/1 var(--mono);
  color: var(--ink-2);
  text-decoration: none;
  transition: color 160ms var(--ease), background-color 160ms var(--ease);
}

.top nav a:hover {
  color: var(--ink);
  background: var(--raised);
}

/* ----------------------------------------------------------------- buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 12px 0 20px;
  border: 0;
  border-radius: 4px;
  background: var(--lantern);
  color: var(--lantern-ink);
  font: 550 15px/1 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 160ms var(--ease), transform 120ms var(--ease);
}

.button:hover {
  background: var(--lantern-hover);
}

.button:active {
  transform: scale(0.97);
}

.button-small {
  min-height: 40px;
  gap: 8px;
  padding-inline: 16px;
  font-size: 13px;
}

/* The hero action is always on screen, so this one stays quiet. */
.top-copy {
  background: var(--raised);
  color: var(--ink);
}

.top-copy:hover {
  background: var(--raised-hover);
}

kbd {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  background: rgb(29 13 2 / 0.14);
  font-size: 13px;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

/* Two labels share one cell so the button never changes width. */
.swap {
  display: grid;
}

.swap > span {
  grid-area: 1 / 1;
  text-align: center;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.swap > span + span {
  opacity: 0;
  transform: translateY(6px);
}

.is-copied .swap > span {
  opacity: 0;
  transform: translateY(-6px);
}

.is-copied .swap > span + span {
  opacity: 1;
  transform: none;
}

/* -------------------------------------------------------------------- hero */
.hero {
  padding-top: clamp(8px, 2.4vh, 32px);
}

h1 {
  font-size: clamp(2rem, 4.4vw, 3.5rem);
  line-height: 1.06;
  letter-spacing: -0.032em;
}

.lead {
  max-width: 46em;
  margin-top: 12px;
  color: var(--ink-2);
  font-size: clamp(1rem, 1.5vw, 1.25rem);
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-top: clamp(14px, 2.2vh, 24px);
}

.status {
  color: var(--ink-3);
  font-size: 15px;
}

.status.is-live {
  color: var(--ink);
}

/* ------------------------------------------------------------------- stage */
.stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  padding-top: clamp(12px, 2.4vh, 28px);
  padding-bottom: clamp(12px, 2.4vh, 28px);
}

.stage > .wrap {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
}

.console {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  row-gap: 12px;
  min-height: 0;
  width: min(640px, 100%);
  margin-inline: auto;
}

.tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding: 4px;
  gap: 4px;
  overflow-x: auto;
  background: var(--surface);
  border-radius: 6px;
}

.tabs button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-2);
  font: 400 13px/1 var(--mono);
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms var(--ease), background-color 160ms var(--ease), transform 120ms var(--ease);
}

.tabs button:hover {
  color: var(--ink);
  background: var(--raised);
}

.tabs button:active {
  transform: scale(0.97);
}

.tabs button[aria-selected="true"] {
  background: var(--raised-hover);
  color: var(--ink);
}

.tabs button[aria-selected="true"]:hover {
  background: #2c3447;
}

.tabs button:focus-visible {
  outline-offset: -2px;
}

.narrow {
  display: none;
}

/* Grows with its content, then stops at the space left and scrolls inside. */
.card {
  align-self: start;
  min-height: 0;
  max-height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 24px 48px -24px rgb(0 0 0 / 0.7);
}

/* All panels occupy one cell, so switching never moves the page. */
.panels {
  min-height: 0;
  display: grid;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--raised-hover) transparent;
}

.panels::-webkit-scrollbar {
  width: 10px;
}

.panels::-webkit-scrollbar-track {
  background: transparent;
}

.panels::-webkit-scrollbar-thumb {
  border: 3px solid var(--surface);
  border-radius: 5px;
  background: var(--raised-hover);
}

/* Fades the last line while there is more to read below. */
.panels[data-more] {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent);
}

.panel {
  grid-area: 1 / 1;
  min-width: 0;
  padding: 20px 20px 16px;
}

.js .panel[data-hidden] {
  visibility: hidden;
}

html:not(.js) .panels {
  display: block;
}

html:not(.js) .tabs {
  display: none;
}

pre {
  font-size: 13px;
  line-height: 1.55;
}

.console pre {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--ink);
}

.console pre:focus-visible {
  outline-offset: 6px;
}

.changes li {
  position: relative;
  padding: 0 0 8px 20px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-2);
}

.changes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  background: var(--lantern);
}

#panel-hand p {
  margin-bottom: 12px;
  color: var(--ink-2);
  font-size: 15px;
}

#panel-hand pre {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 4px;
  background: var(--ground);
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 20px;
  border-top: 1px solid var(--line);
}

.card-foot p {
  margin-right: auto;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.4;
}

html:not(.js) kbd,
html:not(.js) .card-foot .button {
  display: none;
}

/* --------------------------------------------------------------- short screens */
/* Laptop height: draw the same page closer together. */
@media (max-height: 820px) {
  .top {
    padding-block: 10px;
  }

  h1 {
    font-size: clamp(1.75rem, 3.6vw, 2.75rem);
  }

  .lead {
    margin-top: 8px;
    font-size: 1rem;
  }

  .actions {
    margin-top: 14px;
  }

  .actions .button {
    min-height: 46px;
  }

  .stage {
    padding-top: 12px;
    padding-bottom: 16px;
  }

  .panel {
    padding: 14px 20px 10px;
  }

  .console pre {
    line-height: 1.45;
  }

  .changes li {
    padding-bottom: 4px;
    line-height: 1.4;
  }

  .card-foot {
    padding-block: 8px;
  }
}

/* Landscape phones and small windows: the headline carries the page. */
@media (max-height: 620px) {
  .top {
    padding-block: 6px;
  }

  h1 {
    font-size: clamp(1.5rem, 3vw, 2rem);
  }

  .lead {
    display: none;
  }

  .actions {
    margin-top: 10px;
  }

  .actions .button {
    min-height: 44px;
  }

  .stage {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .panel {
    padding: 12px 16px 8px;
  }

  .card-foot {
    padding-block: 6px;
  }
}

@media (max-height: 460px) {
  .status {
    display: none;
  }

  .top nav a:not(:last-child) {
    display: none;
  }
}

/* ------------------------------------------------------------------ narrow */
@media (max-width: 720px) {
  :root {
    --pad: 16px;
  }

  body {
    font-size: 16px;
  }

  .top-row {
    gap: 8px;
  }

  .mark {
    gap: 8px;
  }

  /* The hero button is on screen, so the header keeps one link. */
  .top nav a:not(:last-child) {
    display: none;
  }

  .top-copy {
    display: none;
  }

  .actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
  }

  h1 {
    font-size: clamp(1.5rem, 6.4vw, 2rem);
  }

  .lead {
    margin-top: 8px;
    font-size: 15px;
    line-height: 1.45;
  }

  .status {
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
  }

  .tabs button {
    padding-inline: 10px;
  }

  .panel {
    padding: 16px 16px 12px;
  }

  .card-foot {
    padding-left: 16px;
  }

  .card-foot p {
    display: none;
  }
}

@media (max-width: 360px) {
  .tabs button {
    padding-inline: 6px;
    letter-spacing: -0.01em;
  }

  /* Three full labels do not fit on one line at this width. */
  .wide {
    display: none;
  }

  .narrow {
    display: inline;
  }
}

/* Touch screens get 44px targets. */
@media (pointer: coarse) {
  .tabs button,
  .button-small {
    min-height: 44px;
  }
}

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

@media (forced-colors: active) {
  .button,
  .tabs button {
    border: 1px solid ButtonText;
  }

  .tabs button[aria-selected="true"] {
    outline: 2px solid Highlight;
    outline-offset: -4px;
  }
}
