@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plex-mono-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plex-mono-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* Stockroom grey and navy ink; shelf-label yellow is reserved for the price tag and its button. */
:root {
  color-scheme: light dark;
  --ground: #E8ECF0;
  --surface: #F7F9FA;
  --ink: #16202D;
  --steel: #53637A;
  --rule: #C3CCD6;
  --tag: #FFDA1F;
  --tag-ink: #16202D;
  --markdown: #B8102B;
  --stock-good: #0F5C33;
  --stock-bad: #A10E27;
  --focus: #1F5FD6;
  --code-ground: #16202D;
  --code-rule: #2B3748;
  --code-ink: #DCE4EE;
  --code-dim: #8797AB;
  --code-key: #9CC2FF;
  --code-string: #FFE17A;
  --code-number: #86E3C3;
  --code-literal: #FFA3AE;
  --sans: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121A26;
    --surface: #1A2433;
    --ink: #E6ECF3;
    --steel: #9CABBE;
    --rule: #2F3D51;
    --markdown: #FF7A8C;
    --focus: #86B4FF;
    --code-ground: #1C2738;
    --code-rule: #2F3D51;
  }
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.page {
  max-width: 74rem;
  margin: 0 auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

/* Masthead */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 1.25rem;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 750;
  font-stretch: 88%;
  font-size: 1.1rem;
  text-decoration: none;
}

.wordmark-tag {
  width: 1.6rem;
  height: 1.6rem;
}

.wordmark-tag path {
  fill: var(--tag);
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linejoin: round;
}

.wordmark-tag circle {
  fill: var(--ink);
}

.masthead-link {
  font-weight: 600;
}

/* Intro and form */

.intro {
  padding-block: clamp(2rem, 7vw, 4.5rem) 2rem;
}

.intro h1 {
  max-width: 13ch;
  margin: 0 0 1.25rem;
  font-size: clamp(2.75rem, 8vw, 5.4rem);
  font-weight: 820;
  font-stretch: 68%;
  line-height: 0.92;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.lede {
  max-width: 38rem;
  margin: 0 0 2rem;
  color: var(--steel);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.45;
}

.extractor {
  max-width: 50rem;
}

.field {
  display: flex;
  gap: 0.35rem;
  padding: 0.35rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
}

.field:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.field input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.75rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 1.1rem/1.3 var(--sans);
}

.field input:focus {
  outline: none;
}

.field input::placeholder {
  color: var(--steel);
}

.field button {
  flex: none;
  padding: 0 1.5rem;
  border: 0;
  border-radius: 4px;
  background: var(--ink);
  color: var(--surface);
  font: 700 1.05rem/1 var(--sans);
  font-stretch: 90%;
  cursor: pointer;
}

.field button:disabled,
.field input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.extractor[aria-busy="true"] .field button {
  cursor: progress;
}

.form-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 0.85rem;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.examples-intro {
  margin-right: 0.15rem;
  color: var(--steel);
}

.example {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 500 0.92rem/1.3 var(--sans);
  cursor: pointer;
}

.example:hover {
  border-color: var(--ink);
}

.example:disabled {
  cursor: progress;
  opacity: 0.6;
}

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

.tries strong {
  color: var(--ink);
  font-weight: 700;
}

.turnstile:empty {
  display: none;
}

.turnstile {
  margin-top: 0.75rem;
}

.form-error {
  max-width: 44rem;
  margin: 0.85rem 0 0;
  color: var(--markdown);
  font-weight: 500;
}

.form-error a {
  font-weight: 700;
}

.lock {
  max-width: 50rem;
  margin-top: 1.25rem;
  padding: 1.25rem 1.5rem 1.35rem;
  border-left: 6px solid var(--tag);
  border-radius: 0 8px 8px 0;
  background: var(--surface);
}

.lock h2 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 780;
  font-stretch: 78%;
  line-height: 1.1;
}

.lock p {
  margin: 0 0 1rem;
  color: var(--steel);
}

.lock .lock-note {
  margin: 0.85rem 0 0;
  font-size: 0.92rem;
}

.button-tag {
  display: inline-block;
  padding: 0.75rem 1.3rem;
  border: 2px solid var(--tag-ink);
  border-radius: 4px;
  background: var(--tag);
  color: var(--tag-ink);
  font-weight: 750;
  font-stretch: 90%;
  font-size: 1.05rem;
  text-decoration: none;
}

.button-tag:hover {
  box-shadow: 3px 3px 0 var(--tag-ink);
}

/* Workbench: the printed shelf label next to the raw JSON */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
  align-items: start;
  gap: clamp(1.25rem, 3vw, 2.25rem);
  padding-block: 1rem 3.5rem;
}

@media (max-width: 52rem) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .label-slot {
    max-width: 24rem;
  }
}

/* The dark bar is the printer's slot; labels slide out from under it. */
.label-slot {
  position: relative;
  padding-top: 0.9rem;
  overflow: hidden;
}

.label-slot::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--ink);
}

.label-slot.is-loading::before {
  animation: slot-working 1.1s ease-in-out infinite alternate;
}

@keyframes slot-working {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.35;
  }
}

