/* ============================================
   小爱同学 Blog - Modern Minimalist Design
   ============================================ */

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --accent: #e879f9;
  --accent2: #818cf8;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-hover: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 16px;
  --radius-sm: 8px;
  --max-width: 720px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --text: #e4e4e7;
  --text-secondary: #9ca3af;
  --border: #2d2d44;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-hover: 0 10px 25px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

/* ===== Navigation ===== */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250,250,250,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s;
}

[data-theme="dark"] nav {
  background: rgba(15,15,26,0.85);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 24px;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Main Content ===== */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 100px 24px 60px;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 40px 0 48px;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 500px;
  margin: 0 auto;
}

/* ===== Posts Grid ===== */
.posts-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all 0.25s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
  position: relative;
  overflow: hidden;
}

.post-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: opacity 0.25s;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: transparent;
}

.post-card:hover::before { opacity: 1; }

.post-card .date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.post-card h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 8px 0 10px;
  line-height: 1.4;
}

.post-card .summary {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.post-tags {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(232,121,249,0.12), rgba(129,140,248,0.12));
  color: var(--accent);
  font-weight: 500;
}

/* ===== Post Detail ===== */
.post-detail { display: none; }

.post-detail.active { display: block; }

.post-detail .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 24px;
  transition: color 0.2s;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
}

.post-detail .back-btn:hover { color: var(--accent); }

.post-detail .post-header {
  margin-bottom: 32px;
}

.post-detail .post-header h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.post-detail .post-header .meta {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Markdown Content ===== */
.post-content {
  font-size: 1.05rem;
  line-height: 1.8;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 36px 0 14px;
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 28px 0 10px;
}

.post-content p {
  margin-bottom: 18px;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover { opacity: 0.8; }

.post-content ul, .post-content ol {
  margin: 0 0 18px 24px;
}

.post-content li { margin-bottom: 6px; }

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 20px 0;
  background: rgba(232,121,249,0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-content code {
  font-family: var(--font-mono);
  background: rgba(129,140,248,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.post-content pre {
  background: #1a1a2e;
  color: #e4e4e7;
  padding: 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 20px 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.post-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 20px 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* ===== Loading & Empty ===== */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-secondary);
}

.loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-secondary);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ===== Comments Section ===== */
.comments-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.comments-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.comment-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.comment-location-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: rgba(129,140,248,0.08);
  border-radius: var(--radius-sm);
}

.comment-location-hint .locating {
  opacity: 0.6;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.comment-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  min-height: 80px;
}

.comment-form textarea:focus {
  border-color: var(--accent);
}

.comment-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.comment-char-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.comment-submit {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  font-family: var(--font);
}

.comment-submit:hover { opacity: 0.85; }
.comment-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.comment-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}

.comments-empty {
  text-align: center;
  padding: 32px 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.comment-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.comment-item:last-child { border-bottom: none; }

.comment-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.comment-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.comment-location {
  font-size: 0.8rem;
  color: var(--accent2);
  background: rgba(129,140,248,0.1);
  padding: 2px 8px;
  border-radius: 12px;
}

.comment-time {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.comment-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* ===== Guestbook ===== */
#guestbook-view .hero {
  padding-bottom: 24px;
}

#guestbook-view .hero h1 {
  font-size: 2.4rem;
}

.gb-section {
  margin-bottom: 36px;
}

.gb-subtitle {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.gb-location-group {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.gb-location-pin {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.gb-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 6px;
}

.gb-comment-card {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.gb-comment-card:last-child { border-bottom: none; }

.gb-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.gb-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.gb-time {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.gb-comment-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-bottom: 4px;
}

.gb-comment-post {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.gb-comment-post a {
  color: var(--accent);
  text-decoration: none;
}

.gb-comment-post a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  .comment-form-row {
    flex-direction: column;
  }
}

/* ===== About Page ===== */
.about-section {
  padding: 20px 0;
}

.about-section .avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 20px;
}

.about-section h1 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.about-section .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.about-section .bio {
  font-size: 1.05rem;
  line-height: 1.8;
}

.about-section .bio p { margin-bottom: 16px; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero h1 { font-size: 2rem; }
  .post-card { padding: 20px; }
  .post-card h2 { font-size: 1.15rem; }
  .post-detail .post-header h1 { font-size: 1.5rem; }
  .nav-inner { padding: 0 16px; }
  main { padding: 80px 16px 40px; }
}