/* ==========================================================================
   9b01.net 论坛（/zzjwlbbs/）移动端自适应补丁
   用法：在论坛头部模板 <head> 里加两行：
       <meta name="viewport" content="width=device-width, initial-scale=1">
       <link href="css/mobile.css" rel="stylesheet">
   本文件只做覆盖，不修改原有 bbs.css / hailan.css，可随时删除回滚。
   ========================================================================== */

html {
    -webkit-text-size-adjust: 100%;   /* 防止 iOS 横屏自动放大字号 */
    text-size-adjust: 100%;
}

/* 平板与手机：放开被写死的 960px，改为流式 */
@media screen and (max-width: 960px) {
    BODY {
        width: auto !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 6px !important;
        box-sizing: border-box;
    }

    /* 所有表格一律不超过屏幕宽度 */
    table {
        max-width: 100% !important;
    }
    /* 外层固定宽度的容器表改为占满 */
    table[width="950"],
    table[width="950px"],
    table[width="960"],
    table[width="960px"],
    table[width="921"],
    table[width="759"],
    table[width="759px"],
    table[width="730"],
    table[width="730px"],
    table[width="700"],
    table[width="700px"],
    table[width="600"],
    table[width="600px"] {
        width: 100% !important;
    }
    /* 版块页的图标图例（784px）在手机上纯占宽度，隐藏 */
    table[width="784"],
    table[width="784px"] {
        display: none !important;
    }
    /* 列表页搜索框固定 size，窄屏收窄 */
    INPUT[size="20"] {
        width: 92px !important;
    }
    /* 分页等被 nowrap 撑开的单元格允许换行 */
    TD[nowrap],
    TH[nowrap],
    #hailanpage {
        white-space: normal !important;
    }
    td[width="921"],
    td[width="950"],
    td[width="960"] {
        width: auto !important;
    }

    /* 图片、Flash/嵌入内容自适应 */
    img,
    object,
    embed,
    video,
    iframe {
        max-width: 100% !important;
        height: auto !important;
    }

    /* 12pt 在手机上过大，且 200% 行高太浪费屏幕 */
    DIV, FORM, TD, BODY, P, BR {
        font-size: 15px !important;
        line-height: 1.7 !important;
    }
    .menuitems {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }

    /* 表单控件不撑破布局 */
    INPUT, SELECT, TEXTAREA, BUTTON {
        max-width: 100%;
        box-sizing: border-box;
        font-size: 16px;   /* ≥16px 可避免 iOS 聚焦时页面缩放 */
    }
    TEXTAREA {
        width: 100% !important;
    }

    /* 长英文/链接强制换行，避免横向溢出 */
    TD, DIV, P {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    PRE {
        overflow-x: auto;
    }
}

/* 窄屏下登录表单纵向堆叠：三列横排 + 固定宽度输入框是主要撑宽源 */
@media screen and (max-width: 640px) {
    FORM[action="login.php"] TABLE,
    FORM[action="login.php"] TBODY,
    FORM[action="login.php"] TR,
    FORM[action="login.php"] TD {
        display: block !important;
        width: auto !important;
        text-align: left !important;
    }
    FORM[action="login.php"] TD {
        padding: 2px 0 !important;
    }
    FORM[action="login.php"] INPUT[size] {
        width: 100% !important;
        max-width: 220px;
    }
    INPUT[type="text"],
    INPUT[type="password"] {
        max-width: 100%;
    }
    MARQUEE {
        max-width: 100%;
    }
}

/* BBSxp 的隐藏通讯 iframe（height=0 width=0）会被上面的 height:auto 撑成 150px，
   在页面顶部形成一大块空白，这里直接隐藏（隐藏后仍可用于后台通讯） */
iframe[name="hiddenframe"],
iframe[width="0"],
iframe[height="0"] {
    display: none !important;
}

/* 首页右栏数字时钟（原 Flash 时钟替代品），窄屏缩小避免挤出边界 */
@media screen and (max-width: 640px) {
    #bbsClock {
        font-size: 15px !important;
        line-height: 1.4 !important;
        letter-spacing: 0 !important;
    }
}

/* 手机竖屏：进一步压缩边距，给正文更多宽度 */
@media screen and (max-width: 480px) {
    BODY {
        padding: 0 3px !important;
    }
    DIV, FORM, TD, BODY, P, BR {
        font-size: 14px !important;
        line-height: 1.65 !important;
    }
    /* 单元格内边距减半，避免内容被挤成一条 */
    TD {
        padding-left: 3px !important;
        padding-right: 3px !important;
    }
}

