/* ============================================
   RyAurora 主题 - 响应式样式
   断点体系：
   >1024  桌面双栏（默认）
   ≤1024  平板单栏（侧栏下移，主栏全宽）
   ≤900   汉堡导航接管（PC 导航项过多时不再挤压）
   ≤768   手机布局（横排文章卡、触控优化）
   ≤480   窄屏手机进一步紧凑
   ============================================ */

/* ---- 大屏 (≥1440px)：放宽留白节奏 ---- */
@media (min-width: 1440px) {
    article,
    .container.two-col {
        gap: 32px;
    }
}

/* ---- 平板及以下 (≤1024px)：单栏布局，侧栏下移 ---- */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 280px;
    }

    article,
    .container.two-col {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
        padding: 0 16px;
        margin: 20px auto;
    }

    article > .sidebar,
    .container.two-col > .sidebar {
        grid-column: 1;
        position: static;
        width: 100%;
        max-width: 100%;
    }

    article > .blogsbox,
    .container.two-col > .blogsbox {
        grid-column: 1;
        width: 100%;
        max-width: 100%;
    }

    /* 轮播 + 置顶推荐 上下堆叠 */
    .picsbox {
        grid-template-columns: minmax(0, 1fr);
        gap: 20px;
    }

    .toppic-widget .toppic {
        position: static;
        flex-direction: row;
        gap: 12px;
    }

    .toppic-widget .toppic li {
        flex: 1;
        min-height: 120px;
    }

    .toppic-widget .toppic li img {
        width: 100%;
        height: 100%;
        min-height: inherit;
        aspect-ratio: auto;
        object-fit: cover;
    }

    .nav-list {
        gap: 0;
    }

    .nav-list > li > a {
        padding: 7px 8px;
        font-size: 0.87rem;
    }

    .nav .logo {
        margin-right: 10px;
    }

    .search_bar {
        margin-left: 10px;
    }

    .search_bar .input {
        width: 104px;
    }

    .search_bar form:focus-within .input {
        width: 124px;
    }

    .fader {
        padding-top: 52%;
    }

    /* 平板单栏下文章列表稍收窄图位，文字区留足空间 */
    .blogs {
        grid-template-columns: 196px minmax(0, 1fr);
        column-gap: 18px;
        padding: 16px 18px 12px 22px;
    }
}

/* ---- ≤1140px：导航项增至 10 个（含友情链接），提前收紧横向间距 ---- */
@media (max-width: 1140px) {
    .nav-list > li > a {
        padding: 7px 10px;
        font-size: 0.88rem;
    }

    .search_bar .input {
        width: 126px;
    }

    .search_bar form:focus-within .input {
        width: 150px;
    }
}

/* ---- ≤1000px：汉堡导航接管，避免导航项拥挤（900→1000：10 项导航挤压区间前移） ---- */
@media (max-width: 1000px) {
    /* 隐藏 PC 导航，显示移动导航 */
    .menu {
        display: none;
    }

    #mnav {
        display: block;
        width: 100%;
        max-width: 100%;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow-sm);
    }

    #mnav h2 {
        max-width: var(--container-max);
        margin: 0 auto;
        padding: 0 16px;
        height: var(--header-height);
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    #mnav .mlogo {
        font-size: 1.15rem;
        font-weight: 800;
        color: var(--color-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
    }

    #mnav .navicon {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        cursor: pointer;
        border-radius: var(--radius-sm);
        transition: background var(--transition-fast);
        flex-shrink: 0;
    }

    #mnav .navicon:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    #mnav .navicon::before,
    #mnav .navicon::after {
        content: '';
        position: absolute;
        width: 22px;
        height: 2.5px;
        background: var(--color-text);
        border-radius: 2px;
        transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #mnav .navicon::before {
        transform: translateY(-6px);
    }

    #mnav .navicon::after {
        transform: translateY(6px);
    }

    /* 中间横线：用 navicon 本身背景层模拟 */
    #mnav h2:not(.open) .navicon {
        background-image: linear-gradient(var(--color-text), var(--color-text));
        background-size: 22px 2.5px;
        background-repeat: no-repeat;
        background-position: center;
    }

    /* 展开状态：变换为 X 关闭图标 */
    #mnav h2.open .navicon {
        background-image: none;
    }

    #mnav h2.open .navicon::before {
        transform: rotate(45deg);
    }

    #mnav h2.open .navicon::after {
        transform: rotate(-45deg);
    }

    #mnav .list_dl {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        padding: 0 16px;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.3s ease,
                    padding 0.3s ease;
    }

    #mnav h2.open + .list_dl {
        display: block;
        max-height: 80vh;
        overflow-y: auto;
        opacity: 1;
        padding: 8px 16px 16px;
    }

    #mnav .list_dt a {
        display: block;
        padding: 12px 16px;
        border-radius: var(--radius-md);
        font-size: 0.95rem;
        color: var(--color-text);
        font-weight: 500;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        border-left: 3px solid transparent;
    }

    #mnav .list_dt a:hover,
    #mnav .list_dt a.current {
        background: rgba(13, 148, 136, 0.08);
        color: var(--color-primary);
        border-left-color: var(--color-primary);
        padding-left: 20px;
    }

    #mnav .list_dd {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        padding-left: 20px;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.3s ease 0.05s;
    }

    #mnav .list_dt.open + .list_dd {
        max-height: 300px;
        opacity: 1;
    }

    #mnav .list_dd li a {
        display: block;
        padding: 10px 14px;
        font-size: 0.88rem;
        color: var(--color-text-secondary);
        border-radius: var(--radius-sm);
        transition: all 0.2s ease;
        transform: translateX(0);
    }

    #mnav .list_dd li a:hover {
        color: var(--color-primary);
        background: rgba(13, 148, 136, 0.06);
        transform: translateX(4px);
    }

    /* 移动端搜索 */
    #mnav .search_bar {
        margin: 12px 0;
        width: 100%;
    }

    #mnav .search_bar .input,
    #mnav .search_bar form:focus-within .input {
        width: 100%;
    }
}

