/* The prototype's design language (D70). Each colour is the prototype's own, or the nearest shade of
   its hue at which every pair it is in passes WCAG 2.2 AA with a step to spare: 4.6:1 for text and
   3.1:1 for a control's edge, a state or the focus ring (D55). */

@font-face {
  font-family: "Space Grotesk";
  src: url("SpaceGrotesk-2.0.0.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("GeistMono-1.5.0.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --canvas: #eef2ec;
  --surface: #ffffff;
  --surface-2: #faf6ee;
  --surface-3: #f0e9db;
  --ink: #211d16;
  --ink-2: #4a443a;
  --muted: #756b5c;
  /* A rule that only decorates. */
  --hair: #e6ddcd;
  /* The boundary of a control, at least 3:1 against what it meets (WCAG 1.4.11). */
  --edge: #908779;
  --accent: #0b7d36;
  --accent-press: #047834;
  --accent-tint: #d7f0de;
  --accent-ink: #fff8f1;
  --pos: #247452;
  --pos-tint: #dfeae2;
  --warn: #915d00;
  --warn-tint: #f4e9d2;
  --alert: #a4121c;
  --alert-wash: #fdecee;
  --alert-ink: #fff8f1;
  /* The card face is the same in both themes: --face-1 and --face-2 are --face mixed 90% with
     white and 68% with black, and white text passes over every point of it. */
  --face: #014834;
  --face-1: #1a5a48;
  --face-2: #013123;
  --face-ink: #ffffff;
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Colours only: geometry never depends on the theme. */
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0a0a0a;
    --surface: #171717;
    --surface-2: #111111;
    --surface-3: #1f1f1f;
    --ink: #eddfc4;
    --ink-2: #c0b393;
    --muted: #8c8268;
    --hair: #262626;
    --edge: #666666;
    --accent: #46c47c;
    --accent-press: #46b673;
    --accent-tint: #213d2d;
    --accent-ink: #08130d;
    --pos: #4eb081;
    --pos-tint: #1d3a2b;
    --warn: #d6a24f;
    --warn-tint: #392f1a;
    --alert: #f86a63;
    --alert-wash: #412927;
    --alert-ink: #0a0a0a;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--hair);
  background: var(--surface);
}

.brand { font-weight: 600; font-size: 1.125rem; letter-spacing: -0.01em; }

.bar form { margin: 0; }

main {
  flex: 1;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  overflow-wrap: anywhere;
}

h1 { font-size: 1.75rem; font-weight: 500; line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 1rem; }

p { margin: 0 0 1rem; }

form.stack { display: flex; flex-direction: column; gap: 0.75rem; }

label { font-weight: 560; color: var(--ink-2); }

code { font-family: var(--mono); }

input {
  font: inherit;
  font-size: 1.1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--edge);
  border-radius: 0.75rem;
  width: 100%;
  min-height: 2.75rem;
  background: var(--surface);
  color: var(--ink);
}

input[aria-invalid="true"] { border: 2px solid var(--alert); }

/* States change colour only, never size or place: a press must land where it started. */
button {
  font: inherit;
  font-weight: 560;
  padding: 0.65rem 1.25rem;
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: 1.75rem;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

button:hover, button:active { background: var(--accent-press); }

button.pay { min-height: 3.25rem; padding-inline: 1.75rem; font-size: 1.05rem; }

button.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--edge);
  padding: 0.35rem 0.75rem;
}

button.quiet:hover, button.quiet:active { background: var(--surface-3); }

#reverse-form button[type="submit"] {
  background: var(--alert-wash);
  color: var(--alert);
  border-color: var(--alert);
}

#reverse-form button[type="submit"]:hover, #reverse-form button[type="submit"]:active {
  background: var(--alert);
  color: var(--alert-ink);
}

a { color: var(--accent); }

a:hover { color: var(--accent-press); }

/* A link outside a sentence is a tap target of its own, at least 24 px (WCAG 2.5.8). */
a.alone { display: inline-block; padding: 0.25rem 0; }

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

.alert {
  border-left: 4px solid var(--alert);
  background: var(--alert-wash);
  color: var(--alert);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
}

.alert p { margin: 0; }

.alert ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }

.note { color: var(--muted); }

/* An amount breaks only at the <wbr> after each group separator, never inside a figure (sc.amounts). */
data[data-amount] { overflow-wrap: normal; }

/* Figures in the mono face with equal-width digits; no letter-spacing, so the text either side of
   an amount's <wbr> abuts. */
data[data-amount], data[data-rate] { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }

h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; margin: 0.5rem 0; }

/* The merchant navigation: its own row under the bar, so the bar never crowds at 320 px. */
.subnav { border-bottom: 1px solid var(--hair); background: var(--surface); }

.subnav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  list-style: none;
  margin: 0 auto;
  padding: 0.375rem 0.125rem;
  max-width: 32rem;
}

.subnav a {
  display: inline-block;
  min-height: 2.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 1.75rem;
  color: var(--ink-2);
  font-weight: 560;
  text-decoration: none;
}

.subnav a:hover { background: var(--surface-3); color: var(--ink); }

