:root {
  --red: #E0182D;
  --red-dark: #B51224;
  --red-soft: #FFF1F3;
  --red-mid: #F5A3AB;
  --ink: #1A1A1A;
  --muted: #5C6570;
  --line: #E4E6EA;
  --bg: #F7F7F8;
  --card: #FFFFFF;
  --shadow: 0 8px 24px rgba(26, 26, 26, 0.06);
  --radius: 12px;
  --max: 1180px;
  --font: "Cairo", "Tajawal", "Segoe UI", Tahoma, sans-serif;
  --brand-logo-size: 130px;
  --brand-logo-size-mobile: 84px;
  --ticker-speed: 45s;

  /* Top bar + ticker theme tokens (B = red default) */
  --bar-bg: #9B121F;              /* deep red masthead */
  --bar-fg: #FFFFFF;
  --bar-muted: rgba(255, 255, 255, 0.82);
  --ticker-bg: #E0182D;           /* logo red */
  --ticker-fg: #FFFFFF;
  --ticker-sep: rgba(255, 255, 255, 0.55);
  --ticker-label-bg: #FFFFFF;
  --ticker-label-fg: #E0182D;
  --bar-logo-ring: rgba(255, 255, 255, 0.35);
}

body.theme-black {
  --bar-bg: #15181e;
  --bar-fg: #F5F6F8;
  --bar-muted: rgba(245, 246, 248, 0.78);
  --ticker-bg: #15181e;
  --ticker-fg: #F5F6F8;
  --ticker-sep: rgba(245, 246, 248, 0.4);
  --ticker-label-bg: #E0182D;
  --ticker-label-fg: #FFFFFF;
  --bar-logo-ring: rgba(224, 24, 45, 0.35);
}

body.theme-red {
  /* explicit alias of defaults */
  --bar-bg: #9B121F;
  --bar-fg: #FFFFFF;
  --bar-muted: rgba(255, 255, 255, 0.82);
  --ticker-bg: #E0182D;
  --ticker-fg: #FFFFFF;
  --ticker-sep: rgba(255, 255, 255, 0.55);
  --ticker-label-bg: #FFFFFF;
  --ticker-label-fg: #E0182D;
  --bar-logo-ring: rgba(255, 255, 255, 0.35);
}


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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }

.container {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -100px;
  background: var(--red);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus { top: 1rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ========== Masthead ========== */
.masthead {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--bar-bg);
  color: var(--bar-fg);
  padding-top: 1.25rem;
}

.masthead-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
}

.masthead-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
}

.masthead-logo-link { display: block; line-height: 0; }

.masthead-logo-wrap {
  position: relative;
  display: block;
  width: var(--brand-logo-size);
  height: var(--brand-logo-size);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 4px var(--bar-logo-ring), 0 10px 28px rgba(0, 0, 0, 0.28);
}

.masthead-logo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  padding: 0;
  display: block;
}

.masthead-logo--video {
  position: absolute;
  inset: 0;
  background: transparent;
}

/* Default: animated video on top of static poster fallback */
body.logo-animated .masthead-logo--static { opacity: 0; position: absolute; inset: 0; }
body.logo-animated .masthead-logo--video { opacity: 1; }

body.logo-static .masthead-logo--static { opacity: 1; position: static; }
body.logo-static .masthead-logo--video { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  body.logo-animated .masthead-logo--video { display: none !important; }
  body.logo-animated .masthead-logo--static { opacity: 1; position: static; }
}

.masthead-title {
  margin: 0.35rem 0 0;
  font-size: clamp(1.6rem, 3.2vw, 2.35rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--bar-fg);
}

