/* ========================================
   MOTAFAN — Dual theme (dark default)
   ======================================== */

/* --- Dark theme (default) --- */
[data-theme="dark"] {
  --bg:        #0e0e10;
  --bg-raised: #18181c;
  --bg-card:   #1e1e24;
  --text:      #d4d4d8;
  --text-dim:  #71717a;
  --text-bright: #fafafa;
  --accent:    #e8a44a;
  --accent-dim:#c4863a;
  --border:    #27272a;
  --hero-overlay: rgba(14,14,16,.72);
  --card-glass: rgba(30,30,36,.55);
  --card-glass-border: rgba(255,255,255,.06);
}

/* --- Light theme --- */
[data-theme="light"] {
  --bg:        #f8f7f4;
  --bg-raised: #efeeeb;
  --bg-card:   #ffffff;
  --text:      #3f3f46;
  --text-dim:  #71717a;
  --text-bright: #18181b;
  --accent:    #c4863a;
  --accent-dim:#a06a28;
  --border:    #e4e4e7;
  --hero-overlay: rgba(248,247,244,.72);
  --card-glass: rgba(255,255,255,.45);
  --card-glass-border: rgba(0,0,0,.08);
}

:root {
  --sans:      'DM Sans', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono:      'JetBrains Mono', ui-monospace, monospace;
  --nav-h:     60px;
  --sidebar-w: 280px;
  --max-w:     1100px;
  --radius:    8px;
}

/* === Reset === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* === Theme toggle === */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  transition: color .2s, border-color .2s;
  font-size: 1rem;
  line-height: 1;
  margin-left: .5rem;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
}
[data-theme="dark"] .theme-icon-sun  { display: inline; }
[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme="light"] .theme-icon-sun  { display: none; }
[data-theme="light"] .theme-icon-moon { display: inline; }

/* === Navigation === */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
}
.hero-nav {
  background: transparent !important;
  border-bottom: none !important;
}
.hero-nav.scrolled {
  background: color-mix(in srgb, var(--bg) 85%, transparent) !important;
  border-bottom: 1px solid var(--border) !important;
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .08em;
  color: var(--text-bright);
}
.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}
.nav-links a {
  font-size: .875rem;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--text-dim);
  transition: color .2s;
}
.nav-links a:hover { color: var(--accent); }

/* === HERO / HOME === */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Background image layer — blurred */
.hero-bg {
  position: absolute; inset: -20px;
  background: var(--bg) center/cover no-repeat;
  filter: blur(10px);
  -webkit-filter: blur(10px);
  z-index: 0;
  transform: scale(1.05);
}

/* Color overlay on top of blurred bg */
.hero-overlay {
  position: absolute; inset: 0;
  background: var(--hero-overlay);
  z-index: 1;
}

.hero > *:not(.hero-bg):not(.hero-overlay) {
  position: relative;
  z-index: 2;
}

.hero-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}
.hero-title {
  font-family: var(--sans);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--text-bright);
  margin-bottom: .5rem;
}
.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  font-style: italic;
}

