/* ============================================================
   guestbook.css - 留言板样式（自制发布表单 + 卡片式留言墙）
   加载页面：/guestbook/index.html
   ============================================================ */

/* ---------- 发布表单 ---------- */
.gb-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gb-form-row {
  display: flex;
  gap: 12px;
}
.gb-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.gb-input::placeholder { color: var(--text-muted); }
.gb-input:focus {
  border-color: var(--link);
  box-shadow: 0 0 0 3px var(--active-bg);
}
.gb-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
  min-height: 96px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}
.gb-textarea::placeholder { color: var(--text-muted); }
.gb-textarea:focus {
  border-color: var(--link);
  box-shadow: 0 0 0 3px var(--active-bg);
}
.gb-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gb-form-hint {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.gb-form-hint-err { color: #d33; }
.gb-submitting { opacity: 0.75; cursor: wait; }
.gb-form-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ---------- 预览框 ---------- */
.gb-preview-box {
  margin-top: 4px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.gb-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}
.gb-preview-close {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.gb-preview-close:hover {
  color: var(--link);
  background: var(--active-bg);
}

/* ---------- 留言卡片 ---------- */
.guestbook-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.gb-card {
  display: flex;
  flex-direction: column;
}
.gb-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.gb-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
}
.gb-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: var(--link);
}
.gb-meta {
  min-width: 0;
  flex: 1;
}
.gb-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gb-time {
  font-size: 12px;
  color: var(--text-muted);
}
.gb-body {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  flex: 1;
  margin-bottom: 12px;
}
.gb-body a { color: var(--link); }
.gb-body a:hover { color: var(--link-hover); }

/* ---------- 留言正文（支持 Markdown） ---------- */
.gb-body p { margin: 0 0 10px; }
.gb-body p:last-child { margin-bottom: 0; }
.gb-body a { color: var(--link); }
.gb-body a:hover { color: var(--link-hover); }
.gb-body code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-size: 13px;
}
.gb-body pre {
  padding: 12px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.gb-body pre code { padding: 0; border: none; background: none; }
.gb-body ul, .gb-body ol { padding-left: 22px; margin: 0 0 10px; }
.gb-body li + li { margin-top: 4px; }
.gb-body blockquote {
  margin: 0 0 10px;
  padding: 2px 12px;
  border-left: 4px solid var(--border);
  color: var(--text-muted);
}
.gb-body h1, .gb-body h2, .gb-body h3, .gb-body h4 {
  margin: 8px 0;
  font-size: 1.05em;
  line-height: 1.4;
}
.gb-body img { max-width: 100%; border-radius: 6px; margin: 4px 0; }
.gb-body table { border-collapse: collapse; margin: 0 0 10px; font-size: 13px; }
.gb-body th, .gb-body td { border: 1px solid var(--border); padding: 6px 10px; }

/* ---------- 移动端：表单两列堆叠 ---------- */
@media (max-width: 600px) {
  .gb-form-row { flex-direction: column; }
}

/* ---------- 刷新按钮（图标按钮，点击转圈） ---------- */
#guestbook-refresh {
  padding: 6px;
  line-height: 0;
}
#guestbook-refresh .gb-refresh-icon {
  display: block;
}
#guestbook-refresh.gb-refreshing {
  cursor: wait;
  opacity: 0.75;
}
#guestbook-refresh.gb-refreshing .gb-refresh-icon {
  animation: gb-spin 0.8s linear infinite;
}
@keyframes gb-spin {
  to { transform: rotate(360deg); }
}
