/* Text color choice: #111 rather than pure #000 — less harsh on white */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: #ffffff;
  color: #111111;
  font-family: "Times New Roman", Times, serif;
  font-size: 15px;
  line-height: 1.6;
  font-weight: normal;
}

/* ── Header ── */

header {
  padding: 32px 32px 20px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 4em;
}

.header-nav {
  display: flex;
  align-items: baseline;
  gap: 20px;
}

#toggle-grid {
  cursor: pointer;
}

#toggle-grid:hover {
  text-decoration: none;
}

#prev-btn,
#next-btn {
  cursor: pointer;
  text-decoration: underline;
  user-select: none;
}

#prev-btn:hover,
#next-btn:hover,
#toggle-grid:hover {
  opacity: 0.6;
}

/* ── Main content area ── */

main {
  padding: 0 32px 48px;
}

/* ── Carousel ── */

.slide {
  max-width: 900px;
}

/* Image slide */
.slide img {
  display: block;
  max-width: 100%;
  max-height: 600px;
  height: auto;
  width: auto;
}

/* Text slide */
.slide-text-title {
  max-width: 600px;
  font-size: 18px;
  font-style: italic;
  text-transform: uppercase;
  margin-top: 1em;
  margin-bottom: 1.2em;
}

.slide-text {
  max-width: 550px;
  font-size: 16px;
  line-height: 1.6;
}

.slide-text p {
  margin-bottom: 0.4em;
  text-indent: 1.5em;
}

.slide-text p:first-child {
  text-indent: 0;
}

.slide-text p:last-child {
  margin-bottom: 0;
}

.slide-text em {
  font-style: italic;
}

.slide-text img {
  margin: 1em auto;
}

/* ── Caption ── */

.caption {
  margin-top: 1em;
  max-width: 900px;
  font-size: 14px;
  line-height: 1.5;
}

/* caption width follows slide width for text works */
.caption.caption-text {
  max-width: 600px;
}

.caption-title {
  font-style: italic;
}

/* ── Grid view ── */

.grid-view {
  margin-bottom: 40px;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.grid-tile {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grid-tile:hover .tile-inner {
  opacity: 0.8;
}

.tile-inner {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #ffffff;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
  padding: 12px;
}

.tile-caption {
  display: none;
}

.tile-inner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tile-inner.tile-text-inner {
  padding: 24px 12px;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  background: #f0f0f0;
}

.tile-text-title {
  font-style: italic;
  font-size: 18px;
  line-height: 1.4;
  text-transform: uppercase;
  margin-bottom: 0.6em;
  flex-shrink: 0;
}

.tile-text-preview {
  font-size: 15px;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}


/* ── Responsive ── */

@media (max-width: 470px) {
  header {
    padding: 20px 20px 14px;
  }

  .header-nav {
    flex-basis: 100%;
  }

  main {
    padding: 0 20px 36px;
  }

  .slide {
    max-width: 100%;
  }

  .slide-text {
    font-size: 15px;
    max-width: 100%;
  }

  .caption {
    max-width: 100%;
  }

  .caption.caption-text {
    max-width: 100%;
  }

  .grid-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
}
