/**
 * common.css — 全站设计系统（金检票据 / 金库账本）
 * 用于：导航、页头、行情票证卡片、表格、页脚、响应式
 * 调色板：Vault Ink / Mist Paper / Aged Brass / Rise / Fall
 */

:root {
    /* 色彩 token */
    --ink: #121a22;
    --ink-soft: #2a3642;
    --mist: #eef1f4;
    --mist-deep: #e2e7ec;
    --paper: #f7f8fa;
    --brass: #9a7b3c;
    --brass-dim: #7a6230;
    --brass-glow: rgba(154, 123, 60, 0.22);
    --rise: #c23b3b;
    --fall: #1f7a62;
    --quiet: #5a6a78;
    --line: rgba(18, 26, 34, 0.12);
    --line-strong: rgba(18, 26, 34, 0.22);
    --shadow: 0 12px 40px rgba(18, 26, 34, 0.08);

    /* 字体：与 style/fonts.css 自托管包一致（Syne / Noto Sans SC / DM Mono） */
    --font-display: "Syne", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-data: "DM Mono", "IBM Plex Mono", ui-monospace, monospace;

    --radius: 2px;
    --max: 1120px;
    --header-h: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body.site-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background:
        linear-gradient(165deg, var(--mist) 0%, var(--paper) 45%, var(--mist-deep) 100%);
    background-attachment: fixed;
}

/* 背景细斜纹：像票据底纹，不抢内容 */
body.site-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    background-image:
        repeating-linear-gradient(
            -18deg,
            transparent,
            transparent 11px,
            rgba(154, 123, 60, 0.03) 11px,
            rgba(154, 123, 60, 0.03) 12px
        );
}

[hidden] {
    display: none !important;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 1rem;
    background: var(--ink);
    color: #fff;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
}

/* —— 顶栏 —— */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(247, 248, 250, 0.92);
    -webkit-backdrop-filter: blur(10px); /* Safari */
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.site-header__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 1.25rem;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--ink);
    flex-shrink: 0;
}

.brand__mark {
    width: 2.5rem;
    height: 2.5rem;
    display: grid;
    place-items: center;
    font-family: var(--font-data);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: var(--brass);
    border: 1.5px solid var(--brass);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(154, 123, 60, 0.08), transparent);
}

.brand__name {
    display: block;
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.06em;
}

.brand__tag {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.7rem;
    color: var(--quiet);
    letter-spacing: 0.12em;
}

.nav-toggle {
    display: none;
    margin-left: auto;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line-strong);
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.nav-toggle__bar {
    display: block;
    width: 18px;
    height: 1.5px;
    background: var(--ink);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:first-child {
    transform: translateY(3.75px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:last-child {
    transform: translateY(-3.75px) rotate(-45deg);
}

.site-nav {
    flex: 1;
    min-width: 0;
}

.site-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.15rem;
    justify-content: flex-end;
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 0.7rem;
    text-decoration: none;
    color: var(--ink-soft);
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
}

.site-nav__link::after {
    content: "";
    position: absolute;
    left: 0.7rem;
    right: 0.7rem;
    bottom: 0.55rem;
    height: 1.5px;
    background: var(--brass);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.28s ease;
}

.site-nav__link:hover,
.site-nav__link:focus-visible {
    color: var(--ink);
    outline: none;
}

.site-nav__link:hover::after,
.site-nav__link:focus-visible::after,
.site-nav__link.is-active::after {
    transform: scaleX(1);
}

.site-nav__link.is-active {
    color: var(--ink);
    font-weight: 600;
}

/* —— 主内容 —— */
.site-main {
    position: relative;
    z-index: 1;
    flex: 1;
    width: 100%;
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
}

/* 页头：金检票据条（标题区居中，突出「看价」） */
.page-hero {
    margin-bottom: 1.75rem;
    padding: 1.25rem 0 1.5rem;
    border-bottom: 1px solid var(--line);
    text-align: center;
    animation: hero-in 0.55s ease both;
}

.page-hero__assay {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.page-hero__code {
    font-family: var(--font-data);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--brass);
    padding: 0.2rem 0.45rem;
    border: 1px solid var(--brass);
}

.page-hero__stamp {
    font-family: var(--font-data);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    color: var(--quiet);
}

.page-hero__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.85rem, 4vw, 2.6rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.02em;
    color: var(--ink);
}

.page-hero__lead {
    margin: 0.65rem auto 0;
    max-width: 36em;
    color: var(--quiet);
    font-size: 0.95rem;
}

.page-hero__meta {
    margin: 1rem 0 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--quiet);
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--fall);
    box-shadow: 0 0 0 0 rgba(31, 122, 98, 0.45);
    animation: pulse-dot 2s ease infinite;
}

/* —— 行情票证网格 —— */
.ticket-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .ticket-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .ticket-grid--single {
        grid-template-columns: minmax(0, 560px);
        justify-content: center;
    }
}

