/* ==============================================================================
 * 胡sir牌阳澄湖大闸蟹 - 消费者全链路溯源页样式（2026-09-19 国际大厂风格重制）
 *
 * 消费 /static/css/design-tokens.css 设计令牌（--u-* 前缀），本文件不自定义色彩常量。
 * 设计语言：近白底 + 纯白卡片 + 墨色文字；湖域深绿主色、蟹金点缀；
 * 1px 发丝边框、三级柔和阴影、12/16/20 圆角、8pt 间距、微交互 200ms。
 * 移动优先，内容列 max-width 640px 居中；对比度 ≥ 4.5:1；焦点可见；动效可降级。
 * ============================================================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Vue 挂载完成前隐藏应用根（防止 mustache 插值闪烁）；挂载后 Vue 自动移除 v-cloak */
[v-cloak] {
    display: none;
}

body {
    min-height: 100vh;
    padding-bottom: var(--u-space-6);
    /* viewport-fit=cover（全面屏）：给底部 home 指示条让位；env 不支持的旧内核整行失效回落上一行 */
    padding-bottom: calc(var(--u-space-6) + env(safe-area-inset-bottom));
}

/* 内容列：移动优先、桌面居中 */
.trace-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 var(--u-space-4);
    /* 刘海/灵动岛横屏安全区：内容列左右让位（env 不支持时回落上方 padding 简写） */
    padding-left: max(var(--u-space-4), env(safe-area-inset-left));
    padding-right: max(var(--u-space-4), env(safe-area-inset-right));
}

/* ==============================================================================
 * 顶部粘性毛玻璃导航
 * ============================================================================== */

.trace-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.78);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--u-line);
    /* viewport-fit=cover：粘性顶栏给顶部状态栏/刘海让位，避免品牌字标顶进系统区域 */
    padding-top: env(safe-area-inset-top);
}

.topbar-inner {
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: var(--u-space-2);
    padding: var(--u-space-2) var(--u-space-4);
    /* 与 .trace-main 同口径的左右安全区（横屏刘海） */
    padding-left: max(var(--u-space-4), env(safe-area-inset-left));
    padding-right: max(var(--u-space-4), env(safe-area-inset-right));
    min-height: 48px;
}

/* 品牌字标：深绿圆角方块 + 反白单字 */
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: var(--u-brand);
    color: var(--u-brand-on);
    font-size: var(--u-font-s);
    font-weight: 700;
    flex: 0 0 auto;
    box-shadow: var(--u-shadow-1);
}

