/* Musykfabryk photo gallery (/fotos/). Justified rows in pure CSS (flex-grow by aspect ratio), so there is
   no layout shift and it works without JS. fotos.js adds filters, sorting, favourites and the lightbox. */

.g-hero .hero-media img { object-position: center 40%; }

/* ---------- toolbar ---------- */
.g-toolbar {
  position: sticky; top: 76px; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; overflow: hidden;
  margin: 0 calc(var(--gutter) * -1); padding: 14px var(--gutter);
  background: rgba(12, 13, 14, 0.82); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.g-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.g-row--events { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
.g-row--events::-webkit-scrollbar { display: none; }
.g-chip, .g-toggle {
  display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  font: 600 0.9rem/1 var(--body); cursor: pointer; transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.g-chip small { font-weight: 500; color: var(--muted); font-size: 0.8rem; }
.g-chip span { font-size: 0.75rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-chip:hover, .g-toggle:hover { border-color: var(--teal); }
.g-chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.g-chip[aria-pressed="true"] span, .g-chip[aria-pressed="true"] small { color: rgba(12, 13, 14, 0.6); }
.g-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.g-seg .g-chip { min-height: 36px; padding: 0 14px; }
.g-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.g-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.g-toggle[data-toggle="featured"][aria-pressed="true"] { background: rgba(224, 104, 63, 0.16); border-color: var(--rust); color: #ff9a74; }
.g-toggle[data-toggle="featured"][aria-pressed="true"] svg { fill: currentColor; }
.g-toggle[data-toggle="fav"][aria-pressed="true"] { background: rgba(55, 180, 172, 0.16); border-color: var(--teal); color: var(--teal-hi); }
.g-toggle[data-toggle="fav"][aria-pressed="true"] svg { fill: currentColor; }
.g-fav-count { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-sort select {
  appearance: none; min-height: 40px; padding: 0 38px 0 16px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ece8e1' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 14px center / 14px no-repeat;
  color: var(--text); font: 600 0.9rem var(--body); cursor: pointer;
}
.g-status { margin: 22px 0 0; font-size: 0.85rem; color: var(--muted); }

/* ---------- event groups ---------- */
.g-event { padding-top: 34px; }
.g-event[hidden] { display: none; }
.g-event-head { display: grid; gap: 4px; margin-bottom: 22px; }
.g-event-date { margin: 0; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--teal-hi); }
.g-event-head h2 { margin: 0; font-size: clamp(2rem, 1.3rem + 2.6vw, 3.4rem); }
.g-event-meta { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; }
.g-event-meta a { color: var(--text); text-decoration-color: var(--teal); text-underline-offset: 3px; }
.g-event-head .lineup { margin: 10px 0 0; }
.g-event-head .lineup li { font-size: 0.95rem; padding: 4px 12px; }

/* ---------- justified grid ---------- */
.g-grid { --row: clamp(150px, 22vw, 290px); display: flex; flex-wrap: wrap; gap: 8px; }
.g-grid::after { content: ""; flex-grow: 1e6; }
.g-item {
  position: relative; margin: 0; flex: calc(var(--r) * 100) 1 calc(var(--r) * var(--row));
  aspect-ratio: var(--r); border-radius: 10px; overflow: hidden; background: var(--surface);
  max-height: calc(var(--row) * 1.6);
}
.g-item[hidden] { display: none; }
.g-open { display: block; width: 100%; height: 100%; cursor: zoom-in; }
.g-open:focus-visible { outline: 3px solid var(--teal-hi); outline-offset: -3px; }
.g-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.7s var(--ease), filter 0.4s; }
.g-item::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(12,13,14,.45), transparent 32%); opacity: 0; transition: opacity 0.3s; }
@media (hover: hover) {
  .g-item:hover img { transform: scale(1.04); }
  .g-item:hover::after, .g-item:focus-within::after { opacity: 1; }
}
.g-star {
  position: absolute; left: 10px; top: 10px; z-index: 1; display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: rgba(12, 13, 14, 0.62); color: #ff9a74; backdrop-filter: blur(6px); pointer-events: none;
}
.g-star svg { width: 15px; height: 15px; fill: currentColor; }
.g-fav {
  position: absolute; right: 8px; top: 8px; z-index: 1; display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: rgba(12, 13, 14, 0.55); color: var(--text); cursor: pointer;
  backdrop-filter: blur(6px); transition: transform 0.2s var(--ease), background 0.2s, opacity 0.2s;
}
.g-fav svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.g-fav[aria-pressed="true"] { color: var(--teal-hi); opacity: 1; }
.g-fav[aria-pressed="true"] svg { fill: currentColor; }
.g-fav:active { transform: scale(0.88); }
@media (hover: hover) {
  .g-fav { opacity: 0; }
  .g-item:hover .g-fav, .g-fav:focus-visible { opacity: 1; }
}
.g-fav.pop svg { animation: g-pop 0.4s var(--ease); }
@keyframes g-pop { 40% { transform: scale(1.35); } }
.js .g-item.g-in { animation: g-fade 0.5s var(--ease) both; animation-delay: var(--d, 0s); }
@keyframes g-fade { from { opacity: 0; transform: translateY(12px); } }

.g-empty { padding: 60px 0; text-align: center; color: var(--muted); }
.g-empty p { margin: 0 0 18px; font-size: 1.1rem; }

/* ---------- lightbox ---------- */
.lightbox {
  width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgba(8, 9, 10, 0.97); color: var(--text); overflow: hidden;
}
.lightbox::backdrop { background: rgba(8, 9, 10, 0.9); backdrop-filter: blur(8px); }
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; animation: lb-in 0.25s var(--ease); }
@keyframes lb-in { from { opacity: 0; } }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; overflow: hidden; padding: 64px 72px 12px; touch-action: pan-y; }
.lb-img { max-width: calc(100vw - 144px); max-height: calc(100dvh - 160px); width: auto; height: auto; object-fit: contain; border-radius: 6px; box-shadow: 0 30px 80px rgba(0,0,0,.6); transition: opacity 0.25s, transform 0.25s var(--ease); user-select: none; -webkit-user-drag: none; }
.lb-img.is-loading { opacity: 0.25; }
.lb-spin { position: absolute; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-strong); border-top-color: var(--teal); animation: lb-spin 0.8s linear infinite; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.lb-stage.is-loading .lb-spin { opacity: 1; }
@keyframes lb-spin { to { transform: rotate(1turn); } }
.lb-btn {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: rgba(24, 27, 29, 0.7); color: var(--text); cursor: pointer; transition: background 0.2s, border-color 0.2s;
}
.lb-btn:hover { background: var(--surface-2); border-color: var(--teal); }
.lb-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.lb-prev, .lb-next { position: absolute; top: 50%; z-index: 2; transform: translateY(-50%); }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-fav[aria-pressed="true"] { color: var(--teal-hi); border-color: var(--teal); }
.lb-fav[aria-pressed="true"] svg { fill: currentColor; }
.lb-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px calc(18px + env(safe-area-inset-bottom)); }
.lb-info { min-width: 0; }
.lb-title { margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-meta { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.lb-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.lb-count { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.lb-toast { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 0.9rem; pointer-events: none; animation: g-fade 0.25s var(--ease); }

@media (max-width: 900px) {
  .g-toolbar { top: 76px; }
  .g-tools { width: 100%; }
  .g-sort { margin-left: auto; }
}
@media (max-width: 640px) {
  .g-toolbar { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .g-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); justify-content: flex-start; }
  .g-row::-webkit-scrollbar { display: none; }
  .g-seg, .g-tools { flex-wrap: nowrap; width: auto; }
  .g-sort { margin-left: 0; }
  .g-chip, .g-toggle, .g-sort select { min-height: 36px; font-size: 0.85rem; }
  .g-seg .g-chip { min-height: 36px; }
  .g-grid { --row: 96px; gap: 4px; }
  .g-item { max-height: none; }
  .g-item { border-radius: 8px; }
  .g-fav { width: 36px; height: 36px; right: 4px; top: 4px; }
  .g-star { width: 26px; height: 26px; left: 6px; top: 6px; }
  .lb-stage { padding: 60px 0 8px; }
  .lb-img { border-radius: 0; max-width: 100vw; max-height: calc(100dvh - 150px); }
  .lb-prev, .lb-next { display: none; }
  .lb-bar { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
  .g-toggle { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .g-item img, .lb-img { transition: none; }
  .js .g-item.g-in { animation: none; }
}

/* touch screens: small tiles stay clean; the heart shows only on saved photos (save via the lightbox or a long look) */
@media (hover: none) and (max-width: 640px) {
  .g-fav[aria-pressed="false"] { display: none; }
  .g-fav { width: 30px; height: 30px; background: rgba(12, 13, 14, 0.6); }
  .g-fav svg { width: 15px; height: 15px; }
  .g-star { width: 22px; height: 22px; }
  .g-star svg { width: 12px; height: 12px; }
}
