/* ============ موجز — 2026 editorial dark ============ */

@font-face {
  font-family: "Thmanyah Serif Display";
  src: url("fonts/thmanyahserifdisplay-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Thmanyah Serif Display";
  src: url("fonts/thmanyahserifdisplay-Black.woff2") format("woff2");
  font-weight: 800 900;
  font-display: swap;
}
@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Medium.woff2") format("woff2");
  font-weight: 500 600;
  font-display: swap;
}
@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #0a0c17;
  --bg-2: #10132a;
  --card: rgba(255, 255, 255, 0.035);
  --card-hover: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f1ea;
  --muted: #a2a4ba;
  --faint: #6c6e85;
  --majorelle: #5d6dff;
  --majorelle-deep: #3947d4;
  --saffron: #f2b64d;
  --terra: #e2683c;
  --grad: linear-gradient(120deg, var(--saffron), var(--terra) 45%, var(--majorelle) 100%);
  --radius: 20px;
  --font-display: "Thmanyah Serif Display", serif;
  --font-body: "Thmanyah Sans", sans-serif;
}

/* ---- Light theme (accents stay for brand consistency) ---- */
html.light {
  --bg: #f4f1ea;
  --bg-2: #ffffff;
  --card: rgba(20, 20, 40, 0.022);
  --card-hover: rgba(20, 20, 40, 0.05);
  --line: rgba(20, 20, 45, 0.12);
  --line-strong: rgba(20, 20, 45, 0.2);
  --text: #1a1a22;
  --muted: #55555f;
  --faint: #8c8c97;
}

html.light .bg-glow { opacity: 0.55; }
html.light .bg-pattern {
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%231a1a22' stroke-width='1'%3E%3Cpath d='M48 8 58 38 88 48 58 58 48 88 38 58 8 48 38 38Z'/%3E%3Cpath d='M48 20 55 41 76 48 55 55 48 76 41 55 20 48 41 41Z'/%3E%3Ccircle cx='48' cy='48' r='6'/%3E%3C/g%3E%3C/svg%3E");
}
html.light .grain { opacity: 0.05; }

/* readability overrides on light */
html.light .story-source { color: #c25a1e; }
html.light .whatsapp-btn { color: #128c7e; border-color: rgba(18, 140, 126, 0.3); background: rgba(18, 140, 126, 0.08); }
html.light .whatsapp-btn:hover { color: #fff; }
html.light .ai-badge { color: #c2861e; }
html.light .story.featured { box-shadow: 0 10px 34px rgba(20, 20, 45, 0.1); }
html.light .topics.stuck { background: rgba(255, 255, 255, 0.82); box-shadow: 0 10px 40px rgba(20, 20, 45, 0.14); }

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

/* overflow-x lives on html, not body — setting it only on body triggers the
   CSS overflow-propagation quirk (differing x/y overflow forces the other
   axis to "auto"), which turns body into its own scroll container and
   breaks window.scrollY-based sticky-bar detection. */
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.icon { flex-shrink: 0; vertical-align: -0.15em; }

/* ---------- decorative layers ---------- */

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(56rem 34rem at 85% -8%, rgba(93, 109, 255, 0.22), transparent 60%),
    radial-gradient(44rem 30rem at 0% 4%, rgba(226, 104, 60, 0.16), transparent 62%),
    radial-gradient(38rem 26rem at 50% 110%, rgba(242, 182, 77, 0.08), transparent 65%);
}

/* eight-point zellige star, barely-there */
.bg-pattern {
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%23f3f1ea' stroke-width='1'%3E%3Cpath d='M48 8 58 38 88 48 58 58 48 88 38 58 8 48 38 38Z'/%3E%3Cpath d='M48 20 55 41 76 48 55 55 48 76 41 55 20 48 41 41Z'/%3E%3Ccircle cx='48' cy='48' r='6'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 96px 96px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 55%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 55%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.16;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
}

.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.masthead { padding: 44px 0 10px; }

.meta-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--faint);
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}

.dateline::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--saffron);
  margin-inline-end: 8px;
  vertical-align: 1px;
  box-shadow: 0 0 12px var(--saffron);
  animation: pulse 2.4s ease-in-out infinite;
}

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

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 13px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  color: var(--saffron);
  background: rgba(242, 182, 77, 0.08);
  backdrop-filter: blur(6px);
}

