/* 碼寶日報的樣式。兩種版面：新版（data-skin="modern"）與報紙版（data-skin="paper"），共用同一份 HTML */

/* 新版的色彩與字型 */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --soft: #eef2f8; --line: #dfe3ea; --ink: #18202e; --muted: #5b6474;
  --accent: #2459d6; --accent-ink: #ffffff; --high: #c2321f; --medium: #b7791f; --low: #5b6474; --breaking: #2459d6;
  --text: "Microsoft JhengHei UI", "Microsoft JhengHei", "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  --head: var(--text);
  --figure: "Bahnschrift", "Segoe UI", var(--text);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-skin="paper"]) {
    --bg: #12151b; --surface: #1a1f28; --soft: #222a36; --line: #2c3442; --ink: #e7ebf2; --muted: #9aa3b2;
    --accent: #6d98ff; --accent-ink: #0d1220; --high: #ff7a66; --medium: #e9b45a; --low: #9aa3b2; --breaking: #6d98ff;
    color-scheme: dark;
  }
}

/* 報紙版：米色紙、襯線字、深紅點綴；固定淺色 */
:root[data-skin="paper"] {
  --bg: #e9dfc6; --surface: #f3ebd6; --soft: #e4d8ba; --line: #2a2520; --ink: #1d1a16; --muted: #5a5246;
  --accent: #7d1f1a; --accent-ink: #f6eedb; --high: #7d1f1a; --medium: #8a5a12; --low: #5a5246; --breaking: #1d1a16;
  --text: "Noto Serif TC", "PMingLiU", "MingLiU", "Songti TC", serif;
  --head: "Noto Serif TC", "PMingLiU", "Songti TC", serif;
  --figure: Georgia, "Times New Roman", serif;
  --radius: 0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--text); font-size: 1.0625rem; line-height: 1.75; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); line-height: 1.3; margin: 0; }
