/* ---------------------------------------------------------------------------
   QRCode Generator

   Zero dependencies: no webfonts, no CDN, no network of any kind. The page has
   to open by double-click from file://, so all personality comes from the type
   scale, layering and colour rather than a downloaded typeface.

   Colour discipline: the preview surface stays neutral so it never competes
   with the colours the user picked for their own code. Teal carries every
   interactive affordance; green, amber and red are reserved exclusively for
   scan-safety verdicts. If something in here is green, amber or red, it is
   telling you about your code — not decorating the page.
--------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  --bg:          #0e1216;
  --bg-far:      #0a0d10;
  --surface:     #151b21;
  --surface-2:   #1b232b;
  --surface-3:   #222c35;
  --sunken:      #0c1013;

  --line:        rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .13);

  --text:        #e8eef4;
  --text-mid:    #a8b5c0;
  --dim:         #74838f;

  --accent:      #2fb3c9;
  --accent-hi:   #4ecadf;
  --accent-lo:   rgba(47, 179, 201, .14);
  --accent-edge: rgba(47, 179, 201, .38);

  --ok:   #4fc088;
  --warn: #dfa42c;
  --risk: #e2615c;

  --paper: #fbfaf7;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r:    10px;
  --r-sm: 7px;
  --shadow-lift: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.7);
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg:          #f1f3f5;
  --bg-far:      #e6e9ec;
  --surface:     #ffffff;
  --surface-2:   #f5f7f9;
  --surface-3:   #eceff2;
  --sunken:      #eef1f4;

  --line:        rgba(11, 20, 28, .10);
  --line-strong: rgba(11, 20, 28, .18);

  --text:        #10171d;
  --text-mid:    #45535f;
  --dim:         #6b7883;

  --accent:      #0d8ea4;
  --accent-hi:   #0a7286;
  --accent-lo:   rgba(13, 142, 164, .11);
  --accent-edge: rgba(13, 142, 164, .34);

  --ok:   #17835a;
  --warn: #a9720b;
  --risk: #c0413c;

  --paper: #ffffff;
  --shadow-lift: 0 1px 2px rgba(11,20,28,.06), 0 10px 28px -16px rgba(11,20,28,.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100vh;
}

/* Atmosphere. A flat fill reads as a void; this gives the page a light source
   sitting behind the preview column, where the eye should land first. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(70ch 60ch at 78% 8%, var(--accent-lo), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-far) 100%);
}

/* Shared utility face: small, tracked out, uppercase. */
.panel-title, .docs-title, .tabs button, .segmented button,
.capacity-title, .capacity-label, .spec em, .brand-text small, output {
  font-family: var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* --- Top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 13px 26px;
  border-bottom: 1px solid var(--line);
  /* Opaque fallback first: if color-mix is unsupported the declaration below
     is dropped, and a sticky bar with no background is unreadable. */
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 11px; }

/* Three squares in the finder-pattern arrangement. */
.brand-mark {
  width: 22px; height: 22px;
  display: grid;
  grid-template: repeat(2, 1fr) / repeat(2, 1fr);
  gap: 4px;
  flex: none;
}
.brand-mark i {
  background: var(--accent);
  border-radius: 2px;
}
.brand-mark i:nth-child(1) { grid-area: 1 / 1; }
.brand-mark i:nth-child(2) { grid-area: 1 / 2; }
.brand-mark i:nth-child(3) { grid-area: 2 / 1; }

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.brand-text small { font-size: 8.5px; color: var(--dim); }

.thesis {
  margin: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-mid);
  font-size: 12.5px;
}
.pip {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-mid);
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  flex: none;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--surface-3);
}

/* --- Layout --------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 404px;
  gap: 26px;
  padding: 26px;
  max-width: 1340px;
  margin: 0 auto;
  align-items: start;
}

/* Grid children default to min-width:auto, which refuses to shrink below their
   content and pushes long payloads out of the layout. */
.controls, .preview, .docs-col { min-width: 0; }

.preview { position: sticky; top: 86px; }

@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; gap: 18px; padding: 18px; }
  .preview { position: static; order: -1; }
}

/* --- Panels --------------------------------------------------------------- */

.panel {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lift);
}
.panel:last-child { margin-bottom: 0; }

/* The download panel is the end of the task — give it a little more presence. */
.panel--action { border-color: var(--accent-edge); }

.panel-title, .docs-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--dim);
  margin: 0 0 16px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.row:last-child { margin-bottom: 0; }
.row--sub { margin-top: 12px; }

.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 220px; }

label, .field > label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: .01em;
}
.row > label { white-space: nowrap; }

