/* ==========================================================================
   轩玩聚集地 — 桌面端三栏布局修正
   2026-10-23

   问题现象（用户反馈 + 截图确认）：
     左侧栏是 position:fixed（不参与父容器宽度计算），
     而中间区 .cushomewider 用 width:52.5%、右栏 .cushomesmaller 用 31.5%，
     两者合计 84% 是相对「整个父容器」算的，没扣掉左侧那 260px，
     于是整行实际宽度 = 260px + 84% > 100%，内容被挤到右边界之外，
     表现为「中间那块过于突出、叠到旁边板块上」。

   修法：
     1. 把父容器改成 flex 布局，左/中/右用 flex 比例分配，天然不会溢出；
     2. 左侧栏保持 fixed 但显式留出空间，避免与 body padding 重复计算；
     3. 给中间区加 min-width:0（flex 子项防溢出关键）与 position:relative，
        让悬停卡片、底部工具栏都限制在中间列内，不再压到左右栏；
     4. 只在 ≥1025px 生效，不影响平板与手机。
   ========================================================================== */

@media (min-width: 1025px) {

  /* ① 父级：用 flex 分配，彻底消除百分比 + 固定宽度混算 */
  .page-margin > .row,
  .page-margin.row {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: flex-start;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* ② 三栏统一：flex 子项 + 允许收缩 + 各自独立层叠上下文 */
  .page-margin > .row > .offnavmenu,
  .page-margin > .row > .cushomewider,
  .page-margin > .row > .cushomesmaller,
  .page-margin > .row > .col-md-2,
  .page-margin > .row > .col-md-7,
  .page-margin > .row > .col-md-3 {
    float: none !important;
    min-width: 0 !important;          /* flex 子项防溢出的关键 */
    box-sizing: border-box;
  }

  /* ③ 左栏：占位宽（与 fixed 侧栏宽度一致），本身不需要额外内容宽度 */
  .page-margin > .row > .offnavmenu,
  .page-margin > .row > .col-md-2 {
    flex: 0 0 260px !important;
    max-width: 260px !important;
    width: 260px !important;
  }

  /* ④ 中栏：自适应剩余空间，左右各留 15px 间距 */
  .page-margin > .row > .cushomewider,
  .page-margin > .row > .col-md-7 {
    flex: 1 1 auto !important;
    width: auto !important;
    max-width: none !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
    position: relative;
    z-index: 1;                        /* 建立层叠上下文，浮动元素不出列 */
  }

  /* ⑤ 右栏：固定宽度，不被中间区挤压 */
  .page-margin > .row > .cushomesmaller,
  .page-margin > .row > .col-md-3 {
    flex: 0 0 300px !important;
    max-width: 300px !important;
    width: 300px !important;
    padding-left: 15px !important;
    padding-right: 0 !important;
  }

  /* ⑥ 中间列内部任何浮层都不得横向溢出到相邻板块 */
  .cushomewider .post,
  .cushomewider .post-container,
  .cushomewider .panel {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* ⑦ 发帖框底部工具栏：原本固定宽度会顶出中栏，改成 100% 内自适应 */
  .cushomewider .post-actions,
  .cushomewider .publisher-box-footer {
    width: 100% !important;
    box-sizing: border-box;
  }

  /* ⑧ 用户悬浮卡片（hovercard）在大屏下若定位越界，限制其最大宽度 */
  .cushomewider .hovercard,
  .cushomewider .user-popover-card {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* ⑨ 中屏（1025–1300）右栏略窄，避免挤占中间内容 */
@media (min-width: 1025px) and (max-width: 1300px) {
  .page-margin > .row > .cushomesmaller,
  .page-margin > .row > .col-md-3 {
    flex: 0 0 270px !important;
    max-width: 270px !important;
    width: 270px !important;
  }
}

/* ⑩ 超宽屏：给内容加个上限，避免中间栏被拉得过长难以阅读 */
@media (min-width: 1700px) {
  .page-margin > .row > .cushomewider,
  .page-margin > .row > .col-md-7 {
    max-width: 900px !important;
  }
}

/*
 * 轩玩聚集地 — 左侧栏「论坛」入口可见性保障
 * 2026-10-23
 *
 * 问题：桌面端左侧栏 overflow-y:auto，菜单 9 条 + 头像区，
 *      1080p 及以下屏幕里最后的「论坛」被滚出可视区，
 *      用户以为电脑端没有论坛入口（手机端弹层能滚，所以看得到）。
 *
 * 方案：侧栏改纵向 flex，菜单区可滚动，论坛项 sticky 吸附底部，
 *      无论菜单多长、屏幕多矮都可见。≤1024px 不生效，不影响移动端。
 */

@media (min-width: 1025px) {

  /* 侧栏整体纵向 flex */
  .offnavmenu {
    display: flex !important;
    flex-direction: column !important;
    height: calc(100vh - 50px) !important;
    overflow: hidden !important;
    padding-bottom: 0 !important;
  }

  /* 菜单区可滚动 */
  .offnavmenu .left-sidebar,
  .offnavmenu > div {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
  }
  .offnavmenu .left-sidebar::-webkit-scrollbar,
  .offnavmenu > div::-webkit-scrollbar { width: 5px; }
  .offnavmenu .left-sidebar::-webkit-scrollbar-thumb,
  .offnavmenu > div::-webkit-scrollbar-thumb {
    background: #d5d9e2; border-radius: 3px;
  }
  .offnavmenu .left-sidebar::-webkit-scrollbar-track,
  .offnavmenu > div::-webkit-scrollbar-track { background: transparent; }

  /* 论坛入口吸附底部，始终可见 */
  .offnavmenu li.xw-forum-pin {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 5;
    background: #fff !important;
    box-shadow: 0 -6px 12px -8px rgba(0, 0, 0, .18);
    border-top: 1px solid #f0f1f5;
    margin-bottom: 0 !important;
  }
  .offnavmenu li.xw-forum-pin > a {
    font-weight: 600;
  }

  /* 最后一项去掉原来的 50px 底部空白，避免论坛下沉到视口外 */
  .offnavmenu .left-sidebar ul li:last-child {
    margin-bottom: 0 !important;
  }
}
