/* =========================================================
   contest.css : フォトコンテスト専用スタイル
   2025-11 更新版（この版を基準に運用）
========================================================= */

/* 固定ヘッダー回避（このテンプレ専用） */
.contest-main {
  margin-top: min(calc(170 / 1440 * 100vw), 170px);
}

/* 中身ラッパー */
.contest-archive {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
  font-family: "Noto Sans JP", sans-serif;
}

/* =========================================================
   アーカイブヘッダー（独立カード風）
========================================================= */

.archive-header {
  text-align: center;
  margin: 0 0 2.4rem;
}

/* contest アーカイブ内のヘッダーを固定させず、カード風に */
.contest-archive > .archive-header {
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  z-index: auto !important;

  max-width: 980px;
  margin: 0 auto 5rem; /* 下を少し広めに */
  padding: 1.8rem 2rem 2rem;
  background-color: #ffffff;
  border-radius: 12px;
  border: 1px solid #eee;
  box-shadow: 0 4px 16px rgba(0,0,0,0.03);
}

.archive-title {
  font-size: 2.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.archive-description {
  color: #555;
  font-size: 1.6rem;
  line-height: 1.9;
  margin-bottom: 0.8rem;
}

/* 絞り込みUI */
.contest-filters {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  margin-bottom: 0;
}
.contest-filters select {
  padding: 0.6rem 1.2rem;
  font-size: 1.8rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #fff;
  cursor: pointer;
}

/* =========================================================
   受賞作品セクション
========================================================= */

.contest-featured {
  margin-top: 1.2rem;      /* 絞り込みカードからの間を少し広げる */
  margin-bottom: 5rem;    /* 下方向もほんのり余裕を持たせる */
}

.section-title {
  font-size: 2.4rem;       /* アーカイブタイトルと並ぶ存在感 */
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;     /* 見出し下もしっかりスペース */
}

/* スマホ時は少しだけ抑える */
@media (max-width: 599.98px) {
  .section-title {
    font-size: 2.0rem;
    margin-bottom: 1.6rem;
  }
}


/* =========================================================
   Masonry 基本
========================================================= */

.masonry {
  position: relative;
}
.masonry-sizer {
  width: 33.3333%;
}
.masonry-item {
  float: left;
  margin-bottom: 16px;
  box-sizing: border-box;
}

/* カード共通 */
.masonry-link {
  display: block;
  position: relative;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  background: #fff;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  overflow: hidden; /* 画像ズームをカード内にトリミング */
}


/* 通常カード用：画像ラッパー（ズーム領域） */
.masonry-thumb {
  position: relative;
  overflow: hidden;
  border-radius: 8px 8px 0 0;
}

/* 画像はトリミングしない（通常状態） */
.masonry-img,
.contest-feature-thumb img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.4s ease;
  transform-origin: center center;
}

/* hover：画像だけ1.1倍ズーム（テキスト非干渉） */
.masonry-link:hover .masonry-img,
.masonry-link:hover .contest-feature-thumb img {
  transform: scale(1.1);
}

/* テキストは常に前面 */
.masonry-link h3,
.masonry-link p {
  position: relative;
  z-index: 2;
  background: #fff;
}

/* =========================================================
   通常カードテキスト
========================================================= */

.entry-title {
  font-size: 1.6rem;
  font-weight: 600;
  padding: 0.75rem;
}

.entry-author {
  font-size: 1.4rem;
  color: #777;
  padding: 0 0.75rem 0.75rem;
}

/* =========================================================
   Feature（最優秀賞 / 優秀賞）カード
   - 3カラム全幅
   - 内部 画像2:テキスト1
========================================================= */

.masonry-item--feature {
  width: 100%;
}

/* ワイドカード本体 */
.contest-feature-card {
  display: flex;
  align-items: stretch;
  gap: 0;
}

/* 画像側：2/3 */
.contest-feature-thumb {
  flex: 0 0 66.666%;
  overflow: hidden;
}

/* テキスト側：1/3 */
.contest-feature-body {
  flex: 0 0 33.333%;
  padding: 1.2rem 1.6rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;  /* 縦方向中央寄せ */
  align-items: center;      /* 横方向中央寄せ */
  text-align: center;       /* テキスト中央揃え */
}

.contest-feature-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
}

.contest-feature-text {
  font-size: 1.6rem;
  color: #555;
  line-height: 1.9;
  margin: 0;
}

.contest-feature-author {
  font-size: 1.4rem;
  color: #666;
  margin: 0 0 0.4rem;
}

/* アクセントカラー → 他と同じ色に統一 */
.masonry-item--feature-grand .contest-feature-title,
.masonry-item--feature-excellent .contest-feature-title {
  color: inherit;
}

/* =========================================================
   Pagination
========================================================= */

.pagination {
  clear: both;
  text-align: center;
  margin: 2rem 0;
}
.pagination a,
.pagination span {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  margin: 0 0.2rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1.4rem;
  text-decoration: none;
  color: #333;
}
.pagination .current {
  background: #333;
  color: #fff;
  border-color: #333;
}

/* =========================================================
   Responsive Masonry Columns
========================================================= */

