/* --- 核心变量 --- */
:root {
    --ink-deep: #121212;
    --ink-mid: #3a3a3a;
    --paper: #f5f2eb;
    --seal-red: #b83b2e;
    --glass-bg: rgba(255, 255, 255, 0.45);
    --glass-border: rgba(255, 255, 255, 0.6);
    --font-art: 'ZCOOL XiaoWei', serif;
    --font-body: 'Noto Serif SC', serif;
    --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--paper);
    color: var(--ink-deep);
    font-family: var(--font-body);
    overflow-x: hidden;
}

/* ========== 固定背景层 ========== */
#bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

.bg-slide {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1.2s var(--ease-smooth);
    will-change: opacity;
}

.bg-slide.active {
    opacity: 1;
}

.bg-slide[data-index="0"] {
    background-image: url('../media/img/backer/N1.png');
}

.bg-slide[data-index="1"] {
    background-image: url('../media/img/backer/N2.png');
}

.bg-slide[data-index="2"] {
    background-image: url('../media/img/backer/N3.png');
}

.bg-slide[data-index="3"] {
    background-image: url('../media/img/backer/N4.png');
}

.bg-slide[data-index="4"] {
    background-image: url('../media/img/backer/N5.png');
}

.bg-slide[data-index="5"] {
    background-image: url('../media/img/backer/N6.png');
}

.bg-slide[data-index="6"] {
    background-image: url('../media/img/backer/N7.png');
}

.paper-texture {
    position: absolute;
    inset: 0;
    opacity: 0.3;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
    contain: strict;
    pointer-events: none;
}

/* ========== 顶部数据条（深色胶囊 + Logo + 菜单） ========== */
    .data-ticker {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 20px;
    background: rgba(18, 18, 18, 0.78);
    backdrop-filter: blur(12px) saturate(1.4);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    white-space: nowrap;
    animation: barSlideIn 0.8s var(--ease-smooth) both;
}

@keyframes barSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.ticker-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: transform 0.3s ease, background 0.3s ease;
}
.ticker-logo img {
    width: 22px;
    height: 22px;
    border-radius: 4px;
}
.ticker-logo:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(-10deg) scale(1.05);
}
.ticker-logo:active { transform: scale(0.95); }

/* --- 数据指标组 --- */
.ticker-metrics {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    line-height: 1;
}

.ticker-item + .ticker-item {
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.ticker-icon { font-style: normal; font-size: 0.9rem; }
.ticker-label { color: rgba(255, 255, 255, 0.65); letter-spacing: 0.5px; }

.ticker-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 3ch;
    color: #5cdb5c; 
}

