/* ── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --header-h:    56px;
  --bottom-nav:  62px;
  --cat-nav:     48px;

  --green-900:  #0F2A1E;
  --green-800:  #155C3A;
  --green-600:  #1E8449;
  --green-400:  #2ECC71;
  --green-100:  #D5F5E3;

  --bg:         #F4F5F0;
  --surface:    #FFFFFF;
  --border:     #E0E3DC;

  --text-900:   #0D0D0D;
  --text-600:   #4A4A4A;
  --text-400:   #767676;

  --red:        #C0392B;
  --cat-sports: #E36414;
  --cat-tech:   #5B4CF6;
  --cat-culture:#C0178C;
  --cat-world:  #0077B6;
  --cat-kenya:  #1A7A3A;
  --cat-uk:     #003087;
  --cat-quirky: #7D3C98;
  --cat-deep:   #6D4C41;
  --cat-emerg:  #C0392B;

  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 2px 8px rgba(0,0,0,.10);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.14);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-900);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  padding-top: calc(var(--header-h) + var(--cat-nav));
  padding-bottom: var(--bottom-nav);
  min-height: 100dvh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--green-900);
  z-index: 100;
  border-bottom: 3px solid var(--green-400);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  max-width: 900px;
  margin: 0 auto;
}

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

.logo-box {
  background: var(--green-400);
  color: var(--green-900);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .5px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.logo-text {
  color: #fff;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.logo-text strong { font-weight: 800; }

.icon-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: #fff; background: rgba(255,255,255,.12); }
.icon-btn.spinning svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Category nav ────────────────────────────────────────────────────────── */
.category-nav {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--cat-nav);
  background: var(--green-800);
  z-index: 99;
  overflow: hidden;
}

.category-tabs {
  display: flex;
  align-items: center;
  height: 100%;
  overflow-x: auto;
  padding: 0 12px;
  gap: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  white-space: nowrap;
  border: none;
  background: none;
  color: rgba(255,255,255,.7);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s, color .15s;
  letter-spacing: .3px;
}
.cat-tab:hover { color: #fff; background: rgba(255,255,255,.12); }
.cat-tab.active {
  background: var(--green-400);
  color: var(--green-900);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 0;
  position: relative;
}

.view { display: none; }
.view.active { display: block; }

/* ── Article list ────────────────────────────────────────────────────────── */
.article-list {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.article-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
  display: flex;
  position: relative;
}
.article-card:active { transform: scale(.99); box-shadow: var(--shadow); }

/* Featured (first) card */
.article-card--featured {
  flex-direction: column;
  min-height: 170px;
  border: none;
  box-shadow: var(--shadow-lg);
}
.article-card--featured .featured-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.featured-accent {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  z-index: 1;
}
.article-card--featured .card-body {
  position: relative;
  z-index: 1;
}
.featured-body { padding: 18px; }
.featured-headline {
  font-size: 19px !important;
  font-weight: 800 !important;
  -webkit-line-clamp: 4 !important;
}
.featured-summary {
  -webkit-line-clamp: 3 !important;
}
.article-card--breaking .breaking-banner {
  position: relative;
  z-index: 2;
}

.card-accent {
  width: 4px;
  flex-shrink: 0;
}

.card-body {
  padding: 14px 16px;
  flex: 1;
  min-width: 0;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .7px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  margin-bottom: 6px;
  opacity: .85;
}

.card-headline {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-900);
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-summary {
  font-size: 13px;
  color: var(--text-600);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.card-time {
  font-size: 11px;
  color: var(--text-400);
}

.card-source {
  font-size: 11px;
  color: var(--text-400);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-source::before { content: '·  '; }

/* ── Load more ───────────────────────────────────────────────────────────── */
.load-more-wrap { text-align: center; padding: 16px; }
.load-more-btn {
  background: var(--green-900);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.load-more-btn:hover { background: var(--green-800); }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h2 { font-size: 20px; color: var(--text-600); margin-bottom: 8px; }
.empty-state p  { font-size: 14px; color: var(--text-400); line-height: 1.5; }

/* ── Article detail ──────────────────────────────────────────────────────── */
.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--green-600);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 16px;
  transition: color .15s;
}
.back-btn:hover { color: var(--green-800); }

.article-detail {
  padding: 0 16px 32px;
}

.detail-category-banner {
  height: 6px;
  border-radius: 3px;
  margin-bottom: 16px;
}

.detail-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.detail-headline {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-900);
  margin-bottom: 12px;
}

.detail-meta {
  font-size: 12px;
  color: var(--text-400);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-summary {
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-600);
  margin-bottom: 24px;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--green-900);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn-primary:hover { background: var(--green-800); }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  color: var(--green-800);
  border: 2px solid var(--green-800);
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn-outline:hover { background: var(--green-100); }

/* ── Full article content ────────────────────────────────────────────────── */
.full-article {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 4px;
}

.full-article-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-400);
  margin-bottom: 14px;
}

.full-article-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-900);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Loading skeleton ────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #e8ebe4 25%, #f0f3ed 50%, #e8ebe4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sk-tag  { height: 16px; width: 60px; }
.sk-h1   { height: 18px; width: 90%; }
.sk-h2   { height: 18px; width: 70%; }
.sk-p1   { height: 13px; width: 100%; }
.sk-p2   { height: 13px; width: 80%; }
.sk-meta { height: 11px; width: 100px; }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.spinner::after {
  content: '';
  width: 28px; height: 28px;
  border: 3px solid var(--green-100);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Toast notification ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--green-900);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  z-index: 200;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Bottom nav ──────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 6px;
  z-index: 100;
  safe-area-inset-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-400);
  cursor: pointer;
  padding: 4px 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3px;
  transition: color .15s;
}
.nav-btn.active { color: var(--green-600); }
.nav-btn:hover  { color: var(--green-800); }

/* ── Breaking news banner ────────────────────────────────────────────────── */
.breaking-banner {
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: pulse-red 2s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { background: #C0392B; }
  50%       { background: #E74C3C; }
}
.breaking-dot {
  width: 7px; height: 7px;
  background: #fff;
  border-radius: 50%;
  flex-shrink: 0;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .article-list { gap: 12px; }
  .hero-headline { font-size: 24px; }
  .detail-headline { font-size: 28px; }
}

@media (min-width: 900px) {
  .article-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .article-list .article-card:first-child {
    grid-column: 1 / -1;
  }
}
