/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --red: #8b0000;
  --red-bright: #c0392b;
  --dark: #0a0a0a;
  --dark2: #111111;
  --grey: #1a1a1a;
  --text: #c8c8c8;
  --text-dim: #666;
  --accent: #e0e0e0;
}

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--red) var(--dark);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--dark);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  position: relative;
}

/* ===== FILM GRAIN (canvas) ===== */
.grain-canvas {
  position: fixed;
  top: -10px;
  left: -10px;
  width: calc(100vw + 20px);
  height: calc(100vh + 20px);
  image-rendering: pixelated; /* крупное зерно старой плёнки */
  pointer-events: none;
  z-index: 9998;
  mix-blend-mode: overlay;
  will-change: transform;
}

/* ===== STATIC NOISE OVERLAY (broken monitor) ===== */
.static-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9997;
  opacity: 0;
  mix-blend-mode: overlay;
  background: repeating-linear-gradient(
    0deg,
    rgba(255,255,255,0.03) 0px,
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 2px
  );
  animation: static-flicker 0.15s infinite;
}

.static-overlay::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    repeating-linear-gradient(
      90deg,
      rgba(139, 0, 0, 0.02) 0px,
      transparent 1px,
      transparent 3px
    );
}

/* Random static bursts */
.static-burst {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9996;
  opacity: 0;
  background: rgba(255, 255, 255, 0.03);
}

.static-burst.active {
  animation: burst 0.1s ease-out forwards;
}

@keyframes burst {
  0% { opacity: 0.4; }
  100% { opacity: 0; }
}

/* ===== SCANLINES ===== */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9995;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
}

/* ===== VIGNETTE ===== */
.vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9994;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.7) 100%
  );
}

/* ===== GLITCH LINE (horizontal tear) ===== */
.glitch-line {
  position: fixed;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
  z-index: 9993;
  opacity: 0;
}

/* ===== NAV ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.5rem 3rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(to bottom, rgba(10,10,10,0.95), transparent);
  backdrop-filter: blur(2px);
  transition: background 0.3s;
}

.nav:hover {
  background: linear-gradient(to bottom, rgba(10,10,10,0.98), rgba(10,10,10,0.7));
}

.nav-logo {
  font-family: 'Special Elite', cursive;
  font-size: 1.5rem;
  color: var(--red-bright);
  text-decoration: none;
  position: relative;
  letter-spacing: 2px;
}

.nav-logo::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--red-bright);
  transition: width 0.3s;
}

.nav-logo:hover::after {
  width: 100%;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 2rem;
}

.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color 0.3s, text-shadow 0.3s;
  position: relative;
}

.nav-links a:hover {
  color: var(--text);
  text-shadow: 0 0 10px rgba(139, 0, 0, 0.5);
}

/* ===== HERO ===== */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 2rem;
}

/* Animated blood drip background */
.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(139, 0, 0, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 0, 0, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0.8) 0%, var(--dark) 100%);
  z-index: 0;
}

.hero-content {
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero-title {
  margin-bottom: 1.5rem;
}

.title-line {
  display: block;
  font-family: 'Special Elite', cursive;
  font-size: clamp(3rem, 10vw, 8rem);
  color: var(--accent);
  letter-spacing: 8px;
  line-height: 1.1;
  position: relative;
  text-shadow: 
    0 0 20px rgba(0,0,0,0.8),
    2px 2px 0 rgba(139, 0, 0, 0.3);
  animation: title-glitch 8s infinite;
}

.title-last {
  color: var(--red);
  text-shadow: 
    0 0 30px rgba(139, 0, 0, 0.5),
    0 0 60px rgba(139, 0, 0, 0.2),
    2px 2px 0 rgba(0, 0, 0, 0.5);
}

@keyframes title-glitch {
  0%, 95%, 100% { 
    text-shadow: 
      0 0 20px rgba(0,0,0,0.8),
      2px 2px 0 rgba(139, 0, 0, 0.3);
    transform: translate(0);
  }
  96% {
    text-shadow: 
      -2px 0 rgba(139, 0, 0, 0.7),
      2px 0 rgba(0, 139, 0, 0.5),
      0 0 20px rgba(0,0,0,0.8);
    transform: translate(-2px, 1px);
  }
  97% {
    text-shadow: 
      2px 0 rgba(139, 0, 0, 0.7),
      -2px 0 rgba(0, 139, 0, 0.5),
      0 0 20px rgba(0,0,0,0.8);
    transform: translate(2px, -1px);
  }
  98% {
    text-shadow: 
      0 0 20px rgba(0,0,0,0.8),
      2px 2px 0 rgba(139, 0, 0, 0.3);
    transform: translate(0);
  }
}

.hero-subtitle {
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  color: var(--text-dim);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.hero-divider {
  width: 80px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--red), transparent);
  margin: 0 auto 2rem;
  position: relative;
}

