/* 基本スタイル */
/* ヘッダー */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    max-width: 1152px;
    margin-left: auto;
    margin-right: auto;
}

#calendar-title {
    font-size: 2.25rem;
    letter-spacing: 2px;
}

.aside--select--wrapper {
    width: auto;
    position: relative;
}

/* 月選択 */
#month-selector {
    font-size: 1rem;
    padding: 5px 40px 5px 16px;
}

/* カレンダーコンテナ (CSS Grid) */
#calendar-container {
    display: grid;

    /* ★ 修正: repeat(6, auto) を削除 */
    grid-template-rows: auto;
    /* 曜日ヘッダー(1行目)の高さはauto */

    /* ★ 追加: 2行目以降(日付セル)の行の高さをここで指定 */
    /* (min-height: 80px と同じ効果) */
    grid-auto-rows: minmax(80px, auto);

    /* (以下は変更なし) */
    grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid #ccc;
    border-left: 1px solid #ccc;
    max-width: 1152px;
    margin: 0 auto;
}

/* 曜日ヘッダー */
.day-header {
    text-align: center;
    padding: 4px 0;
    font-weight: bold;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}

.day-header.sunday {
    color: #e60012;
}

.day-header.saturday {
    color: #004098;
}

/* 日付セル */
.date-cell {
    padding: 8px;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    background-color: #fff;
    /* ★ 修正: 週の「最小の高さ」をここで定義 (80px〜100px程度) */
    min-height: 120px;
    box-sizing: border-box;
    /* 崩れ防止 */
}

/* 他の月の日付セル */
/* .date-cell.empty {
    background-color: #f7f7f7;
} */

/* 日付番号 */
.date-number {
    font-size: 1.1em;
    font-weight: bold;
    /* ★ z-index や position があれば削除 ★ */
}

/* 日付セル内の単発イベントコンテナ (z-index追加) */
.date-cell.sunday .date-number {
    color: #e60012;
}

.date-cell.saturday .date-number {
    color: #004098;
}

/* 休館日 */
.date-cell .closed-day {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

.date-cell.cell-closed {
    background-color: #F6F6F6;
    /* 薄いグレー */
}

/* --- イベント表示 --- */

/* 1. 単発イベント (セル内) */
.single-event {
    display: block;
    font-size: 0.8em;
    /* ★ 修正: マージンを元に戻す (帯がある場合はJSで上書き) */
    margin-top: 5px;
    color: var(--color-orange);
    text-decoration: none;
}

.single-event:hover {
    text-decoration: underline;
}

/* 2. 日またぎイベント (帯) */
.event-band {
    display: block;
    /* ★ z-index: 1; を削除 ★ */

    /* ★ 修正の核心: Grid行全体への引き伸ばしを止め、上端揃えにする ★ */
    align-self: start;

    /* (他は変更なし) */
    margin-right: 2px;
    padding: 0 8px;
    /* 上下padding 0 */
    line-height: 1.6;
    /* 行の高さで高さを確保 */
    font-size: 0.8em;
    color: #fff;
    /* border-radius: 4px; */
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.event-band:hover {
    opacity: 0.8;
}

/* 帯が2本目以降で、タイトルが不要な場合のスタイル */
.event-band.no-title {
    /* background-color: transparent !important; */
    /* 色を透明に */
    /* 高さを維持するために不可視のテキストは残すが、見た目上は消す */
    color: transparent;
}

/* イベントタイプ別の色 (画像参考) */
.event-band.type-exhibition {
    background-color: var(--color-green);
    /* 緑 */
    /* margin-top: 2.5em; */
}

.event-band.type-workshop {
    background-color: var(--color-blue);
    /* 青 */
    /* margin-top: 4.3em;  */
}

.event-band.type-dummy {
    background-color: #ffd900;
    /* 黄 */
    color: #333;
    /* margin-top: 2.5em; */
}

/* --- タブレット以下のレスポンシブ対応 (1行横スクロール) --- */
@media (max-width: 767.98px) {

    .calendar-container--wrapper {
        overflow-x: auto;
        overflow-y: hidden;
    }

    .calendar-header {
        max-width: 100%;
    }

    #calendar-container {
        /* JS(4-A)が grid-template-columns, grid-template-rows, min-width を設定 */
        display: grid;
        overflow-x: auto;
        overflow-y: hidden;
        
        /* 枠線 (JS(4-B)が設定する border-left/top を上書き) */
        border-top: 1px solid #ccc !important;
        border-left: 1px solid #ccc !important;
        border-bottom: 1px solid #ccc !important;
        
        /* JS(4-B)が設定する grid-auto-rows を上書き */
        grid-auto-rows: unset !important;
    }

    /* 曜日ヘッダーを非表示 */
    .day-header {
        display: none;
    }

    .date-cell {
        /* JS(4-A)が grid-row/col を設定 */
        
        /* ★ 古いアジェンダビュースタイル(display:flex 等)を上書き */
        display: block; 
        
        /* ★ 重なり順のコンテキスト */
        position: relative; 
        z-index: 1; /* 帯(2)より下 */
        
        /* セルの最小高さとスタイル */
        min-height: 160px; 
        padding: 8px;
        border: 0;
        border-right: 1px solid #ccc; /* 縦の区切り線 */
        background-color: #fff !important; 
        box-sizing: border-box; /* 崩れ防止 */
        
        /* ★ JSのインラインスタイルを妨害する !important を削除 */
        /* grid-row: auto !important; */
        /* grid-column: auto !important; */
    }

    /* 月外の空セル (JS(4-A)では描画されない) */
    .date-cell.empty {
        display: none;
    }

    .date-number {
        /* ★ 重なり順 */
        position: relative;
        z-index: 3; /* 帯(2)より手前 */
        
        /* 古いスタイルをリセット */
        width: auto;
        padding-top: 0;
    }
    
    .date-cell .events-container {
        /* ★ 重なり順 */
        position: relative;
        z-index: 3; /* 帯(2)より手前 */
        
        /* 古いスタイルをリセット */
        flex-grow: 0;
        
        /* margin-top は JS(7)が設定 */
    }

    .event-band {
        /* ★ 重なり順 */
        z-index: 2; /* セル(1)と文字(3)の間 */

        /* ★ デスクトップ(global)の align-self: start を継承 */
        align-self: start;
    }

    /* 繰り返しタイトル帯: 左端のマージンを除去して連続して見えるようにする */
    .event-band.repeat-title {
        margin-left: 0;
    }
    
    /* 単発イベント・休館日のマージン (変更なし) */
    .single-event,
    .date-cell .closed-day {
        margin-top: 5px;
    }
    .single-event:first-child,
    .date-cell .closed-day:first-child {
        margin-top: 5px;
    }
    
    /* モバイルでの休館日 背景色 (変更なし) */
    .date-cell.cell-closed {
        background-color: #f5f5f5 !important;
    }
}