/* Fire Blackbox's own rules, on top of the Fire site kit (public/fire-site-kit):
   its console shell and console layer for the console, its story look for
   the colours, the families, and the doors. Only what is the Box's own is
   here. Tokens only: every colour, size, and space is the kit's. */

/* ── The page ────────────────────────────── */

/* Under the header, no more room than the header itself (owner, 2026-11-17). */
.page {
  padding: var(--nav-height) 0 var(--space-16);
}

/* A console page's parts down its column. */
.box-console {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.box-console > .console-head {
  margin-bottom: 0;
}

/* Each part may be narrower than its content, so a wide table scrolls within
   its own box (.console-table) instead of widening the page. */
.box-console > * {
  min-width: 0;
}

/* Facts in a dialog or the panel: a narrow name column, so the value has the room. */
.console-modal table.console-data.facts tbody th,
.console-panel table.console-data.facts tbody th {
  width: 7rem;
}

/* A step that takes another's place (a form, then its link or phrase). They
   are sections, which the kit's layout.css gives 96px above and below. */
.box-step {
  padding: 0;
}

.box-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.box-step[hidden] {
  display: none;
}

.box-step > h2:not(.story-headline) {
  margin: 0;
  font-size: var(--text-xl);
}

/* A form's button in the side (a seat to switch to, Sign out): as wide as its links. */
.console-side form > .console-side__link {
  width: 100%;
}

/* A form: no wider than a reading line. */
.box-form {
  max-width: 560px;
}

/* Part of a form that waits to be shown (the claim's business name, until
   its license checks out): no room at all until box.js opens it, the form's
   gap above it (base.css, .form) taken back too; then it slides down into
   place, at the slow pace, and back up if closed again. Where motion is
   reduced it simply appears. */
.box-reveal {
  display: grid;
  grid-template-rows: 0fr;
  margin-top: calc(-1 * var(--space-6));
  opacity: 0;
  transition: grid-template-rows var(--duration-slow) var(--ease-out),
              margin-top var(--duration-slow) var(--ease-out),
              opacity var(--duration-slow) var(--ease-out);
}

.box-reveal-open {
  grid-template-rows: 1fr;
  margin-top: 0;
  opacity: 1;
}

.box-reveal__inner {
  min-height: 0;
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .box-reveal {
    transition: none;
  }
}

/* A field shown and not typed (the claim's business name, from its license;
   a price's code once made): its value in the quieter grey, with no line to
   write on, so it does not read as a place to type. */
.field input[readonly] {
  border-bottom-color: transparent;
  color: var(--text-2);
  cursor: default;
}

/* One line of what the reader needs to know, and no more. */
.box-note {
  max-width: 640px;
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-2);
}

