/* QR Code Generator: styles for this tool only. Shared styles live in /tools/shared/tools.css.
   Cards follow the Contrast Checker; the local pieces are .qr-note (scan warnings), .qr-frame and the .qr-err / .qr-hint lines. */

html,
body {
  overflow-x: clip;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-variant-numeric: tabular-nums;
}
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 var(--space-4);
}

/* ---------- layout: content and appearance on the left, the code on the right (it stays in view while you scroll) ---------- */

.qr-main {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-8) 0 var(--space-16);
  --qr-pad-x: var(--space-6);
  --qr-pad-y: var(--space-6);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 23rem;
  grid-template-areas:
    "content preview"
    "options preview";
  grid-template-rows: auto 1fr;
  gap: var(--space-4);
  align-items: start;
}
.qr-content { grid-area: content; }
.qr-options { grid-area: options; }
.qr-preview {
  grid-area: preview;
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
}
.qr-card {
  min-width: 0;
  padding: var(--qr-pad-y) var(--qr-pad-x);
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-2xl);
}

/* ---------- content types ---------- */

/* Seven choices do not fit a phone, so the control scrolls sideways (the highlight scrolls with it) */
.qr-types {
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: var(--space-4);
}
.qr-types::-webkit-scrollbar {
  display: none;
}
.qr-types button {
  flex: 1 0 auto;
  min-height: 2rem;
  padding: 6px var(--space-3);
  cursor: pointer;
}
.qr-types button:not([aria-pressed="true"]):hover,
#ecc button:not([aria-pressed="true"]):hover {
  color: var(--color-ink);
}
.qr-types button:focus-visible,
#ecc button:focus-visible {
  outline-offset: -2px;
}
#ecc button {
  min-height: 2rem;
  cursor: pointer;
}

/* ---------- fields ---------- */

.qr-f {
  min-width: 0;
}
.qr-f + .qr-f,
.qr-panel > .qr-f + .check-row,
.qr-2 + .qr-2,
.qr-2 + .qr-f,
.qr-f + .qr-2,
.qr-f + .qr-colors,
.qr-2 + .qr-colors {
  margin-top: var(--space-3);
}
.qr-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 var(--space-3);
}
.qr-2 > .qr-f + .qr-f {
  margin-top: 0;
}
.qr-panel .field-label,
.qr-options .field-label {
  padding-top: 0;
}
.qr-panel .textarea {
  min-height: 7rem;
}

/* The shared .field and .textarea have no error state yet, so it is added here */
.field.invalid,
.textarea.invalid {
  border-color: var(--color-danger);
}
.qr-err {
  margin-top: var(--space-1);
  padding: 0 var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-danger);
}
.qr-err:empty {
  margin: 0;
}
.qr-hint {
  margin-top: var(--space-2);
  padding: 0 var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.qr-hint:empty {
  margin: 0;
}
.qr-panel .check-row {
  width: max-content;
}

/* ---------- appearance ---------- */

.qr-options > .qr-f + .qr-2 {
  margin-top: var(--space-6);
}
.qr-sliders {
  gap: var(--space-3) var(--space-6);
}
.qr-sliders .slider {
  margin-top: 0; /* the label sits right above, so the gap matches every other label */
}
.qr-colors {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.5rem minmax(0, 1fr);
  align-items: start;
  gap: 0 var(--space-2);
  margin-top: var(--space-6);
}
.qr-colors .qr-f + .qr-f {
  margin-top: 0;
}
.qr-swap {
  width: 2.5rem;
  height: 2.5rem;
  margin-top: 1.5rem; /* level with the color fields, under their labels */
}
.qr-options > .check-row {
  margin-top: var(--space-3);
  width: max-content;
}

/* ---------- the code ---------- */

.qr-frame {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--color-field);
  display: grid;
  place-items: center;
}
.qr-frame.has-code {
  background: none;
  border-color: var(--color-border);
}
/* Transparent codes sit on a checkerboard so the see-through areas are obvious */
.qr-frame.is-transparent {
  background:
    conic-gradient(var(--color-field) 25%, var(--color-surface) 0 50%, var(--color-field) 0 75%, var(--color-surface) 0) 0 0 / 20px 20px;
}
.qr-code {
  width: 100%;
  height: 100%;
}
.qr-code svg {
  display: block;
  width: 100%;
  height: 100%;
}
.qr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6);
  text-align: center;
  font-size: var(--text-md);
  color: var(--color-muted);
}
.qr-empty .icon {
  opacity: 0.5;
}

.qr-stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: 0 var(--space-1);
}
.qr-stats dt {
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.qr-stats dd {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
}

/* Scan warnings: a quiet row with an icon, tinted by how serious it is */
.qr-notes {
  display: grid;
  gap: var(--space-2);
}
.qr-notes:not(:empty) {
  margin-top: var(--space-4);
}
.qr-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--color-ink);
  background: var(--color-field);
}
.qr-note .icon {
  margin-top: 0.1rem;
  color: var(--color-muted);
}
.qr-note-warn {
  background: color-mix(in srgb, var(--color-warning) 12%, transparent);
}
.qr-note-warn .icon {
  color: var(--color-warning);
}
.qr-note-danger {
  background: color-mix(in srgb, var(--color-danger) 12%, transparent);
}
.qr-note-danger .icon {
  color: var(--color-danger);
}

.qr-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.qr-copy {
  grid-column: 1 / -1;
}

/* ---------- narrower screens: content, the code, then appearance, one under the other ---------- */

@media (max-width: 900px) {
  .qr-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "content"
      "preview"
      "options";
    grid-template-rows: none;
  }
  .qr-preview {
    position: static;
    max-width: 30rem;
    width: 100%;
    margin-inline: auto;
  }
  .qr-content,
  .qr-options {
    max-width: 40rem;
    width: 100%;
    margin-inline: auto;
  }
}
@media (max-width: 560px) {
  .qr-main {
    --qr-pad-x: var(--space-4);
    --qr-pad-y: var(--space-4);
    padding-top: var(--space-4);
  }
  .qr-2,
  .qr-sliders {
    grid-template-columns: minmax(0, 1fr);
  }
  .qr-2 > .qr-f + .qr-f {
    margin-top: var(--space-3);
  }
  .qr-colors {
    grid-template-columns: minmax(0, 1fr);
  }
  .qr-swap {
    justify-self: end;
    margin: var(--space-2) 0;
  }
  .qr-colors .qr-f + .qr-f {
    margin-top: 0;
  }
}
