/* qrc.fantata.com — hand-rolled, no framework, no webfonts, no requests.
   Warm paper in light mode, warm ink in dark. */

:root {
  --paper:   #faf6f0;
  --surface: #fffdfa;
  --edge:    #e6ddd1;      /* decorative dividers */
  --control: #8f8274;      /* control outlines — needs 3:1 for WCAG 1.4.11 */
  --ink:     #241f1a;
  --muted:   #635a52;
  --accent:  #a8461f;
  --accent-ink: #ffffff;
  --focus:   #a8461f;
  --radius:  14px;
  --shadow:  0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px -12px rgba(60, 40, 20, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #191512;
    --surface: #221d19;
    --edge:    #382f28;
    --control: #786b60;
    --ink:     #f4eee6;
    --muted:   #b0a498;
    --accent:  #e79063;
    --accent-ink: #241206;
    --focus:   #e79063;
    --shadow:  0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink);
  padding: .75rem 1rem; border-radius: 0 0 var(--radius) 0; z-index: 10;
}
.skip:focus { left: 0; }

:where(a, button, input, textarea):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- masthead ---------- */

.masthead {
  max-width: 34rem;
  margin: 0 auto;
  padding: 3.5rem 0 2rem;
  text-align: center;
}

.masthead h1 {
  margin: 0 0 .5rem;
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: clamp(2.25rem, 7vw, 3rem);
  font-weight: 600;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
}

/* Three finder-pattern squares — a QR code reduced to its bones. */
.mark {
  width: .8em; height: .8em;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 42% 42% no-repeat,
    linear-gradient(var(--accent), var(--accent)) 100% 0 / 42% 42% no-repeat,
    linear-gradient(var(--accent), var(--accent)) 0 100% / 42% 42% no-repeat;
  border-radius: 3px;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 1.0625rem;
  text-wrap: balance;
}

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

main {
  max-width: 34rem;
  margin: 0 auto;
  display: grid;
  gap: 1.75rem;
}

.field { margin: 0 0 1.5rem; padding: 0; border: 0; }
.field:last-child { margin-bottom: 0; }

label, legend {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: .5rem;
  padding: 0;
}

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

textarea, input[type="number"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--radius);
  padding: .75rem .875rem;
  resize: vertical;
}

textarea { min-height: 5.5rem; }

textarea::placeholder { color: var(--muted); opacity: .85; }

/* ---------- size chips ---------- */

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: .625rem;
}

.chip { margin: 0; font-weight: 400; }

.chip input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}

.chip span {
  display: block;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--radius);
  padding: .625rem .75rem;
  text-align: center;
  font-weight: 600;
  transition: border-color .12s ease, background .12s ease;
}

.chip b { font-weight: 600; }

.chip em {
  display: block;
  font-style: normal;
  font-weight: 400;
  font-size: .9375rem;
  color: var(--muted);
}

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

.chip input:checked + span {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

/* Selection is not signalled by colour alone — the checked chip gets a tick. */
.chip input:checked + span b::after {
  content: " ✓";
  color: var(--accent);
}

.chip input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.custom-wrap { margin-top: 1rem; }
.custom-row { display: flex; align-items: center; gap: .625rem; }
.custom-row input { max-width: 8rem; }
.px { color: var(--muted); font-size: .9375rem; }

/* ---------- preview ---------- */

.preview { display: grid; gap: 1rem; justify-items: center; }

.stage {
  width: 100%;
  aspect-ratio: 1;
  max-width: 20rem;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1rem;
  overflow: hidden;
}

.stage canvas {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  display: none;
  /* keep modules crisp when the browser scales a big canvas down */
  image-rendering: -webkit-optimize-contrast;
  border-radius: 6px;
}

.stage[data-state="ready"] canvas { display: block; }
.stage[data-state="ready"] .stage-empty,
.stage[data-state="error"] canvas { display: none; }

.stage-empty {
  margin: 0;
  color: var(--muted);
  text-align: center;
  max-width: 16rem;
}

/* A skeleton shimmer while the code is being drawn. */
.stage[data-state="working"] { position: relative; }
.stage[data-state="working"]::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg,
    transparent 30%,
    color-mix(in srgb, var(--accent) 10%, transparent) 50%,
    transparent 70%);
  background-size: 250% 100%;
  animation: sweep 1.1s ease-in-out infinite;
}

@keyframes sweep {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .stage[data-state="working"]::after { animation: none; }
  * { transition: none !important; }
}

.status {
  margin: 0;
  min-height: 1.5rem;
  font-size: .9375rem;
  color: var(--muted);
  text-align: center;
}

.status[data-tone="error"] { color: var(--accent); font-weight: 600; }

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
  justify-content: center;
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: .6875rem 1.125rem;
  border-radius: 999px;
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--ink);
  transition: transform .08s ease, border-color .12s ease;
}

.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- footer ---------- */

footer {
  max-width: 34rem;
  margin: 3.5rem auto 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--edge);
  color: var(--muted);
  font-size: .9375rem;
  text-align: center;
}

footer p { margin: 0 0 .5rem; }
footer a { color: var(--accent); }
