/* =====================================================
   部活動 試合日程カレンダー
   calendar.css
   ===================================================== */

/* ── リセット ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── カラー変数 ── */
:root {
  --bg:        #ffffff;
  --bg2:       #f7f8fa;
  --bg3:       #eef0f4;
  --text:      #1a1d23;
  --text2:     #5a6070;
  --border:    #dde0e8;
  --today-bg:  #eaf3fb;
  --today-num: #185FA5;
  --radius:    8px;
  --font:      'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── ラッパー ── */
.cal-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

/* ── ヘッダー（ナビゲーション） ── */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cal-nav button {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  transition: background 0.15s;
}

.cal-nav button:hover {
  background: var(--bg3);
}

.cal-nav button.today-btn {
  background: #185FA5;
  color: #fff;
  border-color: #185FA5;
}

.cal-nav button.today-btn:hover {
  background: #0C447C;
}

.cal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  min-width: 9em;
  text-align: center;
}

/* ── 凡例 ── */
.cal-legend {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  font-size: 12px;
  color: var(--text2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── ビュー切替 ── */
.view-switch {
  display: flex;
  gap: 4px;
}

.view-switch button {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text2);
  font-family: var(--font);
}

.view-switch button.active {
  background: #185FA5;
  color: #fff;
  border-color: #185FA5;
}

/* ── カレンダーグリッド ── */
.cal-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.cal-dow-cell {
  text-align: center;
  padding: 7px 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.05em;
}

.cal-dow-cell:first-child { color: #c0392b; }
.cal-dow-cell:last-child  { color: #2980b9; }

.cal-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-cell {
  min-height: 90px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px;
  background: var(--bg);
  transition: background 0.1s;
}

.cal-cell:nth-child(7n) {
  border-right: none;
}

.cal-cell.other-month {
  background: var(--bg2);
  opacity: 0.6;
}

.cal-cell.today {
  background: var(--today-bg);
}

.day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 50%;
  margin-bottom: 2px;
}

.cal-cell.today .day-num {
  background: var(--today-num);
  color: #fff;
}

.cal-cell:nth-child(7n+1) .day-num { color: #c0392b; }
.cal-cell:nth-child(7n)   .day-num { color: #2980b9; }
.cal-cell.today           .day-num { color: #fff !important; }

/* ── イベントバー ── */
.event-bar {
  display: block;
  font-size: 10.5px;
  border-radius: 3px;
  padding: 1px 5px;
  margin-bottom: 2px;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.5;
  transition: opacity 0.15s;
}

.event-bar:hover {
  opacity: 0.82;
}

.event-more {
  font-size: 10px;
  color: var(--text2);
  padding-left: 4px;
  cursor: pointer;
}

.event-more:hover {
  color: var(--today-num);
}

/* ── リストビュー ── */
.list-view         { display: none; }
.list-view.show    { display: block; }
.cal-grid-view.hide { display: none; }

.list-month-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  padding: 0.75rem 0 0.4rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s;
}

.list-item:hover {
  background: var(--bg2);
}

.list-date-col {
  min-width: 70px;
  text-align: center;
  flex-shrink: 0;
}

.list-date-day {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.list-date-dow {
  font-size: 11px;
  color: var(--text2);
}

.list-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}

.list-info  { flex: 1; min-width: 0; }

.list-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.list-meta {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}

.list-link {
  font-size: 12px;
  color: var(--today-num);
  margin-top: 3px;
  text-decoration: none;
}

.list-link:hover {
  text-decoration: underline;
}

.no-events {
  text-align: center;
  padding: 2rem;
  color: var(--text2);
  font-size: 13px;
}

/* ── モーダル ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--bg);
  border-radius: 12px;
  padding: 1.75rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  position: relative;
  animation: modalIn 0.18s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-category {
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 8px;
  color: #fff;
  display: inline-block;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  line-height: 1.45;
}

.modal-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--text2);
}

.modal-row svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--bg2);
}

.modal-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  background: #185FA5;
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}

.modal-link-btn:hover {
  background: #0C447C;
}

.modal-link-btn.hide {
  display: none;
}

/* ── ローディング・エラー ── */
.status-msg {
  text-align: center;
  padding: 2.5rem;
  color: var(--text2);
  font-size: 13px;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: #185FA5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── レスポンシブ ── */
@media (max-width: 600px) {
  .cal-cell    { min-height: 54px; }
  .event-bar   { font-size: 9px; }
  .cal-title   { font-size: 15px; }
  .list-date-day { font-size: 18px; }
}
