/* Materials page: category grid + gallery + lightbox */

.materials-page .materials__wrap {
  max-width: 1010px;
  margin: 0 auto;
  padding: 40px 20px;
}

.materials-page .materials__title {
  color: #fff;
  font-size: 1.75em;
  margin-bottom: 24px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Category grid – same look as news-block on home */
.materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.materials-grid__item {
  display: block;
  width: 100%;
  height: 216px;
  min-height: 180px;
  border: 2px solid rgba(170, 170, 170, 0.75);
  border-radius: 5px;
  position: relative;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
  background-color: #000;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  opacity: 0.95;
}

.materials-grid__item:hover {
  opacity: 1;
}

.materials-grid__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}

.materials-grid__item .materials-grid__text {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 12px 8px;
  border-radius: 0 0 3px 3px;
}

.materials-grid__item .materials-grid__title {
  font-size: 1.125em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  display: block;
}

/* Gallery view (inside a category) */
.materials-gallery {
  display: none;
}

.materials-gallery.is-open {
  display: block;
}

.materials-gallery__header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.materials-gallery__back {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  background: rgba(170, 170, 170, 0.25);
  border: 2px solid rgba(170, 170, 170, 0.75);
  border-radius: 5px;
  color: #00e1ff;
  text-decoration: none;
  font-size: 0.95em;
}

.materials-gallery__back:hover {
  background: rgba(170, 170, 170, 0.35);
  color: #fff;
}

.materials-gallery__heading {
  color: #fff;
  font-size: 1.25em;
  margin: 0;
}

.materials-gallery__empty {
  color: #8f8f8f;
  padding: 40px 20px;
  margin: 0;
  grid-column: 1 / -1;
}

/* Gallery grid – images only, same card style */
.materials-gallery__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.materials-gallery__cell {
  display: block;
  width: 100%;
  height: 216px;
  min-height: 180px;
  border: 2px solid rgba(170, 170, 170, 0.75);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
  background: #000;
  cursor: pointer;
  opacity: 0.95;
}

.materials-gallery__cell:hover {
  opacity: 1;
}

.materials-gallery__cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 3px;
}

/* Hide main grid when gallery is open */
.materials-page.materials-page--gallery-open .materials-categories {
  display: none;
}

/* Image modal (lightbox) */
.materials-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.materials-modal.is-open {
  display: flex;
}

.materials-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.materials-modal__inner {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 90vh;
  border: 2px solid rgba(170, 170, 170, 0.75);
  border-radius: 5px;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
  background: #000;
}

.materials-modal__inner img {
  display: block;
  max-width: 90vw;
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 3px;
}

.materials-modal__close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border: 2px solid rgba(170, 170, 170, 0.75);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.materials-modal__close:hover {
  background: rgba(80, 80, 80, 0.9);
  color: #00e1ff;
}

/* Responsive */
@media (max-width: 740px) {
  .materials-grid,
  .materials-gallery__grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
  .materials-grid__item,
  .materials-gallery__cell {
    height: 160px;
    min-height: 140px;
  }
}

@media (max-width: 460px) {
  .materials-grid,
  .materials-gallery__grid {
    grid-template-columns: 1fr;
  }
  .materials-grid__item,
  .materials-gallery__cell {
    height: 200px;
    min-height: 180px;
  }
}