.ticker-item[data-bind="farmCount"] .ticker-value  { color: #5cdb5c; }
.ticker-item[data-bind="waterSaving"] .ticker-value { color: #4facfe; }
.ticker-item[data-bind="traceQuery"] .ticker-value  { color: #ffa940; }

.ticker-value[data-loading="true"] {
    animation: valuePulse 1.4s ease-in-out infinite;
}
@keyframes valuePulse {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 1; }
}

.ticker-menu-wrapper {
    position: relative;
    flex-shrink: 0;
}

.ticker-menu-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.3s ease;
}
.ticker-menu-btn:hover { background: rgba(255, 255, 255, 0.1); }

.hamburger-line {
    display: block;
    width: 18px;
    height: 2px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 2px;
    transition: all 0.35s var(--ease-smooth);
    transform-origin: center;
}

.ticker-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.ticker-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.ticker-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.ticker-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 160px;
    background: rgba(24, 24, 24, 0.92);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px 0;
    display: flex;
    flex-direction: column;

    /* 收起状态 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top right;
    transition: all 0.3s var(--ease-smooth);
    pointer-events: none;
}

.ticker-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.dropdown-link {
    display: block;
    padding: 10px 20px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}
.dropdown-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding-left: 24px;
}


@media (max-width: 768px) {
    .data-ticker {
        top: 8px;
        gap: 8px;
        padding: 6px 12px;
        border-radius: 16px;
        max-width: calc(100vw - 16px);
    }
    .ticker-metrics { gap: 6px; overflow-x: auto; scrollbar-width: none; }
    .ticker-metrics::-webkit-scrollbar { display: none; }
    .ticker-item { font-size: 0.65rem; gap: 3px; }
    .ticker-item + .ticker-item { padding-left: 6px; }
    .ticker-label { display: none; }
    .ticker-logo { width: 28px; height: 28px; }
    .ticker-logo img { width: 18px; height: 18px; }
    .ticker-menu-btn { width: 28px; height: 28px; gap: 4px; padding: 5px; }
    .hamburger-line { width: 14px; height: 1.5px; }
    .ticker-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
    .ticker-menu-btn[aria-expanded="true"] .hamburger-line:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
} 


/* ========== 时间轴导航 ========== */
.timeline-nav {
    position: fixed;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.tl-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(6px);
    cursor: pointer;
    font-family: var(--font-art);
    font-size: 0.7rem;
    color: var(--ink-mid);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s var(--ease-smooth);
}

.tl-dot.active {
    background: var(--seal-red);
    color: #fff;
    border-color: var(--seal-red);
    transform: scale(1.2);
}

.tl-dot:hover:not(.active) {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

/* ========== 章节内容 ========== */
#story-scroll {
    position: relative;
    z-index: 1;
}

.chapter {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 6rem 8vw 4rem;
}

.chapter:nth-child(odd) {
    justify-content: flex-start;
}

.chapter:nth-child(even) {
    justify-content: flex-end;
}

.chapter:last-child {
    justify-content: center;
}

.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    border-radius: 20px;
    padding: 3rem;
    max-width: 520px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s var(--ease-smooth), transform 0.8s var(--ease-smooth);
    contain: layout style paint;
}

.glass-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.left-align {
    text-align: left;
}

.right-align {
    text-align: right;
}

.center-align {
    text-align: center;
    max-width: 600px;
}

.chapter-time {
    display: inline-block;
    font-size: 0.75rem;
    letter-spacing: 3px;
    color: var(--seal-red);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--seal-red);
    padding-bottom: 0.3rem;
}

.chapter-title {
    font-family: var(--font-art);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.3;
    margin-bottom: 1.5rem;
}

.chapter-title em {
    font-style: normal;
    color: var(--seal-red);
}

.chapter-desc {
    font-size: 1rem;
    line-height: 2;
    color: var(--ink-mid);
    margin-bottom: 2rem;
}

.seal-btn {
    width: 80px;
    height: 80px;
    border: 3px solid var(--seal-red);
    border-radius: 12px;
    background: transparent;
    color: var(--seal-red);
    font-family: var(--font-art);
    font-size: 1rem;
    line-height: 1.3;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.4s var(--ease-smooth);
    position: relative;
    overflow: hidden;
}

.seal-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--seal-red);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.seal-btn:hover {
    transform: scale(1.08) rotate(-3deg);
    color: #fff;
}

.seal-btn:hover::before {
    opacity: 1;
}

.seal-btn span {
    position: relative;
    z-index: 1;
}

/* ========== ⭐ 浮动二维码印章 ========== */
.qr-seal {
    position: fixed;
    z-index: 200;
    bottom: 2rem;
    right: 0;
    display: flex;
    align-items: center;
    /* 默认折叠态：只露出触发按钮 */
    transform: translateX(calc(100% - 48px));
    transition: transform 0.5s var(--ease-smooth);
    will-change: transform;
    /* 防止拖拽时选中文本 */
    user-select: none;
    -webkit-user-select: none;
}

/* 展开态 */
.qr-seal.expanded {
    transform: translateX(-1rem) !important;
}

/* 左侧折叠时的镜像处理 */
.qr-seal.dock-left {
    right: auto;
    left: 0;
    transform: translateX(calc(-100% + 48px));
    flex-direction: row-reverse;
}

.qr-seal.dock-left.expanded {
    transform: translateX(1rem) !important;
}

