/* ========================================
   Medium-inspired Ghost Theme
   nicholassalem-medium-dark
   ======================================== */

/* --- CSS Variables --- */
:root {
  --bg-color: #ffffff;
  --bg-elevated: #ffffff;
  --bg-surface: #f9f9f9;
  --text-color: #242424;
  --text-secondary: #6b6b6b;
  --muted-text: #757575;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.15);
  --accent-color: #1a8917;
  --accent-hover: #0f730c;
  --code-bg: #f2f2f2;
  --tag-bg: #f2f2f2;
  --tag-color: #6b6b6b;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --max-width-content: 680px;
  --max-width-header: 1192px;
  --header-height: 57px;
}

html[data-theme="dark"] {
  --bg-color: #121212;
  --bg-elevated: #191919;
  --bg-surface: #1e1e1e;
  --text-color: #e6e6e6;
  --text-secondary: #a8a8a8;
  --muted-text: #8a8a8a;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --accent-color: #49c246;
  --accent-hover: #3bb338;
  --code-bg: #1e1e1e;
  --tag-bg: #2a2a2a;
  --tag-color: #a8a8a8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

/* --- Base --- */
body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

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

/* ========================================
   HEADER
   ======================================== */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.site-header-inner {
  max-width: var(--max-width-header);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 100%;
  gap: 24px;
}

.site-title-block {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.site-logo img {
  height: 25px;
  width: auto;
  display: block;
}

.site-title-meta {
  display: flex;
  flex-direction: column;
}

.site-title {
  text-decoration: none;
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--text-color);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.site-description {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted-text);
  display: none;
}

/* Navigation */
.site-nav {
  display: none;
  margin-left: auto;
}

.nav {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav li {
  list-style: none;
}

.nav a {
  color: var(--muted-text);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.15s ease;
  white-space: nowrap;
}

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

@media (min-width: 768px) {
  .site-nav {
    display: block;
  }

  .site-description {
    display: block;
  }
}

/* Theme Toggle */
.theme-toggle {
  border: none;
  background: transparent;
  color: var(--muted-text);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  margin-left: auto;
}

@media (min-width: 768px) {
  .theme-toggle {
    margin-left: 0;
  }
}

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

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
.site-main {
  padding: 40px 24px 60px;
}

.content-outer {
  display: flex;
  justify-content: center;
}

.content-inner {
  width: 100%;
  max-width: var(--max-width-content);
}

/* ========================================
   POST FEED (INDEX)
   ======================================== */
.post-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-card {
  padding: 28px 0;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

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

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

/* Card Header */
.post-card-header {
  margin-bottom: 0;
}

.post-card-tag,
.post-tag {
  display: inline-block;
  font-size: 0.8125rem;
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  line-height: 1;
}

.post-card-tag:hover,
.post-tag:hover {
  text-decoration: underline;
}

.post-card-title {
  margin: 8px 0 0;
  font-size: 1.375rem;
  line-height: 1.3;
  font-weight: 700;
  font-family: var(--font-serif);
  letter-spacing: -0.01em;
}

.post-card-title a {
  text-decoration: none;
  color: inherit;
}

.post-card-title a:hover {
  text-decoration: none;
  color: inherit;
}

/* Card Excerpt */
.post-card-excerpt {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  line-height: 1.5;
  font-family: var(--font-serif);
}

.post-card-excerpt p {
  margin: 0;
}

/* Card Meta */
.post-card-meta,
.post-meta {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--muted-text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.reading-time {
  margin-left: 0;
}

/* ========================================
   SINGLE POST
   ======================================== */
.post {
  padding-bottom: 0;
}

.post-header {
  margin-bottom: 32px;
  text-align: center;
}

.post-header .post-tag {
  margin-bottom: 16px;
}

.post-title {
  margin: 8px 0 0;
  font-size: 2.5rem;
  line-height: 1.15;
  font-weight: 700;
  font-family: var(--font-serif);
  letter-spacing: -0.02em;
}

.post-header .post-meta {
  justify-content: center;
  margin-top: 16px;
}

/* Feature Image */
.post-feature-image {
  margin: 0 0 32px;
}

.post-feature-image img {
  width: 100%;
  border-radius: 0;
  display: block;
}

/* Post Body Content */
.post-content {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-color);
  word-break: break-word;
}

.post-content p {
  margin: 0 0 1.5em;
}

.post-content h2 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 2em 0 0.75em;
  letter-spacing: -0.01em;
}

.post-content h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.35;
  margin: 1.8em 0 0.6em;
}

.post-content h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.4;
  margin: 1.6em 0 0.5em;
}