.topbar-title {
    font-size: var(--u-font-s);
    font-weight: 650;
    color: var(--u-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==============================================================================
 * 品牌沉浸区：深绿渐变底 + 金色来源徽标
 * ============================================================================== */

.hero {
    position: relative;
    background: linear-gradient(160deg, var(--u-brand-strong) 0%, var(--u-brand) 55%, #164a3a 100%);
    color: var(--u-ink-inverse);
    text-align: center;
    padding: var(--u-space-6) var(--u-space-4) 68px;
    /* 无 JS 兜底壳/顶栏让位后品牌区自身也要避开顶部状态栏（cover 模式下延伸进系统区域） */
    padding-top: calc(var(--u-space-6) + env(safe-area-inset-top));
    margin-bottom: -44px;
    overflow: hidden;
}

/* 顶部柔和金晕：给深绿底一点光感（纯 CSS，无图片） */
.hero::before {
    content: "";
    position: absolute;
    inset: -40% -20% auto;
    height: 260px;
    background: radial-gradient(ellipse at center, rgba(197, 155, 39, 0.16), transparent 65%);
    pointer-events: none;
}

.hero > * {
    position: relative;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 14px;
    border: 1px solid rgba(226, 194, 102, 0.55);
    border-radius: var(--u-radius-pill);
    background: rgba(197, 155, 39, 0.14);
    color: var(--u-gold-on-dark);
    font-size: var(--u-font-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-bottom: var(--u-space-3);
}

.hero-title {
    font-size: var(--u-font-xl);
    font-weight: 700;
    letter-spacing: 0.01em;
    margin-bottom: var(--u-space-1);
}

.hero-subtitle {
    font-size: var(--u-font-xs);
    color: rgba(245, 247, 245, 0.72);
}

/* ==============================================================================
 * 首访隐私横条
 * ============================================================================== */

.privacy-banner {
    display: flex;
    align-items: center;
    gap: var(--u-space-3);
    margin: var(--u-space-4) 0 0;
    padding: var(--u-space-3) var(--u-space-4);
    border: 1px solid var(--u-line);
    border-left: 3px solid var(--u-gold);
    border-radius: 0 var(--u-radius-s) var(--u-radius-s) 0;
    background: var(--u-gold-soft);
    color: var(--u-caution-ink);
    font-size: var(--u-font-xs);
    line-height: 1.6;
}

.privacy-banner button {
    flex: 0 0 auto;
    border: 1px solid var(--u-line-strong);
    background: var(--u-surface);
    color: var(--u-ink-2);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: var(--u-font-xs);
    font-weight: 600;
    cursor: pointer;
    min-height: 30px;
    transition: background var(--u-dur) var(--u-ease), border-color var(--u-dur) var(--u-ease);
}

.privacy-banner button:hover {
    border-color: var(--u-brand);
    color: var(--u-brand);
}

.privacy-banner button:active {
    transform: scale(0.97);
}

/* ==============================================================================
 * 药丸形搜索条：输入 + 扫码 + 查询一体（48px 高）
 * ============================================================================== */

.search-shell {
    position: relative;
    z-index: 10;
    margin-bottom: var(--u-space-4);
}

.search-pill {
    display: flex;
    align-items: center;
    gap: var(--u-space-2);
    min-height: 48px;
    padding: 5px 5px 5px var(--u-space-4);
    background: var(--u-surface);
    border: 1px solid var(--u-line-strong);
    border-radius: var(--u-radius-pill);
    box-shadow: var(--u-shadow-2);
    transition: border-color var(--u-dur) var(--u-ease), box-shadow var(--u-dur) var(--u-ease);
}

/* 聚焦环：整个搜索条在输入聚焦时点亮（键盘与触屏均可见） */
.search-pill:focus-within {
    border-color: var(--u-brand);
    box-shadow: var(--u-shadow-2), var(--u-focus-ring);
}

.search-glyph {
    flex: 0 0 auto;
    color: var(--u-ink-3);
}

.search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 38px;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--u-font-s);
    font-family: var(--u-font-mono);
    color: var(--u-ink);
}

.search-input::placeholder {
    color: var(--u-ink-3);
    font-family: var(--u-font-sans);
}

/* 扫码按钮（仅在 BarcodeDetector + getUserMedia 环境由 v-if 渲染） */
.scan-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--u-line-strong);
    border-radius: var(--u-radius-pill);
    background: var(--u-surface-2);
    color: var(--u-brand);
    font-size: var(--u-font-xs);
    font-weight: 650;
    cursor: pointer;
    transition: background var(--u-dur) var(--u-ease), border-color var(--u-dur) var(--u-ease),
        transform var(--u-dur) var(--u-ease), opacity var(--u-dur) var(--u-ease);
}

.scan-btn:hover {
    border-color: var(--u-brand);
    background: var(--u-brand-soft);
}

.scan-btn:active {
    transform: scale(0.96);
}

.scan-btn:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

.search-btn {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 20px;
    border: none;
    border-radius: var(--u-radius-pill);
    background: var(--u-brand);
    color: var(--u-brand-on);
    font-size: var(--u-font-s);
    font-weight: 650;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(10, 41, 31, 0.35);
    transition: background var(--u-dur) var(--u-ease), transform var(--u-dur) var(--u-ease),
        box-shadow var(--u-dur) var(--u-ease);
}

.search-btn:hover {
    background: var(--u-brand-strong);
    box-shadow: var(--u-shadow-1);
}

.search-btn:active {
    transform: scale(0.96);
}

/* ==============================================================================
 * 卡片基座
 * ============================================================================== */

