/* ============================================================
   ProjectHub · 蓝白清爽主题
   布局：全屏应用外壳 —— 顶栏 / 内容区（内部滚动，滚动条隐藏）/ 底部状态栏
         body 自身 overflow:hidden，整页不出现滚动条
   ============================================================ */

:root {
  --bg:            #eef3fb;
  --bg-elev:       #ffffff;
  --bg-elev-2:     #f3f7fd;

  --surface:       rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;

  --ink:           #0f1f3a;
  --ink-muted:     #54677f;
  --ink-faint:     #93a1b5;

  --line:          rgba(28, 78, 168, 0.12);
  --line-strong:   rgba(28, 78, 168, 0.22);

  --primary:       #2f6bff;
  --primary-2:     #06b6d4;
  --primary-soft:  rgba(47, 107, 255, 0.10);
  --primary-glow:  rgba(47, 107, 255, 0.28);

  --ok:     #16a34a;
  --warn:   #d97706;
  --info:   #2563eb;
  --danger: #dc2626;

  --shadow:      0 18px 44px -22px rgba(20, 50, 110, .30);
  --shadow-soft: 0 10px 26px -16px rgba(20, 50, 110, .22);
  --radius: 16px;
  --transition: 200ms cubic-bezier(.4, 0, .2, 1);

  --topbar-h: 56px;
  --shell-max: 1400px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;      /* 移动端规避地址栏高度跳动 */
  overflow: hidden;    /* 全屏展示：整页不滚动 */
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

/* 背景光晕：固定在视口，不随内容滚动 */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: -1; pointer-events: none;
  background:
    radial-gradient(70% 55% at 10% -5%,  rgba(56, 120, 255, .14), transparent 62%),
    radial-gradient(55% 50% at 94% 0%,   rgba(6, 182, 212, .10), transparent 66%),
    radial-gradient(75% 60% at 55% 105%, rgba(99, 102, 241, .08), transparent 72%),
    var(--bg);
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* 隐藏滚动条但保留滚动能力 */
.no-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
.no-scrollbar::-webkit-scrollbar { width: 0; height: 0; display: none; }

.skip-link {
  position: absolute; left: 8px; top: -48px;
  background: var(--primary); color: #fff;
  padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; z-index: 9999;
  transition: top .2s;
}
.skip-link:focus { top: 8px; }

/* ========================= 顶栏 ========================= */
.topbar {
  position: relative;
  flex: none;
  z-index: 30;
  background: var(--surface);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--line);
}
.topbar-row {
  height: var(--topbar-h);
  max-width: var(--shell-max); margin: 0 auto;
  padding: 0 18px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: inline-flex; align-items: center; flex: none; }
/* Logo 保持原始透明度：不设背景色、不加阴影 */
.brand-logo { width: 34px; height: 34px; }
.topbar-spacer { flex: 1 1 auto; }

.count-badge {
  flex: none;
  background: var(--primary-soft);
  border: 1px solid var(--line);
  color: var(--primary);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 搜索 / 筛选开关 */
.search-toggle {
  position: relative;
  flex: none;
  width: 38px; height: 38px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: var(--transition);
}
.search-toggle:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--bg-elev-2);
}
.search-toggle[aria-expanded="true"] {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  box-shadow: 0 8px 20px -8px var(--primary-glow);
}
.toggle-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary-2);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .92);
}

