/* news.victorlzn.com — Bloomberg-terminal dark theme.
   Styles ONLY the shared DOM-contract selectors (set in app.js):
     header > .site-title, #category-bar > .cat-btn(.active),
     #connection-status, #news-list > .news-item(.important) with
     .news-time .news-source .news-category .news-title .news-body.
   Visual anchors per .claude/PREFERENCES.md:
     bg #0a0a0a, dark-gray dividers, amber/orange accent;
     serif (Bodoni Moda / EB Garamond) for site title + news title;
     clean mono/sans for body & data; dense, tight line-height, minimal whitespace. */

/* ─── Design tokens ─────────────────────────────────────────────── */
:root {
  --bg:            #0a0a0a;
  --bg-elev:       #101012;
  --bg-elev-2:     #141417;
  --bg-hover:      #18181c;
  --divider:       #232327;
  --divider-soft:  #1a1a1e;
  --text:          #e6e6e6;
  --text-dim:      #9a9a9e;
  --text-faint:    #6a6a6e;
  --accent:        #f5a623; /* amber */
  --accent-warm:   #ff8c2b; /* orange */
  --accent-dim:    #8a6418;
  --important-bg:  #1c1408;
  --ok:            #36d399;
  --warn:          #f5a623;
  --err:           #ff5a52;
  --serif: "Bodoni Moda", "EB Garamond", Georgia, "Times New Roman", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:  "SF Mono", "JetBrains Mono", "Roboto Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

/* ─── Reset / base ──────────────────────────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden; /* #news-list owns the scroll */
}

::selection {
  background: var(--accent-dim);
  color: #000;
}

/* ─── Header ─────────────────────────────────────────────────────── */
header {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 10px 18px 9px;
  background: linear-gradient(180deg, #0d0d0f 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--divider);
}

.site-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.3px;
  line-height: 1;
  color: var(--text);
}

.site-title::first-letter { color: var(--accent); }

/* ─── Category bar ───────────────────────────────────────────────── */
#category-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  padding: 0 10px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--divider);
  overflow-x: auto;
  scrollbar-width: thin;
}

.cat-btn {
  appearance: none;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 12px 7px;
  margin: 0;
  transition: color .12s ease, background-color .12s ease, border-color .12s ease;
}

.cat-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.cat-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.cat-btn.active {
  color: var(--accent);
  background: var(--bg-elev-2);
  border-bottom-color: var(--accent);
}

/* ─── Importance filter bar (1-10 slider) ────────────────────────── */
.importance-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--divider);
}

.imp-end {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}

#importance-range {
  flex: 1 1 auto;
  max-width: 320px;
  accent-color: var(--accent);
  cursor: pointer;
}

.imp-readout {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--accent);
  white-space: nowrap;
  min-width: 88px;
}

/* importance badge on each news item */
.news-importance {
  grid-area: imp;
  justify-self: center;
  align-self: start;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-faint);
  border: 1px solid var(--divider);
  border-radius: 2px;
  padding: 2px 4px;
}
.news-importance[data-level="8"],
.news-importance[data-level="9"],
.news-importance[data-level="10"] {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
}
.news-importance[data-level="6"],
.news-importance[data-level="7"] {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* ─── Connection status ──────────────────────────────────────────── */
#connection-status {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 4px;
}

#connection-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 0 transparent;
  flex: 0 0 auto;
}

/* app.js 用 data-state 属性驱动状态（非 class），故用属性选择器，否则状态永不上色。 */
#connection-status[data-state="connected"] { color: var(--ok); }
#connection-status[data-state="connected"]::before {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: pulse 2.4s ease-in-out infinite;
}

#connection-status[data-state="connecting"],
#connection-status[data-state="reconnecting"] { color: var(--warn); }
#connection-status[data-state="connecting"]::before,
#connection-status[data-state="reconnecting"]::before {
  background: var(--warn);
  animation: blink 1s steps(2, start) infinite;
}

