/* 80085.ai — the whole design system.
 *
 * Two colours and two opacities of those same two colours. No accent, no
 * "just one blue for links". With no colour to lean on, hierarchy comes from
 * scale, weight, space, and inversion — which is what makes a page this plain
 * read as designed rather than as unstyled.
 */

:root {
  color-scheme: light dark;

  --ink: #000000;
  --paper: #ffffff;
  --ghost: rgba(0, 0, 0, 0.12); /* unlit LCD segments, hairlines */
  --ghost-i: rgba(255, 255, 255, 0.16); /* the same, inverted */

  --t-display: clamp(3rem, 14vw, 9rem);
  --t-h1: clamp(1.75rem, 5vw, 3rem);
  --t-h2: 1.25rem;
  --t-body: 1rem;
  --t-small: 0.8125rem;
  --t-micro: 0.6875rem;

  --space: 1.5rem;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

/* The black theme.
 *
 * There is no second palette to design: the whole system is ink on paper, so
 * a theme is the two tokens trading places. Every inverted block, every lit
 * and unlit segment, and every hairline follows automatically — which is the
 * same trick the readout and the FLIP are built on, applied to the page.
 *
 * Defined three times on purpose: the toggle must win in both directions, and
 * the untouched default must still follow the system. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --ink: #ffffff;
    --paper: #000000;
    --ghost: rgba(255, 255, 255, 0.16);
    --ghost-i: rgba(0, 0, 0, 0.12);
  }
}

:root[data-theme='dark'] {
  --ink: #ffffff;
  --paper: #000000;
  --ghost: rgba(255, 255, 255, 0.16);
  --ghost-i: rgba(0, 0, 0, 0.12);
}

:root[data-theme='light'] {
  --ink: #000000;
  --paper: #ffffff;
  --ghost: rgba(0, 0, 0, 0.12);
  --ghost-i: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  /* Monospace for everything, not just code. The page is literally 72
   * characters wide, so every column in every table aligns because it must. */
  font: var(--t-body) / 1.6 var(--mono);
  font-weight: 400;
}

/* --- layout ------------------------------------------------------------ */

.page {
  max-width: 72ch;
  margin: 0 auto;
  padding: 2rem;
}

@media (min-width: 48rem) {
  .page {
    padding: 4rem 2rem;
  }
}

section {
  margin: calc(var(--space) * 2) 0;
}

.rule {
  color: var(--ghost);
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
  margin: calc(var(--space) * 2) 0;
}

/* --- type -------------------------------------------------------------- */

h1,
h2,
h3 {
  font-size: var(--t-h2);
  font-weight: 700;
  margin: 0 0 var(--space);
  line-height: 1.3;
}

.lead {
  font-size: var(--t-h1);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.02em;
}

.sub {
  opacity: 0.6;
  margin: 0.5rem 0 0;
}

p {
  margin: 0 0 var(--space);
  max-width: 68ch;
}

pre {
  font: inherit;
  margin: 0 0 var(--space);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Tabular blocks must not wrap — they are aligned by hand and wrapping is a
 * lie about the data. They scroll inside themselves instead. */
pre.grid {
  white-space: pre;
  overflow-x: auto;
  font-size: var(--t-small);
}

.centre {
  text-align: center;
  margin: calc(var(--space) * 1.5) 0;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

/* --- inversion: the only emphasis available ---------------------------- */

.invert {
  background: var(--ink);
  color: var(--paper);
  padding: calc(var(--space) * 1.5);
  margin-left: -1rem;
  margin-right: -1rem;
}

.invert .seg .on {
  fill: var(--paper);
}

.invert .seg .off {
  fill: var(--ghost-i);
}

.invert a,
.invert .num {
  color: var(--paper);
}

.invert .box,
.invert code,
.invert .copy {
  border-color: var(--paper);
}

/* --- the seven-segment readout ----------------------------------------- */

.seg {
  display: block;
  width: 0.62em;
  height: 1em;
  flex: none;
}

.seg .on {
  fill: var(--ink);
}

.seg .off {
  fill: var(--ghost);
}

.readout {
  display: flex;
  gap: 0.06em;
  justify-content: flex-end;
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--ink);
}

/* The 200ms confirmation flash. Not a prize, just an acknowledgement. */
.readout.flash {
  background: var(--ink);
}

.readout.flash .on {
  fill: var(--paper);
}

.readout.flash .off {
  fill: var(--ghost-i);
}

/* Section numbers, in the same glyphs as the readout, so the page reads as
 * one machine rather than a document with a calculator glued to the top. */
.num {
  display: inline-flex;
  gap: 0.05em;
  font-size: 0.85em;
  vertical-align: -0.05em;
  margin-right: 0.6em;
}

/* --- the calculator ----------------------------------------------------- */

.calc {
  width: min(90vw, 420px);
  margin: 0 auto calc(var(--space) * 2);
  border: 1px solid var(--ink);
  /* The only rounded thing on a square page: a physical object sitting on a
   * text document. */
  border-radius: 12px;
  overflow: hidden;
}

.keys {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.4fr;
  gap: 1px;
  background: var(--ghost);
  padding: 1px;
}

.keys button {
  font: inherit;
  font-size: 1.05rem;
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 6px;
  padding: 0.85rem 0;
  cursor: pointer;
  transition: background 120ms ease-out, color 120ms ease-out;
}

.keys button:hover,
.keys button:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.keys button:active {
  background: var(--ink);
  color: var(--paper);
}

.found {
  text-align: center;
  font-size: var(--t-small);
  margin: calc(var(--space) * -1) 0 var(--space);
}

/* --- code, copy buttons, boxes ------------------------------------------ */

.code {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid currentColor;
  padding: 0.85rem 1rem;
  margin: 0 0 var(--space);
}

.code pre {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  white-space: pre;
  font-size: var(--t-small);
}

.copy {
  flex: none;
  font: inherit;
  font-size: var(--t-small);
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 0;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
}

/* The entire signup flow, visually. It should look like the most obvious
 * thing on the page, because pressing it is the whole process. */
.mint {
  font: inherit;
  font-weight: 700;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: opacity 120ms ease-out;
}

.mint:hover:not(:disabled) {
  opacity: 0.75;
}

.mint:disabled {
  cursor: default;
  opacity: 0.5;
}

/* A prompt nobody can find is a prompt nobody uses, and terminal mode is the
 * most convincing thing here. */
.tryit {
  display: block;
  width: min(90vw, 420px);
  margin: calc(var(--space) * -1) auto var(--space);
  font: inherit;
  font-size: var(--t-small);
  text-align: left;
  background: transparent;
  color: inherit;
  border: 1px dashed var(--ink);
  border-radius: 0;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  opacity: 0.7;
}

.tryit:hover,
.tryit:focus-visible {
  opacity: 1;
  background: var(--ink);
  color: var(--paper);
}

.box {
  border: 1px solid currentColor;
  padding: var(--space);
  margin: 0 0 var(--space);
}

.box .title {
  font-weight: 700;
  display: block;
  margin-bottom: 0.5rem;
}

/* --- steps, tables, columns, status ------------------------------------- */

.steps {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space);
}

