/* attachments.css — Shared styles for file/photo attachment UI.
   Wird sowohl vom Hauptfenster (index.html) als auch von Mac-Stickys (sticky.html)
   eingebunden. Enthält: Action-Sheet, In-App-Viewer, Foto-Lightbox, Link-Pills.
   Keine Abhängigkeit auf styles.css — eigene Variablen-Fallbacks via var(--…, default). */

/* ── Action-Sheet (modernes Frosted-Glass Bottom-Sheet) ─────────────── */
.action-sheet[hidden] { display: none !important; }
.action-sheet {
  position: fixed; inset: 0; z-index: 210;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 10px;
  background: rgba(0,0,0,0.42);
  -webkit-backdrop-filter: blur(3px);
          backdrop-filter: blur(3px);
  animation: zk-sheet-fade .2s ease both;
}
.action-backdrop { position: absolute; inset: 0; }
.action-content {
  position: relative;
  width: 100%; max-width: 460px;
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: zk-sheet-rise .3s cubic-bezier(.22,1,.36,1) both;
}
@keyframes zk-sheet-fade { from { opacity: 0; } }
@keyframes zk-sheet-rise { from { transform: translateY(28px); opacity: 0; } }

/* Greifer oben — visueller Hinweis */
.action-grabber {
  width: 38px; height: 5px;
  border-radius: 3px;
  background: var(--grabber, rgba(255,255,255,0.4));
  margin: 2px auto 10px;
  flex-shrink: 0;
}

