/* =========================================
   基礎排版與容器設定
   ========================================= */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f7;
    padding: 20px;
    margin: 0;
}

.calendar-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    overflow: hidden;
}

/* =========================================
   頂部導覽列 (月份切換)
   ========================================= */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background-color: #fafafa;
    border-bottom: 1px solid #eaeaea;
}

.calendar-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #1a1a1a;
}

.nav-btn {
    text-decoration: none;
    color: #B50838; /* 聖公會深紅色 */
    font-weight: bold;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: #fce8ec;
}

/* =========================================
   日曆網格系統
   ========================================= */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid #eaeaea;
    border-left: 1px solid #eaeaea;
}

.calendar-weekday {
    text-align: center;
    padding: 12px 10px;
    font-weight: bold;
    font-size: 0.95rem;
    color: #555;
    background: #f9f9f9;
    border-right: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
}

.calendar-day {
    min-height: 110px;
    padding: 8px 10px;
    border-right: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s;
    background-color: #fff; /* 預設背景色 */
}

.empty-day {
    background-color: #f5f5f5;
}

/* =========================================
   文字與排版層次 (支援顏色繼承)
   ========================================= */
.day-number {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 6px;
    color: inherit; /* 繼承背景設定的文字顏色 */
}

.liturgy-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
    flex-grow: 1;
    color: inherit;
}

.liturgy-rank {
    font-size: 0.7rem;
    color: inherit;
    opacity: 0.8; /* 80% 透明度弱化副標題 */
    line-height: 1.2;
}

/* =========================================
   紀念項目樣式
   ========================================= */
.liturgy-commemorations {
    margin-top: 6px;
    padding-top: 6px;
}

.comm-item {
    font-size: 0.7rem; /* 與禮儀等級大小一致 */
    color: inherit; 
    opacity: 0.85; /* 85% 透明度 */
    line-height: 1.2;
    margin-bottom: 2px;
}

.comm-item::before {
    content: "• ";
    opacity: 0.6;
}

/* =========================================
   禮儀顏色標示 (全背景覆蓋與文字顏色適配)
   ========================================= */

/* 紫色 (深底白字) */
.color-purple { 
    background-color: #6c2c8f; 
    color: #ffffff; 
}
.color-purple:hover { background-color: #5a2478; }
.color-purple .liturgy-commemorations { border-top: 1px dotted rgba(255, 255, 255, 0.4); }

/* 白色/金色 (淺底深字) */
.color-white { 
    background-color: #fdf6d2; 
    color: #222222; 
}
.color-white:hover { background-color: #f2e9bc; }
.color-white .liturgy-commemorations { border-top: 1px dotted rgba(0, 0, 0, 0.2); }

/* 紅色 (深底白字) */
.color-red { 
    background-color: #c92a2a; 
    color: #ffffff; 
}
.color-red:hover { background-color: #a82323; }
.color-red .liturgy-commemorations { border-top: 1px dotted rgba(255, 255, 255, 0.4); }

/* 綠色 (深底白字) */
.color-green { 
    background-color: #2b8a3e; 
    color: #ffffff; 
}
.color-green:hover { background-color: #237032; }
.color-green .liturgy-commemorations { border-top: 1px dotted rgba(255, 255, 255, 0.4); }

/* 黑色 (深底白字) */
.color-black { 
    background-color: #333333; 
    color: #ffffff; 
}
.color-black:hover { background-color: #222222; }
.color-black .liturgy-commemorations { border-top: 1px dotted rgba(255, 255, 255, 0.4); }

/* 確保普通日子的 hover 效果，避免破壞畫面 */
.calendar-day:not([class*="color-"]):hover {
    background-color: #fcfcfc;
}

/* =========================================
   行動裝置響應式設計
   ========================================= */
@media (max-width: 768px) {
    .calendar-container {
        border-radius: 0;
    }
    .calendar-header {
        padding: 15px;
    }
    .calendar-day {
        min-height: 85px;
        padding: 6px;
    }
    .liturgy-name {
        font-size: 0.75rem;
    }
    .liturgy-rank {
        display: none; /* 手機版隱藏括號等級，保持乾淨 */
    }
}

/* 粉紅色 / 玫瑰色 (深底白字：用於大齋第四主日、降臨第三主日) */
.color-pink { 
    background-color: #d1758f; /* 傳統祭披玫瑰色 */
    color: #ffffff; 
}
.color-pink:hover { background-color: #bd657d; }
.color-pink .liturgy-commemorations { border-top: 1px dotted rgba(255, 255, 255, 0.4); }