.shelf-label {
  position: relative;
  margin-inline: 0.5rem;
  padding: 1.6rem 1.25rem 1.1rem;
  border-radius: 0 0 8px 8px;
  background: var(--tag);
  color: var(--tag-ink);
  /* Punched hanging hole in the top-right corner. */
  -webkit-mask: radial-gradient(circle 0.42rem at calc(100% - 1rem) 1rem, transparent 97%, #000 100%);
  mask: radial-gradient(circle 0.42rem at calc(100% - 1rem) 1rem, transparent 97%, #000 100%);
}

.shelf-label[data-state="empty"],
.shelf-label[data-state="loading"] {
  display: grid;
  min-height: 19rem;
  place-items: center;
  border: 2px dashed var(--rule);
  border-top: 0;
  background: transparent;
  color: var(--steel);
  text-align: center;
  -webkit-mask: none;
  mask: none;
}

.label-placeholder {
  max-width: 16rem;
  margin: 0;
}

.shelf-label.is-printing {
  animation: print 0.75s cubic-bezier(0.2, 0.75, 0.25, 1);
}

@keyframes print {
  from {
    transform: translateY(-102%);
  }
  to {
    transform: none;
  }
}

.label-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-right: 1.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-stretch: 85%;
}

.label-store {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  margin-top: 0.45rem;
}

.label-title {
  display: -webkit-box;
  max-height: calc(3 * 1.18em);
  margin: 0;
  overflow: hidden;
  font-size: 1.2rem;
  font-weight: 680;
  font-stretch: 86%;
  line-height: 1.18;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.label-thumb {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 4px;
  background: #fff;
  object-fit: contain;
}

.label-price {
  display: flex;
  align-items: flex-start;
  margin: 1rem 0 0.2rem;
  font-weight: 860;
  font-stretch: 62%;
  line-height: 0.8;
  font-variant-numeric: lining-nums;
}

.price-symbol {
  margin: 0.4rem 0.1rem 0 0;
  font-size: 1.9rem;
}

.price-whole {
  font-size: 5.6rem;
  letter-spacing: -0.02em;
}

.label-price.is-long .price-whole {
  font-size: 3.9rem;
}

.price-fraction {
  margin: 0.4rem 0 0 0.1rem;
  font-size: 2.1rem;
  text-decoration: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.12em;
}

.price-missing {
  margin: 1rem 0 0.2rem;
  font-size: 1.6rem;
  font-weight: 780;
  font-stretch: 70%;
}

.label-was {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.6rem;
  font-size: 0.95rem;
}

.label-was s {
  text-decoration-color: var(--stock-bad);
  text-decoration-thickness: 2px;
}

.label-discount {
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  background: var(--stock-bad);
  color: #fff;
  font-weight: 750;
}

.label-stock {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.4rem 0 0;
  font-weight: 650;
}

.label-stock::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: currentColor;
}

.label-stock[data-stock="good"] {
  color: var(--stock-good);
}

.label-stock[data-stock="bad"] {
  color: var(--stock-bad);
}

.label-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.9rem 0 0;
  padding-top: 0.65rem;
  border-top: 1px solid rgb(22 32 45 / 0.35);
}

.label-facts div {
  min-width: 0;
}

.label-facts dt {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.8;
}

.label-facts dd {
  margin: 0;
  overflow: hidden;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-code {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: 0.9rem;
}

.barcode {
  display: block;
  width: 11rem;
  max-width: 100%;
  height: 2.9rem;
  fill: var(--tag-ink);
}

.label-code-text {
  margin-top: 0.15rem;
  font: 500 0.8rem/1.2 var(--mono);
  letter-spacing: 0.14em;
}

/* Code panel */

.code-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: clamp(24rem, 62vh, 36rem);
  margin-top: 0.9rem;
  border-radius: 8px;
  background: var(--code-ground);
  color: var(--code-ink);
}

.code-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  border-bottom: 1px solid var(--code-rule);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
}

.tabs button {
  padding: 0.55rem 0.75rem;
  border: 0;
  border-radius: 4px 4px 0 0;
  background: transparent;
  color: var(--code-dim);
  font: 600 0.95rem/1 var(--sans);
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  color: var(--code-ink);
  box-shadow: inset 0 -2px 0 var(--tag);
}

.tabs button:focus-visible,
.copy:focus-visible,
.code:focus-visible {
  outline-color: var(--tag);
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.code-meta {
  color: var(--code-dim);
  font-size: 0.85rem;
}

.copy {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--code-rule);
  border-radius: 4px;
  background: transparent;
  color: var(--code-ink);
  font: 600 0.88rem/1 var(--sans);
  cursor: pointer;
}

.copy:hover {
  border-color: var(--code-dim);
}

.code {
  flex: 1;
  margin: 0;
  padding: 1rem 1.25rem 1.25rem;
  overflow: auto;
  font: 400 0.84rem/1.6 var(--mono);
  tab-size: 2;
}

.code-hint {
  color: var(--code-dim);
}

.tok-key {
  color: var(--code-key);
}

.tok-string {
  color: var(--code-string);
}

.tok-number {
  color: var(--code-number);
}

.tok-literal {
  color: var(--code-literal);
}

.tok-punct {
  color: var(--code-dim);
}

/* Facts and footer */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.5rem clamp(1.5rem, 4vw, 3rem);
  padding-block: 2rem 3rem;
  border-top: 2px solid var(--ink);
}

.facts h2 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 750;
  font-stretch: 84%;
  line-height: 1.2;
}

.facts p {
  max-width: 36ch;
  margin: 0;
  color: var(--steel);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.5rem 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--steel);
  font-size: 0.95rem;
}

.footer p {
  margin: 0;
}

@media (max-width: 30rem) {
  .field {
    flex-direction: column;
  }

  .field button {
    padding-block: 0.85rem;
  }

  .price-whole {
    font-size: 4.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shelf-label.is-printing,
  .label-slot.is-loading::before {
    animation: none;
  }
}
