/* DevCN page layer — resets and content components.
 *
 * ONLY loaded on pages that have been migrated to the new chrome
 * (base.html gates it per FrontPage). Because it is file-scoped it must
 * never be loaded globally: the resets here would strip the legacy
 * redesign.css typography on unmigrated pages.
 *
 * Class names that legacy CSS already owns are renamed with a ui- prefix
 * (.ui-btn, .ui-badge, .ui-empty) so both layers can coexist on this page
 * without fighting !important.
 */

/* ---------- reset (scoped by file: migrated pages only) ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.4; letter-spacing: -.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--primary-soft); color: var(--text); }

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

/* ---------- layout ---------- */
/* NOTE: .wrap is owned by base.css — this file only loads on migrated pages,
   and letting it own the container made the chrome full-bleed everywhere else. */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; align-items: start; }
.side-stack, .media-sidebar { display: grid; gap: 16px; align-content: start; }

/* ---------- buttons (ui- prefix: legacy owns .btn) ---------- */
.ui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 18px; border-radius: var(--radius-pill);
  background: var(--primary); color: #fff; font-size: 14px; font-weight: 600;
  border: 1px solid var(--primary); transition: background .18s, transform .18s, border-color .18s;
}
.ui-btn:hover { background: var(--primary-2); border-color: var(--primary-2); transform: translateY(-1px); }
.ui-btn-outline { background: transparent; color: var(--primary); border-color: var(--border-strong); }
.ui-btn-outline:hover { background: var(--primary-soft); border-color: var(--primary); transform: none; }
.ui-btn-ghost { background: var(--bg-soft); color: var(--text-soft); border-color: transparent; }
.ui-btn-ghost:hover { background: var(--primary-soft); color: var(--primary); transform: none; }
.ui-btn-sm { min-height: 32px; padding: 0 13px; font-size: 13px; }
.ui-btn svg { width: 16px; height: 16px; }

