/* ==========================================================================
   /qrcode/ — QR-Code-Studio

   Eigene Datei statt Anbau an style.css: die Seite bringt ein Werkzeug-Layout
   mit, das keine andere Seite benutzt, und würde den globalen Stylesheet für
   alle Besucher um rund ein Viertel aufblähen. Tokens, Buttons, Formularfelder
   und Typografie kommen unverändert aus style.css.
   ========================================================================== */

.qr-page-vars,
:root {
  --qr-warn: #f0b429;
  --qr-warn-soft: rgba(240, 180, 41, 0.12);
  --qr-panel: rgba(19, 24, 34, 0.72);
}

/* Das hidden-Attribut steuert auf dieser Seite sämtliche bedingten Bereiche
   (Panels, Passwortfeld, Logo-Einstellungen, nicht unterstützte Exportknöpfe).
   Die Voreinstellung des Browsers dafür ist display:none - aber schon eine
   einzige Klassenregel mit display:flex sticht sie aus. Ohne diese Zeile
   bleiben ausgeblendete Bereiche sichtbar. */
[hidden] {
  display: none !important;
}

/* ---- Optionsgruppen (Modulform, Eckmarkierungen, Fehlerkorrektur) ---- */
.qr-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---- Kopfbereich ---- */
.qr-intro {
  padding-bottom: var(--sp-5);
}

.qr-privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  max-width: 68ch;
  margin: 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  background: rgba(63, 215, 224, 0.05);
  font-size: var(--fs-small);
  color: var(--text-body);
  line-height: 1.55;
}

.qr-privacy-note__icon {
  flex: none;
  margin-top: 0.15em;
  color: var(--accent-cyan);
}

.qr-privacy-note a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ---- Grundraster ---- */
.qr-studio-section {
  padding-top: var(--sp-6);
}

.qr-studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6);
  align-items: start;
}

@media (min-width: 1060px) {
  .qr-studio {
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: var(--sp-6);
  }
}

@media (min-width: 1440px) {
  .qr-studio {
    grid-template-columns: minmax(0, 1fr) 440px;
  }
}

.qr-controls {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  min-width: 0;
}

/* ---- Karten ---- */
.qr-card {
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--qr-panel);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  box-shadow: var(--shadow-card);
}

@media (min-width: 720px) {
  .qr-card {
    padding: var(--sp-6);
  }
}

.qr-card__title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 var(--sp-5);
  font-size: var(--fs-h3);
  line-height: 1.2;
  color: var(--text);
}

.qr-card__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 600;
}

.qr-card__optional {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.qr-card__intro {
  margin: -0.5rem 0 var(--sp-5);
  font-size: var(--fs-small);
  color: var(--text-muted);
  max-width: 62ch;
}

.qr-subsection + .qr-subsection {
  margin-top: var(--sp-5);
}

.qr-subsection {
  margin-top: var(--sp-5);
}

.qr-label {
  display: block;
  margin-bottom: 0.6rem;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-body);
}

/* minmax(0, 1fr) statt 1fr: eine "auto"-Untergrenze lässt die Spalte auf die
   Mindestbreite ihres Inhalts wachsen – ein Farbwähler mit Texteingabe schiebt
   die Karte dann auf schmalen Geräten über den Bildschirmrand hinaus. */
.qr-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4) var(--sp-5);
}

.qr-grid-2 > * {
  min-width: 0;
}

@media (min-width: 620px) {
  .qr-grid-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* Bewusst --text-muted statt --text-faint: diese Zeilen tragen Information
   (Formathinweise, Warnungen zur Druckgröße) und müssen 4.5:1 erreichen.
   --text-faint liegt gegen die Kartenfläche nur bei rund 2.9:1. */
.qr-field-note {
  margin: 0.15rem 0 0;
  font-size: var(--fs-micro);
  color: var(--text-muted);
  line-height: 1.5;
}

.qr-panel-note {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: var(--sp-4) 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--qr-warn-soft);
  border: 1px solid rgba(240, 180, 41, 0.28);
  font-size: var(--fs-micro);
  line-height: 1.55;
  color: var(--text-body);
}

.qr-panel-note svg {
  flex: none;
  margin-top: 0.1em;
  color: var(--qr-warn);
}

/* ---- Typ-Auswahl ---- */
.qr-types {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--sp-5);
}

.qr-type {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.qr-type__icon {
  width: 17px;
  height: 17px;
  flex: none;
  opacity: 0.75;
}

.qr-type:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-raised-2);
}

.qr-type[aria-selected="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-glow-sm);
}

.qr-type[aria-selected="true"] .qr-type__icon {
  opacity: 1;
  color: var(--accent-strong);
}

/* ---- Panels ---- */
.qr-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  min-width: 0;
}

