/* =============================================================================
   族 portal —— 门户型
   骨架：1280 三栏（左栏目树 / 中信息流 / 右友站与相关），顶部是双行导航条
   与 mag 的区别：mag 是两栏内容 + 常驻侧栏，这里是三栏、且左栏是导航而不是正文
   ========================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.portal-page {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-size: 14.5px; line-height: 1.75;
  display: flex; flex-direction: column; min-height: 100vh;
}
body.portal-page > .portal-layout { flex: 1 0 auto; }
.portal-page a { color: var(--text-2); text-decoration: none; }
.portal-page a:hover { color: var(--accent-deep); }
.portal-page img { max-width: 100%; height: auto; display: block; }

/* ------------------------------------------------------------------ header */
.portal-top {
  background: var(--surface); border-bottom: 2px solid var(--border);
}
.portal-top-in {
  display: flex; align-items: center; gap: 18px;
  max-width: 1280px; margin: 0 auto; padding: 0 20px; min-height: 48px;
}
.portal-top.is-center .portal-top-in { justify-content: center; gap: 26px; position: relative; }
.portal-top.is-center .portal-tabs { flex: 0 1 auto; align-self: stretch; justify-content: safe center; }
.portal-top.is-center .portal-clock { position: absolute; right: 20px; }
/* is-center 桌面端：报头式两行——站名居中占一行，导航居中另起一行。
   单行排法站名紧跟导航（DOM 顺序 tabs→logo→clock），整行读成
   「首页 关于本站 ⛶ 边界感练习」，站名像菜单的最后一项。
   ≤780 已是「品牌一行 + 频道条整行」的窄屏排法，不走这套。 */
@media (min-width: 781px) {
  .portal-top.is-center .portal-top-in { flex-direction: column; gap: 0; padding: 10px 20px 0; }
  .portal-top.is-center .portal-logo { order: -1; padding: 6px 0 10px; }
  .portal-top.is-center .portal-tabs { justify-content: center; }
  .portal-top.is-center .portal-clock { top: 22px; }
}
.portal-top.is-left .portal-top-in { justify-content: flex-start; }
/* stack：一行三段，标识居左、频道居中、时间居右 */
.portal-top.is-stack { display: flex; align-items: center; gap: 20px; padding: 0 max(20px, calc(50% - 640px)); }
.portal-top.is-stack .portal-top-in { flex: 0 0 auto; padding: 0; border-bottom: 0; }
.portal-top.is-stack .portal-top-row { flex: 1 1 auto; padding: 0; justify-content: space-between; }
.portal-top.is-stack .portal-tabs { flex: 1 1 auto; justify-content: center; }
.portal-top.is-stack .portal-fold { display: none; }
.portal-top-row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  max-width: 1280px; margin: 0 auto; padding: 6px 20px 8px;
}
.portal-logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 17px; font-weight: 700; letter-spacing: .02em; color: var(--text);
  white-space: nowrap;
}
.portal-mark { border-radius: 4px; flex: 0 0 auto; }
/* 页头导航恒为一行：放不下就横向滑，不折行。
   折行会把刊头挤成高低不齐的两行（移动端最明显），而这里是全站唯一的主入口，
   一旦折掉就是「菜单看着断了一截」。滚动条隐掉，横滑不带动整页。 */
