/* ==========================================================================
   Blog Home Page
   ========================================================================== */

/* Override main defaults: full-width, no max-width constraint */
main.blog-home-page {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: calc(var(--top-bar-height) + 16px) 0 80px;
  box-sizing: border-box;
  position: relative;
}

/* ── Two-column grid ── */
.blog-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  align-items: start;
}

/* ── Main reading area ── */
.blog-main {
  min-width: 0; /* prevent grid blowout */
  font-family: 'Literata', Georgia, serif;
  line-height: 1.85;
  color: var(--text-color);
}

.blog-content-header {
  margin-bottom: 0.5em;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25em;
}

.selected-date-label {
  font-size: calc(var(--base-font-size) * 0.88);
  color: var(--text-muted);
  font-weight: 400;
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.02em;
}

#blog-content {
  padding-top: 0.75em;
}

#blog-content h1,
#blog-content h2,
#blog-content h3 {
  font-family: 'Literata', Georgia, serif;
  line-height: 1.3;
}

#blog-content p {
  margin-bottom: 1.1em;
}

/* Loading state: dim content while fetching */
#blog-content.loading {
  opacity: 0.4;
  pointer-events: none;
  position: relative;
}

#blog-content.loading::after {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  margin: 2em auto;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: blog-spin 0.7s linear infinite;
}

@keyframes blog-spin {
  to { transform: rotate(360deg); }
}

/* ── Sidebar ── */
.blog-sidebar {
  position: sticky;
  top: calc(var(--top-bar-height) + 12px);
  max-height: calc(100vh - var(--top-bar-height) - 70px);
  overflow-y: auto;
  border-left: 1px solid var(--border-color);
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-section:last-child {
  border-bottom: none;
}

/* ── Sidebar section labels ── */
.sidebar-section-label {
  font-size: calc(var(--base-font-size) * 0.72);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ── Heatmap: natural size, horizontal scroll ── */
.sidebar-heatmap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#heatmap-container {
  /* wide enough for the natural SVG width to breathe */
  padding-bottom: 4px;
}

/* ── Book icon grid ── */
.sidebar-book-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.book-icon-item {
  flex: 0 0 auto;
}

.book-icon-link {
  display: block;
  text-decoration: none;
  border-radius: 3px;
  overflow: hidden;
  transition: opacity 0.15s, box-shadow 0.15s;
}

.book-icon-link:hover,
.book-icon-link:focus {
  opacity: 0.88;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  outline: none;
}

.book-icon-thumb {
  width: 52px;
  height: auto;
  display: block;
  border-radius: 3px;
}

/* ── Floating book popup (rendered in document.body by JS) ── */
.book-floating-popup {
  position: fixed;
  z-index: 1500;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.16);
  padding: 10px 12px;
  max-width: 230px;
  pointer-events: none; /* clicks fall through to the icon */
}

.book-popup-title {
  display: block;
  font-size: calc(var(--base-font-size) * 0.88);
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 6px;
}

.book-popup-blurb {
  font-size: calc(var(--base-font-size) * 0.78);
  color: var(--text-muted);
  line-height: 1.45;
}

.book-popup-blurb p {
  margin: 0;
}

/* ── Utility links (References / Ρυθμίσεις) ── */
.sidebar-util {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: block;
  font-size: calc(var(--base-font-size) * 0.9);
  color: var(--link-color);
  text-decoration: none;
  padding: 4px 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.sidebar-link:hover {
  text-decoration: underline;
}

/* ── Sidebar close button: hidden on desktop ── */
.sidebar-close {
  display: none;
}

/* ── Sidebar toggle button: hidden on desktop ── */
.sidebar-toggle {
  display: none;
}

/* ═══════════════════════════════════════════════════════════
   Mobile  (<768px): single column + slide-out sidebar overlay
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  main.blog-home-page {
    /* Extra top padding to avoid the floating toggle button */
    padding-top: calc(var(--top-bar-height) + 52px);
  }

  .blog-layout {
    grid-template-columns: 1fr;
    padding: 0 16px;
  }

  /* Sidebar becomes a fixed right-side drawer */
  .blog-sidebar {
    position: fixed;
    top: var(--top-bar-height);
    right: -100%;
    width: min(300px, 85vw);
    height: calc(100vh - var(--top-bar-height));
    max-height: none;
    background: var(--bg-color);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.18);
    z-index: 998;
    transition: right 0.28s ease;
    overflow-y: auto;
    padding: 8px 16px 16px;
    flex-direction: column;
  }

  /* Slide in when body carries .sidebar-open */
  body.sidebar-open .blog-sidebar {
    right: 0;
  }

  /* Show the × close button on mobile */
  .sidebar-close {
    display: flex;
    align-self: flex-end;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-color);
    padding: 2px 6px;
    margin-bottom: 6px;
  }

  /* Show the ☰ toggle button on mobile, fixed below top-bar */
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: calc(var(--top-bar-height) + 8px);
    right: 12px;
    z-index: 997;
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: opacity 0.2s;
  }

  .sidebar-toggle:hover {
    opacity: 0.85;
  }
}