/* ============================================
   首页移动重排：功能卡片前置（仅 .index-page 首页，≤1024 单栏生效）
   倒计时/投票/公告 上浮至轮播图下方、文章列表上方；
   PC 端（>1024px）双栏布局不受影响
   ============================================ */
@media (max-width: 1024px) {
    /* 基础 article 的 align-items:start 会让新弹性子项收缩为内容宽，这里恢复拉伸撑满屏宽 */
    .index-page {
        align-items: stretch;
    }

    /* 解除 picsbox 与 sidebar 的容器盒，让其子模块直接参与 article 纵向排版 */
    .index-page > .picsbox,
    .index-page > .sidebar {
        display: contents;
    }

    /* 重排视觉顺序：轮播图 → 倒计时 → 投票 → 公告 → 置顶推荐(特别推荐，位置保持不变) → 文章列表 → 最近说说 → 最近留言 → 其余侧栏模块 */
    .index-page .picsbox > .banner { order: 1; }
    .index-page .sidebar > .countdown-widget { order: 2; }
    .index-page .sidebar > .vote-widget { order: 3; }
    .index-page .sidebar > .notice-widget { order: 4; }
    .index-page .picsbox > .toppic-widget { order: 5; }
    .index-page > .blogsbox { order: 6; }
    .index-page .sidebar > .ss-widget { order: 7; }
    .index-page .sidebar > .gb-widget { order: 8; }
    .index-page .sidebar > div,
    .index-page .sidebar > section { order: 9; }
}