.qr-panel .field {
  min-width: 0;
}

/* ---- Vorhandenen Code laden ---- */
.qr-import {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}

.qr-import .qr-field-note {
  max-width: 62ch;
}

/* ---- Checkboxen ---- */
.qr-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: var(--fs-small);
  color: var(--text-body);
  cursor: pointer;
  line-height: 1.5;
}

.qr-checkbox input[type="checkbox"] {
  flex: none;
  width: 1.05rem;
  height: 1.05rem;
  margin-top: 0.18em;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---- Passwort ein-/ausblenden ---- */
.qr-inline-toggle {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-micro);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.qr-inline-toggle:hover {
  color: var(--accent-strong);
}

/* ---- Vorlagen ---- */
.qr-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.qr-preset {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-small);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.qr-preset:hover {
  color: var(--text);
  background: var(--bg-raised-2);
}

.qr-preset.is-active {
  color: var(--text);
  border-color: var(--accent-2);
  background: rgba(154, 99, 240, 0.12);
}

/* ---- Farbwähler ---- */
.qr-color {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.qr-color--indent {
  margin-top: 0.7rem;
  margin-left: 1.7rem;
}

.qr-color input[type="color"] {
  width: 2.9rem;
  height: 2.9rem;
  flex: none;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  cursor: pointer;
}

.qr-color input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 3px;
}

.qr-color input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

.qr-color input[type="color"]::-moz-color-swatch {
  border: 0;
  border-radius: 5px;
}

.qr-color input[type="text"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.qr-color input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- Regler ---- */
.qr-value {
  float: right;
  font-size: var(--fs-micro);
  color: var(--text-muted);
  font-weight: 400;
}

input[type="range"] {
  width: 100%;
  height: 1.5rem;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Der globale Fokusring aus style.css würde beim Regler direkt auf der Spur
   sitzen; hier braucht er etwas mehr Luft und die Pillenform. */
input[type="range"]:focus-visible {
  outline-offset: 4px;
  border-radius: var(--radius-pill);
}

/* ---- Logo ---- */
.qr-logo-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.qr-logo-preview {
  position: relative;
  width: 92px;
  height: 92px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  overflow: hidden;
}

.qr-logo-preview.has-image {
  border-style: solid;
  /* Karomuster macht sichtbar, wo das Logo transparent ist. */
  background-color: #f4f5f8;
  background-image: linear-gradient(45deg, #d9dce4 25%, transparent 25%),
    linear-gradient(-45deg, #d9dce4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9dce4 75%),
    linear-gradient(-45deg, transparent 75%, #d9dce4 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

.qr-logo-preview__placeholder {
  width: 26px;
  height: 26px;
  color: var(--text-faint);
}

.qr-logo-preview.has-image .qr-logo-preview__placeholder {
  display: none;
}

.qr-logo-preview img {
  max-width: 78%;
  max-height: 78%;
  object-fit: contain;
}

.qr-logo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  min-width: 0;
  flex: 1 1 220px;
}

.qr-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.qr-file-label {
  cursor: pointer;
}

/* Das Dateifeld selbst ist ausgeblendet - der Fokusring muss auf dem
   sichtbaren Label landen (Reihenfolge im HTML entsprechend). */
.qr-file-input:focus-visible + .qr-file-label {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

.qr-logo-settings {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Vorschau
   ========================================================================== */

.qr-preview {
  min-width: 0;
}

@media (min-width: 1060px) {
  .qr-preview__inner {
    position: sticky;
    /* Kopfzeile (rund 70 px) plus Luft. */
    top: 96px;
  }
}

.qr-preview__inner {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--qr-panel);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  box-shadow: var(--shadow-pop);
}

.qr-stage {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  /* Ohne Deckelung wächst die quadratische Fläche auf Tablets auf gut 770 px,
     während der Code selbst bei 480 px bleibt - der Rest wäre leerer Rand. */
  max-width: 520px;
  width: 100%;
  margin-inline: auto;
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background-color: #eef0f5;
  overflow: hidden;
}

/* Das Karomuster erscheint nur bei tatsächlich transparentem Hintergrund.
   Dauerhaft eingeblendet ließe es auch einen deckend weißen Code so aussehen,
   als wäre er freigestellt. */
.qr-stage.is-alpha {
  background-image: linear-gradient(45deg, #d5d9e2 25%, transparent 25%),
    linear-gradient(-45deg, #d5d9e2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d5d9e2 75%),
    linear-gradient(-45deg, transparent 75%, #d5d9e2 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.qr-stage__canvas {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.qr-stage__canvas canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 4px;
}

.qr-stage__empty {
  position: absolute;
  inset: var(--sp-5);
  display: grid;
  place-items: center;
  margin: 0;
  padding: var(--sp-4);
  border-radius: var(--radius-sm);
  background: rgba(10, 13, 19, 0.9);
  color: var(--text-body);
  font-size: var(--fs-small);
  text-align: center;
  line-height: 1.55;
}

/* ---- Scan-Status ---- */
.qr-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-inset);
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-body);
}

.qr-status__dot {
  width: 0.55rem;
  height: 0.55rem;
  flex: none;
  border-radius: 50%;
  background: var(--text-faint);
}

/* Zusätzlich zur Farbe trägt jeder Zustand ein eigenes Zeichen und einen
   eigenen Text – Farbe allein darf die Aussage nicht transportieren. */
.qr-status::after {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.05em;
  color: inherit;
  opacity: 0.75;
}

.qr-status.is-pending .qr-status__dot {
  background: var(--accent);
}
.qr-status.is-pending::after {
  content: "prüft";
}

.qr-status.is-ok {
  border-color: rgba(62, 207, 142, 0.35);
  background: rgba(62, 207, 142, 0.08);
  color: var(--success);
}
.qr-status.is-ok .qr-status__dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(62, 207, 142, 0.18);
}
.qr-status.is-ok::after {
  content: "OK";
}

.qr-status.is-warn {
  border-color: rgba(240, 180, 41, 0.35);
  background: var(--qr-warn-soft);
  color: var(--qr-warn);
}
.qr-status.is-warn .qr-status__dot {
  background: var(--qr-warn);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.18);
}
.qr-status.is-warn::after {
  content: "ACHTUNG";
}

.qr-status.is-error {
  border-color: rgba(242, 104, 95, 0.38);
  background: rgba(242, 104, 95, 0.08);
  color: var(--danger);
}
.qr-status.is-error .qr-status__dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(242, 104, 95, 0.18);
}
.qr-status.is-error::after {
  content: "FEHLER";
}

.qr-status.is-idle {
  color: var(--text-muted);
}
.qr-status.is-idle::after {
  content: "";
}

/* ---- Kenndaten ---- */
.qr-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.85rem var(--sp-4);
  margin: 0;
  padding: var(--sp-4) 0;
  border-block: 1px solid var(--border);
}

.qr-meta > div {
  min-width: 0;
}

.qr-meta dt {
  font-size: var(--fs-micro);
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.qr-meta dd {
  margin: 0;
  font-size: var(--fs-small);
  color: var(--text);
  overflow-wrap: anywhere;
}

.qr-meta__target {
  font-size: var(--fs-micro);
  line-height: 1.5;
  color: var(--text-body);
  /* Lange Ziele nach vier Zeilen abschneiden statt die Karte zu sprengen. */
  display: -webkit-box;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Hinweise ---- */
.qr-notes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.qr-notes:empty {
  display: none;
}

.qr-note {
  position: relative;
  padding: 0.6rem 0.8rem 0.6rem 2rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-micro);
  line-height: 1.55;
}

.qr-note::before {
  position: absolute;
  left: 0.75rem;
  top: 0.55rem;
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.4;
}

.qr-note--info {
  background: var(--accent-soft);
  color: var(--text-body);
}
.qr-note--info::before {
  content: "i";
  color: var(--accent-strong);
}

.qr-note--warn {
  background: var(--qr-warn-soft);
  color: #f2d190;
}
.qr-note--warn::before {
  content: "!";
  color: var(--qr-warn);
}

.qr-note--error {
  background: rgba(242, 104, 95, 0.1);
  color: #f7b4af;
}
.qr-note--error::before {
  content: "×";
  color: var(--danger);
}

/* ---- Export ---- */
.qr-export {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.qr-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.qr-actions .btn {
  flex: 1 1 auto;
  justify-content: center;
  min-width: 7.5rem;
}

.qr-actions .btn svg {
  width: 16px;
  height: 16px;
}

.qr-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.qr-toast {
  margin: 0;
  min-height: 1.2em;
  font-size: var(--fs-micro);
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.qr-toast.is-visible {
  opacity: 1;
}

/* ==========================================================================
   Erläuterungen
   ========================================================================== */

.qr-explain {
  padding-top: var(--sp-7);
}

.qr-explain__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6) var(--sp-7);
}

@media (min-width: 760px) {
  .qr-explain__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.qr-explain h2 {
  margin: 0 0 0.6rem;
  font-size: var(--fs-h3);
  color: var(--text);
}

.qr-explain p {
  margin: 0;
  max-width: 58ch;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.qr-explain a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* ==========================================================================
   Bewegungsarme Darstellung
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .qr-type,
  .qr-preset,
  .qr-toast,
  .qr-color input[type="text"] {
    transition: none;
  }
}
