/**
 * common.css — 全站公共样式
 * 用途：导航、页脚、容器、加油机价牌、数据表、加载态
 * 设计：浅色内容区 + 琥珀强调 + 油品四色编码（顶栏/页脚保持深色品牌条）
 */

/* ---------- 设计令牌 ---------- */
:root {
    --night-road: #0e1419;
    --asphalt: #0e1419;
    --asphalt-mid: #1a2633;
    --led-gold: #f5a623;
    --led-gold-dim: #c4841a;
    /* 兼容旧变量名 */
    --pump-amber: #f5a623;
    --pump-amber-dim: #c4841a;
    --canopy-light: #f7f5f0;
    --slate-bg: #eceff3;
    --ink: #141c26;
    --muted: #5c6b7a;
    --diesel-teal: #5a6878;
    --grade-92: #f5a623;
    --grade-95: #5b8def;
    --grade-98: #2ec4b6;
    --grade-diesel: #6b7785;
    --surface: #ffffff;
    --line: #d8e0ea;
    --radius: 8px;
    --radius-lg: 12px;
    --max: 1100px;
    /* 自托管：Syne 标题 / Noto Sans SC 正文 / DM Mono 价格数字（见 style/fonts.css） */
    --font-display: "Syne", "Noto Sans SC", sans-serif;
    --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-data: "DM Mono", "Noto Sans SC", monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background:
        radial-gradient(ellipse 70% 45% at 50% -5%, rgba(245, 166, 35, 0.07), transparent 55%),
        linear-gradient(180deg, #e8ecf1 0%, var(--slate-bg) 120px);
    min-height: 100vh;
}

a {
    color: var(--asphalt-mid);
    text-decoration: none;
}

a:hover {
    color: var(--pump-amber-dim);
}

a:focus-visible,
button:focus-visible,
select:focus-visible {
    outline: 2px solid var(--pump-amber);
    outline-offset: 2px;
}

/* ---------- 顶栏 ---------- */
.site-header {
    background: var(--night-road);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 4px 20px rgba(8, 12, 18, 0.4);
}

.site-header__inner {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.04em;
}

.brand:hover {
    color: var(--pump-amber);
}

.brand:hover .brand__mark {
    filter: brightness(1.08);
}

/* 加油枪品牌图标 */
.brand__mark {
    display: block;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 6px;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.28);
}

/* 顶栏栏目：国内油价 / 国际油价 */
.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 0.85rem;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 6px;
    white-space: nowrap;
}

.site-nav__link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.site-nav__link.is-active {
    color: var(--led-gold);
    background: rgba(245, 166, 35, 0.12);
}

/* ---------- 主区 ---------- */
.site-main {
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.25rem 1rem 1rem;
}

/* ---------- 页脚 ---------- */
.site-footer {
    background: var(--night-road);
    color: rgba(255, 255, 255, 0.68);
    padding: 1.25rem 1rem 1.5rem;
    margin-top: 1.5rem;
}

.site-footer__inner {
    max-width: var(--max);
    margin: 0 auto;
}