/* PC：4カラム */
@media (min-width: 1024px) {
  .contest-featured .masonry-sizer,
  .contest-grid .masonry-sizer {
    width: calc((100% - 48px) / 4);
  }

  .contest-featured .masonry-item:not(.masonry-item--feature),
  .contest-grid .masonry-item:not(.masonry-item--feature) {
    width: calc((100% - 48px) / 4);
  }

  /* feature（最優秀賞／優秀賞）は全幅維持 */
  .contest-featured .masonry-item.masonry-item--feature,
  .contest-grid .masonry-item.masonry-item--feature {
    width: 100%;
  }

  /* ★ Masonry：最優秀賞／優秀賞だけ 2カラム分を使用 */
  .contest-grid .masonry-item.masonry-item--span2 {
    /* 4カラム中 2列 + ガター1本分 */
    width: calc(((100% - 48px) / 4) * 2 + 16px);
  }
}


/* タブレット：2カラム */
@media (min-width: 600px) and (max-width: 1023.98px) {
  .contest-featured .masonry-sizer,
  .contest-featured .masonry-item,
  .contest-grid .masonry-sizer,
  .contest-grid .masonry-item {
    width: calc((100% - 16px) / 2);
  }

  .contest-feature-card {
    flex-direction: row;
  }
  .contest-feature-thumb {
    flex: 0 0 60%;
  }
  .contest-feature-body {
    flex: 0 0 40%;
  }

  /* ★ 最優秀賞／優秀賞（featureカード）はタブレットでも1カラム全幅にする */
  .contest-featured .masonry-item.masonry-item--feature {
    width: 100%;
  }

  /* ★ Masonry：2カラム時は span2 を全幅扱い */
  .contest-grid .masonry-item.masonry-item--span2 {
    width: 100%;
  }
}

/* スマホ：2カラム */
@media (max-width: 599.98px) {
  .contest-featured .masonry-sizer,
  .contest-featured .masonry-item:not(.masonry-item--feature),
  .contest-grid .masonry-sizer,
  .contest-grid .masonry-item:not(.masonry-item--feature) {
    width: calc((100% - 16px) / 2);
  }

  /* feature（最優秀賞／優秀賞）は全幅維持 */
  .contest-featured .masonry-item.masonry-item--feature,
  .contest-grid .masonry-item.masonry-item--feature {
    width: 100%;
  }

  .contest-feature-card {
    flex-direction: column;
  }

  .contest-feature-thumb,
  .contest-feature-body {
    flex: 0 0 auto;
    width: 100%;
  }

  .contest-feature-body {
    padding: 0.9rem 1rem 1.2rem;
  }

  /* ★ 優秀賞カードのみ、画像→テキストの順に反転 */
  .masonry-item--feature-excellent .contest-feature-card {
    flex-direction: column-reverse;
  }

  .archive-title {
    font-size: 2.1rem;
  }

  .section-title {
    font-size: 1.8rem;
  }

  .contest-feature-title {
    font-size: 1.6rem;
  }

  .entry-title {
    font-size: 1.5rem;
  }

  /* その他の受賞作・応募作：SP時だけ少しコンパクトに */
  .contest-featured .masonry-item:not(.masonry-item--feature) .masonry-link,
  .contest-grid .masonry-item:not(.masonry-item--feature) .masonry-link {
    max-width: 92%;
    margin: 0 auto 12px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.10);
  }

  .contest-featured .masonry-item:not(.masonry-item--feature) .entry-title,
  .contest-grid .masonry-item:not(.masonry-item--feature) .entry-title {
    font-size: 1.4rem;
  }

  /* ★ Masonry：SPも span2 は実質2カラム分＝全幅 */
  .contest-grid .masonry-item.masonry-item--span2 {
    width: 100%;
  }

}


/* =========================================================
   モーダル（拡大表示）
========================================================= */

.contest-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.contest-modal.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.contest-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.contest-modal.is-active .contest-modal__overlay {
  opacity: 1;
}
.contest-modal__content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  padding: 1rem;
  box-sizing: border-box;
  z-index: 1;
  display: flex;
  flex-direction: column;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.contest-modal.is-active .contest-modal__content {
  opacity: 1;
  transform: translateY(0);
}

/* ===============================
   モーダル閉じるボタン（ポップ・浮遊感あり）
================================= */
.contest-modal__content {
  position: relative; /* ボタンの絶対位置の基準を固定 */
}

.contest-modal__close {
  position: absolute;
  top: -1.5rem;
  right: -1.5rem;
  width: 4.8rem;
  height: 4.8rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 2.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease, transform 0.25s ease;
  z-index: 10; /* 念のため前面に */
}

/* hover：ふわっと拡大＋軽く回転 */
.contest-modal__close:hover {
  background: #fff;
  transform: scale(1.08) rotate(5deg);
}

.contest-modal__figure {
  margin: 0;
  text-align: center;
}
.contest-modal__figure img {
  max-width: 100%;
  max-height: 85vh;
  height: auto;
  width: auto;
  display: inline-block;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.contest-modal.is-loading .contest-modal__figure img {
  opacity: 0;
}
.contest-modal__figure figcaption {
  margin-top: 0.5rem;
  font-size: 1.4rem;
  color: #333;
}
body.contest-modal-open {
  overflow: hidden;
}
