/* index.css (page-specific) */

/* メインコンテナ */
.container {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* 中身は前面 */
.container>* {
  position: relative;
  z-index: 1;
}

/* スキャンライン */
@keyframes scanMove {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 0 120px;
  }
}

.container::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;

  background-image: repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, 0.03),
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px,
      transparent 6px);

  opacity: 0.35;
  animation: scanMove 12s linear infinite;
}

/* ヘッダー */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo {
  font-size: 14px;
}

.nav a {
  margin-right: 16px;
  color: #ffffff;
  text-decoration: none;
}

.create-btn {
  padding: 8px 12px;
  border: 3px solid #ffffff;
  background: #1976d2;
  color: #ffffff;
  text-decoration: none;
  box-shadow: 4px 4px 0 #000;
}

/* メイン */
.main {
  padding: 24px;
  background: #13294b;
}

.main h1 {
  font-size: 18px;
  margin-bottom: 24px;
}

/* 直近イベント枠の画像 */
.next-event img {
  display: block;
  margin-top: 8px;
  max-width: 220px;
  max-height: 140px;
  width: 100%;
  height: auto;
  object-fit: cover;
  border: 2px solid var(--ui-0);
}

/* カード */
.card {
  border: 4px solid var(--ui-0);
  background: rgba(0, 0, 0, 0.88);
  padding: 16px;
  box-shadow: 0 0 0 2px rgba(var(--ui-rgb), 0.45), 0 0 12px rgba(var(--ui-rgb), 0.18);
}

.card h2 {
  font-size: 14px;
  margin-top: 0;
}

/* トップレイアウト */
.top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.right-column {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 20px;
}

/* カレンダー */
.calendar {
  margin-top: 40px;
  padding: 20px;
  border: 4px solid var(--ui-0);
  background: var(--bg-1);
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#monthLabel {
  font-size: 18px;
  letter-spacing: 0.08em;
}

.calendar-week,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

/* 曜日セルだけ */
.calendar-week .day {
  text-align: center;
  font-size: 10px;
  color: var(--ui-0);
}

.date-cell {
  min-height: 80px;
  border: 2px solid var(--ui-0);
  padding: 4px;
  font-size: 10px;
  background: #000;
  overflow-y: auto;
  cursor: pointer;
}

.date-num {
  font-size: 14px;
  letter-spacing: 0.1em;
}

.hidden-day {
  visibility: hidden;
  height: 0;
  padding: 0;
}

/* イベント表示 */
.event-title {
  font-size: 9px;
  margin-top: 2px;
  padding-left: 6px;
  border-left: 4px solid transparent;
  border-left-color: var(--tag-color, transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* フォーム系（indexにある分だけ） */
label {
  font-size: 12px;
  margin-bottom: 8px;
  display: block;
}

input,
textarea {
  width: 100%;
  padding: 10px;
  background: #000;
  border: 3px solid var(--ui-0);
  font-family: "PixelMplus", monospace;
}

input:focus,
textarea:focus {
  border-color: #fff;
}

button {
  font-family: "PixelMplus", monospace;
  padding: 10px 14px;
  background: #1976d2;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
}

button:active {
  box-shadow: 1px 1px 0 #000;
  transform: translate(3px, 3px);
}

/* フッター */
.footer {
  padding: 6px 12px;
  font-size: 10px;
  text-align: center;
  color: #aaa;
  background: #111;
  border-top: 1px solid #333;
  font-family: "PixelMplus", monospace;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.rule-warning {
  color: yellow;
}

.rule-title,
.main h1,
.card h2 {
  color: #ffffff;
}

/* =========================
   ポップアップ（全画面固定 + 中央表示）
========================= */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  padding: 24px;
  background: rgba(0, 0, 0, 0.65);

  align-items: flex-start;
  justify-content: center;
}

.popup-overlay.open {
  display: flex;
}

.popup {
  width: min(560px, calc(100% - 24px));
  margin: 80px auto;
  background: #000;
  border: 4px solid var(--ui-0);
  padding: 12px;
  box-shadow: 6px 6px 0 #000;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#eventPopupTitle {
  font-size: 12px;
  margin: 0;
}

#eventPopupList {
  display: grid;
  gap: 8px;
}

.event-list-item {
  padding: 10px;
  border: 2px solid var(--ui-0);
  background: var(--bg-1);
  cursor: pointer;
}

.event-list-item:hover {
  background: #13294b;
}

#nextEventImage {
  display: block;
  margin-top: 10px;
  max-width: 240px;
  max-height: 160px;
  width: 100%;
  height: auto;
  object-fit: cover;
  border: 2px solid var(--ui-0);
}

