/* The CEFR Gazette — 80 年代末报纸风，暖调版：被阳光晒暖的新闻纸、咖啡色油墨、番茄红专色、芥末黄高亮。 */

@font-face { font-family: "League Gothic"; src: url("/fonts/league-gothic-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tinos"; src: url("/fonts/tinos-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Tinos"; src: url("/fonts/tinos-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "UnifrakturMaguntia"; src: url("/fonts/unifrakturmaguntia-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Special Elite"; src: url("/fonts/special-elite-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* 网点半径：让等级大字像油墨一样“洇”出来 */
@property --dot { syntax: "<length>"; inherits: false; initial-value: 3.6px; }

:root {
  --paper: #f6ecd6;       /* 晒暖的新闻纸 */
  --paper-hi: #fffaf0;    /* 稿纸 */
  --paper-deep: #efdfba;  /* 悬停/凹陷 */
  --ink: #2b2018;         /* 咖啡色油墨 */
  --ink-soft: #6b5846;
  --red: #c93a22;         /* 番茄红：填充用 */
  --red-deep: #b82e1a;    /* 同色加深：小字、印章用，保证对比度 */
  --sun: #f4b935;         /* 芥末黄：高亮 */
  --r: 10px;

  --f-flag: "UnifrakturMaguntia", "Old English Text MT", "Times New Roman", serif;
  /* 西文用 League Gothic（窄体粗黑），中文落到系统黑体：老报纸就是黑体标题 + 宋体正文 */
  --f-head: "League Gothic", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Arial Narrow", sans-serif;
  --f-body: "Tinos", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", "Times New Roman", serif;
  --f-type: "Special Elite", "Courier New", monospace;

  --gutter: clamp(1rem, 3vw, 2.25rem);
  --col-gap: 1.75rem;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: light;
  overflow-x: hidden; /* 兜底：入场动画里放大的印章不能把页面撑出横向滚动条 */
  background: var(--paper);
  background-image: radial-gradient(ellipse at 50% 12%, #fff8e6 0%, var(--paper) 55%, #f2e4c3 100%);
  background-attachment: fixed;
}

body {
  margin: 0;
  color: var(--ink);
  font: 1.0625rem/1.6 var(--f-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

/* 纸面颗粒：很淡的一层噪点，只为让纸有质感，不压暗页面 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.11;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .22 0 0 0 0 .1 0 0 0 .8 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--sun); color: var(--ink); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.sheet { max-width: 1200px; margin: 0 auto; padding: 0.8rem var(--gutter) 2rem; }

/* ───────── 报头：一行搞定 ───────── */

.flag { display: flex; align-items: baseline; gap: 0.9rem; padding-bottom: 0.35rem; border-bottom: 4px double var(--ink); }
.flag-title { margin: 0; font: 400 clamp(2.3rem, 5vw, 3.2rem)/1 var(--f-flag); }
.flag-sub { margin: 0; font: 900 1rem/1 var(--f-head); letter-spacing: 0.3em; }
.flag-date { margin: 0 0 0 auto; font-size: 0.9rem; color: var(--ink-soft); }

/* ───────── 头版：左稿件 / 右号外 + 示例 ───────── */

.front {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "lead verdict" "lead ads";
  padding-top: 1.2rem;
}

.lead { grid-area: lead; padding-right: var(--col-gap); border-right: 1px solid var(--ink); }

.lead-head {
  margin: 0 0 0.9rem;
  font: 900 clamp(1.9rem, 4vw, 2.9rem)/1.1 var(--f-head);
  letter-spacing: -0.01em;
  text-shadow: 2px 0 0 rgba(201, 58, 34, 0.55); /* 套印不准的一点红边 */
}

/* 稿纸 */
.desk { margin: 0; }

.mode { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.mode-label { font: 900 1.05rem/1 var(--f-head); margin-right: 0.1rem; }
.mode-opt { position: relative; cursor: pointer; }
.mode-opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.mode-face {
  display: inline-block; padding: 0.3rem 1rem;
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper-hi);
  font: 900 1.05rem/1.3 var(--f-head);
  user-select: none;
  transition: background-color 0.12s;
}
.mode-opt:hover .mode-face { background: var(--paper-deep); }
.mode-opt input:checked + .mode-face,
.mode-opt:hover input:checked + .mode-face { background: var(--sun); box-shadow: 3px 3px 0 var(--ink); }
.mode-opt input:focus-visible + .mode-face { outline: 3px solid var(--ink); outline-offset: 3px; }

.mode-help { margin: 0.5rem 0 0.75rem; font-size: 0.95rem; color: var(--ink-soft); }

#text {
  display: block; width: 100%; min-height: 15rem;
  margin: 0; padding: 0.5rem 1.1rem;
  border: 2px solid var(--ink); border-radius: var(--r);
  background-color: var(--paper-hi);
  /* 稿纸横线，跟着文字滚动 */
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(1.9rem - 1px), rgba(120, 80, 30, 0.2) calc(1.9rem - 1px), rgba(120, 80, 30, 0.2) 1.9rem);
  background-attachment: local;
  color: var(--ink);
  font: 1.06rem/1.9rem var(--f-type);
  resize: vertical;
}
#text::placeholder { color: rgba(107, 88, 70, 0.7); }
#text:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; box-shadow: 0 0 0 2px var(--ink); }

.counter-row { display: flex; align-items: baseline; gap: 1.25rem; padding: 0.45rem 0.2rem 0; font-size: 0.92rem; color: var(--ink-soft); }
.count { font-variant-numeric: tabular-nums; }
.count.is-over { color: var(--red-deep); font-weight: 700; }
.link-btn {
  margin-left: auto; padding: 0; border: 0; background: none;
  font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-btn:hover { text-decoration-thickness: 2px; }

.submit-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin-top: 1rem; }

.press-btn {
  padding: 0.55rem 2rem 0.5rem;
  border: 3px solid var(--ink); border-radius: var(--r);
  background: var(--red); color: #fff;
  font: 900 1.6rem/1.15 var(--f-head); letter-spacing: 0.08em;
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}
.press-btn:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
.press-btn:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.press-btn:disabled { background: #cdbfa3; color: #fff8e8; border-color: #8a7a62; cursor: not-allowed; box-shadow: 3px 3px 0 #8a7a62; transform: none; }

.form-note { margin: 0; font-size: 0.92rem; color: var(--ink-soft); }
.form-note.is-error { color: var(--red-deep); font-weight: 700; }

/* 分类广告：示例（桌面端放在右栏结果下方，用来和左栏等高） */
.classifieds { grid-area: ads; align-self: start; margin: 1.4rem 0 0 var(--col-gap); padding-top: 0.8rem; border-top: 3px double var(--ink); }
.classifieds h3 { margin: 0 0 0.6rem; font: 900 1.1rem/1.3 var(--f-head); }
.ads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.ad {
  width: 100%; padding: 0.5rem 0.4rem;
  border: 2px solid var(--ink); border-radius: var(--r);
  background: var(--paper-hi); color: var(--ink);
  font: 900 1.1rem/1.2 var(--f-head); cursor: pointer;
  transition: background-color 0.12s, transform 0.08s;
}
.ad:hover, .ad:focus-visible { background: var(--sun); transform: translateY(-2px); box-shadow: 0 3px 0 var(--ink); }

/* ───────── 号外（结果栏） ───────── */

.verdict { grid-area: verdict; display: flex; flex-direction: column; padding-left: var(--col-gap); min-height: 31rem; }

.state { display: none; }
.verdict[data-state="loading"] .state-loading,
.verdict[data-state="result"] .state-result,
.verdict[data-state="error"] .state-error { display: block; }
/* 空闲时让留白版面撑满预留高度，右栏就不会在示例上方空出一大块 */
.verdict[data-state="idle"] .state-idle { display: flex; flex: 1; flex-direction: column; }

/* 空闲 */
.blank-slot {
  display: flex; flex: 1; flex-direction: column; justify-content: center;
  min-height: 18rem; padding: 2rem 1.5rem; text-align: center;
  border: 3px dashed rgba(43, 32, 24, 0.45); border-radius: 16px;
  background: rgba(255, 250, 240, 0.55);
}
.blank-title { margin: 0 0 0.4rem; font: 900 2rem/1.2 var(--f-head); }
.blank-text { margin: 0; color: var(--ink-soft); }

/* 评分中：停机印刷 */
.press-title {
  margin: 0; color: var(--red);
  font: 400 clamp(3.2rem, 7vw, 5rem)/0.95 var(--f-head); text-transform: uppercase;
  animation: pulse 1.3s ease-in-out infinite;
}
.press { position: relative; height: 12rem; margin: 1.25rem 0 1rem; border: 3px solid var(--ink); border-radius: var(--r); background: var(--paper-hi); overflow: hidden; }
.roller {
  position: absolute; left: 0; right: 0; z-index: 2; height: 1.3rem;
  background: repeating-linear-gradient(90deg, var(--ink) 0 3px, #7a6652 3px 6px);
}
.roller:first-child { top: 0; }
.roller:last-child { bottom: 0; }
.web {
  position: absolute; inset: 1.3rem 1.2rem;
  background: repeating-linear-gradient(to bottom, var(--ink) 0 2px, transparent 2px 9px);
  -webkit-mask: repeating-linear-gradient(to right, #000 0 30%, transparent 30% 35%);
  mask: repeating-linear-gradient(to right, #000 0 30%, transparent 30% 35%);
  animation: feed 0.32s linear infinite;
}
.press-text { margin: 0; color: var(--ink-soft); }

/* 结果 */
.extra-band {
  display: flex; align-items: baseline; gap: 0.75rem;
  padding: 0.3rem 0.8rem 0.2rem;
  background: var(--red); color: #fff;
  animation: wipe 0.45s cubic-bezier(0.6, 0, 0.2, 1) both;
}
.extra-word { font: 400 2.1rem/1 var(--f-head); letter-spacing: 0.14em; }
.extra-note { font: 900 1.1rem/1 var(--f-head); }
.extra-no { margin-left: auto; font: 700 0.95rem/1 var(--f-body); }

.grade-wrap { display: flex; align-items: flex-end; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 0 0.4rem; }

.grade {
  --dot: 3.6px;
  margin: 0;
  font: 400 clamp(9.5rem, 21vw, 15rem)/0.82 var(--f-head);
  letter-spacing: -0.01em;
  color: transparent;
  -webkit-text-stroke: 3px var(--ink);
  /* 番茄红网点：像四色印刷里的专色网版 */
  background: radial-gradient(circle at 50% 50%, var(--red) var(--dot), transparent calc(var(--dot) + 0.6px)) 0 0 / 8px 8px;
  -webkit-background-clip: text;
  background-clip: text;
  filter: url(#ink-rough);
  animation: bleed 1.35s cubic-bezier(0.3, 0.6, 0.3, 1) 0.3s both;
}

.stamp {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  margin: 0 0.2rem 1.2rem -1.2rem; padding: 0.4rem 0.9rem 0.5rem;
  border: 4px double var(--red-deep); border-radius: 8px; color: var(--red-deep);
  line-height: 1; text-align: center;
  mix-blend-mode: multiply;
  filter: url(#stamp-rough);
  transform: rotate(-7deg);
  animation: slam 0.38s cubic-bezier(0.2, 0.9, 0.3, 1.15) 1.25s both;
}
.stamp-top { padding-left: 0.3em; font: 900 1rem/1 var(--f-head); letter-spacing: 0.3em; }
.stamp-num { font: 400 4.1rem/0.95 var(--f-head); font-variant-numeric: tabular-nums; }
.stamp-bottom { font: 700 0.8rem/1 var(--f-body); }

.verdict-head {
  margin: 0.5rem 0 0.2rem; padding-top: 0.55rem;
  border-top: 3px solid var(--ink);
  font: 900 clamp(1.7rem, 3.1vw, 2.3rem)/1.15 var(--f-head);
}
.verdict-desc { margin: 0 0 0.4rem; font-size: 1.1rem; color: var(--ink-soft); }

/* 量表：像报纸的行情刻度 */
.gauge { margin: 1.6rem 0 0; padding: 0 0.9rem; }
.gauge-track {
  --pos: 0;
  position: relative; height: 1.1rem;
  border: 2px solid var(--ink);
  background: repeating-linear-gradient(to right, var(--ink) 0 2px, transparent 2px 10%);
}
.gauge-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(var(--pos) * 1%);
  background: repeating-linear-gradient(45deg, var(--red) 0 3px, transparent 3px 6px);
  transition: width 1.1s cubic-bezier(0.2, 1.25, 0.3, 1) 0.6s;
}
.gauge-marker {
  position: absolute; top: -1.35rem; z-index: 2;
  left: calc(var(--pos) * 1%); height: calc(100% + 1.35rem + 0.5rem);
  border-left: 3px solid var(--ink); transform: translateX(-1.5px);
  transition: left 1.1s cubic-bezier(0.2, 1.25, 0.3, 1) 0.6s;
}
.gauge-marker::before {
  content: ""; position: absolute; top: 0; left: -10px;
  border: 8.5px solid transparent; border-top: 12px solid var(--ink); border-bottom: 0;
}
.chunk-dot {
  position: absolute; top: 50%; z-index: 1;
  width: 0.65rem; height: 0.65rem;
  border: 2px solid var(--ink); border-radius: 50%; background: var(--sun);
  transform: translate(-50%, -50%);
}
.gauge-scale { position: relative; height: 1.6rem; margin: 0.35rem 0 0; padding: 0; list-style: none; font: 900 1rem/1.4 var(--f-head); }
.gauge-scale li { position: absolute; transform: translateX(-50%); }
.gauge-scale li:nth-child(1) { left: 0%; }
.gauge-scale li:nth-child(2) { left: 20%; }
.gauge-scale li:nth-child(3) { left: 40%; }
.gauge-scale li:nth-child(4) { left: 60%; }
.gauge-scale li:nth-child(5) { left: 80%; }
.gauge-scale li:nth-child(6) { left: 100%; }

.meta-line { margin: 0.8rem 0 0; font-size: 0.92rem; color: var(--ink-soft); }

/* 出错：更正启事 */
.state-error { padding: 1.5rem; border: 3px solid var(--ink); border-radius: 16px; background: var(--paper-hi); }
.correction-title { margin: 0 0 0.4rem; color: var(--red-deep); font: 900 2rem/1.2 var(--f-head); }
.correction-text { margin: 0; }

.foot { margin-top: 1.6rem; padding-top: 0.7rem; border-top: 1px solid var(--ink); text-align: center; font-size: 0.88rem; color: var(--ink-soft); }
.foot p { margin: 0; }

.noscript { position: fixed; inset: auto 0 0 0; z-index: 101; margin: 0; padding: 0.7rem 1rem; background: var(--red); color: #fff; text-align: center; }

/* ───────── 动画 ───────── */

@keyframes bleed { from { --dot: 0px; } to { --dot: 3.6px; } }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes slam {
  0%   { opacity: 0; transform: rotate(-17deg) scale(2.2); }
  55%  { opacity: 1; transform: rotate(-6deg) scale(0.92); }
  100% { opacity: 1; transform: rotate(-7deg) scale(1); }
}
@keyframes feed { to { background-position: 0 9px; } }
@keyframes pulse { 50% { opacity: 0.55; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
  .web { animation: none; }
}

/* ───────── 窄屏 ───────── */

@media (max-width: 900px) {
  /* 窄屏：稿纸 → 示例 → 结果，和 DOM 顺序一致 */
  .front { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "lead" "ads" "verdict"; }
  .lead { padding-right: 0; border-right: 0; }
  .classifieds { margin: 1.4rem 0 0; }
  .verdict { margin-top: 2rem; padding: 1.25rem 0 0; min-height: 0; border-top: 6px double var(--ink); }
  .blank-slot { min-height: 10rem; }
}

@media (max-width: 560px) {
  .flag-sub { letter-spacing: 0.15em; }
  .flag-date { display: none; }
  #text { min-height: 12rem; }
  .press-btn { width: 100%; }
  .stamp-num { font-size: 3.4rem; }
}