/* The Treasury's balance, and what can be done with it. */
.box-balance {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-8);
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.box-balance__label {
  flex-basis: 100%;
  margin: 0 0 calc(-1 * var(--space-3));
  font: 500 11px/1.4 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.box-balance__amount {
  margin: 0;
  font: 400 clamp(36px, 4vw, 48px)/1 var(--serif);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.box-balance__unit {
  font: 500 var(--text-sm)/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--text-2);
}

.box-balance__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* With no label (the Treasury's own page), its buttons go under the amount. */
.box-balance-stacked .box-balance__actions {
  flex-basis: 100%;
}

/* ── The Box's own parts ───────────────────── */

/* Sign out is a form's button: in a door's header it looks like the header's
   links, and in the console's side like the side's. */
.box-signout {
  margin: 0;
}

/* The size, colour, and padding are the kit's link's (.site-nav__link). */
.box-signout__button {
  background: none;
  border: 0;
  font-family: inherit;
  cursor: pointer;
}

/* A field's own error, under it (fire-design: errors below the field). */
.box-field-error {
  margin: var(--space-1) 0 0;
  min-height: 0;
  color: var(--down);
  font-size: var(--text-sm);
}

.box-field-error:empty {
  display: none;
}

/* A field's good news, under it: the license's licensee. */
.box-field-note {
  margin: var(--space-1) 0 0;
  color: var(--ok);
  font-size: var(--text-sm);
}

.box-field-note:empty {
  display: none;
}

/* The recovery phrase: 24 numbered words, set to be copied by hand. */
.box-phrase {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: var(--space-4) var(--space-4) var(--space-4) var(--space-12);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: var(--text-base);
  color: var(--text);
}

/* Under the phrase: "I have written them down", which turns Continue on,
   and Copy at the row's right (owner, 2026-11-19). */
.box-phrase-check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
}

/* The phrase's Copy at the row's right, with room for its flag at its left. */
.box-phrase-copy {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

/* Every copy's flag (components.ts, copiedFlag; owner, 2026-11-19): "Copied",
   green with its check, to the left of what copied, for a moment (box.js,
   flashCopied). Beside a button in a row, it takes its place in the row. */
.box-copied {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--ok);
  font-size: var(--text-sm);
}

.box-copied[hidden] {
  display: none;
}

.box-copied > svg {
  width: 18px;
  height: 18px;
}

/* Addresses and money: monospaced, wrapped, never cut (fire-design: wrap over truncate). */
.box-address,
.box-money {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  color: var(--text);
}

.box-address {
  font-size: var(--text-sm);
}

/* A value with Copy beside it (components.ts, copyable): the button keeps
   its size as the value wraps; once it has copied, its flag floats at its
   left (below). */
.box-copyable {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 100%;
}

.box-copyable > .box-address {
  min-width: 0;
}

.box-copy {
  flex: none;
}

/* Named as fully as the kit's .console-icon-btn svg, which shows every icon:
   Copy's, and a small icon button's or link's (auto top-up's Edit, every
   View), at 16px. */
.console-icon-btn.box-copy > svg,
.console-icon-btn.box-icon-small > svg {
  width: 16px;
  height: 16px;
}

/* A secret shown once: on one line, fading out under the copy icon at its
   end (owner, 2026-11-17); the field keeps the icon's room clear, so the
   last of it is never under the button. */
/* Its underline is the wrapper's, so the fade leaves the line whole. */
.box-secret {
  position: relative;
  border-bottom: 1px solid var(--border);
}

.box-secret > input {
  padding-right: calc(var(--console-control) + var(--space-2));
  border-bottom: 0;
  font-family: var(--mono);
  font-size: var(--text-sm);
  mask-image: linear-gradient(to right, black calc(100% - var(--console-control) - var(--space-12)), transparent calc(100% - var(--console-control) - var(--space-2)));
}

.box-secret > .box-copy {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

/* A copy icon's flag (beside a value, or at a secret's end) floats at the
   icon's left, over the end of the value on the card's ground, so nothing
   moves while it shows. */
.box-copyable > .box-copied,
.box-secret > .box-copied {
  position: absolute;
  top: 50%;
  right: calc(var(--console-control) + var(--space-1));
  padding: 0 var(--space-2);
  background: var(--surface);
  white-space: nowrap;
  transform: translateY(-50%);
}

/* Receive's "Click to copy." under the code, and "Copied" in its place for a moment. */
.box-receive__note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-2);
}

/* A step's heading takes focus when the step appears, for the keyboard and screen readers. */
h2[tabindex='-1']:focus {
  outline: none;
}

/* A form that is only a button (a seat switch, Pause, Export): no space of its own around it. */
.box-button-form {
  margin: 0;
}

/* A quiet line under a form: the other way in. */
.box-aside {
  margin: 0;
  color: var(--text-2);
  font-size: var(--text-sm);
}

/* A one-button form inside a line of words (an invitation's Sign out): the button reads as a link in the line. */
.box-inline-form {
  display: inline;
}

/* The corner link's name, in the accent (an invitation's "Claim The Fire Factory"; owner, 2026-11-19). */
.box-way-in__name {
  color: var(--accent);
}

/* A paged table's foot: Newest and Older, side by side. */
.box-pager {
  gap: var(--space-3);
}

/* A figure that could not be read: said, not shown as zero. */
.box-quiet {
  color: var(--text-2);
}

/* An address in a table cell: cut short with an ellipsis; the whole of it is
   in the cell for a screen reader and copying, and in its title on hover. */
.box-short {
  display: inline-block;
  max-width: 12rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  vertical-align: bottom;
  font-family: var(--mono);
}

/* On a phone a table's cells are a card's halves (console.css): the cut-short
   text fits its half. (On a desk a width relative to the cell would size the
   column for the whole text instead.) */
@media (max-width: 768px) {
  .box-short {
    max-width: 100%;
  }
}

/* A neutral note under a field: what its choices mean. */
.box-field-note-plain {
  color: var(--text-2);
}

