/* ==========================================================================
   BLOG.CSS — eidevs Blog
   Deliberately independent from the dark site theme (styles.css).
   Every choice below is grounded in established screen-reading research:

   - Line length capped at ~75 characters (the 50-75 char "measure" that
     reading research consistently finds fastest/most comfortable to scan)
   - Line-height 1.7 for body copy (WCAG recommends 1.5 minimum; long-form
     reading benefits from more)
   - Off-white background + dark gray (not pure black) text — pure black on
     pure white creates harsh contrast that causes eye fatigue on screens
   - Left-aligned, never justified — justified text on the web creates
     uneven word spacing ("rivers") that slows reading
   - Minimum 18px body text, scaling up slightly on larger screens
   - Serif for long-form article body (proven easier for sustained reading),
     clean sans-serif for UI/navigation elements (headings, tags, buttons)
   ========================================================================== */

:root {
  --blog-bg:        #fdfdfb;
  --blog-bg-card:   #ffffff;
  --blog-text:      #2b2b2b;
  --blog-text-soft: #5c5c5c;
  --blog-heading:   #1a1a1a;
  --blog-border:    #e8e6e0;
  --blog-accent:    #ff7b00;   /* ties back to the main site's accent, used sparingly */
  --blog-accent-dark: #d96700;
  --blog-serif:  Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
  --blog-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --blog-mono:   'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --blog-measure: 75ch; /* the readable line-length cap */
}

/* ==========================================================================
   Layout shell
   ========================================================================== */

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Full-bleed white background — painted on #main-content (not on our own
   narrower content boxes) so the page is white edge-to-edge on wide screens,
   regardless of what max-width the actual reading content uses. Safe to
   target #main-content here since blog.css only loads on blog pages. */
#main-content {
  background: var(--blog-bg);
  padding-top: var(--nav-height); /* clears the fixed #site-header; auto-adjusts
                                      at the mobile breakpoint since --nav-height
                                      is redefined there in styles.css */
}

/* The main site's header is transparent until scrolled (.scrolled class,
   added by JS) — that works against dark hero sections but disappears
   against our white background. Forcing the "scrolled" look permanently
   here is scoped to blog pages only, since blog.css never loads elsewhere. */
#site-header {
  background: rgba(3, 3, 13, 0.88);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.38);
}

.blog-index,
.blog-post {
  color: var(--blog-text);
  font-family: var(--blog-sans);
  padding: 0 0 80px;
}

/* Blog toolbar — sits directly below the main site header, acts as a
   sub-nav for the blog: category filters on one side, language switch
   on the other. Full-bleed width, content stays centered.

   With 13 categories this overflows even on desktop, so it scrolls
   horizontally at every screen size — not just mobile. The scrollbar is
   shown (thin, styled) by default so mouse/trackpad users have a visible
   handle to grab; it's hidden again in the mobile media query below,
   where touch scroll makes a visible bar unnecessary. */
.blog-toolbar {
  background: var(--blog-bg-card);
  border-bottom: 1px solid var(--blog-border);
  padding: 14px 20px;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 12px;
  font-family: var(--blog-sans);
  scrollbar-width: thin;                       /* Firefox — slim, not hidden */
  scrollbar-color: var(--blog-border) transparent;
}

.blog-toolbar::-webkit-scrollbar {
  height: 6px;                                  /* Chrome/Safari — thin horizontal bar */
}

.blog-toolbar::-webkit-scrollbar-track {
  background: transparent;
}

.blog-toolbar::-webkit-scrollbar-thumb {
  background: var(--blog-border);
  border-radius: 10px;
}

.blog-toolbar::-webkit-scrollbar-thumb:hover {
  background: var(--blog-accent);
}

.category-filters {
  display: flex;
  flex-wrap: nowrap;
  flex-shrink: 0;
  gap: 8px;
}

.category-filters a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--blog-text-soft);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--blog-border);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.category-filters a:hover {
  border-color: var(--blog-accent);
  color: var(--blog-accent-dark);
}

.category-filters a.active {
  background: var(--blog-accent);
  border-color: var(--blog-accent);
  color: #fff;
}

.toolbar-back {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--blog-text-soft);
  text-decoration: none;
  flex-shrink: 0;
}

.toolbar-back:hover {
  color: var(--blog-accent);
}

.lang-switch {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  position: sticky;
  right: 0;
  flex-shrink: 0;
  background: var(--blog-bg-card);
  padding: 8px 16px 8px 12px;
  box-shadow: -14px 0 14px -6px rgba(0, 0, 0, 0.08);
}

.lang-switch a {
  color: var(--blog-text-soft);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.lang-switch a:hover {
  color: var(--blog-heading);
  background: var(--blog-border);
}

.lang-switch a.active {
  color: #fff;
  background: var(--blog-accent);
}

.lang-switch span {
  color: var(--blog-border);
  margin: 0 2px;
}

/* ==========================================================================
   Blog index — card grid
   ========================================================================== */

.blog-index h1 {
  font-family: var(--blog-sans);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--blog-heading);
  margin: 32px 0 28px;
  letter-spacing: -0.01em;
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
}

