/* ==========================================================================
   CARDS — карточки проектов / ресурс-паков (glassmorphism)
   ========================================================================== */
.projects-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 24px; margin-bottom: 80px;
}
@media (max-width: 980px) { .projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .projects-grid { grid-template-columns: 1fr; } }

.project-card {
  position: relative;
  background: linear-gradient(180deg, var(--glass-strong), var(--glass));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .3s var(--ease), border-color .3s ease, box-shadow .3s ease;
}
/* тонкая анимированная неоновая обводка, включается по hover */
.project-card::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad-neon);
  background-size: 220% auto;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .3s ease, background-position .8s ease;
  pointer-events: none;
  z-index: 2;
}
.project-card:hover {
  transform: translateY(-8px);
  border-color: transparent;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4), 0 0 40px rgba(139, 102, 255, 0.18);
}
.project-card:hover::before {
  opacity: 1;
  background-position: 100% center;
}

.project-image {
  width: 100%; height: 180px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, #1c1533 0%, #2a1a52 50%, #10091f 100%);
}
#resources .project-image,
#resources .row-image { height: auto; aspect-ratio: 16 / 9; }
#grid-resources.edition-java .project-image,
#grid-resources.edition-java .row-image { aspect-ratio: 1920 / 1009; }
.project-image::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(183, 148, 255, 0.4) 0%, transparent 8%),
    radial-gradient(circle at 75% 25%, rgba(255,255,255,0.5) 0%, transparent 2%),
    radial-gradient(circle at 60% 60%, rgba(91, 124, 255, 0.35) 0%, transparent 12%),
    radial-gradient(circle at 30% 70%, rgba(139, 92, 246, 0.5) 0%, transparent 10%);
}
/* лёгкий градиент-затемнение снизу для читаемости, если картинка светлая */
.project-image::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(6,6,10,0.35) 100%);
  pointer-events: none;
}
.project-image svg { position: absolute; bottom: 0; width: 100%; height: 70%; }
.project-image .card-cover {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  transition: transform .4s var(--ease);
}
.project-image:hover .card-cover { transform: scale(1.06); }

.project-body { padding: 20px 22px 22px; flex: 1; display: flex; flex-direction: column; }
.project-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.project-desc { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin-bottom: 8px; flex: 1; }

.project-desc.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-desc.clamp.expanded {
  -webkit-line-clamp: unset;
  display: block;
}

.desc-toggle {
  align-self: flex-start;
  background: transparent;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  padding: 2px 6px;
  margin: 0 0 12px -6px;
  font-size: 16px;
  line-height: 1;
  font-family: inherit;
  transition: color .2s ease, transform .25s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.desc-toggle:hover { color: #fff; }
.desc-toggle .chev { display: inline-block; transition: transform .25s ease; }
.desc-toggle.expanded .chev { transform: rotate(180deg); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tag {
  padding: 4px 12px; border: 1px solid var(--glass-border);
  border-radius: 999px; font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
  color: var(--text-dim); background: var(--glass);
}
.tag.tag-danger {
  color: #ff9a9a;
  background: rgba(220, 70, 70, 0.14);
  border-color: rgba(255, 100, 100, 0.4);
}

/* ===== СЧЁТЧИК В УГЛУ ===== */
.resources-counter {
  position: absolute;
  top: 110px;
  right: 40px;
  z-index: 2;
  padding: 8px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--glass-border);
  color: var(--accent-2);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--glow-violet);
}
@media (max-width: 640px) {
  .resources-counter { top: 100px; right: 16px; font-size: 12px; padding: 6px 12px; }
}

/* 4 и 5 колонок */
.projects-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.projects-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .projects-grid.cols-5 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 980px) { .projects-grid.cols-4, .projects-grid.cols-5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .projects-grid.cols-4, .projects-grid.cols-5 { grid-template-columns: 1fr; } }

#resources .container:has(#grid-resources.cols-4) { max-width: 1500px; }
#resources .container:has(#grid-resources.cols-5) { max-width: 1800px; }
#projects .container:has(#grid-projects.cols-4) { max-width: 1500px; }
#projects .container:has(#grid-projects.cols-5) { max-width: 1800px; }

/* режим "список" */
.projects-grid.list-view { display: flex; flex-direction: column; gap: 12px; }
.project-row {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 20px;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.project-row:hover {
  border-color: var(--glass-border-hover);
  transform: translateX(6px);
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.15);
}
.row-image {
  width: 140px; aspect-ratio: 16 / 9; flex-shrink: 0;
  border-radius: 10px; overflow: hidden; position: relative;
  background: linear-gradient(180deg, #1c1533 0%, #2a1a52 50%, #10091f 100%);
}
.row-image .card-cover {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  cursor: zoom-in;
}
.row-info {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.row-title {
  flex: 1; font-size: 16px; font-weight: 600; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 720px) { .row-image { width: 96px; } }
@media (max-width: 520px) {
  .row-info { flex-direction: column; align-items: flex-start; gap: 10px; }
  .row-title { white-space: normal; font-size: 15px; width: 100%; }
  .row-actions { flex-wrap: wrap; width: 100%; }
}

.simple-grid .project-body { padding: 18px 22px 22px; }
.simple-grid .project-title { margin-bottom: 16px; }

/* ===== ГАЛЕРЕЯ НА КАРТОЧКЕ ===== */
.gallery { position: absolute; inset: 0; overflow: hidden; }
.gallery-track { display: flex; width: 100%; height: 100%; transition: transform .4s var(--ease); }
.gallery-slide { flex: 0 0 100%; width: 100%; height: 100%; position: relative; }
.gallery-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(10, 10, 15, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; z-index: 2;
  transition: opacity .2s ease, background .2s ease;
}
.gallery:hover .gallery-arrow { opacity: 1; }
.gallery-arrow:hover { background: rgba(139, 92, 246, 0.85); }
.gallery-prev { left: 8px; }
.gallery-next { right: 8px; }
.gallery-dots {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 2;
}
.gallery-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.gallery-dot.active { background: #fff; transform: scale(1.35); }
@media (hover: none) { .gallery-arrow { opacity: 0.85; } }

/* на телефонах стрелки были слишком крупные и загораживали превью —
   делаем их компактнее, прозрачнее и прижимаем ближе к краю */
@media (max-width: 720px) {
  .gallery-arrow {
    width: 22px;
    height: 22px;
    font-size: 13px;
    background: rgba(10, 10, 15, 0.4);
    opacity: 0.6;
  }
  .gallery-prev { left: 6px; }
  .gallery-next { right: 6px; }
  .gallery-dots { bottom: 6px; gap: 4px; }
  .gallery-dot { width: 5px; height: 5px; }
}
