@font-face {
  font-family: 'ScienceGothic';
  src: url('https://fonts.gstatic.com/s/sciencegothic/v1/Yq6H-LyXKfZlL-1QwQJhWQ.woff2') format('woff2');
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #000000;
  --bg-20: #333333;
  --slide-w: clamp(200px, 22vw, 300px);
  --text-main: #787878;
  --mx: 0;
  --my: 0;
  --angle: 0deg;
  --ring-offset: 0px;
  --ring-width: 1px;
  --bg-blur: 100px;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text-main);
  font-family: system-ui, sans-serif;
  overflow-x: hidden;
}

/* Убираем фиксированную высоту body */
body {
  min-height: 100vh;
  position: relative;
}

/* Фиксируем минимальную высоту для режима слайдов */
body:not(.gallery-active) {
  min-height: 800vh;
}

.scroll-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.bg-blur-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  transform-origin: center;
  transform: scale(1.3);
  filter: blur(var(--bg-blur, 300px)) saturate(3);
  opacity: 0;
  transition: opacity 650ms cubic-bezier(.22,.9,.33,1), filter 400ms;
  will-change: opacity, background-image;
}

.bg-blur-wrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-blur-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: url('/images/noise.gif') repeat;
  opacity: 0.02;
  mix-blend-mode: multiply;
}

.bg-blur-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(circle, rgba(0,0,0,0) 40%, rgba(0,0,0,0.9) 100%);
}

.header {
  position: fixed;
  z-index: 999;
  color: var(--bg-30);
  padding: 20px;
  align-items: center;
  width: 100vw;
  font-family: 'Science Gothic', monospace;
  text-transform: uppercase;
  justify-content: center;
}

.header-content {
  justify-content: space-between;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0 auto;
}

/* Стили для навигации с неоном */
.nav a {
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 200, "wght" 600;
  transition: font-variation-settings 0.3s ease, color 0.3s ease;
  color: #3b3b3b;
  text-decoration: none;
  margin-left: 48px;
  font-size: 14px;
  position: relative;
  padding: 4px 8px;
  border-radius: 2px;
  filter: brightness(0.8);
}

.nav a:hover {
  font-variation-settings: "wdth" 300, "wght" 900;
  color: rgba(255, 255, 255, 0.4);
  text-shadow: 
    0 0 8px rgba(255, 255, 255, 0.3);
}

.nav a.active-filter {
  font-variation-settings: "wdth" 300, "wght" 900;
  color: #ffffff;
  animation: navLampFlicker 0.8s ease forwards;
}

/* Эффект лампы при активации фильтра */
@keyframes navLampFlicker {
  0% {
    text-shadow: none;
    color: #3b3b3b;
  }
  10% {
    text-shadow: 
      0 0 15px #ffffff,
      0 0 30px #ffffff;
    color: #ffffff;
  }
  15% {
    text-shadow: none;
    color: rgba(255, 255, 255, 0.3);
  }
  20% {
    text-shadow: 
      0 0 20px #ffffff,
      0 0 40px #ffffff,
      0 0 60px #ffffff;
    color: #ffffff;
  }
  30% {
    text-shadow: 
      0 0 8px #ffffff,
      0 0 15px #ffffff;
    color: rgba(255, 255, 255, 0.8);
  }
  40% {
    text-shadow: 
      0 0 25px #ffffff,
      0 0 50px #ffffff,
      0 0 75px #ffffff;
    color: #ffffff;
  }
  60% {
    text-shadow: none;
    color: rgba(255, 255, 255, 0.4);
  }
  70% {
    text-shadow: 
      0 0 12px #ffffff,
      0 0 25px #ffffff;
    color: #ffffff;
  }
  85% {
    text-shadow: 
      0 0 35px #ffffff,
      0 0 70px #ffffff,
      0 0 100px #ffffff;
    color: #ffffff;
  }
  100% {
    text-shadow: 
      0 0 8px #ffffff,
      0 0 15px #ffffff,
      0 0 25px #ffffff;
    color: #ffffff;
  }
}

/* Статичное свечение после анимации для навигации */
.nav a.active-filter::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110%;
  height: 150%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.08) 25%,
    transparent 65%
  );
  z-index: -1;
  opacity: 0;
  animation: navStaticGlow 0.5s ease 0.8s forwards;
  pointer-events: none;
}

@keyframes navStaticGlow {
  to {
    opacity: 1;
  }
}

