/* qr.serhard.com. Brand tokens only; the colours of the code itself are the visitor's choice. */
.skip-link { position: absolute; top: var(--space-3); left: var(--space-3); z-index: 2; padding: var(--space-3); background: var(--sheet); }
.skip-link:not(:focus) { clip-path: inset(50%); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-sans); margin: 0; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button.btn { border: 0; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Hero */
.qr-hero { padding-block: var(--space-10) var(--space-8); }
.qr-hero h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); line-height: 1.04; letter-spacing: -0.03em; font-weight: 800; margin: 0 0 18px; max-width: 18ch; }
.qr-hero .lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 58ch; margin: 0; }

/* Studio layout */
.studio { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; padding-bottom: var(--space-14); }
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); min-width: 0; }
.controls { padding: 0 0 var(--space-6); }
.preview { position: sticky; top: var(--space-4); padding: var(--space-6); display: grid; gap: var(--space-4); }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--rule); padding-inline: var(--space-4); gap: var(--space-1); overflow-x: auto; scrollbar-width: none; }
.tabs [role=tab] { background: none; border: 0; padding: 16px 12px 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; font-family: var(--font-mono); font-size: 0.85rem; }
.tabs [role=tab] > span { font-family: var(--font-sans); font-size: 1rem; margin-left: 4px; }
.tabs [role=tab][aria-selected=true] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs [role=tab]:hover { color: var(--ink); }
.pane { padding: var(--space-6) var(--space-6) 0; }
@media (prefers-reduced-motion: no-preference) {
  .pane:not([hidden]) { animation: pane-in 0.22s ease-out; }
  @keyframes pane-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

fieldset { border: 0; margin: 0 0 var(--space-6); padding: 0; min-width: 0; }
legend { font-weight: 700; font-size: 1rem; padding: 0; margin-bottom: var(--space-3); }
.sub { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: var(--space-2); }
.hint { font-size: 0.88rem; color: var(--muted); margin: var(--space-2) 0 0; }

/* Content types */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: var(--space-2); }
.type input { position: absolute; opacity: 0; pointer-events: none; }
.type span { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--rule); border-radius: var(--radius-md); font-size: 0.95rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: border-color 0.15s, background-color 0.15s, color 0.15s; }
.type span svg { flex: none; }
.type:hover span { border-color: var(--control-border); color: var(--ink); }
.type input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.type input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Fields */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); margin: var(--space-6) 0 var(--space-4); }
.field { display: grid; gap: 6px; font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); min-width: 0; }
.field.wide, .fields .field:only-child { grid-column: 1 / -1; }
.field input, .field textarea, .field select, .mini select {
  font: inherit; font-weight: 400; font-size: 1rem; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--control-border); border-radius: var(--radius-md); padding: 10px 12px; min-height: 44px; width: 100%; box-sizing: border-box;
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.field-check { align-self: end; min-height: 44px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.encoded { display: flex; gap: var(--space-2); align-items: baseline; margin: 0; font-size: 0.85rem; color: var(--muted); min-width: 0; }
.encoded .label { flex: none; }
.encoded code { font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink-soft); white-space: pre-wrap; word-break: break-all; max-height: 4.8em; overflow: auto; }

/* Presets */
.presets { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.preset { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px 6px 8px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 999px; font-weight: 600; font-size: 0.92rem; }
.preset:hover { border-color: var(--control-border); }
/* The chip previews a look for the visitor's code: three flat colour bands, not a gradient. */
.chip { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--rule); background: conic-gradient(var(--a) 0 120deg, var(--b) 0 240deg, var(--c) 0); }