.post-content a {
  color: var(--text-color);
  text-decoration: underline;
  text-decoration-color: var(--border-medium);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s ease;
}

.post-content a:hover {
  text-decoration-color: var(--text-color);
}

.post-content blockquote {
  margin: 1.5em 0;
  padding: 0 0 0 1.25em;
  border-left: 3px solid var(--text-color);
  color: var(--text-color);
  font-style: italic;
  font-size: 1.1rem;
}

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

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

.post-content figcaption {
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-text);
  margin-top: 8px;
  font-family: var(--font-sans);
}

.post-content ul,
.post-content ol {
  padding-left: 1.5em;
  margin: 0 0 1.5em;
}

.post-content li {
  margin-bottom: 0.4em;
}

.post-content hr {
  border: none;
  text-align: center;
  margin: 2em 0;
}

.post-content hr::before {
  content: "...";
  font-size: 1.5em;
  letter-spacing: 0.6em;
  color: var(--muted-text);
}

/* Code */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--code-bg);
  padding: 1.25em 1.5em;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 1.5em 0;
}

.post-content pre code {
  padding: 0;
  background: transparent;
  font-size: inherit;
}

/* Images in content */
.post-content img {
  display: block;
  margin: 0 auto;
  border-radius: 0;
}

/* ========================================
   POST FOOTER
   ======================================== */
.post-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 32px;
}

.post-tags {
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8125rem;
}

.post-tags a {
  background: var(--tag-bg);
  color: var(--tag-color);
  padding: 4px 12px;
  border-radius: 100px;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.post-tags a:hover {
  background: var(--border-medium);
  color: var(--text-color);
}

/* Author Card */
.author-card {
  display: flex;
  gap: 16px;
  align-items: center;
}

.author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.author-meta {
  display: flex;
  flex-direction: column;
}

.author-name {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.author-bio {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--muted-text);
  line-height: 1.4;
}

/* ========================================
   FOOTER
   ======================================== */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 24px 24px 48px;
  color: var(--muted-text);
}

.site-footer-inner {
  max-width: var(--max-width-header);
  margin: 0 auto;
  font-size: 0.8125rem;
  text-align: center;
}

.site-footer a {
  color: var(--muted-text);
  text-decoration: none;
}

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

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.pagination a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

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

/* ========================================
   PAGE TEMPLATE
   ======================================== */
.page .post-header {
  margin-bottom: 24px;
}

.page .post-title {
  font-size: 2.25rem;
}

.page .post-content {
  font-family: var(--font-serif);
}

/* ========================================
   GHOST-SPECIFIC OVERRIDES
   ======================================== */

/* Ghost navigation uses <li> elements */
.site-nav ul {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Ghost card styles (image, bookmark, etc.) */
.kg-card {
  margin: 1.5em 0;
}

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

/* Ghost width classes (required) */
.kg-width-wide {
  position: relative;
  width: 85vw;
  max-width: 1040px;
  margin-left: calc(50% - 42.5vw);
  margin-right: calc(50% - 42.5vw);
}

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

.kg-width-wide img,
.kg-width-full img {
  width: 100%;
}

@media (max-width: 1040px) {
  .kg-width-wide {
    width: calc(100vw - 48px);
    margin-left: calc(50% - 50vw + 24px);
    margin-right: calc(50% - 50vw + 24px);
  }
}

/* Ghost gallery card */
.kg-gallery-card {
  margin: 1.5em 0;
}

.kg-gallery-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kg-gallery-row {
  display: flex;
  gap: 4px;
}

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

/* Ghost bookmark card */
.kg-bookmark-card {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
}

.kg-bookmark-card a {
  text-decoration: none;
}

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

.kg-bookmark-content {
  flex-grow: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.kg-bookmark-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
}

.kg-bookmark-description {
  font-size: 0.85rem;
  color: var(--muted-text);
  margin-top: 6px;
  line-height: 1.4;
  max-height: 3em;
  overflow: hidden;
}

.kg-bookmark-metadata {
  display: flex;
  align-items: center;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--muted-text);
}

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

