/* 碼舍日報的樣式：報紙版。訊號強弱用三種不同份量的版面區分：頭版（紅）、要聞（金）、簡訊（灰） */

/* 色彩與字型 */
:root {
  --paper: #eee4cb; /* 底色：舊報紙 */
  --paper-2: #e3d6b4; /* 次要底色：框內、表頭 */
  --card: #f6eedb; /* 卡片底色 */
  --ink: #17130f; /* 主要文字與粗框 */
  --muted: #5c5245; /* 次要文字 */
  --red: #8e1b16; /* 訊號強、反方、強調 */
  --gold: #a5730f; /* 訊號中 */
  --green: #1d5236; /* 正方 */
  --wood: #3a2817; /* 側欄 */
  --text: "Noto Serif TC", "PMingLiU", "MingLiU", "Songti TC", serif;
  --display: "Playfair Display", Georgia, "Times New Roman", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0; color: var(--ink); font-family: var(--text); font-size: 1.0625rem; line-height: 1.8;
  background: var(--paper) radial-gradient(rgba(70, 45, 10, .06) 1px, transparent 1px) 0 0 / 4px 4px;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums lining-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: 240px minmax(0, 1fr); min-height: 100vh; }
.content { padding: 20px clamp(16px, 4vw, 56px) 72px; min-width: 0; }
.main { max-width: 960px; margin: 0 auto; outline: none; }

