/* ============================================================
   components.css — 检索区、结果卡片、阶次表、详情抽屉、空状态
   ============================================================ */

/* ---------- 检索面板 ---------- */
.search-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.search-box {
  display: flex;
  gap: 8px;
}

.search-box__input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: #fbfcfe;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box__input::placeholder {
  color: var(--c-text-3);
}

.search-box__input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(22, 102, 217, 0.12);
  background: #fff;
}

/* 清空按钮（type=search 原生按钮在部分浏览器不显示，这里自绘） */
.search-box__inner {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}

.search-box__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: #eef2f7;
  color: var(--c-text-2);
  cursor: pointer;
  line-height: 1;
  display: none;
}

.search-box__clear[data-visible="true"] {
  display: block;
}

.search-box__btn {
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radius);
  background: var(--c-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}

.search-box__btn:hover {
  background: var(--c-primary-dark);
}

.quick-tags {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--c-text-3);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quick-tag {
  padding: 2px 9px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #fff;
  color: var(--c-text-2);
  cursor: pointer;
  font-size: 12.5px;
  transition: all 0.15s;
}

.quick-tag:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: var(--c-primary-light);
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--c-border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group__label {
  font-size: 12.5px;
  color: var(--c-text-3);
  flex: none;
}

.select {
  height: 34px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%237b8794' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 9px center;
  appearance: none;
  cursor: pointer;
  max-width: 240px;
}

