/* ============================================================
   我推的汉字 · 2026
   原型样式（纯前端，演示数据）
   ============================================================ */

/* ============================================================
   字体
   三款字体都已子集化，见 tools/subset-fonts.py
   英文 → 江城圆体（只含 ASCII）  中文 → 思源黑体（400/700）
   引言 → 鸿雷行书（只有那 9 个字）
   同一个字体栈里浏览器按字符逐个回退，所以英文自动走江城、中文自动走思源
   ============================================================ */
@font-face {
    font-family: "HZYuan";
    src: url("yuan-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "HZYuan";
    src: url("yuan-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "HZHei";
    src: url("hei-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "HZHei";
    src: url("hei-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "HZXing";
    src: url("xing-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    /* 江城圆体在前，但它只有英文，所以中文字符会回退到思源黑体 */
    --font-body: "HZYuan", "HZHei", -apple-system, BlinkMacSystemFont, "Segoe UI",
                 Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
                 Helvetica, Arial, sans-serif;
    --font-brush: "HZXing", "HZHei", "Kaiti SC", "KaiTi", "Songti SC", serif;
}

:root {
    /* 只有浅色一套配色。
       only light 会禁止浏览器（尤其是 Chrome / Edge 的强制夜间模式）改写配色，
       否则底色会被算法倒成深灰、卡片发黑、输入框也变深。
       meta 里同样声明了一次，两处都写是为了首屏就有、不等 CSS */
    color-scheme: only light;

    --bg: #f4f7f6;
    --card: #ffffff;
    --ink: #222a2a;
    --muted: #4d5757;
    --line: #e6eceb;

    /* 主题色：默认取主页“我推的汉字”按钮的青色 */
    --accent: #21B2AB;
    --accent-deep: #17827D;      /* 承载白字时用这一档，对比度 4.65:1 */
    --accent-lite: #238F8A;      /* 标题下面那行英文：同色系浅一档 */
    --accent-soft: rgba(33, 178, 171, 0.12);
    --accent-line: rgba(33, 178, 171, 0.35);

    --brand: #CD2626;
    --shadow: 0 18px 50px rgba(20, 40, 40, 0.10);
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    /* 底部固定状态栏占的高度，body 用它留白 */
    --bar-h: 68px;
    /* 时间轴中间那一列的宽度，两处对齐都靠它 */
    --tb-mid: 92px;
}

/* 投稿截止后 → 揭榜 → 之后，主题切品牌红 */
html[data-phase="red"] {
    --accent: #CD2626;
    --accent-deep: #A81E1E;
    --accent-lite: #C44646;
    --accent-soft: rgba(205, 38, 38, 0.10);
    --accent-line: rgba(205, 38, 38, 0.28);
}

* { box-sizing: border-box; }

/* 关键：.form 等元素自己设了 display，会盖掉 [hidden] 的默认 display:none，
   所以统一在这里强制一次 */
[hidden] { display: none !important; }

html {
    /* 整体字号基准：页面里所有 rem 都按这个缩放 */
    font-size: 17px;
    -webkit-text-size-adjust: 100%;
}

html, body { margin: 0; padding: 0; }

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* 给固定的底部状态栏留出位置，否则内容会被压在它下面 */
    padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
    font-family: var(--font-body);
    color: var(--ink);
    background-color: var(--bg);
    background-image:
        radial-gradient(1200px 800px at 12% -10%, rgba(33, 178, 171, 0.07), transparent 55%),
        radial-gradient(1000px 700px at 105% 15%, rgba(205, 38, 38, 0.05), transparent 55%),
        radial-gradient(900px 900px at 50% 120%, rgba(105, 132, 211, 0.06), transparent 55%);
    background-attachment: fixed;
    /* 用 clip 而不是 hidden：hidden 会创建滚动容器，让下面的 sticky 失效 */
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部品牌条 ---------- */
.brand-bar {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 12px;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
}

/* 高度跟随右侧标题块（stretch + object-fit），保证图标与两行标题同高 */
.brand-mark {
    display: block;
    flex: 0 0 auto;
    width: 40px;
    object-fit: contain;
    object-position: center;
}

.brand-text {
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    line-height: 1.15;
}

.brand-title {
    display: block;
    font-size: 1.26rem;
    font-weight: 700;
    letter-spacing: 1.6px;
    text-indent: 1.6px;
}

.brand-title i {
    font-style: normal;
    margin: 0 5px;
    opacity: 0.62;
    font-weight: 400;
    letter-spacing: 0;
    text-indent: 0;
}

.brand-en {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.3px;
    opacity: 0.92;
}

/* ---------- 底部状态栏（常驻贴底） ---------- */
.status-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 8px 16px 10px;
    background: var(--accent);
    color: #fff;
    text-align: center;
    /* iPhone 底部安全区 */
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

.status-bar .count {
    margin: 0;
    font-size: 0.94rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    font-variant-numeric: tabular-nums;
}

.status-bar .count b {
    font-size: 1.08rem;
    letter-spacing: 0.6px;
}

.status-bar .credit {
    margin: 3px 0 0;
    font-size: 0.72rem;
    letter-spacing: 0.2px;
    opacity: 0.88;
}

/* 演示标记：一个描边小胶囊，明显但不喧宾夺主 */
.status-bar .credit em {
    font-style: normal;
    margin-left: 5px;
    padding: 1px 7px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 999px;
    font-size: 0.9em;
    letter-spacing: 0.4px;
}

/* 阶段切换时，品牌条和状态栏跟着换色 */
html[data-phase="red"] .brand-bar,
html[data-phase="red"] .status-bar {
    background: var(--brand);
}

/* ---------- 版心 ---------- */
.wrap {
    flex: 1;
    /* 必须显式给宽度：flex 子项有 auto 外边距时不会被拉伸，
       否则版心会缩成内容宽度，窄屏两侧空一大片 */
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 22px 16px 40px;
}

.card {
    background: var(--card);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 34px 26px 28px;
    text-align: center;
}

/* ---------- 首页海报 ---------- */
.poster {
    flex: 1;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 10px 18px 20px;
}

/* 书法体引言 */
.slogan {
    margin: 2px 0 8px;
    font-family: var(--font-brush);
    font-size: clamp(1.5rem, 6.4vw, 1.92rem);
    font-weight: 700;
    letter-spacing: 2px;
    text-indent: 2px;
    text-align: center;
    text-wrap: balance;
    color: #5c6866;
}

.slogan .hit {
    font-size: 1.26em;
    color: #4c5858;
}

.slogan-en {
    margin: 0 0 14px;
    font-size: 0.78rem;
    line-height: 1.55;
    text-align: center;
    color: #5a6665;
    letter-spacing: 0.2px;
}
/* 英文里点一下“Hanzi”，跟中文那一个「字」呼应 */
.slogan-en .hit {
    font-size: 1.06em;
    font-weight: 700;
    color: #4c5858;
}

/* 渐变丝带：取色自设计稿原图（蓝 #1781B5 → 黄 #FDBA07 → 绿 #207F4C） */
.ribbon {
    height: 13px;
    margin: 9px 0;
    background: linear-gradient(90deg,
        #1781B5 0%, #1781B5 25%,
        #FDBA07 50%,
        #207F4C 75%, #207F4C 100%);
    clip-path: polygon(1.8% 0, 100% 0, 98.2% 100%, 0 100%);
}

.intro {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.78;
    color: #242c2c;
    letter-spacing: 0.2px;
}

/* 时间块 */
.timeblock { text-align: center; }

.tb-title {
    margin: 0 0 8px;
    font-size: 1.08rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-indent: 1px;
    color: var(--ink);
}

.tb-title span {
    display: block;
    margin: 3px 0 0;
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.2px;
    color: #5f6a69;
}

.tb-row {
    display: grid;
    grid-template-columns: 1fr var(--tb-mid) 1fr;
    align-items: stretch;
}

.tb-row.two {
    /* 竖线落在 50% + 半个中列处，正好与三栏那一行的第二条竖线对齐 */
    grid-template-columns: calc(50% + var(--tb-mid) / 2) 1fr;
}

.tb-cell { padding: 0 6px; }

.tb-cell .year {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #222a2a;
}

.tb-cell .day {
    margin: 0 0 7px;
    font-size: 1.26rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #1f2626;
}

.tb-cell .solar {
    margin: 0;
    padding-top: 6px;
    border-top: 1.5px solid #222a2a;
    font-size: 0.72rem;
    letter-spacing: 0.2px;
    color: #48524f;
}

.tb-mid {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    border-left: 1.5px solid #222a2a;
    border-right: 1.5px solid #222a2a;
    font-variant-numeric: tabular-nums;
}

.tb-row.two .tb-mid { border-right: 0; }

.tb-mid .tz {
    font-size: 0.72rem;
    font-weight: 600;
    color: #525d5c;
}

.tb-mid .hm {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1f2626;
}

/* ---------- 按钮 ---------- */
.cta-stack {
    display: grid;
    gap: 12px;
    /* 按设计稿，按钮约半幅宽、居中 */
    max-width: 236px;
    margin: 18px auto 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    font-family: inherit;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.24s var(--ease), filter 0.24s var(--ease),
                background-color 0.24s var(--ease), color 0.24s var(--ease);
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:focus-visible {
    outline: 2px solid #24393b;
    outline-offset: 3px;
}

.btn.primary {
    background: var(--accent-deep);
    color: #fff;
    box-shadow: 0 10px 22px rgba(23, 130, 125, 0.28);
}

.btn.primary:hover { filter: brightness(1.05); }

.btn.ghost {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.btn:disabled {
    pointer-events: none;
    background: #eef2f1;
    color: #7c8988;
    box-shadow: none;
}

/* ---------- 内页通用 ---------- */
.page-head {
    margin-bottom: 22px;
    text-align: center;
}

.page-head h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-indent: 2px;
    color: var(--accent-deep);
}

.page-head p {
    margin: 8px 0 0;
    font-size: 0.84rem;
    line-height: 1.7;
    color: var(--muted);
}

/* 标题下方的英文注：同色系，比中文标题浅一档 */
.page-head .page-en {
    margin-top: 2px;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-indent: 0.06em;
    color: var(--accent-lite);
}

/* 状态提示为空时整行不占位（推选页只在非投稿期才写内容） */
.page-head p:empty { display: none; }

/* 年份区间下方的说明：比正文再小一档、再浅一档 */
.page-head .page-note {
    margin-top: 12px;
    font-size: 0.76rem;
    line-height: 1.65;
    color: #5f6a69;
}

/* ---------- 推选表单 ---------- */
.form {
    display: grid;
    gap: 16px;
    text-align: left;
}

.field { display: grid; gap: 8px; }

.field > .label {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--ink);
    /* 说明太长时整段折到下一行，而不是在句子中间断开 */
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    row-gap: 2px;
}

.field > .label .hint {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
}

.field input,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdfc;
    color: var(--ink);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.field input:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea {
    min-height: 84px;
    resize: vertical;
    line-height: 1.6;
}

.field.hanzi input {
    /* 只填一个字：框做小、水平居中；
       不放假占位符，靠这圈深一点的边框说明「这里要填字」 */
    width: 108px;
    max-width: 100%;
    justify-self: center;
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    padding: 10px;
    border: 2px solid #7f8d89;
    background: #fff;
    letter-spacing: 0;
}

/* 上面那圈深色边框会盖掉通用的 focus 样式，补回来 */
.field.hanzi input:focus { border-color: var(--accent); }

.field .err {
    margin: 0;
    font-size: 0.76rem;
    font-weight: 600;
    color: #C1272D;
}

.field.invalid input,
.field.invalid textarea { border-color: #C1272D; }

.form-error {
    margin: 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(193, 39, 45, 0.08);
    color: #A81E1E;
    font-size: 0.8rem;
    font-weight: 600;
}

/* 提交按钮和页面里其它按钮同宽，不拉满整行 */
.form > .btn {
    justify-self: center;
    width: 236px;
    max-width: 100%;
}

.captcha-slot {
    display: grid;
    place-items: center;
    min-height: 62px;
    padding: 10px;
    border: 1px dashed var(--accent-line);
    border-radius: 12px;
    background: #fbfdfc;
    font-size: 0.76rem;
    color: var(--muted);
    text-align: center;
}

/* ---------- 提交成功 ---------- */
.done {
    padding: 8px 0 4px;
}

/* 昵称单独一行 */
.done .name {
    margin: 0 0 10px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--accent-deep);
}

.done .line {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.6;
    color: var(--ink);
}

.done .hang {
    display: inline-block;
    margin: 0 1px;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--accent-deep);
}

.done .seq {
    margin: 16px 0 22px;
    font-size: 0.9rem;
    color: var(--muted);
}

.done .seq b {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent-deep);
    font-variant-numeric: tabular-nums;
    margin: 0 4px;
}

/* 提交成功后收尾区已经有「返回首页 / 查看往年榜首」，底部那个就别重复了 */
.done:not([hidden]) ~ .cta-stack { display: none; }

/* ---------- 实时列表 ---------- */
.live { margin-top: 30px; text-align: left; }

.live-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 12px;
}

.live-head h2 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--ink);
}

.live-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
}

