/* =========================================================
   Webで地学（吉冨Lab.） / Main Stylesheet
   ========================================================= */


/* =========================================================
   1. RESET / BASE
   ========================================================= */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: auto;
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Helvetica Neue",
    "Noto Sans JP",
    sans-serif;
  background: #000;
}


/* =========================================================
   2. HEADER
   ========================================================= */

header {
  position: relative;
  z-index: 1000;

  width: 100%;
  height: 80px;

  background: rgba(65, 105, 225, 0.96);
  color: white;

  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(15px);
}

.header-inner {
  width: 100%;
  height: 100%;
  padding: 0 4vw;

  display: flex;
  align-items: center;
  justify-content: space-between;
}


/* --- Logo --- */

.logo a {
  color: white;
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}


/* --- Main navigation --- */

.main-nav {
  height: 100%;

  display: flex;
  align-items: center;
  gap: 5px;
}

.main-nav > a,
.nav-item > a {
  height: 100%;
  padding: 0 clamp(12px, 1.5vw, 25px);

  display: flex;
  align-items: center;

  color: white;
  text-decoration: none;
  font-size: clamp(14px, 1.2vw, 17px);

  transition: background 0.3s ease;
}

.main-nav > a:hover,
.nav-item:hover > a {
  background: rgba(255, 255, 255, 0.15);
}

.arrow {
  margin-left: 7px;
  font-size: 10px;
}


/* =========================================================
   3. MEGA MENU
   ========================================================= */

.nav-item {
  position: static;
  height: 100%;
}

.mega-menu {
  position: absolute;
  top: 80px;
  left: 0;

  z-index: 1500;

  width: 100%;
  padding: 30px 6vw;

  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 30px;

  background: rgba(65, 105, 225, 0.98);
  backdrop-filter: blur(20px);

  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.18);

  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);

  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0.25s ease;
}

.nav-item:hover .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}


/* --- Mega menu headings --- */

.mega-column h3 {
  margin: 0 0 8px;
  padding-bottom: 7px;

  color: white;
  font-size: 18px;

  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}


/* --- First-level items --- */

.mega-item {
  position: relative;
}

.mega-item > a {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 5px 8px;

  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 14px;

  border-radius: 6px;

  transition:
    background 0.2s ease,
    padding-left 0.2s ease;
}

.mega-item:hover > a {
  padding-left: 14px;
  background: rgba(255, 255, 255, 0.15);
}


/* --- First-level arrow --- */

.mega-item > a span {
  font-size: 20px;
  line-height: 1;
  opacity: 0.7;

  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.mega-item:hover > a span {
  transform: translateX(4px);
  opacity: 1;
}


/* =========================================================
   4. SUB MENU
   ========================================================= */

.sub-menu {
  position: absolute;
  top: 0;
  left: calc(100% + 10px);

  z-index: 2000;

  min-width: 220px;
  padding: 4px;

  /* Opaque background so items underneath do not show through. */
  background: #284bb4;

  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);

  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px);

  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s ease;
}


/* Show submenu on desktop hover. */

.mega-item:hover .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}


/* Rightmost column: open submenu toward the left. */

.right-column .sub-menu {
  left: auto;
  right: calc(100% + 10px);
  transform: translateX(10px);
}

.right-column .mega-item:hover .sub-menu {
  transform: translateX(0);
}


/* --- Submenu links --- */

.sub-menu a {
  display: block;

  padding: 3px 8px;

  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.6;

  border-radius: 5px;

  transition:
    background 0.2s ease,
    padding-left 0.2s ease;
}

.sub-menu a:hover {
  padding-left: 16px;
  color: white;
  background: rgba(255, 255, 255, 0.15);
}


/* =========================================================
   5. HERO
   ========================================================= */

.hero {
  position: relative;

  width: 100%;
  height: calc(100vh - 80px);
  min-height: 0;

  overflow: hidden;
}


/* --- Hero image --- */

.hero img {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: cover;
  object-position: center;

  transform: scale(1.02);
}


/* --- Dark overlay --- */

.hero::after {
  content: "";

  position: absolute;
  inset: 0;
  z-index: 1;

  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.10),
    rgba(0, 0, 0, 0.45)
  );

  pointer-events: none;
}


