/* ==========================================================================
   WorldWire — Clean Editorial Dark Design System
   High-contrast, zero-clutter, rapid-scan typography & layout
   ========================================================================== */

:root {
  --bg-page: #0d0f12;
  --bg-surface: #15181e;
  --bg-surface-hover: #1c2028;
  --bg-elevated: #212631;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --live-green: #10b981;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --amber-text: #fbbf24;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-sinhala: 'Noto Sans Sinhala', 'Inter', sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: 0.18s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sinhala-text {
  font-family: var(--font-sinhala) !important;
  line-height: 1.65;
}

.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ==========================================================================
   TOP SLIM PROGRESS BAR
   ========================================================================== */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.top-progress-bar.active {
  opacity: 1;
  width: 100%;
  animation: progressPulse 1.4s ease-in-out infinite;
}

@keyframes progressPulse {
  0% { transform: translateX(-60%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(60%); }
}

/* ==========================================================================
   HEADER & CATEGORY NAV
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(13, 15, 18, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-logo {
  height: 38px;
  width: auto;
  max-width: 175px;
  object-fit: contain;
  display: block;
  transition: transform var(--transition);
}

.brand-logo:hover {
  transform: scale(1.02);
}

.category-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.cat-tab {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
}

.cat-tab:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.cat-tab.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live-green);
}

.live-status.syncing .status-dot {
  background: var(--amber-text);
  animation: pulseDot 1s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-text:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-icon-text:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-icon-text.spinning .icon-spin-target {
  animation: spin 0.9s linear infinite;
}

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

/* ==========================================================================
   MAIN CONTENT & BRIEFING HEADER
   ========================================================================== */
.main-content {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 48px;
}

.briefing-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.briefing-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.briefing-desc {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.briefing-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stat-chip {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ==========================================================================
   SOURCE PILLS & QUICK-SCAN TOOLBAR
   ========================================================================== */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 18px 0 24px;
  flex-wrap: wrap;
}

.source-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.source-pill:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.source-pill.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.source-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

#quick-search {
  width: 230px;
  padding: 7px 12px 7px 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  outline: none;
  transition: var(--transition);
}

#quick-search:focus {
  border-color: var(--accent);
  background: var(--bg-surface-hover);
}

#quick-search::placeholder {
  color: var(--text-muted);
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.view-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ==========================================================================
   NEWS FEED — CARD VIEW
   ========================================================================== */
.news-feed.view-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.story-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), transform var(--transition), background-color var(--transition);
}

.story-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
  transform: translateY(-2px);
}

.story-media {
  position: relative;
  width: 100%;
  height: 176px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.story-media.no-img {
  display: none;
}

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

.story-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.05));
  border-bottom: 1px solid var(--border-subtle);
}

.story-placeholder span {
  font-family: var(--font-serif);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--src-color, var(--text-muted));
  opacity: 0.55;
  letter-spacing: 0.04em;
}

.story-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.story-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 600;
}

.lang-pill {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber-text);
  font-size: 0.7rem;
  font-weight: 600;
}

.story-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.story-link {
  color: inherit;
  text-decoration: none;
}

.story-link:hover {
  color: #93c5fd;
}

.story-subtitle-en {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.4;
}

.story-summary {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 14px;
}

