/**
 * HNMC Portfolio Frontend Styles - Enhanced mit 3:2 Bildformat
 * Erweiterte Version mit Settings-basierten, einheitlichen Bildformaten für Portfolio UND Mitarbeiter
 */

/* CSS Custom Properties */
.hnmc-portfolio {
  --gap: 16px;
  --overlay: rgba(0, 0, 0, 0.6);
  --tile-ratio: auto;
  --border-radius: 8px;
  --transition-duration: 0.3s;
  --text-color: #ffffff;
  --focus-color: #0073aa;
  position: relative;
}

/* Core Grid */
.hnmc-portfolio .hnmc-grid {
  display: grid;
  gap: var(--gap);
  margin: 0;
  padding: 0;
}

/* Portfolio Item - Einheitliche Basis */
.hnmc-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius);
  background: #f5f5f5;
  margin: 0;
  transition: transform var(--transition-duration) ease, box-shadow var(--transition-duration) ease;
  display: flex;
  flex-direction: column;
}

.hnmc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Link Styling */
.hnmc-link {
  position: relative;
  display: block;
  text-decoration: none;
  color: inherit;
  outline: none;
  flex: 1;
}

.hnmc-link:focus {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

/* Standard Images - Basis für alle Bilder */
.hnmc-card img {
  width: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-duration) ease;
}

/* PORTFOLIO-BILDER: Konfigurierbare, einheitliche Formate basierend auf Settings */

/* Portfolio Format Automatic - Fallback */
.hnmc-portfolio-format-auto .hnmc-card:not(.hnmc-employee-card) img {
  height: 200px;
  object-position: center center;
}

/* Portfolio Format Square (1:1) */
.hnmc-portfolio-format-square .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 1 / 1;
  height: auto;
  object-position: center center;
}

/* Portfolio Format Portrait (3:4) */
.hnmc-portfolio-format-portrait .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 3 / 4;
  height: auto;
  object-position: center 30%;
}

/* Portfolio Format Landscape (4:3) - Standard für Architektur */
.hnmc-portfolio-format-landscape .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 4 / 3;
  height: auto;
  object-position: center center;
}

/* Portfolio Format Classic (3:2) - NEU */
.hnmc-portfolio-format-classic .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 3 / 2;
  height: auto;
  object-position: center center;
}

/* Portfolio Format Wide (16:9) */
.hnmc-portfolio-format-wide .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 16 / 9;
  height: auto;
  object-position: center 40%;
}

/* Portfolio Format Tall (2:3) */
.hnmc-portfolio-format-tall .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 2 / 3;
  height: auto;
  object-position: center 25%;
}

/* MITARBEITER-BILDER: Konfigurierbare, einheitliche Formate */

/* Basis-Style für alle Mitarbeiter-Bilder */
.hnmc-employee-card img {
  width: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-duration) ease;
}

/* Portrait Format (3:4) - Standard für Personenfotos */
.hnmc-employees.format-portrait .hnmc-employee-card img {
  aspect-ratio: 3 / 4;
  height: auto;
  object-position: center 20%;
}

/* Quadratisches Format (1:1) */
.hnmc-employees.format-square .hnmc-employee-card img {
  aspect-ratio: 1 / 1;
  height: auto;
  object-position: center 25%;
}

/* Landschaft Format (4:3) */
.hnmc-employees.format-landscape .hnmc-employee-card img {
  aspect-ratio: 4 / 3;
  height: auto;
  object-position: center 30%;
}

/* Klassisches Format (3:2) - NEU */
.hnmc-employees.format-classic .hnmc-employee-card img {
  aspect-ratio: 3 / 2;
  height: auto;
  object-position: center 25%;
}

/* Breites Format (16:9) */
.hnmc-employees.format-wide .hnmc-employee-card img {
  aspect-ratio: 16 / 9;
  height: auto;
  object-position: center 25%;
}

/* Hohes Portrait Format (2:3) */
.hnmc-employees.format-tall .hnmc-employee-card img {
  aspect-ratio: 2 / 3;
  height: auto;
  object-position: center 15%;
}

/* Automatisches Format - behält Original-Proportionen */
.hnmc-employees.format-auto .hnmc-employee-card img {
  height: 250px; /* Fallback-Höhe */
  object-position: center 20%;
}

/* Object-Position Varianten für Mitarbeiter */
.hnmc-employees.position-center_top .hnmc-employee-card img {
  object-position: center top !important;
}

.hnmc-employees.position-center_20 .hnmc-employee-card img {
  object-position: center 20% !important;
}

