/* ═══════════════════════════════════════════════════
   历史上的今天 · Design System
   ═══════════════════════════════════════════════════ */

:root {
  --bg: #f8f6f4;
  --card-bg: #ffffff;
  --card-border: #e8e3dc;
  --text: #2c2416;
  --text-secondary: #8c7f6d;
  --text-muted: #bfb5a5;
  --accent: #c84b31;
  --accent-light: #fdf0ec;
  --accent-glow: rgba(200, 75, 49, 0.1);
  --blue: #4a6fa5;
  --blue-bg: #edf2f8;
  --green: #4a7c59;
  --green-bg: #edf5ef;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow: 0 2px 12px rgba(0,0,0,0.05);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

[data-theme="dark"] {
  --bg: #1a1815;
  --card-bg: #282520;
  --card-border: #38332b;
  --text: #e8e0d5;
  --text-secondary: #9c9280;
  --text-muted: #5c554a;
  --accent: #e0734d;
  --accent-light: #3c2218;
  --accent-glow: rgba(224, 115, 77, 0.15);
  --blue: #7aadf0;
  --blue-bg: #1c2838;
  --green: #6a9f76;
  --green-bg: #1c2f20;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow: 0 2px 12px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.bg-pattern {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5v50M5 30h50' stroke='%23000' stroke-width='0.3'/%3E%3C/svg%3E");
}

.container { width: 100%; max-width: 600px; padding: 28px 16px 48px; position: relative; z-index: 1; }

/* Header */
header { text-align: center; margin-bottom: 20px; }
.header-top {
  display: flex; align-items: center; justify-content: center; gap: 12px; position: relative;
}
header h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: 0.04em; }
.subtitle { color: var(--text-secondary); font-size: 0.82rem; margin-top: 2px; }

.theme-btn {
  position: absolute; right: 0;
  width: 38px; height: 38px;
  border: 1px solid var(--card-border); background: var(--card-bg);
  border-radius: 50%; font-size: 1.1rem; cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.theme-btn:hover { transform: scale(1.08); box-shadow: var(--shadow); }

/* Main */
main { display: flex; flex-direction: column; gap: 14px; }

/* Card */
.card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

/* Date Card */
.date-card {
  display: flex; align-items: center; justify-content: center; gap: 0;
  padding: 20px 16px; position: relative;
}

.date-display { text-align: center; }
.date-month { font-size: 1rem; color: var(--text-secondary); font-weight: 500; display: block; }
.date-day {
  font-size: 3.2rem; font-weight: 800; color: var(--accent);
  line-height: 1.1; letter-spacing: -0.02em;
}
.date-wday { font-size: 0.82rem; color: var(--text-muted); display: block; margin-top: 2px; }

.date-arrow {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--card-border); background: var(--card-bg);
  color: var(--text-secondary); font-size: 0.9rem; cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.date-arrow:hover { border-color: var(--accent); color: var(--accent); box-shadow: var(--shadow); }
.date-arrow:active { transform: scale(0.94); }

#prevDay { margin-right: 20px; }
#nextDay { margin-left: 20px; }

.today-btn {
  position: absolute; bottom: 10px; right: 16px;
  padding: 3px 12px; border: 1px solid var(--card-border);
  background: var(--card-bg); color: var(--text-secondary);
  border-radius: 12px; font-size: 0.7rem; cursor: pointer;
  font-family: var(--font); transition: all var(--transition);
}
.today-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Tabs */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.tab {
  flex: 1; padding: 9px 8px; border: none; background: transparent;
  color: var(--text-secondary); font-size: 0.82rem; cursor: pointer;
  border-radius: 10px; font-family: var(--font); font-weight: 500;
  transition: all var(--transition); white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Content */
.content { min-height: 300px; }

.state-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 56px 20px; text-align: center;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
}
.state-box p { color: var(--text-muted); font-size: 0.9rem; margin-top: 12px; }
.state-icon { font-size: 2.4rem; opacity: 0.35; }

/* Spinner */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.retry-btn {
  margin-top: 14px; padding: 8px 20px;
  border: 1px solid var(--accent); background: var(--accent-light);
  color: var(--accent); border-radius: 18px; font-size: 0.84rem;
  cursor: pointer; font-family: var(--font); transition: all var(--transition);
}
.retry-btn:hover { background: var(--accent); color: #fff; }

/* Timeline */
.timeline {
  display: flex; flex-direction: column; gap: 10px;
}

.timeline-item {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm); transition: all var(--transition);
  animation: itemIn 0.3s ease backwards;
}
.timeline-item:nth-child(1) { animation-delay: 0.02s; }
.timeline-item:nth-child(2) { animation-delay: 0.05s; }
.timeline-item:nth-child(3) { animation-delay: 0.08s; }
.timeline-item:nth-child(4) { animation-delay: 0.11s; }
.timeline-item:nth-child(5) { animation-delay: 0.14s; }
.timeline-item:nth-child(n+6) { animation-delay: 0.17s; }

@keyframes itemIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.timeline-item:hover {
  border-color: var(--accent); box-shadow: var(--shadow);
  transform: translateX(2px);
}

.year-badge {
  flex-shrink: 0;
  min-width: 52px; padding: 3px 10px;
  background: var(--accent); color: #fff;
  border-radius: 12px; font-size: 0.78rem; font-weight: 700;
  text-align: center; white-space: nowrap;
  letter-spacing: 0.02em;
}

.year-badge.bc {
  background: var(--text-muted);
  font-size: 0.7rem;
}

.timeline-text {
  font-size: 0.9rem; line-height: 1.65; color: var(--text);
  flex: 1; padding-top: 1px;
}

.timeline-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px;
}

.wiki-link {
  font-size: 0.72rem; color: var(--blue);
  text-decoration: none; font-weight: 500;
  transition: color var(--transition);
  display: inline-flex; align-items: center; gap: 3px;
}
.wiki-link:hover { text-decoration: underline; }
.wiki-link::after { content: '↗'; font-size: 0.65rem; }

/* Holiday card */
.holiday-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--green-bg);
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 14px 18px;
  animation: itemIn 0.3s ease backwards;
}
.holiday-item:hover { border-color: var(--green); }
.holiday-icon { font-size: 1.6rem; flex-shrink: 0; }
.holiday-text { font-size: 0.9rem; line-height: 1.6; color: var(--green); font-weight: 600; }

/* Footer */
footer { text-align: center; padding: 28px 0 12px; color: var(--text-muted); font-size: 0.74rem; }

/* Responsive */
@media (max-width: 480px) {
  .container { padding: 16px 10px 36px; }
  header h1 { font-size: 1.3rem; }
  .date-day { font-size: 2.6rem; }
  .date-arrow { width: 34px; height: 34px; }
  #prevDay { margin-right: 12px; }
  #nextDay { margin-left: 12px; }
  .tab { font-size: 0.75rem; padding: 8px 4px; }
  .timeline-item { padding: 12px 14px; gap: 10px; }
  .year-badge { min-width: 44px; font-size: 0.72rem; }
  .timeline-text { font-size: 0.84rem; }
}
