﻿/* =========================================================
   Global News Hub — style.css
   Premium light professional design
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;900&family=Noto+Sans:ital,wght@0,400;0,600;0,700;1,400&family=Outfit:wght@300;400;600;700&display=swap');

/* ----- CSS variables ----- */
:root {
  color-scheme: light;
  --c-bg: #f5f7fb;
  --c-bg-alt: #e8ecf3;
  --c-surface: #ffffff;
  --c-surface-strong: rgba(255, 255, 255, 0.95);
  --c-card: #ffffff;
  --c-card-hover: #f8fafd;
  --c-border: #e1e8f0;
  --c-accent: #1e40af;
  --c-accent2: #0f766e;
  --c-gold: #d97706;
  --c-red: #dc2626;
  --c-green: #16a34a;
  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-dimmed: #9ca3af;
  --c-scroll-track: #f0f3f8;
  --c-scroll-thumb-hover: #1a3a8a;
  --c-live-bg: rgba(220, 38, 38, 0.08);
  --c-live-border: rgba(220, 38, 38, 0.2);
  --c-tag-bg: rgba(30, 64, 175, 0.08);
  --c-tag-border: rgba(30, 64, 175, 0.15);
  --c-count-bg: rgba(30, 64, 175, 0.05);
  --c-input-focus: rgba(30, 64, 175, 0.1);
  --c-image-bg-start: #e8ecf3;
  --c-image-bg-end: #dce1ed;
  --c-toggle-bg: rgba(30, 64, 175, 0.06);
  --c-toggle-border: rgba(30, 64, 175, 0.14);
  --c-toggle-hover: rgba(30, 64, 175, 0.12);
  --c-toggle-icon: #1e40af;
  --c-link-hover: #1a3a8a;
  --radius-card: 22px;
  --shadow-soft: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-card-hover: 0 12px 32px rgba(15, 23, 42, 0.14);
  --shadow-toast: 0 8px 24px rgba(15, 23, 42, 0.12);
  --transition: 0.22s cubic-bezier(.4, 0, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #08121f;
  --c-bg-alt: #122338;
  --c-surface: #0f1b2b;
  --c-surface-strong: rgba(8, 19, 31, 0.9);
  --c-card: #102033;
  --c-card-hover: #14283f;
  --c-border: #23384f;
  --c-accent: #76aaff;
  --c-accent2: #37cfc3;
  --c-gold: #ffbf5a;
  --c-red: #ff7b78;
  --c-green: #4ade80;
  --c-text: #edf4ff;
  --c-muted: #9ab0c6;
  --c-dimmed: #73879d;
  --c-scroll-track: #0b1725;
  --c-scroll-thumb-hover: #9cc1ff;
  --c-live-bg: rgba(255, 123, 120, 0.14);
  --c-live-border: rgba(255, 123, 120, 0.34);
  --c-tag-bg: rgba(118, 170, 255, 0.14);
  --c-tag-border: rgba(118, 170, 255, 0.28);
  --c-count-bg: rgba(118, 170, 255, 0.1);
  --c-input-focus: rgba(118, 170, 255, 0.2);
  --c-image-bg-start: #14263b;
  --c-image-bg-end: #0f1d2e;
  --c-toggle-bg: rgba(118, 170, 255, 0.08);
  --c-toggle-border: rgba(118, 170, 255, 0.2);
  --c-toggle-hover: rgba(118, 170, 255, 0.16);
  --c-toggle-icon: #ffd166;
  --c-link-hover: #b9d2ff;
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.28);
  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.24);
  --shadow-card-hover: 0 18px 42px rgba(0, 0, 0, 0.34);
  --shadow-toast: 0 16px 32px rgba(0, 0, 0, 0.3);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: linear-gradient(135deg, var(--c-bg) 0%, var(--c-bg-alt) 100%);
  color: var(--c-text);
  font-family: 'Noto Sans', sans-serif;
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--c-scroll-track);
}

::-webkit-scrollbar-thumb {
  background: var(--c-accent);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--c-scroll-thumb-hover);
}

/* ===== Selection ===== */
::selection {
  background: var(--c-accent);
  color: #fff;
}

/* ===== Live Ticker ===== */
.ticker-wrap {
  background: var(--c-surface);
  border-bottom: 2px solid var(--c-border);
  overflow: hidden;
  position: relative;
  height: 40px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-soft);
}

.ticker-label {
  flex-shrink: 0;
  background: var(--c-red);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  z-index: 2;
  gap: 6px;
}

