/* ==========================================================================
   Cookie 同意横幅（v1.18.0 / v1.18.2 改为贴底部横条）
   ==========================================================================
   ⚠ 本文件**不在 bundle 内**，由 functions.php 条件加载 ——
     样式只服务这一个组件，不该让所有页面都背这几 KB。

   ⚠ 排版铁律：横幅是**新增**的独立浮层，不修改任何既有元素的样式。
     全部规则用 .tyst-consent 前缀，避免污染现有类名。

   ⚠ 层级：z-index 9999 —— 必须高于页头（z-index: 999）
     与移动端菜单（z-index: 100），否则会被压住。

   ⚠ v1.18.2（用户要求）：**贴底部横条，每次访问都显示**
     —— 形态从「居中浮动卡片」改成「固定在视口底部的整幅横条」。
   ========================================================================== */

/* ---------- 浮层容器：贴底整幅横条 ---------- */
.tyst-consent {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: var(--bg);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(20, 20, 20, .10);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/*
 * ⚠⚠⚠ **[hidden] 必须显式 !important**（项目铁律）
 *
 * v1.18.1 实测踩过**两个**坑：
 *   ① `.tyst-consent__cats { display: grid }` 的特异性**高于**浏览器 UA
 *      样式表里的 `[hidden] { display: none }` —— HTML 上明明写了
 *      `hidden`，分类列表却照样显示出来。
 *   ② 后代选择器 `.tyst-consent [hidden]` 匹配的是**容器内部的**元素，
 *      **匹配不到容器自己** —— 所以 `.tyst-consent` 的 `display: flex`
 *      照样生效，同意后横幅不消失。
 *
 * ⚠ 而且这不会报错、不会白屏，浏览器测试里查 DOM 属性 `.hidden === true`
 *   也是 true —— **只有看截图才发现**。
 *
 * ✅ 一条规则统一覆盖：自身 + 后代，别再逐个补。
 */
.tyst-consent[hidden],
.tyst-consent [hidden] {
  display: none !important;
}

/* ---------- 横条内层：内容居中，文字与按钮左右分布 ---------- */
.tyst-consent__inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex;
  align-items: center;
  gap: 10px 28px;
  flex-wrap: wrap;
}

/* ---------- 标题与正文 ---------- */
.tyst-consent__text {
  flex: 1 1 420px;
  min-width: 0;
}

.tyst-consent__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}


.tyst-consent__body {
  margin: 0;
  font-size: .85rem;
  line-height: 1.6;
  color: var(--ink-mute);
}

/* ---------- 分类列表（管理偏好时展开） ---------- */
.tyst-consent__cats {
  margin: 12px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--line-soft);
  list-style: none;
  display: grid;
  gap: 10px;
  flex: 1 1 100%;
}

.tyst-consent__cat-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.tyst-consent__cat-input {
  margin: 3px 0 0;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  accent-color: var(--brand-red);
  cursor: pointer;
}

.tyst-consent__cat-input:disabled {
  cursor: not-allowed;
  opacity: .65;
}

.tyst-consent__cat-text {
  display: block;
  font-size: .85rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.tyst-consent__cat-text strong {
  display: block;
  font-weight: 600;
  color: var(--ink);
}

.tyst-consent__cat-desc {
  display: block;
  color: var(--ink-mute);
}

/* ---------- 按钮 ---------- */
.tyst-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
}

.tyst-consent__actions--prefs {
  flex: 1 1 100%;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.tyst-consent__btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: .86rem;
  font-weight: 500;
  line-height: 1.2;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}

.tyst-consent__btn:hover {
  border-color: var(--ink-faint);
}

.tyst-consent__btn:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
}

.tyst-consent__btn--primary {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #fff;
}

.tyst-consent__btn--primary:hover {
  background: var(--brand-red-dark);
  border-color: var(--brand-red-dark);
}

.tyst-consent__btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-mute);
  padding-left: 4px;
  padding-right: 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tyst-consent__btn--ghost:hover {
  color: var(--ink);
  border-color: transparent;
}

/* ---------- 说明链接 ---------- */
.tyst-consent__link {
  margin: 0;
  font-size: .82rem;
  flex: 0 0 auto;
}

.tyst-consent__link a {
  color: var(--brand-red);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

.tyst-consent__noscript {
  margin: 8px 0 0;
  font-size: .82rem;
  line-height: 1.6;
  color: var(--ink-mute);
  flex: 1 1 100%;
}

/* ==========================================================================
   顶开右下角「回到顶部」按钮
   ==========================================================================
   ⚠ 横条是贴底整幅的，会盖住 .back-to-top（bottom:24px 的圆形按钮）。
   ⚠ 高度必须由 JS 实测写入 --tyst-consent-h（窄屏横条更高），
     这里不能写死数值。
   ⚠ 只在横条显示时生效（body.has-tyst-consent 由 JS 加）——
     横条是 fixed 浮层，不占文档流，不会把页面内容顶上去。
   ========================================================================== */
body.has-tyst-consent .back-to-top {
  bottom: calc(24px + var(--tyst-consent-h, 0px));
}

/*
 * ⚠⚠⚠ **页面底部必须留出横条的高度**（v1.18.4 修）
 *
 * 实测问题：联系页的留言文本域（textarea[name="message"]）
 * 正好在页面最底部 —— 访客滚到底部填写时，**横条盖住了输入框**，
 * 点不进去、也看不到自己输入的内容。
 *
 * ⚠ 为什么要加在 body 上而不是某个页面：
 *   任何页面的最底部元素都可能被横条盖住（留言区、页脚版权、翻页…），
 *   这是**全站通用**的问题，不该逐页处理。
 *
 * ⚠ 用 `margin-bottom` 而不是 `padding-bottom`：
 *   padding 会让页脚自身的背景色（深色）也被拉高一块，
 *   视觉上多出一条空白；margin 只会把整块内容往上顶。
 *
 * ⚠ 高度由 JS 实测写入 --tyst-consent-h —— 窄屏横条更高，
 *   写死数值会在手机上又出现遮挡。
 */
body.has-tyst-consent {
  margin-bottom: var(--tyst-consent-h, 0px);
}

@media (max-width: 640px) {
  body.has-tyst-consent .back-to-top {
    bottom: calc(16px + var(--tyst-consent-h, 0px));
  }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 640px) {
  .tyst-consent__inner {
    padding: 12px 16px 14px;
    gap: 10px 12px;
  }

  .tyst-consent__text {
    flex: 1 1 100%;
  }

  .tyst-consent__actions {
    flex: 1 1 100%;
  }

  .tyst-consent__btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .tyst-consent__btn--ghost {
    flex: 1 1 100%;
  }

  .tyst-consent__link {
    flex: 1 1 100%;
  }
}

/* ---------- 尊重「减少动效」偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  .tyst-consent__btn {
    transition: none;
  }
}