/* Убираем underline из старого стиля */
.nav a.active-filter {
  text-decoration: none;
}

.footer {
  position: fixed;
  z-index: 1000; /* Поверх всего */
  bottom: 0;
  left: 0;
  width: 100%;
  color: var(--bg-30);
  padding: 8px;
  text-align: center;
  font-family: 'Science Gothic', monospace;
  text-transform: uppercase;
  pointer-events: none; /* Пропускаем события мыши */
}

.footer-content {
  display: flex;
  justify-content: right;
  align-items: center;
  gap: 4px;
}

.footer-text {
  color: #3b3b3b;
  line-height: 1.4;
  font-size: 6px;
}

.footer-image img {
  display: block;
  opacity: 0.4;
}

.tunnel-scene {
  position: fixed;
  inset: 0;
  perspective: 200px;
  overflow: hidden;
}

#scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  perspective: 800px;
  pointer-events: none;
}

#gridCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.slider {
  position: absolute;
  inset: 0;
  pointer-events: none;
  perspective: 1000px;
  z-index: 5;
  transform-style: preserve-3d;
  will-change: transform;
}

.slide {
  text-transform: uppercase;
  position: absolute;
  isolation: isolate;
  min-width: var(--slide-w);
  max-width: var(--slide-w);
  color: var(--text-main);
  background: rgba(0,0,0,0.1);
  border-radius: 0;
  padding: 1rem 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.5);
  font-size: .8rem;
  line-height: 1.4;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  pointer-events: auto;
  transition: outline 0.25s ease, outline-offset 0.25s ease, box-shadow 0.25s ease;
}

.slide:hover {
  outline: none;
  box-shadow: 0px 0px 2px rgba(255, 255, 255, 0.424);
}

.slide::after {
  content: "";
  position: absolute;
  inset: calc(var(--ring-offset) * -1);
  padding: var(--ring-width);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease, filter .2s ease;
  background: conic-gradient(
    from var(--angle)
    at calc(50% + var(--mx)*12%) calc(50% + var(--my)*10%),
    #000000, #000000, #f9f9f9, #000000, #f9f9f9, #000000
  );
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
}

.slide:hover::after {
  opacity: 1;
}

.slide-img {
  width: 100%;
  background: #111;
  overflow: hidden;
  display: block;
}

.slide-img img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.card-title {
  text-transform: uppercase;
  position: relative;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2em;
  min-height: 1.2em;
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 200, "wght" 900;
  letter-spacing: 0.05em;
  white-space: nowrap;
  color: var(--bg-20);
}

.card-subtitle {
  text-transform: uppercase;
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 200, "wght" 600;
  font-size: 8px;
  color: var(--bg-20);
}

/* ==========================
   СТИЛИ ГАЛЕРЕИ (PINTEREST-STYLE GRID)
   ========================== */

/* Контейнер галереи */
#gallery {
  display: none;
  position: relative;
  z-index: 10;
  min-height: 100vh;
  padding: 100px 20px 120px; /* Увеличил нижний padding для футера */
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.4s ease;
  width: 100%;
}

/* Показываем галерею в активном состоянии */
.gallery-active #gallery {
  display: block;
  opacity: 1;
}

/* Скрываем tunnel элементы в режиме галереи */
.gallery-active .tunnel-scene,
.gallery-active #scene,
.gallery-active .bg-blur-wrap,
.gallery-active .slider,
.gallery-active .bg-blur-layer {
  display: none;
  opacity: 0;
  visibility: hidden;
}

/* Разрешаем скролл в режиме галереи */
.gallery-active {
  overflow-y: auto;
  overflow-x: hidden;
  cursor: default;
  min-height: 100vh;
}

.gallery-active .scroll-container {
  display: none;
}

/* Pinterest-style masonry grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 0;
  align-items: start; /* Важно для разной высоты карточек */
}

/* Элементы галереи */
.gallery-item {
  position: relative;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0; /* Убрал скругление углов */
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  animation: slideUp 0.5s ease forwards;
  animation-delay: calc(var(--item-index, 0) * 0.03s);
  will-change: transform, opacity;
  break-inside: avoid; /* Предотвращает разрыв карточек */
  display: flex;
  flex-direction: column;
}

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

.gallery-item:hover {

  border: 1px solid rgba(255, 255, 255, 0.741);

}

/* Изображение в галерее - сохраняем пропорции оригинального изображения */
.gallery-thumb {
  width: 100%;
  overflow: hidden;
  background: #111;
  position: relative;
  flex-shrink: 0;
}