/* 已生效筛选（面板收起时显示） */
.active-bar {
  max-width: var(--shell-max); margin: 0 auto;
  padding: 0 18px 10px;
  display: flex; align-items: center; gap: 10px;
}
.active-bar[hidden] { display: none; }
.active-bar-scroll {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 6px;
  overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.active-bar-scroll::-webkit-scrollbar { width: 0; height: 0; display: none; }
.active-chip {
  display: inline-flex; align-items: center; gap: 2px;
  flex: none;
  background: var(--primary-soft);
  border: 1px solid var(--line);
  color: var(--primary);
  padding: 2px 4px 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.active-chip button {
  width: 18px; height: 18px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: inherit; font-size: 13px; line-height: 1;
}
.active-chip button:hover { background: var(--primary-soft); color: var(--primary); }
.clear-all {
  flex: none; font-size: 12px; color: var(--ink-faint);
  padding: 4px 8px; border-radius: 8px;
}
.clear-all:hover { color: var(--primary); }

/* 展开面板：搜索框 + 分类 + 标签 */
.filter-panel {
  position: absolute; top: 100%; left: 0; right: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.70);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 26px 50px -22px rgba(20, 50, 110, .25);
  padding: 14px 18px 18px;
  max-height: calc(100dvh - var(--topbar-h) - 48px);
  overflow-y: auto;
  animation: panel-in .22s cubic-bezier(.2, .8, .2, 1);
}
.filter-panel[hidden] { display: none; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
.filter-panel-inner {
  max-width: var(--shell-max); margin: 0 auto; width: 100%;
  display: flex; flex-direction: column; gap: 14px;
}


.search-field {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.search-icon { width: 17px; height: 17px; fill: var(--ink-faint); flex: none; }
.search-input {
  flex: 1; min-width: 0;
  border: 0; outline: none; background: transparent;
  color: var(--ink); font-size: 14.5px; padding: 11px 0;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  color: var(--ink-faint);
  transition: var(--transition);
}
.search-clear.visible { display: inline-flex; }
.search-clear:hover { color: var(--primary); background: var(--primary-soft); }

.filter-group { display: flex; flex-direction: column; gap: 8px; }
.filter-title {
  margin: 0; font-size: 11px; color: var(--ink-faint);
  font-weight: 600; letter-spacing: .1em;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--ink-muted);
  font-size: 13px; transition: var(--transition);
  user-select: none; cursor: pointer;
}
.chip:hover {
  border-color: var(--line-strong);
  color: var(--ink); background: var(--bg-elev-2);
}
.chip.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 600;
  border-color: transparent;
  box-shadow: 0 8px 18px -8px var(--primary-glow);
}
.chip .count {
  font-size: 11px;
  background: rgba(15, 40, 90, .08);
  padding: 1px 6px; border-radius: 999px;
}
.chip.active .count { background: rgba(255, 255, 255, .22); }

/* ========================= 内容区 ========================= */
.stage { flex: 1 1 auto; min-height: 0; position: relative; }
.stage-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;   /* 避免滚动穿透到 body */
}
.stage-inner {
  max-width: var(--shell-max); margin: 0 auto;
  padding: 20px 18px 28px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.card:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
/* 透明热区：铺满整卡，天然可聚焦、可键盘触发 */
.card-hit {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  background: transparent; border: 0;
  cursor: pointer; z-index: 2;
  border-radius: inherit;
}

.card-cover {
  position: relative; aspect-ratio: 16/10;
  background: linear-gradient(135deg, #e8f0ff, #d6e4ff);
  overflow: hidden;
}
.card-cover img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .5s ease;
}
.card:hover .card-cover img { transform: scale(1.04); }

.cover-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 44px;
  color: var(--primary);
  letter-spacing: -.04em;
  text-shadow: none;
}
.cover-shimmer::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, .55) 50%, transparent 75%);
  -webkit-animation: shimmer 1.4s infinite;
  animation: shimmer 1.4s infinite;
  z-index: 1;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.card-body {
  padding: 13px 15px 15px;
  display: flex; flex-direction: column; gap: 8px; flex: 1;
}
.card-name {
  margin: 0; font-size: 15.5px; font-weight: 700;
  letter-spacing: -.01em; color: var(--ink);
}
.card-summary {
  margin: 0; color: var(--ink-muted);
  font-size: 13px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden; min-height: 3.6em;
}
.card-summary.placeholder { color: var(--ink-faint); font-style: italic; }
.card-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: auto; padding-top: 8px;
}
.tag {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: var(--primary-soft); color: var(--primary); font-weight: 500;
}
.tag.cat { background: rgba(34, 211, 238, .14); color: #0891b2; }
.card-arrow {
  margin-left: auto; align-self: center;
  color: var(--primary); font-size: 15px; font-weight: 700; line-height: 1;
  transition: transform var(--transition);
}
.card:hover .card-arrow { transform: translateX(3px); }

/* ========================= 空状态 ========================= */
.empty {
  text-align: center; padding: 56px 16px;
  color: var(--ink-muted);
  background: var(--bg-elev);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty-icon { font-size: 40px; }
.empty-title { margin: 8px 0 4px; color: var(--ink); font-size: 16px; }
.empty-desc { margin: 0 0 16px; font-size: 13px; }

/* ========================= 按钮 ========================= */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600;
  transition: var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 12px 24px -10px var(--primary-glow);
}
.btn-primary:hover { transform: translateY(-1px); }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-faint); transition: var(--transition);
}
.icon-btn:hover { color: var(--primary); background: var(--primary-soft); }