/* Two buttons in one table cell, side by side. */
.box-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* A value with its one button beside it, on a line (a wallet's May pay and View). */
.box-with-action {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* A dialog's status line takes no room until it has something to say. */
.console-modal .form__status:empty {
  display: none;
}

/* A group of fields under one name (a wallet's rules): no frame of its own. */
.box-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.box-fieldset[hidden] {
  display: none;
}

/* A set's name over its choices, as a field's label stands over its control
   (owner, 2026-11-17: they sat on the first choice). A legend is not one of
   its fieldset's flex items, so the set's gap does not reach it. */
.box-fieldset > legend {
  margin-bottom: var(--space-3);
  padding: 0;
}

/* Test Payment's answer, under its fields: the words, then each check as the console's rows. */
.box-trial {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.box-trial[hidden] {
  display: none;
}

.box-trial__answer {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

/* Code a reader copies (the developer page's sample): the mono, as it is,
   scrolling within itself rather than widening the page. */
.box-code {
  margin: 0;
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  color: var(--text);
  font: var(--text-sm)/1.6 var(--mono);
  /* Code as it is typed: === stays three signs, never one joined glyph. */
  font-variant-ligatures: none;
  white-space: pre;
}

.box-code:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

/* A set of choices any of which may be ticked (a webhook's events): one to a line. */
.box-checks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.box-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font: var(--text-sm)/1.4 var(--mono);
  cursor: pointer;
}

/* A choice in words (an API key's permissions), not a name to type: the sans. */
.box-choice {
  font-family: var(--sans);
}

/* A field with a button at its right (Send's Max): the field takes the room. */
.box-field-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.box-field-row > input {
  flex: 1;
  min-width: 0;
}

/* A field's unit beside it (Settings and a wallet's rules: eUSD, %), in the mono, quieter. */
.box-field-unit {
  flex: none;
  font: 500 var(--text-sm)/1 var(--mono);
  color: var(--text-2);
}

/* Two ways to show one thing (Receive: QR or Address), one pressed. */
.box-toggle {
  display: inline-flex;
  align-self: flex-start;
  gap: var(--space-1);
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.box-toggle__option {
  min-height: 32px;
  padding: 0 var(--space-4);
  border: 0;
  border-radius: var(--radius-full);
  background: none;
  color: var(--text-2);
  font: 500 var(--text-sm)/1 var(--sans);
  cursor: pointer;
}

.box-toggle__option[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
}

/* Receive's address, as a QR code or as words: a button that copies it. */
.box-receive {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.box-receive:hover {
  border-color: var(--border-hover);
}

.box-receive[hidden] {
  display: none;
}

/* A camera reads dark modules on a light ground, as a printed code. */
.box-receive__qr {
  max-width: 280px;
  padding: var(--space-3);
  background: var(--white);
  color: var(--bg);
}

.box-receive__code {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

.box-receive.box-address {
  padding: var(--space-3);
  background: none;
  color: var(--text);
}

/* A pairing code (owner, 2026-11-17): its QR code, dark on a light ground
   as Receive's, and the code itself, large in the mono, to read aloud. */
.box-pair-code {
  max-width: 220px;
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--bg);
}

.box-pair-code__qr {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

.box-pair-code__code {
  margin: 0;
  font: 500 var(--text-2xl)/1.2 var(--mono);
  letter-spacing: 0.08em;
  color: var(--text);
}

/* A button that holds an icon in place of words (Dismiss): a button as any
   other, its icon the size of a line of its words. */
.box-btn-icon {
  padding-inline: var(--space-3);
}

.box-btn-icon > svg {
  width: 20px;
  height: 20px;
}

/* A page's further actions behind three dots (components.ts, moreMenu): the
   list under its button, at its right edge, drawn as the side's own menu
   (.console-more) with the kit's items. Where a browser cannot place it by
   its button, it stands at the top right of the window. */
.box-actions-menu__toggle {
  anchor-name: --box-actions-menu;
}

.box-actions-menu {
  position: fixed;
  inset: var(--space-16) var(--space-4) auto auto;
  min-width: 192px;
  margin: 0;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dropdown);
}

@supports (position-area: bottom) {
  .box-actions-menu {
    position-anchor: --box-actions-menu;
    position-area: bottom span-left;
    position-try-fallbacks: flip-block;
    inset: auto;
    margin-top: var(--space-2);
  }
}

/* The front door (pages.ts, frontDoorPage): the whole page in the cube's
   very dark room, the header and the footer with it. */
.box-front-door {
  --bg: var(--hero-cube-room);
}

/* A door's steps in a dialog (the front door's claim): the story's
   headline and line at the dialog's size, not the page's. */
.console-modal .story-headline-small {
  font-size: var(--text-xl);
}

.console-modal .story-lede {
  margin: var(--space-3) 0 var(--space-6);
  font-size: var(--text-base);
}

/* The way in (pages.ts, wayIn): Sign in, or Claim, small, at the header's
   right, in the page's white rather than a link's colour (owner,
   2026-11-18), and as small on a phone. */
.box-way-in {
  font-size: var(--text-sm);
  color: var(--text);
}

.box-way-in:hover,
.box-way-in:focus-visible {
  color: var(--white);
}

/* The front door's ways in (pages.ts: the claim, signing in, lost access),
   each a flyout from the header's right corner, where the way in is (owner,
   2026-11-18). It grows out of that corner as it opens, at the slow pace,
   and shrinks back into it as it closes, at the normal pace and evenly, so
   the shrink is seen rather than over in its last moment; the cube's
   room stays as it is behind it, and a click there closes it (console.js).
   Its corner sits just outside the link's, so its X lands about where the
   link was. Where the header's row is centred on a wide screen, so is the
   corner. Where motion is reduced it simply appears and goes. */
.box-front-door {
  --box-flyout-edge: max(var(--space-3), calc((100vw - var(--page-max)) / 2 + var(--space-3)));
}

.box-flyout {
  position: fixed;
  inset: var(--space-3) var(--box-flyout-edge) auto auto;
  max-height: calc(100vh - var(--space-6));
  max-height: calc(100dvh - var(--space-6));
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  opacity: 0;
  transform: scale(0.2);
  transform-origin: top right;
  transition: transform var(--duration-normal) var(--ease-in-out),
              opacity var(--duration-normal) var(--ease-in-out),
              overlay var(--duration-normal) var(--ease-in-out) allow-discrete,
              display var(--duration-normal) var(--ease-in-out) allow-discrete;
}

.box-flyout[open] {
  opacity: 1;
  transform: none;
  transition-duration: var(--duration-slow);
  transition-timing-function: var(--ease-out);
}

@starting-style {
  .box-flyout[open] {
    opacity: 0;
    transform: scale(0.2);
  }
}

.box-flyout::backdrop {
  background: transparent;
}

.box-flyout-narrow {
  width: min(280px, calc(100vw - var(--space-6)));
}

@media (prefers-reduced-motion: reduce) {
  .box-flyout {
    transition: none;
  }
}

/* Sign in (pages.ts, SIGN_IN_DIALOG): the fingerprint alone in the middle,
   in the quieter grey, what it says under it, and Lost access at the foot,
   all centred (owner, 2026-11-18). The fingerprint is the button, and
   shows its hover and its focus in the page's white. */
.box-sign-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) 0 var(--space-2);
  text-align: center;
}

.box-passkey {
  display: grid;
  place-items: center;
  width: var(--space-16);
  height: var(--space-16);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
}

.box-passkey:hover,
.box-passkey:focus-visible {
  outline: none;
  color: var(--white);
}

.box-passkey:disabled {
  opacity: 0.5;
  cursor: progress;
}

.box-passkey > svg {
  width: var(--space-12);
  height: var(--space-12);
}

.box-sign-in__lost {
  margin: var(--space-10) 0 0;
  font-size: var(--text-sm);
  color: var(--text-2);
}

.box-sign-in__lost > span {
  display: block;
}

/* Two cards side by side (a wallet's Details and Rules): each half the
   page's width, so neither stretches across it; one above the other on a
   phone, and a card alone keeps its half. */
.box-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  align-items: start;
}

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

/* Instructions (owner, 2026-11-17): Markdown as written, in the mono, to
   write in its panel and to read in a wallet's; its lines and spaces kept. */
.box-markdown,
.box-instructions {
  font: var(--text-sm)/1.65 var(--mono);
}

.box-instructions {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Whom a wallet may pay, in its dialog: one to a line, an address with Copy. */
.box-payees {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Settings' parts (pages.ts, settingsPage): each headed as a card's title
   is (story.css, Inter at 20px), below the page's own title, with room
   above it. */
.box-settings h2 {
  margin: var(--space-8) 0 0;
  font: 400 20px/1.2 var(--sans);
  letter-spacing: -0.01em;
}

.box-settings h2:first-child {
  margin-top: 0;
}
