/* 定义暗黑主题颜色变量 */
:root {
  --bg-color: #1c1c1e;
  --nav-bg: #242426;
  --card-bg: #2c2c2e;
  --card-hover: #3a3a3c;
  --text-main: #ffffff;
  --text-sub: #98989d;
  --accent-color: #ff4d4f;
  /* 搜索按钮和激活态的红色 */
}

/* 新增：亮色模式覆盖规则 */
html[data-theme="light"] {
  --bg-color: #f2f2f7;
  /* 浅灰色背景 */
  --nav-bg: #ffffff;
  /* 纯白导航栏 */
  --card-bg: #ffffff;
  /* 纯白卡片 */
  --card-hover: #f5f5f5;
  /* 卡片悬停时的浅灰色 */
  --text-main: #1c1c1e;
  /* 黑色主文字 */
  --text-sub: #8e8e93;
  /* 灰色次要文字 */
}

/* ================= 亮色模式：搜索框定制 ================= */
html[data-theme="light"] .search-box input {
  background-color: #ffffff;
  /* 搜索框背景变成纯白 */
  color: #000000;
  /* 用户输入的文字变成纯黑 */
  border: 2px solid #d4af37;
  /* 添加一层金色边框做区分 */
  outline: none;
  /* 依然保持没有默认高亮蓝边 */
}

/* 修改亮色模式下 placeholder (占位符) 的颜色 */
html[data-theme="light"] .search-box input::placeholder {
  color: #666666;
  /* 把原本暗色模式的白灰色改成深灰色，防止看不清 */
}

/* 顺便给搜索按钮也适配一下边框，让它们看起来是一个整体 */
html[data-theme="light"] .search-box button {
  border: 2px solid #d4af37;
  /* 按钮也加上金色边框 */
  border-left: none;
  /* 去掉按钮左边的边框，防止和输入框的右边框重叠变粗 */
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  /* 为了让颜色切换时更柔和，给原本的 body 加上背景色过渡动画 */
  transition: background-color 0.3s, color 0.3s;
  color: var(--text-main);
  display: flex;
  flex-direction: column; /* 让内容从上到下垂直排列 */
  min-height: 100vh;      /* 核心：让 body 的最小高度等于浏览器窗口的高度 (100% Viewport Height) */
}

.card,
header {
  transition: all 0.3s ease;
}

/* 头部导航 */
header {
  display: flex;
  align-items: center;
  padding: 15px 40px;
  background-color: var(--nav-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: #00d2d3;
  margin-right: 40px;
}

nav a {
  color: var(--text-main);
  text-decoration: none;
  margin-right: 25px;
  font-size: 15px;
  padding-bottom: 5px;
}

nav a.active {
  color: var(--accent-color);
  border-bottom: 2px solid var(--accent-color);
}

.theme-switch {
  margin-left: auto;
  /* 利用 auto 把按钮挤到最右边 */
  cursor: pointer;
  font-size: 20px;
  user-select: none;
  /* 防止双击时选中图标文字，防止图标蓝色高亮显示，影响观感，不加这条也不影响 */
  transition: transform 0.3s;
}

.theme-switch:hover {
  transform: scale(1.2);
  /* 悬停时稍微放大 */
}

/* 搜索区域 */
.search-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 60px 0 40px 0;
}

.search-tabs {
  margin-bottom: 10px;
}

.search-tabs span {
  cursor: pointer;
  margin: 0 15px;
  color: var(--text-sub);
  font-size: 14px;
  transition: color 0.3s;
}

.search-tabs span.active {
  color: var(--text-main);
  font-weight: bold;
}

.search-box {
  display: flex;
  width: 90%;
  max-width: 600px;
  height: 45px;
}

.search-box input {
  flex: 1;
  padding: 0 20px;
  border: none;
  border-radius: 8px 0 0 8px;
  /* 圆角属性，使得方框有弧度更好看 */
  background-color: #333333;
  color: white;
  font-size: 16px;
  outline: none;
  /* outline是浏览器自带的打字时出现蓝色或者黑色边框，设置none去除蓝色边框 */
}

.search-box button {
  padding: 0 25px;
  border: none;
  border-radius: 0 8px 8px 0;
  background-color: var(--accent-color);
  color: white;
  font-size: 16px;
  cursor: pointer;
  /* 改变鼠标悬停该格子上的点击样式，小手图标 */
  transition: opacity 0.2s;
  /* 过度动画0.2秒切换 */
}

.search-box button:hover {
  opacity: 0.8;
}

/* 网址分类与卡片网格 */
main {
  padding: 0 5%;
  max-width: 1400px;
  margin: 0 auto;
  width: 90%; /* 保证 main 自身宽度正常 */
  flex: 1; /* 核心修改：让 main 撑开剩余的全部空间 */
}