.gallery-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.6s ease;
  object-fit: contain; /* Показываем все изображение */
  max-width: 100%;
  max-height: none; /* Убираем ограничение по высоте */
}



/* Ленивая загрузка */
.gallery-thumb .lazy-img {
  opacity: 0;
  transition: opacity 0.4s ease;
  min-height: 200px; /* Минимальная высота для placeholder */
}

.gallery-thumb img:not(.lazy-img) {
  opacity: 1;
}

/* Подпись к изображению */
.gallery-caption {
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.g-title {
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 180, "wght" 600;
  font-size: 14px;
  color: #f0f0f0;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.3;
}

.g-sub {
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 150, "wght" 400;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

/* Пустое состояние галереи */
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: #888;
}

.gallery-empty h3 {
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 200, "wght" 600;
  font-size: 20px;
  margin-bottom: 12px;
  color: #f0f0f0;
}

.gallery-empty p {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.5;
  color: #666;
}

/* Пустое состояние слайдов */
.slide-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #888;
  font-size: 16px;
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 200, "wght" 400;
}

/* View switcher стили - белый неон с ламповым переключением */
/* View switcher стили - белый неон с ламповым переключением */
.view-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 48px;
  padding: 4px;
}

.view-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.2);
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 180, "wght" 500;
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 6px 16px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  text-transform: uppercase;
  min-width: 80px;
  text-align: center;
  filter: brightness(0.8);
}

.view-btn:hover {
  color: rgba(255, 255, 255, 0.4);
  filter: brightness(1.1);
}

.view-btn.active-view {
  color: #ffffff;
  font-variation-settings: "wdth" 300, "wght" 900;
  animation: lampFlicker 0.8s ease forwards;
}

/* Эффект мигания лампы при переключении видов */
@keyframes lampFlicker {
  0% {
    text-shadow: none;
    color: rgba(255, 255, 255, 0.2);
  }
  10% {
    text-shadow: 
      0 0 20px #ffffff,
      0 0 40px #ffffff;
    color: #ffffff;
  }
  15% {
    text-shadow: none;
    color: rgba(255, 255, 255, 0.3);
  }
  20% {
    text-shadow: 
      0 0 25px #ffffff,
      0 0 50px #ffffff,
      0 0 80px #ffffff;
    color: #ffffff;
  }
  30% {
    text-shadow: 
      0 0 10px #ffffff,
      0 0 20px #ffffff;
    color: rgba(255, 255, 255, 0.8);
  }
  40% {
    text-shadow: 
      0 0 30px #ffffff,
      0 0 60px #ffffff,
      0 0 100px #ffffff;
    color: #ffffff;
  }
  60% {
    text-shadow: none;
    color: rgba(255, 255, 255, 0.4);
  }
  70% {
    text-shadow: 
      0 0 15px #ffffff,
      0 0 30px #ffffff;
    color: #ffffff;
  }
  85% {
    text-shadow: 
      0 0 40px #ffffff,
      0 0 80px #ffffff,
      0 0 120px #ffffff;
    color: #ffffff;
  }
  100% {
    text-shadow: 
      0 0 10px #ffffff,
      0 0 20px #ffffff,
      0 0 30px #ffffff;
    color: #ffffff;
  }
}

/* Статичное свечение после анимации */
.view-btn.active-view::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%;
  height: 180%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.15) 0%,
    rgba(255, 255, 255, 0.1) 30%,
    transparent 70%
  );
  z-index: -1;
  opacity: 0;
  animation: staticGlow 0.5s ease 0.8s forwards;
}

@keyframes staticGlow {
  to {
    opacity: 1;
  }
}

/* Адаптивность для галереи */
@media (max-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    padding: 0 20px;
  }
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 0 16px;
  }
  
  .gallery-caption {
    padding: 12px;
  }
  
  .g-title {
    font-size: 12px;
  }
  
  .g-sub {
    font-size: 10px;
  }
  
  .view-switcher {
    margin-left: 20px;
    padding: 3px;
  }
  
  .view-btn {
    padding: 5px 12px;
    min-width: 70px;
    font-size: 10px;
  }
  
  .nav a {
    margin-left: 24px;
    font-size: 13px;
  }
  
  #gallery {
    padding: 80px 16px 100px;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 0 12px;
  }
  
  .view-switcher {
    margin-left: 16px;
  }
  
  .nav a {
    margin-left: 16px;
    font-size: 11px;
  }
  
  #gallery {
    padding: 70px 12px 90px;
  }
  
  .footer {
    padding: 6px;
  }
}