/* 首页三块列表（最新主题 / 人气 / 回复）：手机端由三列横排改为竖排 */
@media screen and (max-width: 640px) {
    table.homelists,
    table.homelists > tbody,
    table.homelists tr.a4 {
        display: block !important;
        width: auto !important;
    }
    table.homelists tr.a1 { display: none !important; }
    table.homelists tr.a4 > td {
        display: block !important;
        width: auto !important;
        box-sizing: border-box;
    }
    table.homelists tr.a4 > td + td { margin-top: 8px; }
    table.homelists tr.a4 > td::before {
        display: block;
        margin: 0 0 6px;
        padding: 4px 8px;
        background: #e8eff8;
        border-radius: 6px;
        color: #33507a;
        font-weight: 700;
        text-align: center;
    }
    table.homelists tr.a4 > td:nth-child(1)::before { content: "..::最新发表主题::.."; }
    table.homelists tr.a4 > td:nth-child(2)::before { content: "..::本周最强人气::.."; }
    table.homelists tr.a4 > td:nth-child(3)::before { content: "..::本周最多回复::.."; }
}

/* ===== 全站头部：统一为圆角白卡 ===== */
table.headbar,
table.headlogo {
    width: calc(100% - 24px) !important;
    max-width: 950px !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: #fff !important;
    border: 1px solid #e3e9f1 !important;
    border-radius: 13px !important;
    box-shadow: 0 1px 2px rgba(20, 40, 70, .05) !important;
    overflow: hidden !important;
}
table.headbar { margin: 10px auto 0 !important; }
table.headlogo { margin: 10px auto 16px !important; }
table.headbar td,
table.headbar tr,
table.headbar .a1,
table.headlogo td {
    background: transparent !important;
}
table.headbar td {
    padding: 9px 14px !important;
    color: #5b6b7c !important;
}
table.headbar #TableTitleLink { font-size: 13px; line-height: 1.9; }
table.headbar a { color: #2f6fb2 !important; }
table.headlogo td { padding: 10px 16px !important; vertical-align: middle; }
#logo a { display: block; }
#logo img { display: block; max-height: 64px; width: auto; }
table.headlogo td:last-child { text-align: right; }
table.headlogo td:last-child img { max-height: 64px; width: auto; max-width: 100%; }
table.headmsg {
    width: calc(100% - 24px) !important;
    max-width: 950px !important;
    margin: 8px auto 0 !important;
}
table.headmsg td {
    padding: 6px 12px !important;
    border: 1px solid #f3e2b8;
    border-radius: 10px;
    background: #fff8e6 !important;
    font-size: 13px;
}
@media screen and (max-width: 820px) {
    table.headlogo td:last-child { display: none !important; }
    table.headlogo td { padding: 12px !important; text-align: center; }
    #logo img { margin: 0 auto; max-height: 56px; }
    table.headbar td { padding: 8px 12px !important; }
}

table.headbar td,
table.headbar tr,
table.headbar table,
table.headlogo td,
table.headlogo table {
    border: 0 !important;
    outline: 0 !important;
}
table.headbar { border-spacing: 0 !important; }

/* 头部文字加大、加深，提升可读性 */
table.headbar #TableTitleLink {
    font-size: 14px !important;
    color: #334155 !important;
    letter-spacing: .2px;
}
table.headbar a {
    font-weight: 600 !important;
}
@media screen and (max-width: 820px) {
    table.headbar #TableTitleLink {
        font-size: 15px !important;
        line-height: 2 !important;
    }
}

/* 手机端头部导航：改为单行横向滑动的「胶囊条」，不再折行 */
@media screen and (max-width: 820px) {
    table.headbar td {
        padding: 0 !important;
    }
    table.headbar #TableTitleLink {
        display: block;
        white-space: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        padding: 10px 14px !important;
        font-size: 14px !important;
        line-height: 1.6 !important;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
        mask-image: linear-gradient(90deg, #000 calc(100% - 26px), transparent);
    }
    table.headbar #TableTitleLink::-webkit-scrollbar { display: none; }
    table.headbar #TableTitleLink a {
        display: inline-block;
        margin: 0 2px;
        padding: 3px 10px;
        border-radius: 999px;
        background: #f2f6fb;
        font-weight: 500 !important;
        line-height: 1.5;
    }
}

@media screen and (max-width: 820px) {
    table.headbar,
    table.headbar table {
        width: 100% !important;
        table-layout: fixed !important;
    }
    table.headbar td,
    table.headbar th {
        max-width: 100% !important;
        overflow: hidden;
    }
}

@media screen and (max-width: 820px) {
    .headnav-chips {
        display: inline-flex;
        flex-wrap: nowrap;
        gap: 8px;
        align-items: center;
    }
    .headnav-chips a {
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 5px 13px !important;
        border-radius: 999px;
        background: #f2f6fb;
        color: #2f6fb2 !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        line-height: 1.5;
        text-decoration: none;
    }
}

/* 手机端头部导航：胶囊自动换行，全部可见（不隐藏、不横向截断） */
@media screen and (max-width: 820px) {
    table.headbar #TableTitleLink {
        white-space: normal !important;
        overflow: visible !important;
        padding: 10px 12px !important;
        -webkit-mask-image: none !important;
        mask-image: none !important;
        font-size: 0 !important;
    }
    .headnav-chips {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        white-space: normal !important;
    }
    .headnav-chips a {
        flex: 0 0 auto !important;
        padding: 5px 12px !important;
        font-size: 14px !important;
        line-height: 1.5 !important;
    }
}

