/* 萌主题 mobile.css — 移动端 */

@media (max-width: 900px) {
  .moe-homepage-body,
  .moe-archive-body,
  .moe-single-wrap { grid-template-columns: 1fr; }

  .moe-sidebar { order: 2; }

  .moe-card-grid { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .moe-card-grid--related { grid-template-columns: repeat(2,1fr); }
  .moe-carousel__slide { height: 220px; }
  .moe-ad-grid { grid-template-columns: repeat(3,1fr); gap: 8px; }
  .moe-ad-item img { height: 66px; }
}

@media (max-width: 768px) {
  :root { --header-h: 52px; }
  html, body { overflow-x: hidden; max-width: 100%; }
  body { position: relative; }

  /* ══ 移动导航抽屉 ═══════════════════════════════════════════ */
  /* 遮罩层：菜单打开时降低主内容透明度 */
  .moe-nav-mask {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 94;
  }
  .moe-nav-mask.active { display: block; }

  /* 抽屉本体：从左侧滑入（汉堡按钮在左，动画方向与按钮位置保持一致） */
  .moe-nav {
    display: block !important;          /* 始终在 DOM 里，用 transform 控制显隐 */
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 80vw; max-width: 340px;
    min-height: 100dvh;
    background: var(--c-surface-s);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border-right: 1px solid var(--c-border);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    transform: translateX(-100%);       /* 默认隐藏到左侧 */
    pointer-events: none;               /* 关闭时不拦截点击/触摸事件 */
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    z-index: 95;
    padding: 0 0 calc(24px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
  }
  .moe-nav.open { transform: translateX(0); pointer-events: auto; }

  /* 抽屉头部：网站名 + 关闭按钮 */
  .moe-nav__brand--mobile {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border);
    position: sticky; top: 0;
    background: var(--c-surface-s);
    z-index: 1;
  }
  .moe-nav__brand-link {
    display: flex; align-items: center; gap: 8px;
    color: var(--c-text); font-weight: 700; font-size: 17px;
    text-decoration: none;
  }
  .moe-nav__brand .moe-logo__img { height: 28px; width: auto; }
  .moe-nav__brand .moe-logo__text {
    font-family: 'ZCOOL KuaiLe', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-weight: 400; letter-spacing: 1px; font-size: 20px;
    background: linear-gradient(90deg, #1a5d7e 0%, #5eb3d9 50%, #1a5d7e 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    color: transparent;
    animation: moe-logo-flow 5s linear infinite;
  }

  /* 关闭按钮（注入到 brand 区域内） */
  .moe-nav__close {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border: none; background: transparent;
    border-radius: 50%; cursor: pointer;
    color: var(--c-text-2); font-size: 20px; line-height: 1;
    transition: background var(--trans), color var(--trans);
    flex-shrink: 0;
  }
  .moe-nav__close:hover { background: var(--c-border); color: var(--c-text); }

  /* 菜单列表：左对齐，全行可点击 */
  .moe-nav__list {
    display: flex !important;
    flex-direction: column;
    gap: 0;
    padding: 8px 0;
    list-style: none;
    margin: 0;
    align-items: stretch;
  }
  .moe-nav__list li { width: 100%; }
  .moe-nav__list > li > a {
    display: flex; align-items: center;
    width: 100%; padding: 13px 20px;
    font-size: 15px; font-weight: 500;
    color: var(--c-text); text-decoration: none;
    text-align: left;
    border-radius: 0;
    transition: background var(--trans), color var(--trans);
  }
  .moe-nav__list > li > a:hover,
  .moe-nav__list > li.current-menu-item > a {
    background: rgba(94,179,217,0.1);
    color: var(--c-primary);
  }
  .moe-nav__list .sub-menu { display: none !important; }

  /* 打开时禁止页面滚动 */
  body.moe-nav-open { overflow: hidden; }

  .moe-logo { display: none; }
  .moe-hamburger { display: flex; }
  .moe-hamburger.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
  .moe-hamburger.active span:nth-child(2) { opacity: 0; }
  .moe-hamburger.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

  .moe-article { padding: 18px; }
  .moe-article__title { font-size: 20px; }
  .moe-footer__inner { flex-direction: column; gap: 12px; text-align: center; }
  .moe-footer__nav--right { display: none; }

  .moe-settings-panel { right: 8px; left: 8px; width: auto; }
  .moe-header__inner { padding: 0 12px; gap: 8px; }
  .moe-header__actions { margin-left: auto; gap: 2px; justify-content: flex-end; }
  .moe-header__action { padding: 6px 8px; }
  .moe-container { padding: 14px 12px; }
  .moe-ad-grid { grid-template-columns: repeat(3,1fr); gap: 6px; }

  /* iOS Safari */
  .moe-bg {
    background-attachment: scroll !important;
    position: fixed;
    transform: translateZ(0); -webkit-transform: translateZ(0);
  }
  .moe-header {
    position: -webkit-sticky; position: sticky;
    transform: translateZ(0); -webkit-transform: translateZ(0);
  }
  .moe-settings-panel { top: calc(var(--header-h) + 4px); }
}

@media (max-width: 480px) {
  .moe-card-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .moe-card__body { padding: 8px; }
  .moe-card__title { font-size: 13px; }
  .moe-carousel__slide { height: 180px; }
  .moe-carousel__title { font-size: 16px; }
  .moe-back-top { bottom: 16px; right: 12px; width: 38px; height: 38px; }

  .moe-article__actions { gap: 6px; }
  .moe-action-btn { padding: 6px 10px; font-size: 12px; }
  .moe-action-wrap { flex: 0 0 auto; }
  .moe-star { font-size: 20px; }
  .moe-search-bar { padding: 10px 12px; }
  .moe-search-bar form { max-width: 100%; }
  .moe-footer__inner { padding: 0 12px; }
}

/* 汉堡菜单：移动端排最左 */
@media (max-width: 768px) {
  .moe-hamburger { order: -1; margin-right: 4px; }
}
