/* ============================================================
   游戏卡密商城 · 前台样式
   单文件、零依赖，移动端优先。
   ============================================================ */

:root {
    --brand: #2f6bff;
    --brand-dark: #1f4fd0;
    --brand-soft: #eef3ff;
    --ok: #0f9d58;
    --ok-soft: #e8f7ef;
    --warn: #b7791f;
    --warn-soft: #fdf6e3;
    --danger: #d93025;
    --danger-soft: #fdecea;
    --ink: #1b1f27;
    --ink-2: #4a5361;
    --ink-3: #7b8698;
    --line: #e4e8f0;
    --bg: #f5f7fb;
    --card: #ffffff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(20, 32, 60, .05), 0 6px 20px rgba(20, 32, 60, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    font-size: 15px;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 全局可见的键盘焦点环，不为了美观牺牲可访问性 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ---------------------------------------------------------- 顶部导航 */

.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--ink);
    letter-spacing: .2px;
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--brand); }

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-wrap: wrap;
}

.nav a, .nav button {
    display: inline-block;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 14px;
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
}
.nav a:hover, .nav button:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
    text-decoration: none;
}
.nav .badge-dot {
    display: inline-block;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    margin-left: 4px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    line-height: 17px;
    text-align: center;
    vertical-align: 1px;
}

/* ---------------------------------------------------------- 横幅公告 */

.announce-bar {
    background: var(--warn-soft);
    border-bottom: 1px solid #f0e2bd;
    color: var(--warn);
    font-size: 14px;
}
.announce-bar .container { padding-top: 8px; padding-bottom: 8px; }
.announce-bar strong { margin-right: 6px; }

/* ---------------------------------------------------------- 教程区 */

/* 网站上方预留的教程位置：内容全部来自后台「公告 / 教程」的 tutorial 项 */
.tutorial-zone { padding: 20px 0 4px; }

.tutorial-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.tutorial-card + .tutorial-card { margin-top: 12px; }
.tutorial-card h2 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--ink);
}
.tutorial-card .body { color: var(--ink-2); font-size: 14px; }
.tutorial-card .body p:first-child { margin-top: 0; }
.tutorial-card .body p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------- 通用块 */

.page-title {
    font-size: 20px;
    margin: 22px 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.page-title .sub { font-size: 13px; color: var(--ink-3); font-weight: 400; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.card h3 { margin-top: 0; }

/* ---------------------------------------------------------- 商品 */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 14px;
}

.product-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.product-card h3 { margin: 0; font-size: 16px; }
.product-card .desc { color: var(--ink-2); font-size: 14px; margin: 0; flex: 1; }

/* 商品图片。
   aspect-ratio + object-fit 保证不同尺寸的图都能整齐地对齐，
   不会因为谁传了竖图就把整行卡片撑变形。 */
.product-img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg);
}

.product-hero {
    display: block;
    width: 100%;
    max-width: 460px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--bg);
    margin-bottom: 16px;
}

.price-row { display: flex; align-items: baseline; gap: 8px; }
.price {
    color: var(--danger);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
}
.price .unit { font-size: 15px; font-weight: 600; }
.price-face { color: var(--ink-3); font-size: 13px; text-decoration: line-through; }

.stock { font-size: 13px; color: var(--ink-3); }
.stock.low { color: var(--warn); }
.stock.out { color: var(--danger); }

/* ---------------------------------------------------------- 按钮 */

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    line-height: 1.4;
    transition: background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f2c3bf; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-block { display: block; width: 100%; }
.btn:disabled, .btn[disabled] {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ---------------------------------------------------------- 表单 */

.field { margin-bottom: 15px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 6px;
}
/* 文本类输入框统一外观。
   注意：不要再用「逐个列 type」的写法 —— 之前只列了 text/password/number，
   加了邮箱注册后 type=email 漏网，高度退回浏览器默认值，比密码框矮一截。
   这里改成「排除法」，以后再加任何文本类 widget 都自动继承。 */
.field input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]):not([type=button]):not([type=range]):not([type=color]):not([type=image]),
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
}
.field input:focus, .field textarea:focus { border-color: var(--brand); }
.field .help { font-size: 12px; color: var(--ink-3); margin-top: 5px; }
.field .errors { color: var(--danger); font-size: 13px; margin-top: 5px; }
.field .errors ul { margin: 0; padding-left: 18px; }

