:root{
  --gold-1: #D4AF37;   /* глухое золото */
  --gold-2: #E9C970;   /* светлый отблеск */
  --gold-3: #8A6B20;   /* тёплая тень */
  --gold-glow: rgba(212,175,55,.55);
}

.gallery-item.hidden {
  opacity: 0;
  transform: translateY(20px);
  visibility: hidden;
}

.gallery-item.visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition: all 0.3s ease;
}

.gallery-item {
  transition: all 0.3s ease;
}

.gallery-main {
    margin-top: 80px;
    min-height: calc(100vh - 80px);
    padding: var(--sp-xl);
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.gallery-header {
    text-align: center;
    margin-bottom: var(--sp-2xl);
}

.gallery-header h2 {
    color: var(--gold);
    font-size: var(--fs-4xl);
    font-weight: 700;
    margin-bottom: var(--sp-md);
}

.gallery-subtitle {
    color: var(--gold-light);
    font-size: var(--fs-lg);
    opacity: 0.9;
    margin-bottom: var(--sp-lg);
}

.gallery-stats {
    display: flex;
    justify-content: center;
    gap: var(--sp-lg);
    font-size: var(--fs-sm);
    color: var(--gold-light);
}

.filtered-count {
    color: var(--gold-bright);
}

.filter-tags-container {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: var(--sp-lg);
    margin-bottom: var(--sp-2xl);
    display: flex;
    flex-direction: column;
    gap: var(--sp-lg);
}

.search-container {
    display: flex;
    justify-content: center;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: var(--sp-sm) var(--sp-lg);
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    color: var(--gold);
    font-size: var(--fs-md);
    transition: all var(--ease);
    text-align: center;
}

.search-input::placeholder {
    color: var(--gold-light);
    opacity: 0.7;
}

.search-input:focus {
    outline: none;
    border-color: var(--gold-warm);
    background: rgba(255,255,255,0.15);
    text-align: left;
}

.filter-tags-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-xl);
    align-items: center;
    justify-content: center;
}

.filter-tag-section {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex-wrap: wrap;
}

.filter-tag-label {
    color: var(--gold-light);
    font-size: var(--fs-sm);
    font-weight: 500;
    white-space: nowrap;
}

.filter-tags {
    display: flex;
    gap: var(--sp-xs);
    flex-wrap: wrap;
}

.filter-tag {
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: var(--sp-xs) var(--sp-md);
    color: var(--gold-light);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: all var(--ease);
    white-space: nowrap;
}

.filter-tag:hover {
    background: rgba(218,165,32,0.1);
    border-color: var(--gold-warm);
    color: var(--gold);
}

.filter-tag.active {
    background: var(--gold-warm);
    border-color: var(--gold);
    color: #1a1a1a;
    font-weight: 600;
}

.reset-filters-btn {
    background: rgba(218,165,32,0.1);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: var(--sp-xs) var(--sp-lg);
    color: var(--gold-light);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: all var(--ease);
    white-space: nowrap;
}

.reset-filters-btn:hover {
    background: rgba(218,165,32,0.2);
    color: var(--gold);
    border-color: var(--gold-warm);
}

#galleryContainer{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(260px,1fr));
  gap:16px;
  grid-auto-rows:8px;
  grid-auto-flow:row;
}

.gallery-item{ overflow:visible; }
.gallery-item__inner{ 
  display:block;
}

.gallery-media{
  width:100%;
  height:auto;
  display:block;
}

.gallery-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    margin-bottom: var(--sp-lg);
    overflow: hidden;
    break-inside: avoid;
    cursor: pointer;
    transition: all var(--ease);
    opacity: 0;
    transform: translateY(30px);
    position: relative;
}

.gallery-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.gallery-item.filtered-out {
    display: none;
}

.gallery-item:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--gold-warm);
}

.gallery-media-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: rgba(0,0,0,0.2);
}

.gallery-media {
    width: 100%;
    height: auto;
    display: block;
    transition: transform var(--ease);
}

.gallery-item:hover .gallery-media {
    transform: scale(1.05);
}

.video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(0,0,0,0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: var(--fs-xl);
    backdrop-filter: blur(5px);
    transition: all var(--ease);
}

.gallery-item:hover .video-overlay {
    background: rgba(218,165,32,0.8);
    color: white;
    transform: translate(-50%, -50%) scale(1.1);
}

.gallery-tags-overlay {
    position: absolute;
    top: var(--sp-sm);
    left: var(--sp-sm);
    right: var(--sp-sm);
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-xs);
    pointer-events: none;
}

.gallery-tag {
    background: rgba(0,0,0,0.7);
    color: var(--gold-bright);
    padding: 2px var(--sp-xs);
    border-radius: 8px;
    font-size: var(--fs-xs);
    font-weight: 500;
    backdrop-filter: blur(5px);
}

.gallery-info {
    padding: var(--sp-md);
}

.gallery-title {
    color: var(--gold);
    font-size: var(--fs-md);
    font-weight: 600;
    margin-bottom: var(--sp-xs);
    line-height: 1.3;
}