p { margin: 0; }
.num { font-family: var(--figure); font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.loading { color: var(--muted); padding: 48px 0; }

/* 版面：左側欄、右內容 */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 20px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.content { padding: 20px clamp(16px, 4vw, 48px) 64px; min-width: 0; }
.main { max-width: 920px; margin: 0 auto; outline: none; }

/* 側欄：報名、各期 */
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-weight: 700; font-size: 1.25rem; text-decoration: none; padding: 4px 8px 16px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 1rem; }
.nav-title { font-size: .8125rem; color: var(--muted); font-weight: 700; padding: 8px 8px 6px; letter-spacing: .04em; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.issue-link { display: grid; gap: 2px; padding: 8px 10px; border-radius: 8px; text-decoration: none; border-left: 3px solid transparent; }
.issue-link .num { font-size: .875rem; font-weight: 700; }
.issue-link .headline { font-size: .8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue-link:hover { background: var(--soft); }
.issue-link[aria-current="page"] { background: var(--soft); border-left-color: var(--accent); }
.issue-link[aria-current="page"] .num { color: var(--accent); }

/* 工具列：期數選單、上一期、下一期、換版面 */
.toolbar { max-width: 920px; margin: 0 auto 24px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.issue-select { margin-right: auto; }
.issue-select select { min-height: 40px; max-width: 320px; padding: 0 10px; font: inherit; font-size: .9375rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.btn { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; font: inherit; font-size: .9375rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--soft); }
.btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* 報頭 */
.masthead { padding: 8px 0 24px; }
.masthead .established, .masthead h1.paper-only { display: none; }
.masthead .subtitle { color: var(--muted); }
.folio { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 12px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .875rem; color: var(--muted); letter-spacing: .06em; }

/* 標籤 */
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; font-size: .8125rem; font-weight: 700; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tag.signal-high { color: var(--high); border-color: color-mix(in srgb, var(--high) 40%, transparent); background: color-mix(in srgb, var(--high) 8%, transparent); }
.tag.signal-medium { color: var(--medium); border-color: color-mix(in srgb, var(--medium) 40%, transparent); }
.tag.signal-low { color: var(--low); }
.tag.breaking { color: var(--breaking); border-color: color-mix(in srgb, var(--breaking) 40%, transparent); background: color-mix(in srgb, var(--breaking) 8%, transparent); }

/* 一期的目錄 */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.card { padding: 22px 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.lead-card { border-top: 3px solid var(--accent); }
.card .title { font-size: 1.375rem; margin: 6px 0; }
.card .title a { text-decoration: none; }
.card .title a:hover { text-decoration: underline; text-underline-offset: 4px; }
.card .more { margin-top: 10px; font-size: .9375rem; }
.card .more a { color: var(--accent); text-decoration: none; font-weight: 700; }
.why { color: var(--muted); font-size: .9375rem; }
.source { margin: 6px 0 10px; font-size: .8125rem; color: var(--muted); letter-spacing: .04em; }
.source-name { text-transform: uppercase; letter-spacing: .12em; }
.source a { color: inherit; }
.dek { color: var(--ink); }

/* 全文 */
.crumb { font-size: .875rem; color: var(--muted); margin-bottom: 12px; }
.crumb a { text-decoration: none; }
.article-box { padding: clamp(20px, 4vw, 36px); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius); }
.article .title { font-size: clamp(1.625rem, 1.2rem + 1.6vw, 2.25rem); margin: 10px 0 8px; }
.article .why { padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.article .dek { margin: 14px 0 8px; padding: 14px 18px; background: var(--soft); border-radius: var(--radius); font-size: 1.0625rem; }
.section { margin-top: 28px; }
.section-title { display: inline-block; font-size: .875rem; font-weight: 700; letter-spacing: .06em; padding-bottom: 4px; margin-bottom: 10px; border-bottom: 1px solid var(--ink); }
.section p + p { margin-top: .8em; }
.section ul, .section ol, .sources ul { margin: 0; padding-left: 1.4em; }
.section li + li { margin-top: .35em; }
.callout { padding: 16px 20px; background: var(--soft); border-radius: var(--radius); }
.debate { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.debate > div { padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius); }
.debate h3 { font-size: .9375rem; margin-bottom: 6px; }
.debate .pro h3 { color: var(--accent); }
.debate .con h3 { color: var(--high); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 700; white-space: nowrap; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: .9em; padding: 1px 5px; background: var(--soft); border-radius: 4px; }
.sources { margin-top: 28px; }
.meta { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); display: grid; gap: 4px; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin-top: 20px; }
.pager .btn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 40px; }
.pager .btn:last-child { text-align: right; }
.message { padding: 64px 0; text-align: center; }
.message p { color: var(--muted); margin-top: 8px; }

/* ── 報紙版 ── */
[data-skin="paper"] body { background-image: radial-gradient(rgba(60, 40, 10, .05) 1px, transparent 1px); background-size: 4px 4px; }
[data-skin="paper"] .sidebar { background: #3a2a1a; border-right: 6px solid #6b4a2a; color: #f3ebd6; }
[data-skin="paper"] .brand-mark { background: #f3ebd6; color: #3a2a1a; }
[data-skin="paper"] .nav-title { color: #d9c7a3; }
[data-skin="paper"] .issue-link { border: 1px solid #1d150d; border-left: 6px solid #7d1f1a; border-radius: 2px; background: linear-gradient(#5a3f25, #46301c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); }
[data-skin="paper"] .issue-link.signal-medium { border-left-color: #8a5a12; }
[data-skin="paper"] .issue-link.signal-low { border-left-color: #2f5a3a; }
[data-skin="paper"] .issue-link .num { font-family: Georgia, serif; letter-spacing: .1em; color: #f3ebd6; }
[data-skin="paper"] .issue-link .headline { color: #d9c7a3; }
[data-skin="paper"] .issue-link[aria-current="page"] { transform: translateX(8px); background: linear-gradient(#7a5532, #5e4127); }
[data-skin="paper"] .issue-link[aria-current="page"] .num { color: #fff6df; }
[data-skin="paper"] .issue-link:hover { background: linear-gradient(#6a4a2c, #523821); }
[data-skin="paper"] .btn { border: 2px solid var(--ink); border-radius: 999px; background: var(--surface); box-shadow: 2px 2px 0 var(--ink); }
[data-skin="paper"] .btn.primary { background: var(--accent); color: var(--accent-ink); }
[data-skin="paper"] .issue-select select { border: 2px solid var(--ink); border-radius: 0; background: var(--surface); }
[data-skin="paper"] .masthead { text-align: center; padding-bottom: 28px; }
[data-skin="paper"] .masthead .established { display: block; font-family: var(--figure); font-size: .8125rem; letter-spacing: .4em; color: var(--muted); }
[data-skin="paper"] .masthead h1.paper-only { display: block; font-family: "Playfair Display", Georgia, "Times New Roman", serif; font-weight: 900; font-size: clamp(2.25rem, 1.2rem + 4.5vw, 4.25rem); letter-spacing: -.01em; line-height: 1.05; margin: 10px 0; }
[data-skin="paper"] .masthead .subtitle { font-style: italic; }
[data-skin="paper"] .folio { border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); color: var(--ink); }
[data-skin="paper"] .tag { border-radius: 0; border: 1px solid var(--ink); background: transparent; color: var(--ink); letter-spacing: .14em; }
[data-skin="paper"] .tag.signal-high { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); transform: rotate(-1.5deg); box-shadow: 3px 3px 0 var(--ink); }
[data-skin="paper"] .card, [data-skin="paper"] .article-box { background: var(--surface); border: 2px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); }
[data-skin="paper"] .card.lead-card, [data-skin="paper"] .article-box { border-top-width: 2px; }
[data-skin="paper"] .card .title, [data-skin="paper"] .article .title { font-weight: 900; text-align: center; }
[data-skin="paper"] .card .more a { color: var(--accent); }
[data-skin="paper"] .why { font-style: italic; text-align: center; }
[data-skin="paper"] .article .why { border-bottom: 3px double var(--ink); }
[data-skin="paper"] .source { text-align: center; }
[data-skin="paper"] .dek { font-style: italic; text-align: center; }
[data-skin="paper"] .article .dek { background: transparent; }
[data-skin="paper"] .section-title { border-bottom: 1px solid var(--ink); }
[data-skin="paper"] .section-briefing p:first-of-type::first-letter { float: left; font-family: var(--figure); font-size: 3.4em; line-height: .9; padding: 4px 8px 0 0; color: var(--accent); }
[data-skin="paper"] .callout, [data-skin="paper"] .debate > div { background: var(--soft); border: 1px solid var(--ink); }
[data-skin="paper"] code { background: var(--soft); }

/* 窄螢幕：側欄移到上方，各期改成橫向捲動 */
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; min-width: 0; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; }
  [data-skin="paper"] .sidebar { border-right: 0; border-bottom: 6px solid #6b4a2a; }
  .issues { grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; padding-bottom: 6px; }
  [data-skin="paper"] .issue-link[aria-current="page"] { transform: translateY(-4px); }
  .content { padding: 16px 16px 48px; }
  .issue-select { margin-right: 0; flex: 1 1 100%; }
  .issue-select select { width: 100%; max-width: none; }
  .debate { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager .btn:last-child { text-align: left; }
}