#connection-status[data-state="disconnected"],
#connection-status[data-state="error"] { color: var(--err); }
#connection-status[data-state="disconnected"]::before,
#connection-status[data-state="error"]::before { background: var(--err); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 4px var(--ok); }
  50%      { box-shadow: 0 0 9px var(--ok); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.25; }
}

/* ─── News list (scroll container) ───────────────────────────────── */
#news-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--divider) transparent;
}

#news-list::-webkit-scrollbar { width: 10px; }
#news-list::-webkit-scrollbar-track { background: transparent; }
#news-list::-webkit-scrollbar-thumb {
  background: var(--divider);
  border: 2px solid var(--bg);
  border-radius: 6px;
}
#news-list::-webkit-scrollbar-thumb:hover { background: #34343a; }

/* ─── News item row ──────────────────────────────────────────────── */
/* 三列：importance(最左) | meta(time/source/category 竖直堆叠) | content(title/body)。
   三列物理隔离 + meta/content 各自 flex 竖排 → time 与 source 不可能重叠（结构性保证）。 */
.news-item {
  display: grid;
  grid-template-columns: 24px 74px minmax(0, 1fr);
  grid-template-areas: "imp meta main";
  column-gap: 10px;
  align-items: start;
  padding: 9px 18px 10px;
  border-bottom: 1px solid var(--divider-soft);
  border-left: 2px solid transparent;
  transition: background-color .1s ease;
  animation: row-in .26s ease both;
}

.news-item:hover { background: var(--bg-elev); }

@keyframes row-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* col2：meta 竖直堆叠（time 上、source/category 依次在下）。 */
.news-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  align-items: flex-start;
}
/* col3：内容竖直堆叠（title/body/also）。 */
.news-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.news-time {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.news-source {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.3px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.news-category {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: var(--accent);
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.32);
  border-radius: 2px;
  padding: 1px 5px;
  line-height: 1.3;
  max-width: 100%;
}

.news-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.25;
  color: var(--text);
  margin: 0;
}

/* url anchor inside title (href set only after http(s) check in app.js) */
.news-title a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.news-title a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent-dim);
}

.news-body {
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-dim);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ─── Important emphasis (amber) ─────────────────────────────────── */
.news-item.important {
  background: linear-gradient(90deg, var(--important-bg) 0%, var(--bg) 70%);
  border-left-color: var(--accent);
}
.news-item.important:hover {
  background: linear-gradient(90deg, #241a0c 0%, var(--bg-elev) 70%);
}
.news-item.important .news-title { color: #fff3df; }
.news-item.important .news-time { color: var(--accent); }
.news-item.important .news-category {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 13px; }
  header { padding: 8px 12px 7px; }
  .site-title { font-size: 19px; }
  #category-bar { padding: 0 4px; }
  .cat-btn { padding: 7px 9px 6px; font-size: 10px; }
  #connection-status {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    padding: 3px 8px 4px;
    order: 99;
  }
  .news-item {
    grid-template-columns: 20px 64px minmax(0, 1fr);
    grid-template-areas: "imp meta main";
    padding: 8px 12px 9px;
    column-gap: 8px;
  }
  .news-title { font-size: 15px; }
}

@media (min-width: 1400px) {
  .news-item {
    grid-template-columns: 26px 84px minmax(0, 1fr);
    padding-left: 32px;
    padding-right: 32px;
  }
  header { padding-left: 32px; padding-right: 32px; }
  #category-bar { padding-left: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .news-item { animation: none; }
  #connection-status::before { animation: none !important; }
}

/* ─── JS-produced classes (P7 audit: were rendered by app.js but unstyled) ─── */
.news-also {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
}
.news-also-label {
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
}
.news-also-names { color: var(--text-faint); }
.news-link { color: inherit; text-decoration: none; }
.news-link:hover { color: var(--accent); text-decoration: underline; }
.news-item-enter { animation: row-in 0.26s ease both; }

/* 空 / 错误占位（app.js 在加载失败或无数据时插入，文本走 textContent）。 */
.news-placeholder {
  padding: 22px 18px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
}