.gallery-description {
    color: var(--gold-light);
    font-size: var(--fs-xs);
    line-height: 1.4;
    opacity: 0.9;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: var(--sp-xs);
}

.gallery-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-xs);
    color: var(--gold-light);
    opacity: 0.7;
}

.media-type-badge {
    position: absolute;
    top: var(--sp-xs);
    right: var(--sp-xs);
    background: var(--gold);
    color: #1a1a1a;
    padding: 2px var(--sp-xs);
    border-radius: 10px;
    font-size: var(--fs-xs);
    font-weight: 600;
    z-index: 10;
}

.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-sm);
    padding: var(--sp-xl);
    opacity: 0;
    transition: opacity var(--ease);
}

.loading-indicator.visible {
    opacity: 1;
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: var(--gold-bright);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.loading-text {
    color: var(--gold-light);
    font-weight: 500;
    font-size: var(--fs-sm);
}

.end-message {
    text-align: center;
    padding: var(--sp-xl);
    color: var(--gold-light);
    font-size: var(--fs-md);
    opacity: 0.8;
}

/* ===== LIGHTBOX ===== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--ease);
}

.lightbox:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px);
    cursor: pointer;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    background: var(--glass);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    transform: scale(0.8);
    transition: transform var(--ease);
}

.lightbox:not(.hidden) .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: var(--sp-md);
    right: var(--sp-md);
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.7);
    color: var(--gold-bright);
    border: none;
    border-radius: 50%;
    font-size: var(--fs-xl);
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all var(--ease);
}

.lightbox-close:hover {
    background: rgba(218,165,32,0.8);
    color: #1a1a1a;
    transform: scale(1.1);
}

.lightbox-media-container {
    position: relative;
    width: 100%;
    max-height: 70vh;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image,
.lightbox-video {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

.lightbox-video {
    width: 100%;
}

.lightbox-info {
    padding: var(--sp-lg);
}

.lightbox-title {
    color: var(--gold);
    font-size: var(--fs-xl);
    font-weight: 600;
    margin-bottom: var(--sp-sm);
}

.lightbox-description {
    color: var(--gold-light);
    font-size: var(--fs-sm);
    line-height: 1.6;
    margin-bottom: var(--sp-md);
    opacity: 0.9;
}

.lightbox-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-xs);
}

.lightbox-tag {
    background: rgba(218,165,32,0.2);
    color: var(--gold);
    padding: var(--sp-xs) var(--sp-sm);
    border-radius: 10px;
    font-size: var(--fs-xs);
    font-weight: 500;
    border: 1px solid var(--glass-border);
}

@media (max-width: 1200px) {
    .masonry-container {
        columns: 3;
    }
}

@media (max-width: 900px) {
    .masonry-container {
        columns: 2;
    }
    
    .filter-tags-group {
        flex-direction: column;
        gap: var(--sp-md);
    }
    
    .filter-tag-section {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .masonry-container {
        columns: 1;
    }
    
    .gallery-main {
        padding: var(--sp-md);
    }
    
    .filter-tags-container {
        padding: var(--sp-md);
    }
    
    .gallery-header h2 {
        font-size: var(--fs-3xl);
    }
    
    .filter-tags-group {
        gap: var(--sp-sm);
    }
    
    .filter-tag-section {
        width: 100%;
        justify-content: flex-start;
    }
    
    .filter-tag-label {
        min-width: 50px;
    }
}

.hidden {
    display: none !important;
}

.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;
}

.loading-indicator {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: rgba(255, 214, 150, 0.8);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 214, 150, 0.2);
  border-top: 3px solid #ffd696;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-indicator p {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
}

.end-indicator {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px;
  color: rgba(255, 214, 150, 0.6);
  font-size: 14px;
  opacity: 0.8;
}

.end-indicator p {
  margin: 0;
}

.filter-tags{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-tag{
  position: relative;
  appearance: none;
  padding: 8px 14px;
  border-radius: 14px;
  font-weight: 600;
  letter-spacing: .2px;
  color: #E8E6DF;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}
.filter-tag:hover{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.28);
}

.filter-tag.active,
.filter-tag[aria-pressed="true"]{
  color: #1B1404;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
  background:
    radial-gradient(120% 120% at 10% 0%, rgba(255,255,255,.35) 0%, rgba(255,255,255,0) 60%),
    linear-gradient(160deg, var(--gold-3) 0%, var(--gold-1) 32%, var(--gold-2) 55%, var(--gold-1) 75%, var(--gold-3) 100%);
  border: 1px solid #B9912B;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.38),
    inset 0 -1px 0 rgba(128,84,0,.25),
    0 4px 14px rgba(0,0,0,.45),
    0 0 24px var(--gold-glow);
}

.filter-tag.active::before{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 30%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.filter-tag.active:hover{
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.42),
    0 6px 18px rgba(0,0,0,.55),
    0 0 34px rgba(240,204,90,.70);
}

@media (max-width: 560px){
  .filter-tag{ padding: 7px 12px; border-radius: 12px; }
  .gallery-main { margin-top: 10px;}
}

.gallery-meta {
    display: none;
}