.batch-card,
.timeline-card,
.side-card {
    background: var(--u-surface);
    border: 1px solid var(--u-line);
    border-radius: var(--u-radius-l);
    box-shadow: var(--u-shadow-1);
    padding: var(--u-space-5) var(--u-space-4);
    margin-bottom: var(--u-space-4);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--u-space-3);
    margin-bottom: var(--u-space-4);
    border-bottom: 1px solid var(--u-line);
}

.card-title {
    font-size: var(--u-font-m);
    font-weight: 700;
    color: var(--u-ink);
    letter-spacing: 0.01em;
}

/* ==============================================================================
 * 批次核心档案卡
 * ============================================================================== */

.batch-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--u-space-2) var(--u-space-3);
    margin-bottom: var(--u-space-4);
}

.batch-head-main {
    flex: 1 1 220px;
    min-width: 0;
}

.batch-label {
    font-size: var(--u-font-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--u-ink-3);
    margin-bottom: var(--u-space-1);
}

/* 大号批次号：32px 等宽数字（tabular-nums 防跳动） */
.batch-no {
    font-size: var(--u-font-2xl);
    font-weight: 700;
    line-height: 1.2;
    color: var(--u-brand);
    font-family: var(--u-font-mono);
    letter-spacing: 0.01em;
    word-break: break-all;
}

.cert-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--u-radius-pill);
    background: var(--u-brand-soft);
    color: var(--u-brand);
    border: 1px solid rgba(15, 56, 44, 0.14);
    font-size: var(--u-font-xs);
    font-weight: 650;
    white-space: nowrap;
}

/* 记录边界条：日期 + 来源标签 + 边界说明（aria-live 播报区） */
.record-boundary {
    padding: var(--u-space-3) var(--u-space-4);
    border-radius: var(--u-radius-s);
    background: var(--u-gold-soft);
    border: 1px solid rgba(197, 155, 39, 0.25);
    color: var(--u-caution-ink);
    font-size: var(--u-font-xs);
    margin-bottom: var(--u-space-4);
}

.boundary-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--u-space-2);
    font-weight: 650;
}

.dot-sep {
    color: rgba(107, 82, 0, 0.55);
}

.boundary-msg {
    margin-top: 2px;
    line-height: 1.6;
}

.boundary-msg:empty {
    display: none;
}

/* 2×N 元信息网格（2026-09-19 定稿 6 项：塘口/水温溶氧/质检·绑蟹·打包责任人与同规格良品率） */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--u-space-2);
}

.meta-item {
    background: var(--u-surface-2);
    border: 1px solid var(--u-line);
    border-radius: var(--u-radius-s);
    padding: var(--u-space-3) var(--u-space-3);
    min-width: 0;
}

.meta-label {
    font-size: var(--u-font-xs);
    color: var(--u-ink-3);
    margin-bottom: 3px;
}

.meta-val {
    font-size: var(--u-font-s);
    font-weight: 650;
    color: var(--u-ink);
    word-break: break-all;
}

.meta-sep {
    color: var(--u-ink-3);
    font-weight: 400;
}

.box-hint {
    margin-top: var(--u-space-3);
    font-size: var(--u-font-xs);
    color: var(--u-ink-2);
    line-height: 1.6;
    word-break: break-all;
}

/* ==============================================================================
 * 扫码预警（alert=多扫风险 / calm=首扫与专属码口径）与存证链徽标
 * ============================================================================== */

.scan-warning {
    margin-top: var(--u-space-3);
    padding: var(--u-space-3) var(--u-space-4);
    border-radius: var(--u-radius-s);
    font-size: var(--u-font-xs);
    line-height: 1.65;
    border: 1px solid rgba(197, 155, 39, 0.4);
    background: var(--u-caution-soft);
    color: var(--u-caution-ink);
}

.scan-warning.alert {
    border-color: rgba(179, 38, 30, 0.35);
    background: var(--u-danger-soft);
    color: var(--u-danger-ink);
    font-weight: 600;
}

