/* ============================================
   REIMMERSE Blog
   ============================================ */

/* --- Theme tokens --- */

:root,
[data-theme="light"] {
  --bg: #fafafa;
  --bg-header: rgba(250, 250, 250, 0.88);
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-tertiary: #888;
  --text-faint: #aaa;
  --border: #e5e7eb;
  --border-hover: #1a1a1a;
  --surface: #fff;
  --surface-hover: rgba(0, 0, 0, 0.025);
  --accent: #4f46e5;
  --accent-light: #6366f1;
  --code-bg: #f3f4f6;
  --code-text: #4f46e5;
  --pre-bg: #1a1a1a;
  --pre-text: #e5e7eb;
  --pre-border: transparent;
  --selection-bg: rgba(79, 70, 229, 0.15);
  --selection-text: inherit;
}

[data-theme="dark"] {
  --bg: #111113;
  --bg-header: rgba(17, 17, 19, 0.88);
  --text: #e0e0e0;
  --text-secondary: #999;
  --text-tertiary: #666;
  --text-faint: #444;
  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.2);
  --surface: #18181b;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --accent: #818cf8;
  --accent-light: #a5b4fc;
  --code-bg: rgba(99, 102, 241, 0.1);
  --code-text: #c4b5fd;
  --pre-bg: #0a0a0c;
  --pre-text: #ccc;
  --pre-border: rgba(255, 255, 255, 0.06);
  --selection-bg: rgba(99, 102, 241, 0.3);
  --selection-text: #fff;
}

/* --- Reset --- */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

/* --- Layout --- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Header --- */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s, border-color 0.3s;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-group {
  display: flex;
  align-items: center;
}

.logo {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--text);
  text-decoration: none;
  transition: opacity 0.15s;
}

.logo:hover {
  opacity: 0.7;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

nav {
  display: flex;
  gap: 1.25rem;
}

nav a {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.15s;
}

nav a:hover {
  color: var(--text);
}

/* --- Theme toggle --- */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

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

[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* --- Feed (index) --- */

.feed {
  padding: 4rem 0 6rem;
}

.post-feed {
  display: flex;
  flex-direction: column;
}

.post-item-link {
  display: flex;
  gap: 1.75rem;
  align-items: baseline;
  text-decoration: none;
  padding: 1rem 1rem;
  margin: 0 -1rem;
  border-radius: 8px;
  transition: background 0.2s;
}

.post-item-link:hover {
  background: var(--surface-hover);
}

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

.post-item-date {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-faint);
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  white-space: nowrap;
  min-width: 6rem;
  transition: color 0.2s;
}

.post-item-body {
  flex: 1;
}

.post-item-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.45;
  transition: color 0.2s;
}

.post-item-excerpt {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.9375rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: 0.2rem;
}

/* --- Pagination --- */

.pagination {
  margin-top: 2.5rem;
  padding-left: 1rem;
}

.pagination-link {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.15s;
}

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

/* --- Post --- */

.post {
  padding: 4rem 0 5rem;
}

.post-header {
  margin-bottom: 3rem;
}

.post-date {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--accent);
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  letter-spacing: 0.03em;
  margin-bottom: 0.75rem;
  display: block;
}

.post-title {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: -0.015em;
}

.post-subtitle {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.125rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: 0.75rem;
}

/* --- Post content --- */

.post-content {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.0625rem;
  font-weight: 300;
  line-height: 1.9;
  color: var(--text-secondary);
}

.post-content h2 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 3rem;
  margin-bottom: 0.75rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.0625rem;
  font-weight: 500;
  margin-top: 2.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.post-content p {
  margin-bottom: 1.375rem;
}

.post-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
}

.post-content a:hover {
  border-bottom-color: var(--accent);
}

.post-content strong {
  font-weight: 500;
  color: var(--text);
}

.post-content em {
  font-style: italic;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.375rem;
  padding-left: 1.5rem;
}

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

.post-content li::marker {
  color: var(--text-faint);
}

.post-content blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.25rem;
  margin: 2rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 2rem 0;
}

.post-content figure {
  margin: 2rem 0;
}

.post-content figcaption {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
  text-align: center;
}

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

/* --- Code --- */

.post-content code {
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  color: var(--code-text);
}

.post-content pre {
  background: var(--pre-bg);
  color: var(--pre-text);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--pre-border);
  overflow-x: auto;
  margin: 2rem 0;
  line-height: 1.55;
  font-size: 0.8125rem;
}

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

/* --- Post footer --- */

.post-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.back-link {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.15s;
}

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

/* --- Error page --- */

.error-page {
  padding: 8rem 0;
  text-align: center;
}

.error-page h1 {
  font-size: 4rem;
  font-weight: 300;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
}

.error-page p {
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* --- Footer --- */

.footer {
  padding: 4rem 0 3rem;
  border-top: 1px solid var(--border);
  transition: border-color 0.3s;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.15s;
}

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

.footer-meta {
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-faint);
}

/* --- Ghost cards --- */

.kg-width-wide {
  max-width: 100%;
}

.kg-width-full {
  max-width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
}

.kg-card {
  margin: 2rem 0;
}

.kg-bookmark-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.kg-bookmark-card:hover {
  border-color: var(--border-hover);
}

.kg-bookmark-container {
  display: flex;
  text-decoration: none;
  color: inherit;
}

.kg-bookmark-content {
  padding: 1rem 1.25rem;
  flex: 1;
}

.kg-bookmark-title {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
}

.kg-bookmark-description {
  font-size: 0.8125rem;
  font-weight: 300;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  line-height: 1.5;
}

.kg-bookmark-metadata {
  font-size: 0.6875rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
}

/* --- Mobile --- */

@media (max-width: 640px) {
  .post-item-link {
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.875rem 0.75rem;
    margin: 0 -0.75rem;
  }

  .post-item-date {
    min-width: auto;
  }

  .post-title {
    font-size: 1.5rem;
  }

  .feed {
    padding: 3rem 0 4rem;
  }

  .post {
    padding: 3rem 0 4rem;
  }

  .footer-inner {
    flex-direction: column;
  }
}
