/* ==========================================================================
   NsN — Newsmatic-inspired news features
   ========================================================================== */

/* Preloader */
.nsn-preloader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
.nsn-preloader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.nsn-preloader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.nsn-preloader-spin {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid #e2e8f0;
  border-top-color: var(--nsn-accent, #0284c7);
  animation: nsn-spin 0.7s linear infinite;
}
.nsn-preloader-text {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: #0f172a;
}
@keyframes nsn-spin {
  to { transform: rotate(360deg); }
}

/* Scroll top */
.nsn-scroll-top {
  position: fixed;
  right: 18px;
  bottom: 22px;
  z-index: 9990;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--nsn-accent, #0284c7);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(2, 132, 199, 0.35);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}
.nsn-scroll-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nsn-scroll-top:hover {
  filter: brightness(1.06);
}

/* Breadcrumb */
.nsn-breadcrumb {
  background: #f8fafc;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 0.84rem;
}
.nsn-breadcrumb-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  color: #64748b;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.nsn-breadcrumb a {
  color: #0284c7;
  text-decoration: none;
  font-weight: 600;
}
.nsn-breadcrumb a:hover {
  text-decoration: underline;
}
.nsn-breadcrumb .sep {
  opacity: 0.5;
}
.nsn-breadcrumb span:last-child {
  color: #0f172a;
  font-weight: 650;
}

/* Reading time */
.nsn-reading-time {
  margin: 0 0 1rem !important;
}
.nsn-reading-time span {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Related posts — compact editorial cards */
.nsn-related-posts {
  margin-top: clamp(2rem, 4vw, 3rem);
  padding-top: 1.25rem;
  border-top: 1px solid #e2e8f0;
}
.nsn-related-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 1rem !important;
  font-size: clamp(1.05rem, 1.8vw, 1.3rem) !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  letter-spacing: -0.02em;
}
.nsn-related-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, #cbd5e1, transparent);
}
.nsn-related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.nsn-related-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none !important;
  color: inherit;
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.035);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.nsn-related-card:hover {
  transform: translateY(-2px);
  border-color: #bae6fd;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.09);
}
.nsn-related-thumb {
  width: 100%;
  min-height: 0;
  aspect-ratio: 16 / 9;
  background: #e2e8f0;
  overflow: hidden;
  flex: 0 0 auto;
}
.nsn-related-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.nsn-related-card:hover .nsn-related-thumb img {
  transform: scale(1.04);
}
.nsn-related-ph {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #0284c7;
  background: linear-gradient(135deg, #e0f2fe, #f8fafc);
}
.nsn-related-body {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 13px 15px 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
}
.nsn-related-body h3 {
  margin: 0 !important;
  font-size: 0.94rem !important;
  line-height: 1.35 !important;
  font-weight: 750 !important;
  color: #0f172a !important;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nsn-related-date {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 600;
}
.nsn-related-body .nsn-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.64rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 750;
}
.nsn-editorial-note,
.nsn-source-note {
  padding: 12px 14px;
  border-left: 3px solid #38bdf8;
  border-radius: 0 10px 10px 0;
  background: #f0f9ff;
  color: #475569;
  font-size: 0.9rem;
}
.nsn-source-note a {
  color: #0369a1;
  font-weight: 700;
}

/* Archive layouts (when not custom homepage) */
body.nsn-archive-list .site-main article {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: start;
}
body.nsn-archive-grid .site-main {
  /* soft hint — themes vary */
}

@media (max-width: 760px) {
  .nsn-related-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  .nsn-related-card {
    min-height: 0;
  }
  .nsn-related-body {
    padding: 11px 12px;
  }
  .nsn-related-body h3 {
    font-size: 0.88rem !important;
    -webkit-line-clamp: 3;
  }
  .nsn-related-thumb,
  .nsn-related-ph {
    min-height: 0;
  }
  body.nsn-archive-list .site-main article {
    grid-template-columns: 1fr;
  }
  .nsn-scroll-top {
    right: 12px;
    bottom: 14px;
  }
}