.evidence-line {
    margin-top: var(--u-space-3);
    padding: var(--u-space-3) var(--u-space-4);
    border-radius: 0 var(--u-radius-s) var(--u-radius-s) 0;
    border-left: 3px solid var(--u-gold);
    background: var(--u-gold-soft);
    color: var(--u-caution-ink);
    font-size: var(--u-font-xs);
    line-height: 1.65;
}

.evidence-line.broken {
    border-left-color: var(--u-danger);
    background: var(--u-danger-soft);
    color: var(--u-danger-ink);
    font-weight: 600;
}

/* ==============================================================================
 * 自定义时间线：2px 轨道 + 状态圆点，最新节点金色
 * ============================================================================== */

.timeline {
    list-style: none;
    position: relative;
    padding-left: var(--u-space-5);
}

/* 竖向轨道 */
.timeline::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    border-radius: 1px;
    background: linear-gradient(to bottom, rgba(15, 56, 44, 0.30), rgba(15, 56, 44, 0.10));
}

.timeline-item {
    position: relative;
    padding-bottom: var(--u-space-4);
}

.timeline-item:last-child {
    padding-bottom: 0;
}

/* 状态圆点：默认深绿描边空心，最新节点金色实心 + 光晕 */
.timeline-dot {
    position: absolute;
    left: calc(-1 * var(--u-space-5) + 1px);
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--u-surface);
    border: 2px solid var(--u-brand);
    box-shadow: 0 0 0 3px var(--u-surface);
}

.timeline-item.latest .timeline-dot {
    background: var(--u-gold);
    border-color: var(--u-gold);
    box-shadow: 0 0 0 3px var(--u-surface), 0 0 0 6px rgba(197, 155, 39, 0.18);
}

.timeline-body {
    background: var(--u-surface-2);
    border: 1px solid var(--u-line);
    border-radius: var(--u-radius-m);
    padding: var(--u-space-3) var(--u-space-4);
    transition: border-color var(--u-dur) var(--u-ease), box-shadow var(--u-dur) var(--u-ease);
}

.timeline-item.latest .timeline-body {
    border-color: rgba(197, 155, 39, 0.45);
    background: linear-gradient(180deg, #fffdf6, var(--u-surface-2));
    box-shadow: var(--u-shadow-1);
}

.timeline-item:not(.latest) .timeline-body:hover {
    border-color: rgba(197, 155, 39, 0.35);
}

.node-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px var(--u-space-2);
    margin-bottom: 3px;
}

.node-title {
    font-size: var(--u-font-s);
    font-weight: 700;
    color: var(--u-ink);
    min-width: 0;
}

/* 最新节点标题金色文字级 */
.timeline-item.latest .node-title {
    color: var(--u-gold-ink);
}

.node-status-tag {
    flex: 0 0 auto;
    font-size: var(--u-font-xs);
    font-weight: 600;
    padding: 2px 9px;
    border-radius: var(--u-radius-pill);
    background: rgba(197, 155, 39, 0.14);
    color: var(--u-gold-ink);
    border: 1px solid rgba(197, 155, 39, 0.25);
}

.node-time {
    font-size: var(--u-font-xs);
    color: var(--u-ink-3);
    margin-bottom: 4px;
}

.node-details {
    font-size: var(--u-font-xs);
    color: var(--u-ink-2);
    line-height: 1.65;
    margin-bottom: var(--u-space-2);
}

.node-footer {
    display: flex;
    justify-content: space-between;
    gap: var(--u-space-2);
    font-size: var(--u-font-xs);
    color: var(--u-ink-3);
    border-top: 1px dashed var(--u-line-strong);
    padding-top: var(--u-space-2);
}

.timeline-empty {
    padding: var(--u-space-5) var(--u-space-4);
    text-align: center;
    color: var(--u-ink-3);
    font-size: var(--u-font-s);
    background: var(--u-surface-2);
    border: 1px dashed var(--u-line-strong);
    border-radius: var(--u-radius-m);
}

/* ==============================================================================
 * 骨架屏加载态（shimmer；prefers-reduced-motion 下由令牌底座统一静止）
 * ============================================================================== */