.story-actions {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-read {
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.btn-read:hover {
  text-decoration: underline;
}

.btn-external {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-external:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

/* ==========================================================================
   NEWS FEED — COMPACT LIST VIEW (RAPID SCANNING)
   ========================================================================== */
.news-feed.view-compact {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.news-feed.view-compact .story-card {
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  flex-direction: row;
  align-items: center;
}

.news-feed.view-compact .story-card:last-child {
  border-bottom: none;
}

.news-feed.view-compact .story-card:hover {
  transform: none;
}

.news-feed.view-compact .story-media {
  display: none;
}

.news-feed.view-compact .story-body {
  padding: 13px 18px;
  display: grid;
  grid-template-columns: 190px 1fr auto;
  align-items: center;
  gap: 16px;
}

.news-feed.view-compact .story-meta {
  margin-bottom: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.news-feed.view-compact .meta-sep {
  display: none;
}

.news-feed.view-compact .lang-pill {
  margin-left: 0;
  margin-top: 2px;
}

.news-feed.view-compact .story-title {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.news-feed.view-compact .story-subtitle-en,
.news-feed.view-compact .story-summary {
  display: none;
}

.news-feed.view-compact .story-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ==========================================================================
   SKELETON LOADERS
   ========================================================================== */
.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.news-feed.view-compact .skeleton-card {
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
}

.news-feed.view-compact .skeleton-media {
  display: none;
}

.skeleton-media {
  height: 176px;
  background: var(--bg-elevated);
}

.skeleton-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  background: var(--bg-elevated);
}

.skeleton-line.short { width: 38%; height: 10px; }
.skeleton-line.title { width: 92%; height: 16px; }
.skeleton-line.title-2 { width: 70%; height: 16px; }
.skeleton-line.text { width: 85%; height: 11px; margin-top: 4px; }

.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

/* ==========================================================================
   EMPTY STATE & PAGINATION
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.empty-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-bottom: 6px;
}

.empty-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 18px;
}

.pagination-bar {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.btn-load-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-load-more:hover:not(:disabled) {
  background: var(--bg-elevated);
}

.btn-load-more:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pagination-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   READER MODAL
   ========================================================================== */
.reader-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.reader-modal.active {
  display: flex;
}

.reader-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}

.reader-dialog {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
  z-index: 1;
}

.reader-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(13, 15, 18, 0.82);
  color: var(--text-primary);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.reader-media {
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.reader-img {
  width: 100%;
  height: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

.reader-content {
  padding: 24px 28px 28px;
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.reader-title {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 8px;
}

.reader-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.reader-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

.reader-text {
  font-size: 0.98rem;
  color: var(--text-primary);
  line-height: 1.7;
}

.reader-text p {
  margin-bottom: 12px;
}

.reader-footer {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  transition: var(--transition);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-secondary:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 18px 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1024px) {
  .news-feed.view-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 12px;
  }
  .site-header {
    background: rgba(13, 15, 18, 0.95);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 8px 0 6px;
    row-gap: 8px;
    column-gap: 10px;
    min-height: auto;
  }
  .brand {
    grid-column: 1;
    grid-row: 1;
  }
  .brand-logo {
    height: 30px;
    max-width: 140px;
  }
  .header-actions {
    grid-column: 2;
    grid-row: 1;
    gap: 8px;
  }
  .live-status {
    padding: 4px 9px;
    font-size: 0.74rem;
  }
  .btn-icon-text {
    padding: 6px 11px;
    font-size: 0.78rem;
  }
  .category-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    margin: 0;
    padding: 6px 0 2px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }
  .cat-tab {
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
    flex-shrink: 0;
    touch-action: manipulation;
  }
  .cat-tab.active {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--text-primary);
    font-weight: 600;
  }
  .briefing-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .briefing-title {
    font-size: 1.6rem;
  }
  .controls-bar {
    gap: 10px;
  }
  .source-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .source-pills::-webkit-scrollbar {
    display: none;
  }
  .source-pill {
    flex-shrink: 0;
  }
  .toolbar-right {
    width: 100%;
    justify-content: space-between;
  }
  .search-box {
    flex: 1;
  }
  #quick-search {
    width: 100%;
  }
  .news-feed.view-cards {
    grid-template-columns: 1fr;
  }
  .news-feed.view-compact .story-body {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .news-feed.view-compact .story-meta {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .reader-modal {
    padding: 10px;
  }
  .reader-dialog {
    max-height: 92vh;
  }
  .reader-content {
    padding: 18px;
  }
  .reader-title {
    font-size: 1.3rem;
  }
  .reader-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .reader-footer .btn-primary,
  .reader-footer .btn-secondary {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .brand-logo {
    height: 26px;
    max-width: 125px;
  }
  .live-status {
    padding: 3px 7px;
    font-size: 0.7rem;
  }
  .btn-icon-text {
    padding: 5px 8px;
  }
  .btn-icon-text span {
    display: none;
  }
  .view-btn span {
    display: none;
  }
  .cat-tab {
    padding: 5px 12px;
    font-size: 0.78rem;
  }
}