/* ---------------------------------------------------------- 消息提示 */

.messages { padding-top: 14px; }
.msg {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}
.msg-success { background: var(--ok-soft); color: #0b6b3d; border-color: #bfe6d0; }
.msg-error   { background: var(--danger-soft); color: #9b1c14; border-color: #f2c3bf; }
.msg-warning { background: var(--warn-soft); color: #8a5b0f; border-color: #f0e2bd; }
.msg-info    { background: var(--brand-soft); color: var(--brand-dark); border-color: #ccdcff; }

/* ---------------------------------------------------------- 状态徽标 */

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.pill-pending      { background: #eef0f4; color: #5a6472; }
.pill-reviewing    { background: var(--warn-soft); color: var(--warn); }
.pill-review_failed{ background: var(--danger-soft); color: var(--danger); }
.pill-paid         { background: var(--brand-soft); color: var(--brand-dark); }
.pill-shipping     { background: #f3ecff; color: #6b3fd4; }
.pill-shipped      { background: var(--ok-soft); color: var(--ok); }
.pill-cancelled    { background: #eef0f4; color: var(--ink-3); }
.pill-refunded     { background: #eef0f4; color: var(--ink-3); }

/* ---------------------------------------------------------- 步骤指引 */

.steps { counter-reset: step; margin: 0; padding: 0; list-style: none; }
.steps li {
    position: relative;
    padding-left: 40px;
    padding-bottom: 16px;
    counter-increment: step;
}
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 1px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 14px;
    line-height: 26px;
    text-align: center;
}
/* 竖线连接各步骤，最后一步不画 */
.steps li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 12.5px;
    top: 30px;
    bottom: 4px;
    width: 1px;
    background: var(--line);
}
.steps .step-title { font-weight: 600; }
.steps .step-desc { color: var(--ink-2); font-size: 14px; }

/* 关键信息（订单号后 6 位）高亮 */
.key-code {
    display: inline-block;
    padding: 3px 10px;
    background: var(--warn-soft);
    border: 1px dashed #e0c579;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #8a5b0f;
}

/* ---------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data th, table.data td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data th {
    color: var(--ink-3);
    font-weight: 600;
    font-size: 13px;
    background: #fafbfe;
    white-space: nowrap;
}
table.data tr:last-child td { border-bottom: 0; }

/* ---------------------------------------------------------- 详情列表 */

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); word-break: break-all; }

/* 卡密显示：等宽 + 可一键全选 */
.card-secret {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #0b6b3d;
    background: var(--ok-soft);
    border: 1px dashed #a8d9bf;
    border-radius: var(--radius-sm);
    padding: 14px;
    word-break: break-all;
    user-select: all;
    text-align: center;
}

/* ---------------------------------------------------------- 空状态 */

.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--ink-3);
}
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------------------------------------------------------- 页脚 */

.site-footer {
    margin-top: 40px;
    padding: 24px 0 32px;
    border-top: 1px solid var(--line);
    color: var(--ink-3);
    font-size: 13px;
    background: var(--card);
}
.site-footer .body { color: var(--ink-2); }
.site-footer p:first-child { margin-top: 0; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer .meta { margin-top: 12px; line-height: 1.9; }

/* 筛选标签 */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a {
    padding: 5px 12px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 13px;
}
.tabs a:hover { text-decoration: none; border-color: var(--brand); color: var(--brand-dark); }
.tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.inline-form { display: inline; }

/* 小屏适配 */
@media (max-width: 520px) {
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dd { margin-bottom: 8px; }
    .price { font-size: 21px; }
    .nav { gap: 0; }
    .nav a, .nav button { padding: 6px 8px; font-size: 13px; }
}
