/* ========================================
   疾走とラリー 〜男3人、愛媛テニス巡礼記〜
   Novel Documentary Style CSS
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Shippori Mincho', 'Noto Serif JP', 'Yu Mincho', '游明朝', serif;
  line-height: 1.8;
  color: #2d2d2d;
  background-color: #fcfbf9;
}

::selection {
  background-color: rgba(154, 52, 18, 0.1);
  color: #9a3412;
}

/* --- Reading Progress Bar --- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  z-index: 1000;
}

.progress-bar {
  height: 100%;
  background-color: rgba(154, 52, 18, 0.5);
  width: 0%;
  transition: width 0.15s ease;
}

/* --- Cover Page --- */
.cover-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  /* 背景画像設定 */
  background-image: url('../images/cover-tennis-team.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* 背景オーバーレイ（透過効果） */
.cover-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(252, 251, 249, 0.75) 0%,
    rgba(252, 251, 249, 0.85) 30%,
    rgba(252, 251, 249, 0.9) 60%,
    rgba(252, 251, 249, 0.95) 100%
  );
  z-index: 1;
}

.paper-texture {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0.03;
  pointer-events: none;
  background-image: url('https://www.transparenttextures.com/patterns/cream-paper.png');
}

.cover-content {
  z-index: 10;
  max-width: 56rem;
  width: 100%;
  border-top: 4px double #1f2937;
  border-bottom: 4px double #1f2937;
  padding: 4rem 2rem;
  animation: fadeInUp 1s ease-out;
  /* 背景をさらに読みやすく */
  background: rgba(252, 251, 249, 0.6);
  backdrop-filter: blur(2px);
  border-radius: 4px;
}

.document-type {
  font-size: 0.875rem;
  letter-spacing: 0.4em;
  color: #4b5563;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.main-title {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
  line-height: 1.2;
  letter-spacing: 0.1em;
  color: #111827;
  text-shadow: 0 2px 4px rgba(255, 255, 255, 0.8);
}

