/* ============================================================
   Галерея — стили
   ============================================================ */

:root {
  --bg: #0b0f14;
  --bg-soft: #121822;
  --surface: #161d29;
  --surface-2: #1d2632;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eef7;
  --text-muted: #8b98ab;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --danger: #ff5a7a;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.85);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(79, 140, 255, 0.14), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(124, 92, 255, 0.12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: #cfe0ff;
}

.wrap {
  width: min(1280px, 100% - 40px);
  margin-inline: auto;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 18px 0 14px;
  background: rgba(11, 15, 20, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px -6px rgba(79, 140, 255, 0.8);
}

.brand-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Filters ---------- */

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 26px 0 22px;
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease),
              border-color 0.2s var(--ease), transform 0.15s var(--ease);
}

.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.18); }
.chip:active { transform: scale(0.97); }

.chip.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px -12px rgba(79, 140, 255, 0.9);
}

.chip[hidden] { display: none; }

/* ---------- Grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}

.card {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  text-align: left;
  font: inherit;
  color: inherit;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease),
              border-color 0.28s var(--ease), box-shadow 0.28s var(--ease);
}

.card.is-in {
  opacity: 1;
  transform: translateY(0);
}

.card:hover,
.card:focus-visible {
  transform: translateY(-5px);
  border-color: rgba(79, 140, 255, 0.5);
  box-shadow: var(--shadow);
  outline: none;
}

.card-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--ease);
}

.card:hover .card-media { transform: scale(1.05); }

.card-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(79, 140, 255, 0.22), rgba(124, 92, 255, 0.22)),
    var(--surface-2);
}

.card-fallback svg { width: 34px; height: 34px; opacity: 0.85; }

.card-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 34px 14px 12px;
  background: linear-gradient(to top, rgba(3, 6, 10, 0.9), rgba(3, 6, 10, 0));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.card-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: #f2f6fc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(6, 10, 16, 0.72);
  border: 1px solid var(--border);
  color: #cdd8ea;
  backdrop-filter: blur(6px);
}

.play-badge {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 14, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  transition: transform 0.28s var(--ease), background 0.28s var(--ease);
  pointer-events: none;
}

.play-badge::after {
  content: "";
  border-style: solid;
  border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent #fff;
  margin-left: 4px;
}

.card:hover .play-badge {
  transform: scale(1.08);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

/* ---------- Empty state ---------- */

.empty {
  margin: 40px 0 80px;
  padding: 34px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  line-height: 1.8;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0 28px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.lightbox[hidden] { display: none; }

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 12, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.28s var(--ease);
}

.lightbox.is-open .lightbox-backdrop { opacity: 1; }

.lightbox-stage {
  position: relative;
  margin: 0;
  max-width: min(1100px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.lightbox.is-open .lightbox-stage {
  opacity: 1;
  transform: scale(1);
}

.lightbox-media {
  position: relative;
  display: grid;
  place-items: center;
  min-width: min(320px, 80vw);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}

.lightbox-media img,
.lightbox-media video {
  display: block;
  max-width: min(1100px, 94vw);
  max-height: 78vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.lightbox-media video { background: #000; }

.lightbox-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.lb-title {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-counter { white-space: nowrap; font-variant-numeric: tabular-nums; }

.lb-btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(18, 24, 34, 0.72);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.lb-btn:hover { background: rgba(38, 48, 66, 0.92); }
.lb-btn:active { transform: scale(0.94); }
.lb-btn:disabled { opacity: 0.3; cursor: default; }

.lb-close { top: 20px; right: 22px; font-size: 1.6rem; }
.lb-prev { left: 22px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 22px; top: 50%; transform: translateY(-50%); }
.lb-prev:active { transform: translateY(-50%) scale(0.94); }
.lb-next:active { transform: translateY(-50%) scale(0.94); }

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .wrap { width: min(1280px, 100% - 28px); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .brand-title { font-size: 1.2rem; }
  .lightbox { padding: 12px; }
  .lb-btn { width: 42px; height: 42px; }
  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lb-close { top: 10px; right: 12px; }
  .lightbox-media img,
  .lightbox-media video { max-height: 70vh; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .card { opacity: 1; transform: none; }
}
