/* === NavXingShu 字体 === */
@font-face { font-family: "NavXingShu"; src: url("/fonts/HongLeiXingShuJianTi-2.otf") format("opentype"); font-display: swap; }

/* === 全局变量 === */
:root { 
    --bg: #000; 
    --text: #fff; 
    --card-bg: #121212; 
    --anim-speed: 0.6s; 
    --size-ratio: 1;
    --font-cn: "NavXingShu", 'Noto Sans SC';
    --font-en: 'Inter';
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

body, html { 
    height: 100%; 
    margin: 0; 
    background: var(--bg); 
    color: var(--text); 
    font-family: var(--font-en), var(--font-cn), sans-serif; 
    overflow: hidden; 
    -webkit-font-smoothing: antialiased;
    font-weight: 300;
}

/* 全局布局 */
.stage { height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; }
.view { display: none; text-align: center; width: 100%; }
.view.active { display: block; }
.dot { position: fixed; top: 30px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; background: #fff; border-radius: 50%; animation: pulse 4s infinite; cursor: pointer; z-index: 1000; }

/* --- 模式 1: 物理 3D 翻页 --- */
.flip-clock { display: flex; gap: clamp(15px, 3vw, 40px); justify-content: center; align-items: center; perspective: 1000px; }
.flip-unit { 
    position: relative; 
    width: clamp(120px, 18vw, 280px); 
    height: clamp(170px, 26vw, 400px); 
    font-size: clamp(6rem, 12vw, 16rem); 
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono), var(--font-en), sans-serif;
    letter-spacing: -0.02em;
}
.flip-unit .top, .flip-unit .bottom {
    position: absolute; left: 0; width: 100%; height: 50%;
    background: var(--card-bg); overflow: hidden;
    display: flex; justify-content: center;
}
.flip-unit .top { 
    top: 0; border-radius: 14px 14px 0 0; 
    align-items: flex-end; 
    border-bottom: 2px solid #000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.flip-unit .bottom { 
    bottom: 0; border-radius: 0 0 14px 14px; 
    align-items: flex-start;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}
.flip-unit .top span, .flip-unit .bottom span,
.flip-unit .flip-top span, .flip-unit .flip-bottom span {
    display: block; width: 100%; text-align: center;
    font-family: var(--font-mono), var(--font-en), sans-serif;
    font-weight: 200;
    letter-spacing: -0.02em;
}
.flip-unit .top span { transform: translateY(50%); }
.flip-unit .bottom span { transform: translateY(-50%); }
.flip-unit .flip-top, .flip-unit .flip-bottom {
    position: absolute; left: 0; width: 100%; height: 50%;
    background: var(--card-bg); overflow: hidden;
    display: flex; justify-content: center;
    backface-visibility: hidden;
}
.flip-unit .flip-top {
    top: 0; border-radius: 14px 14px 0 0;
    transform-origin: bottom; 
    align-items: flex-end;
    border-bottom: 2px solid #000;
    z-index: 10;
}
.flip-unit .flip-top span { transform: translateY(50%); }
.flip-unit .flip-bottom {
    bottom: 0; border-radius: 0 0 14px 14px;
    transform-origin: top; 
    transform: rotateX(90deg);
    align-items: flex-start;
    z-index: 10;
}
.flip-unit .flip-bottom span { transform: translateY(-50%); }
.flip-unit.flipping .flip-top {
    animation: flipTop 0.6s ease-in forwards;
}
.flip-unit.flipping .flip-bottom {
    animation: flipBottom 0.6s ease-out 0.3s forwards;
}
@keyframes flipTop {
    0% { transform: rotateX(0deg); }
    100% { transform: rotateX(-90deg); }
}
@keyframes flipBottom {
    0% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

/* --- 模式 2: 扫掠表盘 --- */
.analog-box { position: relative; width: 460px; height: 460px; border-radius: 50%; border: 4px solid #fff; margin: 0 auto; background: #000; }
.hand { position: absolute; bottom: 50%; left: 50%; transform-origin: bottom center; transition: transform 0.1s linear; }
.h-hand { width: 14px; height: 115px; background: #fff; z-index: 3; border-radius: 6px; margin-left: -7px; }
.m-hand { width: 10px; height: 170px; background: #fff; z-index: 2; border-radius: 4px; margin-left: -5px; }
.s-hand { width: 3px; height: 200px; background: #ff3b30; z-index: 4; margin-left: -1.5px; }
.pin { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 18px; height: 18px; background: #fff; border-radius: 50%; z-index: 10; border: 2px solid #000; }
.mark { position: absolute; left: 50%; transform-origin: 0 225px; top: 5px; background: #333; width: 2px; height: 15px; }
.mark.big { background: #fff; width: 6px; height: 35px; margin-left: -2px; }

/* --- 其他模式 --- */
.clock-big { 
    font-size: calc(clamp(4rem, 12vw, 12rem) * var(--size-ratio)); 
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono), var(--font-en), sans-serif;
    letter-spacing: -0.02em;
}

.chinese-time { text-align: center; }
.cn-date { 
    font-size: calc(clamp(2.5rem, 6vw, 5rem) * var(--size-ratio)); 
    opacity: 0.6; 
    margin-bottom: 20px; 
    letter-spacing: 0.05em;
    font-family: var(--font-cn), sans-serif;
    font-weight: 300;
}
.cn-time { 
    font-size: calc(clamp(4rem, 10vw, 9rem) * var(--size-ratio)); 
    font-weight: 300;
    letter-spacing: 0.05em;
    font-family: var(--font-cn), sans-serif;
}

.custom-msg { 
    font-size: calc(clamp(2rem, 5vw, 5rem) * var(--size-ratio)); 
    line-height: 1.6; 
    padding: 0 10%;
    font-family: var(--font-en), var(--font-cn), sans-serif;
    font-weight: 400;
    letter-spacing: 0.06em;
}

#goal-name {
    font-size: calc(clamp(1.2rem, 3vw, 2rem) * var(--size-ratio));
    font-family: var(--font-cn), sans-serif;
    letter-spacing: 6px;
    opacity: 0.4;
    margin-bottom: 20px;
}
.goal-timer { 
    font-size: calc(clamp(3rem, 6vw, 6rem) * var(--size-ratio)); 
    font-weight: 200;
    font-family: var(--font-mono), var(--font-en), sans-serif;
    letter-spacing: -0.02em;
}

/* --- 底部导航栏 --- */
.nav { 
    position: absolute; 
    bottom: 40px; 
    width: 100%; 
    text-align: center; 
    font-size: 0.85rem; 
    font-weight: 400;
    letter-spacing: 4px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 100;
    font-family: var(--font-cn), sans-serif;
}
.nav a { color: #fff; text-decoration: none; margin: 0 12px; opacity: 0.5; transition: 0.3s; padding-bottom: 5px; border-bottom: 1px solid transparent; }
.nav a.active, .nav a:hover { opacity: 1; border-bottom: 1px solid #fff; }
.nav-sep { width: 1px; height: 12px; background: rgba(255,255,255,0.2); margin: 0 15px; }

/* --- 设置面板 --- */
#settings { 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    background: rgba(10,10,10,0.99); 
    padding: 30px; 
    border-radius: 20px; 
    border: 1px solid #333; 
    display: none; 
    flex-direction: column; 
    gap: 10px; 
    backdrop-filter: blur(30px); 
    z-index: 2000; 
    width: 320px; 
    max-height: 85vh; 
    overflow-y: auto;
    font-family: var(--font-en), var(--font-cn), sans-serif;
}
body.settings-open .stage { opacity: 0; pointer-events: none; transition: opacity 0.3s; }
body.settings-open .nav { opacity: 0; pointer-events: none; transition: opacity 0.3s; }
#settings label { 
    font-size: 10px; 
    font-weight: 500;
    opacity: 0.4; 
    text-transform: uppercase; 
    margin-top: 10px; 
    letter-spacing: 1px;
}
#settings input, #settings select, #settings button { 
    background: #1a1a1a; 
    border: 1px solid #333; 
    color: #fff; 
    padding: 12px; 
    border-radius: 8px; 
    outline: none;
    font-family: var(--font-en), var(--font-cn), sans-serif;
    font-weight: 400;
}
#settings button.save-btn { background: #fff; color: #000; font-weight: bold; border: none; cursor: pointer; margin-top: 20px; }

/* --- 音乐播放器 --- */
#music-player { 
    display:none; 
    position:fixed; 
    bottom:60px; 
    left:50%; 
    transform:translateX(-50%); 
    background:rgba(10,10,10,0.95); 
    padding:20px; 
    border-radius:15px; 
    border:1px solid #333; 
    z-index:1000; 
    backdrop-filter: blur(10px); 
    transition: all 0.3s ease;
    font-family: var(--font-en), var(--font-cn), sans-serif;
}
#music-player input:focus { outline: none; border-color: #fff; }
#music-player input { 
    font-family: var(--font-en), var(--font-cn), sans-serif;
    font-weight: 400;
}
#music-results div { 
    font-family: var(--font-en), var(--font-cn), sans-serif;
    font-weight: 400;
}
#music-results::-webkit-scrollbar { width: 4px; }
#music-results::-webkit-scrollbar-track { background: #1a1a1a; }
#music-results::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
#music-results div:hover { background: rgba(255,255,255,0.1); }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 0.8; } }

/* 平板设备 */
@media (max-width: 1024px) {
    .analog-box { width: 400px; height: 400px; }
    .h-hand { height: 100px; }
    .m-hand { height: 145px; }
    .s-hand { height: 170px; }
    .mark { transform-origin: 0 195px; }
}

/* 大手机 / 小平板 */
@media (max-width: 767px) {
    .analog-box { width: 360px; height: 360px; }
    .h-hand { height: 90px; }
    .m-hand { height: 130px; }
    .s-hand { height: 152px; }
    .mark { transform-origin: 0 175px; }
    .flip-unit { width: clamp(130px, 44vw, 200px); height: clamp(182px, 62vw, 280px); font-size: clamp(7rem, 22vw, 14rem); }
    .clock-big { font-size: clamp(5rem, 20vw, 8rem); }
    .cn-date { font-size: clamp(2.2rem, 8vw, 4rem); letter-spacing: 6px; }
    .cn-time { font-size: clamp(4rem, 14vw, 7rem); letter-spacing: 5px; }
    .custom-msg { font-size: clamp(2rem, 7vw, 3.5rem); }
    .goal-timer { font-size: clamp(3rem, 12vw, 6rem); }
    #goal-name { font-size: 1rem; }
    .nav { font-size: 0.55rem; bottom: 15px; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
    .nav-sep { display: none; }
    .nav a { margin: 2px 5px; padding-bottom: 3px; }
    #settings { width: 90%; padding: 20px; }
    #music-player { width: 90%; padding: 15px; }
    #music-search { width: 100% !important; margin-bottom: 10px; }
}

/* 小手机 */
@media (max-width: 480px) {
    .analog-box { width: 300px; height: 300px; }
    .h-hand { height: 75px; }
    .m-hand { height: 108px; }
    .s-hand { height: 126px; }
    .mark { transform-origin: 0 145px; }
    .mark.big { height: 30px; }
    .flip-clock { gap: 12px; }
    .flip-unit { width: clamp(115px, 42vw, 160px); height: clamp(161px, 59vw, 224px); font-size: clamp(5.5rem, 20vw, 10rem); }
    .clock-big { font-size: clamp(3.8rem, 18vw, 6rem); }
    .cn-date { font-size: clamp(2rem, 7vw, 3rem); margin-bottom: 15px; }
    .cn-time { font-size: clamp(3.2rem, 13vw, 5rem); }
    .nav { font-size: 0.5rem; gap: 4px; }
    .nav a { margin: 2px 4px; letter-spacing: 1px; }
}

/* 超小屏幕 */
@media (max-width: 360px) {
    .analog-box { width: 260px; height: 260px; }
    .h-hand { height: 65px; }
    .m-hand { height: 93px; }
    .s-hand { height: 109px; }
    .mark { transform-origin: 0 125px; }
    .flip-unit { width: 105px; height: 147px; font-size: 4.8rem; }
    .clock-big { font-size: 3.2rem; }
    .cn-date { font-size: 1.8rem; }
    .cn-time { font-size: 2.8rem; }
}

/* 横屏模式 */
@media (orientation: landscape) and (max-height: 500px) {
    .analog-box { width: min(70vh, 400px); height: min(70vh, 400px); }
    .h-hand { height: calc(min(70vh, 400px) * 0.25); }
    .m-hand { height: calc(min(70vh, 400px) * 0.37); }
    .s-hand { height: calc(min(70vh, 400px) * 0.43); }
    .mark { transform-origin: 0 calc(min(70vh, 400px) * 0.49 - 5px); }
    .flip-clock { gap: 15px; }
    .flip-unit { width: min(25vh, 150px); height: min(35vh, 210px); font-size: min(15vh, 8rem); }
    .clock-big { font-size: min(20vh, 8rem); }
    .custom-msg { font-size: min(10vh, 3rem); }
    .goal-timer { font-size: min(12vh, 4rem); }
    .cn-date { font-size: min(8vh, 2.5rem); margin-bottom: 10px; }
    .cn-time { font-size: min(14vh, 5rem); }
}

/* 全屏模式隐藏导航 */
body.fullscreen-mode .nav { opacity: 0; pointer-events: none; transition: opacity 0.3s; }
body.fullscreen-mode .dot { opacity: 0.3; }
body.fullscreen-mode:hover .dot { opacity: 0.8; }