.kg-bookmark-publisher {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.kg-bookmark-thumbnail {
  position: relative;
  min-width: 160px;
  max-width: 160px;
}

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

/* Ghost callout card */
.kg-callout-card {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 4px;
  background: var(--bg-surface);
}

.kg-callout-emoji {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.kg-callout-text {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Ghost toggle card */
.kg-toggle-card {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 16px 20px;
}

.kg-toggle-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
}

.kg-toggle-content {
  margin-top: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Ghost button card */
.kg-button-card {
  display: flex;
  justify-content: center;
  margin: 1.5em 0;
}

.kg-btn {
  display: inline-block;
  padding: 8px 24px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  background: var(--accent-color);
  color: #fff;
  transition: background-color 0.15s ease;
}

.kg-btn:hover {
  background: var(--accent-hover);
}

/* Ghost header card */
.kg-header-card {
  padding: 4em 2em;
  text-align: center;
  background: var(--bg-surface);
  border-radius: 4px;
}

.kg-header-card h2 {
  font-size: 2rem;
  margin: 0;
}

.kg-header-card p {
  font-size: 1.1rem;
  margin-top: 0.5em;
  color: var(--text-secondary);
}

/* ========================================
   TAG & AUTHOR HEADERS
   ======================================== */
.tag-header,
.author-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.tag-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.tag-description {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

.author-header .author-card {
  gap: 20px;
}

.author-header .author-avatar {
  width: 64px;
  height: 64px;
}

.author-header .author-name {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
}

.author-header .author-bio {
  font-size: 0.95rem;
  margin-top: 6px;
}

/* ========================================
   ERROR PAGE
   ======================================== */
.error-page {
  text-align: center;
  padding: 80px 0;
}

.error-code {
  font-family: var(--font-serif);
  font-size: 6rem;
  font-weight: 700;
  margin: 0;
  color: var(--muted-text);
  line-height: 1;
}

.error-message {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin: 16px 0 32px;
}

.error-link {
  display: inline-block;
  padding: 10px 28px;
  background: var(--accent-color);
  color: #fff;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.error-link:hover {
  background: var(--accent-hover);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 767px) {
  .post-title {
    font-size: 1.75rem;
  }

  .post-card-title {
    font-size: 1.2rem;
  }

  .post-content {
    font-size: 1.0625rem;
  }

  .site-main {
    padding: 28px 20px 48px;
  }

  .post-header {
    text-align: left;
  }

  .post-header .post-meta {
    justify-content: flex-start;
  }
}

/* ========================================
   SYSTEM DARK MODE FALLBACK
   ======================================== */
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] body,
  html:not([data-theme]) body {
    background-color: #121212;
    color: #e6e6e6;
  }
}

/* ========================================
   NEW MEDIUM-STYLE ELEMENTS
   ======================================== */

/* Post card content wrapper */
.post-card-content {
  flex: 1;
  min-width: 0;
}

/* Post card author */
.post-card-author {
  font-weight: 500;
  color: var(--text-color);
}

/* Meta separator */
.meta-separator {
  color: var(--muted-text);
  margin: 0 2px;
}

/* Post meta avatar (on single post) */
.post-meta-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 4px;
  vertical-align: middle;
}

.post-meta-author {
  font-weight: 500;
  color: var(--text-color);
}

/* Horizontal rule Medium style (three dots) */
.post-content hr {
  border: none;
  text-align: center;
  margin: 2.5em 0;
}

.post-content hr::before {
  content: "···";
  font-size: 1.75em;
  letter-spacing: 0.5em;
  color: var(--muted-text);
}

/* Selection color */
::selection {
  background-color: rgba(26, 137, 23, 0.15);
}

html[data-theme="dark"] ::selection {
  background-color: rgba(73, 194, 70, 0.25);
}

/* ========================================
   TRANSITIONS
   ======================================== */
body,
.site-header,
.post-card,
.theme-toggle,
.post-tags a {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
