/* ═══════════════════════════════════════════════════════════════════════════
   bytefret — styles/dialogs.css
   ───────────────────────────────────────────────────────────────────────────
   Modal-Dialogs (alle 4 nutzen <dialog> oder Backdrop-Pattern):
     - Confirm-Dialog (in-app Promise-API für window.confirm())
     - A2 Transpose-Dialog (Capo + Tuning + Spell)
     - Feedback Modal (Send-Form mit Klipboard-Fallback)
     - A5 Share-Dialog (QR-Code + Mode-Toggle)

   Shared Animation-Infrastructure:
     - @keyframes cd-fade (.15s opacity-fade-in)
     - @keyframes cd-pop (.18s scale-pop)
     - body.cd-open (overflow:hidden während Dialog auf)

   ANMERKUNG zu generic Popover-Infrastructure:
     - .chip-popover lebt territorial in sheet.css (dominant-User .music-chip).
       Notation-Popover (footer.css) overrided via cascade.
     - .view-popover lebt in topbar.css (Settings-Gear-Anker).
     - Inline-Popover-Anker innerhalb Dialogs (z.B. Spell-Picker im Transpose-
       Dialog) nutzen die jeweilige Popover-Klasse via cascade.

   Dependencies: base.css, topbar.css (button defaults: .btn-primary, etc.).
   Cascade: overlays.css (global print + reduced-motion-sweep) load NACH dialogs.
   ═══════════════════════════════════════════════════════════════════════════ */


/* ─── Confirm-Dialog ──────────────────────────────────────────────────────
   In-app Replacement für native window.confirm(). Promise-API in app.js,
   role="alertdialog" für AT, ESC + Backdrop-Click cancellable, Initial-
   Focus auf Cancel (sicherer Pfad ist Default). */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: cd-fade .15s var(--ease) both;
}
.confirm-dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem 1.1rem;
  max-width: 32rem;
  width: 100%;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .04) inset,
    0 12px 40px rgba(0, 0, 0, .25),
    0 4px 12px rgba(0, 0, 0, .12);
  animation: cd-pop .18s var(--ease) both;
}
.confirm-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 .4rem;
  letter-spacing: .005em;
}
.confirm-body {
  font-size: .92rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 1rem;
}
.confirm-actions {
  display: flex;
  gap: .55rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}
/* Confirm-Action-Buttons brauchen sichtbaren Border auch in Default-State,
   damit sie als Buttons lesbar sind (Toolbar nutzt ghost, hier ist Kontext
   anders — Modal-Actions sollen klar als interaktiv signalisieren). */
.confirm-actions button {
  min-width: 6rem;
  justify-content: center;
  border: 1px solid var(--border);
}
.confirm-actions button.btn-primary,
.confirm-actions button.btn-danger {
  border-color: transparent;   /* primary: filled, danger: own outline */
}

@keyframes cd-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cd-pop {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .confirm-backdrop,
  .confirm-dialog { animation: none; }
}

/* Hinter dem Backdrop: keine Scroll-Bewegung des Body. Wird beim Open
   per JS gesetzt, hier nur die CSS-Klasse falls JS-Pfad scheitert. */
body.cd-open { overflow: hidden; }

/* ─── A2 Transpose-Dialog ────────────────────────────────────────────────
   Reuse .confirm-backdrop (gleiches DOM-Eltern-Element wie confirmDialog).
   Box-Geometrie analog .confirm-dialog (max-width 22rem, padding etc.).
   Animations cd-fade + cd-pop greifen automatisch. */
.transpose-dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem 1.1rem;
  max-width: 22rem;
  width: calc(100vw - 2rem);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .04) inset,
    0 12px 40px rgba(0, 0, 0, .25),
    0 4px 12px rgba(0, 0, 0, .12);
  animation: cd-pop .18s var(--ease) both;
}
.transpose-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 .85rem;
}
.transpose-body label {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.transpose-input-wrap {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-bottom: .85rem;
}
.transpose-step {
  flex: 0 0 auto;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 .4rem;
  font-size: .85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--bg-sunken);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.transpose-step:hover { border-color: var(--secondary-line); }
.transpose-step:active { background: var(--accent-soft); }
.transpose-step:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
#tr-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.4rem;
  padding: 0 .5rem;
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .12s var(--ease);
}
#tr-input:focus-visible { border-color: var(--accent); }
.transpose-preview {
  font-size: .82rem;
  color: var(--text-muted);
  margin: 0;
  min-height: 1.2em;   /* damit Layout nicht springt zwischen leerem und 1-Zeilen-Text */
}
.transpose-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1rem;
}
.transpose-actions button {
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.transpose-actions button.btn-primary {
  background: var(--accent);
  color: var(--accent-on);
  border-color: transparent;
}
.transpose-actions button:disabled {
  cursor: not-allowed;
  opacity: .35;
}
.transpose-actions button:hover:not(:disabled) { border-color: var(--accent); }
.transpose-actions button.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

/* M-3 Mobile narrow-viewport: 5 Step-Buttons + Input könnten auf 320px-Breite
   eng werden. Bei <360px wrap die Step-Buttons unter den Input. */
@media (max-width: 360px) {
  .transpose-input-wrap {
    flex-wrap: wrap;
    justify-content: center;
  }
  #tr-input {
    flex: 0 0 100%;
    order: -1;       /* Input nach oben */
    margin-bottom: .35rem;
  }
}

/* Touch-Target-Größen via @media (pointer: coarse) — analog zu
   M1-Cell-Sizing-Block. Step-Buttons + Input mind. 44px hoch. */