/* ========================= 底部状态栏 ========================= */
.footer {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--surface);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  padding: 7px 18px calc(7px + env(safe-area-inset-bottom));
}
.footer-inner {
  max-width: var(--shell-max); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 12px; color: var(--ink-faint);
}
.footer-status { display: flex; align-items: center; gap: 6px; }
.footer-legal { display: flex; align-items: center; gap: 10px; }
.footer-legal a { color: var(--ink-faint); transition: color var(--transition); }
.footer-legal a:hover { color: var(--primary); }

.cache-badge {
  font-size: 11.5px; color: var(--ink-faint);
  display: inline-flex; align-items: center; gap: 6px;
}
.cache-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-faint);
}
.cache-badge.fresh::before  { background: var(--ok);     box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.cache-badge.stale::before  { background: var(--warn);   box-shadow: 0 0 0 3px rgba(251, 191, 36, .18); }
.cache-badge.loading::before{ background: var(--info);   box-shadow: 0 0 0 3px rgba(96, 165, 250, .18); animation: pulse 1s infinite; }
.cache-badge.error::before  { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, .18); }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ========================= 提示条 ========================= */
.protocol-hint {
  flex: none;
  padding: 8px 18px;
  background: rgba(251, 191, 36, .12);
  border-bottom: 1px solid rgba(251, 191, 36, .3);
  color: #ad7a08;
  font-size: 12.5px; text-align: center;
}

/* ========================= 弹窗 ========================= */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 31, 58, .45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade-in .2s ease;
}
.modal-window {
  position: relative;
  width: min(1200px, 100%);
  height: min(84vh, 840px);
  max-height: 100%;
  background: var(--surface-solid);
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 34px 80px -22px rgba(20, 50, 110, .28);
  animation: modal-in .25s cubic-bezier(.2, .8, .2, 1);
}
.modal.fullscreen .modal-window {
  width: 100%; height: 100%;
  border-radius: 0; border: 0;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.modal-title-wrap { min-width: 0; flex: 1; }
.modal-title {
  margin: 0; font-size: 16px; font-weight: 700;
  white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}
.modal-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.modal-actions { display: flex; gap: 4px; flex: none; }

.modal-body { flex: 1; position: relative; background: var(--bg-elev); min-height: 0; }
.modal-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%; border: 0;
  background: #fff; display: block;
}
.modal-frame[hidden] { display: none; }

.modal-loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(135deg, #eef3fb, #e3ecfa);
  color: var(--ink-muted);
  z-index: 2;
  pointer-events: none;   /* 加载层不拦截 iframe 内的交互 */
  transition: opacity .25s ease, visibility .25s ease;
}
.modal-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(47, 107, 255, .2);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(238, 243, 251, .96);
  z-index: 3;
}
/* 关键修复：.modal-fallback 声明了 display:flex，会覆盖 UA 默认 [hidden]{display:none}，
   导致即便设置 hidden 属性兜底层仍铺满 modal-body 遮挡 iframe。显式补回隐藏规则。 */
.modal-fallback[hidden] { display: none; }
.modal-fallback .fb-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 24px; border-radius: var(--radius);
  max-width: 480px; text-align: center;
  box-shadow: var(--shadow);
}
.modal-fallback h4 { margin: 0 0 8px; font-size: 17px; }
.modal-fallback p { margin: 0 0 14px; color: var(--ink-muted); font-size: 13px; }
.modal-fallback .btn-primary { margin-top: 4px; }

/* ========================= Toast ========================= */
.toast {
  position: fixed; left: 50%; bottom: 56px;
  transform: translate(-50%, 16px);
  background: var(--bg-elev-2);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  padding: 9px 18px; border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0; transition: all .25s ease;
  z-index: 2000;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast[hidden] { display: none; }

/* ========================= 响应式 ========================= */
@media (max-width: 720px) {
  :root { --topbar-h: 52px; }
  .topbar-row { padding: 0 12px; gap: 8px; }
  .active-bar { padding: 0 12px 9px; }
  .filter-panel { padding: 12px; }
  .stage-inner { padding: 14px 12px 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card-name { font-size: 14px; }
  .card-summary { font-size: 12px; -webkit-line-clamp: 2; min-height: 2.6em; }
  .footer { padding-left: 12px; padding-right: 12px; }
  .footer-legal { gap: 8px; }
  .modal { padding: 0; }
  .modal-window { border-radius: 0; height: 100%; }
}
@media (max-width: 420px) {
  .cache-badge { font-size: 0; gap: 0; }        /* 仅保留状态圆点 */
  .footer-legal { flex-direction: column; align-items: flex-end; gap: 0; line-height: 1.3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