/* ---------- hero card ---------- */
.hero-card {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: var(--card-bg); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.hero-body { padding: 32px; }
.hero-flag {
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 14px;
  padding: 4px 12px; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
}
.hero-body h1, .hero-body h2 { font-size: clamp(24px, 2.8vw, 36px); line-height: 1.35; }
.hero-body h1 a:hover, .hero-body h2 a:hover { color: var(--primary); }
.hero-excerpt {
  margin-top: 12px; font-size: 15px; line-height: 1.85; color: var(--text-soft);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-more {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 18px;
  font-size: 14px; font-weight: 600; color: var(--primary);
}
.hero-more svg { width: 17px; height: 17px; transition: transform .18s; }
.hero-more:hover svg { transform: translateX(3px); }
/* 21/9 instead of 16/8: at the ~870px hero column the wider image made the
   headline card 733px tall and pushed the whole feed below the fold. */
.hero-thumb { aspect-ratio: 21 / 9; overflow: hidden; }
.hero-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- section head ---------- */
.sec-head { display: flex; align-items: baseline; gap: 12px; margin: 38px 0 16px; }
.sec-head h2 { font-size: 21px; }
.sec-head small { margin-left: 2px; font-size: 13px; font-weight: 400; color: var(--text-faint); }
.sec-head .sec-more { margin-left: auto; font-size: 13px; color: var(--text-soft); }
.sec-head .sec-more:hover { color: var(--primary); }

/* ---------- post list ---------- */
.post-list { display: flex; flex-direction: column; }
.post-item {
  display: grid; grid-template-columns: minmax(0, 1fr) 148px; gap: 22px; align-items: center;
  padding: 20px 0; border-bottom: 1px solid var(--border);
}
.post-item:last-child { border-bottom: 0; }
.post-title { font-size: 18px; line-height: 1.6; font-weight: 650; }
.post-title a:hover { color: var(--primary); }
.post-excerpt {
  margin-top: 7px; font-size: 14px; line-height: 1.8; color: var(--text-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-thumb { aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-soft); }
.post-thumb img { width: 100%; height: 100%; object-fit: cover; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; font-size: 13px; color: var(--text-soft); }
.meta .dot { opacity: .45; }
.meta a { color: var(--text-soft); }
.meta a:hover { color: var(--primary); }
.meta .cat { color: var(--primary); }

/* ---------- sidebar ---------- */
.side-box {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.side-box h3 { font-size: 14px; font-weight: 650; margin: 0 0 14px; }
.side-box p { font-size: 13px; line-height: 1.8; color: var(--text-soft); }
.side-links a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 7px 0; font-size: 13px; color: var(--text-soft); transition: color .18s;
}
.side-links a:hover { color: var(--primary); }
.side-links .n {
  flex: none; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: var(--radius-pill);
  background: var(--bg-soft); font-size: 11px; color: var(--text-faint);
}
.side-links .more { color: var(--text-faint); font-size: 12px; }
.side-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.side-tags a {
  padding: 5px 12px; border-radius: var(--radius-pill); background: var(--bg-soft);
  font-size: 13px; color: var(--text-soft); transition: .18s;
}
.side-tags a:hover { background: var(--primary-soft); color: var(--primary); }
.side-search { display: flex; gap: 8px; }
.side-search input {
  flex: 1; min-width: 0; min-height: 38px; padding: 0 13px; font-size: 13px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-xs); outline: 0;
}
.side-search input:focus { border-color: var(--primary); }
.side-search button {
  flex: none; padding: 0 15px; border-radius: var(--radius-xs);
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 600;
}
.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.side-head h3 { margin-bottom: 0; }
.side-more { flex: none; font-size: 12px; color: var(--text-faint); }
.side-more:hover { color: var(--primary); }

/* ---------- badges (ui- prefix: legacy owns .badge) ---------- */
.ui-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: var(--radius-pill); font-size: 11px; font-weight: 600;
  background: var(--bg-soft); color: var(--text-soft);
}
.ui-badge-primary { background: var(--primary-soft); color: var(--primary); }
.ui-badge-accent { background: var(--accent-soft); color: var(--accent); }
.ui-badge-success { background: var(--success-soft); color: var(--success); }
.ui-badge-warn { background: var(--warn-soft); color: var(--warn); }
.ui-badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- pager ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 28px 0; flex-wrap: wrap; }
.pager a, .pager span, .pager b {
  display: inline-flex; align-items: center; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-xs); font-size: 13px;
}
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager b { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.pager span { color: var(--text-faint); }

/* ---------- empty state (ui- prefix: legacy owns .empty-state) ---------- */
.ui-empty { padding: 52px 20px; text-align: center; color: var(--text-soft); }
.ui-empty h3 { font-size: 17px; margin-bottom: 8px; }
.ui-empty p { font-size: 14px; line-height: 1.8; }
.ui-empty .ui-btn { margin-top: 16px; }

/* ---------- home ---------- */
.home-shell { padding-top: 30px; }
.home-hero { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.home-main { margin-top: 10px; }
.home-column { min-width: 0; }

.pick-list { display: grid; gap: 2px; }
.pick-list a { display: flex; gap: 11px; align-items: baseline; padding: 9px 0; font-size: 14px; line-height: 1.65; color: var(--text); }
.pick-list a:hover { color: var(--primary); }
.pick-list b { flex: none; width: 20px; font-size: 13px; font-weight: 700; color: var(--primary); }
.pick-list span {
  min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* headline visuals */
.visual-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.visual-card {
  display: block; overflow: hidden; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card-bg);
  box-shadow: var(--shadow-sm); transition: border-color .18s, transform .18s;
}
.visual-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.visual-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.visual-card span { display: block; padding: 14px 16px 16px; }
.visual-card small { display: block; margin-bottom: 6px; font-size: 12px; color: var(--primary); }
.visual-card strong {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 15px; font-weight: 650; line-height: 1.6;
}

/* topic cards — home-topic-card is a legacy name kept for tests; the
 * body.front-ui prefix outranks the old home-topics.css rules. */
.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
body.front-ui .home-topic-card {
  display: block; overflow: hidden; border-radius: var(--radius);
  background: var(--card-bg); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); transition: border-color .18s, transform .18s;
  position: static;
}
body.front-ui .home-topic-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.topic-art { display: block; aspect-ratio: 3 / 1; overflow: hidden; background: var(--bg-soft); position: static; }
.topic-art img { width: 100%; height: 100%; object-fit: cover; }
.topic-copy { padding: 16px 18px 18px; position: static; }
.topic-copy h3 { font-size: 16px; }
.topic-copy p {
  margin-top: 6px; font-size: 13px; line-height: 1.75; color: var(--text-soft);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.topic-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 12px; color: var(--text-faint); }
.topic-meta b { color: var(--text); font-weight: 650; }

/* sidebar extras */
.rank-list { display: grid; gap: 2px; }
.rank-list li { display: flex; gap: 11px; align-items: baseline; padding: 8px 0; }
.rank-no { flex: none; font-size: 12px; font-weight: 700; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.rank-list a {
  min-width: 0; font-size: 13px; line-height: 1.7; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rank-list a:hover { color: var(--primary); }
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-soft); }
.stat-row span { flex: 1 1 auto; text-align: center; padding: 10px 4px; border-radius: var(--radius-sm); background: var(--bg-soft); }
.stat-row b { display: block; font-size: 17px; font-weight: 700; color: var(--text); }

/* community feed */
.feed { min-width: 0; }
.feed-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.feed-tabs a {
  padding: 6px 14px; border-radius: var(--radius-pill); font-size: 13px;
  color: var(--text-soft); background: var(--bg-soft); transition: .18s;
}
.feed-tabs a:hover { color: var(--primary); }
.feed-tabs a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.post-item.has-tally { grid-template-columns: 52px minmax(0, 1fr); align-items: start; gap: 16px; }
.reply-tally {
  display: grid; place-items: center; gap: 1px; padding: 8px 4px; text-align: center;
  border-radius: var(--radius-sm); background: var(--bg-soft);
}
.reply-tally b { font-size: 17px; font-weight: 700; color: var(--text); line-height: 1.2; }
.reply-tally span { font-size: 11px; color: var(--text-faint); }
.post-copy { min-width: 0; }
.post-copy .ui-badge { margin-left: 8px; vertical-align: middle; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .home-hero { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .hero-body { padding: 22px; }
  .post-item { grid-template-columns: minmax(0, 1fr) 96px; gap: 14px; }
  .post-item.has-tally { grid-template-columns: 44px minmax(0, 1fr); gap: 12px; }
  .topic-grid { grid-template-columns: 1fr; }
}
