/**
 * Blog Post Image and Grid Styling
 * 
 * Design: Responsive image display with lightbox modal functionality and
 * grid layouts for photo galleries.
 * 
 * Image Styling:
 * - Centered images with rounded corners and shadows
 * - Hover effects: slight scale (1.02x) and enhanced shadow
 * - Responsive sizing: 80% width on desktop, 100% on mobile
 * - Max height constraints: 600px mobile, 700px desktop
 * 
 * Grid Layout:
 * - 2-column grid on desktop (768px+), single column on mobile
 * - Images in grid: max 400px height, pointer cursor
 * - Stronger hover effect in grid: 1.05x scale
 * 
 * Lightbox Modal:
 * - Full-screen dark overlay (90% opacity black background)
 * - Images constrained by viewport units (80vw / 88vh desktop)
 * - Prev/next controls are fixed-width flex slots to avoid image shifting
 * - Arrow icons are CSS mask vectors (font-independent, cross-browser)
 * - Close via X button, background click, or Escape key
 * - Prevents page scrolling when active
 */

/* Draft post greying (visible only in local --drafts preview) */
.draft-post {
  opacity: 0.45;
}

/* Prevent long URLs/content from causing horizontal scroll on mobile */
.post-content {
  overflow-wrap: break-word;
  word-break: break-word;
}
/* Restore normal table layout — word-break: break-word removes the minimum
   content-width floor for table cells, causing narrow columns to be squeezed */
.post-content table {
  word-break: normal;
}
/* Shared base for all post badges (draft + type labels) */
.badge {
  font-size: 0.65em;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-radius: 4px;
  padding: 3px 8px;
}

.draft-label {
  color: #fff;
  background: #aaa;
}

/* Post type label badges — softer pastel style, no-wrap handled by .post-card-meta */
.post-label-technical  { background: #dbeafe; color: #1e40af; } /* blue */
.post-label-conference { background: #e2e8f0; color: #475569; } /* silver */
.post-label-analysis   { background: #fef9c3; color: #854d0e; } /* amber */
.post-label-industry   { background: #dcfce7; color: #166534; } /* green */
.post-label-worldly-matters { background: #dbe4ff; color: #1e1b4b; } /* muted philosophy indigo */

/* Groups label + date together, prevents them from wrapping */
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.post-content img {
  max-width: 100%;
  max-height: 600px;
  height: auto;
  width: auto;
  display: block;
  margin: 20px auto;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  object-fit: contain;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

.post-content img:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

@media (min-width: 768px) {
  .post-content img {
    max-width: 80%;
    max-height: 700px;
  }
}

.image-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 30px 0;
}

@media (min-width: 768px) {
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.image-grid img {
  max-width: 100%;
  max-height: 400px;
  width: 100%;
  margin: 0;
  cursor: pointer;
}

.image-grid img:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 16px rgba(0,0,0,0.25);
}

/* Modal/Lightbox styles */
.image-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.image-modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Inner container that hugs the image so arrows are anchored to its edges */
.image-modal-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 96vw;
  max-height: 90vh;
}

/* Add extra desktop breathing room while keeping mobile baseline unchanged */
@media (min-width: 681px) {
  .image-modal-inner {
    gap: 54px;
  }
}

.image-modal img {
  /* Viewport units instead of percentages: avoids circular dependency
     when the container is content-sized through flex */
  max-width: 80vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 0;
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
  cursor: default;
}

.image-modal-close {
  position: absolute;
  top: 20px;
  right: 40px;
  color: #fff;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
}

.image-modal-close:hover {
  color: #ccc;
}

/* Prev / Next navigation arrows — regular flex items, no absolute positioning.
   Being in the normal flex flow means their placement is computed identically
   by Chrome, Safari, and Firefox. */
.image-modal-prev,
.image-modal-next {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  padding: 0;
  width: 44px;
  height: 60px;
  color: transparent;
  font-size: 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s ease;
  z-index: 10000;
  /* Keep both button slots in layout to prevent image shifting while navigating */
  display: flex;
  visibility: hidden;
  pointer-events: none;
  align-items: center;
  justify-content: center;
  user-select: none;
}

/* Draw chevrons as vector masks so icon rendering is independent of browser fonts */
.image-modal-prev::before,
.image-modal-next::before {
  content: "";
  width: 16px;
  height: 24px;
  background-color: #fff;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 24'%3E%3Cpolyline points='3,2 13,12 3,22' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 24'%3E%3Cpolyline points='3,2 13,12 3,22' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.image-modal-prev::before {
  transform: rotate(180deg);
}

.image-modal-prev:hover,
.image-modal-next:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* On narrow screens shrink the buttons so the image keeps most of the width */
@media (max-width: 680px) {
  .image-modal-prev,
  .image-modal-next {
    width: 32px;
    height: 48px;
  }

  .image-modal-prev::before,
  .image-modal-next::before {
    width: 13px;
    height: 20px;
  }

  .image-modal img {
    max-width: 76vw;
  }
}


