/* =========================================
   日曆元件樣式（calendar.css）
   架構：固定邏輯畫布（500×850px）+ transform:scale()
   所有尺寸使用 px — 在 scale 容器內不受系統字體/縮放影響
   原來的1.0rem = 現在的20px
   ========================================= */

:root {
    --bg-color: hsl(0, 60%, 24%);
    --font-main: 'Noto Serif TC', serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
}

/* body：全畫面背景，不再負責置中（#stage 由 screen_adaptive.js 的 left/top 控制） */
body {
    background-color: var(--bg-color);
    font-family: var(--font-main);
    width: 100%;
    height: 100%;
    overflow: hidden;

    /* 防止瀏覽器縮放影響佈局 */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ★ 覆蓋 screen_adaptive.css 的 #stage 背景，使用日曆主題背景色 */
#stage {
    background: var(--bg-color);
    display: block;
    /* 覆蓋 screen_adaptive.css 的 flex，由子元素自行定位 */
}

/* =========================================
   #calendarCardContainer
   填滿整個 #stage（500×850px）
   ========================================= */
#calendarCardContainer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    perspective: 480px;
    /* 無 width/height transition，避免遊戲中畫面飄移 */
}

/* Card Styling with Dynamic Hue */
.calendarCard {
    position: absolute;
    inset: 0;
    margin: auto;

    /* 卡片是容器的 90%，並居中顯示 */
    width: 90%;
    height: 90%;

    --card-hue: 0;
    background-color: hsl(var(--card-hue), 18%, 72%);

    /* 文字顏色：Same Hue, S 20%, L 20% */
    --main-text-color: hsl(var(--card-hue), 20%, 20%);
    color: var(--main-text-color);

    border-radius: 30px;
    /* 1rem → 16px */
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    /* 0.6rem / 1.8rem → 10px / 29px */
    display: flex;
    padding: 20px 30px;
    /* 1rem 1.5rem → 16px 24px */
    transition: transform 0.1s linear, opacity 0.3s ease;
    cursor: grab;
    will-change: transform;
}

.calendarCard:active {
    cursor: grabbing;
}

/* Layout Columns */
.calendarCol-left,
.calendarCol-right {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 0 4px;
    /* 0.2rem → 3px */
    height: 100%;
}

/* ============ 右欄：上方農曆資訊直排居中，下方宜忌並排 ============ */
.calendarCol-right {
    display: flex;
    flex-direction: column;
    /* 正常垂直排列（不套 writing-mode） */
    align-items: center;
    /* 讓農曆資訊水平居中 */
    justify-content: flex-start;
    font-size: 24px;
    /* 1.2rem → 19px */
    color: var(--main-text-color);
    padding-top: 10px;
    /* 0.5rem → 8px */
    gap: 0;
    overflow: hidden;
}

.lunar-info {
    font-size: 24px;
    /* 1.2rem → 19px */
    writing-mode: vertical-rl;
    /* 農曆資訊本身直排 */
    color: var(--main-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
}

/* Holidays (Right Col) */
.holidays-container {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    writing-mode: vertical-rl;
    flex-shrink: 1;
}

/* 宜忌 Lucky / Unlucky — 右欄底部，宜忌左右並排 */
.lucky-unlucky {
    display: flex;
    flex-direction: row;
    /* 宜、忌左右並排（各自是一條直排欄） */
    gap: 4px;
    /* 0.2rem → 3px */
    margin-top: auto;
    /* 推到欄位底部 */
    padding-bottom: 10px;
    /* 0.5rem → 8px */
    align-items: flex-start;
    justify-content: center;
}

.activity {
    display: flex;
    flex-direction: row;
    /* writing-mode:vertical-rl 下，row = 由上而下，讓圓圈與文字同一直欄 */
    align-items: center;
    gap: 6px;
    /* 0.3rem → 5px */
    writing-mode: vertical-rl;
}

/* 宜忌標籤 */
.activity .label {
    width: 28px;
    /* 1.4rem → 22px */
    height: 28px;
    /* 1.4rem → 22px */
    margin: 0;
    border-radius: 50%;
    background-color: color-mix(in srgb, var(--main-text-color), transparent 60%);
    color: hsl(var(--card-hue), 18%, 72%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    /* 1rem → 16px */
    font-weight: bold;
    flex-shrink: 0;
}

.activity .value {
    font-weight: 500;
    font-size: 22px;
    /* 1.1rem → 18px */
    line-height: 1.0;
    white-space: nowrap;
    writing-mode: vertical-rl;
    letter-spacing: 0.1em;
}

/* ============ 左欄：三個元素直排靠底部 ============ */
.calendarCol-left {
    justify-content: flex-end;
    font-size: 24px;
}

/* 左邊詩名作者名 Metadata Vertical (Left Column) */
.poem-meta-and-logo-left {
    display: flex;
    flex-direction: row;
    writing-mode: vertical-rl;
    gap: 20px;
    /* 1rem → 16px */
    color: var(--main-text-color);
    padding-bottom: 20px;
    /* 1rem → 16px */
}

.poem-title,
.poem-author {
    font-size: 24px;
    opacity: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    writing-mode: vertical-rl;
}

.poem-title {
    font-weight: bold;
}

/* Vertical Text Utilities */
.vertical-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.2em;
}

/* 花月商標 BRAND LOGO */
.brand-logo {
    font-size: 24px;
    writing-mode: vertical-rl;
    font-weight: bold;
    letter-spacing: 10px;
    /* 0.5rem → 8px */
    white-space: nowrap;
}

/* ============ 中欄：主要內容 (包含日期、詩詞) ============ */
.calendarCol-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 0;
    padding: 0 10px;
    /* 0.5rem → 8px */
    position: relative;
    z-index: 2;
    height: 100%;
}

/* 日曆 Date Header */
.date-header {
    text-align: center;
    color: whitesmoke;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.4);
    /* 0.1rem → 2px */
}

.year-month {
    font-size: 40px;
    /* 2.0rem → 32px */
    line-height: 0.8;
    letter-spacing: 3px;
    font-weight: bold;
    padding-top: 16px;
    /* 0.8rem → 13px */
    margin: 0;
}

.day-number {
    font-size: 160px;
    /* 8.0rem → 128px */
    line-height: 1;
    font-weight: bold;
    margin: 0;
}

.weekday {
    font-size: 60px;
    /* 3.0rem → 48px */
    font-weight: bold;
    margin: 0;
}


/* Animation Classes */
.animate-recoil {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.animate-flyout {
    transition: transform 0.8s cubic-bezier(0.5, 0, 1, 0.5), opacity 1.2s ease;
}

/* Poem Section */
.poem-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    /* 0.3rem → 5px */
    width: 100%;
    position: relative;
    overflow: hidden;
    min-height: 160px;
    /* 10rem → 160px */
}

/* 下方詩句 */
.poem-body {
    font-size: 40px;
    /* 2.0rem → 32px */
    font-weight: bold;
    max-height: 400px;
    /* 20rem → 320px */
    line-height: 1.7;
    /* 詩句間距 超過1.7會造成左右欄被拖出去卡片之外 */
    height: 100%;
    padding-top: 20px;
    /* 1.0rem → 16px */
    text-align: center;
    writing-mode: vertical-rl;
    display: flex;
    flex-direction: column;
    align-content: center;
    overflow: hidden;
    transform: scaleX(0.9);
}

.poem-line {
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    max-height: 400px;
    /* 20rem → 320px */
}