/* 触发按钮（印章外观） */
.qr-seal__trigger {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--seal-red);
    border-radius: 12px 0 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    box-shadow: -2px 2px 12px rgba(184, 59, 46, 0.3);
    transition: background 0.3s ease;
}

.qr-seal.dock-left .qr-seal__trigger {
    border-radius: 0 12px 12px 0;
    box-shadow: 2px 2px 12px rgba(184, 59, 46, 0.3);
}

.qr-seal__trigger svg {
    width: 24px;
    height: 24px;
}

.qr-seal__trigger:hover {
    background: #a03328;
}

/* 二维码面板 */
.qr-seal__panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    border-radius: 16px 0 0 16px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    box-shadow: -4px 4px 20px rgba(0, 0, 0, 0.06);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease 0.1s;
}

.qr-seal.dock-left .qr-seal__panel {
    border-radius: 0 16px 16px 0;
    box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.06);
}

.qr-seal.expanded .qr-seal__panel {
    opacity: 1;
    pointer-events: auto;
}

.qr-seal__panel img {
    width: 140px;
    height: 140px;
    border-radius: 8px;
    border: 2px solid rgba(184, 59, 46, 0.15);
}

.qr-seal__label {
    font-family: var(--font-art);
    font-size: 0.8rem;
    color: var(--ink-deep);
    letter-spacing: 2px;
}

/* 拖拽中的样式 */
.qr-seal.dragging {
    transition: none !important;
    cursor: grabbing;
}

.qr-seal.dragging .qr-seal__trigger {
    cursor: grabbing;
}

/* ========== 页脚 ========== */
.ink-footer {
    position: relative;
    z-index: 10;
    padding: 2rem 5%;
    display: flex;
    justify-content: center;
    background: linear-gradient(to top, var(--paper) 60%, transparent);
}

.footer-inner {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    font-size: 0.75rem;
    color: var(--ink-mid);
    opacity: 0.7;
}

.divider {
    display: inline-block;
    width: 1px;
    height: 12px;
    background: linear-gradient(to bottom, transparent, var(--ink-mid) 30%, var(--ink-mid) 70%, transparent);
}

.icp-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dashed rgba(58, 58, 58, 0.3);
    transition: all 0.3s ease;
}

.icp-link:hover {
    color: var(--ink-deep);
    border-bottom-color: var(--seal-red);
    border-bottom-style: solid;
}

/* ========== 响应式 ========== */
@media(max-width:1024px) {
    .chapter {
        padding: 5rem 5vw 3rem;
        justify-content: center !important;
    }

    .glass-card {
        max-width: 100%;
        text-align: left !important;
    }

    .timeline-nav {
        right: 0.8rem;
        gap: 0.8rem;
    }

    .tl-dot {
        width: 28px;
        height: 28px;
        font-size: 0.6rem;
    }

    /* 移动端印章缩小并降低z-index避免遮挡内容 */
    .qr-seal {
        bottom: 1rem;
        z-index: 150;
    }

    .qr-seal__trigger {
        width: 40px;
        height: 40px;
    }

    .qr-seal__trigger svg {
        width: 20px;
        height: 20px;
    }

    .qr-seal__panel img {
        width: 120px;
        height: 120px;
    }
}

@media(max-width:768px) {
    .data-ticker {
        gap: 1.5rem;
        font-size: 0.65rem;
        padding: 0.5rem 4%;
    }

    .timeline-nav {
        display: none;
    }

    .glass-card {
        padding: 2rem 1.5rem;
    }

    .ink-footer .footer-inner {
        flex-direction: column;
        gap: 0.6rem;
        text-align: center;
    }

    .divider {
        width: 20px;
        height: 1px;
        background: linear-gradient(to right, transparent, var(--ink-mid) 30%, var(--ink-mid) 70%, transparent);
    }
}

@media(prefers-reduced-motion:reduce) {

    .bg-slide,
    .glass-card,
    .qr-seal,
    .qr-seal__panel {
        transition: none !important;
    }

    .glass-card {
        opacity: 1 !important;
        transform: none !important;
    }

    html {
        scroll-behavior: auto;
    }
}
