/* Mzansi News — design tokens
   Monochrome ink-on-grey palette: light grey paper, charcoal accents, silver details.
   Display face: Bricolage Grotesque. Body: system stack (fast on mobile data). */

:root {
  --paper: #F6F6F5;
  --card: #FFFFFF;
  --ink: #1A1A1C;
  --ink-soft: #6F7074;
  --line: #E4E4E7;
  --accent: #2E2F32;
  --deep: #202124;
  --silver: #A6A7AB;
  --ticker-bg: #E9E9EB;
  --red: #DA291C;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow: 0 8px 24px rgba(26, 26, 28, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131315;
    --card: #1D1D20;
    --ink: #EEEEEF;
    --ink-soft: #A0A1A5;
    --line: #2D2D31;
    --accent: #C9CACE;
    --deep: #0F0F11;
    --silver: #8A8B90;
    --ticker-bg: #232326;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  font-weight: 600;
  z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- masthead ---------- */

.masthead { text-align: center; }

.masthead-inner { padding: 26px 16px 18px; }

.masthead-meta {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.meta-sep { margin: 0 8px; opacity: 0.5; }
.live-clock { font-variant-numeric: tabular-nums; }

.brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 9vw, 4.4rem);
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand a { text-decoration: none; }
.brand-accent { color: var(--silver); }

.tagline {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/* Signature: the diagonal two-tone band under the masthead,
   a nod to the Y-band of the South African flag — now in charcoal and silver. */
.flag-band {
  display: flex;
  height: 10px;
  overflow: hidden;
}
.band-main { flex: 1 1 auto; background: var(--deep); }
.band-tip {
  flex: 0 0 clamp(90px, 22vw, 230px);
  background: var(--silver);
  transform: skewX(-35deg);
  margin-right: -14px;
}

/* ---------- ticker ---------- */

.ticker {
  display: flex;
  align-items: stretch;
  background: var(--ticker-bg);
  color: var(--ink);
  overflow: hidden;
}

.ticker-label {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  background: var(--deep);
  color: #F6F6F5;
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 14px;
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.ticker-viewport { overflow: hidden; flex: 1 1 auto; display: flex; align-items: center; }

.ticker-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding-left: 14px;
}
.ticker-track.is-scrolling { animation: ticker 90s linear infinite; }
.ticker:hover .ticker-track.is-scrolling { animation-play-state: paused; }
@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.ticker-item {
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
}
.ticker-item:hover { text-decoration: underline; }
.ticker-sep { margin: 0 14px; font-size: 0.55rem; opacity: 0.55; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ticker-track.is-scrolling { animation: none; }
  .ticker-viewport { overflow-x: auto; }
  .live-dot { animation: none; }
}

/* ---------- tabs ---------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.tabs-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 12px;
}
.tabs-inner::-webkit-scrollbar { display: none; }

.tab {
  font-family: var(--display);
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 13px 14px 10px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* .refresh-btn is reused by the error-state "Try again" button in the story grid */
.refresh-btn {
  font-family: var(--body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
}
.refresh-btn:hover { border-color: var(--accent); background: rgba(128, 128, 132, 0.1); }

/* ---------- story grid ---------- */

.stories {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}

.card-link { display: block; flex: 1 1 auto; text-decoration: none; }

.card-media { aspect-ratio: 16 / 9; background: var(--line); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-body { padding: 14px 16px 18px; }

.card-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.ago { font-size: 0.72rem; color: var(--ink-soft); }

.card-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.06rem;
  line-height: 1.28;
  letter-spacing: -0.01em;
}
.card-link:hover .card-title { text-decoration: underline; text-decoration-color: var(--silver); text-decoration-thickness: 2px; }

.card-desc {
  margin-top: 8px;
  font-size: 0.86rem;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* share button + popover menu at the foot of each card */
.card-share {
  position: relative;
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.share-btn {
  font-family: var(--body);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}
.share-btn:hover, .share-btn[aria-expanded="true"] {
  color: var(--ink);
  border-color: var(--accent);
}

.share-menu {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 4px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 150px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.share-opt {
  font-family: var(--body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.share-opt:hover { background: var(--paper); }

/* Lead story: double-width with a bigger headline on wider screens */
@media (min-width: 640px) {
  .card-lead { grid-column: span 2; }
  .card-lead .card-title { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
  .card-lead .card-desc { -webkit-line-clamp: 2; font-size: 0.95rem; }
}

/* ---------- skeleton loading ---------- */

.skeleton { pointer-events: none; }
.sk-media { aspect-ratio: 16 / 9; background: var(--line); }
.sk-line {
  height: 13px;
  border-radius: 6px;
  background: var(--line);
  margin-bottom: 10px;
  animation: shimmer 1.2s ease-in-out infinite;
}
.sk-w40 { width: 40%; }
.sk-w90 { width: 90%; }
.sk-w70 { width: 70%; }
@keyframes shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) { .sk-line { animation: none; } }

/* ---------- error state ---------- */

.error-box {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
}
.error-box h2 { font-family: var(--display); font-weight: 600; margin-bottom: 8px; }
.error-box p { color: var(--ink-soft); margin-bottom: 18px; }

/* ---------- static pages (About, Contact, Privacy, Terms) ---------- */

.page-main {
  max-width: 740px;
  margin: 0 auto;
  padding: 34px 16px 56px;
}

.page-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.page-updated {
  color: var(--ink-soft);
  font-size: 0.78rem;
  margin-bottom: 26px;
}

.prose h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 28px 0 8px;
}

.prose p, .prose li { font-size: 0.95rem; margin-bottom: 12px; }
.prose ul, .prose ol { padding-left: 22px; margin-bottom: 12px; }
.prose li { margin-bottom: 6px; }
.prose a { color: inherit; text-decoration-color: var(--silver); }
.prose a:hover { text-decoration-color: var(--accent); }

.contact-email {
  margin: 20px 0 28px;
}
.contact-email a {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  color: var(--ink);
  text-decoration-color: var(--silver);
}
.contact-email a:hover { text-decoration-color: var(--accent); }

/* ---------- footer ---------- */

.site-footer {
  margin-top: 40px;
  background: var(--deep);
  color: #ECECEE;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 16px;
  font-size: 0.82rem;
  display: grid;
  gap: 10px;
}

.footer-brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}
.footer-brand span { color: var(--silver); }

.footer-sources { opacity: 0.75; }
.footer-note { opacity: 0.55; }

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 4px 0;
}
.footer-nav a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}
.footer-nav a:hover { text-decoration: underline; }