@media (min-width: 1025px) {
    .ticket-grid:not(.ticket-grid--single) {
        grid-template-columns: repeat(3, 1fr);
    }
}

.ticket {
    position: relative;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: ticket-in 0.5s ease both;
}

.ticket:nth-child(2) { animation-delay: 0.08s; }
.ticket:nth-child(3) { animation-delay: 0.16s; }

/* 裁切标记：像化验单四角 */
.ticket::before,
.ticket::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: var(--brass);
    border-style: solid;
    opacity: 0.55;
    pointer-events: none;
}

.ticket::before {
    top: 8px;
    left: 8px;
    border-width: 1.5px 0 0 1.5px;
}

.ticket::after {
    top: 8px;
    right: 8px;
    border-width: 1.5px 1.5px 0 0;
}

.ticket__inner {
    padding: 1.35rem 1.25rem 1.2rem;
    position: relative;
}

.ticket__watermark {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-55%);
    font-family: var(--font-display);
    font-size: 5.5rem;
    font-weight: 700;
    color: var(--brass);
    opacity: 0.07;
    line-height: 1;
    pointer-events: none;
    -webkit-user-select: none; /* Safari */
    user-select: none;
}

/* 票证标题与大价签居中：第一眼看价 */
.ticket__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
}

.ticket__sub {
    margin: 0.25rem 0 0;
    font-size: 0.78rem;
    color: var(--quiet);
    text-align: center;
}

.ticket__price {
    margin: 1.1rem 0 0.35rem;
    font-family: var(--font-data);
    font-size: clamp(1.85rem, 3.5vw, 2.35rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.ticket__change {
    font-family: var(--font-data);
    font-size: 0.9rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.price-up { color: var(--rise); }
.price-down { color: var(--fall); }
.price-neutral { color: var(--quiet); }

.ticket__price.is-flash-up {
    animation: flash-up 0.45s ease;
}

.ticket__price.is-flash-down {
    animation: flash-down 0.45s ease;
}

.ticket__stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem 1rem;
    margin-top: 1.1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--line);
    text-align: center;
}

.ticket__stat {
    font-size: 0.78rem;
    color: var(--quiet);
    text-align: center;
}

.ticket__stat strong {
    display: block;
    margin-top: 0.15rem;
    font-family: var(--font-data);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.ticket__time {
    margin-top: 0.85rem;
    font-size: 0.72rem;
    color: var(--quiet);
    text-align: center;
}

.ticket__chart {
    margin-top: 1rem;
    border: 1px solid var(--line);
    background: #fff;
    line-height: 0;
}

.ticket__chart img {
    width: 100%;
    height: auto;
    display: block;
}

/* 品牌/金条小票证（多列） */
.brand-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .brand-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .brand-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.brand-ticket {
    background: var(--paper);
    border: 1px solid var(--line-strong);
    padding: 1.1rem 1.15rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    animation: ticket-in 0.45s ease both;
}

.brand-ticket__name {
    margin: 0 0 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--line);
}

.brand-ticket__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: var(--quiet);
}

.brand-ticket__row strong {
    font-family: var(--font-data);
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.brand-ticket__time {
    margin-top: 0.65rem;
    font-size: 0.72rem;
    color: var(--quiet);
}

/* —— 行情表格（纸黄金） —— */
.table-panel {
    background: var(--paper);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table-panel__head {
    padding: 0.9rem 1.15rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(154, 123, 60, 0.08), transparent);
}

/* 标题后统一单位，如（元/克） */
.table-panel__unit {
    font-weight: 500;
    color: var(--quiet);
    margin-left: 0.15rem;
}

.table-scroll {
    overflow-x: auto;
}

.quote-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

.quote-table th,
.quote-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 0.88rem;
}

/* 更新时间等字段不换行（手机横滑表尤其需要） */
.quote-table th:last-child,
.quote-table td:last-child {
    white-space: nowrap;
    min-width: 9.75rem;
}

.quote-table th {
    font-weight: 600;
    color: var(--quiet);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    background: rgba(238, 241, 244, 0.6);
}

.quote-table td:nth-child(n+3) {
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
}

.quote-table tbody tr:hover {
    background: rgba(154, 123, 60, 0.05);
}