.ticker-label::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.7);
  }
}

.ticker-track {
  display: flex;
  white-space: nowrap;
  animation: ticker-scroll 60s linear infinite;
  font-size: 0.78rem;
  color: var(--c-muted);
  padding-left: 20px;
}

.ticker-track:hover {
  animation-play-state: paused;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px 0 0;
}

.ticker-item a {
  color: var(--c-text);
  text-decoration: none;
  transition: color var(--transition);
}

.ticker-item a:hover {
  color: var(--c-accent);
}

.ticker-sep {
  color: var(--c-accent);
  font-weight: 700;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--c-surface-strong);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-soft);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-family: 'Montserrat', sans-serif;
  font-weight: 900;
  font-size: 1.55rem;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  color: var(--c-text);
  text-decoration: none;
  white-space: nowrap;
}

.logo span {
  color: var(--c-accent);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--c-live-bg);
  border: 1px solid var(--c-live-border);
  color: var(--c-red);
  padding: 4px 10px;
  border-radius: 22px;
  font-weight: 700;
}

.live-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-red);
  animation: pulse-dot 1s ease-in-out infinite;
}

#last-updated-label {
  color: var(--c-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--c-toggle-bg);
  border: 1px solid var(--c-toggle-border);
  color: var(--c-text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.theme-toggle:hover {
  background: var(--c-toggle-hover);
  border-color: var(--c-accent);
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--c-input-focus);
}

.theme-toggle-icons {
  position: relative;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.theme-icon {
  position: absolute;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity var(--transition), transform var(--transition), color var(--transition);
}

.theme-icon-sun {
  color: var(--c-toggle-icon);
  opacity: 0;
  transform: scale(0.72) rotate(-18deg);
}

.theme-icon-moon {
  color: var(--c-accent);
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

:root[data-theme="dark"] .theme-icon-sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

:root[data-theme="dark"] .theme-icon-moon {
  opacity: 0;
  transform: scale(0.72) rotate(18deg);
}

.theme-toggle-text {
  white-space: nowrap;
}

/* ===== Category Tab Bar ===== */
.tab-bar-wrap {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 70px;
  z-index: 90;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.tab-bar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
  -ms-overflow-style: thin;
}

.tab-bar::-webkit-scrollbar {
  height: 4px;
}

.tab-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  padding: 14px 18px;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--c-text);
}

.tab-btn.active {
  color: var(--c-accent);
  border-bottom-color: var(--c-accent);
}

.tab-btn[data-category="all"] {
  color: var(--c-gold);
}

.tab-btn[data-category="all"].active {
  border-bottom-color: var(--c-gold);
}

/* ===== Main layout ===== */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ===== Category section ===== */
.category-section {
  margin-bottom: 48px;
  scroll-margin-top: 130px;
}

.category-section.hidden {
  display: none;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--c-border);
}

.section-tag {
  font-family: 'Outfit', sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--c-accent);
  background: var(--c-tag-bg);
  border: 1px solid var(--c-tag-border);
  padding: 4px 10px;
  border-radius: 22px;
}

.section-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--c-text);
  letter-spacing: -0.02em;
}

/* ===== Article grid ===== */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

/* ===== Article card ===== */
.article-card {
  --card-pad-y: 20px;
  --card-pad-x: 20px;
  --card-pad-start: 24px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: var(--shadow-card);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.article-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent2));
  opacity: 0;
  transition: opacity var(--transition);
}

.article-card:hover {
  background: var(--c-card-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--c-accent);
}

.article-card:hover::before {
  opacity: 1;
}

.new-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: var(--c-red);
  font-family: 'Outfit', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 22px;
  align-self: flex-start;
  animation: badge-pulse 2s ease-in-out infinite;
}

.new-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-red);
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.article-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--c-text);
  margin: 0;
  padding: 0;
}

.article-title a {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: color var(--transition);
  overflow-wrap: anywhere;
}

.article-title a:hover {
  color: var(--c-accent);
}

.article-summary {
  font-size: 0.82rem;
  color: var(--c-muted);
  line-height: 1.6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
  padding: 0;
  overflow-wrap: anywhere;
}

.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.article-date {
  font-size: 0.72rem;
  color: var(--c-dimmed);
  font-family: 'Outfit', sans-serif;
  font-variant-numeric: tabular-nums;
}

.article-date[data-timestamp] {
  cursor: help;
}

.read-link {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--transition), color var(--transition);
}