.hero-divider::after {
  content: '†';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--red);
  font-size: 1rem;
}

.hero-tagline {
  font-family: 'Special Elite', cursive;
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 6px;
  text-transform: uppercase;
  opacity: 0.6;
}

.hero-scroll {
  position: absolute;
  bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: scroll-bounce 2s infinite;
}

.hero-scroll span {
  font-size: 0.7rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.scroll-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--red), transparent);
}

@keyframes scroll-bounce {
  0%, 100% { transform: translateY(0); opacity: 1; }
  50% { transform: translateY(10px); opacity: 0.5; }
}

/* ===== SECTIONS COMMON ===== */
section {
  padding: 6rem 3rem;
  position: relative;
}

.section-title {
  font-family: 'Special Elite', cursive;
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 3rem;
  letter-spacing: 4px;
}

.title-mark {
  color: var(--red);
  font-size: 0.9rem;
  letter-spacing: 2px;
}

/* ===== GALLERY ===== */
.gallery {
  background: var(--dark2);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: auto;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(30%) contrast(1.1) brightness(0.9);
  transition: filter 0.5s, transform 0.5s;
}

.gallery-item:hover img {
  filter: grayscale(0%) contrast(1.2) brightness(1);
  transform: scale(1.03);
}

/* Glitch overlay on hover */
.gallery-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(139, 0, 0, 0.1) 50%,
    transparent 60%
  );
  z-index: 2;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.gallery-item:hover::before {
  opacity: 1;
  animation: gallery-glitch 0.3s steps(2) 2;
}

@keyframes gallery-glitch {
  0% { transform: translate(0); }
  25% { transform: translate(-3px, 1px); }
  50% { transform: translate(3px, -1px); }
  75% { transform: translate(-1px, 2px); }
  100% { transform: translate(0); }
}

.gallery-item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent 50%);
  display: flex;
  align-items: flex-end;
  padding: 1.5rem;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 3;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.item-number {
  font-family: 'Special Elite', cursive;
  font-size: 2rem;
  color: var(--red);
}

.gallery-item-wide {
  grid-column: span 2;
}

/* ===== ABOUT ===== */
.about {
  background: var(--dark);
}

.about-container {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 3rem;
}

.about-text {
  font-size: 1.05rem;
  line-height: 1.9;
  margin-bottom: 1.5rem;
  color: var(--text);
}

.about-text strong {
  color: var(--red-bright);
  font-weight: 400;
}

.about-text em {
  color: var(--text-dim);
  font-style: italic;
}

.about-skills {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--grey);
}

