.projects-section,
.project-detail-section {
  width: 100%;
  max-width: 100%;
  position: relative;
  z-index: 2;
}

section.project-images {
  display: block;
  width: 100%;
  padding: 3rem 0;
  margin: 0;
  box-sizing: border-box;
}

.projects-page-head,
.project-detail-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  max-width: 100%;
  margin-bottom: 2rem;
}

.gallery-header {
  text-align: center;
  max-width: 100%;
  margin: 0 auto 2.25rem;
}

.gallery-header .badge,
.detail-category {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.gallery-header h1,
.detail-title {
  margin-bottom: 1.5rem;
  color: var(--text);
  font-size: 3.25rem;
  line-height: 1.2;
  font-weight: 800;
}

.gallery-header h1 span {
  color: var(--primary);
}

.detail-lead {
  margin: 0 auto;
  max-width: 760px;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.7;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  align-items: stretch;
  width: 100%;
}

.project-card {
  --project-accent: var(--primary);
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  isolation: isolate;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--project-accent);
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.24);
}

.slider-container {
  position: relative;
  width: 100%;
  height: 260px;
  min-height: 260px;
  max-height: 260px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.slider-images {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.35s ease;
}

.slider-img {
  display: block;
  width: 100%;
  min-width: 100%;
  height: 100%;
  max-height: 260px;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  z-index: 3;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.slider-container:hover .slider-btn {
  opacity: 1;
}

.slider-btn:hover {
  background: var(--project-accent);
  border-color: var(--project-accent);
}

.slider-btn.prev {
  left: 0.75rem;
}

.slider-btn.next {
  right: 0.75rem;
}

.slider-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.8rem;
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  z-index: 3;
}

.dot {
  width: 14px;
  height: 4px;
  border: none;
  border-radius: 999px;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.35);
  transition: all 0.2s ease;
}

.dot.active {
  width: 28px;
  background: var(--project-accent);
}

.card-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.2rem 1.2rem 1.25rem;
  background: var(--bg-secondary);
  flex: 1;
}

.card-category {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.card-title {
  margin: 0;
  color: var(--text);
  font-size: 1.22rem;
  line-height: 1.2;
  font-weight: 700;
}

.card-description {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-actions,
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: auto;
  padding-top: 0.4rem;
}

.btn-details,
.btn-secondary,
.back-link {
  min-height: 42px;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  transition: all 0.2s ease;
}

.btn-details {
  background: var(--project-accent);
  border: 1px solid var(--project-accent);
  color: #fff;
}

.btn-details:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  color: #0F2A47;
}

.btn-secondary,
.back-link {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover,
.back-link:hover {
  border-color: var(--project-accent);
  color: var(--project-accent);
}

.projects-empty {
  grid-column: 1 / -1;
  padding: 1.5rem;
  border-radius: 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
}

.project-detail-head {
  margin-bottom: 1.5rem;
}

.back-link {
  margin-bottom: 1rem;
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  width: 100%;
}

.detail-gallery-item {
  width: 100%;
  height: 320px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.detail-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.detail-description {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1.8;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 10, 0.88);
  backdrop-filter: blur(10px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-inner {
  position: relative;
  width: auto;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-img {
  display: block;
  max-width: 92vw;
  max-height: 86vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  background: #000;
}

.close-modal,
.modal-arrow {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: all 0.2s ease;
}

.close-modal:hover,
.modal-arrow:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.close-modal {
  top: -0.75rem;
  right: -0.75rem;
  font-size: 1.3rem;
}

.modal-arrow {
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
}

.modal-arrow.prev {
  left: -3.25rem;
}

.modal-arrow.next {
  right: -3.25rem;
}

.hero-grid {
  text-align: left;
}

@media (max-width: 1280px) {
  .projects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .projects-section,
  .project-detail-section {
    padding: 1rem 0 2rem;
  }

  .projects-grid,
  .detail-gallery {
    grid-template-columns: 1fr;
  }

  .slider-container {
    height: 220px;
    min-height: 220px;
    max-height: 220px;
  }

  .slider-img {
    max-height: 220px;
  }

  .card-actions,
  .detail-actions {
    flex-direction: column;
  }

  .btn-details,
  .btn-secondary {
    width: 100%;
  }

  .detail-gallery-item {
    height: 240px;
  }

  .modal-inner {
    max-width: 96vw;
    max-height: 96vh;
  }

  .modal-img {
    max-width: 96vw;
    max-height: 78vh;
  }

  .modal-arrow.prev {
    left: 0.5rem;
  }

  .modal-arrow.next {
    right: 0.5rem;
  }

  .close-modal {
    top: 0.5rem;
    right: 0.5rem;
  }

  .hero h1 {
    font-size: 2.25rem;
  }

  .hero-inner-container {
    padding: 0 1.5rem;
  }

  .gallery-header h1 {
    font-size: 2.75rem;
  }

  .gallery-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
  }

  .hero-description {
    white-space: normal;
  }
}

/* ===== НЕОНОВЫЙ КУРСОР-СЛЕД ===== */
.projects-grid {
  position: relative;
}

/* Само пятно */
.cursor-glow {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(
          circle at center,
          var(--project-accent, var(--primary)) 0%,
          rgba(63, 185, 80, 0.4) 15%,
          rgba(88, 166, 255, 0.1) 35%,
          transparent 70%
  );
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  mix-blend-mode: screen;
  filter: blur(20px);
}

.cursor-glow.active {
  opacity: 1;
}

/* При наведении на карточку — усиление */
.project-card:hover ~ .cursor-glow,
.project-card:hover .cursor-glow {
  /* Селектор не сработает, поэтому управляем через JS */
}

/* Второй слой — более резкое пятно ближе к курсору */
.cursor-dot {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--project-accent, var(--primary));
  box-shadow: 0 0 20px var(--project-accent, var(--primary)),
  0 0 60px var(--project-accent, var(--primary)),
  0 0 100px var(--primary-glow);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cursor-dot.active {
  opacity: 1;
}

/* Линии сканирования — горизонтальная + вертикальная */
.scan-lines {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.scan-lines.active {
  opacity: 0.15;
}

.scan-line-h,
.scan-line-v {
  position: absolute;
  background: var(--project-accent, var(--primary));
  box-shadow: 0 0 8px var(--project-accent, var(--primary));
}

.scan-line-h {
  left: 0;
  width: 100%;
  height: 1px;
  opacity: 0.5;
}

.scan-line-v {
  top: 0;
  height: 100%;
  width: 1px;
  opacity: 0.5;
}

/* ===== МАТРИЧНЫЙ ДОЖДЬ ===== */
.matrix-rain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 260px; /* Совпадает с высотой слайдера */
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  border-radius: 20px 20px 0 0;
}

.project-card:hover .matrix-rain {
  opacity: 1;
}

/* На мобильных — меньше высота */
@media (max-width: 768px) {
  .matrix-rain {
    height: 220px;
  }
}
