/* ==========================================================================
   PORTFOLIO – Kachelübersicht, Grossansicht, CMS-Editor
   ========================================================================== */

.pf-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Raster (Mobile First) ---------- */
.pf-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 600px) {
  .pf-grid { grid-template-columns: repeat(3, 1fr); }
}

.pf-item { position: relative; min-width: 0; }

/* ---------- Kachel ---------- */
.pf-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 5 / 4; /* Querformat */
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.pf-tile-media {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16%; /* Motiv ca. 65–70 % der Kachel */
  pointer-events: none;
}
.pf-tile-media img,
.pf-tile-media .pf-svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.pf-svg svg { display: block; width: 100%; height: 100%; }

.pf-tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}
.pf-tile-title {
  font-family: var(--font-heading);
  font-size: clamp(15px, 1.4vw, 19px);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-align: center;
  color: #111;
}

@media (hover: hover) and (pointer: fine) {
  .pf-tile:hover .pf-tile-overlay { opacity: 1; }
}
.pf-tile:focus-visible .pf-tile-overlay { opacity: 1; }
.pf-tile:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Touch: Titel dezent unter der Kachel */
.pf-caption {
  display: none;
  margin: 8px 0 6px;
  font-size: 13px;
  line-height: 1.4;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}
@media (hover: none), (pointer: coarse) {
  .pf-caption { display: block; }
  .pf-tile:focus-visible .pf-tile-overlay { opacity: 0; }
}

/* ---------- CMS-Modus auf den Kacheln ---------- */
.pf-admin {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pf-drag-handle { cursor: grab; }
.pf-draft-badge {
  padding: 4px 8px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: #111;
  color: #fff;
}
.pf-item.is-draft .pf-tile { opacity: 0.45; }
.pf-item.is-dragging { opacity: 0.4; }
.pf-item.is-over .pf-tile { outline: 2px dashed #fff; outline-offset: -6px; }
.pf-add { grid-column: 1 / -1; }

/* ---------- Grossansicht ---------- */
.pf-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  opacity: 0;
  transition: opacity 250ms ease;
}
.pf-lightbox[hidden] { display: none; }
.pf-lightbox.is-open { opacity: 1; }

.pf-lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.94);
}

.pf-lb-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.pf-lb-slide {
  position: absolute;
  inset: 72px 112px 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 250ms ease;
}
.pf-lb-slide.is-active { opacity: 1; }

.pf-lb-figure {
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pf-lb-figure img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
.pf-lb-figure .pf-svg { width: 100%; height: 100%; }

.pf-lb-nav,
.pf-lb-close {
  position: absolute;
  z-index: 2;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, opacity 200ms ease;
}
.pf-lb-nav:hover:not(:disabled),
.pf-lb-close:hover { background: #fff; color: #111; }
.pf-lb-nav:focus-visible,
.pf-lb-close:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.pf-lb-nav:disabled { opacity: 0.2; cursor: default; }
.pf-lb-prev { left: 32px; top: 50%; transform: translateY(-50%); }
.pf-lb-next { right: 32px; top: 50%; transform: translateY(-50%); }
.pf-lb-close { top: 16px; right: 16px; }

.pf-lb-counter {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.7);
}

/* Infoseite im Stil der Kachel */
.pf-info {
  width: min(760px, 100%);
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  padding: clamp(36px, 7vw, 96px);
  background: var(--pf-color, #e6ded2);
  color: #1a1a1a;
}
.pf-info-title {
  margin: 0 0 40px;
  font-family: var(--font-heading);
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 300;
  letter-spacing: 0.03em;
  line-height: 1.2;
  color: #1a1a1a;
  text-transform: none;
}
.pf-info-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 24px;
  margin: 0 0 40px;
}
.pf-info-meta dt {
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(26, 26, 26, 0.55);
}
.pf-info-meta dd {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}
.pf-info-desc {
  margin: 0;
  max-width: 56ch;
  font-size: 15px;
  line-height: 1.75;
  font-weight: 300;
}

/* Mobile: Vollbild, Navigation per Swipe */
@media (max-width: 767px) {
  .pf-lb-slide { inset: 64px 0 52px; }
  .pf-lb-nav { display: none; }
  .pf-lightbox.is-info .pf-lb-slide { inset: 64px 0 52px; align-items: stretch; }
  .pf-info { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .pf-lightbox, .pf-lb-slide, .pf-tile-overlay { transition: none; }
}

/* ---------- CMS-Editor ---------- */
.pf-editor {
  max-width: 720px;
  width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  text-align: left;
}
.pf-ed-label {
  display: block;
  margin: 18px 0 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.pf-ed-label small { text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.pf-ed-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
}
.pf-ed-input:focus { outline: none; border-color: #fff; }
textarea.pf-ed-input { resize: vertical; line-height: 1.5; }
select.pf-ed-input option { color: #111; }

.pf-ed-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 560px) { .pf-ed-row { grid-template-columns: 1fr; } }
.pf-ed-inline { display: flex; gap: 8px; align-items: stretch; }
.pf-ed-btn { margin-top: 8px; padding: 6px 12px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.pf-ed-inline .pf-ed-btn { margin-top: 0; white-space: nowrap; }

.pf-ed-cover {
  width: 100%;
  aspect-ratio: 5 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14%;
  box-sizing: border-box;
}
.pf-ed-cover img, .pf-ed-cover .pf-svg { width: 100%; height: 100%; object-fit: contain; }

.pf-ed-color { width: 64px; height: 40px; padding: 0; border: 0; background: none; cursor: pointer; }
.pf-ed-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pf-ed-swatch { width: 28px; height: 28px; border: 1px solid rgba(255, 255, 255, 0.2); cursor: pointer; padding: 0; }
.pf-ed-swatch:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.pf-ed-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  min-height: 60px;
  padding: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
}
.pf-ed-thumb {
  position: relative;
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.06);
  cursor: grab;
}
.pf-ed-thumb img, .pf-ed-thumb .pf-svg { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.pf-ed-thumb.is-dragging { opacity: 0.4; }
.pf-ed-thumb.is-over { outline: 2px dashed #fff; }
.pf-ed-num {
  position: absolute; left: 4px; top: 4px;
  padding: 1px 6px; font-size: 10px; background: #111; color: #fff;
}
.pf-ed-remove {
  position: absolute; right: 4px; top: 4px;
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: #111; color: #fff; font-size: 10px; cursor: pointer;
}
.pf-ed-empty { font-size: 12px; color: var(--text-muted); grid-column: 1 / -1; align-self: center; }
.pf-ed-check { display: flex; align-items: center; gap: 8px; margin-top: 20px; font-size: 14px; cursor: pointer; }
.pf-ed-status { min-height: 18px; margin: 12px 0 0; font-size: 12px; color: var(--text-secondary); }
.pf-ed-status.is-error { color: #eb5757; }