.live-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f7fbfa;
    border: 1px solid var(--line);
}

.live-list .hz {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--accent-deep);
    min-width: 1.2em;
    text-align: center;
}

.live-list .votes {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.live-list .votes b {
    font-size: 1rem;
    color: var(--accent-deep);
    margin-right: 2px;
}

.live-note {
    margin: 12px 0 0;
    font-size: 0.72rem;
    color: var(--muted);
}

.captcha-hint { font-size: 0.72rem; color: var(--muted); margin: 0 0 2px; }


/* ---------- 往年 ---------- */
.past-list {
    display: grid;
    gap: 14px;
    text-align: left;
}

.past-card {
    padding: 16px 16px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fbfdfc;
}

.past-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.past-year {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-indent: 0.14em;
    color: var(--accent-deep);
    font-variant-numeric: tabular-nums;
}

.past-badge {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--accent-deep);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-indent: 0.1em;
}

.past-glyph {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.past-glyph .hz {
    font-size: 3.1rem;
    font-weight: 700;
    line-height: 1.05;
    color: var(--ink);
}

.past-glyph .py {
    font-size: 1.02rem;
    color: var(--muted);
    letter-spacing: 0.2px;
}

.past-def {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 16px;
    font-size: 0.82rem;
    line-height: 1.75;
    color: #3a4443;
}

.past-def li {
    display: flex;
    gap: 5px;
}

.past-def i {
    font-style: normal;
    color: var(--accent-deep);
    flex: 0 0 auto;
    opacity: 0.8;
}

.past-empty {
    margin-top: 22px;
    padding: 14px 16px;
    border: 1px dashed var(--accent-line);
    border-radius: 16px;
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--muted);
    text-align: center;
}