@media (pointer: coarse) {
  .transpose-step,
  #tr-input,
  .transpose-actions button {
    min-height: 2.75rem;
  }
  .transpose-step { min-width: 2.75rem; }
  #tr-input { font-size: 1rem; }   /* iOS-Auto-Zoom-Prevention */
}

@media (prefers-reduced-motion: reduce) {
  .transpose-dialog { animation: none; }
}

/* ─── Feedback Modal ─────────────────────────────────────────────────────── */
.feedback-dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem 1.1rem;
  max-width: 28rem;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .04) inset,
    0 12px 40px rgba(0, 0, 0, .25),
    0 4px 12px rgba(0, 0, 0, .12);
  animation: cd-pop .18s var(--ease) both;
}
.feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 .75rem;
}
.feedback-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .005em;
  margin: 0;
  min-width: 0;
}
.feedback-close {
  width: 28px;
  height: 28px;
  min-width: 0;
  flex-shrink: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
}
.feedback-close:hover {
  color: var(--text);
  background: var(--bg-sunken);
}
.feedback-cats {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin: 0 0 .85rem;
}
.feedback-cat {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  padding: .55rem .7rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: all .15s var(--ease);
}
.feedback-cat svg { flex-shrink: 0; opacity: .85; }
.feedback-cat:hover {
  color: var(--text);
  border-color: var(--border);
}
.feedback-cat[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.feedback-cat-text {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  min-width: 0;
  flex: 1;
}
.feedback-cat-label {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.25;
}
.feedback-cat-desc {
  font-size: .75rem;
  font-weight: 400;
  line-height: 1.3;
  opacity: .75;
}
.feedback-textarea {
  display: block;
  width: 100%;
  min-height: 6rem;
  max-height: 16rem;
  resize: vertical;
  padding: .55rem .65rem;
  font: inherit;
  font-size: .88rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-sizing: border-box;
  transition: border-color .15s var(--ease);
}
.feedback-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.feedback-textarea::placeholder { color: var(--text-subtle); }
.feedback-textarea.feedback-error { border-color: var(--danger); }
.feedback-sysinfo {
  margin: .5rem 0 0;
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.feedback-sysinfo-label {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  cursor: pointer;
  user-select: none;
}
.feedback-sysinfo-label input[type="checkbox"] {
  margin-top: .15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.feedback-sysinfo-label > span { min-width: 0; flex: 1; }
.feedback-sysinfo-data {
  margin: .3rem 0 0 1.35rem;
  padding: .35rem .5rem;
  background: var(--bg-sunken);
  border-radius: calc(var(--radius) - 2px);
  font-size: .72rem;
  word-break: break-word;
}
.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  justify-content: flex-end;
  margin: .75rem 0 0;
}
.feedback-actions button {
  min-width: 6rem;
  justify-content: center;
  border: 1px solid var(--border);
}
.feedback-actions button.btn-primary {
  border-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
  .feedback-dialog { animation: none; }
}

/* ─── A5 (Stage 10) — Share-Dialog mit QR-Code + Mode-Toggle ──────────────────
   Reuse .confirm-backdrop für Backdrop-Animation + Z-Index. Dialog selbst hat
   eigenes Layout für URL-Box + QR-Code side-by-side desktop / stacked mobile.
   Width-Pattern via `width` (NICHT min-width — Audit-Pass-3-Lehre). */
.share-dialog {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem 1.1rem;
  width: 32rem;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 8px 24px rgba(0,0,0,.22), 0 2px 6px rgba(0,0,0,.12);
  animation: cd-pop .18s var(--ease) both;
}
.share-title {
  margin: 0 0 .75rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* Mode-Toggle: segmented-buttons (editable | read-only) */
.share-mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: .85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-sunken);
}
.share-mode-btn {
  flex: 1;
  padding: .55rem .75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.share-mode-btn:hover:not(.is-active) {
  background: var(--bg-page);
  color: var(--text);
}
.share-mode-btn.is-active {
  background: var(--accent);
  color: var(--accent-on);
  font-weight: 600;
}

/* URL-Box: input fill + copy-button rechts */
.share-url-box {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}
.share-url-input {
  flex: 1;
  font: inherit;
  font-size: .85rem;
  font-family: monospace;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-sunken);
  color: var(--text);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-url-input:focus-visible {
  border-color: var(--accent);
}
.share-url-copy {
  padding: .5rem 1rem;
  background: var(--bg-page);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease);
  white-space: nowrap;
}
.share-url-copy:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--accent);
}
.share-url-copy:disabled {
  opacity: .7;
  cursor: default;
}

/* QR-Box: SVG zentriert + hint darunter */
.share-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1rem;
}
.share-qr-svg {
  width: 160px;
  height: 160px;
  background: white;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  /* SVG inside fills via viewBox-scaling. preserveAspectRatio default. */
}
.share-qr-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}
.share-qr-hint {
  margin: .5rem 0 0;
  font-size: .8rem;
  color: var(--text-muted);
  font-style: italic;
}
.share-qr-toolarge {
  margin: .5rem 0 1rem;
  padding: .65rem .85rem;
  background: var(--bg-sunken);
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  font-size: .85rem;
  border-radius: 4px;
}

/* Actions */
.share-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}
.share-close {
  padding: .55rem 1.2rem;
}

/* Mobile: schmalere viewports — Layout bleibt stacked, QR größer für Touch-Scan */
@media (max-width: 600px) {
  .share-dialog { width: calc(100vw - 1.5rem); padding: 1rem 1rem .85rem; }
  .share-qr-svg { width: 200px; height: 200px; }
  .share-url-box { flex-direction: column; }
  .share-url-copy { width: 100%; padding: .8rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .share-dialog, .feedback-dialog { animation: none; }
}

@media print {
  .confirm-backdrop { display: none !important; }
}