@media screen and (max-width: 820px) {
    .headnav-chips {
        width: calc(100vw - 48px) !important;
        max-width: 100% !important;
    }
}

/* 独立的手机端导航卡 */
#headnavMobile { display: none; }
@media screen and (max-width: 820px) {
    body.has-headchips table.headbar { display: none !important; }
    #headnavMobile {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        width: calc(100% - 24px) !important;
        max-width: 950px !important;
        margin: 10px auto 0 !important;
        padding: 10px 12px !important;
        background: #fff !important;
        border: 1px solid #e3e9f1 !important;
        border-radius: 13px !important;
        box-shadow: 0 1px 2px rgba(20, 40, 70, .05) !important;
        box-sizing: border-box !important;
    }
    #headnavMobile a {
        flex: 0 0 auto !important;
        padding: 5px 12px !important;
        border-radius: 999px !important;
        background: #f2f6fb !important;
        color: #2f6fb2 !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        line-height: 1.5 !important;
        text-decoration: none !important;
        white-space: nowrap;
    }
}

/* 手机端导航下拉菜单：白底圆角卡片 */
@media screen and (max-width: 820px) {
    #popmenu {
        background: #fff !important;
        background-image: none !important;
        border: 1px solid #e3e9f1 !important;
        border-radius: 11px !important;
        box-shadow: 0 10px 28px rgba(20, 40, 70, .16) !important;
        padding: 5px !important;
        max-width: calc(100vw - 24px) !important;
        box-sizing: border-box !important;
    }
    #popmenu .menuitems a,
    #popmenu a {
        display: block !important;
        padding: 9px 14px !important;
        border-radius: 8px !important;
        color: #334155 !important;
        font-size: 14px !important;
        line-height: 1.5 !important;
        text-decoration: none !important;
        white-space: nowrap !important;
    }
    #popmenu a:active,
    #popmenu a:hover {
        background: #eef4fb !important;
        color: #2f6fb2 !important;
    }
}

/* 首页统计表（头像 / 我的资料 / 论坛统计 / 时钟）：手机端由四列挤压改为纵向卡片 */
@media screen and (max-width: 820px) {
    table.idxstats {
        width: calc(100% - 24px) !important;
        max-width: 950px !important;
        margin: 10px auto 0 !important;
        border-collapse: separate !important;
        border-spacing: 0 !important;
        background: #fff !important;
        border: 1px solid #e3e9f1 !important;
        border-radius: 13px !important;
        overflow: hidden !important;
        box-shadow: 0 1px 2px rgba(20, 40, 70, .05) !important;
    }
    table.idxstats > tbody > tr { display: block !important; }
    table.idxstats > tbody > tr > td {
        display: block !important;
        width: auto !important;
        height: auto !important;
        padding: 9px 12px !important;
        background: #fff !important;
        border: 0 !important;
        box-sizing: border-box !important;
        text-align: center !important;
    }
    table.idxstats > tbody > tr > td + td,
    table.idxstats > tbody > tr + tr > td:first-child {
        border-top: 1px solid #eef2f7 !important;
    }
    /* 公告行 */
    table.idxstats .idxann { padding: 8px 12px !important; }
    table.idxstats .idxann table { margin: 0 auto !important; width: 100% !important; }
    table.idxstats .idxann td { border: 0 !important; }
    table.idxstats .idxann marquee { display: block; }
    /* 头像 / 快捷登录 */
    table.idxstats .idxface { padding: 12px !important; }
    table.idxstats .idxface img { max-height: 74px !important; width: auto !important; margin: 2px 6px; }
    /* 我的资料 3×3 链接：不再逐字换行 */
    table.idxstats .idxlinks { width: 100% !important; table-layout: auto !important; }
    table.idxstats .idxlinks td {
        padding: 3px 2px !important;
        font-size: 15px !important;
        line-height: 1.8 !important;
        white-space: nowrap !important;
        text-align: left !important;
        border: 0 !important;
    }
    /* 论坛统计数字 */
    table.idxstats .idxcount { width: 100% !important; table-layout: auto !important; }
    table.idxstats .idxcount td {
        padding: 3px 0 !important;
        font-size: 15px !important;
        line-height: 1.8 !important;
        white-space: nowrap !important;
        border: 0 !important;
    }
    /* 时钟、日期、星期合并为一行居中 */
    table.idxstats .idxclock {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 4px 14px !important;
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    table.idxstats .idxclock #bbsClock { font-size: 19px !important; letter-spacing: 1px !important; }
    /* 发帖 / 热门 / 精华 等快捷条 */
    table.idxstats .idxquick {
        padding: 8px 10px !important;
        font-size: 14px !important;
        line-height: 2.1 !important;
        white-space: normal !important;
    }
    table.idxstats .idxquick a { margin: 0 1px; }
    table.idxstats .idxquick font { color: #93a4b8; font-size: 10px; }
}