/* The current tab is told apart by its edge and its weight as well as its colour. */
.subnav a[aria-current="page"] {
  background: var(--accent-tint);
  color: var(--accent-press);
  border-color: var(--accent);
  font-weight: 700;
}

/* A link that starts an action, drawn as a button. */
a.button-link {
  display: inline-block;
  min-height: 2.75rem;
  padding: 0.65rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 1.75rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 560;
  text-decoration: none;
}

a.button-link:hover, a.button-link:active { background: var(--accent-press); color: var(--accent-ink); }

.listings { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }

.listing h2 { margin-top: 0; }

.listing p { margin: 0; }

dl.terms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 6.5rem), 1fr));
  gap: 0.5rem 1rem;
  margin: 0 0 0.75rem;
}

dl.terms div { min-width: 0; }

dl.terms dt { color: var(--muted); font-size: 0.9rem; }

dl.terms dd { margin: 0; font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* The gift-card face, as one element's background (no pseudo-element). Its sizes are in px, so
   enlarged text does not move the gloss under it: white text passes at every point of the face. */
article.card, article.listing {
  color: var(--face-ink);
  border: 0;
  border-radius: 18px;
  padding: 16px 18px;
  min-height: 10.75rem;
  background:
    radial-gradient(circle at 45% 0, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 136px),
    linear-gradient(118deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0) 26%,
      rgba(255, 255, 255, 0) 62%, rgba(255, 255, 255, 0.1) 100%),
    linear-gradient(135deg, var(--face-1) 0%, var(--face-2) 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 12px 26px -10px rgba(1, 72, 52, 0.55);
}

article.card dt, article.listing dt, article.card a, article.listing a { color: var(--face-ink); }

article.card dd, article.listing dd { font-size: 1.25rem; }

article.card :focus-visible, article.listing :focus-visible { outline-color: var(--face-ink); }

.fields { display: flex; flex-direction: column; gap: 1.25rem; }

.field { display: flex; flex-direction: column; gap: 0.25rem; }

.hint { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* The error line and every sentence it can hold share one cell, so the line keeps the room of the
   longest: nothing below it moves when the preview shows or clears an error, and a press on
   Publish lands where it started. */
.error-slot { display: grid; }

.error-slot > p { grid-area: 1 / 1; margin: 0; color: var(--alert); font-weight: 600; }

.error-slot > .room { visibility: hidden; }

/* Drawn as 2 px without changing the border's width, which would move what follows. */
.field:has(.field-error:not(:empty)) input {
  border-color: var(--alert);
  box-shadow: inset 0 0 0 1px var(--alert);
}

.preview {
  border: 1px solid var(--hair);
  border-radius: 0.75rem;
  background: var(--surface-2);
  padding: 0.75rem 1rem;
}

/* Two columns at most, and one when two would not fit, as with large text on a phone. */
.preview dl.terms {
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(6.5rem, 40%)), 1fr));
}

form.stack h2 { margin-bottom: 0; }

/* The perks stub (OP-12): shown, and disabled, until perks ship. */
fieldset.perks {
  margin: 0;
  border: 1px dashed var(--edge);
  border-radius: 0.75rem;
  padding: 0.5rem 1rem 0.75rem;
  color: var(--muted);
}

fieldset.perks legend { font-weight: 600; padding: 0 0.25rem; }

fieldset.perks p { margin: 0; }

/* Text for screen readers only: a 1 px clipped box. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

footer {
  padding: 1rem;
  border-top: 1px solid var(--hair);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  overflow-wrap: anywhere;
}

/* The QA panel (contracts/m1.json screen.qa.panel). Its element rules hold only inside its sections,
   so they style no product screen. */
section.qa { margin: 0 0 1.5rem; }

section.qa + section.qa { border-top: 1px solid var(--hair); padding-top: 1.25rem; }

.qa h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 0.75rem; }

.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 0 0 0.75rem; }

.inline form { margin: 0; }

.check { display: flex; align-items: center; gap: 0.5rem; }

/* Drawn here rather than by the browser, whose box is under 3:1 in some engines and schemes
   (WCAG 1.4.11). The tick is two strokes, each a band along the diagonal of its own tile. */
.check input {
  appearance: none;
  width: 1.75rem;
  height: 1.75rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: none;
  border: 0.125rem solid var(--edge);
  border-radius: 0.375rem;
  background-color: var(--surface);
  background-repeat: no-repeat;
  background-size: 0.4375rem 0.4375rem, 0.6875rem 0.75rem;
  background-position: 0.25rem 0.6875rem, 0.5625rem 0.375rem;
  cursor: pointer;
}

.check input[aria-invalid="true"] { border-color: var(--alert); }

.check input:checked {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image:
    linear-gradient(to top right, transparent calc(50% - 0.125rem), var(--accent-ink) calc(50% - 0.0625rem),
      var(--accent-ink) calc(50% + 0.0625rem), transparent calc(50% + 0.125rem)),
    linear-gradient(to bottom right, transparent calc(50% - 0.125rem), var(--accent-ink) calc(50% - 0.0625rem),
      var(--accent-ink) calc(50% + 0.0625rem), transparent calc(50% + 0.125rem));
}