.read-link:hover {
  gap: 8px;
  color: var(--c-link-hover);
}

.read-link::after {
  content: '→';
}

/* ===== Article image ===== */
.article-img-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(135deg, var(--c-image-bg-start) 0%, var(--c-image-bg-end) 100%);
  flex-shrink: 0;
  border-bottom: 1px solid var(--c-border);
}

.article-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.article-card:hover .article-img {
  transform: scale(1.05);
}

.article-body {
  width: 100%;
  min-width: 0;
  padding: var(--card-pad-y) var(--card-pad-x) var(--card-pad-y) var(--card-pad-start);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  flex: 1;
  margin: 0;
  transform: none;
}

.article-body > * {
  width: 100%;
  min-width: 0;
}

/* Keep card spacing intact if stale markup omits the .article-body wrapper. */
.article-card > .article-title,
.article-card > .article-summary,
.article-card > .article-footer {
  width: 100%;
  min-width: 0;
  padding-left: var(--card-pad-start);
  padding-right: var(--card-pad-x);
}

.article-card > .article-title:first-child,
.article-card > .article-img-wrap + .article-title {
  padding-top: var(--card-pad-y);
}

.article-card > .new-badge + .article-title,
.article-card > .article-img-wrap + .new-badge + .article-title {
  padding-top: 12px;
}

.article-card > .article-summary {
  margin-top: 12px;
}

.article-card > .article-title + .article-footer,
.article-card > .article-summary + .article-footer {
  margin-top: 12px;
}

.article-card > .article-footer:last-child {
  padding-bottom: var(--card-pad-y);
}

.article-body h3,
.article-body h4,
.article-body p,
.article-body span {
  margin-left: 0;
  margin: 0;
  padding: 0;
}

.article-card > .new-badge {
  margin: var(--card-pad-y) var(--card-pad-x) 0 var(--card-pad-start);
}

/* ===== Toast notification ===== */
#toast-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-accent);
  color: var(--c-text);
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-toast);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s ease forwards;
  max-width: 360px;
}

.toast.fade-out {
  animation: toast-out 0.4s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
}

/* ===== Refresh progress bar ===== */
#refresh-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent2));
  z-index: 9999;
  transition: width 0.5s linear;
}

/* ===== No articles ===== */
.no-articles {
  color: var(--c-dimmed);
  font-style: italic;
  font-size: 0.85rem;
  padding: 20px 0;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--c-border);
  text-align: center;
  padding: 30px 24px;
  color: var(--c-dimmed);
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  background: var(--c-surface);
}

/* ===== Country section ===== */
.country-search-wrap {
  margin-bottom: 28px;
}

.country-search {
  width: 100%;
  max-width: 420px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  color: var(--c-text);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  padding: 12px 16px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.country-search:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-input-focus);
}

.country-search::placeholder {
  color: var(--c-dimmed);
}

.country-block {
  margin-bottom: 44px;
}

.country-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--c-border);
}

.country-name {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--c-text);
  letter-spacing: -0.01em;
}

.country-count {
  font-family: 'Outfit', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-muted);
  background: var(--c-count-bg);
  border: 1px solid var(--c-border);
  padding: 4px 10px;
  border-radius: 22px;
  white-space: nowrap;
}

.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.country-card .article-title {
  font-size: 0.88rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header-meta {
    display: none;
  }

  .header-controls {
    margin-left: auto;
  }

  .theme-toggle {
    padding: 8px 10px;
  }

  .theme-toggle-text {
    display: none;
  }

  .logo {
    font-size: 1.2rem;
  }

  .section-title {
    font-size: 1.25rem;
  }

  .article-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
  }

  .country-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
  }

  .main-content {
    padding: 24px 16px 60px;
  }

  #toast-container {
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 640px) {
  .article-card {
    --card-pad-y: 18px;
    --card-pad-x: 18px;
    --card-pad-start: 20px;
  }

  .article-grid {
    grid-template-columns: 1fr;
  }

  .country-grid {
    grid-template-columns: 1fr;
  }

  .tab-bar {
    padding: 0 12px;
  }

  .header-inner {
    padding: 0 16px;
  }

  .theme-toggle {
    width: 42px;
    justify-content: center;
  }

  .article-body {
    padding: var(--card-pad-y) var(--card-pad-x) var(--card-pad-y) var(--card-pad-start);
  }

  .article-card > .new-badge {
    margin: var(--card-pad-y) var(--card-pad-x) 0 var(--card-pad-start);
  }
}
