/* ==========================================================================
   FastUTM QR Generator (/qr/ only)
   v1.6.4 (Tasks 55 to 57): balanced columns, compact preview, clean empty
   state, separate code and background colours. Base .qr-layout and
   .qr-type-btn styles live in main.css. The preview column uses its own
   .qr-preview-card class, so the Site Checker's .preview-card rules in
   main.css no longer reach this page.
   ========================================================================== */

/* Respect the hidden attribute even where main.css sets display */
.qr-tool [hidden],
.qr-modal[hidden],
.qr-modal [hidden] { display: none !important; }

/* ---------- Layout (Task 56) ---------- */
.qr-tool.qr-layout {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 1.4rem;
  max-width: 1100px;
  margin: 0 auto 2rem;          /* clear gap before the Need help note */
  align-items: start;
}

@media (max-width: 820px) {
  .qr-tool.qr-layout {
    grid-template-columns: 1fr;
    margin-bottom: 1.25rem;
  }
}

.qr-tool > .glass-card {
  min-width: 0;
  margin-bottom: 0;
}

/* Preview column: sticks beside a long form on wide screens */
.qr-preview-card {
  text-align: center;
}
@media (min-width: 821px) {
  .qr-preview-card {
    position: sticky;
    top: 82px;
  }
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.qr-actions .btn-primary { flex: 1 1 200px; }

/* ---------- Status line ---------- */
.qr-status {
  margin: 0.8rem 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-2);
  min-height: 1.3em;
}
.qr-status.is-ok { color: var(--green, #15803d); }
.qr-status.is-warn { color: #b45309; }
.qr-status.is-error { color: var(--red, #dc2626); }

/* ---------- About these codes ---------- */
.qr-about {
  margin-top: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-2);
  background: var(--bg2);
}
.qr-about summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--text);
}
.qr-about p { margin: 0.6rem 0 0; }

/* ---------- Preview header (Task 05) ---------- */
.qr-preview-head { margin-bottom: 0.8rem; }

.qr-type-heading {
  font-size: 1.25rem;
  font-weight: 900;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.qr-type-sub {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-2);
  word-break: break-word;
}

/* ---------- Preview box: a real button (Task 06) ---------- */
.qr-preview-wrap {
  position: relative;
  width: 100%;
  max-width: 300px;             /* display size only; downloads keep their own size */
  margin: 0 auto;
}

.qr-tool .qr-preview-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  aspect-ratio: 1 / 1;
  margin: 0;
  padding: 8px;                 /* keeps rounded corners off the code's quiet zone */
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--bg2, #f4f6fa);
  font: inherit;
  color: #4b5563;
  cursor: zoom-in;
  transition: box-shadow 0.2s, transform 0.2s;
}

.qr-tool .qr-preview-box:disabled {
  cursor: default;
}
/* Dashed outline only for the empty state, not an out-of-date code */
.qr-tool .qr-preview-box.is-empty {
  border-style: dashed;
  background: transparent;
}

.qr-tool .qr-preview-box:not(:disabled):hover {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  transform: translateY(-1px);
}

.qr-tool .qr-preview-box:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.qr-tool #qrCanvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  image-rendering: pixelated;
}

.qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-2);
}
.qr-empty svg { color: var(--text-3); }

.qr-enlarge-hint {
  margin: 0.5rem 0 0;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-3);
}

/* ---------- Stale state ---------- */
.qr-tool .qr-preview-box.is-stale {
  cursor: default;
}
.qr-tool .qr-preview-box.is-stale #qrCanvas {
  opacity: 0.18;
  filter: grayscale(1);
}

