/* =========================================================
 *  基础
 *  color-scheme: only light —— 防止手机浏览器「强制深色模式」
 *  把粉色背景反色成暗红（那样黑字就看不见了）
 * ========================================================= */
:root {
    color-scheme: only light;
}

/* 统一盒模型：手机上 #text / #clock-box 带左右内边距，
   用 content-box 时宽度会撑出屏幕，长句子就被切掉了 */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #ffc0cb;
    font-family: '微软雅黑', 'Microsoft YaHei', 'PingFang SC', '宋体', sans-serif;
    color: #000;
    -webkit-tap-highlight-color: transparent;
}

/* 铺满整屏的粉色底：手机页内容比屏幕短时，
   浏览器会在文档结束后露出自己的深色底，这一层把它盖住 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: #ffc0cb;
    z-index: -1;
    pointer-events: none;
}

/* =========================================================
 *  电脑端：整块 1100x680 按窗口缩放，占窗口约 80%
 * ========================================================= */
body {
    overflow: hidden;
}

#viewport {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#stage {
    position: relative;
    width: 1100px;
    height: 680px;
    transform-origin: center center;
}

#canvas-box {
    position: absolute;
    inset: 0;
}

#tree-bg {
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    z-index: 1;
}

#canvas {
    position: relative;
    z-index: 2;
    display: block;
    width: 1100px;
    height: 680px;
}

/* ---------- 情书文字 ---------- */
#text {
    position: absolute;
    left: 60px;
    top: 20px;
    width: 470px;
    z-index: 3;
    pointer-events: none;
}

#code {
    display: none;
    font-size: 16px;
    line-height: 1.85;
    letter-spacing: .5px;
    color: #000;
    word-break: break-word;
    opacity: 0;
    transition: opacity 1.2s ease;
}

#code.in {
    opacity: 1;
}

#code .say {
    display: inline-block;
    margin-left: 4px;
}

#code .stanza {
    margin: 0 0 12px;
}

#code .stanza:last-child {
    margin-bottom: 0;
}

/* 表白那句：加粗 + 大一号 + 字距，配合更慢的打字速度做强调。
   「跳两下」的动作由 js/main.js 的 popEmphasis() 驱动。 */
#code .stanza.emph {
    font-weight: 700;
    font-size: 19px;
    letter-spacing: 1px;
    transform-origin: left bottom;
}

/* 落款（以「——」开头的那一段）：靠右、正常字重 */
#code .stanza.sign {
    text-align: right;
    font-size: 17px;
    letter-spacing: 1px;
    margin-top: 6px;
    margin-bottom: 0;
    color: #c2185b;
}

/* ---------- 在一起的计时 ---------- */
#clock-box {
    position: absolute;
    left: 60px;
    top: 560px;
    font-size: 26px;
    display: none;
    z-index: 3;

    /* 柔和入场：淡入 + 轻微上浮 + 去掉一点模糊 */
    opacity: 0;
    transform: translateY(18px);
    filter: blur(5px);
    transition: opacity 1.6s ease,
                transform 1.6s cubic-bezier(.16, .84, .28, 1),
                filter 1.3s ease;
    will-change: opacity, transform;
}

#clock-box.in {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

#clock-box .name {
    font-size: 26px;
    text-decoration: none;
    color: #c2185b;          /* 深粉，和下面的数字呼应 */
    border: none;
    font-weight: 700;        /* 加粗 */
    letter-spacing: 1px;     /* 字距拉开一点，显得更郑重 */
}

#clock {
    margin-top: 4px;
    margin-left: 44px;
    font-size: 26px;
    white-space: nowrap;
    color: #000;
}

#clock .digit {
    font-size: 58px;
    font-weight: bold;
    font-family: 'Times New Roman', '微软雅黑', serif;
    color: #c2185b;
}

.hand {
    cursor: pointer;
}

/* ---------- 提示 ---------- */
#hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    text-align: center;
    font-size: 15px;
    letter-spacing: 3px;
    color: #b03060;
    opacity: .9;
    transition: opacity .5s;
    z-index: 4;
    pointer-events: none;
}

#hint.gone {
    opacity: 0;
}

/* ---------- 音乐按钮 ---------- */
#music-btn {
    position: fixed;
    right: 14px;
    bottom: 14px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .75);
    color: #c2185b;
    font-size: 19px;
    line-height: 42px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
    z-index: 10;
    outline: none;
}

#music-btn.playing {
    background: #c2185b;
    color: #fff;
}

/* =========================================================
 *  手机 / 窄屏：树在上、文字在下，正常滚动
 *  树用「百分比放大 + 左移 + overflow 裁切」来聚焦，
 *  全程不使用 transform（部分手机浏览器 transform-origin 处理不一致，
 *  会导致树跑出屏幕）
 * ========================================================= */
@media (max-width: 900px) {
    html, body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        background: #ffc0cb;
    }

    #viewport {
        position: static;
        display: block;
        min-height: 100vh;
        background: #ffc0cb;
    }

    #stage {
        width: 100%;
        height: auto;
        min-height: 100vh;       /* 内容再短，粉色底也铺满一屏 */
        background: #ffc0cb;
        transform: none !important;
        display: flex;
        flex-direction: column;
        padding-bottom: 56px;
    }

    #canvas-box {
        position: relative;
        inset: auto;
        width: 100%;
        height: 92.7vw;          /* = 150vw × 680/1100，正好等于放大后画布的高度 */
        overflow: hidden;
        order: 1;
        flex: none;
        -webkit-mask-image: linear-gradient(to bottom, #000 88%, transparent 100%);
        mask-image: linear-gradient(to bottom, #000 88%, transparent 100%);
    }

    /* 画布放大到 150% 宽、左移 59%，视野正好落在树上 */
    #tree-bg,
    #canvas {
        position: absolute;
        top: 0;
        left: -59%;
        width: 150%;
        height: 92.7vw;
    }

    #text {
        position: static;
        width: auto;
        order: 3;
        padding: 20px 22px 0;
    }

    #code {
        font-size: 15px;
        line-height: 2.1;
    }

    #code .stanza {
        margin-bottom: 14px;
    }

    #clock-box {
        position: static;
        order: 2;
        padding: 18px 22px 0;
        font-size: 16px;
    }

    #clock-box .name {
        font-size: 16px;
    }

    #clock {
        font-size: 14px;
        white-space: normal;
        margin-left: 0;
    }

    #clock .digit {
        font-size: 26px;
    }

    #hint {
        position: static;
        order: 4;
        margin-top: 16px;
        font-size: 13px !important;
    }

    #music-btn {
        position: fixed;
    }
}