.masthead-tagline {
  margin: 0;
  color: var(--bar-muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.masthead-side {
  display: flex;
  align-items: center;
}

.masthead-date {
  justify-content: flex-start;
  font-size: 0.92rem;
  color: var(--bar-muted);
  font-weight: 600;
}

.masthead-subscribe { justify-content: flex-end; }

.masthead-rule {
  position: relative;
  z-index: 1;
  height: 4px;
  background: var(--red);
  width: 100%;
}
.masthead .btn-subscribe {
  background: #fff;
  color: var(--red) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
.masthead .btn-subscribe:hover {
  background: var(--red-soft);
}

/* ========== Ticker ========== */
.ticker {
  display: flex;
  align-items: stretch;
  background: var(--ticker-bg);
  color: var(--ticker-fg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  overflow: hidden;
  min-height: 42px;
}

.ticker-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--ticker-label-bg);
  color: var(--ticker-label-fg);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0 1rem;
  z-index: 2;
  white-space: nowrap;
}

.ticker-viewport {
  flex: 1;
  overflow: hidden;
  mask-image: linear-gradient(to left, transparent 0, #000 2%, #000 98%, transparent 100%);
  -webkit-mask-image: linear-gradient(to left, transparent 0, #000 2%, #000 98%, transparent 100%);
  display: flex;
  align-items: center;
}

.ticker-track {
  display: flex;
  flex-direction: row-reverse; /* RTL flow: content moves toward the right visually while reading RTL */
  gap: 0;
  width: max-content;
  white-space: nowrap;
  animation: ticker-scroll var(--ticker-speed) linear infinite;
  will-change: transform;
}

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

.ticker-item {
  display: inline-flex;
  align-items: center;
  padding: 0 0.15rem;
  color: var(--ticker-fg);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
}
.ticker-item:hover { color: #fff; opacity: 0.9; text-decoration: underline; }
.ticker-sep {
  display: inline-block;
  padding: 0 0.85rem;
  color: var(--ticker-sep);
  font-weight: 800;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(50%); } /* two identical halves; RTL row-reverse + +X = continuous */
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track {
    animation: none;
    flex-wrap: wrap;
    white-space: normal;
    width: 100%;
    row-gap: 0.25rem;
    padding: 0.4rem 0.75rem;
  }
  .ticker-viewport { mask-image: none; -webkit-mask-image: none; overflow: visible; }
}

/* ========== Sticky nav ========== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  flex-wrap: wrap;
}

.nav-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}
.nav-tab:hover { background: var(--red-soft); color: var(--red-dark); }
.nav-tab.is-active {
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 12px rgba(224, 24, 45, 0.25);
}

.nav-source select {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-width: 9rem;
}

.btn-subscribe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 800;
  font-size: 0.92rem;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(224, 24, 45, 0.28);
  white-space: nowrap;
}
.btn-subscribe:hover { background: var(--red-dark); }
.btn-subscribe--block {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
}

.sample-banner {
  margin-top: 1rem;
  background: #FFF8E6;
  border: 1px solid #F0D58A;
  color: #7A5B00;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.last-updated {
  margin: 0.75rem auto 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ========== Front page ========== */
.front-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.5rem;
  padding: 1.25rem 0 2.5rem;
  align-items: start;
}

.front-main { min-width: 0; display: flex; flex-direction: column; gap: 1.25rem; }

.lead-story {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.lead-story .story-media {
  aspect-ratio: 16 / 9;
}

.lead-story .story-body { padding: 1.15rem 1.25rem 1.35rem; }
.lead-story .story-title {
  margin: 0.35rem 0 0.55rem;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 800;
  line-height: 1.35;
}
.lead-story .story-summary {
  margin: 0;
  color: #333;
  font-size: 1.02rem;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}

.secondary-stories {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.story-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.story-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(26, 26, 26, 0.09);
}

.story-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #FFE5E8 0%, #FFB3BB 45%, #E0182D 100%);
  overflow: hidden;
}
.story-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Light-red placeholder (NOT dark brown) */
.story-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  gap: 0.35rem;
  background: linear-gradient(145deg, #FFF1F3 0%, #FFC9CF 40%, #F07884 78%, #E0182D 100%);
  color: #fff;
  text-align: center;
  padding: 1rem;
}
.story-placeholder-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.85);
}
.story-placeholder-word {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(180, 20, 35, 0.35);
  color: #fff;
}

.story-body {
  padding: 0.95rem 1.05rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.story-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  background: var(--red-soft);
  color: var(--red-dark);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.chip--region {
  background: #EEF3FF;
  color: #2A4A9B;
}

.story-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.4;
}
.story-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-line;
}
.story-footer {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding-top: 0.35rem;
}
.story-source {
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
}
.story-source:hover { text-decoration: underline; }
.story-time {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

/* Sidebar */
.front-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 4.25rem;
}

