/**
 * Mobile-first overrides (loads after main.css).
 * Defaults = phone; larger screens in @media (min-width: …).
 */

body,
button,
a,
[role="button"] {
    touch-action: manipulation;
}

html {
    -webkit-text-size-adjust: 100%;
    font-size: clamp(15px, 3.8vw, 17px);
}

body {
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
    text-rendering: optimizeLegibility;
}

@keyframes site-title-line-in {
    from {
        opacity: 0;
        transform: scaleX(0.35);
    }

    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

@keyframes site-bridge-line-in {
    from {
        opacity: 0;
        transform: scaleY(0.2);
    }

    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

@keyframes site-nav-box-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Layout shell ---- */
#wrapper {
    padding: 0.85rem min(1rem, 4vw) 1.75rem;
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

@media (min-width: 36em) {
    #wrapper {
        padding: 1.25rem min(1.5rem, 5vw) 2.25rem;
    }
}

@media (min-width: 62em) {
    #wrapper {
        padding: 2.5rem 2rem 3rem;
    }
}

/* ---- Header：无玻璃卡片，恢复横线 + 竖线层次（略加间距更饱满）---- */
#header {
    width: 100%;
    max-width: min(100%, 28rem);
    margin-left: auto;
    margin-right: auto;
    padding: 0 0.35rem;
    box-sizing: border-box;
    /* 与 #header > * 的 margin-top 一致，供竖线 height: calc(...) 使用（缺失会使整条 calc 无效 → 高度为 0） */
    --title-nav-stack: 1.65rem;
}

@media (min-width: 36em) {
    #header {
        --title-nav-stack: 2.15rem;
    }
}

@media (min-width: 56.25em) {
    #header {
        --title-nav-stack: 2.85rem;
    }
}

#header > * {
    margin-top: 1.65rem !important;
    position: relative;
}

#header > *:before {
    display: none !important;
}

#header > :first-child {
    margin-top: 0 !important;
}

@media (min-width: 36em) {
    #header > * {
        margin-top: 2.15rem !important;
    }

    #header > *:before {
        display: block !important;
        content: '';
        position: absolute;
        top: calc(-2.15rem - 1px);
        left: calc(50% - 1px);
        width: 1px;
        height: calc(2.15rem + 1px);
        background: rgba(255, 255, 255, 0.92);
    }

    #header > :first-child:before {
        display: none !important;
    }
}

@media (min-width: 56.25em) {
    #header > * {
        margin-top: 2.85rem !important;
    }

    #header > *:before {
        top: calc(-2.85rem - 1px);
        height: calc(2.85rem + 1px);
    }
}

#header .content {
    position: relative;
    z-index: 2;
    max-width: 100%;
    width: 100%;
    overflow: visible;
    border-top: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
}

#header .content::before,
#header .content::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    pointer-events: none;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.15) 8%,
        rgba(255, 255, 255, 0.92) 22%,
        rgba(255, 255, 255, 0.92) 78%,
        rgba(255, 255, 255, 0.15) 92%,
        transparent 100%
    );
    transform-origin: center center;
    opacity: 0;
    animation: site-title-line-in 1.05s cubic-bezier(0.22, 0.85, 0.32, 1) forwards;
}

#header .content::before {
    top: 0;
    animation-delay: 0.08s;
}

#header .content::after {
    bottom: 0;
    animation-delay: 0.28s;
}

#header .content .inner {
    padding: 0.55rem min(1.1rem, 4vw) 1.45rem !important;
    max-height: none !important;
}

@media (min-width: 36em) {
    #header .content .inner {
        padding: 0.72rem 1.5rem 1.75rem !important;
    }
}

@media (min-width: 62em) {
    #header .content .inner {
        padding: 0.85rem 1.85rem 2.1rem !important;
    }
}

#main-title {
    font-size: clamp(1.45rem, 6.9vw, 2.55rem);
    margin-top: -0.45rem;
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
    letter-spacing: 0.1rem;
    text-transform: none;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    animation: site-nav-box-in 0.75s ease 0.05s both;
}

@media (prefers-reduced-motion: reduce) {
    #header .content::before,
    #header .content::after {
        animation: none;
        opacity: 1;
        transform: none;
    }

    #main-title {
        animation: none;
    }

    #header nav ul#nav-links,
    #header nav ul {
        animation: none !important;
        opacity: 1 !important;
    }

    #header .content > .site-axis-bridge {
        animation: none;
        opacity: 1;
        transform: scaleY(1);
    }
}

/* ---- Nav：无整列表外框；每行独立小框；文字与框边略留空 ---- */
#header nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0.55rem 0 0.65rem;
    position: relative;
    z-index: 1;
}

