/* ---- Fonts ---- */
@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --max-width: 760px;
}

[data-theme="light"] {
  --bg: #fafafa;
  --bg-alt: #f0f0f0;
  --text: #1a1a1a;
  --text-muted: #666;
  --accent: #2563eb;
  --border: #e0e0e0;
  --text-faint: #aaa;
}

[data-theme="dark"] {
  --bg: #111;
  --bg-alt: #1a1a1a;
  --text: #e0e0e0;
  --text-muted: #999;
  --accent: #60a5fa;
  --border: #333;
  --text-faint: #555;
}

html {
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

/* ---- Layout ---- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ---- Header ---- */
header { margin-bottom: 3rem; }

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Avatar */
.nav-avatar { flex-shrink: 0; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  display: block;
  border: 2px solid var(--border);
  transition: border-color 0.2s;
}

.nav-avatar:hover .avatar { border-color: var(--accent); }

/* Search */
.nav-search {
  position: relative;
  width: 260px;
  flex-shrink: 0;
  margin: 0 auto;
}

#search-input {
  width: 100%;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
  transition: border-color 0.2s;
}

#search-input::placeholder { color: var(--text-muted); }
#search-input:focus { border-color: var(--accent); }

#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  max-height: 300px;
  overflow-y: auto;
}

#search-results.open { display: block; }

.search-result {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--bg-alt); }

.search-result-title {
  font-weight: 500;
}

.search-result-date {
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.search-empty {
  padding: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Nav links & social */
.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

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

.nav-links a:not(.social-icon) {
  font-size: 1rem;
}

.nav-divider {
  width: 1px;
  height: 1.2rem;
  background: var(--border);
  flex-shrink: 0;
}

.social-icon {
  display: flex;
  align-items: center;
}

.social-icon svg { transition: color 0.2s; }

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
  color: var(--text-muted);
  line-height: 1;
}

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

/* ---- Post list ---- */
.post-preview {
  margin-bottom: 2rem;
}

.post-preview-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.post-preview-header time {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.post-preview h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.post-preview h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-preview h3 a:hover { color: var(--accent); }

.post-preview-body {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.post-preview-cover {
  flex-shrink: 0;
  width: 120px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
}

.post-preview-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
}

.post-preview-cover:hover img {
  opacity: 0.8;
}

.post-preview-body p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* Cover image on single post */
.post-cover {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 2rem;
}

/* ---- Single post ---- */
.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-header time {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Post content ---- */
.post-content h1 { font-size: 1.6rem; margin: 2.5rem 0 1rem; }
.post-content h2 { font-size: 1.4rem; margin: 2rem 0 0.75rem; }
.post-content h3 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem; }
.post-content p { margin-bottom: 1rem; }
.post-content a { color: var(--accent); }

.post-content ul, .post-content ol {
  margin: 0 0 1rem 1.5rem;
}

.post-content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--text-muted);
  margin: 1rem 0;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-alt);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
}

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

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

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.post-content th,
.post-content td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.post-content th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.post-content tr:last-child td {
  border-bottom: none;
}

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

.post-content .about-photo {
  display: block;
  max-width: 480px;
  border-radius: 10px;
  margin: 0 auto 2.5rem;
}

/* ---- Video embed ---- */
.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 1.5rem 0;
  border-radius: 6px;
}

.video-embed iframe,
.video-embed video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ---- Footer ---- */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.75rem;
}

/* ---- Responsive ---- */

/* Tablet */
@media (max-width: 768px) {
  .nav-search { width: 180px; }
}

/* Mobile */
@media (max-width: 600px) {
  html { font-size: 16px; }
  .post-header h1 { font-size: 1.5rem; }
  .container { padding: 1.5rem 1rem; }

  nav { flex-wrap: wrap; gap: 0.75rem; }
  .nav-search { order: 3; max-width: 100%; flex-basis: 100%; }
  .nav-links { gap: 0.75rem; }

  .post-preview-header {
    flex-direction: column;
    gap: 0;
  }

  .post-preview-header time {
    order: -1;
    font-size: 0.8rem;
  }

  .post-preview-cover {
    width: 100px;
    height: 68px;
  }
}