/* 手机：纸黄金隐藏「货币单位」列，仅固定第一列，右侧可横向滑动 */
@media (max-width: 767px) {
    .paper-gold-page .quote-table {
        --sticky-col1: 8.5rem;
        min-width: 42rem;
        border-collapse: separate;
        border-spacing: 0;
    }

    .paper-gold-page .quote-table th,
    .paper-gold-page .quote-table td {
        border-bottom: 1px solid var(--line);
    }

    /* 货币单位列：各行单位不同，手机端隐藏以省宽 */
    .paper-gold-page .quote-table th:nth-child(2),
    .paper-gold-page .quote-table td:nth-child(2) {
        display: none;
    }

    .paper-gold-page .quote-table th:nth-child(1),
    .paper-gold-page .quote-table td:nth-child(1) {
        position: sticky;
        left: 0;
        z-index: 2;
        min-width: var(--sticky-col1);
        max-width: var(--sticky-col1);
        white-space: nowrap;
        background: var(--paper);
        box-shadow: 6px 0 8px -6px rgba(18, 26, 34, 0.18);
        padding-left: 0.75rem;
        padding-right: 0.65rem;
    }

    .paper-gold-page .quote-table th:nth-child(1) {
        z-index: 3;
        background: #eef1f4;
    }

    .paper-gold-page .quote-table tbody tr:hover td:nth-child(1) {
        background: #f5f2eb;
    }

    /* 实物黄金 / 金条：仅第一列（交易品种）固定 */
    .physical-gold-page .quote-table,
    .gold-bars-page .quote-table {
        --sticky-col1: 9.5rem;
        min-width: 36rem;
        border-collapse: separate;
        border-spacing: 0;
    }

    .physical-gold-page .quote-table th,
    .physical-gold-page .quote-table td,
    .gold-bars-page .quote-table th,
    .gold-bars-page .quote-table td {
        border-bottom: 1px solid var(--line);
    }

    .physical-gold-page .quote-table th:nth-child(1),
    .physical-gold-page .quote-table td:nth-child(1),
    .gold-bars-page .quote-table th:nth-child(1),
    .gold-bars-page .quote-table td:nth-child(1) {
        position: sticky;
        left: 0;
        z-index: 2;
        min-width: var(--sticky-col1);
        max-width: var(--sticky-col1);
        white-space: nowrap;
        background: var(--paper);
        box-shadow: 6px 0 8px -6px rgba(18, 26, 34, 0.18);
        padding-left: 0.75rem;
        padding-right: 0.65rem;
    }

    .physical-gold-page .quote-table th:nth-child(1),
    .gold-bars-page .quote-table th:nth-child(1) {
        z-index: 3;
        background: #eef1f4;
    }

    .physical-gold-page .quote-table tbody tr:hover td:nth-child(1),
    .gold-bars-page .quote-table tbody tr:hover td:nth-child(1) {
        background: #f5f2eb;
    }
}

/* —— 状态 —— */
.state-box {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--quiet);
}

.state-box--error {
    color: var(--rise);
}

.spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto 0.85rem;
    border: 2px solid var(--line-strong);
    border-top-color: var(--brass);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* —— 页脚 —— */
.site-footer {
    position: relative;
    z-index: 1;
    border-top: 1px solid var(--line);
    background: rgba(247, 248, 250, 0.85);
    margin-top: auto;
}

.site-footer__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.75rem 1.25rem 2.25rem;
    text-align: center;
}

.sister-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem 1.15rem;
    margin-bottom: 1.25rem;
}

.sister-links a {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.88rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.sister-links a:hover,
.sister-links a:focus-visible {
    color: var(--brass-dim);
    outline: none;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.site-footer__disclaimer {
    margin: 0;
    font-size: 0.82rem;
    color: var(--quiet);
    max-width: 40em;
    margin-inline: auto;
}

.site-footer__copy {
    margin: 0.65rem 0 0;
    font-size: 0.75rem;
    color: var(--quiet);
}

/* —— 动画 —— */
@keyframes hero-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes ticket-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(31, 122, 98, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(31, 122, 98, 0); }
    100% { box-shadow: 0 0 0 0 rgba(31, 122, 98, 0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes flash-up {
    0%, 100% { background: transparent; }
    40% { background: rgba(194, 59, 59, 0.15); }
}

@keyframes flash-down {
    0%, 100% { background: transparent; }
    40% { background: rgba(31, 122, 98, 0.15); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .live-dot {
        animation: none;
    }
}

/* —— 手机导航 —— */
@media (max-width: 767px) {
    .nav-toggle {
        display: flex;
    }

    .site-nav {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        background: var(--paper);
        border-bottom: 1px solid var(--line);
        padding: 0.5rem 1.25rem 1rem;
        box-shadow: var(--shadow);
    }

    .site-nav.is-open {
        display: block;
    }

    .site-nav__list {
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
    }

    .site-nav__link {
        width: 100%;
        padding: 0.65rem 0.5rem;
    }

    .site-nav__link::after {
        display: none;
    }

    .site-nav__link.is-active {
        color: var(--brass-dim);
        border-left: 2px solid var(--brass);
        padding-left: 0.65rem;
    }

    .brand__tag {
        display: none;
    }
}

/* Pad：导航可横向滚动，避免挤成一团 */
@media (min-width: 768px) and (max-width: 1024px) {
    .site-nav__list {
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 0.15rem;
    }

    .site-nav__link {
        white-space: nowrap;
    }
}