/* ---- 手机 (≤768px) ---- */
@media (max-width: 768px) {
    :root {
        --header-height: 56px;
        --sidebar-width: 100%;
    }

    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }

    body {
        font-size: 15px;
        /* 顶部固定导航占位 + 底部安全区（全面屏手势条） */
        padding-top: var(--header-height);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    .container {
        padding: 0 16px;
        max-width: 100%;
    }

    header {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-width: 100vw;
        z-index: 1000;
    }

    /* 展开的菜单避开底部手势条 */
    #mnav h2.open + .list_dl {
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    #mnav .navicon {
        width: 42px;
        height: 42px;
    }

    /* 单栏内容布局 */
    article,
    .container.two-col {
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 0 12px;
        margin: 16px auto;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    article > .blank {
        display: none;
    }

    article > .blogsbox,
    article > .picsbox,
    article > .infosbox,
    article > .share,
    article > .timebox,
    article > .guestbook-container,
    article > .timeline-container,
    article > .search-results,
    article > .lry-form-box-wrap,
    .container.two-col > .blogsbox,
    .container.two-col > .sidebar {
        width: 100%;
        max-width: 100%;
        grid-column: unset;
    }

    article > .sidebar {
        width: 100%;
        max-width: 100%;
        position: static;
        display: flex;
        flex-direction: column;
        gap: 12px;
        grid-column: unset;
    }

    /* 轮播图 */
    .fader {
        padding-top: 56.25%;
        width: 100%;
    }

    .fader__slides .slide .imginfo {
        padding: 12px 14px 30px;
        font-size: 0.88rem;
    }

    /* 触屏无 hover：箭头常显为半透明 */
    .fader_controls .page.prev,
    .fader_controls .page.next {
        width: 34px;
        height: 34px;
        font-size: 1.05rem;
        opacity: 0.85;
    }

    .fader_controls .page.prev { left: 8px; }
    .fader_controls .page.next { right: 8px; }

    .pager_list li {
        width: 7px;
        height: 7px;
    }

    /* 置顶推荐恢复纵向卡片 */
    .toppic-widget {
        overflow: visible;
    }

    .toppic-widget .hometitle {
        margin-bottom: 12px;
    }

    .toppic-widget .toppic {
        position: static;
        flex-direction: column;
        gap: 12px;
    }

    .toppic-widget .toppic li {
        flex: none;
        min-height: 0;
    }

    .toppic-widget .toppic li img {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 7;
        object-fit: cover;
    }

    /* 文章卡片：标题通栏单行——图片与右栏摘要+阅读更多同行居中对齐，元信息通栏贴底；
       图文行高度由固定 16:10 图片主导（摘要恒3行不超图片高），列表项之间高度完全一致 */
    .blogs {
        grid-template-columns: minmax(0, 1fr) minmax(0, 0.74fr);
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "title title"
            "image text"
            "info  info";
        column-gap: 14px;
        row-gap: 8px;
        padding: 14px 16px 12px 20px;
    }

    /* 标题独占一行：单行显示，超长省略号截断（恒单行高，利于等高） */
    .blogtitle {
        padding: 0;
        font-size: 1.02rem;
        line-height: 1.45;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 图片容器去掉灰底/边框（沿用基础的 16:10 比例与垂直居中） */
    .blogpic {
        border: none;
        background: transparent;
        border-radius: 0;
    }

    .blogpic img {
        border-radius: var(--radius-sm);
    }

    /* 右栏摘要块与图片同行居中对齐（中线水平对齐）；"阅读更多"紧跟摘要文字 */
    .blogbody {
        align-self: center;
    }

    .blogtext {
        padding: 0;
        font-size: 0.82rem;
        line-height: 1.68;
        /* 统一截取 3 行摘要：块高恒小于图片高度，图文行高度由图片主导保证等高 */
        -webkit-line-clamp: 3;
    }

    /* "阅读更多"是摘要流内的普通行内元素，紧跟摘要文字之后 */
    .readmore {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        align-self: flex-start;
        margin-top: 6px;
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--color-primary);
    }

    .readmore i {
        font-size: 0.85em;
        transition: transform var(--transition-fast);
    }

    .readmore:active {
        color: var(--color-primary-dark);
    }

    /* 元信息通栏贴底一行 */
    .bloginfo {
        padding: 8px 0 0;
        border-top: 1px solid var(--color-border);
    }

    .bloginfo ul {
        gap: 4px 10px;
    }

    .bloginfo li {
        font-size: 0.76rem;
    }

    /* "次阅读"文字收起只留图标+数字；间距统一走 ul 的 gap，不再额外右移 */
    .bloginfo li.view .v-unit {
        display: none;
    }

    /* 窄屏信息行同样展示作者；过长昵称截断，空间不足时随整行 flex-wrap 换行 */
    .bloginfo li.author {
        max-width: 40%;
    }

    .bloginfo li.author a {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* 侧边栏组件移动端优化 */
    .sidebar > div,
    .sidebar > section,
    .notice-widget,
    .vote-widget,
    .countdown-widget {
        padding: 16px;
    }

    .zhuanti li i {
        width: 80px;
        height: 54px;
    }

    .tuijian .tjpic i {
        width: 90px;
        height: 60px;
    }

    .tuijian .sidenews li i {
        width: 64px;
        height: 48px;
    }

    .ss-widget .sidenews li i {
        width: 64px;
        height: 48px;
    }

    .tuijian .sidenews li p {
        font-size: 0.84rem;
        flex-basis: calc(100% - 74px);
    }

    .tuijian .sidenews li span {
        flex-basis: calc(100% - 74px);
        margin-left: 74px;
    }

    /* 面包屑 */
    .t_nav {
        width: 100%;
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    /* 文章内容 */
    .newsview {
        padding: 20px;
    }

    .news_title {
        font-size: 1.3rem;
    }

    .infosbox .bloginfo ul {
        gap: 10px;
    }

    .nextinfo-content {
        grid-template-columns: 1fr;
    }

    .next-article .nav-label {
        justify-content: flex-start;
    }

    /* 相关推荐 */
    .related-list {
        grid-template-columns: 1fr;
    }

    /* 评论区：头像缩小、内容左对齐 */
    .comment-item {
        padding: 12px 0;
        gap: 10px;
    }

    .comment-avatar {
        width: 36px;
        height: 36px;
    }

    .guestbook-content,
    .admin-reply {
        padding-left: 0;
        margin-left: 0;
    }

    /* 留言板 */
    .form-grid {
        grid-template-columns: 1fr;
    }

    .guestbook-form, .guestbook-list {
        padding: 18px;
    }

    /* 友链表单 */
    .lry-table-title {
        width: auto;
        display: block;
        text-align: left;
        padding: 4px 0;
    }

    .lry-input-text, .lry-textarea {
        max-width: 100%;
    }

    /* 时间轴的对齐规则由页面级 timeline.css 负责（.timeline::before 在该文件中为 content:none，轴线是 .timeline-arrow-top） */

    .timeline-header {
        padding: 25px 15px;
    }

    .timeline-header h1 {
        font-size: 1.4rem;
    }

    .event-item,
    .event-item:nth-child(odd),
    .event-item:nth-child(even) {
        flex-direction: row;
        width: 100%;
        margin-left: 0;
        padding: 0;
    }

    .event-item:nth-child(odd) .event-content,
    .event-item:nth-child(even) .event-content {
        margin-left: 10px;
        margin-right: 0;
        text-align: left;
    }

    .event-item:nth-child(odd) .event-date,
    .event-item:nth-child(even) .event-date {
        left: auto;
        right: auto;
    }

    .event-image {
        width: 40px;
        height: 40px;
        border-width: 2px;
    }

    .year-title h2 {
        font-size: 1.1rem;
        padding: 8px 18px;
    }

    /* 分页：加大触控目标 */
    #page a, .pagelist a, .pagination a {
        min-width: 40px;
        height: 40px;
        font-size: 0.85rem;
    }

    #page .jumppage,
    .pagelist .jumppage,
    .pagination .jumppage {
        height: 40px;
    }

    /* 回到顶部：避开安全区 */
    .cd-top {
        bottom: calc(20px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        width: 44px;
        height: 44px;
    }

    /* 留言快捷入口：叠在回到顶部正上方（20px 底距 + 44px 按钮高 + 10px 间距） */
    .cd-msg {
        bottom: calc(74px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        width: 44px;
        height: 44px;
    }

    /* 页脚 */
    footer {
        padding: 24px 16px;
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
        border-radius: 16px 16px 0 0;
    }

    footer::before {
        border-radius: 16px 16px 0 0;
    }

    footer p {
        font-size: 0.8rem;
    }

    /* 图文列表 */
    .share ul {
        grid-template-columns: 1fr;
    }

    .share-list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }

    /* 顶踩 */
    .digg_up, .digg_down {
        width: 64px;
        height: 64px;
        font-size: 1.1rem;
    }

    /* 消息提示：窄屏居中展示 */
    .message-toast {
        left: 16px;
        right: 16px;
        max-width: none;
    }
}

/* ---- 触屏设备：消除 hover 粘滞（点按后卡片/图片停留悬浮态） ---- */
@media (hover: none) {
    .sidebar > div:hover,
    .sidebar > section:hover,
    .share-card:hover,
    .shareli a:hover,
    .notice-widget:hover,
    .vote-widget:hover,
    .countdown-widget:hover,
    .event-content:hover {
        transform: none;
    }

    /* 触屏无悬停语义：抑制点按后的行洗色与左缘竖线残留 */
    .blogs:hover {
        background: transparent;
    }

    .blogs:hover::before {
        transform: scaleY(0);
    }

    /* ---- 触屏触摸反馈（.is-touching 由 index_page.js 在 touchstart 时挂上）----
       按下：左缘竖线自上而下点亮 + 竖线上流光循环下行 + 行底洗色 + 标题/缩略图/箭头联动；
       松开：竖线向底部收拢、其余元素平滑复位（PC 端 hover 效果不受影响） */
    .blogs.is-touching {
        background: rgba(13, 148, 136, 0.055);
    }

    /* 竖线本体：默认 origin 在底部，松开时向底部收拢，与按下时自顶部生长方向相反 */
    .blogs::before {
        transform-origin: bottom center;
    }

    .blogs.is-touching::before {
        transform: scaleY(1);
        transform-origin: top center;
        box-shadow: 0 0 10px rgba(13, 148, 136, 0.5);
    }

    /* 流光：一枚亮青光带贴着竖线自上而下循环滑行，赋予线条"通电"的流动感 */
    .blogs::after {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 4px;
        height: 26%;
        border-radius: 4px;
        background: linear-gradient(180deg, transparent, #5eead4, transparent);
        opacity: 0;
        transform: translateY(-100%);
        pointer-events: none;
    }

    .blogs.is-touching::after {
        opacity: 1;
        animation: blogs-touch-flow 1.1s linear infinite;
    }

    /* 光带自身高度为行的 26%：从完全隐藏于顶部滑到完全隐藏于底部约需位移 385% */
    @keyframes blogs-touch-flow {
        from { transform: translateY(-100%); }
        to   { transform: translateY(385%); }
    }

    /* 联动元素过渡准备（仅触屏设备生效，不改动 PC 的 hover 时间线） */
    .blogs .blogtitle a,
    .blogs .blogpic img,
    .blogs .readmore i {
        transition: color 0.2s ease, transform 0.25s ease;
    }

    /* 标题点亮为主题色 */
    .blogs.is-touching .blogtitle a {
        color: var(--color-primary);
    }

    /* 缩略图在容器内轻微放大（.blogpic overflow:hidden 保证不溢出圆角） */
    .blogs.is-touching .blogpic img {
        transform: scale(1.045);
    }

    /* "阅读更多"箭头右移一小步 */
    .blogs.is-touching .readmore i {
        transform: translateX(3px);
    }

    /* 减弱动态偏好：保留竖线点亮与变色，停用流光与缩放位移动画 */
    @media (prefers-reduced-motion: reduce) {
        .blogs.is-touching::after {
            animation: none;
            opacity: 0;
        }

        .blogs.is-touching .blogpic img,
        .blogs.is-touching .readmore i {
            transform: none;
        }
    }

    .share-card:hover .share-thumb img,
    .shareli a:hover img,
    .toppic-widget .toppic li:hover img,
    .zhuanti li:hover i img,
    .tuijian .tjpic:hover i img,
    .tuijian .sidenews li:hover i img,
    .ss-widget .sidenews li:hover i img {
        transform: none;
    }

    /* 触屏上箭头按钮不需要 hover 变色，保持可读 */
    .banner:hover .fader_controls .page.prev,
    .banner:hover .fader_controls .page.next {
        opacity: 0.85;
    }

    /* 触屏按压反馈：右下角快捷按钮（留言/回到顶部）轻按缩小 */
    .cd-msg:active,
    .cd-top.cd-is-visible:active {
        transform: scale(0.92);
    }
}

/* ---- 窄屏手机 (≤480px) ---- */
@media (max-width: 480px) {
    article,
    .container.two-col {
        padding: 0 8px;
        margin: 12px auto;
    }

    /* 窄屏杂志卡微调：右栏比例与字号再收一档 */
    .blogs {
        grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
        column-gap: 12px;
        padding: 12px 12px 10px 16px;
    }

    .blogtitle {
        font-size: 0.96rem;
    }

    .blogtext {
        font-size: 0.8rem;
    }

    .bloginfo ul {
        gap: 8px;
    }

    .bloginfo li {
        font-size: 0.72rem;
    }

    /* 侧边栏窄屏 */
    .sidebar > div,
    .sidebar > section,
    .notice-widget,
    .vote-widget,
    .countdown-widget {
        padding: 14px;
    }

    .zhuanti li i {
        width: 72px;
        height: 48px;
    }

    .tuijian .tjpic i {
        width: 80px;
        height: 54px;
    }

    .tuijian .sidenews li i {
        width: 56px;
        height: 42px;
    }

    .ss-widget .sidenews li i {
        width: 56px;
        height: 42px;
    }

    .tuijian .sidenews li p {
        flex-basis: calc(100% - 66px);
    }

    .tuijian .sidenews li span {
        flex-basis: calc(100% - 66px);
        margin-left: 66px;
    }

    .news_title {
        font-size: 1.2rem;
    }

    .timeline-header h1 {
        font-size: 1.2rem;
    }

    .event-image {
        width: 36px;
        height: 36px;
        border-width: 2px;
    }

    .event-content {
        padding: 12px 14px;
    }

    .event-content h3 {
        font-size: 0.95rem;
    }

    .event-content p {
        font-size: 0.82rem;
    }

    .lry-table td {
        display: block;
        padding: 4px 0;
    }

    .lry-table-title {
        display: block;
    }

    /* 密码门控表单紧凑化 */
    .article-password-gate {
        padding: 32px 16px;
    }
}