/* theme toggle — top-left, where the AI badge used to sit */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease, color 0.18s ease;
}
.theme-toggle:hover { background: var(--card-hover); border-color: var(--saffron); color: var(--saffron); transform: rotate(-15deg); }

/* end bar — under the last card, before the footer */
.end-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 4px 0 22px;
}

.back-to-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.back-to-top:hover { background: var(--card-hover); border-color: var(--saffron); transform: translateY(-2px); }
.back-to-top .icon { color: var(--saffron); }

/* share-the-site — icon-only pill, matches back-to-top height */
.share-site {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--saffron);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.share-site:hover { background: var(--card-hover); border-color: var(--saffron); transform: translateY(-2px); }

.footer .ai-badge { margin-bottom: 16px; }

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(4.2rem, 13vw, 7.5rem);
  line-height: 1.4; /* Kufi descenders (ـج) clip below 1.3 with background-clip:text */
  margin-block: -0.12em; /* reclaim the extra leading visually */
  letter-spacing: -0.01em;
  background: var(--grad);
  background-size: 220% 220%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradShift 9s ease-in-out infinite;
  cursor: pointer;
  width: fit-content;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes gradShift {
  0%, 100% { background-position: 0% 40%; }
  50% { background-position: 100% 60%; }
}

.brand-dot { color: var(--saffron); -webkit-text-fill-color: var(--saffron); }

.tagline {
  color: var(--muted);
  font-size: clamp(0.95rem, 2.4vw, 1.08rem);
  font-weight: 300;
  line-height: 1.8;
  max-width: 56ch;
  margin-top: 14px;
}

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

.ticker {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-top: 26px;
  border-block: 1px solid var(--line);
  overflow: hidden;
}

.ticker-label {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: #0a0c17;
  background: var(--saffron);
  padding: 9px 16px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}

.ticker-viewport {
  overflow: hidden;
  flex: 1;
  direction: ltr; /* animation math in LTR; items stay RTL */
  display: flex;
  align-items: center;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 4%, #000 96%, transparent);
}

.ticker-track {
  display: flex;
  align-items: center;
  width: max-content;
  animation: tick 70s linear infinite;
}

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

/* RTL reading flow: the strip travels left → right */
@keyframes tick {
  from { transform: translateX(-50%); }
  to { transform: translateX(0); }
}

.ticker-item {
  direction: rtl;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 9px 0;
}

/* premium separator: rotated square, no glyphs */
.ticker-item::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--terra);
  transform: rotate(45deg);
  border-radius: 1px;
  margin: 0 18px;
}

/* ---------- topics ---------- */

/* Inline & transparent at the top; once the masthead scrolls away it lifts
   into a clean floating rounded pill — no rectangular mask band. */
.topics {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  margin: 12px -6px 0;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, padding 0.3s ease;
}

.topics.stuck {
  background: rgba(10, 12, 23, 0.72);
  backdrop-filter: blur(26px) saturate(1.4);
  -webkit-backdrop-filter: blur(26px) saturate(1.4);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.mini-brand, .mini-date {
  flex-shrink: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
}

.mini-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  line-height: 1.6;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.mini-date { font-size: 0.72rem; color: var(--faint); }

.topics.stuck .mini-brand { max-width: 100px; opacity: 1; margin-inline-start: 8px; margin-inline-end: 12px; }
.topics.stuck .mini-date { max-width: 140px; opacity: 1; margin-inline-start: 12px; margin-inline-end: 8px; }

.chips {
  flex: 1;
  display: flex;
  flex-wrap: nowrap;
  gap: 9px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 6px 8px; /* vertical room so nothing clips */
  /* soft fade at both ends as chips slide past */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}

.chips::-webkit-scrollbar { display: none; }

.topic-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 10px 19px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.topic-chip .icon { opacity: 0.75; }

.topic-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
  transform: translateY(-1px);
}

.topic-chip:active { transform: scale(0.96); }

.topic-chip.active {
  background: var(--grad) border-box;
  background-size: 100% 100%;
  border-color: transparent;
  color: #0a0c17;
  font-weight: 700;
  /* no glow: box-shadow gets clipped into a square by the chips scroller */
}