/* eventdetail.css or style.css */
#detailImage {
  max-width: 100%;
  max-height: 400px;

  width: auto;
  height: auto;

  object-fit: contain;
  /* ← 全体を収める */
  display: block;
  margin: 16px auto;
  border-radius: 8px;
}

#detailImage {
  background: #f3f3f3;
}

/* =========================
   カレンダー：タグ色反映
   JSが --tag-color を設定する前提
========================= */

/* カレンダーセル内のイベント表示 */
.event-title {
  position: relative;
  padding-left: 10px;
  /* 色バー分の余白 */
  margin-top: 4px;
  line-height: 1.2;
}

/* 左の色バー（タグ色） */
.event-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 4px;
  background: var(--tag-color, transparent);
  border-radius: 2px;
}

/* ポップアップ一覧側も同じ色バー */
.event-list-item {
  position: relative;
  padding-left: 10px;
  margin: 6px 0;
  cursor: pointer;
}

.event-list-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 4px;
  background: var(--tag-color, transparent);
  border-radius: 2px;
}

/* カレンダー：複数タグの色ドット */
.event-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.event-title .event-text {
  flex: 1;
  min-width: 0;
  /* 折り返し/省略の崩れ防止 */
}

.tag-dots {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0
}

.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot-color, transparent);
  border: 1px solid rgba(255, 255, 255, .35)
}

.event-title {
  display: flex;
  align-items: center;
  gap: 6px
}

.event-text {
  flex: 1;
  min-width: 0
}

.event-list-item {
  display: flex;
  align-items: center;
  gap: 6px
}

.tag-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 14px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  margin-left: 2px;
}

/* =========================
   Mobile minimal patch (append-only)
   既存デザインを壊さず、スマホでの崩れを抑える
========================= */
@media (max-width: 640px) {

  /* コンテナ余白を少し詰める（中央寄せは維持） */
  .container {
    padding: 12px;
    /* 既存24pxから上書き */
  }

  /* ヘッダー：横並びを維持しつつ、折り返し許可 */
  .header {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* ナビ：横幅が足りない時に折り返し */
  .nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav a {
    margin-right: 0;
    /* 既存の右マージンを無効化してgapに寄せる */
  }

  /* 作成ボタン：スマホで押しやすい見た目（サイズのみ） */
  .create-btn {
    padding: 10px 12px;
  }

  /* 上段2カラム → 1カラム（ここが崩れの最大要因になりがち） */
  .top-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* カレンダー：左右の余白を圧縮し、横幅に収める */
  .calendar {
    padding: 12px;
  }

  /* 月ラベル：横幅が狭いときの見切れ対策 */
  #monthLabel {
    font-size: 16px;
    /* 既存18pxから少しだけ */
    letter-spacing: 0.04em;
  }

  /* 前後ボタン：タップしやすさ（サイズのみ） */
  #prev,
  #next {
    min-width: 44px;
    min-height: 44px;
  }

  /* 日付セル：縦が伸びすぎないように最小高さを少し下げる */
  .date-cell {
    min-height: 64px;
    /* 既存80pxから上書き */
    font-size: 10px;
    /* 現状維持に近い */
  }

  /* ポップアップ：スマホで画面外に飛ばないようにする */
  .popup-overlay {
    padding: 12px;
    /* 既存24pxから上書き */
    align-items: center;
    /* 上寄せ→中央寄せ（画面外を避ける） */
  }

  .popup {
    margin: 0 auto;
    /* 既存80px auto を上書き */
    width: 100%;
    /* 画面幅に合わせる */
    max-height: 80vh;
    /* 画面からはみ出したら中をスクロール */
    overflow: auto;
  }
}

/* さらに小さい端末（例: 375px以下）だけ微調整 */
@media (max-width: 380px) {
  .logo {
    font-size: 12px;
  }

  #monthLabel {
    font-size: 15px;
  }

  .event-title {
    font-size: 8px;
    /* 既存9pxから1段だけ */
  }
}