/* Karte aus Titel + Aktionen (alles außer „Abbrechen") */
.action-title,
.action-btn:not(.cancel) {
  background: var(--sheet-bg, rgba(44,44,46,0.97));
  -webkit-backdrop-filter: blur(22px) saturate(180%);
          backdrop-filter: blur(22px) saturate(180%);
}
.action-title {
  color: var(--sheet-title, rgba(255,255,255,0.55));
  font-size: 13px; font-weight: 500; text-align: center;
  letter-spacing: 0.2px;
  padding: 15px 18px 13px;
  border-radius: 16px 16px 0 0;
  word-break: break-all;
}
.action-btn {
  color: var(--tint, #0a84ff);
  font-size: 17px; font-weight: 400;
  padding: 16px 18px;
  border: none; border-radius: 0;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background .12s ease;
}
/* Haarlinien-Trenner zwischen den Karten-Buttons */
.action-btn:not(.cancel) { border-top: 0.5px solid var(--hairline, rgba(255,255,255,0.1)); }
.action-btn:not(.cancel):active { background: var(--sheet-active, rgba(72,72,74,0.92)); }
/* „Löschen" ist immer der letzte Button der Karte → unten abrunden */
.action-btn.destructive { color: #ff453a; border-radius: 0 0 16px 16px; }

.action-btn.cancel {
  margin-top: 9px;
  border-radius: 16px;
  font-weight: 600;
  color: var(--tint, #0a84ff);
  background: var(--sheet-cancel-bg, rgba(58,58,60,0.92));
  -webkit-backdrop-filter: blur(22px) saturate(180%);
          backdrop-filter: blur(22px) saturate(180%);
}
.action-btn.cancel:active { background: var(--sheet-active, rgba(72,72,74,0.95)); }

@media (min-width: 768px) {
  .action-sheet { align-items: center; padding: 24px; }
}
/* Mode-Filter: Sheet zeigt entweder Datei- oder Foto-Buttons. */
.action-sheet[data-mode="file"]  .action-btn[data-for="photo"] { display: none; }
.action-sheet[data-mode="photo"] .action-btn[data-for="file"]  { display: none; }

/* ── In-App File-Viewer (HTML/Text/Bild/PDF Vorschau) ────────────────── */
.file-viewer[hidden] { display: none !important; }
.file-viewer {
  position: fixed; inset: 0; z-index: 230;
  background: var(--bg, #1a1a1a);
  display: flex; flex-direction: column;
}
.file-viewer-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  border-bottom: 1px solid var(--border, #333);
  background: var(--bg, #1a1a1a);
  flex-shrink: 0;
}
.file-viewer-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.file-viewer .icon-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text, #fff);
  background: transparent;
  border: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.file-viewer .icon-btn:active { background: rgba(255,255,255,0.08); }
#file-viewer-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}
#file-viewer-frame[hidden] { display: none !important; }

/* ── In-App-PDF-Viewer (pdf.js-Canvas-Seiten) ───────────────────────── */
/* Zoom/Drehen-Controls in der Kopfleiste — nur im PDF-Modus sichtbar. */
.fv-pdf-controls {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.fv-pdf-controls[hidden] { display: none !important; }
.file-viewer-pages {
  flex: 1;
  overflow: auto; /* horizontal scrollbar wenn rein-gezoomt */
  -webkit-overflow-scrolling: touch;
  padding: 12px 10px calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg, #1a1a1a);
}
.file-viewer-pages[hidden] { display: none !important; }
.fv-page {
  /* Inhalts-breit + zentriert: bei Zoom > Fit wird die Seite breiter als der
     Container, margin:auto fällt auf 0 → links bündig + horizontal scrollbar. */
  width: max-content;
  max-width: none;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Hält die Rotations-Bounding-Box: bei 90°/270° setzt JS Breite/Höhe getauscht,
   die Seite (per transform rotiert) bleibt mittig. */
.fv-canvas-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fv-page-canvas {
  /* Breite/Höhe setzt JS (applyPdfTransforms) aus Zoom + Drehung. */
  display: block;
  max-width: none;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
/* Lazy-Platzhalter: weißes Blatt mit Seitennummer, bis scharf gerendert.
   Breite/Höhe setzt JS (applyPdfTransforms) wie beim Canvas → kein Springen. */
.fv-canvas-box.fv-box-ph {
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
.fv-page-ph-label {
  color: #b8b8b8;
  font-size: 13px;
  font-weight: 600;
}
.fv-page-annotate {
  align-self: flex-end;
  height: 30px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #fff);
  background: var(--bg-card, #2c2c2e);
  border: 1px solid var(--border, #3a3a3c);
  border-radius: 999px;
  cursor: pointer;
}
.fv-pages-note {
  margin: 4px 0;
  font-size: 12.5px;
  color: var(--text-dim, #98989d);
  text-align: center;
}

/* ── Foto-Lightbox ──────────────────────────────────────────────────── */
.photo-lightbox[hidden] { display: none !important; }
.photo-lightbox {
  position: fixed; inset: 0; z-index: 220;
  background: rgba(0,0,0,0.94);
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top, 0) 12px env(safe-area-inset-bottom, 0);
  touch-action: manipulation;
}
.photo-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  /* Eigene Pinch/Pan-Geste — Browser-Defaults (Scroll/Zoom) aus, sonst
     kapert iOS WKWebView die Zwei-Finger-Geste. */
  touch-action: none;
  will-change: transform;
  transition: transform 0.18s ease-out;
  transform-origin: center center;
}
.photo-lightbox img.zk-lb-dragging { transition: none; }
.photo-lightbox-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: 12px;
  width: 44px; height: 44px;
  border-radius: 22px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 0;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.photo-lightbox-close:active { background: rgba(255,255,255,0.25); }

/* ── Link-Pills (Auto-Linkify-URLs verkürzt darstellen) ─────────────── */
/* font-size:0 versteckt den nackten URL-Text optisch, ::after rendert den
   Hostname statt dessen. textContent (= volle URL) bleibt erhalten →
   Long-Press/Copy gibt den vollen Link, target=_blank/href bleibt klickbar.
   Im Edit-Mode ([contenteditable=true]) wird die Pill deaktiviert, damit
   der User die URL ganz normal editieren kann. */
a[data-host] {
  font-size: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 6px;
  margin: 0 1px;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border, rgba(0,0,0,0.18));
  color: var(--accent, #4ea1ff);
  text-decoration: none;
  vertical-align: baseline;
  line-height: 1.5;
  max-width: 100%;
}
a[data-host]::before {
  content: '';
  width: 12px; height: 12px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/><path d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/></svg>") center/contain no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/><path d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/></svg>") center/contain no-repeat;
}
a[data-host]::after {
  content: attr(data-host);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
/* Edit-Mode-Override nur für den Hauptapp-Editor (#note-editor). Mac-Stickys
   sind immer contenteditable=true, sollen die Pill aber trotzdem zeigen —
   sonst stehen dort dauerhaft die nackten Long-URLs. */
#note-editor[contenteditable="true"] a[data-host] {
  font-size: inherit;
  display: inline;
  padding: 0; margin: 0;
  border: 0; border-radius: 0;
  background: transparent;
  color: var(--accent, #4ea1ff);
  text-decoration: underline;
  max-width: none;
}
#note-editor[contenteditable="true"] a[data-host]::before,
#note-editor[contenteditable="true"] a[data-host]::after {
  display: none;
}

/* ── Anhang-Inhalts-Styles (Datei-Chip + Foto + Foto-Wrap) ──────────── */
/* Greifen in jedem Editor mit `data-zk-attachments-root` (Hauptapp #note-editor
   und Sticky #editor). Die ausführlicheren Resize-Handle-Regeln für die
   Hauptapp leben weiter in styles.css unter #note-editor — Sticky braucht
   den Resize-Handle nicht. */
[data-zk-attachments-root] a.note-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, .08);
  color: inherit;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  vertical-align: middle;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* iOS Safari: ohne diese beiden poppt bei Langdruck die native
     Text-Markierung + das Kopieren/Nachschlagen-Menü auf, statt unseres
     Action-Sheets. user-select allein reicht auf iOS nicht. */
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-zk-attachments-root] img.note-photo {
  display: inline-block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  vertical-align: top;
  margin: 4px 4px 4px 0;
  -webkit-user-drag: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
[data-zk-attachments-root] span.photo-wrap {
  display: inline-block;
  position: relative;
  vertical-align: top;
  margin: 4px 4px 4px 0;
  max-width: 100%;
  line-height: 0;
}
[data-zk-attachments-root] span.photo-wrap img.note-photo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}
/* Sticky braucht keinen Resize-Handle — pure Anzeige. */
#editor span.photo-wrap .photo-resize-handle { display: none; }