/* Shape pickers: each button draws the shape with CSS */
.shapes { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.shapes button { width: 52px; height: 52px; display: grid; place-items: center; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius-md); transition: border-color 0.15s, background-color 0.15s; }
.shapes.small button { width: 46px; height: 46px; }
.shapes button:hover { border-color: var(--control-border); }
.shapes button[aria-checked=true] { border-color: var(--ink); background: var(--steel); box-shadow: inset 0 0 0 1px var(--ink); }
.shape { --u: 9px; display: block; width: calc(var(--u) * 3 + 4px); height: calc(var(--u) * 3 + 4px); position: relative; }
.shape::before { content: ""; position: absolute; }
/* dots grid: a 3x3 pattern with two gaps, drawn with box-shadows so the shape of each module shows */
.s-square::before, .s-rounded::before, .s-dots::before, .s-classy::before, .s-classy-rounded::before, .s-extra-rounded::before {
  width: var(--u); height: var(--u); inset: auto; top: 0; left: 0; background: var(--ink);
  box-shadow: calc(var(--u) + 2px) 0 var(--ink), 0 calc(var(--u) + 2px) var(--ink), calc(var(--u) * 2 + 4px) calc(var(--u) + 2px) var(--ink), calc(var(--u) + 2px) calc(var(--u) * 2 + 4px) var(--ink), calc(var(--u) * 2 + 4px) calc(var(--u) * 2 + 4px) var(--ink);
}
.s-rounded::before { border-radius: 3px; }
.s-dots::before { border-radius: 50%; }
.s-classy::before { border-radius: 0 5px 0 5px; }
.s-classy-rounded::before { border-radius: 2px 6px 2px 6px; }
.s-extra-rounded::before { border-radius: 4px; }
/* corner frames and centres */
.shapes.small .shape { width: 24px; height: 24px; }
#corner-square-shapes .shape::before, #corner-dot-shapes .shape::before { width: auto; height: auto; box-shadow: none; border-radius: 0; }
#corner-square-shapes .shape::before { inset: 0; background: none; border: 4px solid var(--ink); box-sizing: border-box; }
#corner-square-shapes .s-extra-rounded::before { border-radius: 8px; }
#corner-square-shapes .s-dot::before { border-radius: 50%; }
#corner-dot-shapes .shape::before { inset: 6px; background: var(--ink); }
#corner-dot-shapes .s-dot::before { border-radius: 50%; }

.color-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.corner-row { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-8); }
.swatch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; min-height: 44px; }
.swatch input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--control-border); border-radius: var(--radius-md); background: var(--sheet); cursor: pointer; }
.mini { display: inline-flex; align-items: center; gap: 10px; font-size: 0.95rem; min-height: 44px; }
.mini input[type=range] { width: 120px; accent-color: var(--brand); }
.mini select { width: auto; min-height: 40px; padding: 6px 10px; }
.link { background: none; border: 0; padding: 10px 0; text-decoration: underline; text-underline-offset: 0.18em; font-size: 0.95rem; color: var(--ink); min-height: 44px; }

/* Segmented control */
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--control-border); border-radius: var(--radius-md); overflow: hidden; }
.segmented button { background: var(--sheet); border: 0; border-right: 1px solid var(--rule); padding: 10px 14px; min-height: 44px; font-size: 0.92rem; font-weight: 600; color: var(--ink-soft); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-checked=true] { background: var(--brand); color: var(--on-brand); }
.segmented.compact button { padding: 8px 12px; font-family: var(--font-mono); font-size: 0.85rem; }
#caption-wrap { margin-top: var(--space-4); max-width: 320px; }

