/* ========= Global reset ========= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background:
    linear-gradient(rgba(20, 26, 35, 0.55), rgba(20, 26, 35, 0.55)),
    url("../img/minecraft.jpg") no-repeat center center fixed;
  background-size: cover;
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
  color: white;
  position: relative;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: inherit;
}

.container {
  width: min(1200px, 92%);
  margin: 0 auto;
  padding: 2rem 0 24px;
  text-align: center;
}

/* ========= Horní box ========= */
.infotext,
.page-header {
  padding: 3% 8%;
  background-color: rgba(15, 199, 209, 0.75);
  margin: 1rem 0 3rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 0 8px black;
  text-align: center;
}

.infotext .title,
.page-header h1 {
  font-size: clamp(3rem, 7vw, 5rem);
  color: #a2f4ff;
  text-align: center;
  font-weight: bold;
  margin-bottom: 1rem;
  text-shadow: 0 0 10px black;
  line-height: 1.1;
}

.infotext p,
.page-header .subtitle,
.page-header p {
  color: white;
  font-size: 1.3rem;
  text-shadow: 0 0 10px black;
  text-align: center;
  padding-bottom: 10px;
}

/* ========= Sekce galerie ========= */
.gallery-section {
  margin-top: 34px;
  padding: clamp(18px, 3vw, 28px);
  background-color: rgba(15, 199, 209, 0.45);
  box-shadow: 0 0 8px black;
}

.section-heading {
  margin-bottom: 20px;
  text-align: left;
}

.section-heading h2 {
  font-size: clamp(1.65rem, 4vw, 2.5rem);
  color: #a2f4ff;
  text-shadow: 0 0 10px black;
}

.section-heading p {
  margin-top: 5px;
  color: white;
  line-height: 1.5;
  text-shadow: 0 0 8px black;
}

/*
  Responzivní grid bez rozbití:
  - na velkém PC maximálně 4 karty na řádek
  - 3 zbylé karty vyplní řádek po třetinách
  - 2 zbylé karty vyplní řádek půl na půl
  - 1 zbylá karta je zarovnaná doprostřed
*/
.gallery-grid {
  --gallery-gap: 22px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gallery-gap);
  align-items: start;
}

.gallery-card {
  grid-column: span 3;
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 0 12px black;
  text-align: left;
  width: 100%;
  min-width: 0;
}

/* Poslední neúplný řádek při 4 kartách na řádek */
.gallery-grid > .gallery-card:nth-last-child(1):nth-child(4n + 1) {
  grid-column: 4 / span 6;
}

.gallery-grid > .gallery-card:nth-last-child(2):nth-child(4n + 1),
.gallery-grid > .gallery-card:nth-last-child(1):nth-child(4n + 2) {
  grid-column: span 6;
}

.gallery-grid > .gallery-card:nth-last-child(3):nth-child(4n + 1),
.gallery-grid > .gallery-card:nth-last-child(2):nth-child(4n + 2),
.gallery-grid > .gallery-card:nth-last-child(1):nth-child(4n + 3) {
  grid-column: span 4;
}

.gallery-card:focus-visible {
  outline: 3px solid #a2f4ff;
  outline-offset: 4px;
}

.gallery-card figure {
  background: rgba(15, 199, 209, 0.18);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.gallery-card img {
  display: block;
  width: 100%;
  height: 230px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.25);
  transition: transform 0.25s ease, filter 0.25s ease;
}

.gallery-card:hover img,
.gallery-card:focus-visible img {
  transform: scale(1.06);
  filter: brightness(1.12);
}

.gallery-card figcaption {
  min-height: 92px;
  padding: 14px 15px 16px;
  background-color: rgba(15, 199, 209, 0.75);
  text-shadow: 0 0 8px black;
}

.gallery-card figcaption strong {
  display: block;
  margin-bottom: 5px;
  font-size: 1.05rem;
  color: white;
}

.gallery-card figcaption span {
  display: block;
  color: #eaffff;
  font-size: 0.94rem;
  line-height: 1.35;
}