.hero-recent {
  padding: 0 2rem 4rem;
}
.hero-recent-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}
.hero-recent h2 {
  font-size: .85rem;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

/* Glass-style recent cards */
.recent-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.recent-card {
  position: relative;
  display: block;
  padding: 1.25rem;
  background: var(--card-glass);
  border: 1px solid var(--card-glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color .25s, transform .25s;
}
.recent-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

/* Pin icon — top right of card */
.pin-icon {
  position: absolute;
  top: .75rem;
  right: .75rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.recent-section {
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.recent-card h3 {
  font-size: 1rem;
  color: var(--text-bright);
  margin: .5rem 0 .35rem;
  line-height: 1.4;
}
.recent-card time {
  font-size: .75rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

/* === PAGE LAYOUT (sidebar) === */
.page-layout {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 2rem) 2rem 4rem;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: 3rem;
}

/* === SECTION HEADER === */
.section-header {
  margin-bottom: 2.5rem;
}
.section-header h1 {
  font-family: var(--sans);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: .04em;
}
.section-desc {
  color: var(--text-dim);
  margin-top: .35rem;
}

/* === TIMELINE === */
.timeline-year {
  margin-bottom: 2.5rem;
}
.year-label {
  font-family: var(--mono);
  font-size: .85rem;
  color: var(--accent);
  letter-spacing: .08em;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.timeline-item {
  display: flex;
  gap: 1.25rem;
  padding: .85rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.timeline-item:hover {
  border-bottom-color: var(--border);
}
.timeline-date {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--text-dim);
  min-width: 3.5rem;
  padding-top: .15rem;
}
.timeline-body h3 {
  font-size: 1.05rem;
  color: var(--text-bright);
  line-height: 1.45;
  transition: color .2s;
}
.timeline-item:hover .timeline-body h3 { color: var(--accent); }
.timeline-summary {
  font-size: .85rem;
  color: var(--text-dim);
  margin-top: .3rem;
  line-height: 1.55;
}
.timeline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .4rem;
}
.tag {
  font-size: .7rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  letter-spacing: .03em;
}

/* === SIDEBAR === */
.sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 2rem);
  align-self: start;
}
.sidebar-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.sidebar-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: .75rem;
}
.sidebar-name {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
}
.sidebar-bio {
  font-size: .85rem;
  color: var(--text-dim);
  margin: .35rem 0 1.25rem;
  line-height: 1.5;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: .75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.sidebar-nav a {
  font-size: .85rem;
  color: var(--text);
  transition: color .2s;
}
.sidebar-nav a:hover { color: var(--accent); }
.sidebar-social {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  align-items: center;
}
.sidebar-social a {
  color: var(--text-dim);
  transition: color .2s;
  display: flex;
  align-items: center;
}
.sidebar-social a:hover { color: var(--accent); }

/* === ARTICLE === */
.article-header {
  margin-bottom: 2.5rem;
}
.article-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: .75rem;
}
.article-section {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: .2rem .6rem;
  border-radius: 4px;
}
.article-meta time {
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--text-dim);
}
.article-header h1 {
  font-size: 1.85rem;
  color: var(--text-bright);
  line-height: 1.4;
  font-weight: 700;
}
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .75rem;
}

/* === PROSE (article body) — system font === */
.prose {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text);
}
.prose h2 {
  font-size: 1.4rem;
  color: var(--text-bright);
  margin: 2.5rem 0 1rem;
  font-weight: 700;
}
.prose h3 {
  font-size: 1.15rem;
  color: var(--text-bright);
  margin: 2rem 0 .75rem;
  font-weight: 700;
}
.prose p { margin-bottom: 1.25rem; }
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.prose a:hover { color: var(--accent-dim); }
.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: .5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-dim);
  font-style: italic;
  background: var(--bg-raised);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.prose code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg-raised);
  padding: .15rem .4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.prose pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
}
.prose img {
  border-radius: var(--radius);
  margin: 1.5rem 0;
}
.prose ul, .prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}
.prose li { margin-bottom: .35rem; }
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* === ARTICLE NAV === */
.article-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.article-nav a {
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .25s;
}
.article-nav a:hover { border-color: var(--accent-dim); }
.article-nav span {
  font-size: .75rem;
  color: var(--text-dim);
}
.article-nav strong {
  display: block;
  font-size: .9rem;
  color: var(--text-bright);
  margin-top: .25rem;
}
.article-nav-next { text-align: right; }

/* === COMMENTS === */
.comments {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.comments h2 {
  font-size: 1.15rem;
  color: var(--text-bright);
  margin-bottom: 1.25rem;
}
.comments-placeholder {
  color: var(--text-dim);
  font-size: .9rem;
  padding: 2rem;
  text-align: center;
  background: var(--bg-raised);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* === FOOTER === */
.site-footer {
  text-align: center;
  padding: 2rem;
  font-size: .8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .page-layout {
    grid-template-columns: 1fr;
    padding: calc(var(--nav-h) + 1rem) 1rem 2rem;
  }
  .sidebar {
    position: static;
  }
  .sidebar-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
  }
  .sidebar-avatar { margin-bottom: 0; }
  .sidebar-bio { margin: 0; }
  .sidebar-nav {
    flex-direction: row;
    border: none;
    padding: 0;
    gap: 1rem;
  }
  .sidebar-social { margin-top: 0; }
  .recent-grid {
    grid-template-columns: 1fr;
  }
  .article-nav {
    grid-template-columns: 1fr;
  }
  .hero-title {
    letter-spacing: .06em;
  }
  .nav-inner {
    padding: 0 1rem;
  }
}