.portal-tabs {
  display: flex; flex-wrap: nowrap; gap: 0 2px;
  flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none; overscroll-behavior-x: contain;
}
.portal-tabs::-webkit-scrollbar { display: none; }
.portal-tabs a { flex: 0 0 auto; white-space: nowrap; }
.portal-tabs.is-row { flex: 0 1 auto; }
.portal-tab {
  padding: 13px 13px; font-size: 13.5px; color: var(--text-3);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.portal-tab:hover { color: var(--accent-deep); border-bottom-color: var(--accent); }
.portal-clock {
  font-size: 11px; color: var(--muted); letter-spacing: .1em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  flex: 0 0 auto;
}
.portal-fold { position: relative; }
.portal-fold-btn {
  cursor: pointer; list-style: none; padding: 4px 11px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 4px; color: var(--text-3);
}
.portal-fold-btn::-webkit-details-marker { display: none; }
.portal-fold-panel {
  position: absolute; right: 0; top: 140%; z-index: 12; min-width: 160px;
  display: flex; flex-direction: column; padding: 8px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(20, 30, 40, .08);
}
.portal-fold-panel a { padding: 5px 8px; font-size: 13px; }

/* ------------------------------------------------------------------ layout */
.portal-layout {
  display: grid; grid-template-columns: 176px minmax(0, 1fr) 248px;
  max-width: 1280px; margin: 0 auto; width: 100%;
  /* 栅格默认 align-content:stretch 会把剩余高度摊给 auto 行：窄屏三栏变三行、
     内容又只有 404 那么短时，左栏那一行会被撑到 297px，正文被顶到下半屏。
     行高按内容走，不跟着视口长 */
  align-content: start;
}
.portal-side {
  padding: 22px 16px 30px 20px;
  border-right: 1px solid var(--border-soft);
  position: sticky; top: 0; align-self: start; max-height: 100vh; overflow: auto;
}
.portal-side-h {
  margin: 0 0 8px; font-size: 10.5px; letter-spacing: .2em; color: var(--muted);
}
.portal-side-nav { display: flex; flex-direction: column; }
.portal-side-link {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 6px 0; font-size: 13.5px; color: var(--text-3);
  border-bottom: 1px dotted var(--border-soft);
}
.portal-side-link:hover { color: var(--accent-deep); padding-left: 3px; }
.portal-side-n { font-weight: 400; font-size: 12px; color: var(--muted); }
.portal-side-meta { display: flex; flex-direction: column; gap: 2px; margin: 16px 0 0; }
.portal-stat {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 11px; color: var(--text-4);
}
.portal-stat b {
  font-weight: 400; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.portal-feed { padding: 22px 26px 60px; min-width: 0; }
.portal-hot {
  padding: 22px 18px 40px 20px;
  border-left: 1px solid var(--border-soft);
  position: sticky; top: 0; align-self: start; max-height: 100vh; overflow: auto;
}
.portal-hot-h {
  margin: 0 0 7px; font-size: 10.5px; letter-spacing: .2em; color: var(--muted);
}
.portal-hot-h + .portal-hot-t { margin-top: 0; }
.portal-hot-t { margin: 0 0 18px; font-size: 12px; line-height: 1.7; color: var(--text-4); }
.portal-hot-links { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.portal-hot-links a { color: var(--text-4); }
.portal-hot-links a:hover { color: var(--accent-deep); }

/* -------------------------------------------------------------------- hero */
.portal-hero { margin: 0 0 20px; }
.portal-hero-t { margin: 5px 0 0; font-size: 13px; color: var(--text-3); }
/* hero：首屏图已停用——右栏「本站导航」本来就写着同一句描述，图只是装饰。 */

/* -------------------------------------------------------------------- feed */
.portal-sec { margin: 0 0 26px; }
.portal-sec-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 7px; border-bottom: 2px solid var(--text); margin-bottom: 4px;
}
.portal-sec-h { margin: 0; font-size: 15.5px; font-weight: 700; }
.portal-sec-h a { color: var(--text); }
.portal-more { font-size: 11px; color: var(--muted); }
.portal-list { margin: 0; padding: 0; list-style: none; }
.portal-li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 8px 0; border-bottom: 1px dotted var(--border-soft);
}
.portal-li-t { font-size: 14.8px; color: var(--text); min-width: 0; }
.portal-li-t:hover { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 3px; }
.portal-li-d {
  flex: 0 0 auto; font-size: 10.5px; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ----------------------------------------------------------------- article */
.portal-post { max-width: 760px; }
.portal-crumb { margin: 0 0 10px; font-size: 11.5px; color: var(--muted); }
.portal-sep { margin: 0 6px; color: var(--border); }
.portal-h1 { margin: 0 0 8px; font-size: 27px; font-weight: 700; line-height: 1.4; }
.portal-meta {
  display: flex; align-items: center; gap: 10px; margin: 0 0 22px;
  padding-bottom: 12px; border-bottom: 1px solid var(--border-soft);
  font-size: 11.5px; color: var(--muted);
}
.portal-meta-c { color: var(--accent-deep); }
.portal-body { font-size: 15.5px; line-height: 1.9; color: var(--text-2); }
.portal-body p { margin: 0 0 1.1em; }
.portal-body h2 {
  margin: 1.9em 0 .6em; padding-left: 10px; border-left: 3px solid var(--accent);
  font-size: 19px; font-weight: 700; color: var(--text);
}
.portal-body h3 { margin: 1.5em 0 .5em; font-size: 16.5px; font-weight: 700; color: var(--text); }
.portal-body ul, .portal-body ol { margin: 0 0 1.1em; padding-left: 1.3em; }
.portal-body li { margin: .28em 0; }
.portal-body blockquote {
  margin: 1.4em 0; padding: 10px 14px;
  border-left: 2px solid var(--border); background: var(--surface-soft); color: var(--text-3);
}
.portal-body figure { margin: 1.5em 0; }
.portal-body figcaption { margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.portal-body table { width: 100%; border-collapse: collapse; margin: 1.3em 0; font-size: 13.5px; }
.portal-body th, .portal-body td { padding: 7px 9px; border: 1px solid var(--border-soft); text-align: left; }
.portal-body th { background: var(--surface-soft); }
.portal-body code {
  padding: 1px 4px; background: var(--surface-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em;
}

/* --------------------------------------------------------------- 右栏相关 */
.portal-related {
  display: flex; gap: 9px; padding: 8px 0;
  border-bottom: 1px dotted var(--border-soft);
}
.portal-related-img { width: 52px; height: 40px; object-fit: cover; flex: 0 0 auto; }
.portal-related-t { font-size: 12px; line-height: 1.55; color: var(--text-3); }

/* -------------------------------------------------------------------- foot */
.portal-foot { border-top: 1px solid var(--border); background: var(--surface); }
.portal-foot.is-min, .portal-foot.is-row { padding: 20px 24px; text-align: center; }
.portal-copy { margin: 0; font-size: 11px; color: var(--muted); }
.portal-friends, .portal-foot-nav {
  display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center;
  margin-top: 5px; font-size: 11.5px;
}
.portal-friends a, .portal-foot-nav a { color: var(--text-4); }
.portal-foot.is-cols { padding: 28px 20px 18px; }
.portal-foot-grid {
  display: grid; grid-template-columns: 1.5fr 1fr 1.3fr; gap: 22px;
  max-width: 1100px; margin: 0 auto 14px;
}
.portal-foot-col { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; }
.portal-foot-col a { color: var(--text-4); }
.portal-foot-h { margin: 0 0 2px; font-size: 11px; font-weight: 600; color: var(--text-2); }

@media (max-width: 1080px) {
  .portal-layout { grid-template-columns: 160px minmax(0, 1fr); }
  .portal-hot { display: none; }
}
@media (max-width: 780px) {
  .portal-layout { grid-template-columns: 1fr; }
  .portal-side { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .portal-side-nav { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; }
  .portal-side-link { border-bottom: 0; }
  .portal-side-meta { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
  .portal-feed { padding: 18px 16px 44px; }
  .portal-top-in { flex-wrap: wrap; padding: 0 16px; }
  .portal-top.is-stack { flex-wrap: wrap; gap: 0; padding: 0 16px; }
  /* 窄屏只留一个入口：频道条与「栏目」下拉是同一批链接，同时出现＝菜单两遍
     （390px 下频道条还会被挤成竖排单列），这里直接收起频道条整行 */
  .portal-top.is-stack .portal-top-row { display: none; }
  .portal-top.is-stack .portal-top-in { flex: 1 1 100%; justify-content: space-between; }
  .portal-top.is-stack .portal-fold { display: block; }
  /* 频道条让位后「栏目」是唯一菜单入口，触摸目标放大到 32px 高 */
  .portal-top.is-stack .portal-fold-btn { padding: 6px 12px; }
  .portal-top.is-stack .portal-clock { display: none; }
  .portal-top-row { padding: 6px 16px 8px; }
  /* is-left / is-center：品牌与频道条保持同一行，频道条拿剩余宽度横滑。
     拆成两行会让站名孤零零占一行、频道条贴在下边，视觉上更难看。 */
  .portal-top.is-left .portal-top-in, .portal-top.is-center .portal-top-in { flex-wrap: nowrap; gap: 10px; }
  .portal-top.is-left .portal-logo, .portal-top.is-center .portal-logo {
    flex: 0 1 auto; min-width: 0; order: 1;
  }
  .portal-top.is-left .portal-logo span, .portal-top.is-center .portal-logo span {
    display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .portal-top.is-left .portal-tabs, .portal-top.is-center .portal-tabs {
    flex: 1 1 auto; min-width: 0; order: 2; justify-content: flex-start;
  }
  .portal-top.is-left .portal-fold { order: 3; flex: 0 0 auto; }
  .portal-top.is-center .portal-clock { display: none; }
  .portal-tabs { gap: 0; }
  .portal-tab { padding: 10px 9px; }
  .portal-foot-grid { grid-template-columns: 1fr; gap: 14px; }
}

/* 手机宽度：日期（19 字符等宽 ≈130px）挤在标题右侧，把标题压成两行，自己还悬在
   首行基线上，读起来像贴在标题中间。标题先占满整行，时间另起一行做次级信息。
   620px 以上标题够宽、日期右对齐还能形成栏线，保持单行不变。 */
@media (max-width: 620px) {
  .portal-li { display: block; padding: 9px 0; }
  .portal-li-t { display: block; }
  .portal-li-d { display: block; margin-top: 3px; }
}

.portal-tab[aria-current="page"] { color: var(--accent-deep); border-bottom-color: var(--accent); }
.portal-fold-panel a[aria-current="page"] { color: var(--accent-deep); font-weight: 600; }

/* 侧栏栏目：portal 的栏目在左栏而不是顶部，当前栏同样标出来 */
.portal-side-link[aria-current="page"] { color: var(--accent-deep); font-weight: 600; }