.category h2 {
  font-size: 16px;
  color: var(--text-sub);
  margin-bottom: 20px;
}

.card-grid {
  display: grid;
  /* CSS Grid 魔法：自动换行，每列最小220px，最大平分空间 */
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 15px;
  /* 如果我写 repeat(3, 100px)，意思就是创建 3 列，每列宽 100px。 */
  /* auto-fill 关键字：
  结合 repeat 使用时，它的意思是**“自动填充”**。浏览器会根据屏幕的宽度自动计算能塞下多少列。屏幕宽了，它就多放几张卡片；屏幕窄了（比如手机），它就少放几张，放不下的自动挤到下一行去 */
  /* minmax(220px, 1fr) 函数：
  它规定了每一列（每一张卡片）尺寸的底线和上限。

  220px 是最小宽度（底线）：当屏幕不断缩小，卡片被挤压到 220px 时，它就死活不缩了，而是强制换行。

  1fr 是最大宽度（上限）：fr (fraction) 是 Grid 独有的单位，代表“一份剩余空间”。在这里它的意思是，如果本行还有多余的空间，卡片们会平分拉伸，把剩下的屏幕缝隙填满，不留大黑边。 */
  /* gap: 15px;
  gap: 15px;
  这个最好理解，它用来设置网格与网格之间的间隙（沟壑） 。它同时设定了卡片上下的行距和左右的列距为 15 像素，比你以前用 margin 去算间距要省事得多。 */
}

/* 卡片样式 */
.card {
  display: flex;
  align-items: center;
  background-color: var(--card-bg);
  padding: 15px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);

  /* transform（变形/变换） */
  /* 这是 CSS3 中一个非常强大的属性，专门用来改变元素的长相和位置。它可以让元素进行平移（translate）、缩放（scale）、旋转（rotate）、倾斜（skew）等操作 。

translate（平移）
它是 transform 里的一个功能，意思是把元素从它原本的位置推走 。

translateX()：在 X 轴（左右）移动 。

translateY()：在 Y 轴（上下）移动 。

-3px（移动距离）
在网页的坐标系中，向下是正数，向上是负数 。

所以 translateY(-3px) 就是让卡片沿着 Y 轴向上移动 3 像素 。 */
  background-color: var(--card-hover);
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: 12px;
  object-fit: cover;
}

.placeholder-icon {
  background-color: #74b9ff;
  display: flex;
  align-items: center;
  /* 垂直居中 */
  justify-content: center;
  /* 水平居中 */
  font-weight: bold;
  /* 字体加粗 */
  font-size: 20px;
  /* 字体放大 */
}

.card-info {
  overflow: hidden;
  /* 防止文字溢出撑破卡片 */
  text-overflow: ellipsis;
}

.card-info h3 {
  margin: 0 0 4px 0;
  font-size: 15px;
  white-space: nowrap;
  /*不许换行 */
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-info p {
  margin: 0;
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

footer {
  background-color: var(--nav-bg);
  padding: 8px 0;
  margin-top: 30px;
  text-align: center;
  border-top: 1px solid #3a3a3c;
}

.footer-content p {
  color: var(--text-sub);
  /* 灰色次要文字 */
  font-size: 14px;
  margin-top: 10px;
  /* 往下留一点距离，隔开下方的链接 */
}

/* 不备案不需要，提前备注好 */
.footer-links a {
  color: var(--text-main);
  text-decoration: none;
  margin: 0 15px;
  /* 链接之间保持距离 */
  font-size: 14px;
  transition: color 0.3s;
  /* 鼠标悬停变色的过渡动画 */
}

/* 历史记录下拉框 */
.history-list {
  position: absolute;
  top: 55px;          /* 挂在输入框正下方 */
  left: 0;
  width: calc(100% - 80px); /* 宽度等于输入框减去按钮的宽度，视你的按钮宽度微调 */
  background-color: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  list-style: none;   /* 去掉列表默认的小圆点 */
  padding: 5px 0;
  margin: 0;
  z-index: 100;       /* 保证它浮在最上面 */
  max-height: 250px;  /* 限制最大高度 */
  overflow-y: auto;   /* 超出高度时可滚动 */
}

/* 隐藏状态 */
.history-list.hidden {
  display: none;
}

/* 每一条历史记录的样式 */
.history-list li {
  padding: 10px 20px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 14px;
  display: flex;
  align-items: center;
}

.history-list li:hover {
  background-color: var(--card-hover); /* 鼠标放上去有背景色提示 */
}

/* 历史记录前面的小图标（这里用一个简单的符号代替截图里的时钟图标） */
.history-list li::before {
  content: "🫪";
  margin-right: 10px;
  color: var(--text-sub);
}
/* .history-list li::after {
  content: "♂️";
  margin-left: 10px;
  color: var(--text-sub);
} */