.back {
  display: inline-block;
  margin-top: 35px;
  padding: 12px 22px;
  background-color: rgba(65, 164, 217, 0.95);
  color: #a6f1fb;
  font-weight: bold;
  text-decoration: none;
  box-shadow: 0 0 1rem black;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.back:hover,
.back:focus-visible {
  background-color: rgba(65, 164, 217, 1);
  transform: translateY(-2px);
}

footer {
  margin-top: 40px;
  color: white;
  text-align: center;
  padding: 3px;
  text-shadow: 0 0 8px black;
}

footer a {
  color: #a2f4ff;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ========= Lightbox ========= */
.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
}

.lightbox.active {
  display: flex;
  animation: fadeIn 0.18s ease;
}

.lightbox-content {
  width: min(1100px, 92vw);
  max-height: 94vh;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.lightbox-img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 68vh;
  margin: 0 auto;
  object-fit: contain;
  box-shadow: 0 0 24px black;
  animation: zoomIn 0.18s ease;
}

.lightbox-img[src=""],
.lightbox-img:not([src]) {
  display: none;
}

.lightbox-info {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(15, 199, 209, 0.75);
  box-shadow: 0 0 8px black;
  text-shadow: 0 0 8px black;
}

.lightbox-title {
  font-size: 1.18rem;
  font-weight: bold;
  color: #a2f4ff;
}

.lightbox-caption {
  margin-top: 4px;
  color: white;
  line-height: 1.45;
}

.lightbox-counter {
  margin-top: 8px;
  font-size: 0.95rem;
  color: #d9fbff;
}

.lightbox-close,
.lightbox-arrow {
  position: absolute;
  border: 0;
  color: white;
  background: rgba(15, 199, 209, 0.35);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.lightbox-close:hover,
.lightbox-arrow:hover,
.lightbox-close:focus-visible,
.lightbox-arrow:focus-visible {
  background: rgba(15, 199, 209, 0.85);
  transform: scale(1.08);
}

.lightbox-close {
  top: 20px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 38px;
  line-height: 42px;
}

.lightbox-arrow {
  top: 50%;
  width: 52px;
  height: 72px;
  border-radius: 12px;
  font-size: 38px;
  transform: translateY(-50%);
}

.lightbox-arrow:hover,
.lightbox-arrow:focus-visible {
  transform: translateY(-50%) scale(1.08);
}

.lightbox-prev {
  left: 24px;
}

.lightbox-next {
  right: 24px;
}

.lightbox.loading .lightbox-content::before {
  content: "Načítám album...";
  display: inline-block;
  align-self: center;
  margin-bottom: 12px;
  padding: 10px 16px;
  background: rgba(15, 199, 209, 0.75);
  box-shadow: 0 0 8px black;
  text-shadow: 0 0 8px black;
}

.lightbox.loading .lightbox-img {
  visibility: hidden;
}

.lightbox-thumbs {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 8px black;
  max-width: 100%;
}

.lightbox-thumbs[hidden] {
  display: none !important;
}

.lightbox-thumb {
  flex: 0 0 92px;
  width: 92px;
  height: 56px;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  background: transparent;
  opacity: 0.62;
  overflow: hidden;
  transform: scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.lightbox-thumb img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover !important;
}

.lightbox-thumb:hover,
.lightbox-thumb:focus-visible,
.lightbox-thumb.active {
  border-color: #a2f4ff;
  opacity: 1;
  transform: scale(1);
}

.lightbox-img.slide-next {
  animation: lightboxSlideNext 0.24s ease;
}

.lightbox-img.slide-prev {
  animation: lightboxSlidePrev 0.24s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes zoomIn {
  from { transform: scale(0.96); opacity: 0.75; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes lightboxSlideNext {
  from { opacity: 0; transform: translateX(28px) scale(0.985); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes lightboxSlidePrev {
  from { opacity: 0; transform: translateX(-28px) scale(0.985); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@media (max-width: 1100px) and (min-width: 701px) {
  .gallery-card {
    grid-column: span 4;
  }

  .gallery-grid > .gallery-card:nth-last-child(1):nth-child(3n + 1) {
    grid-column: 5 / span 4;
  }

  .gallery-grid > .gallery-card:nth-last-child(2):nth-child(3n + 1),
  .gallery-grid > .gallery-card:nth-last-child(1):nth-child(3n + 2) {
    grid-column: span 6;
  }
}

@media (max-width: 820px) and (min-width: 701px) {
  .gallery-card {
    grid-column: span 6;
  }

  .gallery-grid > .gallery-card:nth-last-child(1):nth-child(2n + 1) {
    grid-column: 4 / span 6;
  }
}

@media (width > 500px) {
  .infotext,
  .page-header {
    padding: 3rem 20%;
  }
}

@media (max-width: 700px) {
  .container {
    width: min(100% - 24px, 1200px);
    padding-top: 1rem;
  }

  .infotext,
  .page-header {
    margin: 1rem 0 2rem 0;
    padding: 2rem 1rem;
  }

  .infotext .title,
  .page-header h1 {
    font-size: 3rem;
  }

  .infotext p,
  .page-header .subtitle,
  .page-header p {
    font-size: 1.1rem;
  }

  .gallery-section {
    padding: 18px;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .gallery-grid > .gallery-card,
  .gallery-grid > .gallery-card:nth-last-child(1):nth-child(n),
  .gallery-grid > .gallery-card:nth-last-child(2):nth-child(n),
  .gallery-grid > .gallery-card:nth-last-child(3):nth-child(n) {
    grid-column: 1 / -1;
  }

  .gallery-card img {
    height: 210px;
  }

  .section-heading {
    text-align: center;
  }

  .lightbox {
    padding: 16px;
  }

  .lightbox-content {
    width: 100%;
    max-height: 94vh;
  }

  .lightbox-img {
    max-height: 58vh;
  }

  .lightbox-close {
    top: 12px;
    right: 12px;
    width: 42px;
    height: 42px;
    font-size: 34px;
  }

  .lightbox-arrow {
    top: auto;
    bottom: 20px;
    width: 48px;
    height: 48px;
    font-size: 30px;
    transform: none;
  }

  .lightbox-prev {
    left: 20px;
  }

  .lightbox-next {
    right: 20px;
  }

  .lightbox-arrow:hover,
  .lightbox-arrow:focus-visible {
    transform: scale(1.08);
  }

  .lightbox-thumbs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    -webkit-overflow-scrolling: touch;
  }

  .lightbox-thumb {
    flex: 0 0 76px;
    width: 76px;
    height: 48px;
  }
}