.hint {
  margin: 12px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--dim);
}
.hint:empty { display: none; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-mid);
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

/* --- Form controls -------------------------------------------------------- */

input[type="text"], input[type="email"], input[type="tel"],
input[type="number"], input[type="datetime-local"], input[type="file"],
select, textarea {
  background: var(--sunken);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
  width: 100%;
  transition: border-color .15s, background .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }

input[type="number"] { width: 100%; }
input[type="file"] { font-size: 11.5px; padding: 8px 10px; cursor: pointer; }
textarea { min-height: 92px; resize: vertical; line-height: 1.55; }

input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: transparent;
}

select {
  appearance: none;
  padding-right: 30px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) calc(50% + 1px), calc(100% - 10px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Colour swatch: a big tappable well with its hex beside it. */
.swatch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px 7px 8px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color .15s;
}
.swatch:hover { border-color: var(--line-strong); }
.swatch input[type="color"] {
  width: 30px; height: 30px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: none;
  cursor: pointer;
  flex: none;
}
.swatch input[type="color"]:disabled { opacity: .35; cursor: not-allowed; }
.swatch-meta { display: flex; flex-direction: column; line-height: 1.3; }
.swatch-meta label { font-size: 10.5px; }
.swatch-meta output { font-size: 10.5px; color: var(--text-mid); letter-spacing: .04em; }

input[type="color"] {
  width: 34px; height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: none;
  cursor: pointer;
}
input[type="color"]:disabled { opacity: .35; cursor: not-allowed; }

input[type="range"] {
  flex: 1 1 150px;
  width: auto;
  accent-color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
}

output {
  font-size: 11px;
  color: var(--text-mid);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
}

/* --- Payload type tabs ---------------------------------------------------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}
.tabs button {
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text-mid);
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 600;
  transition: color .15s, background .15s, border-color .15s;
}
.tabs button:hover { color: var(--text); border-color: var(--line-strong); }
.tabs button.on {
  background: var(--accent-lo);
  border-color: var(--accent-edge);
  color: var(--accent-hi);
}

.fields { display: grid; gap: 14px; }
.fields .row { margin-bottom: 0; flex-direction: column; align-items: stretch; gap: 6px; }
.fields .check { flex-direction: row; align-items: center; }

.field-error {
  color: var(--risk);
  font-size: 11.5px;
}
.field-error:empty { display: none; }

/* --- Segmented control ---------------------------------------------------- */