.skeleton {
    display: grid;
    gap: var(--u-space-3);
}

.sk-row {
    height: 64px;
    border-radius: var(--u-radius-m);
    background: linear-gradient(100deg,
        rgba(27, 30, 33, 0.05) 35%,
        rgba(27, 30, 33, 0.09) 50%,
        rgba(27, 30, 33, 0.05) 65%);
    background-size: 240% 100%;
    animation: u-shimmer 1.4s ease infinite;
}

.sk-short {
    width: 62%;
    height: 40px;
}

@keyframes u-shimmer {
    from { background-position: 120% 0; }
    to { background-position: -120% 0; }
}

/* ==============================================================================
 * 同日批次 chips 与物流步进器
 * ============================================================================== */

.side-card {
    padding: var(--u-space-4);
}

.side-card-title {
    font-size: var(--u-font-s);
    font-weight: 700;
    color: var(--u-ink);
    margin-bottom: var(--u-space-3);
}

.logistics {
    list-style: none;
}

.logistics-milestone {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--u-space-3);
    padding: var(--u-space-2) 0 var(--u-space-2) 0;
    font-size: var(--u-font-s);
    border-bottom: 1px dashed var(--u-line);
}

.logistics-milestone:last-child {
    border-bottom: none;
}

/* 步进器圆点：done 实心深绿 / current 金色 / pending 空心 */
.milestone-state {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--u-line-strong);
    background: var(--u-surface);
}

.logistics-milestone.done .milestone-state {
    background: var(--u-brand);
    border-color: var(--u-brand);
    box-shadow: inset 0 0 0 2.5px var(--u-surface);
}

.logistics-milestone.current .milestone-state {
    background: var(--u-gold);
    border-color: var(--u-gold);
    box-shadow: 0 0 0 4px rgba(197, 155, 39, 0.16);
}

.logistics-milestone.pending {
    color: var(--u-ink-3);
}

.milestone-label {
    min-width: 0;
}

.logistics-milestone.current .milestone-label {
    font-weight: 650;
    color: var(--u-ink);
}

.milestone-time {
    margin-left: auto;
    font-size: var(--u-font-xs);
    color: var(--u-ink-3);
    white-space: nowrap;
}

.logistics-note {
    margin-top: var(--u-space-3);
    font-size: var(--u-font-xs);
    color: var(--u-ink-3);
    line-height: 1.65;
    padding-top: var(--u-space-3);
    border-top: 1px solid var(--u-line);
}

/* ==============================================================================
 * 底部信任区 + 隐私手风琴
 * ============================================================================== */

.trust-footer {
    text-align: center;
    padding: var(--u-space-4) 0 var(--u-space-5);
    color: var(--u-ink-3);
    font-size: var(--u-font-xs);
}

.trust-icons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--u-space-2) var(--u-space-5);
    margin-bottom: var(--u-space-4);
}

.trust-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--u-ink-2);
    font-weight: 550;
}

.trust-item svg {
    color: var(--u-brand);
}

.privacy-note {
    text-align: left;
    border: 1px solid var(--u-line);
    border-radius: var(--u-radius-s);
    background: var(--u-surface);
    padding: var(--u-space-3) var(--u-space-4);
    margin-bottom: var(--u-space-4);
}

.privacy-note summary {
    cursor: pointer;
    color: var(--u-brand);
    font-weight: 650;
    font-size: var(--u-font-xs);
}

.privacy-note p {
    margin-top: var(--u-space-2);
    line-height: 1.7;
    color: var(--u-ink-2);
}

.footer-copyright {
    color: var(--u-ink-2);
}

.footer-note {
    margin-top: var(--u-space-1);
    color: var(--u-ink-3);
}

/* ==============================================================================
 * 小屏适配：≤420px 时元信息网格收成单列、批次号缩小一档
 * ============================================================================== */

@media (max-width: 420px) {
    .meta-grid {
        grid-template-columns: 1fr;
    }

    .batch-no {
        font-size: var(--u-font-xl);
    }

    .search-btn {
        padding: 0 16px;
    }
}
