/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== Theme Definitions ===== */

/* Light (default) */
[data-theme="light"], :root {
  --bg: #fafaf9;
  --text: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --border: #e7e5e4;
  --code-bg: #f5f5f4;
  --code-text: #1c1917;
  --link: #2563eb;
  --accent: #2563eb;
}

/* Dark */
[data-theme="dark"] {
  --bg: #0f172a;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --link: #60a5fa;
  --accent: #60a5fa;
}

/* Warm */
[data-theme="warm"] {
  --bg: #fdf6e3;
  --text: #3d2b1f;
  --text-secondary: #6b5344;
  --text-muted: #a08b7a;
  --border: #e8dcc8;
  --code-bg: #f5ead6;
  --code-text: #3d2b1f;
  --link: #b45309;
  --accent: #b45309;
}

/* Lavender */
[data-theme="lavender"] {
  --bg: #f5f3ff;
  --text: #1e1b4b;
  --text-secondary: #6b6394;
  --text-muted: #a5a0c8;
  --border: #e4e0f5;
  --code-bg: #ede9fe;
  --code-text: #1e1b4b;
  --link: #7c3aed;
  --accent: #7c3aed;
}

/* Blueprint */
[data-theme="blueprint"] {
  --bg: #0f172a;
  --text: #e0f2fe;
  --text-secondary: #7dd3fc;
  --text-muted: #38bdf8;
  --border: rgba(56, 189, 248, 0.15);
  --code-bg: rgba(56, 189, 248, 0.08);
  --code-text: #bae6fd;
  --link: #38bdf8;
  --accent: #38bdf8;
}

[data-theme="blueprint"] html,
[data-theme="blueprint"] {
  background-color: #0f172a;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Starry */
[data-theme="starry"] {
  --bg: #1e3a5f;
  --text: #fef3c7;
  --text-secondary: #bfdbfe;
  --text-muted: #93c5fd;
  --border: rgba(251, 191, 36, 0.2);
  --code-bg: rgba(251, 191, 36, 0.08);
  --code-text: #fde68a;
  --link: #fbbf24;
  --accent: #fbbf24;
}

[data-theme="starry"] {
  background-color: #1e3a5f;
  background-image:
    radial-gradient(2px 2px at 10% 15%, #fbbf24 50%, transparent 50%),
    radial-gradient(2px 2px at 25% 60%, #fbbf24 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 40% 8%, #fde68a 50%, transparent 50%),
    radial-gradient(2px 2px at 55% 45%, #fbbf24 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 70% 25%, #fde68a 50%, transparent 50%),
    radial-gradient(2px 2px at 85% 70%, #fbbf24 50%, transparent 50%),
    radial-gradient(1px 1px at 15% 80%, #fde68a 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 48% 90%, #fbbf24 50%, transparent 50%),
    radial-gradient(2px 2px at 90% 10%, #fde68a 50%, transparent 50%),
    radial-gradient(1px 1px at 60% 75%, #fbbf24 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 5% 45%, #fde68a 50%, transparent 50%),
    radial-gradient(2px 2px at 35% 35%, #fbbf24 50%, transparent 50%),
    radial-gradient(1px 1px at 75% 55%, #fde68a 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 95% 40%, #fbbf24 50%, transparent 50%);
}

/* ===== Base Styles ===== */
html {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

body {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== Theme Switcher Dots ===== */
.theme-dots {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 6px;
  z-index: 100;
}

.theme-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.theme-dot:hover {
  transform: scale(1.3);
}

.theme-dot.active {
  border-color: var(--text);
}

.theme-dot[data-theme="light"] { background: #fafaf9; border-color: #d6d3d1; }
.theme-dot[data-theme="dark"] { background: #1e293b; border-color: #475569; }
.theme-dot[data-theme="warm"] { background: #d4a574; border-color: #92400e; }
.theme-dot[data-theme="lavender"] { background: #c4b5fd; border-color: #7c3aed; }
.theme-dot[data-theme="blueprint"] { background: #38bdf8; border-color: #0284c7; }
.theme-dot[data-theme="starry"] { background: #fbbf24; border-color: #d97706; }

.theme-dot.active[data-theme="light"] { border-color: #1c1917; }
.theme-dot.active[data-theme="dark"] { border-color: #e2e8f0; }
.theme-dot.active[data-theme="warm"] { border-color: #3d2b1f; }
.theme-dot.active[data-theme="lavender"] { border-color: #1e1b4b; }
.theme-dot.active[data-theme="blueprint"] { border-color: #e0f2fe; }
.theme-dot.active[data-theme="starry"] { border-color: #fef3c7; }

/* ===== Header ===== */
.site-header {
  text-align: center;
  padding: 3rem 0 2rem;
}

.site-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.5px;
}

.site-bio {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Post List (Homepage) ===== */
.post-list {
  list-style: none;
  flex: 1;
}

.post-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

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

.post-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-link {
  display: block;
  color: var(--text);
  font-size: 1rem;
  margin-top: 0.15rem;
}

.post-link:hover {
  color: var(--link);
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
}

.site-footer a:hover {
  color: var(--text);
}

.footer-sep {
  margin: 0 0.4rem;
}

/* ===== Post Page ===== */
.back-link {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.back-link:hover {
  color: var(--text);
}

.post-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}

.post-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.post-body {
  flex: 1;
  line-height: 1.8;
  color: var(--text);
}

.post-body p {
  margin-bottom: 1.2rem;
}

.post-body h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

.post-body code {
  font-family: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.88em;
  color: var(--code-text);
}

.post-body pre {
  background: var(--code-bg);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.2rem;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.post-body blockquote {
  border-left: 3px solid var(--border);
  margin: 1.2rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  color: var(--text-secondary);
  font-style: italic;
}

.post-body blockquote a {
  color: var(--link);
}

.post-body hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-body a {
  color: var(--link);
}

.post-body ul,
.post-body ol {
  margin: 0 0 1.2rem 0;
  padding-left: 1.5rem;
}

.post-body li {
  margin-bottom: 0.5rem;
}

.post-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  border-radius: 4px;
}