/* 側欄：木頭書架，每一期是一本書背，左緣顏色是那一期最強的訊號 */
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 20px 14px; background: var(--wood); border-right: 8px solid #6b4a2a; color: var(--card); }
.nav-title { font-size: .8125rem; color: #d9c7a3; font-weight: 700; padding: 6px 6px 8px; letter-spacing: .3em; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.issue-link { display: grid; gap: 1px; padding: 8px 12px; text-decoration: none; border: 1px solid #1d150d; border-left: 7px solid #6f6556; background: linear-gradient(#5a3f25, #46301c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); transition: transform .15s; }
.issue-link.signal-high { border-left-color: #c0362c; }
.issue-link.signal-medium { border-left-color: #d29a2a; }
.issue-link .num { font-size: .95rem; font-weight: 700; letter-spacing: .12em; color: #fff6df; }
.issue-link .headline { font-size: .8125rem; color: #d9c7a3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.issue-link:hover { background: linear-gradient(#6a4a2c, #523821); }
.issue-link[aria-current="page"] { transform: translateX(10px); background: linear-gradient(#7d5733, #5e4127); }

/* 工具列：期數選單、上一期、下一期 */
.btn { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; font: inherit; font-size: .9375rem; font-weight: 700; color: var(--ink); background: var(--card); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 3px 3px 0 var(--ink); text-decoration: none; transition: transform .1s, box-shadow .1s; }
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn[aria-disabled="true"] { opacity: .4; box-shadow: none; pointer-events: none; }

/* 報頭 */
.masthead { text-align: center; padding: 18px 0 8px; }
.masthead .established { font-family: var(--display); font-size: .8125rem; letter-spacing: .5em; color: var(--muted); }
.masthead h1 { font-size: clamp(3.2rem, 2rem + 6vw, 6.25rem); font-weight: 900; letter-spacing: .12em; line-height: 1.1; margin: 6px 0 4px; text-shadow: 3px 3px 0 rgba(142, 27, 22, .18); }
.masthead h1 a { text-decoration: none; }
.masthead .subtitle { font-style: italic; color: var(--muted); }
.masthead .subtitle [lang="en"] { font-family: var(--display); font-weight: 700; color: var(--ink); }
.folio { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding: 8px 0; border-top: 2px solid var(--ink); border-bottom: 6px double var(--ink); font-size: .875rem; letter-spacing: .14em; }
.masthead.compact { padding-top: 4px; }
.masthead.compact .established, .masthead.compact .subtitle { display: none; }
.masthead.compact h1 { font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.4rem); text-shadow: none; }
.masthead.compact .folio { margin-top: 8px; }

/* 區塊標題：頭版、要聞、簡訊 */
.band { display: flex; align-items: baseline; gap: 14px; margin: 36px 0 18px; padding: 8px 16px; font-weight: 900; }
.band span { font-size: 1.6rem; letter-spacing: .3em; }
.band small { font-family: var(--display); font-size: .8125rem; letter-spacing: .4em; }
.band-high { background: var(--red); color: var(--card); box-shadow: 6px 6px 0 var(--ink); }
.band-medium { border-top: 4px solid var(--ink); border-bottom: 1px solid var(--ink); padding-left: 0; }
.band-medium span { color: var(--gold); }
.band-low { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding-left: 0; color: var(--muted); }
.band-low span { font-size: 1.25rem; }

/* 訊號緞帶與標籤 */
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.ribbon { display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px; font-weight: 900; font-size: .875rem; letter-spacing: .16em; }
.ribbon [lang="en"] { font-family: var(--display); }
.ribbon i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.ribbon.signal-high { background: var(--red); color: var(--card); transform: rotate(-2deg); box-shadow: 3px 3px 0 var(--ink); margin-left: -48px; padding-left: 44px; }
.ribbon.signal-high i { background: #fff3d6; box-shadow: 0 0 0 3px rgba(255, 243, 214, .35); }
.ribbon.signal-medium { background: var(--gold); color: var(--ink); }
.ribbon.signal-low { border: 1px solid var(--muted); color: var(--muted); padding: 3px 12px; font-size: .8125rem; }
.tag { display: inline-block; padding: 2px 10px; font-size: .8125rem; font-weight: 700; letter-spacing: .14em; border: 1px solid var(--ink); }
.stamp { position: absolute; top: 18px; right: 22px; display: grid; justify-items: center; padding: 4px 14px; color: var(--red); border: 4px double var(--red); font-weight: 900; font-size: 1.15rem; letter-spacing: .3em; line-height: 1.2; transform: rotate(7deg); opacity: .9; }
.stamp small { font-family: var(--display); font-size: .625rem; letter-spacing: .3em; }

/* 頭版與要聞的卡片 */
.card { position: relative; margin: 0 0 28px; padding: 24px 30px 22px; background: var(--card); border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.card .title { margin: 6px 0 6px; font-weight: 900; }
.card .title a { text-decoration: none; }
.card .title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.card.signal-high { border-width: 3px; box-shadow: 9px 9px 0 var(--red); padding: 28px 36px 24px; }
.card.signal-high .title { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); }
.card.signal-medium .title { font-size: 1.35rem; }
.card .more { margin-top: 12px; font-weight: 900; letter-spacing: .1em; }
.card .more a { color: var(--red); text-decoration: none; }
.card .more a:hover { text-decoration: underline; text-underline-offset: 4px; }
.origin { margin: 28px 0 0; }
.origin .origin-link { display: inline-block; padding: 10px 22px; background: var(--red); color: var(--card); font-weight: 900; letter-spacing: .1em; text-decoration: none; border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.origin .origin-link:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.notable .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; }
.notable .card { padding: 20px 24px; }
.why { font-style: italic; color: var(--muted); border-left: 4px solid var(--red); padding-left: 12px; }
.signal-medium .why { border-left-color: var(--gold); }
.source { margin: 4px 0 10px; font-size: .8125rem; color: var(--muted); letter-spacing: .06em; }
.source-link { color: var(--red); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.source-link:hover { text-decoration-thickness: 2px; }
.source-name { font-family: var(--display); text-transform: uppercase; letter-spacing: .18em; font-weight: 700; color: var(--ink); }
.dek { font-size: 1.0625rem; }
/* 執筆列：全文最上面的「某某 手筆 · 身分」 */
.byline { display: flex; align-items: baseline; gap: 8px; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px dotted var(--ink); font-size: .9375rem; letter-spacing: .08em; }
.byline .pen { color: var(--red); }
.byline strong { font-size: 1.0625rem; font-weight: 900; }
.byline .role { margin-left: 4px; padding: 0 8px; font-size: .8125rem; color: var(--muted); border: 1px solid var(--muted); }

/* 簡訊：一則一列 */
.briefs ul { list-style: none; margin: 0; padding: 0; }
.briefs li a { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; padding: 12px 4px; text-decoration: none; border-bottom: 1px dotted var(--ink); }
.briefs li a:hover strong { text-decoration: underline; text-underline-offset: 4px; }
.briefs .tag { grid-row: span 2; align-self: start; margin-top: 3px; }
.briefs .why { border: 0; padding: 0; font-size: .9375rem; }

/* 全文 */
.article { position: relative; margin-top: 28px; padding: clamp(22px, 4vw, 44px); background: var(--card); border: 3px solid var(--ink); box-shadow: 9px 9px 0 var(--ink); }
.article.signal-high { box-shadow: 9px 9px 0 var(--red); }
.article .why { margin-bottom: 6px; }
.article .title { font-size: clamp(1.8rem, 1.3rem + 2vw, 2.75rem); font-weight: 900; margin: 14px 0 8px; padding-top: 14px; border-top: 6px double var(--ink); }
.article .dek { margin: 18px 0 8px; padding: 14px 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); font-size: 1.25rem; font-style: italic; text-align: center; }
.section { margin-top: 34px; }
.section-title { display: inline-block; font-size: .875rem; font-weight: 900; letter-spacing: .14em; padding-bottom: 4px; margin-bottom: 12px; border-bottom: 2px solid var(--ink); }
.section-title [lang="en"] { font-family: var(--display); text-transform: uppercase; }
.section p + p { margin-top: .9em; }
.section ul, .sources ul { margin: 0; padding-left: 1.4em; }
.section li + li { margin-top: .4em; }
.section-briefing p:first-of-type::first-letter { float: left; font-family: var(--display); font-weight: 900; font-size: 3.6em; line-height: .9; padding: 6px 10px 0 0; color: var(--red); }
.callout { padding: 18px 22px; background: var(--paper-2); border: 2px dashed var(--ink); }

/* 正反論點：左綠右紅兩大塊，中間 VS */
.debate { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 0; }
.debate .side { border: 3px solid var(--ink); background: var(--card); box-shadow: 5px 5px 0 var(--ink); }
.debate h3 { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 18px; color: var(--card); font-size: 1.3rem; font-weight: 900; letter-spacing: .3em; }
.debate h3 small { font-family: var(--display); font-size: .75rem; letter-spacing: .3em; }
.debate .pro h3 { background: var(--green); }
.debate .con h3 { background: var(--red); }
.debate .side ul { padding: 14px 20px 16px 36px; }
.debate .vs { align-self: center; display: grid; place-items: center; width: 56px; height: 56px; margin: 0 -10px; z-index: 1; border-radius: 50%; background: var(--ink); color: var(--card); font-family: var(--display); font-weight: 900; font-style: italic; font-size: 1.25rem; border: 3px solid var(--card); }

/* 建議行動：大號紅色數字 */
.section-action ol { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.section-action li { counter-increment: step; position: relative; padding: 6px 0 6px 52px; border-bottom: 1px dotted var(--ink); }
.section-action li::before { content: counter(step); position: absolute; left: 6px; top: 4px; font-family: var(--display); font-weight: 900; font-size: 1.9rem; line-height: 1; color: var(--red); }

/* 換個視角：大字引言 */
.perspective blockquote { position: relative; margin: 0; padding: 18px 20px 18px 70px; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); font-size: 1.2rem; font-style: italic; }
.perspective blockquote::before { content: "“"; position: absolute; left: 10px; top: -10px; font-family: var(--display); font-weight: 900; font-size: 5.5rem; line-height: 1; color: var(--red); }

/* 表格、程式碼、資料來源、頁尾 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--ink); text-align: left; vertical-align: top; }
th { font-weight: 900; white-space: nowrap; background: var(--paper-2); }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: .88em; padding: 1px 5px; background: var(--paper-2); border: 1px solid rgba(23, 19, 15, .25); }
.sources { margin-top: 30px; }
.meta { margin-top: 36px; padding-top: 14px; border-top: 1px dashed var(--ink); font-size: .8125rem; color: var(--muted); display: grid; gap: 4px; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; margin-top: 28px; }
.pager .btn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 36px; }
.pager .btn:last-child { text-align: right; }
/* 讀者正反方：全文的左右兩側，正方在左（綠）、反方在右（紅），留言由上往下排。反方整列鏡像：頭像在右、說詞框靠右 */
.main:has(.stage) { max-width: 1680px; }
.stage { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "center" "pro" "con"; gap: 28px; }
.stage-center { grid-area: center; min-width: 0; max-width: 960px; width: 100%; justify-self: center; }
.verdict-col { min-width: 0; }
.verdict-col.pro { grid-area: pro; }
.verdict-col.con { grid-area: con; text-align: right; }
.verdict-head { display: flex; align-items: baseline; gap: 10px; padding: 6px 16px; color: var(--card); font-size: 1.25rem; font-weight: 900; letter-spacing: .3em; border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.verdict-head .num { letter-spacing: .05em; }
.pro .verdict-head { background: var(--green); }
.con .verdict-head { background: var(--red); flex-direction: row-reverse; }
.verdict-col .loading { padding: 12px 0; }
.verdict-col .error { margin-top: 8px; color: var(--red); font-weight: 700; }
.speak-hint { margin-top: 12px; font-size: .875rem; color: var(--muted); }
.speak { margin-top: 12px; text-align: left; }
.speak summary { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; font-weight: 900; letter-spacing: .12em; border: 2px solid var(--ink); background: var(--card); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; list-style: none; }
.speak summary::-webkit-details-marker { display: none; }
.speak summary::before { content: "＋"; margin-right: 6px; }
.speak[open] summary::before { content: "－"; }
.pro .speak[open] summary { background: var(--green); color: var(--card); }
.con .speak { text-align: right; }
.con .speak[open] summary { background: var(--red); color: var(--card); }
.verdict-form { display: grid; gap: 10px; margin-top: 10px; padding: 12px 14px; text-align: left; background: var(--paper-2); border: 2px dashed var(--ink); }
.verdict-form .as { display: flex; align-items: center; gap: 10px; font-size: .9375rem; }
.verdict-form textarea { width: 100%; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--card); border: 2px solid var(--ink); resize: vertical; }
.verdict-form .actions { display: flex; align-items: center; gap: 16px; }
.link { padding: 0; font: inherit; font-size: .875rem; color: var(--muted); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.btn:disabled, .link:disabled { opacity: .5; pointer-events: none; }
.voices { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 16px; text-align: left; }
.voice { display: flex; align-items: flex-start; gap: 12px; }
.con .voice { flex-direction: row-reverse; }
/* 說詞框：漫畫風圓角泡泡加偏移陰影，靠頭像的角收小接尾巴；尾巴是外框三角（::before）疊一層底色三角（::after）。
   奇偶列各歪一點、彈出進場、滑過時擺正放大，讓整排不死板 */
.bubble { position: relative; min-width: 0; max-width: 100%; padding: 9px 16px 11px; background: var(--card); border: 2px solid var(--ink); border-radius: 6px 22px 22px 22px; box-shadow: 3px 3px 0 var(--ink); font-size: .9375rem; line-height: 1.65; text-align: left; overflow-wrap: anywhere; transform: rotate(-1deg); transform-origin: 0 16px; transition: transform .18s cubic-bezier(.34, 1.56, .64, 1); animation: bubble-pop .35s cubic-bezier(.34, 1.56, .64, 1) both; }
.con .bubble { border-radius: 22px 6px 22px 22px; transform: rotate(1deg); transform-origin: 100% 16px; }
.voice:nth-child(even) .bubble { transform: rotate(1deg); }
.con .voice:nth-child(even) .bubble { transform: rotate(-1deg); }
.voice .bubble:hover { transform: rotate(0) scale(1.02); }
@keyframes bubble-pop { from { opacity: 0; scale: .6; } to { opacity: 1; scale: 1; } }
@media (prefers-reduced-motion: reduce) { .bubble { animation: none; transition: none; } }
.bubble::before, .bubble::after { content: ""; position: absolute; top: 12px; border: solid transparent; }
.bubble::before { left: -11px; border-width: 9px 11px 9px 0; border-right-color: var(--ink); }
.bubble::after { left: -7px; top: 14px; border-width: 7px 8px 7px 0; border-right-color: var(--card); }
.con .bubble::before { left: auto; right: -11px; border-width: 9px 0 9px 11px; border-color: transparent transparent transparent var(--ink); }
.con .bubble::after { left: auto; right: -7px; border-width: 7px 0 7px 8px; border-color: transparent transparent transparent var(--card); }
.bubble .author { margin-bottom: 4px; padding-bottom: 3px; font-size: .75rem; font-weight: 900; letter-spacing: .08em; border-bottom: 1px dotted rgba(23, 19, 15, .35); } /* 暱稱：顏色跟所站的一方 */
.pro .bubble .author { color: var(--green); }
.con .bubble .author { color: var(--red); text-align: right; }
.avatar { flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--ink); object-fit: cover; background: var(--paper-2); color: var(--card); font-weight: 900; }
.avatar.c0 { background: #8e1b16; } .avatar.c1 { background: #1d5236; } .avatar.c2 { background: #a5730f; }
.avatar.c3 { background: #2c4a6e; } .avatar.c4 { background: #5c3a6e; } .avatar.c5 { background: #5c5245; }
.verdict-col .empty { margin-top: 12px; color: var(--muted); font-size: .9375rem; }
.more-voices { display: block; width: 100%; margin-top: 10px; padding: 6px 0; font: inherit; font-weight: 900; letter-spacing: .1em; color: var(--muted); background: none; border: 0; border-top: 1px dotted var(--ink); cursor: pointer; text-align: inherit; }
.more-voices:hover { color: var(--ink); }
/* 中等寬度：全文在上，正反方在下面左右並排 */
@media (min-width: 761px) {
  .stage { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "center center" "pro con"; }
}
/* 寬螢幕：正方、全文、反方三欄並排，兩側從報頭的高度開始往下排 */
@media (min-width: 1440px) {
  .stage { grid-template-columns: minmax(220px, 1fr) minmax(0, 880px) minmax(220px, 1fr); grid-template-areas: "pro center con"; align-items: start; }
  .verdict-col { align-self: stretch; } /* 撐滿整列高度，標題才能一路固定到全文底部 */
  /* 捲動時標題與表態區固定在頂端，留言照常跟著頁面捲；底色蓋住捲上來的留言 */
  .verdict-top { position: sticky; top: 0; z-index: 2; padding: 4px 6px 12px 0; background: var(--paper) radial-gradient(rgba(70, 45, 10, .06) 1px, transparent 1px) 0 0 / 4px 4px; }
  .con .verdict-top { padding: 4px 0 12px 6px; }
}
/* 登入頁：沒登入時首頁換成這一頁 */
.gate { max-width: 560px; margin: 0 auto; padding: 40px 16px 72px; }
.gate-card { display: grid; gap: 16px; margin-top: 28px; padding: 24px 28px; text-align: center; background: var(--card); border: 3px solid var(--ink); box-shadow: 9px 9px 0 var(--ink); }
.gate-card .btn { justify-self: center; }
.gate-note { font-size: .875rem; color: var(--muted); }
.message { padding: 64px 0; text-align: center; }
.message p { color: var(--muted); margin-top: 8px; }

/* 窄螢幕：側欄移到上方，各期改成橫向捲動，兩欄改一欄 */
@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: 6px solid #6b4a2a; padding: 12px 16px; }
  .issues { grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); overflow-x: auto; padding-bottom: 6px; }
  .issue-link[aria-current="page"] { transform: translateY(-4px); }
  .content { padding: 16px 16px 48px; }
  .notable .grid { grid-template-columns: minmax(0, 1fr); }
  .card, .card.signal-high { padding: 22px 20px 20px; }
  .ribbon.signal-high { margin-left: -30px; padding-left: 28px; }
  .stamp { position: static; display: inline-grid; margin-bottom: 8px; transform: rotate(-3deg); }
  .debate { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .debate .vs { justify-self: center; margin: -10px 0; }
  .pager { grid-template-columns: 1fr; }
  .pager .btn:last-child { text-align: left; }
}