.qr-stale {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.2rem;
  text-align: center;
  pointer-events: none;
}
.qr-stale p {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 800;
  color: #1f2937;
}
.qr-stale-btn {
  pointer-events: auto;
  font: inherit;
  font-weight: 800;
  font-size: 0.86rem;
  padding: 0.6rem 1.2rem;
  min-height: 44px;
  border-radius: 100px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.qr-stale-btn:focus-visible { outline: 3px solid #1f2937; outline-offset: 2px; }

/* ---------- Colours (Task 57) ---------- */
.qr-colours {
  margin: 1.1rem 0 0;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  min-width: 0;
}
.qr-colours legend {
  padding: 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.qr-colour-field + .qr-colour-field { margin-top: 0.9rem; }
.qr-colour-field > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--text);
}
.qr-colour-inputs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 220px;
}
.qr-colour-inputs input[type="color"] {
  flex: 0 0 44px;
  width: 44px;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--input-border, var(--border));
  border-radius: 9px;
  background: var(--input-bg, #fff);
  cursor: pointer;
}
.qr-hash {
  font-family: 'DM Mono', monospace;
  font-weight: 600;
  color: var(--text-3);
}
.qr-colour-inputs input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 0.7rem;
  border: 1px solid var(--input-border, var(--border));
  border-radius: 9px;
  background: var(--input-bg, #fff);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.qr-colour-inputs input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light, rgba(37, 99, 235, 0.2));
}
.qr-colour-inputs input[aria-invalid="true"] { border-color: var(--red, #dc2626); }

.qr-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.qr-swatch {
  width: 32px;
  height: 32px;
  padding: 3px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.qr-swatch > span:first-child {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.25);   /* keeps white and pale swatches visible */
}
.qr-swatch:hover { border-color: var(--border-strong); }
.qr-swatch.active { border-color: var(--accent); }
.qr-swatch:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

.qr-contrast {
  margin: 0.8rem 0 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: left;
}
.qr-contrast:empty { display: none; }
.qr-colour-tip {
  margin: 0.35rem 0 0;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--text-3);
}
.qr-contrast.is-good { color: var(--green, #15803d); }
.qr-contrast.is-warn { color: #b45309; }
.qr-contrast.is-bad { color: var(--red, #dc2626); }

/* ---------- Download row ---------- */
.qr-download {
  display: block;
  margin-top: 1rem;
  text-align: left;
}
.qr-download label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 0.35rem;
  color: var(--text);
}
.qr-download-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.qr-download-row select {
  flex: 1 1 200px;
  width: auto;
  min-height: 44px;
}
.qr-download-row .btn-primary { flex: 0 0 auto; }
.qr-tool .btn-primary:disabled,
.qr-tool .btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  animation: none;
}

.qr-tool .output-link { margin-top: 1rem; }

/* ---------- Enlarged view (Task 06) ---------- */
html.qr-modal-open,
html.qr-modal-open body { overflow: hidden; }

.qr-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.78);
}

.qr-modal-panel {
  background: #ffffff;
  color: #0f172a;
  border-radius: 18px;
  padding: 1rem;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.qr-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}
.qr-modal-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 900;
  color: #0f172a;
}
.qr-modal-head p {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: #475569;
  word-break: break-word;
}

.qr-modal-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  font-size: 1.1rem;
  cursor: pointer;
}
.qr-modal-close:focus-visible,
.qr-modal .btn-secondary:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

#qrModalCanvas {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
}

.qr-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
  font-size: 0.76rem;
  color: #475569;
}
.qr-modal .btn-secondary {
  color: #2563eb;
  border: 1.5px solid #2563eb;
}
.qr-modal .btn-secondary::before { background: #2563eb; }
.qr-modal .btn-secondary:hover { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .qr-tool .qr-preview-box { transition: none; }
  .qr-tool .qr-preview-box:not(:disabled):hover { transform: none; }
}

/* Panel-level hint (e.g. the Wi-Fi password note sits outside a .field) */
.qr-panel > .hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-3);
}

/* v1.15.0: "Use a FastUTM short link" option and the note under the code */
.qr-short-opt { display: flex; gap: 0.6rem; align-items: flex-start; margin-top: 0.8rem; padding: 0.7rem 0.8rem; border-radius: 12px; background: var(--accent-light); border: 1px solid var(--accent-dim); font-size: 0.78rem; line-height: 1.45; color: var(--text-2); cursor: pointer; }
.qr-short-opt input { margin-top: 0.15rem; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.qr-short-opt strong { display: block; color: var(--text); font-size: 0.84rem; margin-bottom: 0.1rem; }
.qr-short-note { margin: 0.5rem 0 0; font-size: 0.74rem; line-height: 1.45; color: var(--text-2); word-break: break-word; }