.about-skills h3 {
  font-family: 'Special Elite', cursive;
  font-size: 1rem;
  color: var(--text-dim);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.about-skills ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.about-skills li {
  padding: 0.4rem 1rem;
  border: 1px solid var(--grey);
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  transition: all 0.3s;
  cursor: default;
}

.about-skills li:hover {
  border-color: var(--red);
  color: var(--text);
  background: rgba(139, 0, 0, 0.1);
  box-shadow: 0 0 15px rgba(139, 0, 0, 0.2);
}

/* ===== CONTACT ===== */
.contact {
  background: var(--dark2);
  text-align: center;
}

.contact-content {
  max-width: 600px;
  margin: 0 auto;
}

.contact-text {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.contact-email {
  display: inline-block;
  font-family: 'Special Elite', cursive;
  font-size: 1.5rem;
  color: var(--red);
  text-decoration: none;
  position: relative;
  transition: color 0.3s, text-shadow 0.3s;
}

.contact-email:hover {
  color: var(--red-bright);
  text-shadow: 0 0 20px rgba(139, 0, 0, 0.5);
}

.contact-email::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s;
}

.contact-email:hover::after {
  transform: scaleX(1);
}

.contact-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 3rem;
}

.contact-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: color 0.3s;
}

.contact-link:hover {
  color: var(--red-bright);
}

/* ===== FOOTER ===== */
.footer {
  padding: 2rem 3rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  background: var(--dark);
}

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.97);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  /* отступы под кнопку закрытия сверху и счётчик снизу */
  padding: 5rem 6rem 5rem;
  cursor: zoom-out;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.lightbox.active {
  opacity: 1;
  pointer-events: all;
  cursor: default;
}

/* Кнопки навигации (стрелки) */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(139, 0, 0, 0.3);
  border: 1px solid rgba(139, 0, 0, 0.5);
  color: var(--text);
  font-size: 2rem;
  width: 60px;
  height: 80px;
  cursor: pointer;
  font-family: 'Special Elite', cursive;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.lightbox-nav:hover {
  background: rgba(139, 0, 0, 0.6);
  box-shadow: 0 0 20px rgba(139, 0, 0, 0.4);
}

.lightbox-nav.lightbox-prev {
  left: 1rem;
}

.lightbox-nav.lightbox-next {
  right: 1rem;
}

/* Спрятать стрелки если фото одно */
.lightbox.single .lightbox-nav {
  display: none;
}

/* Счётчик */
.lightbox-counter {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Special Elite', cursive;
  font-size: 0.9rem;
  color: var(--text-dim);
  letter-spacing: 3px;
  z-index: 10;
}

/* Фигура и подпись */
.lightbox figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  height: 100%;
  max-width: 90vw;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.lightbox img {
  display: block;
  /* сжимается по высоте, уступая место подписи */
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: grayscale(20%) contrast(1.1);
  transition: filter 0.3s;
}

/* Глитч-эффект при смене кадра */
.lightbox img.glitching {
  animation: lightbox-glitch 0.25s steps(3);
}

.lightbox figcaption.lightbox-desc {
  flex: 0 1 auto;
  width: 100%;
  max-width: 600px;
  max-height: 32%;
  overflow-y: auto;
  padding: 0 1rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-dim);
  text-align: center;
  white-space: pre-line;
  overscroll-behavior: contain;
}

/* Тонкий скроллбар подписи */
.lightbox figcaption.lightbox-desc::-webkit-scrollbar {
  width: 4px;
}

.lightbox figcaption.lightbox-desc::-webkit-scrollbar-thumb {
  background: rgba(139, 0, 0, 0.6);
}

@keyframes lightbox-glitch {
  0% { opacity: 1; filter: grayscale(20%) contrast(1.1); }
  20% { opacity: 0.3; filter: grayscale(0%) contrast(2) hue-rotate(180deg); }
  40% { opacity: 0.6; filter: grayscale(10%) contrast(1.5); }
  60% { opacity: 0.2; filter: grayscale(0%) contrast(1.8); }
  80% { opacity: 0.8; filter: grayscale(15%) contrast(1.2); }
  100% { opacity: 1; filter: grayscale(20%) contrast(1.1); }
}

.lightbox-close {
  position: absolute;
  top: 2rem;
  right: 2rem;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  font-family: 'Special Elite', cursive;
  transition: color 0.3s;
  z-index: 10;
  background: none;
  border: none;
  padding: 0.5rem;
}