/* 从主标题区底边横线（::after）中点垂下：止于标题与 nav 间距 + nav 顶内边距，不进入第一个链接外框 */
#header .content > .site-axis-bridge {
    position: absolute;
    left: calc(50% - 0.5px);
    top: calc(100% - 0.5px);
    width: 1px;
    height: calc(var(--title-nav-stack, 1.65rem) + 0.55rem - 1px);
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0.5px;
    transform-origin: top center;
    background: #ffffff;
    opacity: 0;
    animation: site-bridge-line-in 0.95s cubic-bezier(0.22, 0.85, 0.32, 1) 0.24s forwards;
    pointer-events: none;
}

#header nav ul#nav-links,
#header nav ul {
    display: flex !important;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    width: max-content;
    max-width: min(100%, 26rem);
    margin: 0 auto;
    padding: 0;
    list-style: none;
    border: none !important;
    border-radius: 0;
    overflow: visible;
    gap: 0.5rem !important;
    background: transparent !important;
    opacity: 0;
    animation: site-nav-box-in 0.85s ease 0.42s forwards;
    position: relative;
    z-index: 1;
}

#header nav ul#nav-links li,
#header nav ul li {
    padding: 0 !important;
    width: auto;
    min-width: 0;
    max-width: 100%;
    border: none !important;
    display: flex;
    justify-content: center;
}

#header nav ul#nav-links li a,
#header nav ul li a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: max-content !important;
    max-width: min(100vw - 2.5rem, 26rem) !important;
    min-height: 2.85rem;
    height: auto !important;
    line-height: 1.4 !important;
    padding: 0.78rem 1.65rem !important;
    box-sizing: border-box;
    border: solid 1px rgba(255, 255, 255, 0.55) !important;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.14);
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0.06em;
    font-size: clamp(0.82rem, 3.2vw, 0.98rem);
    word-break: break-word;
    text-align: center;
    white-space: normal;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#header nav ul#nav-links li a:hover,
#header nav ul li a:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.72) !important;
}

#header nav ul#nav-links li a:active,
#header nav ul li a:active {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

@media (min-width: 36em) {
    #header nav ul#nav-links,
    #header nav ul {
        gap: 0.55rem !important;
    }

    #header nav ul#nav-links li a,
    #header nav ul li a {
        padding: 0.88rem 1.9rem !important;
        min-height: 3rem;
        border-radius: 11px;
    }
}

/* 纵向链接列表时隐藏 nav 内中轴竖线，避免穿过文字 */
#header nav.use-middle:after {
    display: none !important;
}

/* ---- Footer ---- */
#footer {
    margin-top: 1.5rem;
    padding: 0.85rem 0.75rem 0.5rem;
    width: 100%;
    max-width: min(100%, 28rem);
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#footer .copyright {
    font-size: clamp(0.68rem, 2.9vw, 0.78rem);
    line-height: 1.5;
    word-break: break-word;
    letter-spacing: 0.06em;
    text-transform: none;
    color: rgba(255, 255, 255, 0.88);
    text-align: center;
}

@media (min-width: 48em) {
    #footer {
        margin-top: 2rem;
    }

    #footer .copyright {
        letter-spacing: 0.2rem;
        text-transform: uppercase;
    }
}

/* ---- Background layer: less zoom on narrow viewports ---- */
#bg {
    transform: scale(1.04);
}

@media (min-width: 48em) {
    #bg {
        transform: scale(1.08);
    }
}

@media (min-width: 75em) {
    #bg {
        transform: scale(1.1);
    }
}

/* ---- Snow ---- */
.fx-snow-root {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    /* 手机端略增高飘落区，与下落动画位移一致 */
    height: min(46vh, 360px);
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
    display: none;
}

.fx-snow-root.is-on {
    display: block;
}

.fx-snow-root .flake {
    position: absolute;
    top: -18px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    animation: fx-snow-fall linear infinite;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.35));
    pointer-events: none;
}

.fx-snow-root .flake svg {
    display: block;
    overflow: visible;
}

@keyframes fx-snow-fall {
    0% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }

    100% {
        transform: translate3d(var(--snow-drift, 0px), min(46vh, 360px), 0) rotate(360deg);
        opacity: 0.15;
    }
}

/* ---- Marquee ---- */
.fx-marquee-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: clamp(0.72rem, 3.1vw, 0.95rem);
    padding: 0.4rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: calc(0.4rem + env(safe-area-inset-bottom, 0));
}

.fx-marquee-inner {
    display: flex;
    width: max-content;
    white-space: nowrap;
    animation: fx-marquee-scroll 20s linear infinite;
}

.fx-marquee-inner span {
    flex: 0 0 auto;
    padding-right: 2.5rem;
}

@keyframes fx-marquee-scroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

body.has-marquee #wrapper {
    padding-bottom: calc(2.75rem + env(safe-area-inset-bottom, 0));
}

@media (prefers-reduced-motion: reduce) {
    .fx-marquee-inner {
        animation: none;
    }

    /* 雪花保留飘落动画（用户期望）；仅关掉底部跑马灯滚动 */
}
