/* ═══════════════════════════════════════════════════════
 * LAAP 站点切换器
 *
 * 背景：design / game / app / mobile 是四个独立入口，
 * 但每个站的导航都是自己一套，彼此之间没有横向通路 ——
 * 用户在设计馆想去游戏站，只能靠记域名或退回某个入口页。
 *
 * 这个组件只做一件事：把四个站收进一个下拉，让"我在哪、还能去哪"一眼可见。
 *
 * 三条约束：
 *   1. **只用 CSS 变量** —— 四个站的主题各不同（深/浅/冷/暖），
 *      写死颜色必然有一边站挂掉
 *   2. **当前站不可点** —— 点自己等于刷新页面，用户会以为坏了
 *   3. **键盘可达** —— Esc 关闭、方向键移动、Tab 能进出
 * ═══════════════════════════════════════════════════════ */

.laap-sw {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
}

.laap-sw-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background .22s ease;
}
.laap-sw-trigger:hover { background: var(--ph-a, rgba(127, 127, 127, .1)); }
.laap-sw-trigger:focus-visible {
  outline: 2px solid var(--accent, #4a6bff);
  outline-offset: 2px;
}

/* 下拉箭头：只做提示，不抢视觉 */
.laap-sw-caret {
  width: 11px;
  height: 11px;
  opacity: .48;
  transition: transform .22s ease;
  flex: none;
}
.laap-sw.is-open .laap-sw-caret { transform: rotate(180deg); }

/* ───────────────────────────────────────────────────────
 * 菜单挂到 <body> 上，用 fixed 定位（见 laap-switcher.js 的 portal 说明）
 *
 * 为什么不能留在 .laap-sw 里用 absolute：
 *   导航栏 .pill-nav 有 backdrop-filter: blur(22px) **和** transform。
 *   这两个属性各自都会把元素变成“后代 fixed 元素的包含块” ——
 *   于是菜单的 position: fixed 不再是“相对视口”，而是“相对这条导航栏”，
 *   被死死困在那 60px 高的胶囊里，z-index 调到 99999 也出不去。
 *   实测 elementFromPoint 落在菜单中心，拿到的顶层元素是 <h1>。
 *
 * 只要导航还用玻璃效果，这个陷阱就一直在。所以菜单不留在导航里。
 * ─────────────────────────────────────────────────────── */
.laap-sw-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99999;
  width: 258px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line, rgba(0, 0, 0, .1));
  background: var(--card, #fff);
  box-shadow: 0 20px 52px rgba(0, 0, 0, .22), 0 2px 8px rgba(0, 0, 0, .08);
  transform-origin: top left;
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s cubic-bezier(.22, 1, .36, 1);
  /* 菜单挂到 body 后不再继承站点根节点的字体，要自己声明 */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--fg, #17171a);
}
.laap-sw-menu.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* 深色主题下阴影要更重，否则像浮着一层灰雾 */
html[data-theme="dark"] .laap-sw-menu {
  box-shadow: 0 22px 60px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .3);
}

.laap-sw-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 11px;
  text-decoration: none;
  color: var(--fg, #17171a);
  transition: background .16s ease;
}
.laap-sw-item:hover { background: var(--ph-a, rgba(127, 127, 127, .1)); }
.laap-sw-item:focus-visible {
  outline: 2px solid var(--accent, #4a6bff);
  outline-offset: -2px;
}

/* 当前站：不可点，用"这里"标出来 */
.laap-sw-item[aria-current="true"] {
  cursor: default;
  pointer-events: none;
  background: var(--ph-a, rgba(127, 127, 127, .08));
}
.laap-sw-item[aria-current="true"]:hover { background: var(--ph-a, rgba(127, 127, 127, .08)); }

.laap-sw-ico {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--ph-a, rgba(127, 127, 127, .1));
}
.laap-sw-ico svg { width: 15px; height: 15px; stroke-width: 1.7; }

.laap-sw-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.laap-sw-name {
  font-size: 13.5px;
  font-weight: 620;
  line-height: 1.25;
  white-space: nowrap;
}
.laap-sw-desc {
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--muted, #6b6b72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.laap-sw-here {
  margin-left: auto;
  flex: none;
  font-size: 10.5px;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--muted, #6b6b72);
  background: var(--ph-a, rgba(127, 127, 127, .1));
}

/* 窄屏：菜单改成近满宽，避免右侧被裁 */
@media (max-width: 560px) {
  .laap-sw-menu { width: min(86vw, 300px); }
}