.blog-card {
  background: var(--blog-bg-card);
  border: 1px solid var(--blog-border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.blog-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.blog-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.blog-card h2 {
  font-family: var(--blog-sans);
  font-size: 1.15rem;
  line-height: 1.4;
  margin: 14px 18px 8px;
}

.blog-card h2 a {
  color: var(--blog-heading);
  text-decoration: none;
}

.blog-card h2 a:hover {
  color: var(--blog-accent);
}

.blog-card p {
  font-family: var(--blog-sans);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--blog-text-soft);
  margin: 0 18px 14px;
  flex-grow: 1;
}

.blog-card .read-more {
  display: inline-block;
  margin: 0 18px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--blog-accent);
  text-decoration: none;
}

.blog-card .read-more:hover {
  color: var(--blog-accent-dark);
  text-decoration: underline;
}

.category-tag {
  display: inline-block;
  font-family: var(--blog-sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blog-accent-dark);
  background: rgba(255, 123, 0, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  margin: 16px 18px 0;
}

.blog-post .category-tag {
  margin: 0 0 16px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
  font-family: var(--blog-sans);
  font-weight: 600;
}

.pagination a {
  color: var(--blog-accent);
  text-decoration: none;
}

.pagination a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Single post — the actual reading experience
   ========================================================================== */

.blog-post {
  max-width: var(--blog-measure);
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.blog-post h1 {
  font-family: var(--blog-sans);
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--blog-heading);
  margin: 20px 0 12px;
  letter-spacing: -0.01em;
}

.post-meta {
  font-family: var(--blog-sans);
  font-size: 0.9rem;
  color: var(--blog-text-soft);
  margin-bottom: 28px;
}

.post-hero-image {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 32px;
  display: block;
}

/* The core reading rules: serif body, generous size, generous line-height */
.post-content {
  font-family: var(--blog-serif);
  font-size: 1.15rem;
  line-height: 1.75;
  color: var(--blog-text);
}

.post-content p {
  margin: 0 0 1.4em;
}

.post-content h2 {
  font-family: var(--blog-sans);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blog-heading);
  margin: 2.2em 0 0.7em;
  line-height: 1.3;
}

.post-content h3 {
  font-family: var(--blog-sans);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blog-heading);
  margin: 1.8em 0 0.6em;
  line-height: 1.3;
}

.post-content a {
  color: var(--blog-accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover {
  color: var(--blog-accent);
}

.post-content ul,
.post-content ol {
  margin: 0 0 1.4em;
  padding-left: 1.4em;
}

.post-content li {
  margin-bottom: 0.5em;
}

.post-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1.6em 0;
  display: block;
}

.post-content blockquote {
  font-family: var(--blog-serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--blog-text-soft);
  border-left: 3px solid var(--blog-accent);
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.2em;
}

.post-content code {
  font-family: var(--blog-mono);
  font-size: 0.9em;
  background: var(--blog-border);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.post-content pre {
  background: #1e1e1e;
  color: #f2f2f2;
  padding: 1.2em;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.6em 0;
}

.post-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.8em 0;
  font-family: var(--blog-sans);
  font-size: 0.95rem;
}

.post-content th,
.post-content td {
  border: 1px solid var(--blog-border);
  padding: 10px 14px;
  text-align: left;
}

.post-content th {
  background: var(--blog-bg);
  font-weight: 700;
}

/* CTA block */
.post-cta {
  background: var(--blog-bg-card);
  border: 1px solid var(--blog-border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  margin: 48px 0 32px;
}

.post-cta h3 {
  font-family: var(--blog-sans);
  font-size: 1.25rem;
  color: var(--blog-heading);
  margin-bottom: 16px;
}

.post-cta .btn {
  font-family: var(--blog-sans);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--blog-accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 12px 26px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.post-cta .btn:hover {
  background: var(--blog-accent-dark);
}

.back-link {
  display: inline-block;
  font-family: var(--blog-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--blog-text-soft);
  text-decoration: none;
}

.back-link:hover {
  color: var(--blog-accent);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .container {
    padding: 0 16px;
  }

  .blog-index,
  .blog-post {
    padding: 24px 40px 56px; /* kept at 40px intentionally, per your edit */
  }

  .blog-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .post-content {
    font-size: 1.05rem;
    line-height: 1.7;
  }

  .post-cta {
    padding: 22px;
  }

  /* Toolbar keeps its horizontal scroll behavior from the base rules above,
     but on mobile the scrollbar is hidden — touch users swipe directly,
     so a visible bar isn't needed the way it is for mouse/trackpad users. */
  .blog-toolbar {
    margin-bottom: 0;
    margin-left: 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .blog-toolbar::-webkit-scrollbar {
    display: none;
  }
}