/* ---------- 揭榜 ---------- */
/* 榜首上方那句题诗：一句中文、一句英文 */
.couplet {
    margin: 0;
    font-size: 1.02rem;
    letter-spacing: 0.08em;
    text-indent: 0.08em;
    color: var(--ink);
}

.couplet-en {
    margin: 10px 0 26px;
    font-size: 0.78rem;
    line-height: 1.75;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.crown {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
}

.crown .hz {
    font-size: 6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--ink);
}

.crown .py {
    font-size: 1.1rem;
    color: var(--muted);
}

.crown-votes {
    margin: 8px 0 0;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--accent-deep);
}

.rank {
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 8px;
    text-align: left;
}

.rank li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdfc;
}

.rank .no {
    flex: 0 0 1.2em;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent-deep);
    font-variant-numeric: tabular-nums;
}

.rank .hz {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.05;
    color: var(--ink);
}

.rank .py {
    font-size: 0.78rem;
    color: var(--muted);
}

.rank .votes {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.rank .votes b {
    font-size: 0.94rem;
    color: var(--ink);
}

/* ---------- 页脚 ---------- */
/* ---------- 无障碍 ---------- */
@media (prefers-reduced-motion: reduce) {
    .btn, .field input, .field textarea { transition: none !important; }
}

/* ---------- 移动端 ---------- */
@media (max-width: 420px) {
    .wrap { padding: 18px 12px 32px; }
    .card { padding: 26px 18px 22px; border-radius: 22px; }
    .poster { padding: 16px 14px 20px; }
    .past-def { grid-template-columns: 1fr; }
}

/* 窄屏：时间轴的日期字号收一档，避免挤爆 */
@media (max-width: 380px) {
    :root { --tb-mid: 78px; }
    .slogan { font-size: 1.18rem; letter-spacing: 1.4px; }
    .tb-cell .day { font-size: 1.1rem; }
    .tb-cell .solar { font-size: 0.66rem; }
}


/* ============================================================
   字重只有 400 / 700 两档
   —— 每个中文重量都是一份完整字形（约 87KB），多一档多一份体积；
      500 / 600 收进 400，800 收进 700，避免浏览器合成假粗体
   ============================================================ */
.brand-title,
.tb-title,
.tb-cell .year,
.tb-cell .day,
.tb-mid .hm,
.page-head h1,
.field.hanzi input,
.done .line b,
.done .seq b,
.done .hang,
.live-head h2,
.live-list .hz,
.past-glyph .hz {
    font-weight: 700;
}

/* 鸿雷行书只有一档，引言不能请求 700，否则会被合成加粗 */
.slogan,
.brand-title i,
.brand-en,
.tb-title span,
.tb-mid .tz,
.slogan-en,
.field > .label .hint,
.field .err,
.form-error {
    font-weight: 400;
}