/* With forced colours the browser's own box returns, as the drawn one's colours are overridden. */
@media (forced-colors: active) {
  .check input { appearance: auto; }
}

ul.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }

ul.items > li {
  border: 1px solid var(--hair);
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: var(--surface);
}

.qa dl { margin: 0 0 0.75rem; }

.qa dl > div { display: flex; flex-wrap: wrap; column-gap: 0.5rem; }

.qa dt { font-weight: 600; min-width: 5.5rem; }

.qa dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

form.return { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }

form.return label { flex-basis: 100%; }

form.return input { width: 6rem; flex: none; }

.outcome {
  border-left: 4px solid var(--pos);
  background: var(--pos-tint);
  color: var(--pos);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin: 0 0 1rem;
}

.outcome p { margin: 0; }

main > .alert { margin: 0 0 1rem; }

/* The customer's cards, one section per shop, and the buy screen. */
section.shop { margin: 0 0 1.5rem; }

.cards { display: flex; flex-direction: column; gap: 1rem; }

.card h3 { font-size: 1.1rem; font-weight: 600; line-height: 1.3; margin: 0 0 0.5rem; }

/* The status a card's words already say, as the face's stamp. */
.card-status {
  width: fit-content;
  padding: 0.125rem 0.625rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 1.75rem;
  background: rgba(0, 0, 0, 0.4);
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.card dl.terms { margin-bottom: 0; }

section.authorization {
  border: 1px solid var(--hair);
  border-radius: 0.75rem;
  background: var(--surface-2);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

section.authorization h2 { margin-top: 0; }

section.authorization p { margin: 0; }

#buy > .alert { margin: 0 0 1rem; }

/* Counter redemption: the counter's buttons, its camera and the session below the form. */
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.camera:not([hidden]) { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }

.camera video { width: 100%; max-width: 20rem; border-radius: 1.125rem; background: var(--surface-3); }

/* An empty live region keeps its place in the accessibility tree, and no room on screen. */
#camera-status:empty { margin: 0; }

section.session { margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--hair); }

/* Paid shows as a pill drawn by colour and shadow alone, so the status changing moves nothing. */
.checkout-status { font-weight: 600; width: fit-content; border-radius: 1.75rem; }

.checkout-status[data-session-status="confirmed"], [data-session-status="confirmed"] > .checkout-status {
  background: var(--pos-tint);
  color: var(--pos);
  box-shadow: 0 0 0 0.375rem var(--pos-tint);
}

/* The customer's code: the QR, and the code as text, large, in its two groups. */
.pay-code { text-align: center; }

/* White in both themes, so the code keeps its dark modules on a light ground. */
.qr {
  background: #ffffff;
  padding: 1rem;
  border-radius: 1.375rem;
  max-width: 18rem;
  margin: 0 auto 1rem;
  line-height: 0;
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.32), 0 4px 12px -6px rgba(0, 0, 0, 0.14);
}

.qr svg { width: min(100%, 16rem); height: auto; }

.code {
  font-family: var(--mono);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
}

/* What each card pays: a column heading wraps only at its space; a card's name, in its row's heading,
   breaks anywhere, as `main` lets every text, so the table fits a 320 px screen whatever the name. */
table.lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  margin: 0 0 1rem;
}

table.lines th, table.lines td {
  padding: 0.35rem 0.2rem;
  text-align: right;
  vertical-align: top;
}

table.lines th:first-child { text-align: left; padding-left: 0; }

table.lines tbody th { -webkit-hyphens: auto; hyphens: auto; }

table.lines td:last-child, table.lines th:last-child { padding-right: 0; }

table.lines thead th { border-bottom: 1px solid var(--hair); color: var(--muted); font-weight: 500; overflow-wrap: normal; }

table.lines tbody tr + tr > * { border-top: 1px solid var(--hair); }

table.lines td:last-child { font-weight: 600; }

/* Two columns at most, so a three-column row never squeezes "Pay another way" onto two lines. */
dl.terms.totals {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, max(6.5rem, 40%)), 1fr));
  border-block: 1px solid var(--hair);
  padding-block: 0.75rem;
}

#checkout-main > form { margin: 0 0 1rem; }

.warning {
  border-left: 4px solid var(--warn);
  background: var(--warn-tint);
  color: var(--warn);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  margin: 0 0 0.75rem;
}

.warning p { margin: 0; }

/* The merchant's redemption (contracts/m1.json screen.merchant.redemption). */
section.reversal { margin: 1.5rem 0 0; padding-top: 1rem; border-top: 1px solid var(--hair); }

section.reversal h3 { font-size: 1.05rem; font-weight: 600; margin: 1rem 0 0.25rem; }

/* Broken only between its words, so the column is as wide as its longest; set small, so that word
   leaves a 320 px screen room for seven-character figures beside it. */
table.lines .returned { display: block; color: var(--alert); font-size: 0.75rem; font-weight: 400; overflow-wrap: normal; }

.field-error { margin: 0; color: var(--alert); font-weight: 600; }
