/**
 * ============================================================================
 * ALPINE.JS PROTOTYPE FRAMEWORK — News Reader (Feed) Styles
 * ============================================================================
 * Read-only Facebook/Medium-style card feed for browsing published news.
 * Prefix: nr-
 *
 * Copyright (c) 2026 Foundation Tutator. All rights reserved.
 * ============================================================================
 */

/* ── Feed container ────────────────────────────────────────────── */
.nr-feed {
  max-width: 700px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* ── Search bar ────────────────────────────────────────────────── */
.nr-search {
  position: relative;
  margin-bottom: 24px;
}

.nr-search input {
  width: calc(100% - 44px);
  padding: 12px 16px 12px 42px;
  font-size: 15px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  background: var(--card-bg, #fff);
  color: var(--color-gray-800, #1e293b);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.nr-search input:focus {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px var(--color-primary-bg, #eff6ff);
}

.nr-search input::placeholder {
  color: var(--color-gray-400, #94a3b8);
}

.nr-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-gray-400, #94a3b8);
  pointer-events: none;
}

.nr-reload-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  background: var(--card-bg, #fff);
  color: var(--color-gray-400, #94a3b8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nr-reload-btn:hover {
  color: var(--color-primary, #2563eb);
  border-color: var(--color-primary, #2563eb);
  background: var(--color-primary-bg, #eff6ff);
}

@keyframes spin {
  from { transform: translateY(-50%) rotate(0deg); }
  to { transform: translateY(-50%) rotate(360deg); }
}

/* ── Post card ─────────────────────────────────────────────────── */
.nr-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  margin-bottom: 20px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.nr-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* ── Hero image ────────────────────────────────────────────────── */
.nr-card-hero {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

/* ── Multi-image gallery (Facebook-style) ────────────────────── */
.nr-card-gallery {
  display: grid;
  gap: 3px;
  overflow: hidden;
  max-height: 300px;
  height: 300px;
}

.nr-card-gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 2 images: side by side, equal width */
.nr-gallery-2 {
  grid-template-columns: 1fr 1fr;
}

/* 3 images: left ~60%, right 2 stacked ~40% */
.nr-gallery-3 {
  grid-template-columns: 3fr 2fr;
  grid-template-rows: 1fr 1fr;
}
.nr-gallery-3 > .nr-card-gallery-img:first-child {
  grid-row: 1 / 3;
}

/* 4 images: 2x2 grid */
.nr-gallery-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* 5+ images: 2x2 grid with overlay on last cell */
.nr-gallery-more {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

/* Overlay cell (wraps 4th image + "+N" label) */
.nr-gallery-overlay-cell {
  position: relative;
  overflow: hidden;
}

.nr-gallery-overlay-cell .nr-card-gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nr-gallery-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

/* ── Card header (author + date + pinned) ──────────────────────── */
.nr-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px 0;
  font-size: 13px;
  color: var(--color-gray-500, #64748b);
}

.nr-card-author {
  font-weight: 600;
  color: var(--color-gray-800, #1e293b);
}

.nr-card-date {
  color: var(--color-gray-400, #94a3b8);
}

.nr-card-header-dot {
  color: var(--color-gray-400, #94a3b8);
}

/* ── Pinned badge ──────────────────────────────────────────────── */
.nr-pinned-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-warning, #f59e0b);
  background: var(--color-warning-bg, #fffbeb);
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: auto;
}

/* ── Card title ────────────────────────────────────────────────── */
.nr-card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-gray-800, #1e293b);
  padding: 10px 20px 0;
  line-height: 1.35;
}

/* ── Translated label ─────────────────────────────────────────── */
.nr-translated-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 20px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-info, #3b82f6);
  font-style: italic;
}

.nr-translated-label svg {
  flex-shrink: 0;
}

/* ── Card content (rendered HTML) ──────────────────────────────── */
.nr-card-content {
  padding: 8px 20px 16px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--color-gray-600, #475569);
  overflow: hidden;
  position: relative;
}

.nr-card-content.nr-collapsed {
  max-height: 120px;
}

.nr-card-content.nr-collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(transparent, var(--card-bg, #fff));
  pointer-events: none;
}

/* Reuse typography from news content display */
.nr-card-content h1 { font-size: 22px; font-weight: 700; margin: 16px 0 8px; color: var(--color-gray-800, #1e293b); }
.nr-card-content h2 { font-size: 18px; font-weight: 600; margin: 14px 0 6px; color: var(--color-gray-800, #1e293b); }
.nr-card-content h3 { font-size: 16px; font-weight: 600; margin: 12px 0 4px; color: var(--color-gray-800, #1e293b); }
.nr-card-content p { margin: 0 0 10px; }
.nr-card-content ul, .nr-card-content ol { margin: 0 0 10px; padding-left: 24px; }
.nr-card-content li { margin-bottom: 4px; }
.nr-card-content a { color: var(--color-primary, #2563eb); text-decoration: underline; }
.nr-card-content img { max-width: 100%; border-radius: 8px; margin: 10px 0; }
.nr-card-content blockquote {
  border-left: 4px solid var(--color-primary, #2563eb);
  padding: 8px 16px;
  margin: 10px 0;
  background: var(--color-primary-bg, #eff6ff);
  border-radius: 0 6px 6px 0;
}

/* ── Read more / Show less toggle ──────────────────────────────── */
.nr-read-more {
  display: inline-block;
  padding: 0 20px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary, #2563eb);
  cursor: pointer;
  border: none;
  background: none;
}

.nr-read-more:hover {
  text-decoration: underline;
}

/* ── Reaction bar (thumbs up/down + view count) ───────────────── */
.nr-reaction-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 8px 20px 12px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  margin: 0;
}

.nr-reaction-btn {
  display: inline-flex;
  flex-direction: row;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--color-gray-500, #64748b);
  background: none;
  border: 1px solid transparent;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}

.nr-reaction-btn svg {
  flex-shrink: 0;
  display: block;
}

.nr-reaction-btn:hover {
  background: var(--content-bg, #f8fafc);
  border-color: var(--border-color, #e2e8f0);
}

.nr-reaction-btn.nr-reaction-active {
  color: var(--color-primary, #2563eb);
  background: var(--color-primary-bg, #eff6ff);
  border-color: var(--color-primary, #2563eb);
}

.nr-reaction-btn.nr-reaction-active:hover {
  background: var(--color-primary-bg, #eff6ff);
}

.nr-reaction-btn-down.nr-reaction-active-down {
  color: var(--color-error, #ef4444);
  background: var(--color-error-bg, #fef2f2);
  border-color: var(--color-error, #ef4444);
}

.nr-reaction-btn-down.nr-reaction-active-down:hover {
  background: var(--color-error-bg, #fef2f2);
}

.nr-reaction-count {
  font-size: 13px;
  line-height: 1;
}

/* ── Share button ──────────────────────────────────────────────── */
.nr-share-btn {
  display: inline-flex;
  flex-direction: row;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--color-gray-500, #64748b);
  background: none;
  border: 1px solid transparent;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
  position: relative;
}

.nr-share-btn svg {
  flex-shrink: 0;
  display: block;
}

.nr-share-btn:hover {
  background: var(--content-bg, #f8fafc);
  border-color: var(--border-color, #e2e8f0);
  color: var(--color-gray-600, #475569);
}

.nr-share-count {
  font-size: 13px;
  line-height: 1;
}

/* ── Share popup ──────────────────────────────────────────────── */
.nr-share-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 6px 0;
  min-width: 160px;
  z-index: 100;
  animation: nr-share-fadein 0.15s ease;
}

@keyframes nr-share-fadein {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.nr-share-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--color-gray-600, #475569);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.nr-share-option:hover {
  background: var(--color-primary-bg, #eff6ff);
  color: var(--color-primary, #2563eb);
}

.nr-share-option svg {
  flex-shrink: 0;
}

.nr-share-option-label {
  flex: 1;
}

.nr-view-label {
  margin-left: auto;
  display: inline-flex;
  flex-direction: row;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  line-height: 1;
  color: var(--color-gray-400, #94a3b8);
  user-select: none;
  white-space: nowrap;
}

.nr-view-label svg {
  flex-shrink: 0;
  display: block;
}

/* ── Card footer ───────────────────────────────────────────────── */
.nr-card-footer {
  padding: 0 20px 16px;
  font-size: 12px;
  color: var(--color-gray-400, #94a3b8);
  border-top: 1px solid var(--border-color, #e2e8f0);
  padding-top: 12px;
  margin: 0 20px;
  padding-left: 0;
  padding-right: 0;
}

/* ── Empty state ───────────────────────────────────────────────── */
.nr-empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--color-gray-400, #94a3b8);
}

.nr-empty-icon {
  margin-bottom: 16px;
  color: var(--color-gray-400, #94a3b8);
  display: flex;
  justify-content: center;
}

.nr-empty-text {
  font-size: 16px;
  line-height: 1.5;
}

/* ── Load more button ──────────────────────────────────────────── */
.nr-load-more {
  display: block;
  width: 100%;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary, #2563eb);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  margin-top: 8px;
}

.nr-load-more:hover {
  background: var(--color-primary-bg, #eff6ff);
  border-color: var(--color-primary, #2563eb);
}

/* ── Infinite scroll sentinel (invisible trigger) ────────────── */
.nr-scroll-sentinel {
  height: 1px;
  width: 100%;
  pointer-events: none;
}

/* ── Loading more spinner (bottom of feed) ───────────────────── */
.nr-loading-more {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0 8px;
  color: var(--color-gray-400, #94a3b8);
}

/* ── Searching indicator ─────────────────────────────────────── */
.nr-searching {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 16px;
  font-size: 13px;
  color: var(--color-gray-400, #94a3b8);
}

/* ── Loading spinner ───────────────────────────────────────────── */
.nr-loading {
  text-align: center;
  padding: 60px 24px;
  color: var(--color-gray-400, #94a3b8);
  font-size: 14px;
}

/* ── Lightbox / Photo Carousel ─────────────────────────────────── */
.nr-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: nr-lb-fadein 0.2s ease;
}

@keyframes nr-lb-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.nr-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
}

.nr-lightbox-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px;
  box-sizing: border-box;
}

/* Close button */
.nr-lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.nr-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Image wrapper (holds image + nav arrows) */
.nr-lightbox-stage {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nr-lightbox-image {
  max-height: 70vh;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
  display: block;
  transition: opacity 0.25s ease;
}

.nr-lightbox-image.nr-lb-fade {
  opacity: 0;
}

/* Navigation arrows */
.nr-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.nr-lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.nr-lightbox-nav.nr-lb-prev {
  left: -60px;
}

.nr-lightbox-nav.nr-lb-next {
  right: -60px;
}

.nr-lightbox-nav[disabled] {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

/* Counter "2 / 4" */
.nr-lightbox-counter {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  margin-top: 12px;
  letter-spacing: 1px;
  user-select: none;
}

/* Info area (title + content below image) */
.nr-lightbox-info {
  width: 100%;
  max-height: 25vh;
  overflow-y: auto;
  margin-top: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.nr-lightbox-info::-webkit-scrollbar {
  width: 6px;
}
.nr-lightbox-info::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

.nr-lightbox-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.35;
}

.nr-lightbox-content {
  font-size: 14px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.75);
}

.nr-lightbox-content p { margin: 0 0 8px; }
.nr-lightbox-content ul, .nr-lightbox-content ol { margin: 0 0 8px; padding-left: 20px; }
.nr-lightbox-content li { margin-bottom: 3px; }
.nr-lightbox-content a { color: #93c5fd; text-decoration: underline; }
.nr-lightbox-content blockquote {
  border-left: 3px solid rgba(255,255,255,0.3);
  padding: 6px 12px;
  margin: 8px 0;
  color: rgba(255,255,255,0.6);
}
.nr-lightbox-content h1, .nr-lightbox-content h2, .nr-lightbox-content h3 {
  color: #fff;
  margin: 10px 0 4px;
}

/* Make gallery / hero images clickable */
.nr-card-hero.nr-clickable,
.nr-card-gallery-img.nr-clickable,
.nr-gallery-overlay-cell.nr-clickable {
  cursor: pointer;
}

.nr-card-hero.nr-clickable:hover,
.nr-card-gallery-img.nr-clickable:hover {
  opacity: 0.9;
}

.nr-gallery-overlay-cell.nr-clickable:hover .nr-card-gallery-img {
  opacity: 0.9;
}

/* ── Responsive ────────────────────────────────────────────────── */

/* Lightbox responsive */
@media (max-width: 1040px) {
  .nr-lightbox-nav.nr-lb-prev {
    left: 8px;
  }
  .nr-lightbox-nav.nr-lb-next {
    right: 8px;
  }
}

@media (max-width: 640px) {
  .nr-lightbox-nav {
    width: 40px;
    height: 40px;
  }
  .nr-lightbox-nav.nr-lb-prev {
    left: 4px;
  }
  .nr-lightbox-nav.nr-lb-next {
    right: 4px;
  }
  .nr-lightbox-close {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
  }
  .nr-lightbox-info {
    max-height: 20vh;
  }
}

@media (max-width: 640px) {
  .nr-feed {
    padding: 12px 8px 32px;
  }
  .nr-card {
    border-radius: 8px;
  }
  .nr-card-title {
    font-size: 17px;
    padding: 8px 16px 0;
  }
  .nr-card-header {
    padding: 12px 16px 0;
  }
  .nr-card-content {
    padding: 6px 16px 12px;
    font-size: 14px;
  }
  .nr-read-more {
    padding: 0 16px 12px;
  }
  .nr-reaction-bar {
    padding: 8px 16px 12px;
  }
  .nr-card-footer {
    margin: 0 16px;
  }
}
