/* css/side-drawer.css —— 全站公用左侧边条菜单（「我的」抽屉）
   规格依据 doc/左侧边条菜单设计文档.md */

/* ===== 入口：汉堡按钮 ===== */
.sd-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.sd-hamburger:active {
    opacity: .7;
}

/* 蓝色导航栏（白图标）。
   margin-right 原为 12px——那是"汉堡紧挨站名"时代给站名留的间距；
   2026-10-21 汉堡右侧加了回首页小房子，改 4px：与房子保持 10px
   （4 + 顶栏 gap 6），房子与站名也同样 10px，三个元素节奏均匀。 */
.sd-hamburger-navbar {
    color: #ffffff;
    margin-right: 4px;
}

.sd-hamburger-navbar:active {
    background: rgba(255, 255, 255, .15);
    opacity: 1;
}

/* 浅底顶栏（深图标）：文章列表页返回条 */
.sd-hamburger-plain {
    color: #1f2937;
}

.sd-hamburger-plain:active {
    background: rgba(0, 0, 0, .06);
    opacity: 1;
}

/* 蹭饭地图左侧面板（深色文字） */
.sd-hamburger-map {
    color: #1f2937;
    margin-right: 8px;
}

.sd-hamburger-map:active {
    background: rgba(0, 0, 0, .06);
    opacity: 1;
}

/* ===== 遮罩与容器 ===== */
.sd-mask {
    position: fixed;
    inset: 0;
    z-index: 9999; /* 高于底部 Tab Bar(9998) 与 Bootstrap Modal(1055) */
    background: rgba(0, 0, 0, .5);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
}

.sd-drawer {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    width: 320px;
    height: 100vh;
    height: 100dvh;
    background: #ffffff;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .18);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .28s cubic-bezier(.32, .72, 0, 1), visibility .28s;
    display: flex;
    flex-direction: column;
}

body.sd-open .sd-mask {
    opacity: 1;
    visibility: visible;
}

body.sd-open .sd-drawer {
    transform: translateX(0);
    visibility: visible;
}

.sd-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

/* ===== ① 身份区 ===== */
.sd-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    /* 左边距压到 10px：让「小房子」大致落在汉堡按钮原来的位置上 */
    padding: 20px 16px 18px 10px;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
}

/* 抽屉滑出后接管汉堡按钮的位置与职能：点击回首页 */
.sd-home {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .12);
    color: #ffffff;
    font-size: 19px;
    line-height: 1;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.sd-home:active {
    background: rgba(255, 255, 255, .26);
}

/* VIP 角标：抽屉右上角、昵称右侧 */
.sd-vip {
    flex: none;
    margin-left: auto;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #ffc107;
    color: #212529;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.sd-avatar {
    flex: none;
    position: relative;          /* 未读小红点的定位锚（2026-10-21 加，不影响静态布局） */
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, .4);
    color: #0d6efd;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 未读站内信小红点：由 js/side-drawer.js 按 window.__USER__.noticeUnread 生成。
   服务端每页渲染（一条 COUNT，无轮询）；在 me 页"全部标记已读"会 reload 整页，红点随之消失。 */
.sd-notice-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff4d4f;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}

.sd-profile-text {
    min-width: 0;
}

