/* CSS Reset */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after, q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* Original Styles */
@import url(https://fonts.googleapis.com/css?family=Montserrat:500);

:root {
  /* Base font size */
  font-size: 10px;
}

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

body {
  min-height: 100vh;
  background-color: #fafafa;
}

.container {
  max-width: 100rem;
  margin: 0 auto;
  padding: 0 2rem 2rem;
  position: relative; /* For positioning page_top_btn */
}

.heading {
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 4rem;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  padding: 3.5rem 0;
  color: #1a1a1a;
}

.heading span {
  display: block;
}

.gallery {
  display: flex;
  flex-wrap: wrap;
  margin: -1rem -1rem;
}

.gallery-item {
  flex: 1 0 24rem;
  margin: 1rem;
  box-shadow: 0.3rem 0.4rem 0.4rem rgba(0, 0, 0, 0.4);
  overflow: hidden;
  position: relative;
}

.gallery-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease-out;
}

.gallery-image:hover {
  transform: scale(1.15);
}

/* Display alt text in the center of the image */
.gallery-item::after {
  content: attr(data-alt);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 2rem;
  text-align: center;
  text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 10;
}

@supports (display: grid) {
  .gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Fixed 3 columns */
    grid-template-rows: repeat(2, auto); /* Fixed 2 rows */
    grid-auto-flow: row; /* Ensure items fill rows first */
    grid-gap: 2rem;
  }

  .gallery,
  .gallery-item {
    margin: 0;
  }
}

/* Responsive adjustments for smaller screens */
@media screen and (max-width: 600px) {
  .gallery {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); /* 2 columns on small screens */
    grid-gap: 1rem;
  }

  .heading {
    font-size: 2.5rem;
  }

  .gallery-item::after {
    font-size: 1.5rem;
  }

  .page_top_btn {
    bottom: 10px;
    left: 10px;
    width: 40px;
    height: 40px;
  }

  .page_top_btn img {
    width: 100%;
    height: 100%;
  }
}

/* トップへ戻るボタン */
.page_top_btn {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 40px;
  height: 40px;
  z-index: 100;
  text-decoration: none;
  transition: opacity 0.3s;
}

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

/* ホバー時 */
.page_top_btn:hover {
  opacity: 0.8;
}

.content.white {
  height: 500px;
  background-color: #fff;
}

.content.gray {
  height: 500px;
  background-color: #eee;
}

/* ボタン全体（未使用だが保持） */
#page_top {
  width: 100px;
  height: 100px;
  position: fixed;
  right: 10px;
  bottom: 10px;
  background: #e25407;
  opacity: 0.6;
}

/* Font Awesome（未使用だが保持） */
#page_top::before {
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  content: '\f0d8';
  font-size: 50px;
  color: #ffffff;
  position: absolute;
  top: 46%;
  left: 50%;
  translate: -50%;
}

#page_top::after {
  content: 'PAGE TOP';
  font-size: 13px;
  color: #fff;
  position: absolute;
  margin: auto;
  text-align: center;
  width: 100%;
  top: 30%;
  left: 50%;
  translate: -50%;
}