/* FreeQR widget. Every selector is prefixed .fqr so nothing leaks into the page.
   Matches blackwork.css: ink on paper, square corners, one blue accent.
   Gold stays reserved for the buy action, so it is not used here. */

.fqr {
    --fqr-ink: var(--bw-ink, #1d1d1f);
    --fqr-ink-soft: var(--bw-ink-soft, #6e6e73);
    --fqr-paper: var(--bw-paper, #ffffff);
    --fqr-paper-2: var(--bw-paper-2, #f5f5f7);
    --fqr-line: rgba(0, 0, 0, .14);
    --fqr-accent: var(--bw-blue, #0071e3);
    --fqr-accent-dark: #0058b0;
    --fqr-warn-ink: #8a4b00;
    --fqr-warn-bg: #fff6e5;
    --fqr-font: var(--bw-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif);
    color-scheme: light;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    font-family: var(--fqr-font);
    font-size: 16px;
    line-height: 1.45;
    letter-spacing: normal;
    color: var(--fqr-ink);
    background: var(--fqr-paper);
    border: 1px solid var(--fqr-line);
    box-shadow: var(--bw-shadow, 0 4px 16px rgba(0, 0, 0, .08));
    padding: 20px;
    text-align: left;
}

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

.fqr [hidden] { display: none !important; }

/* ---- type picker ---- */
.fqr .fqr-types {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 18px;
}

.fqr .fqr-type {
    flex: 0 0 auto;
    margin: 0;
    padding: 8px 12px;
    min-height: 40px;
    font: 500 15px/1.2 var(--fqr-font);
    letter-spacing: -0.01em;
    color: var(--fqr-ink);
    background: var(--fqr-paper-2);
    border: 1px solid transparent;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    text-transform: none;
}

.fqr .fqr-type:hover { border-color: var(--fqr-line); }

.fqr .fqr-type[aria-pressed="true"] {
    color: #ffffff;
    background: var(--fqr-ink);
    border-color: var(--fqr-ink);
}

/* ---- layout ---- */
.fqr .fqr-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
}

@media (min-width: 720px) {
    .fqr { padding: 28px; }
    .fqr .fqr-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 300px);
        gap: 28px;
        align-items: start;
    }
}

.fqr .fqr-form, .fqr .fqr-preview { min-width: 0; }

/* ---- fields ---- */
.fqr .fqr-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.fqr .fqr-field {
    flex: 1 1 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fqr .fqr-half { flex: 1 1 calc(50% - 6px); min-width: 120px; }

.fqr .fqr-label {
    display: block;
    margin: 0;
    font: 500 14px/1.3 var(--fqr-font);
    color: var(--fqr-ink-soft);
    text-transform: none;
    letter-spacing: normal;
}

.fqr .fqr-input {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 10px 12px;
    min-height: 44px;
    font: 400 16px/1.4 var(--fqr-font);
    color: var(--fqr-ink);
    background: var(--fqr-paper);
    border: 1px solid var(--fqr-line);
    border-radius: 0;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.fqr .fqr-textarea { resize: vertical; min-height: 84px; }

.fqr .fqr-select {
    padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.fqr .fqr-input::placeholder { color: #9a9aa0; opacity: 1; }

.fqr .fqr-input:focus,
.fqr .fqr-type:focus-visible,
.fqr .fqr-btn:focus-visible,
.fqr .fqr-swatch:focus-visible,
.fqr .fqr-checkbox:focus-visible {
    outline: 2px solid var(--fqr-accent);
    outline-offset: 1px;
}

.fqr .fqr-input:focus { border-color: var(--fqr-accent); }

.fqr .fqr-check {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.fqr .fqr-checkbox {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--fqr-accent);
    flex: 0 0 auto;
}

.fqr .fqr-label-inline { color: var(--fqr-ink); font-weight: 400; font-size: 15px; cursor: pointer; }

/* ---- colors ---- */
.fqr .fqr-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--fqr-line);
}

.fqr .fqr-color {
    flex: 1 1 calc(50% - 6px);
    min-width: 120px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fqr .fqr-color-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fqr .fqr-swatch {
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 2px;
    background: var(--fqr-paper);
    border: 1px solid var(--fqr-line);
    border-radius: 0;
    cursor: pointer;
    flex: 0 0 auto;
}

.fqr .fqr-hex {
    font-family: var(--bw-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 14px;
    color: var(--fqr-ink-soft);
}

.fqr .fqr-warn {
    margin: 12px 0 0;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--fqr-warn-ink);
    background: var(--fqr-warn-bg);
    border-left: 3px solid #d98a00;
}

/* ---- preview ---- */
.fqr .fqr-frame {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    background: var(--fqr-paper-2);
    border: 1px solid var(--fqr-line);
}

.fqr .fqr-canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    image-rendering: pixelated;
    visibility: hidden;
}

.fqr.fqr-has-code .fqr-canvas { visibility: visible; }

.fqr .fqr-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 24px;
    font-size: 15px;
    line-height: 1.4;
    text-align: center;
    color: var(--fqr-ink-soft);
}

.fqr.fqr-has-code .fqr-empty { display: none; }

/* ---- actions ---- */
.fqr .fqr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 300px;
    margin: 14px auto 0;
}

.fqr .fqr-btn {
    flex: 1 1 130px;
    margin: 0;
    padding: 12px 14px;
    min-height: 46px;
    font: 500 15px/1.2 var(--bw-display, var(--fqr-font));
    letter-spacing: -0.01em;
    text-transform: none;
    border-radius: 0;
    cursor: pointer;
    box-shadow: none;
    transition: transform .08s steps(2);
}

.fqr .fqr-btn-primary {
    color: #ffffff;
    background: var(--fqr-accent);
    border: 1px solid var(--fqr-accent);
}

.fqr .fqr-btn-primary:hover { background: var(--fqr-accent-dark); border-color: var(--fqr-accent-dark); }

.fqr .fqr-btn-secondary {
    color: var(--fqr-ink);
    background: var(--fqr-paper);
    border: 1px solid var(--fqr-ink);
}

.fqr .fqr-btn-secondary:hover { background: var(--fqr-paper-2); }

.fqr .fqr-btn:active { transform: scale(0.985); }

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

.fqr .fqr-upsell {
    max-width: 300px;
    margin: 12px auto 0;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    color: var(--fqr-ink-soft);
}

.fqr .fqr-upsell:empty { display: none; }

@media (max-width: 380px) {
    .fqr { padding: 16px; }
    .fqr .fqr-type { padding: 8px 10px; font-size: 14px; }
}

/* the sticky nav would cover the widget when jumping to #free-qr or #make-free */
#free-qr, #make-free { scroll-margin-top: 90px; }

/* iOS Safari gives date inputs an intrinsic min-width that ignores width:100%,
   so they overflow on phones. min-height keeps an empty one level with the text inputs. */
.fqr input.fqr-input[type="datetime-local"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 44px;
}

.fqr input.fqr-input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; }

.fqr .fqr-note {
    flex: 1 1 100%;
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--fqr-ink-soft);
}

.fqr .fqr-empty.fqr-empty-error { color: #b42318; }

/* date pairs sit side by side only when each gets room for a full date and time */
.fqr .fqr-half-wide { min-width: 210px; }