.chip {
  padding: 4px 11px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #fff;
  color: var(--c-text-2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
}

.chip[aria-pressed="true"] {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
  font-weight: 600;
}

/* 阶次筛选 chip 用各自色系 */
.chip--lv1[aria-pressed="true"] { background: var(--lv1-fg); border-color: var(--lv1-fg); }
.chip--lv2[aria-pressed="true"] { background: var(--lv2-fg); border-color: var(--lv2-fg); }
.chip--lv3[aria-pressed="true"] { background: var(--lv3-fg); border-color: var(--lv3-fg); }
.chip--lv4[aria-pressed="true"] { background: var(--lv4-fg); border-color: var(--lv4-fg); }
.chip--lv5[aria-pressed="true"] { background: var(--lv5-fg); border-color: var(--lv5-fg); }

/* ---------- 结果区 ---------- */
.result-head {
  margin: 18px 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.result-count {
  font-size: 13.5px;
  color: var(--c-text-2);
}

.result-count strong {
  color: var(--c-primary);
  font-size: 16px;
  margin: 0 2px;
}

.result-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

/* ---------- 事项卡片 ---------- */
.card {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.card:hover {
  border-color: #b9cdf0;
  box-shadow: var(--shadow);
  text-decoration: none;
}

.card:active {
  transform: translateY(1px);
}

.card__top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card__no {
  flex: none;
  min-width: 34px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  background: var(--c-primary-light);
  color: var(--c-primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.card__act {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--c-text);
}

.card__meta {
  margin: 8px 0 0 44px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: #f1f4f9;
  color: var(--c-text-2);
  font-size: 12px;
  white-space: nowrap;
}

.tag--exempt {
  background: var(--c-accent-light);
  color: var(--c-accent-text);
  font-weight: 600;
}

.tag--cat {
  background: #eef3fd;
  color: #3a63a8;
}

/* 阶次色块条 */
.level-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.level-dot {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
}

.lv1 { background: var(--lv1-bg); color: var(--lv1-fg); }
.lv2 { background: var(--lv2-bg); color: var(--lv2-fg); }
.lv3 { background: var(--lv3-bg); color: var(--lv3-fg); }
.lv4 { background: var(--lv4-bg); color: var(--lv4-fg); }
.lv5 { background: var(--lv5-bg); color: var(--lv5-fg); }

.card__fine {
  margin: 10px 0 0 44px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #fafbfd;
  border: 1px solid #eef1f6;
  font-size: 13px;
  color: var(--c-text-2);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.card__fine b {
  color: var(--c-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* 搜索命中高亮 */
mark {
  background: #fff2ac;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* ---------- 空状态 ---------- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--c-text-3);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.empty__title {
  font-size: 15px;
  color: var(--c-text-2);
  font-weight: 600;
  margin-bottom: 6px;
}

.empty__hint {
  font-size: 13px;
  line-height: 1.9;
}

/* ---------- 详情抽屉 ---------- */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}

.drawer[hidden] {
  display: none;
}

.drawer__mask {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  animation: fadeIn 0.18s ease;
}

.drawer__panel {
  position: relative;
  width: min(680px, 100%);
  height: 100%;
  background: var(--c-surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from { transform: translateX(24px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer__head {
  flex: none;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--c-border);
  background: #fff;
}

.drawer__head-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.drawer__title {
  font-size: 17px;
  line-height: 1.5;
  font-weight: 700;
  flex: 1;
  margin: 0;
}

.drawer__close {
  flex: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--c-text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.drawer__close:hover {
  background: #f5f7fa;
  color: var(--c-text);
}

.drawer__sub {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 32px;
  overscroll-behavior: contain;
}

/* ---------- 正文区块 ---------- */
.section {
  margin-bottom: 22px;
}

.section:last-child {
  margin-bottom: 0;
}

.section__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text-3);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section__title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* 法定依据：保留原始换行 */
.legal {
  margin: 0;
  padding: 12px 14px;
  background: #fbfcfe;
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.85;
  color: var(--c-text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 阶次清单 ---------- */
.tier {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.tier__head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  background: #fafbfd;
  border-bottom: 1px solid var(--c-border);
}

.tier__lv {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
}

.tier__fine {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--c-text-3);
  font-variant-numeric: tabular-nums;
}

.tier__body {
  padding: 11px 12px;
  display: grid;
  gap: 10px;
}

.tier__row {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 10px;
  font-size: 14px;
  line-height: 1.75;
}

.tier__label {
  color: var(--c-text-3);
  font-size: 12.5px;
  padding-top: 2px;
}

.tier__text {
  white-space: pre-wrap;
  word-break: break-word;
}

.tier__text--key {
  font-weight: 600;
  color: var(--c-text);
}

/* ---------- 提示条 ---------- */
.callout {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius);
  background: var(--c-accent-light);
  border: 1px solid #bfe6d7;
  color: #14624a;
  font-size: 13.5px;
  line-height: 1.75;
}

.callout--info {
  background: var(--c-primary-light);
  border-color: #cfe0fb;
  color: #17458c;
}

.callout__icon {
  flex: none;
  font-size: 15px;
  line-height: 1.6;
}

/* ---------- 口径说明 ---------- */
.note-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--c-border);
  font-size: 14px;
  line-height: 1.8;
}

.note-item:last-child {
  border-bottom: 0;
}

.note-item__no {
  color: var(--c-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- 轻罚清单行 ---------- */
.exempt-item {
  padding: 13px 15px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  margin-bottom: 10px;
}

.exempt-item__head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.exempt-item__no {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c-accent-light);
  color: var(--c-accent-text);
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  line-height: 24px;
}

.exempt-item__act {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.55;
}

.exempt-item__cond {
  margin: 8px 0 0 34px;
  font-size: 13.5px;
  color: var(--c-text-2);
  line-height: 1.75;
}

.exempt-item__link {
  margin: 8px 0 0 34px;
  font-size: 13px;
}

/* ---------- 小工具类 ---------- */
.muted {
  color: var(--c-text-3);
  font-size: 13px;
}

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.loading {
  padding: 40px 0;
  text-align: center;
  color: var(--c-text-3);
  font-size: 14px;
}

/* ---------- 返回顶部 ----------
   层级说明：tab-bar 是 sticky(z-index:20)，详情抽屉是 60，
   所以这里取 30 —— 高于吸顶导航、低于抽屉遮罩，抽屉打开时按钮被盖住。
   显隐用 opacity + visibility 过渡（display 无法过渡）；
   visibility:hidden 同时把按钮移出 Tab 焦点序列，键盘不会聚焦到隐藏按钮。 */
.to-top {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.to-top[data-show="true"] {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.to-top:hover {
  background: var(--c-primary-dark);
  box-shadow: var(--shadow-lg);
}

.to-top:active {
  transform: translateY(1px);
}

.to-top__icon {
  display: block;
}

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  .search-panel {
    padding: 12px;
    border-radius: var(--radius);
  }
  .search-box__btn {
    padding: 0 14px;
  }
  .card__meta,
  .card__fine {
    margin-left: 0;
  }
  .tier__row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .tier__label {
    padding-top: 0;
  }
  .drawer__panel {
    width: 100%;
    height: 92dvh;
    margin-top: auto;
    border-radius: 16px 16px 0 0;
    animation: slideUp 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  @keyframes slideUp {
    from { transform: translateY(30px); opacity: 0.7; }
    to { transform: translateY(0); opacity: 1; }
  }
  .drawer {
    align-items: flex-end;
  }

  /* 窄屏贴边更近，尺寸略缩但保持 42px ≥ 无障碍最小点击区 */
  .to-top {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: 42px;
    height: 42px;
  }
}