.steps > li {
  margin-bottom: var(--space);
}

.steps .n {
  font-weight: 700;
  margin-right: 0.6em;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 var(--space);
  font-size: var(--t-small);
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 0.8rem 0.5rem 0;
  border-bottom: 1px solid var(--ghost);
}

th {
  font-weight: 700;
  border-bottom: 1px solid currentColor;
}

.cols {
  display: grid;
  gap: var(--space);
  grid-template-columns: 1fr;
  margin: 0 0 var(--space);
}

@media (min-width: 40rem) {
  .cols {
    grid-template-columns: repeat(3, 1fr);
  }
}

.cols h3 {
  font-size: var(--t-small);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.cols p {
  font-size: var(--t-small);
  margin: 0;
}

.status {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space);
  font-size: var(--t-small);
}

.status li {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--ink);
  margin-bottom: -1px;
}

/* The only place dashes are permitted: things that are not done yet. */
.status li.todo {
  border-style: dashed;
}

.status .what {
  flex: 1 1 auto;
}

.status .note {
  opacity: 0.6;
}

@media (max-width: 34rem) {
  .status li {
    flex-wrap: wrap;
  }
}

.faq dt {
  font-weight: 700;
  margin-top: var(--space);
}

.faq dd {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
  opacity: 0.85;
}

details {
  border: 1px solid currentColor;
  padding: 0.75rem 1rem;
  margin: 0 0 var(--space);
}

summary {
  cursor: pointer;
  font-size: var(--t-small);
}

details[open] summary {
  margin-bottom: var(--space);
}

/* --- chrome ------------------------------------------------------------- */

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: var(--t-small);
  margin-bottom: calc(var(--space) * 2);
}

.top nav {
  display: flex;
  gap: 0.5rem;
}

.top button {
  font: inherit;
  font-size: var(--t-small);
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 0;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  transition: background 120ms ease-out, color 120ms ease-out;
}

.top button:hover {
  background: var(--ink);
  color: var(--paper);
}

footer {
  font-size: var(--t-small);
  margin-top: calc(var(--space) * 3);
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  position: static;
  display: inline-block;
  margin-bottom: var(--space);
}

/* Contrast is 21:1 here, so it costs nothing — do not squander it. */
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* --- the flip ----------------------------------------------------------- */

.stage {
  transform-origin: center center;
}

/* Both states stay in the DOM at all times. `visibility: hidden` rather than
 * `display: none` keeps the page height stable, so flipping never shifts
 * layout and never moves the reader's scroll position. */
[data-state='hidden'] {
  visibility: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
}

.states {
  position: relative;
}

/* The page fades in after the boot self-test. Gated on `.js`, which boot.js
 * sets in <head>: with JavaScript disabled the class never appears and the
 * content is simply visible, which is the requirement. */
.js .states {
  transition: opacity 300ms ease-out;
}

.js body:not(.ready) .states {
  opacity: 0;
}

/* --- terminal ----------------------------------------------------------- */

.term {
  position: fixed;
  inset: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 10;
  font-size: var(--t-small);
  line-height: 1.5;
}

.term[hidden] {
  display: none;
}

.term pre {
  white-space: pre-wrap;
  margin: 0;
}

.term .line {
  display: flex;
  gap: 0.5ch;
}

.term input {
  font: inherit;
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  color: inherit;
  outline: none;
  padding: 0;
}

/* --- motion ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* --- print: a one-page install cheat sheet ------------------------------ */

@media print {
  /* Paper is paper. Nobody wants the black theme rendered onto a sheet. */
  :root {
    --ink: #000000;
    --paper: #ffffff;
    --ghost: rgba(0, 0, 0, 0.12);
  }

  .calc,
  .top,
  .term,
  .rule,
  .copy,
  details,
  .status,
  .faq {
    display: none !important;
  }

  [data-state='hidden'] {
    display: none;
  }

  .invert {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--ink);
  }

  .page {
    max-width: none;
    padding: 0;
  }

  body {
    font-size: 10pt;
  }
}