.lightbox-close:hover {
  color: var(--red);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .nav {
    padding: 1rem 1.5rem;
  }
  
  .nav-links {
    gap: 1rem;
  }
  
  .nav-links a {
    font-size: 0.75rem;
  }
  
  section {
    padding: 4rem 1.5rem;
  }
  
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  
  .gallery-item-wide {
    grid-column: span 1;
  }
  
  .about-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .contact-links {
    flex-direction: column;
    gap: 1rem;
  }

  /* Лайтбокс на узких экранах: меньше отступов, стрелки компактнее */
  .lightbox {
    padding: 4rem 0.5rem 4.5rem;
  }

  .lightbox-nav {
    width: 44px;
    height: 60px;
    font-size: 1.4rem;
  }

  .lightbox-nav.lightbox-prev {
    left: 0.25rem;
  }

  .lightbox-nav.lightbox-next {
    right: 0.25rem;
  }

  .lightbox figcaption.lightbox-desc {
    max-height: 32vh;
    font-size: 0.8rem;
  }

  .lightbox-close {
    top: 1rem;
    right: 1rem;
    font-size: 1.1rem;
  }

  .lightbox-counter {
    bottom: 1.2rem;
  }
}

/* ===== SELECTION ===== */
::selection {
  background: var(--red);
  color: var(--accent);
}

/* ===== CUSTOM SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--dark);
}

::-webkit-scrollbar-thumb {
  background: var(--red);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--red-bright);
}

/* ===== MONITOR FLICKER (нестабильная подсветка) ===== */
.monitor-flicker {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9992;
  opacity: 0;
  background: rgba(255, 255, 255, 0.04);
  transition: opacity 0.04s;
}

.monitor-flicker.on {
  opacity: 1;
  background: rgba(255, 255, 255, 0.06);
}

/* ===== РЯБЬ ПРИ БЫСТРОМ СКРОЛЛЕ ===== */
body.ripple {
  animation: ripple-shift 0.15s steps(3);
}

@keyframes ripple-shift {
  0% { transform: translateX(0); filter: none; }
  20% { transform: translateX(-4px) skewX(0.4deg); filter: hue-rotate(-8deg) contrast(1.2); }
  40% { transform: translateX(3px); filter: brightness(1.15); }
  60% { transform: translateX(-2px) skewX(-0.3deg); }
  80% { transform: translateX(2px); filter: contrast(0.9); }
  100% { transform: translateX(0); filter: none; }
}

/* ===== ВКЛЮЧЕНИЕ СТАРОГО МОНИТОРА ===== */
.monitor-boot {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 99999;
  pointer-events: all;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.8s ease 0.3s;
}

/* Белая линия, которая "разворачивается" в экран */
.monitor-boot::before {
  content: '';
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
  animation: boot-line 0.6s ease-out forwards;
}

@keyframes boot-line {
  0% { transform: scaleX(0) scaleY(3); opacity: 0; }
  40% { transform: scaleX(1) scaleY(3); opacity: 1; }
  70% { transform: scaleX(1) scaleY(3); opacity: 1; }
  100% { transform: scaleX(1) scaleY(600); opacity: 0; }
}

.monitor-boot.done {
  opacity: 0;
  pointer-events: none;
}

/* ===== REVEAL (проявление из помех) ===== */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  filter: blur(6px) contrast(1.5);
  transition: opacity 0.8s, transform 0.8s, filter 0.8s;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0) contrast(1);
}

/* Уменьшаем нагрузку для тех, кто не любит движения */
@media (prefers-reduced-motion: reduce) {
  .grain-canvas,
  .static-overlay,
  .monitor-flicker,
  .glitch-line,
  .monitor-boot {
    display: none;
  }

  body.ripple {
    animation: none;
  }

  .title-line {
    animation: none;
  }

  .reveal {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }
}