/* Fix для активной табы all works при загрузке */
.nav a[data-filter="allworks"].active-filter {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  color: #f0f0f0;
  font-variation-settings: "wdth" 300, "wght" 900;
}

.head {
  width: 148px;
  height: 148px;
  background-image: url('./images/head5.gif');
  background-size: cover;
  position: absolute;
  left: 16px;
  bottom: 4px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.2;
  transition: opacity 0.3s ease-in-out;
  
  /* ДОБАВЬТЕ ЭТИ СТРОКИ: */
  z-index: 1001; /* Выше чем .footer (1000) */
  pointer-events: auto; /* Явное разрешение событий */
}

/* Остальной CSS без изменений */
.head::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('./images/head7.gif');
  background-size: cover;
  opacity: 0;
  mix-blend-mode: screen;
  transform: translate(0, 0);
  pointer-events: none;
}

.head:hover {
  opacity: 1;
  background-image: url('./images/head7.gif');
}

.head:hover::after {
  opacity: 1;
  animation: glitch-fade 0.5s steps(2, end);
}

@keyframes glitch-fade {
  0% {
    opacity: 0;
    clip-path: inset(0 0 40% 0);
    transform: translate(0, 0);
  }
  20% {
    opacity: 1;
    clip-path: inset(30% 0 0 0);
    transform: translate(-2px, 2px);
  }
  40% {
    opacity: 0.6;
    clip-path: inset(10% 0 20% 0);
    transform: translate(20px, -1px);
  }
  60% {
    opacity: 0.1;
    clip-path: inset(0 0 0 0);
    transform: translate(-10px, 1px);
  }
  80% {
    opacity: 0.7;
    clip-path: inset(20% 0 10% 0);
    transform: translate(1px, 0);
  }
  100% {
    opacity: 1;
    clip-path: none;
    transform: translate(0, 0);
  }
}

/* Loader стили */
.loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.loader-content {
  text-align: center;
  color: #fff;
}

.loader-spinner {
 width: 148px;
  height: 148px;
    background-size: cover;
  background-image: url('./images/head5.gif');
 opacity: 0.2;
}

@keyframes loader-spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-text {
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 200, "wght" 600;
  font-size: 14px;
  color: #888;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.loader-progress {
  padding-top: 48px;
  font-family: "Science Gothic", sans-serif;
  font-variation-settings: "wdth" 200, "wght" 900;
  font-size: 28px;
  color: #ffffff;
  opacity: 0.2;
  letter-spacing: 0.05em;
}

/* Улучшение скроллбара для галереи */
.gallery-active::-webkit-scrollbar {
  width: 8px;
}

.gallery-active::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

.gallery-active::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.gallery-active::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Ховер эффекты для элементов галереи */
@media (hover: hover) {
  .gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(0, 255, 249, 0.05), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
  }
  
  .gallery-item:hover::before {
    opacity: 1;
  }
}

/* Анимация затухания для переключения видов */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#gallery {
  animation: fadeIn 0.4s ease;
}

/* Стили для ленивой загрузки */
.lazy-img {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.lazy-img.loaded {
  opacity: 1;
}

/* Убираем pointer-events для контента за футером в галерее */
.gallery-active .gallery-grid {
  padding-bottom: 60px; /* Добавляем отступ для футера */
}

/* Улучшенная masonry сетка для Pinterest-эффекта */
@media (min-width: 768px) {
  .gallery-grid {
    column-count: 3;
    column-gap: 24px;
    display: block;
  }
  
  .gallery-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 24px;
    break-inside: avoid;
  }
}

@media (max-width: 768px) and (min-width: 480px) {
  .gallery-grid {
    column-count: 2;
    column-gap: 16px;
    display: block;
  }
  
  .gallery-item {
    display: inline-block;
    width: 100%;
    margin-bottom: 16px;
    break-inside: avoid;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    column-count: 1;
    display: block;
  }
  
  .gallery-item {
    display: block;
    width: 100%;
    margin-bottom: 12px;
  }
}

/* Исправление для коррекции высоты страницы в режиме слайдов */
body:not(.gallery-active) {
  height: auto;
  min-height: 800vh;
  overflow-y: auto;
}

/* Исправление для футера в режиме галереи */