/* cuishark 极简主站 · 按 DESIGN-SPEC.md 第 2、3 节实现（响应式第 9 节本单不做） */

/* ---------- 2. 设计令牌 ---------- */
:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #888888;
  --border: #e8e8e8;
  --border-hover: #c8c8c8;
  --hover-bg: #f7f7f7;
  --solid-bg: #111111;
  --solid-text: #ffffff;
  --radius-cell: 10px;   /* 格子/输入框 */
  --radius-pill: 999px;  /* 搜索框胶囊 */
  --radius-badge: 6px;   /* 字标方块 */
  --radius-btn: 8px;     /* 齿轮/关闭按钮 hover 圆角 */
  --focus-outline: 2px solid var(--text);
  --focus-offset: 2px;
  --error: #c0392b;      /* 管理密码错误态专用 */
}

/* ---------- 基础 ---------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-offset);
}

/* ---------- 3.1 顶栏（56px 高） ---------- */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

/* ---------- 3.2 大字网址 ---------- */
main {
  padding: 26vh 16px 48px; /* 容器顶部距顶栏约 26vh */
}

.url {
  margin: 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: clamp(44px, 8vw, 84px);
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
  white-space: nowrap;
}

/* ---------- 3.3 搜索框 ---------- */
.search {
  display: block;
  width: min(560px, 92vw);
  height: 48px;
  margin: 32px auto 0;
  padding: 0 20px 0 44px; /* 左内 20px 处 16px 放大镜，文字从 44px 起 */
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E")
    no-repeat left 20px center;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

.search::placeholder {
  color: var(--muted);
}

/* ---------- 3.4 格子网格 ---------- */
#grid {
  width: min(880px, 100%);
  margin: 36px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.cell {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-cell);
  text-decoration: none;
  cursor: pointer;
}

.cell:hover {
  background: var(--hover-bg);
  border-color: var(--border-hover);
}

.cell:active {
  opacity: 0.85;
}

.cell-badge {
  width: 28px;
  height: 28px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-badge);
  background: var(--solid-bg);
  color: var(--solid-text);
  font-size: 14px;
}

.cell-name {
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 空状态 ---------- */
#empty {
  margin: 24px 0 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 3.5 管理覆盖层（基础布局） ---------- */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  overflow-y: auto;
}

#overlay-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 96px 16px 48px; /* 内容列居中，顶部留白 96px */
}

/* 右上角关闭位（按钮本体由 admin.js 注入） */
.overlay-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.overlay-close:hover {
  background: var(--hover-bg);
}

/* 管理面板标题字号（供 admin.js 渲染时使用） */
.overlay-title {
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
}

/* ---------- 3.5.1 密码门（admin.js 注入） ---------- */
/* display:flex 会覆盖 UA 对 [hidden] 的 display:none，这里补回 */
.gate[hidden],
.editor[hidden] {
  display: none;
}

.gate {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  max-width: 360px;
  margin: 0 auto;
}

.gate-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-cell);
  background: var(--bg);
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  /* 聚焦态走全局 :focus-visible（2px solid #111, offset 2px），此处不重复定义 */
}

.gate-input::placeholder {
  color: var(--muted);
}

.btn-solid {
  height: 44px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius-cell);
  background: var(--solid-bg);
  color: var(--solid-text);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}

.btn-solid:hover {
  background: #333333;
}

.gate-error {
  margin: 0;
  font-size: 14px;
  color: var(--error);
}

/* 密码错误抖动：translateX 往返 4 次共 300ms，只动 transform */
.shake {
  animation: gate-shake 300ms ease-in-out;
}

@keyframes gate-shake {
  0% { transform: translateX(0); }
  12.5% { transform: translateX(-6px); }
  25% { transform: translateX(6px); }
  37.5% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  62.5% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
  87.5% { transform: translateX(-6px); }
  100% { transform: translateX(0); }
}

/* ---------- 3.5.2 编辑区（空容器，内容后续任务填） ---------- */
.editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 3.5.3 编辑区字段（站点名字 / 站点列表 / 添加站点） ---------- */

/* 单个字段：标签在上、输入框在下 */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
}

/* 输入框：高 40px、圆角 10px、1px #e8e8e8 边框 */
.field-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-cell);
  background: var(--bg);
  font: inherit;
  color: var(--text);
}

/* 站点列表：每行一个站点 */
.site-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-row .site-name {
  flex: 1;
}

.site-row .site-url {
  flex: 1.4;
}

/* 行内小按钮：↑ ↓ ×，32×32、无边框、透明底 */
.row-btn {
  flex: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: var(--radius-badge);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.row-btn:not(:disabled):hover {
  background: var(--hover-bg);
}

/* 首行 ↑ 与末行 ↓ 禁用 */
.row-btn:disabled {
  cursor: default;
  opacity: 0.4;
}

/* + 添加站点：全宽、虚线边框 */
.add-site {
  width: 100%;
  height: 44px;
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-cell);
  background: var(--bg);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.add-site:hover {
  background: var(--hover-bg);
}

/* 编辑区加载失败 */
.editor-error {
  margin: 0;
  font-size: 14px;
  color: var(--error);
}

/* ---------- 3.5.4 自动保存提示条（admin.js 注入 .toast） ---------- */
/* 底/字取第 2 节「实心元素」令牌：底 #111111，字 #ffffff */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  padding: 8px 14px;
  border-radius: var(--radius-cell);
  background: var(--solid-bg);
  color: var(--solid-text);
  font-size: 14px;
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* ---------- 6. 响应式（收尾单补：规格第 1 节「一屏为主」的窄屏适配） ---------- */
/* 手机（≤480px）：格子两列一排，保持「网格」而不是长列表 */
@media (max-width: 480px) {
  #grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

/* 手机（≤480px）：管理行改为两行堆叠——名称、网址各占整行，按钮组换行排在其下 */
@media (max-width: 480px) {
  .site-row {
    flex-wrap: wrap;
  }
  .site-row .site-name,
  .site-row .site-url {
    flex: 1 1 100%;
  }
  .row-btn {
    flex: none;
  }
}