.sd-nickname {
    font-size: 17px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sd-subtitle {
    margin-top: 2px;
    font-size: 12px;
    font-weight: 400;
    color: rgba(255, 255, 255, .85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sd-subtitle-empty {
    color: #ffffff;
    text-decoration: underline dotted;
}

/* 昵称行：昵称 + 匿名态「（点击登录）」入口（2026-10-21） */
.sd-nick-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

/* flex 项默认 min-width:auto，nowrap 下不收缩会把省略号撑失效 */
.sd-nick-row .sd-nickname {
    min-width: 0;
}

/* 匿名态直登入口：长得像链接，实际是 <button>——保证键盘/读屏可达 */
.sd-login-hint {
    flex: none;
    padding: 0;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    color: rgba(255, 255, 255, .92);
    text-decoration: underline dotted;
    white-space: nowrap;
    cursor: pointer;
}

.sd-login-hint:hover,
.sd-login-hint:focus-visible {
    color: #ffffff;
    text-decoration: underline solid;
}

/* 头像与昵称改用 <button>（未登录点了要弹登录框）—— 重置浏览器默认按钮样式。
   不用 <div>+onclick 是因为 <div> 不可聚焦，键盘和读屏用户根本够不到。 */
button.sd-avatar {
    padding: 0;
    cursor: pointer;
    overflow: hidden;
}

button.sd-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

button.sd-nickname {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
}

/* ===== E2b：昵称铅笔（登录态渲染）+ 原地编辑 ===== */
.sd-nickname-pen {
    margin-left: 6px;
    font-size: 12px;
    opacity: .65;
    vertical-align: 2px;
}

button.sd-nickname:hover .sd-nickname-pen,
button.sd-nickname:focus-visible .sd-nickname-pen {
    opacity: 1;
}

.sd-nick-edit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sd-nickname-input {
    flex: 1;
    min-width: 0;
    padding: 2px 8px;
    font-size: 17px;
    font-weight: 600;
    color: #ffffff;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 8px;
    font-family: inherit;
}

.sd-nickname-input:focus {
    outline: none;
    background: rgba(255, 255, 255, .22);
}

.sd-nick-act {
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    color: #ffffff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sd-nick-act:disabled {
    opacity: .5;
    cursor: default;
}

.sd-nick-act.sd-nick-ok:hover {
    background: #198754;                /* 保存＝绿，取消＝红，不用文字说明 */
}

.sd-nick-act.sd-nick-cancel:hover {
    background: #dc3545;
}

button.sd-avatar:active,
button.sd-nickname:active {
    opacity: .75;
}

/* ===== 退出登录：红色语义，区别于「关于」 ===== */
.sd-signout .sd-menu-label,
.sd-signout .sd-menu-icon {
    color: #dc3545;
}

.sd-signout:hover .sd-menu-label,
.sd-signout:hover .sd-menu-icon {
    color: #dc3545;
}

/* ===== E2b：头像裁剪 modal ===== */
.sd-crop-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.sd-crop-box {
    background: #fff;
    border-radius: 14px;
    padding: 18px;
    width: 340px;
    max-width: 92vw;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}

.sd-crop-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    color: #212529;
}

.sd-crop-stage {
    position: relative;
    width: 300px;
    height: 300px;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    /* 棋盘格底色：图片未覆盖处一眼可辨 */
    background-color: #f0f0f0;
    background-image:
        linear-gradient(45deg, #e3e3e3 25%, transparent 25%),
        linear-gradient(-45deg, #e3e3e3 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e3e3e3 75%),
        linear-gradient(-45deg, transparent 75%, #e3e3e3 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.sd-crop-stage:active {
    cursor: grabbing;
}

.sd-crop-canvas {
    position: absolute;
    left: 0;
    top: 0;
    width: 300px;
    height: 300px;
    display: block;
}

/* 圆形取景框：白圈 + 圈外暗化，圈内是原图预览 */
.sd-crop-ring {
    position: absolute;
    left: 0;
    top: 0;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .92),
                0 0 0 9999px rgba(0, 0, 0, .45);
    pointer-events: none;
}

.sd-crop-zoom {
    width: 100%;
    margin: 14px 0 6px;
}

.sd-crop-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.sd-crop-btn {
    flex: 1;
    padding: 9px 0;
    border: 0;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.sd-crop-cancel {
    background: #f1f1f1;
    color: #333;
}

.sd-crop-ok {
    background: #0d6efd;
    color: #fff;
}

/* 头像最终显示为圆形（裁剪已输出圆形 PNG，这里双保险） */
.sd-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* ===== ② 热门文章 ===== */
.sd-articles {
    background: #f8f9fa;
}

.sd-section-title {
    padding: 16px 20px 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .5px;
    color: #868e96;
}

.sd-article-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    min-height: 48px;
    color: #212529;
    text-decoration: none;
}

.sd-article-item:active {
    background: #e9ecef;
}

.sd-article-index {
    flex: none;
    width: 18px;
    font-size: 12px;
    font-weight: 600;
    color: #adb5bd;
    font-variant-numeric: tabular-nums;
}

.sd-article-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sd-article-new {
    flex: none;
    padding: 0 5px;
    font-size: 11px;
    line-height: 16px;
    color: #ffffff;
    background: #c0392b;
    border-radius: 3px;
}

.sd-arrow {
    flex: none;
    font-size: 13px;
    color: #ced4da;
}

.sd-article-empty {
    color: #adb5bd;
    font-size: 13px;
}

.sd-more {
    display: block;
    padding: 12px 20px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #0d6efd;
    text-decoration: none;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
}

.sd-more:active {
    background: #e9ecef;
}

/* ===== ③ 设置 / ④ 关于 ===== */
.sd-settings {
    background: #ffffff;
    margin-top: 8px;
}

.sd-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 20px;
    min-height: 50px;
    border: 0;
    background: transparent;
    font-size: 15px;
    color: #212529;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

button.sd-menu-item:active,
a.sd-menu-item:active {
    background: #f1f3f5;
}

/* 一期占位：不可点击 */
.sd-menu-item.sd-placeholder {
    cursor: default;
}

.sd-menu-item.sd-placeholder:active {
    background: transparent;
}

.sd-menu-icon {
    flex: none;
    width: 20px;
    font-size: 17px;
    text-align: center;
}

.sd-icon-subject { color: #0d6efd; }
.sd-icon-rank    { color: #198754; }
.sd-icon-major   { color: #fd7e14; }
.sd-icon-map     { color: #6c757d; }
.sd-icon-about   { color: #6c757d; }
.sd-icon-help    { color: #6c757d; }

.sd-menu-label {
    flex: 1 1 auto;
    min-width: 0;
}

.sd-footer {
    margin-top: 8px;
    border-top: 1px solid #e9ecef;
}

/* ===== 「关于」弹层 ===== */
.sd-modal-mask {
    position: fixed;
    inset: 0;
    z-index: 10000; /* 高于抽屉 */
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.sd-modal-mask.is-open {
    opacity: 1;
    visibility: visible;
}

.sd-modal {
    width: 100%;
    max-width: 391px;   /* 原 340px 加宽 15%（用户 2026-10-03 要求）；窄屏仍是 100% - 边距 */
    background: #ffffff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
}

.sd-modal-title {
    padding: 16px 20px 8px;
    font-size: 16px;
    font-weight: 600;
    color: #212529;
}

.sd-modal-body {
    padding: 0 20px 8px;
}

.sd-modal-name {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: #212529;
}

.sd-modal-line {
    margin: 0 0 4px;
    font-size: 13px;
    color: #6c757d;
}

.sd-modal-note {
    margin: 10px 0 0;
    font-size: 12px;
    line-height: 1.7;
    color: #868e96;
}

/* ===== 关于弹层里的用户ID + 点击复制 ===== */
.sd-modal-uid {
    margin: 8px 0 0;
    font-size: 13px;
    color: #495057;
}

/* 关于弹层里“加QQ好友请说明…”提示：右对齐、弱化 */
.sd-modal-qqhint {
    text-align: right;
    margin: 2px 0 0;
    font-size: 12px;
    color: #868e96;
}

.sd-uid-num {
    font-weight: 600;
    color: #212529;
}

.sd-uid-copy {
    margin-left: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: #0d6efd;
    font-size: 12px;
    cursor: pointer;
}

.sd-uid-copy:hover {
    text-decoration: underline;
}

/* ===== 关于弹层里的「数据上新日志」（点数据库版本展开） ===== */
.sd-updates {
    margin: 0 0 4px;
}

.sd-updates-sum {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    cursor: pointer;
    list-style: none;              /* 去掉 <summary> 默认的三角标记 */
    -webkit-tap-highlight-color: transparent;
}

.sd-updates-sum::-webkit-details-marker {
    display: none;
}

.sd-updates-sum:active {
    color: #495057;
}

.sd-updates-hint {
    margin-left: auto;
    font-size: 12px;
    color: #0d6efd;
    white-space: nowrap;
}

.sd-updates-hint i {
    font-size: 11px;
    transition: transform .2s ease;
}

/* 展开时箭头翻转 */
.sd-updates[open] .sd-updates-hint i {
    transform: rotate(180deg);
}

.sd-updates-list {
    margin: 8px 0 0;
    padding: 8px 12px;
    list-style: none;
    background: #f8f9fa;
    border-radius: 8px;
    max-height: 190px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sd-updates-list li {
    display: flex;
    gap: 8px;
    padding: 7px 0;
    font-size: 12px;
    line-height: 1.6;
    border-bottom: 1px dashed #e9ecef;
}

.sd-updates-list li:last-child {
    border-bottom: 0;
}

.sd-updates-date {
    flex: none;
    color: #0d6efd;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.sd-updates-text {
    min-width: 0;
    color: #495057;
}

.sd-modal-btn {
    display: block;
    width: calc(100% - 40px);
    margin: 12px 20px 20px;
    padding: 9px 0;
    border: 0;
    border-radius: 8px;
    background: #0d6efd;
    color: #ffffff;
    font-size: 15px;
    cursor: pointer;
}

.sd-modal-btn:active {
    background: #0a58ca;
}

/* ===== 移动端 ===== */
@media (max-width: 768px) {
    .sd-drawer {
        width: min(300px, 82vw);
        border-radius: 0 16px 16px 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, .22);
    }

    .sd-mask {
        background: rgba(0, 0, 0, .45);
    }

    .sd-profile {
        gap: 10px;
        padding: 18px 14px 16px 8px;
    }

    .sd-home {
        width: 34px;
        height: 34px;
        font-size: 18px;
    }

    .sd-article-title {
        font-size: 13px;
    }
}