.hnmc-employees.position-center_center .hnmc-employee-card img {
  object-position: center center !important;
}

.hnmc-employees.position-center_30 .hnmc-employee-card img {
  object-position: center 30% !important;
}

.hnmc-employees.position-center_bottom .hnmc-employee-card img {
  object-position: center bottom !important;
}

/* Mobile Anpassungen - BEIBEHALTEN der konfigurierten Formate */
@media (max-width: 768px) {
  /* Portfolio-Formate bleiben auf Mobile erhalten */
  .hnmc-portfolio-format-portrait .hnmc-card:not(.hnmc-employee-card) img {
    aspect-ratio: 3 / 4; /* Beibehalten */
  }
  
  .hnmc-portfolio-format-square .hnmc-card:not(.hnmc-employee-card) img {
    aspect-ratio: 1 / 1; /* Beibehalten */
  }
  
  .hnmc-portfolio-format-landscape .hnmc-card:not(.hnmc-employee-card) img {
    aspect-ratio: 4 / 3; /* Beibehalten */
  }
  
  .hnmc-portfolio-format-classic .hnmc-card:not(.hnmc-employee-card) img {
    aspect-ratio: 3 / 2; /* Beibehalten - NEU */
  }
  
  .hnmc-portfolio-format-wide .hnmc-card:not(.hnmc-employee-card) img {
    aspect-ratio: 16 / 9; /* Beibehalten */
  }
  
  .hnmc-portfolio-format-tall .hnmc-card:not(.hnmc-employee-card) img {
    aspect-ratio: 2 / 3; /* Beibehalten */
  }
  
  /* Nur automatisches Portfolio-Format wird auf Mobile angepasst */
  .hnmc-portfolio-format-auto .hnmc-card:not(.hnmc-employee-card) img {
    height: 150px; /* Kompakter auf Mobile */
  }

  /* Mitarbeiter-Formate bleiben auf Mobile erhalten */
  .hnmc-employees.format-portrait .hnmc-employee-card img {
    aspect-ratio: 3 / 4; /* Beibehalten */
  }
  
  .hnmc-employees.format-square .hnmc-employee-card img {
    aspect-ratio: 1 / 1; /* Beibehalten */
  }
  
  .hnmc-employees.format-landscape .hnmc-employee-card img {
    aspect-ratio: 4 / 3; /* Beibehalten */
  }
  
  .hnmc-employees.format-classic .hnmc-employee-card img {
    aspect-ratio: 3 / 2; /* Beibehalten - NEU */
  }
  
  .hnmc-employees.format-wide .hnmc-employee-card img {
    aspect-ratio: 16 / 9; /* Beibehalten */
  }
  
  .hnmc-employees.format-tall .hnmc-employee-card img {
    aspect-ratio: 2 / 3; /* Beibehalten */
  }
  
  /* Nur automatisches Mitarbeiter-Format wird auf Mobile angepasst */
  .hnmc-employees.format-auto .hnmc-employee-card img {
    height: 200px; /* Kompakter auf Mobile */
  }
}

/* Extra kleine Bildschirme - minimale Anpassungen */
@media (max-width: 480px) {
  .hnmc-portfolio-format-auto .hnmc-card:not(.hnmc-employee-card) img {
    height: 120px; /* Noch kompakter für Portfolio */
  }
  
  .hnmc-employees.format-auto .hnmc-employee-card img {
    height: 180px; /* Noch kompakter für Mitarbeiter */
  }
}

/* Legacy Tile Ratios für Rückwärtskompatibilität (für tile_ratio Parameter) */
.hnmc-tile-1\:1 .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 1 / 1;
  height: auto;
  object-fit: cover;
}

.hnmc-tile-4\:3 .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
}

.hnmc-tile-3\:2 .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 3 / 2;
  height: auto;
  object-fit: cover;
}

.hnmc-tile-16\:9 .hnmc-card:not(.hnmc-employee-card) img {
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
}

.hnmc-tile-auto .hnmc-card:not(.hnmc-employee-card) img {
  height: 200px;
  object-fit: cover;
}

/* Hover Effects (nur auf Hover-fähigen Geräten) */
@media (hover: hover) and (pointer: fine) {
  .hnmc-card:hover img {
    transform: scale(1.03);
  }
  
  .hnmc-card:hover .hnmc-overlay {
    transform: translateY(0%);
    opacity: 1;
  }
}

/* Overlay */
.hnmc-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1rem;
  background: var(--overlay);
  color: var(--text-color);
  transform: translateY(100%);
  transition: transform var(--transition-duration) ease, opacity var(--transition-duration) ease;
  opacity: 0;
}