.segmented {
  display: inline-flex;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 3px;
}
.segmented button {
  background: transparent;
  border: 0;
  color: var(--dim);
  padding: 6px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 600;
  transition: color .15s, background .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.on {
  background: var(--accent);
  color: #04191d;
}
:root[data-theme="light"] .segmented button.on { color: #ffffff; }

/* --- The proof sheet ------------------------------------------------------ */

.proof {
  margin: 0 0 16px;
  padding: 26px;
  position: relative;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

/* A light source behind the sample, so the code reads as the focal object. */
.proof::before {
  content: "";
  position: absolute;
  left: 50%; top: -34%;
  width: 132%; aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--accent-lo), transparent 58%);
  pointer-events: none;
}

/* Registration marks: they mark the trim of the sample, which is what a quiet
   zone is. Structural, not decorative. */
.proof-marks { position: absolute; inset: 13px; pointer-events: none; }
.proof-marks .reg { position: absolute; width: 11px; height: 11px; }
.proof-marks .tl { top:0; left:0;  border-top:1px solid var(--line-strong); border-left:1px solid var(--line-strong); }
.proof-marks .tr { top:0; right:0; border-top:1px solid var(--line-strong); border-right:1px solid var(--line-strong); }
.proof-marks .bl { bottom:0; left:0;  border-bottom:1px solid var(--line-strong); border-left:1px solid var(--line-strong); }
.proof-marks .br { bottom:0; right:0; border-bottom:1px solid var(--line-strong); border-right:1px solid var(--line-strong); }

.plate {
  position: relative;
  background: var(--paper);
  border-radius: var(--r-sm);
  padding: 16px;
  display: grid;
  place-items: center;
  min-height: 190px;
  box-shadow: 0 2px 6px rgba(0,0,0,.18), 0 18px 40px -22px rgba(0,0,0,.7);
}

/* Transparent exports preview over a checkerboard, so "no background" is
   visibly different from "white background" — they export very differently. */
.plate.is-transparent {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #d5d1c9 25%, transparent 25%, transparent 75%, #d5d1c9 75%),
    linear-gradient(45deg, #d5d1c9 25%, transparent 25%, transparent 75%, #d5d1c9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

#canvas {
  max-width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
}

/* Encoding facts as stat cells, the way a press proof carries its specs. */
/* Three across rather than six: at a 404px column, a sixth-width cell cannot
   hold the word "alphanumeric" without breaking mid-word. */
.specs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 20px 0 0;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.spec {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 8px;
  background: var(--surface);
  text-align: center;
  min-width: 0;
}
.spec b {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}
.spec em {
  font-size: 8px;
  font-style: normal;
  color: var(--dim);
}
/* The longest value here is "alphanumeric"; it needs a smaller size to sit on
   one line at this column width. */
#m-mode { font-size: 11px; }
@media (max-width: 380px) {
  .specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- Capacity ------------------------------------------------------------- */

.capacity {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.capacity-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 9px;
}
.capacity-title { font-size: 9px; color: var(--dim); font-weight: 600; }
.capacity-label {
  font-size: 9.5px;
  color: var(--text-mid);
  font-variant-numeric: tabular-nums;
  letter-spacing: .05em;
}

/* Drawn as discrete cells: the thing being measured is codewords, which are
   discrete, not a continuous quantity. */
.capacity-bar {
  height: 9px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.capacity-bar span {
  display: block;
  height: 100%;
  width: 0;
  background-image: repeating-linear-gradient(
    90deg, var(--accent) 0 3px, transparent 3px 5px);
  transition: width .22s ease;
}
.capacity-bar span.is-full {
  background-image: repeating-linear-gradient(
    90deg, var(--warn) 0 3px, transparent 3px 5px);
}

/* --- Scan-safety notices -------------------------------------------------- */

.warnings { display: grid; gap: 8px; }
.warnings:not(:empty) { margin-bottom: 16px; }

.warning {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--dim);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  overflow-wrap: break-word;
  animation: rise .26s ease both;
}
.warning-icon {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.85;
}
.warning-fix { color: var(--dim); display: block; margin-top: 4px; }

.warning.is-ok   { border-left-color: var(--ok); }
.warning.is-ok   .warning-icon { color: var(--ok); }
.warning.is-warn { border-left-color: var(--warn); }
.warning.is-warn .warning-icon { color: var(--warn); }
.warning.is-risk { border-left-color: var(--risk); }
.warning.is-risk .warning-icon { color: var(--risk); }

/* --- Buttons -------------------------------------------------------------- */

.btn-row { gap: 8px; }

.primary-btn, .ghost-btn {
  border-radius: var(--r-sm);
  padding: 9px 16px;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  transition: transform .12s, background .15s, border-color .15s, color .15s;
}
.primary-btn {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #04191d;
  font-weight: 650;
}
:root[data-theme="light"] .primary-btn { color: #ffffff; }
.primary-btn:hover { background: var(--accent-hi); border-color: var(--accent-hi); }

.ghost-btn {
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text-mid);
}
.ghost-btn:hover { color: var(--text); border-color: var(--line-strong); }

.primary-btn:active, .ghost-btn:active { transform: translateY(1px); }
.ghost-btn:disabled, .primary-btn:disabled {
  opacity: .4; cursor: not-allowed; transform: none;
}

/* --- Docs ----------------------------------------------------------------- */

.docs {
  max-width: 1340px;
  margin: 0 auto;
  padding: 12px 26px 76px;
}
.docs-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}
@media (max-width: 900px) {
  .docs-grid { grid-template-columns: 1fr; gap: 30px; }
  .docs { padding: 12px 18px 60px; }
}
.docs-title { margin-bottom: 18px; }

#live-explainer { font-size: 14.5px; line-height: 1.75; color: var(--text-mid); }
#live-explainer p { margin: 0 0 14px; }
#live-explainer p:last-child { margin-bottom: 0; }
#live-explainer b { color: var(--text); font-weight: 650; }
#live-explainer code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--accent-hi);
  overflow-wrap: anywhere;
}

#faq { margin: 0; display: grid; gap: 2px; }
#faq dt {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}
#faq dt:first-child { border-top: 0; padding-top: 0; }
#faq dd {
  margin: 5px 0 14px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.65;
}

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 1340px;
  margin: 0 auto;
  padding: 30px 26px 44px;
  border-top: 1px solid var(--line);
  text-align: center;
}

/* Smaller and quieter than the header mark — a sign-off, not a second brand. */
.site-footer .brand-mark {
  width: 16px; height: 16px;
  gap: 3px;
  opacity: .5;
}

.site-footer p {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
}

/* --- Motion --------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}
.panel, .proof, .capacity { animation: rise .42s ease both; }
.proof { animation-delay: .05s; }
.capacity { animation-delay: .1s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