.topic-chip.active .icon { opacity: 1; }

/* ---------- digest ---------- */

.digest { flex: 1; padding: 24px 0 48px; }

.digest-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.digest-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4.5vw, 2.1rem);
  font-weight: 700;
}

.digest-header h2::after {
  content: "";
  display: block;
  width: 52px;
  height: 4px;
  border-radius: 4px;
  background: var(--grad);
  margin-top: 8px;
}

.digest-header .stamp { font-size: 0.78rem; color: var(--faint); white-space: nowrap; }

.story-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.story {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  gap: 18px;
  align-items: flex-start;
  animation: rise 0.5s cubic-bezier(0.22, 0.8, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
  transition: transform 0.2s ease, border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.story:hover {
  transform: translateY(-3px);
  background: var(--card-hover);
  border-color: rgba(242, 182, 77, 0.35);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.story-num {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  line-height: 2;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.story-body { display: flex; flex-direction: column; gap: 9px; min-width: 0; }

.story-actions { display: flex; align-items: stretch; gap: 8px; margin-top: 2px; }

/* Same pill language as the source link; white brand glyph */
.whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 13px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.whatsapp-btn:hover {
  background: #25d366;
  border-color: #25d366;
  transform: translateY(-1px);
}

.story-title {
  font-family: var(--font-display);
  font-size: 1.13rem;
  font-weight: 700;
  line-height: 1.8;
  color: var(--text);
}

.story-desc {
  font-size: 0.94rem;
  font-weight: 300;
  line-height: 1.9;
  color: var(--muted);
}

.story-source {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--saffron);
  text-decoration: none;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid rgba(242, 182, 77, 0.25);
  background: rgba(242, 182, 77, 0.06);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.story-source:hover {
  background: rgba(242, 182, 77, 0.15);
  border-color: rgba(242, 182, 77, 0.5);
  transform: translateY(-1px);
}

.story-source .icon { transform: scaleX(-1); } /* mirror external-link for RTL */

/* featured first story */
.story.featured {
  padding: 28px 26px 26px;
  background:
    linear-gradient(var(--bg-2), var(--bg-2)) padding-box,
    var(--grad) border-box;
  border: 1.5px solid transparent;
}

.story.featured .story-title {
  font-size: clamp(1.25rem, 3.2vw, 1.5rem);
  line-height: 1.75;
}

.story.featured .story-desc { font-size: 1rem; }

.story.featured::before {
  content: "الخبر الأبرز";
  position: absolute;
  top: 0;
  inset-inline-start: 26px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #0a0c17;
  background: var(--grad);
  padding: 3px 12px 4px;
  border-radius: 0 0 9px 9px;
}

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

.skeleton-list { list-style: none; display: flex; flex-direction: column; gap: 13px; }

.skeleton {
  height: 110px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.055) 50%, transparent 70%) var(--card);
  background-size: 240% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton:first-child { height: 150px; }

@keyframes shimmer {
  from { background-position: 130% 0; }
  to { background-position: -110% 0; }
}

.loading-note {
  text-align: center;
  color: var(--faint);
  font-size: 0.88rem;
  padding: 18px 0 4px;
}

/* ---------- states ---------- */

.empty-state, .error-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 2;
}

.error-state button {
  margin-top: 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 26px;
  border-radius: 99px;
  border: none;
  background: var(--grad);
  color: #0a0c17;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.error-state button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(226, 104, 60, 0.35);
}

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

.footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 34px;
  font-size: 0.76rem;
  color: var(--faint);
  line-height: 2;
}

.footer-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 14px;
}
.footer-sections a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  transition: color 0.15s ease;
}
.footer-sections a:hover { color: var(--saffron); }

.footer-legal {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  opacity: 0.8;
}

/* ---------- responsive & motion ---------- */

@media (max-width: 560px) {
  .masthead { padding-top: 30px; }
  .topics.stuck .mini-date { max-width: 0; opacity: 0; margin: 0; }
  .story { padding: 18px 16px; gap: 13px; }
  .story-title { font-size: 1.04rem; }
  .story-desc { font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ticker-track { animation: none; }
}