/* Logo drop zone */
.drop { position: relative; display: grid; place-items: center; text-align: center; min-height: 112px; padding: var(--space-4); border: 2px dashed var(--control-border); border-radius: var(--radius-lg); color: var(--ink-soft); font-size: 0.95rem; cursor: pointer; margin-bottom: var(--space-3); transition: background-color 0.15s, border-color 0.15s; }
.drop:hover, .drop.over { background: var(--row-rule); border-color: var(--ink); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Preview stage */
.stage { position: relative; display: grid; place-items: center; padding: var(--space-6); border-radius: var(--radius-lg); background: var(--paper); overflow: hidden; aspect-ratio: 1 / 1.08; }
.stage { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Ccircle cx='8' cy='8' r='1' fill='%2349685f' fill-opacity='.35'/%3E%3C/svg%3E"); }
.card { position: relative; background: var(--card-bg, #fff); border-radius: var(--radius-md); padding: 0; box-shadow: var(--shadow-panel); width: min(100%, 300px); display: grid; justify-items: center; }
.card[style*="--card-bg: transparent"] { box-shadow: none; }
.qr { width: 100%; line-height: 0; }
.qr svg, .qr canvas { width: 100% !important; height: auto !important; display: block; }
.cap { margin: 0; padding: 0 0 16px; font-weight: 700; font-size: 1.15rem; color: var(--card-ink); text-align: center; line-height: 1.2; }
.card[data-frame=badge] .cap { background: var(--card-ink); color: var(--card-bg, #fff); padding: 8px 20px; border-radius: 999px; margin: 0 0 16px; }
.card[data-frame=badge][style*="--card-bg: transparent"] .cap { color: #fff; }
.scanline { position: absolute; left: 6%; right: 6%; top: 0; height: 2px; background: var(--signal); opacity: 0; pointer-events: none; box-shadow: 0 0 12px 2px var(--signal); }

/* The signature moment: the code fills in from the top-left finder pattern while a scan line passes over it. */
@media (prefers-reduced-motion: no-preference) {
  .stage.assembling .qr { animation: assemble 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .stage.assembling .card { animation: settle 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .stage.assembling .scanline { animation: scan 0.9s ease-in-out 0.15s both; }
  @keyframes assemble { from { clip-path: circle(0% at 14% 14%); } to { clip-path: circle(150% at 14% 14%); } }
  @keyframes settle { from { transform: scale(0.96) rotate(-1.5deg); } to { transform: none; } }
  @keyframes scan { 0% { top: 8%; opacity: 0; } 15% { opacity: 0.9; } 85% { opacity: 0.9; } 100% { top: 92%; opacity: 0; } }
}

.qr-status { margin: 0; font-size: 0.92rem; min-height: 2.8em; padding: 10px 12px; border-radius: var(--radius-md); background: var(--row-rule); color: var(--ink-soft); }
.qr-status[data-tone=ok] { color: var(--match); }
.qr-status[data-tone=ok]::before { content: "Ready. "; font-weight: 700; }
.qr-status[data-tone=warn]::before { content: "Check. "; font-weight: 700; }
.qr-status[data-tone=flag] { background: var(--flag-bg); color: var(--flag); }
.qr-status[data-tone=flag]::before { content: "Problem. "; font-weight: 700; }
.export { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2); }
.export-more { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.btn-line { background: var(--sheet); border: 1px solid var(--control-border); border-radius: var(--radius-md); padding: 11px 12px; font-weight: 600; font-size: 0.95rem; min-height: 44px; }
.btn-line:hover { border-color: var(--ink); background: var(--row-rule); }
.recent-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.recent-row button { padding: 3px; border: 1px solid var(--rule); border-radius: var(--radius-md); background: var(--sheet); line-height: 0; }
.recent-row button:hover { border-color: var(--ink); }
.recent-row img { border-radius: 3px; }

/* How it works */
.how { border-top: 1px solid var(--rule); padding-block: var(--space-14); }
.how h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); letter-spacing: -0.02em; margin: 0 0 var(--space-6); }
.how-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); padding: 0; margin: 0 0 var(--space-6); list-style: none; counter-reset: s; }
.how-steps li { counter-increment: s; color: var(--ink-soft); }
.how-steps li::before { content: counter(s); display: block; font-family: var(--font-mono); font-weight: 600; color: var(--ink); border-bottom: 1px solid var(--rule); padding-bottom: 8px; margin-bottom: 12px; }
.how-steps strong { color: var(--ink); display: block; margin-bottom: 4px; }
.note { color: var(--muted); font-size: 0.92rem; max-width: var(--measure); margin: 0; }
.note code { font-family: var(--font-mono); }
.qr-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); padding-block: var(--space-6) var(--space-10); border-top: 1px solid var(--rule); font-size: 0.9rem; color: var(--muted); }
.qr-footer .addr { font-family: var(--font-mono); }

@media (max-width: 900px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; order: -1; }
  .stage { aspect-ratio: auto; min-height: 280px; }
}
@media (max-width: 560px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .pane { padding-inline: var(--space-4); }
  .preview { padding: var(--space-4); }
  .how-steps { grid-template-columns: minmax(0, 1fr); }
  .tabs [role=tab] span { font-size: 0.95rem; }
  .tabs .wide-only { display: none; }
  .tabs [role=tab] { padding-inline: 10px; }
  .site-head nav { gap: 14px; }
  .card { width: min(100%, 240px); }
}
@media print { .controls, .export, .export-more, .site-head nav { display: none; } .studio { display: block; } }

/* Focus rings inside clipping containers are drawn inside the button. */
.segmented button:focus-visible, .tabs [role=tab]:focus-visible { outline-offset: -3px; }