.sidebar-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
  box-shadow: var(--shadow);
}

.sidebar-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 800;
  padding-bottom: 0.45rem;
  border-bottom: 3px solid var(--red);
}

.ranked-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: rank;
}
.ranked-list li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 1.6rem 1fr;
  gap: 0.55rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.ranked-list li:last-child { border-bottom: 0; }
.ranked-list li::before {
  content: counter(rank);
  font-weight: 800;
  color: var(--red);
  font-size: 1.05rem;
  line-height: 1.3;
}
.ranked-list a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.45;
}
.ranked-list a:hover { color: var(--red); }
.ranked-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  font-weight: 600;
}

/* About + footer */
.about-section { padding: 0 0 2.5rem; }
.about-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.about-card h2 { margin-top: 0; }
.about-card p { color: #444; }

.site-footer {
  background: #161616;
  color: #CFD3D8;
  padding: 1.75rem 0 2rem;
}
.footer-inner { display: flex; flex-direction: column; gap: 0.75rem; }
.footer-brand { display: flex; align-items: center; gap: 0.75rem; }
.footer-brand strong { color: #fff; display: block; }
.footer-brand p { margin: 0.1rem 0 0; font-size: 0.85rem; color: #9CA3AF; }
.footer-logo { border-radius: 50%; object-fit: cover; }
.footer-sources { margin: 0; font-size: 0.85rem; }
.footer-copy { margin: 0; font-size: 0.8rem; color: #9CA3AF; }

/* ========== Responsive ========== */
@media (max-width: 960px) {
  .front-page { grid-template-columns: 1fr; }
  .front-sidebar { position: static; }
  .secondary-stories { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  :root { --brand-logo-size: var(--brand-logo-size-mobile); }

  .masthead-grid {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 0.65rem;
  }
  .masthead-side {
    justify-content: center;
    width: 100%;
  }
  .masthead-date { order: 2; font-size: 0.85rem; }
  .masthead-center { order: 1; }
  .masthead-subscribe { order: 3; }
  .masthead-logo-wrap {
    width: var(--brand-logo-size-mobile);
    height: var(--brand-logo-size-mobile);
  }
  .masthead-title { font-size: 1.55rem; }

  .secondary-stories,
  .news-grid { grid-template-columns: 1fr; }

  .ticker-label { font-size: 0.82rem; padding: 0 0.75rem; }
  .nav-tab { font-size: 0.85rem; padding: 0.35rem 0.7rem; }
}





/* ========== Masthead world-map relief (prototype variants) ==========
   Toggle via ?map=emboss|silhouette|dots (see js/app.js). Default: emboss with fixed ~1200px map scale.
   Source map: assets/world-map.svg — Public Domain (CIA World Factbook Continents.svg
   via https://commons.wikimedia.org/wiki/File:Continents.svg).
   Variants use lightweight pre-rendered WebP overlays derived from that SVG.
*/
.masthead-map {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.masthead-map-layer {
  position: absolute;
  inset: -6% -1% -2%;
  background-repeat: no-repeat;
  background-position: center 42%;
  background-size: 108% auto;
  opacity: 0;
}

/* Show only the active variant's layer */
body.map-emboss .masthead-map-base,
body.map-silhouette .masthead-map-base,
body.map-dots .masthead-map-dots {
  opacity: 1;
}

/* Hide unused decorative layers in prerendered mode */
.masthead-map-shadow,
.masthead-map-highlight {
  display: none !important;
}

/* Fixed absolute map scale so wide screens (~1920+) stay as subtle as ~1280 */
body.map-emboss .masthead-map-base,
body.map-silhouette .masthead-map-base,
body.map-dots .masthead-map-dots {
  /* Cap: do NOT use % of viewport — keeps the faint emboss look at every width */
  background-size: 1200px auto;
  background-position: center 42%;
  -webkit-mask-size: 1200px auto; /* no-op for webp layers without mask */
  mask-size: 1200px auto;
}

/* (1) Embossed relief — subtle, low-contrast (DEFAULT) */
body.map-emboss .masthead-map-base {
  background-image: url("../assets/world-map-emboss.webp");
  opacity: 0.82;
}

/* (2) Tone-on-tone silhouette — darker red continents */
body.map-silhouette .masthead-map-base {
  background-image: url("../assets/world-map-silhouette.webp");
  opacity: 0.78;
}

/* (3) Dotted / halftone world map in lighter red */
body.map-dots .masthead-map-dots {
  background-image: url("../assets/world-map-dots.webp");
  opacity: 0.85;
}
body.map-dots .masthead-map-base {
  display: none;
}

/* Legacy raised asset kept on disk but not offered as a default/variant UI */
body.map-raised .masthead-map-base {
  background-image: url("../assets/world-map-raised.webp");
  background-size: 1200px auto;
  background-position: center 42%;
  opacity: 0.9;
}

/* Soft vignette so map fades at masthead edges and text stays readable */
body.map-emboss .masthead-map::after,
body.map-silhouette .masthead-map::after,
body.map-dots .masthead-map::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 85% at 50% 45%,
    transparent 32%,
    rgba(155, 18, 31, 0.28) 68%,
    rgba(155, 18, 31, 0.7) 100%);
  pointer-events: none;
}

/* Raised: gentler vignette so the gray shadow stays readable */
body.map-raised .masthead-map::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 72% 88% at 50% 42%,
    transparent 40%,
    rgba(155, 18, 31, 0.18) 72%,
    rgba(155, 18, 31, 0.55) 100%);
  pointer-events: none;
}

/* Text readability over map */
body.map-raised .masthead-title,
body.map-emboss .masthead-title,
body.map-silhouette .masthead-title,
body.map-dots .masthead-title,
body.map-raised .masthead-tagline,
body.map-emboss .masthead-tagline,
body.map-silhouette .masthead-tagline,
body.map-dots .masthead-tagline,
body.map-raised .masthead-date,
body.map-emboss .masthead-date,
body.map-silhouette .masthead-date,
body.map-dots .masthead-date {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 18px rgba(155, 18, 31, 0.55);
}

@media (max-width: 720px) {
  .masthead-map-layer {
    inset: -4% -6% 0;
    /* Keep the same absolute map scale as desktop so it stays subtle */
    background-size: 1200px auto;
    background-position: center 36%;
  }
  body.map-emboss .masthead-map-base,
  body.map-silhouette .masthead-map-base,
  body.map-dots .masthead-map-dots,
  body.map-raised .masthead-map-base {
    background-size: 1200px auto;
    background-position: center 36%;
  }
}

/* Whole news card clickable: stretch the source link over the card */
.lead-story, .story-card { position: relative; cursor: pointer; }
.lead-story .story-source::after,
.story-card .story-source::after { content: ""; position: absolute; inset: 0; z-index: 2; }

/* Floating Telegram subscribe button, shown after scrolling past the masthead.
   Fade only (no movement), own compositing layer, so it stays put while scrolling. */
.btn-subscribe--float {
  position: fixed; left: 1.25rem; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); z-index: 60;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate3d(0, 0, 0); -webkit-transform: translate3d(0, 0, 0);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  will-change: opacity;
  transition: opacity .2s ease, visibility .2s;
}
.btn-subscribe--float.is-visible { opacity: 1; visibility: visible; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { .btn-subscribe--float { transition: none; } }

/* Small Telegram subscribe button on each news card, next to the source */
.story-subscribe {
  position: relative; z-index: 3;
  display: inline-flex; align-items: center;
  background: var(--red); color: #fff !important; text-decoration: none !important;
  font-weight: 700; font-size: 0.72rem; line-height: 1;
  padding: 0.3rem 0.65rem; border-radius: 999px; white-space: nowrap;
}
.story-subscribe:hover { background: var(--red-dark); }
.story-footer .story-subscribe { margin-inline-end: auto; }
