/* ==========================================================================
   Devlog Minimal - Ghost Theme
   A clean, typography-focused theme for developer blogs
   ========================================================================== */

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Light mode (default) */
  --bg: #fafafa;
  --bg-secondary: #f0f0f0;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --border: #e0e0e0;
  --accent: #6d9eeb;
  --code-bg: #f4f4f4;
  --code-text: #d63384;
  --kbd-bg: #e8e8e8;
  --kbd-border: #ccc;
  --blockquote-border: #ddd;
  --link: #4a7cc9;
  --link-hover: #2d5aa0;
  --selection-bg: #b3d4fc;

  /* Typography - with Ghost custom font fallbacks */
  --font-body: var(--gh-font-body, 'IBM Plex Sans'), -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: var(--gh-font-heading, 'IBM Plex Sans'), -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Spacing */
  --content-width: 720px;
  --nav-height: 60px;
}

[data-theme="dark"] {
  --bg: #111111;
  --bg-secondary: #1a1a1a;
  --text: #e0e0e0;
  --text-secondary: #999999;
  --text-tertiary: #666666;
  --border: #2a2a2a;
  --accent: #7daeeb;
  --code-bg: #1e1e1e;
  --code-text: #e8a0bf;
  --kbd-bg: #2a2a2a;
  --kbd-border: #444;
  --blockquote-border: #333;
  --link: #7daeeb;
  --link-hover: #a5c8f2;
  --selection-bg: #264f78;
}

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

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

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

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background-color 0.2s ease, color 0.2s ease;
  min-height: 100vh;
}

/* ---------- Links ---------- */
a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

/* ---------- Layout ---------- */
.site-wrapper {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
}

.site-content {
  width: 100%;
  padding: 2rem 1.5rem;
}

/* ---------- Navigation ---------- */
.site-nav {
  position: fixed;
  left: calc(50% - var(--content-width) / 2 - 220px);
  top: 0;
  height: 100vh;
  width: 200px;
  padding: 5.5rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1.5rem;
  background: var(--bg);
  transition: background-color 0.2s ease;
  overflow-y: auto;
  z-index: 10;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  list-style: none;
  align-items: flex-end;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  letter-spacing: -0.01em;
  transition: color 0.15s ease;
  text-align: right;
}

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

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

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

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

.theme-toggle kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  border-radius: 3px;
  line-height: 1;
}

/* ---------- Post List (Index) ---------- */
.post-list {
  list-style: none;
}

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

.post-list-item:first-child {
  padding-top: 0;
}

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

.post-list-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

.post-list-title a {
  color: var(--text);
}

.post-list-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-list-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.post-list-meta .separator {
  opacity: 0.4;
}

.post-list-excerpt {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ---------- Post Header ---------- */
.post-header {
  margin-bottom: 2.5rem;
}

.post-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.post-meta .separator {
  opacity: 0.4;
}

.post-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.post-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Post Content ---------- */
.post-feature-image {
  margin-bottom: 2rem;
}

.post-feature-image img {
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.post-content {
  font-size: 1rem;
  line-height: 1.8;
}

.post-content > * + * {
  margin-top: 1.5rem;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.post-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.5rem;
}

.post-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.post-content p {
  margin-top: 1rem;
  margin-bottom: 0;
}

.post-content strong {
  font-weight: 600;
}

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

/* Inline code */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

/* Code blocks */
.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  overflow-x: auto;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-content pre code {
  background: none;
  color: var(--text);
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Blockquotes */
.post-content blockquote {
  border-left: 3px solid var(--blockquote-border);
  padding-left: 1.25rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Images */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5rem 0;
}

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

.post-content figcaption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-top: 0.5rem;
  font-family: var(--font-mono);
}

/* Lists */
.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
  margin-top: 1rem;
}

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

.post-content li + li {
  margin-top: 0.25rem;
}

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

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

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

.post-content th {
  background: var(--bg-secondary);
  font-weight: 600;
}

/* Bookmark cards (Ghost) */
.kg-bookmark-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 1.5rem 0;
}

.kg-bookmark-container {
  display: flex;
  text-decoration: none;
  color: var(--text);
}

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

.kg-bookmark-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.kg-bookmark-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kg-bookmark-metadata {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.kg-bookmark-icon {
  width: 16px;
  height: 16px;
}

.kg-bookmark-thumbnail {
  width: 180px;
  min-height: 100%;
}

.kg-bookmark-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
}

/* Gallery cards */
.kg-gallery-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.kg-gallery-row {
  display: flex;
  gap: 0.75rem;
}

.kg-gallery-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

/* Image cards */
.kg-image-card,
.kg-gallery-card {
  margin: 2rem 0;
}

.kg-image-card img {
  margin: 0;
}

.kg-width-wide {
  max-width: calc(var(--content-width) + 120px);
  margin-left: calc(50% - 50vw + 1.5rem);
  margin-right: calc(50% - 50vw + 1.5rem);
  width: calc(100vw - 3rem);
}

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

/* ---------- Tags Page ---------- */
.tag-list {
  list-style: none;
}

.tag-list-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.tag-list-name {
  font-weight: 500;
}

.tag-list-count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

/* ---------- Page Header (for tag/author archives) ---------- */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.page-header-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header-description {
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-size: 0.95rem;
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.pagination a {
  color: var(--text-secondary);
}

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

.page-number {
  color: var(--text-tertiary);
}

/* ---------- Footer ---------- */
.site-footer {
  width: 100%;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}

.footer-links a {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  transition: color 0.15s ease;
}

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

.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ---------- Error Pages ---------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  text-align: center;
}

.error-code {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 700;
  color: var(--text-tertiary);
  line-height: 1;
  margin-bottom: 1rem;
}

.error-message {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.error-link {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* ---------- Members / Subscribe (Ghost) ---------- */
.subscribe-form {
  margin-top: 2rem;
  padding: 2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

.subscribe-form h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.subscribe-form p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.subscribe-input-group {
  display: flex;
  gap: 0.5rem;
  max-width: 400px;
  margin: 0 auto;
}

.subscribe-input-group input[type="email"] {
  flex: 1;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.subscribe-input-group input[type="email"]:focus {
  border-color: var(--accent);
}

.subscribe-input-group button {
  padding: 0.6rem 1.25rem;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.subscribe-input-group button:hover {
  opacity: 0.85;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .site-nav {
    position: relative;
    left: auto;
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 1.5rem 1.5rem 0;
  }

  .nav-links {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .site-wrapper {
    max-width: var(--content-width);
  }
}

@media (max-width: 640px) {
  :root {
    --content-width: 100%;
  }

  .site-nav {
    position: relative;
    left: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding: 1rem;
  }

  .nav-links {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .site-wrapper {
    max-width: 100%;
  }

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

  .post-content h2 {
    font-size: 1.3rem;
  }

  .site-content {
    padding: 1.5rem 1rem;
  }

  .site-footer {
    padding: 1.5rem 1rem;
  }

  .footer-content {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .kg-bookmark-container {
    flex-direction: column;
  }

  .kg-bookmark-thumbnail {
    width: 100%;
    height: 150px;
    order: -1;
  }

  .subscribe-input-group {
    flex-direction: column;
  }

  .kg-width-wide {
    margin-left: -1rem;
    margin-right: -1rem;
    width: calc(100% + 2rem);
    max-width: calc(100% + 2rem);
  }
}

/* ---------- Print ---------- */
@media print {
  body {
    background: white;
    color: black;
  }

  .site-nav,
  .site-footer,
  .theme-toggle,
  .subscribe-form {
    display: none;
  }
}