.subtitle {
  font-size: 1.75rem;
  color: #374151;
  font-weight: 300;
  letter-spacing: 0.2em;
  margin-bottom: 3rem;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.meta-info {
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 0.875rem;
  letter-spacing: 0.2em;
  color: #4b5563;
  font-family: sans-serif;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.scroll-hint {
  position: absolute;
  bottom: 2.5rem;
  animation: bounce 2s infinite;
  color: #6b7280;
  z-index: 10;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.scroll-hint span {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
}

/* --- Main Content --- */
.main-content {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.5rem 8rem;
  font-size: 1.125rem;
  line-height: 2.2;
  letter-spacing: 0.05em;
  text-align: justify;
}

.main-content p {
  margin-bottom: 2rem;
}

.main-content strong {
  font-weight: 700;
  border-bottom: 1px solid #9ca3af;
}

.pink-underline {
  border-bottom-color: #f9a8d4 !important;
}

/* --- Drop Cap --- */
.first-paragraph {
  margin-bottom: 2rem;
}

.drop-cap {
  float: left;
  font-size: 3.5rem;
  margin-right: 0.75rem;
  margin-top: -6px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1;
}

/* --- Chapter Title --- */
.chapter-title {
  margin-top: 6rem;
  margin-bottom: 3rem;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.chapter-title.visible {
  opacity: 1;
  transform: translateY(0);
}

.chapter-number {
  color: rgba(154, 52, 18, 0.6);
  font-size: 0.875rem;
  letter-spacing: 0.2em;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(154, 52, 18, 0.2);
  display: inline-block;
  padding-bottom: 0.5rem;
}

.chapter-main {
  font-size: 2rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 1rem;
  letter-spacing: 0.1em;
  line-height: 1.5;
}

.chapter-subtitle {
  font-size: 1.25rem;
  color: #4b5563;
  font-style: italic;
  font-weight: 300;
}

/* --- Quote / Blockquote --- */
.quote {
  background-color: #fff;
  border-left: 4px solid #9ca3af;
  padding: 0.5rem 0 0.5rem 1.5rem;
  margin: 2rem 0;
  font-style: italic;
  color: #4b5563;
}

/* --- Highlight Text --- */
.highlight-text {
  font-weight: 700;
  color: #1f2937;
  margin: 2rem 0;
}

.centered-highlight {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
  padding: 1rem 0;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  margin: 2rem 0;
}

/* --- Column / Sidebar --- */
.column {
  margin: 3rem auto;
  max-width: 36rem;
  background-color: #f4f1ea;
  border-top: 2px solid rgba(154, 52, 18, 0.1);
  border-bottom: 2px solid rgba(154, 52, 18, 0.1);
  padding: 2rem;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.column-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  color: rgba(154, 52, 18, 0.4);
}

.column-title {
  text-align: center;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 1rem;
  letter-spacing: 0.2em;
  font-size: 0.875rem;
  border-bottom: 1px solid #d1d5db;
  padding-bottom: 0.5rem;
  display: inline-block;
  width: 100%;
}

.column-content {
  color: #374151;
  font-size: 0.9375rem;
  line-height: 1.75;
  text-align: justify;
}

/* --- Pit Crew List --- */
.pit-crew-list {
  list-style: none;
  padding-left: 1rem;
  margin-bottom: 2rem;
  border-left: 2px solid #d1d5db;
}

.pit-crew-list li {
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

/* --- Trust Illustration Chart --- */
.trust-illustration {
  margin: 4rem 0;
  padding: 2rem;
  border: 3px double #d1d5db;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}

.illustration-title {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.125rem;
  color: #1f2937;
  letter-spacing: 0.2em;
}

.chart-container {
  padding: 0 1rem;
  margin-bottom: 1.5rem;
}

.chart-bars {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 8rem;
  padding-bottom: 1px;
  border-bottom: 2px solid #1f2937;
  position: relative;
}

.bar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  width: 25%;
  cursor: pointer;
  position: relative;
}

.bar {
  width: 1rem;
  background-color: #1f2937;
  transition: all 0.7s ease-out;
  opacity: 0.3;
}

.bar-wrapper.active .bar {
  opacity: 1;
}

.bar.negative {
  background-color: #d1d5db;
}

.negative-indicator {
  position: absolute;
  bottom: 0;
  width: 1rem;
  height: 2rem;
  background-color: #d1d5db;
  animation: pulse 2s infinite;
}

.chart-description {
  text-align: center;
  min-height: 100px;
  transition: all 0.5s ease;
  padding: 0 1rem;
}

.desc-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.desc-icon svg {
  width: 24px;
  height: 24px;
}

.desc-phase {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 0.5rem;
}

.desc-text {
  color: #1f2937;
  font-size: 1.125rem;
  line-height: 1.6;
}

.desc-note {
  font-size: 0.875rem;
  color: rgba(153, 27, 27, 0.7);
  margin-top: 0.5rem;
}

.chart-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: #d1d5db;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
}

.dot.active {
  background-color: #1f2937;
}

.dot:hover {
  transform: scale(1.2);
}

/* --- The End --- */
.the-end {
  margin-top: 5rem;
  text-align: center;
  font-size: 0.875rem;
  color: #9ca3af;
  letter-spacing: 0.2em;
}

/* --- Back Cover / Footer --- */
.back-cover {
  padding: 5rem 1.5rem;
  background-color: #111827;
  color: #9ca3af;
  text-align: center;
}

.footer-content {
  margin-bottom: 2rem;
}

.book-icon {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.book-icon svg {
  margin: 0 auto;
}

.based-on {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.credit {
  font-size: 0.875rem;
}

.copyright {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  opacity: 0.5;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
  .main-title {
    font-size: 2.5rem;
  }

  .subtitle {
    font-size: 1.25rem;
    letter-spacing: 0.1em;
  }

  .meta-info {
    flex-direction: column;
    gap: 0.5rem;
  }

  .main-content {
    font-size: 1rem;
    line-height: 2;
    padding: 0 1rem 6rem;
  }

  .chapter-main {
    font-size: 1.5rem;
  }

  .chapter-subtitle {
    font-size: 1rem;
  }

  .trust-illustration {
    padding: 1.5rem;
    margin: 3rem 0;
  }

  .chart-bars {
    height: 6rem;
  }

  .bar {
    width: 0.75rem;
  }

  .negative-indicator {
    width: 0.75rem;
    height: 1.5rem;
  }

  .desc-text {
    font-size: 1rem;
  }
}

@media (min-width: 769px) {
  .main-content {
    line-height: 2.4;
  }
}

/* --- Utility Classes --- */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   Photo Gallery Styles
   ======================================== */

/* --- Photo Button (Fixed Position) --- */
.photo-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background-color: rgba(255, 255, 255, 0.95);
  border: 2px solid #1f2937;
  border-radius: 2rem;
  font-family: 'Shippori Mincho', serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.photo-btn:hover {
  background-color: #1f2937;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.photo-btn svg {
  transition: stroke 0.3s ease;
}

.photo-btn:hover svg {
  stroke: #fff;
}

/* --- Photo Gallery Overlay --- */
.photo-gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background-color: rgba(17, 24, 39, 0.98);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  overflow-y: auto;
}

.photo-gallery-overlay.active {
  opacity: 1;
  visibility: visible;
}

.gallery-container {
  min-height: 100vh;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* --- Gallery Header --- */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gallery-title {
  font-family: 'Shippori Mincho', serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.1em;
}

.gallery-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
}

.gallery-close:hover {
  background-color: #fff;
  border-color: #fff;
  color: #1f2937;
}

.gallery-close:hover svg {
  stroke: #1f2937;
}

/* --- Gallery Grid --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  animation: fadeInUp 0.5s ease;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 0.5rem;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.05);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.gallery-item:hover img,
.gallery-item:hover video {
  transform: scale(1.08);
}

/* --- Video Items --- */
.gallery-item-video {
  position: relative;
}

.gallery-item-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.gallery-video-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  pointer-events: none;
}

.gallery-item-video:hover .gallery-video-icon {
  background: rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%) scale(1.1);
}

.gallery-video-icon svg {
  margin-left: 4px;
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: flex-end;
  padding: 1rem;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-caption {
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

/* --- Gallery Footer --- */
.gallery-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

#photo-count {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
  letter-spacing: 0.1em;
}

/* --- Lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background-color: rgba(0, 0, 0, 0.98);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.lightbox-close:hover {
  opacity: 1;
  transform: scale(1.1);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: all 0.3s ease;
}

.lightbox-nav:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
  left: 1rem;
}

.lightbox-next {
  right: 1rem;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}

#lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 0.25rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
  color: #fff;
  font-size: 1rem;
  margin-top: 1rem;
  font-family: 'Shippori Mincho', serif;
}

.lightbox-counter {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* --- Empty State --- */
.gallery-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: rgba(255, 255, 255, 0.5);
}

.gallery-empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.gallery-empty-text {
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}

.gallery-empty-sub {
  font-size: 0.875rem;
  opacity: 0.7;
}

/* --- Responsive for Gallery --- */
@media (max-width: 768px) {
  .photo-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
  }

  .photo-btn span {
    display: none;
  }

  .photo-btn svg {
    width: 18px;
    height: 18px;
  }

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

  .gallery-title {
    font-size: 1.25rem;
  }

  .lightbox-nav {
    width: 44px;
    height: 44px;
  }

  .lightbox-prev {
    left: 0.5rem;
  }

  .lightbox-next {
    right: 0.5rem;
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}
