/* ========================================
   Luna Theme — Swiss Modernism 2.0
   nekocoder.me
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;500;600;700&family=Quicksand:wght@300;400;500;600;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
  --bg: #FAFAFA;
  --bg-secondary: #F4F4F5;
  --text: #09090B;
  --text-secondary: #3F3F46;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --border: #E4E4E7;
  --border-hover: #D4D4D8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --font-heading: 'Caveat', cursive;
  --font-body: 'Quicksand', 'Noto Sans SC', sans-serif;
  --grid-gap: 24px;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1200px;
  --content-width: 720px;
}

[data-theme="dark"] {
  --bg: #09090B;
  --bg-secondary: #18181B;
  --text: #FAFAFA;
  --text-secondary: #A1A1AA;
  --accent: #60A5FA;
  --accent-hover: #93BBF8;
  --border: #27272A;
  --border-hover: #3F3F46;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; display: block; }

/* --- 12-Column Grid System --- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--grid-gap);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--grid-gap);
}

.col-1  { grid-column: span 1; }
.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; }
.col-12 { grid-column: span 12; }

/* --- Layout --- */
.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main { flex: 1; padding: 48px 0; }

/* --- Header / Nav --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(250,250,250,0.85);
  transition: background var(--transition), border-color var(--transition);
}

[data-theme="dark"] .site-header {
  background: rgba(9,9,11,0.85);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--grid-gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.site-logo {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  transition: color var(--transition);
}
.site-logo:hover { color: var(--accent); }
.site-logo span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.nav-links a:hover {
  color: var(--accent);
  background: var(--bg-secondary);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
  margin-left: 8px;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.nav-mobile-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

/* --- Hero Section --- */
.hero {
  padding: 80px 0 64px;
  text-align: center;
}

.hero-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin: 0 auto 24px;
  border: 3px solid var(--border);
  overflow: hidden;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  transition: border-color var(--transition), transform var(--transition);
}
.hero-avatar:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.hero .tagline {
  font-size: 1.15rem;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 520px;
  margin: 0 auto 32px;
}

.hero-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--bg);
  transition: all var(--transition);
}
.hero-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* --- Section Titles --- */
.section-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 32px;
  color: var(--text);
}

.section-title-line {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
}
.section-title-line h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  white-space: nowrap;
}
.section-title-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* --- Post Cards --- */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--grid-gap);
}

.post-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}
.post-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card .post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.post-card .post-category {
  background: var(--bg-secondary);
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.75rem;
}

.post-card h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.3;
}
.post-card h3 a {
  color: inherit;
}
.post-card h3 a:hover {
  color: var(--accent);
}

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

.post-card .post-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 999px;
  transition: all var(--transition);
}
.tag:hover {
  background: var(--accent);
  color: #fff;
}

/* --- Single Post --- */
.post-header {
  text-align: center;
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-family: var(--font-heading);
  font-size: 2.75rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.2;
}

.post-header .post-meta {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.post-content {
  max-width: var(--content-width);
  margin: 0 auto;
  font-size: 1.05rem;
  line-height: 1.8;
}

.post-content h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin: 48px 0 16px;
  color: var(--text);
}

.post-content h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin: 36px 0 12px;
  color: var(--text);
}

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

.post-content ul, .post-content ol {
  margin-bottom: 20px;
  padding-left: 24px;
}

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

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 16px 24px;
  margin: 24px 0;
  background: var(--bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.88em;
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
}

.post-content pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  overflow-x: auto;
  margin-bottom: 24px;
}

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

.post-content img {
  border-radius: var(--radius-sm);
  margin: 24px auto;
}

/* --- List Page (Section) --- */
.section-header {
  text-align: center;
  padding: 48px 0 32px;
}

.section-header h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* --- Page (About, etc) --- */
.page-content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 48px var(--grid-gap);
}

.page-content h1 {
  font-family: var(--font-heading);
  font-size: 2.75rem;
  font-weight: 700;
  margin-bottom: 32px;
  text-align: center;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  max-width: var(--content-width);
  margin: 32px auto;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 32px;
  padding-left: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -37px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-item .timeline-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.timeline-item h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.timeline-item p {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

/* --- Archives --- */
.archive-year {
  margin-bottom: 40px;
}

.archive-year h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--accent);
}

.archive-list {
  list-style: none;
}

.archive-list li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.archive-list li:hover {
  background: var(--bg-secondary);
}

.archive-list .archive-date {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  min-width: 80px;
  font-variant-numeric: tabular-nums;
}

.archive-list a {
  font-weight: 500;
  color: var(--text);
}
.archive-list a:hover {
  color: var(--accent);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

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

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--grid-gap);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .posts-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  :root {
    --grid-gap: 16px;
  }

  .nav-links { display: none; }
  .nav-mobile-toggle { display: flex; align-items: center; justify-content: center; }
  
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px;
    box-shadow: var(--shadow-md);
  }

  .hero { padding: 48px 0 32px; }
  .hero h1 { font-size: 2.25rem; }
  .hero-avatar { width: 96px; height: 96px; font-size: 2.5rem; }

  .post-header h1 { font-size: 2rem; }
  .post-content { font-size: 1rem; }

  .posts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 375px) {
  html { font-size: 14px; }
  .header-inner { padding: 0 12px; }
  .hero h1 { font-size: 1.75rem; }
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 48px;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  transition: all var(--transition);
}

.pagination a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pagination .active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- Back to top --- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  transition: all var(--transition);
  z-index: 50;
}
.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}
