/* === Mřížka fotek — edge-to-edge v rámci containeru === */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  /* Přesah přes px-4 padding containeru, ale nepřekračuje jeho šířku */
  width: calc(100% + 2rem);
  margin-left: -1rem;
}

.photo-card {
  position: relative;
  overflow: hidden;
  background: #111827;
  aspect-ratio: var(--photo-ar, 3/2);
}

@media (min-width: 640px) {
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-rows: 150px;
  }
  .photo-card {
    aspect-ratio: unset;
  }
  .photo-card.portrait {
    grid-row: span 2;
  }
}

.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
.photo-card:hover img {
  transform: scale(1.04);
}
.photo-card .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  transition: background 0.2s ease;
  pointer-events: none;
}
@media (hover: hover) {
  .photo-card:hover .overlay {
    background: rgba(0,0,0,0.25);
  }
  .photo-card:hover .zoom-hint {
    opacity: 1 !important;
  }
}
.photo-card.selected .overlay {
  background: rgba(79,70,229,0.35);
}

/* Rohy karty fotky — cena (vlevo dole) a košík (vpravo dole). Inline-styly v šabloně by
   se násobily přes 100+ fotek per album a zbytečně nafukovaly HTML payload. */
.photo-card-price-corner {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 11;
  pointer-events: none;
}
.photo-card-cart-corner {
  position: absolute;
  bottom: 0;
  right: 0;
  z-index: 10;
}
.photo-card-zoom-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-price-tag {
  display: block;
  background: rgba(0, 0, 0, 0.52);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 1px 5px 2px;
  border-radius: 0 3px 0 0;
}
.photo-price-tag--free { color: rgba(134, 239, 172, 0.9); }
.photo-price-tag--override { color: rgba(253, 224, 71, 0.9); }
.cart-form { margin: 0; }

/* Košík tlačítko */
.cart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 3px 0 0 0;
  border: none;
  background: rgba(0,0,0,0.52);
  color: white;
  cursor: pointer;
  transition: background 0.15s;
}
.cart-btn:hover { background: rgba(0,0,0,0.72); }
.cart-btn.in-cart { background: rgba(79,70,229,0.82); color: white; }
.cart-btn.in-cart:hover { background: rgba(67,56,202,0.92); }
@keyframes cartPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}
.cart-btn.cart-pop { animation: cartPop 0.35s ease forwards; }

.photo-card.io-pending {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* === Lightbox — full-screen === */
#lightbox {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  /* Veškerá touch gesta řeší JS (pinch/pan/swipe) — vypneme browser default. */
  touch-action: none;
  overscroll-behavior: contain;
}
#lbCartBtn:disabled { opacity: 0.6; cursor: wait; }
#lightbox img {
  max-width: 100vw;
  max-height: 90vh;
  object-fit: contain;
  user-select: none;
  -webkit-touch-callout: none;
  /* Pinch-zoom transform aplikuje JS přes inline style. transform-origin uprostřed. */
  transform-origin: center center;
  will-change: transform;
  touch-action: none; /* veškerá touch gesta řeší JS (pinch / pan / swipe) */
}
/* Tmavé pozadí + jemný bílý border + blur — viditelné nad jakkoli světlou fotkou. */
.lb-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  width: 48px;
  height: 72px;
  border-radius: 8px;
  font-size: 1.8rem;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  z-index: 10001;
}
.lb-btn:hover { background: rgba(0,0,0,0.75); }
#lbPrev { left: 0.5rem; }
#lbNext { right: 0.5rem; }
#lbClose {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  z-index: 10002;
}
#lbClose:hover { background: rgba(0,0,0,0.75); }
#lbInfo {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255,255,255,0.9);
  font-size: 0.8rem;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 120px);
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0,0,0,0.6);
  padding: 0.3rem 0.9rem;
  border-radius: 9999px;
  backdrop-filter: blur(6px);
}
#lbInfoAlbum { font-weight: 600; }
#lbInfoPrice { color: #c4b5fd; font-weight: 600; }
#lbCounter {
  position: fixed;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  background: rgba(0,0,0,0.5);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
}
#lbCartBtn {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  min-width: 10rem;
  border-radius: 9999px;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  z-index: 10001;
}
/* Cart button — tmavé pozadí + bílý border, aby byl čitelný nad světlou fotkou. */
#lbCartBtn.lb-cart-add  {
  background: rgba(0,0,0,0.6);
  color: white;
  border: 1px solid rgba(255,255,255,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
#lbCartBtn.lb-cart-add:hover { background: rgba(0,0,0,0.8); }
#lbCartBtn.lb-cart-in  {
  background: #4f46e5;
  color: white;
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 2px 12px rgba(79,70,229,0.55);
}
#lbCartBtn.lb-cart-in:hover { background: #4338ca; }

/* Posun pod spodek videa — native <video controls> bar by jinak překrýval cart button.
   Aktivuje se z base_photos.html pro mediaType==='video'. */
#lbCartBtn.lb-cart-video {
  bottom: 5rem;
}

/* === HTMX — ochrana proti double-submit ===
   Třídu htmx-request přidává HTMX automaticky na formulář po dobu požadavku. */
form.htmx-request button[type="submit"] {
  pointer-events: none;
  opacity: 0.65;
}

/* === Plovoucí košík bar === */
#cartBar {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  transition: transform 0.3s cubic-bezier(.4,0,.2,1);
  z-index: 50;
  white-space: nowrap;
}
#cartBar.visible {
  transform: translateX(-50%) translateY(0);
}
#cartBar a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.25s, box-shadow 0.25s;
  background: #fbbf24;
  color: #111827;
  border: none;
  box-shadow: 0 4px 18px rgba(251,191,36,0.40);
}
#cartBar a:hover {
  background: #f59e0b;
  box-shadow: 0 6px 22px rgba(245,158,11,0.50);
}
/* Dark mode — jantarová zůstává, jen mírně tlumená */
.dark #cartBar a {
  background: #f59e0b;
  color: #111827;
  box-shadow: 0 4px 18px rgba(245,158,11,0.35);
}
.dark #cartBar a:hover {
  background: #d97706;
  box-shadow: 0 6px 22px rgba(217,119,6,0.45);
}