.sister-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1.1rem;
    justify-content: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sister-links a {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.sister-links a:hover {
    color: var(--pump-amber);
}

.site-footer__disclaimer {
    font-size: 0.75rem;
    line-height: 1.6;
    margin: 0 0 0.65rem;
    opacity: 0.85;
    text-align: center;
}

.site-footer__disclaimer strong {
    color: var(--pump-amber);
}

.site-footer__copy {
    font-size: 0.8rem;
    opacity: 0.65;
    margin: 0;
    text-align: center;
}

/* ---------- 面板 / 区块 ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

/* 主区内最后一块面板：去掉底部外边距，避免与页脚之间空隙过大 */
.site-main > .panel:last-child {
    margin-bottom: 0;
}

.panel__head {
    background: linear-gradient(180deg, #fafbfc 0%, #f3f6f9 100%);
    color: var(--ink);
    padding: 0.85rem 1.1rem;
    font-family: var(--font-display);
    font-weight: 650;
    font-size: 1rem;
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--line);
}

/* 标题左 + 更新日期右（首页油价表） */
.panel__head--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.panel__meta {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0;
    color: var(--muted);
    white-space: nowrap;
}

.panel__meta time {
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
    color: var(--led-gold-dim);
}

.panel__body {
    padding: 1.1rem;
}

/* ---------- 加油机价牌（签名：浅底 + 油品四色数字） ---------- */
.pump-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.pump-cell {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.85rem 0.65rem;
    text-align: center;
    color: var(--ink);
    position: relative;
    overflow: hidden;
    animation: pump-in 0.55s ease both;
}

.pump-cell:nth-child(2) { animation-delay: 0.06s; }
.pump-cell:nth-child(3) { animation-delay: 0.12s; }
.pump-cell:nth-child(4) { animation-delay: 0.18s; }

.pump-cell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.pump-cell--92::before { background: var(--grade-92); }
.pump-cell--95::before { background: var(--grade-95); }
.pump-cell--98::before { background: var(--grade-98); }
.pump-cell--diesel::before { background: var(--grade-diesel); }

.pump-cell__grade {
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.pump-cell__price {
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
    font-size: clamp(1.35rem, 3.5vw, 1.85rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.pump-cell--92 .pump-cell__price { color: var(--grade-92); }
.pump-cell--95 .pump-cell__price { color: var(--grade-95); }
.pump-cell--98 .pump-cell__price { color: var(--grade-98); }
.pump-cell--diesel .pump-cell__price { color: var(--grade-diesel); }

.pump-cell__region {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pump-cell__unit {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 0.2rem;
}

@keyframes pump-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pump-cell {
        animation: none;
    }
}

/* ---------- 表格 ---------- */
.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px; /* 首页多列表用；内页两列用 .data-table--compact */
}

/* 内页油品/价格两列表：自适应宽度，禁止左右滑动 */
.data-table--compact {
    min-width: 0;
    table-layout: fixed;
}

.data-table--compact th,
.data-table--compact td {
    padding: 0.65rem 0.5rem;
    font-size: 0.9rem;
    word-break: break-all;
}

.data-table th,
.data-table td {
    padding: 0.75rem 0.65rem;
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.data-table th {
    background: #f3f6fa;
    font-size: 0.875rem;
    font-weight: 650;
    color: var(--muted);
}

.data-table td {
    font-variant-numeric: tabular-nums;
}

.data-table a {
    font-weight: 650;
    color: var(--ink);
}

.data-table a:hover {
    color: var(--pump-amber-dim);
}

.price-92 { color: var(--grade-92); font-weight: 600; }
.price-95 { color: var(--grade-95); font-weight: 600; }
.price-98 { color: var(--grade-98); font-weight: 600; }
.price-diesel { color: var(--grade-diesel); font-weight: 600; }

/* ---------- 城市链接网格 ---------- */
.city-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.55rem;
}

.city-grid a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 0.65rem;
    background: #f3f6fa;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    font-size: 0.9rem;
    text-align: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.city-grid a:hover {
    background: var(--asphalt);
    border-color: var(--asphalt);
    color: var(--pump-amber);
}

/* ---------- 状态 ---------- */
.loading-state,
.error-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

/* 保证 hidden 不被其它 display 规则盖住 */
.loading-state[hidden],
.error-state[hidden],
.guoji-board[hidden] {
    display: none !important;
}

.loading-state__spinner {
    width: 2rem;
    height: 2rem;
    margin: 0 auto 0.85rem;
    border: 3px solid var(--line);
    border-top-color: var(--pump-amber);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .loading-state__spinner {
        animation: none;
        border-top-color: var(--line);
    }
}

.summary-text {
    text-align: center;
    color: var(--muted);
    margin: 0 0 1.1rem;
    line-height: 1.7;
}

/* ---------- 响应式 ---------- */
@media (max-width: 767px) {
    .site-header__inner {
        justify-content: space-between;
        gap: 0.5rem;
    }

    .site-main {
        padding-bottom: 0.75rem;
    }

    .pump-board {
        grid-template-columns: repeat(2, 1fr);
    }

    .city-grid {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .pump-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 无障碍：视觉隐藏、保留给读屏 */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.panel__body--flush {
    padding: 0;
}

.mt-md {
    margin-top: 1.1rem;
}