/* --- Hero text --- */

.hero-text {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;

  width: 90%;

  transform: translate(-50%, -50%);

  color: white;
  text-align: center;

  text-shadow: 0 3px 15px rgba(0, 0, 0, 0.65);
}

.hero-text h1 {
  margin: 0 0 20px;

  font-size: clamp(36px, 7vw, 100px);
  line-height: 1.1;
  font-weight: 700;
}

.hero-text p {
  margin: 0;

  font-size: clamp(14px, 2vw, 22px);
  line-height: 1.8;
}


/* =========================================================
   6. UPDATE HISTORY BUTTON
   ========================================================= */

.history-button {
  padding: 8px 16px;

  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;

  background: rgba(255, 255, 255, 0.12);
  color: white;

  cursor: pointer;
  font-size: 14px;
}

.history-button:hover {
  background: rgba(255, 255, 255, 0.25);
}


/* =========================================================
   7. UPDATE HISTORY MODAL
   ========================================================= */

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;

  display: none;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.history-modal.show {
  display: flex;
}


/* --- Modal window --- */

.history-window {
  width: min(600px, 100%);
  max-height: 80vh;

  overflow: hidden;

  background: white;
  border-radius: 12px;

  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);

  animation: historyOpen 0.2s ease;
}


/* --- Modal header --- */

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 16px 20px;

  background: #4169E1;
  color: white;
}

.history-header h2 {
  margin: 0;
  font-size: 20px;
}


/* --- Close button --- */

.history-close {
  border: none;
  background: transparent;
  color: white;

  font-size: 30px;
  line-height: 1;

  cursor: pointer;
}


/* --- History content --- */

.history-content {
  max-height: calc(80vh - 70px);
  padding: 20px;

  overflow-y: auto;
}


/* --- History item --- */

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid #ddd;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item time {
  display: block;

  margin-bottom: 4px;

  color: #4169E1;
  font-size: 13px;
  font-weight: 700;
}

.history-item p {
  margin: 0;

  color: #333;
  font-size: 14px;
  line-height: 1.6;
}


/* --- Modal animation --- */

@keyframes historyOpen {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}


/* =========================================================
   8. TABLET
   ========================================================= */

@media (max-width: 1000px) {

  .header-inner {
    padding: 0 20px;
  }

  .main-nav > a,
  .nav-item > a {
    padding: 0 10px;
  }

  .mega-menu {
    padding: 25px 4vw;
    gap: 20px;
  }

}


/* =========================================================
   9. SMARTPHONE
   ========================================================= */

@media (max-width: 768px) {

  body {
    overflow: auto;
  }


  /* --- Scrollable mega menu --- */

  .mega-menu {
    max-height: calc(100vh - 70px);

    overflow-x: hidden;
    overflow-y: auto;

    -webkit-overflow-scrolling: touch;
  }


  /* --- One-column mega menu --- */

  .mega-column {
    width: 100%;
    margin-bottom: 15px;
  }

  .mega-column h3 {
    margin-bottom: 5px;
  }


  /* --- Always show submenus on smartphones --- */

  .sub-menu {
    position: static;

    width: auto;
    min-width: 0;

    margin: 2px 0 8px 12px;

    opacity: 1;
    visibility: visible;
    max-height: none;

    overflow: visible;
    transform: none;

    background: #284bb4;
    box-shadow: none;
  }

  .mega-item:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    max-height: none;
    transform: none;
  }


  /* Right-column desktop positioning is unnecessary on mobile. */

  .right-column .sub-menu {
    left: auto;
    right: auto;
    transform: none;
  }

  .right-column .mega-item:hover .sub-menu {
    transform: none;
  }


  /* --- Update history modal --- */

  .history-modal {
    padding: 12px;
  }

  .history-window {
    width: 100%;
    max-height: 85vh;
    border-radius: 10px;
  }

  .history-content {
    max-height: calc(85vh - 65px);
  }

}


/* =========================================================
   10. VERY SMALL SCREEN
   ========================================================= */

@media (max-width: 450px) {

  .mega-menu {
    grid-template-columns: 1fr;
  }

  .hero {
    height: calc(100vh - 120px);
  }

}
