/* Mermaid enhancements */
.mermaid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 2.25rem 0;
  padding: 1.75rem;
  border-radius: 20px;
  border: 1px solid rgba(99, 102, 241, 0.18);
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.12), rgba(236, 72, 153, 0.08)) padding-box,
              var(--bg-elevated) border-box;
  box-shadow: 0 32px 55px -35px rgba(79, 70, 229, 0.55);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  transition: transform 0.3s ease, box-shadow 0.35s ease;
}

.mermaid:hover {
  transform: translateY(-4px);
  box-shadow: 0 36px 80px -48px rgba(79, 70, 229, 0.65);
}

.mermaid svg {
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  flex-shrink: 0;
  font-family: var(--font-base);
  background-color: transparent !important;
}

.mermaid .label,
.mermaid .node text,
.mermaid text {
  font-family: var(--font-base) !important;
}

@media (prefers-color-scheme: dark) {
  .mermaid {
    border: 1px solid rgba(129, 140, 248, 0.35);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(129, 140, 248, 0.12)) padding-box,
                rgba(15, 23, 42, 0.9) border-box;
    box-shadow: 0 35px 80px -45px rgba(15, 23, 42, 0.85);
  }
}

@media (max-width: 640px) {
  .mermaid {
    margin: 1.75rem -1rem;
    border-radius: 16px;
  }
}

/* Article cover */
.post-cover {
  margin: 0 0 2.5rem;
  border-radius: 1.1rem;
  overflow: hidden;
  position: relative;
  background: linear-gradient(160deg, rgba(99, 102, 241, 0.25), rgba(56, 189, 248, 0.18));
  box-shadow: 0 40px 70px -45px rgba(15, 23, 42, 0.55);
}

.post-cover img {
  display: block;
  width: 100%;
  height: clamp(260px, 45vw, 420px);
  object-fit: cover;
  filter: saturate(1.05) contrast(0.95);
}

.post-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.18), transparent 35%);
  pointer-events: none;
}

.post-cover figcaption {
  position: absolute;
  left: 1.75rem;
  bottom: 1.5rem;
  padding: 0.4rem 0.9rem;
  background: rgba(15, 23, 42, 0.55);
  color: rgba(248, 250, 252, 0.95);
  font-size: 0.85rem;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  max-width: 70%;
}

@media (max-width: 768px) {
  .post-cover {
    border-radius: 0.9rem;
  }

  .post-cover figcaption {
    left: 1.25rem;
    bottom: 1.1rem;
    max-width: calc(100% - 2.5rem);
  }
}

/* Listing card cover */
.post-card {
  display: block;
  padding: 0;
  overflow: hidden;
}

.post-card > a {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
}

.post-card-cover {
  margin: 0;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: linear-gradient(150deg, rgba(99, 102, 241, 0.25), rgba(236, 72, 153, 0.18));
}

.post-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.post-card-content {
  padding: 1.6rem 1.75rem 1.85rem;
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  flex: 1;
}

.post-card:hover .post-card-cover img {
  transform: scale(1.04);
}

@media (max-width: 640px) {
  .post-card-cover {
    aspect-ratio: 16 / 10;
  }
}

/* Inline image helpers used in posts */
.image-note {
  margin: 2rem 0;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.16);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 22px 45px -32px rgba(15, 23, 42, 0.4);
}

.image-note img {
  display: block;
  width: 100%;
  height: auto;
}

.image-note figcaption {
  padding: 0.9rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.image-grid {
  margin: 2.25rem 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.image-grid img {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid rgba(99, 102, 241, 0.18);
  box-shadow: 0 18px 40px -30px rgba(15, 23, 42, 0.45);
  object-fit: cover;
}


.image-grid img {
  cursor: zoom-in;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background: rgba(2, 8, 23, 0.78);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
  z-index: 50;
}

.image-lightbox.is-open {
  display: flex;
}

.image-lightbox__img {
  max-width: min(900px, 100%);
  max-height: 90vh;
  border-radius: 1rem;
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 28px 60px -24px rgba(15, 23, 42, 0.75);
  cursor: default;
}

.image-lightbox__close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.image-lightbox__close:hover,
.image-lightbox__close:focus {
  background: rgba(99, 102, 241, 0.75);
  transform: scale(1.05);
}

@media (max-width: 600px) {
  .image-lightbox {
    padding: 1.25rem;
  }

  .image-lightbox__img {
    max-height: 80vh;
  }
}


.post-detail .content :not(pre) > code {
  display: inline-block;
  padding: 0.15em 0.45em;
  margin: 0 0.08em;
  border-radius: 0.45rem;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.92em;
  line-height: 1.2;
}

@media (prefers-color-scheme: dark) {
  .post-detail .content :not(pre) > code {
    background: rgba(129, 140, 248, 0.28);
    border-color: rgba(129, 140, 248, 0.42);
    color: #e2e8ff;
  }
}