.hnmc-overlay-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hnmc-title {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
  margin: 0;
}

.hnmc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.875rem;
  opacity: 0.9;
}

.hnmc-meta span {
  position: relative;
}

.hnmc-meta span:not(:last-child)::after {
  content: "•";
  margin-left: 0.75rem;
  opacity: 0.7;
}

.hnmc-location::before {
  content: "? ";
  opacity: 0.8;
}

.hnmc-year::before {
  content: "? ";
  opacity: 0.8;
}

.hnmc-area::before {
  content: "? ";
  opacity: 0.8;
}

/* Mitarbeiter-spezifische Overlay-Styles - EINHEITLICH mit Portfolio */
.hnmc-employee-card .hnmc-overlay {
  background: var(--overlay); /* Verwendet die gleiche Overlay-Farbe wie Portfolio-Items */
}

.hnmc-employee-title {
  font-size: 0.875rem;
  opacity: 0.9;
  font-weight: 400;
  margin-top: 0.25rem;
}

.hnmc-employee-contact {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

.hnmc-employee-email {
  display: block;
  color: inherit;
  text-decoration: none;
}

.hnmc-employee-phone {
  display: block;
  color: inherit;
  text-decoration: none;
  margin-top: 0.1rem;
}

.hnmc-employee-department {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

/* Touch-Titel (Mobile Geräte) */
.hnmc-title-touch {
  display: none;
  padding: 0.75rem;
  background: #ffffff;
  border-top: 1px solid #e0e0e0;
  margin-top: auto;
}

.hnmc-title-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: #333;
  margin-bottom: 0.25rem;
}

.hnmc-meta-touch {
  display: flex;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #666;
}

.hnmc-meta-touch span:not(:last-child)::after {
  content: "•";
  margin-left: 0.5rem;
  opacity: 0.7;
}

/* Mitarbeiter Touch-Styles */
.hnmc-employee-touch .hnmc-employee-title-touch {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
  font-weight: 400;
  line-height: 1.3;
}

.hnmc-employee-contact-touch {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.hnmc-employee-email-link,
.hnmc-employee-phone-link {
  color: var(--focus-color);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.2s ease;
  display: inline-block;
  padding: 2px 0;
}

.hnmc-employee-email-link:hover,
.hnmc-employee-phone-link:hover {
  color: #005a87;
  text-decoration: underline;
}

/* Touch-Geräte: Mobile Titel anzeigen, Overlay verstecken */
@media (hover: none) and (pointer: coarse) {
  .hnmc-title-touch {
    display: block;
  }
  
  .hnmc-overlay {
    display: none;
  }
  
  .hnmc-card:active {
    transform: scale(0.98);
  }
  
  /* Bessere Touch-Targets für Kontakt-Links */
  .hnmc-employee-email-link,
  .hnmc-employee-phone-link {
    padding: 8px 4px;
    margin: -4px -4px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* Native Lightbox */
.hnmc-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 9999;
}

.hnmc-lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.hnmc-lb-img {
  max-width: min(92vw, 1600px);
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}

.hnmc-close,
.hnmc-prev,
.hnmc-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  color: #fff;
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.hnmc-close:hover,
.hnmc-prev:hover,
.hnmc-next:hover {
  background: rgba(255, 255, 255, 0.25);
}

.hnmc-close:focus,
.hnmc-prev:focus,
.hnmc-next:focus {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

.hnmc-close {
  top: 20px;
  right: 20px;
}

.hnmc-prev {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.hnmc-next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.hnmc-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
}

/* Empty State */
.hnmc-portfolio-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #666;
  font-style: italic;
  background: #f8f9fa;
  border: 2px dashed #dee2e6;
  border-radius: var(--border-radius);
}

/* PhotoSwipe Container */
.hnmc-photoswipe-container {
  /* PhotoSwipe wird hier durch JavaScript eingefügt */
}

/* Block Editor Styles */
.hnmc-portfolio-block-editor {
  margin: 1rem 0;
}

.hnmc-block-preview {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Spezielle Employees Grid Styles */
.hnmc-employees {
  /* Mitarbeiter-spezifische Anpassungen */
}

.hnmc-employees .hnmc-card {
  cursor: default;
}

.hnmc-employees .hnmc-card[data-click="single"] {
  cursor: pointer;
}

.hnmc-employees .hnmc-employee-email-link:hover,
.hnmc-employees .hnmc-employee-phone-link:hover {
  cursor: pointer;
}

/* Responsive Breakpoints */
@media (max-width: 599px) {
  .hnmc-overlay {
    padding: 0.75rem;
  }
  
  .hnmc-title {
    font-size: 0.9rem;
  }
  
  .hnmc-meta {
    font-size: 0.8rem;
  }
  
  .hnmc-close,
  .hnmc-prev,
  .hnmc-next {
    width: 40px;
    height: 40px;
    font-size: 24px;
  }
  
  .hnmc-close {
    top: 15px;
    right: 15px;
  }
  
  .hnmc-prev {
    left: 15px;
  }
  
  .hnmc-next {
    right: 15px;
  }
}

@media (min-width: 1200px) {
  .hnmc-overlay {
    padding: 1.25rem;
  }
  
  .hnmc-title {
    font-size: 1.1rem;
  }
}

/* Grid-spezifische Anpassungen für bessere Ausrichtung */
.hnmc-grid {
  align-items: start;
}

/* Flexbox-Anpassungen für einheitliche Höhen */
.hnmc-card {
  height: auto;
  min-height: 200px;
}

/* Spezielle Anpassungen für das Single-Template */
.hnmc-single-gallery .hnmc-gallery-grid .hnmc-gallery-item img {
  height: 160px;
}

@media (max-width: 768px) {
  .hnmc-single-gallery .hnmc-gallery-grid .hnmc-gallery-item img {
    height: 120px;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .hnmc-card {
    border: 1px solid #000;
  }
  
  .hnmc-overlay {
    background: rgba(0, 0, 0, 0.9) !important;
  }
  
  .hnmc-link:focus {
    outline: 3px solid #000;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .hnmc-card,
  .hnmc-card img,
  .hnmc-overlay,
  .hnmc-lightbox,
  .hnmc-close,
  .hnmc-prev,
  .hnmc-next {
    transition: none;
  }
  
  .hnmc-card:hover {
    transform: none;
  }
  
  .hnmc-card:hover img {
    transform: none;
  }
}

/* Print Styles */
@media print {
  .hnmc-portfolio .hnmc-grid {
    display: block;
  }
  
  .hnmc-card {
    break-inside: avoid;
    margin-bottom: 1rem;
    page-break-inside: avoid;
  }
  
  .hnmc-overlay {
    display: none;
  }
  
  .hnmc-title-touch {
    display: block !important;
  }
  
  .hnmc-lightbox {
    display: none !important;
  }
  
  /* Mitarbeiter-Kontaktdaten in Print anzeigen */
  .hnmc-employee-contact-touch {
    display: block !important;
    margin-top: 0.5rem;
    font-size: 0.8rem;
  }
}

/* Focus Management */
.hnmc-card:focus-within {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}

/* Loading States */
.hnmc-card.loading {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Error States */
.hnmc-card.error {
  background: #ffebee;
  border: 1px solid #f44336;
}

.hnmc-card.error::after {
  content: "? Fehler beim Laden";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #f44336;
  font-size: 0.875rem;
}

/* Accessibility Improvements */
.hnmc-card [aria-label] {
  cursor: pointer;
}

.hnmc-lightbox[aria-hidden="true"] {
  visibility: hidden;
}

.hnmc-lightbox[aria-hidden="false"] {
  visibility: visible;
}

/* Custom Scrollbar */
.hnmc-portfolio::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.hnmc-portfolio::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.hnmc-portfolio::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .hnmc-portfolio::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
  }
}

/* Animation für neue Karten */
.hnmc-card {
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered Animation für mehrere Karten */
.hnmc-portfolio .hnmc-card:nth-child(1) { animation-delay: 0.1s; }
.hnmc-portfolio .hnmc-card:nth-child(2) { animation-delay: 0.2s; }
.hnmc-portfolio .hnmc-card:nth-child(3) { animation-delay: 0.3s; }
.hnmc-portfolio .hnmc-card:nth-child(4) { animation-delay: 0.4s; }
.hnmc-portfolio .hnmc-card:nth-child(5) { animation-delay: 0.5s; }
.hnmc-portfolio .hnmc-card:nth-child(6) { animation-delay: 0.6s; }

/* DEBUG: Temporäre Klassen zum Testen der Formate */
.hnmc-portfolio.debug .hnmc-card::before {
  content: attr(data-format);
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(255, 0, 0, 0.8);
  color: white;
  padding: 2px 6px;
  font-size: 10px;
  z-index: 10;
  border-radius: 3px;
}

.hnmc-employees.debug .hnmc-employee-card::before {
  content: attr(data-format);
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0, 255, 0, 0.8);
  color: white;
  padding: 2px 6px;
  font-size: 10px;
  z-index: 10;
  border-radius: 3px;
}