/* ============================================
   奇棋网 layout.css — 侧边栏、顶栏、抽屉、hover 预览卡
   ============================================ */

/* ---------- 桌面布局：固定侧边栏 ---------- */
#sidebar-mount { display: contents; }

.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #fffdf8;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  overflow-y: auto;
  z-index: 100;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 16px;
  text-decoration: none !important;
}
.sidebar .logo img, .sidebar .logo svg { width: 44px; height: 44px; flex: none; }
.sidebar .logo b { font-size: 1.35rem; color: var(--text); }
.sidebar .logo small { display: block; color: var(--text-light); font-size: .72rem; font-weight: 400; }

.sidebar .group-title {
  font-size: .78rem;
  color: var(--text-light);
  font-weight: 700;
  letter-spacing: .12em;
  padding: 14px 10px 6px;
}

.game-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none !important;
  min-height: 44px;
  transition: background .15s;
}
.game-link:hover, .game-link.active { background: rgba(179, 71, 0, .1); }

/* 次级菜单（象棋/国象子页面） */
.sub-links { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px 18px; }
.sub-links a {
  padding: .32rem .8rem .32rem 1.1rem;
  border-radius: 8px;
  font-size: .86rem;
  color: var(--text-light);
  text-decoration: none;
  position: relative;
}
.sub-links a::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
  transform: translateY(-50%);
  transition: background .12s;
}
.sub-links a:hover { color: var(--primary); background: rgba(179, 71, 0, .07); }
.sub-links a:hover::before { background: var(--primary); }
.sub-links a.active { color: var(--primary); font-weight: 700; background: rgba(179, 71, 0, .09); }
.sub-links a.active::before { background: var(--primary); }
.game-link .thumb {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  flex: none;
}
.game-link > span { font-weight: 600; font-size: .98rem; }

.play-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--accent);
  text-decoration: none !important;
  font-weight: 600;
  min-height: 44px;
}
.play-link:hover, .play-link.active { background: rgba(47, 111, 79, .12); }
.play-link .ico { font-size: 1.15rem; }

.sidebar .bottom-links {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--border);
  font-size: .88rem;
}
.sidebar .bottom-links a { color: var(--text-light); text-decoration: none !important; }
.sidebar .bottom-links a:hover { color: var(--primary); }

/* ---------- hover 预览卡（仅精确指针设备） ---------- */
@media (hover: hover) and (pointer: fine) {
  .game-link .hover-card {
    position: fixed;
    left: calc(var(--sidebar-w) + 14px);
    width: 186px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;            /* 防悬停抖动 */
    transform: translateY(6px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s;
    z-index: 300;
    text-align: center;
  }
  .game-link:hover .hover-card, .game-link:focus-visible .hover-card {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .hover-card img, .hover-card svg {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    background: #fff;
  }
  .hover-card b { display: block; font-size: 1rem; color: var(--text); }
  .hover-card p { font-size: .8rem; color: var(--text-light); line-height: 1.5; margin: 2px 0 0; }
}

/* ---------- 主内容区 ---------- */
.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; }
.page { max-width: var(--maxw); margin: 0 auto; padding: 34px 28px 60px; }
.top-title {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}
.top-title .title-ico {
  width: 58px; height: 58px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  flex: none;
}
.top-title .title-ico img { width: 48px; height: 48px; }
.top-title .sub { color: var(--text-light); font-size: .95rem; margin-top: 2px; }

/* ---------- 移动端：顶栏 + 抽屉 ---------- */
.topbar { display: none; }

@media (max-width: 899px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: none;
    width: min(300px, 84vw);
  }
  body.drawer-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }

  .drawer-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(58, 46, 35, .4);
    z-index: 90;
  }
  body.drawer-open .drawer-mask { display: block; }

  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 80;
    background: rgba(250, 246, 239, .96);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .topbar .hamburger {
    width: 44px; height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .topbar .brand { font-weight: 800; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
  .topbar .brand svg, .topbar .brand img { width: 28px; height: 28px; }

  .main-wrap { margin-left: 0; }
  .page { padding: 22px 16px 48px; }

  /* hover 预览卡在触屏不可用 → 抽屉中直接显示缩略图（默认就有 .thumb） */
  .game-link .thumb { display: block; }
}

/* 桌面上抽屉内缩略图同样显示（小尺寸），保持一致 */
.game-link .thumb { display: block; }
