/**
 * 日历小组件
 *
 * 1x1：跟图标一样大，白底卡
 * 2x2：宽高是 1x1 的两倍加缝，由 JS 的 layout() 直接设 width/height，
 *      这里只给个兜底值，免得布局脚本没跑到时塌成一坨
 */

.app-card--cal {
    display: flex;
    flex-direction: column;
    align-items: center;
    /*
     * 6px —— 跟 .app（站点图标）的 gap、2x2 的通用规则都是 6。
     * 这里以前写 8，加上名字 18 就是 8 + 72 + 18 = 98，超过格子的 96，
     * flex 把方块压成 70.4 —— 跟纪念日那个毛病同源，肉眼差一点点但确实小一圈。
     */
    gap: 6px;
    /* 宽度由 .app-cell 决定，这里别再写 100% —— 会把整行撑开 */
}

.cal-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    /* 1x1 是死尺寸，别被父级 flex 压缩（2x2 那条 flex: 1 特异性更高，不受影响） */
    flex: none;
    width: var(--icon);
    height: var(--icon);
    padding: 0;
    border: 0;
    border-radius: var(--icon-radius);
    background: #fff;
    color: #1f2329;
    cursor: pointer;
    overflow: hidden;
    /* 假期角标绝对定位在这张卡里 */
    position: relative;
    box-shadow: 0 1px 2px rgba(18, 24, 38, .10), 0 6px 16px rgba(18, 24, 38, .08);
    transition: transform .18s cubic-bezier(.2, .7, .3, 1), box-shadow .18s ease;
}

.app-cell:hover .cal-tile {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(18, 24, 38, .12), 0 10px 22px rgba(18, 24, 38, .12);
}

.cal-week {
    font-size: 13px;
    line-height: 1.1;
    font-weight: 600;
    /* 星期几一律红色（跟手机日历的顶栏一致），不再按工作日/周末分色 */
    color: #ef4444;
}

.cal-num {
    font-size: 26px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.cal-lunar {
    font-size: 10px;
    line-height: 1.2;
    color: #8a929c;
    transform: scale(.94);
}

/* ---------- 2×2 ---------- */

/*
 * 宽高别在这里写：.app-cell[data-span="2"] 里已经算死了（2 行 + 行距）。
 * 原来这里写了 height:100%，它的选择器权重不比那边低、又后加载，
 * 会把算死的高度覆盖成 100% —— 而 100% 在自动行高的网格里解析不出来，
 * 结果卡片反而把行撑高（第 3 行被撑到 168px）。
 */

.app-card--cal.is-2x2 .cal-tile {
    flex: 1;
    width: 100%;
    height: auto;
    /* 数字贴着红头，第几天紧跟，农历用 margin-top:auto 压到底，跟 mtab 一致 */
    /*
     * 卡片现在是严格的「两列两行」（224px 上下），比以前的 181 高了 40 多。
     * 原来内容全贴顶、农历用 margin-top:auto 压到底，中间会空出一大块；
     * 改成整组垂直居中，四个元素一起排在卡里。
     */
    justify-content: center;
    gap: 0;
    padding: 42px 8px 12px;
    border-radius: 20px;
    /* 顶上那条红是头部，底下留白给数字 */
    background:
        linear-gradient(#ef4444, #ef4444) top / 100% 38px no-repeat,
        #fff;
    /* 头部文字压在红条里，绝对定位省得挤数字 */
    position: relative;
}

.cal-head {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14.5px;
    font-weight: 600;
    color: #fff;
    letter-spacing: .01em;
}

/* 2x2 有 174×180，44px 的日期在一张卡里显得空，放大到 56 */
.app-card--cal.is-2x2 .cal-num {
    font-size: 56px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -.02em;
    color: #1f2329;
}

.cal-meta {
    margin-top: 11px;
    font-size: 13px;
    line-height: 1.2;
    color: #6b7480;
    font-variant-numeric: tabular-nums;
}

.app-card--cal.is-2x2 .cal-lunar {
    margin-top: 9px;
    font-size: 13.5px;
    color: #8a929c;
    transform: none;
}

/* 深色主题：日历卡本身就是白卡，不改底色，只把投影压深一点 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .cal-tile {
        box-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px rgba(0, 0, 0, .3);
    }
}

/* ---------- 法定假期 / 调休 ---------- */

/*
 * 角标只在「今天确实是法定假日 or 调休上班」时渲染，
 * 平时根本没有这个节点，所以不用考虑怎么藏。
 * 1x1 只有 72px 见方，占布局会挤掉数字，只能绝对定位压角。
 */
.cal-off {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 2;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 4px;
    /* 卡片只有 72px 见方，铺不了整格底色，只能压一个实心角标。
       配色跟月历对齐：休 = 红、班 = 绿 */
    background: #e5484d;
    color: #fff;
    font-size: 9px;
    line-height: 15px;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* 调休上班用灰色，跟「休」的红色分开，扫一眼就知道那天要上班 */
.cal-off.is-work {
    background: #16a34a;
}

/* 2x2 的头部是一条红底，红角标压上去看不见，翻成白底红字 */
.app-card--cal.is-2x2 .cal-off {
    top: 9px;
    right: 10px;
    height: 17px;
    line-height: 17px;
    padding: 0 5px;
    border-radius: 5px;
    font-size: 10px;
    background: rgba(255, 255, 255, .94);
    color: #e5484d;
}

.app-card--cal.is-2x2 .cal-off.is-work {
    color: #16a34a;
}

/* 2x2 底部那行「春节 · 放假」，只在是假期时才出现 */
.cal-holiday {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.2;
    font-weight: 600;
    color: #e5484d;
}

.cal-holiday.is-work {
    color: #16a34a;
}
