/* ============================================================
   KNY News — Professional Editorial Design System
   Inspired by Al Jazeera / BBC News
   RTL-first | Dark Mode | Fully Responsive
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=Noto+Kufi+Arabic:wght@300;400;500;600;700;800;900&family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700;800&family=Source+Serif+4:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Brand — Al Jazeera-inspired red */
  --red:          #c10b1b;
  --red-dark:     #9e0917;
  --red-deep:     #7a050f;
  --red-soft:     rgba(193,11,27,0.08);
  --red-glow:     rgba(193,11,27,0.18);

  /* Secondary palette */
  --navy:         #0a2240;
  --navy-mid:     #133a63;
  --blue:         #1a6ea8;
  --gold:         #c9972c;
  --green:        #1a7a4a;
  --teal:         #1270a1;

  /* Neutrals — Light */
  --white:        #ffffff;
  --off-white:    #f5f5f5;
  --gray-50:      #fafafa;
  --gray-100:     #f0f0f0;
  --gray-200:     #e4e4e4;
  --gray-300:     #d0d0d0;
  --gray-400:     #a8a8a8;
  --gray-500:     #6e6e6e;
  --gray-600:     #4a4a4a;
  --gray-700:     #2e2e2e;
  --gray-800:     #1c1c1c;
  --gray-900:     #0d0d0d;

  /* Semantic — Light mode */
  --bg:           #f0f0f0;
  --bg-card:      #ffffff;
  --bg-nav:       #ffffff;
  --bg-topbar:    #0a2240;
  --bg-ticker:    #c10b1b;
  --bg-skeleton:  #e4e4e4;
  --bg-section:   #f5f5f5;
  --bg-footer:    #0d0d0d;
  --bg-footer-mid:#1a1a1a;
  --bg-overlay:   rgba(0,0,0,0.55);

  --text-main:    #111111;
  --text-muted:   #555555;
  --text-faint:   #888888;
  --text-invert:  #ffffff;

  --border:       #e0e0e0;
  --border-mid:   #cccccc;
  --border-strong:#b0b0b0;

  --shadow-xs:    0 1px 3px rgba(0,0,0,0.07);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.09);
  --shadow-md:    0 4px 18px rgba(0,0,0,0.12);
  --shadow-lg:    0 8px 36px rgba(0,0,0,0.16);
  --shadow-xl:    0 16px 56px rgba(0,0,0,0.22);

  /* Radii — editorial is tight */
  --r-none:       0px;
  --r-xs:         2px;
  --r-sm:         4px;
  --r-md:         6px;
  --r-lg:         10px;
  --r-xl:         16px;
  --r-full:       9999px;

  /* Motion */
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:     cubic-bezier(0, 0, 0.2, 1);
  --t-fast:       120ms;
  --t-mid:        250ms;
  --t-slow:       400ms;

  /* Typography */
  --font-ar:      'IBM Plex Sans Arabic', 'Cairo', 'Noto Kufi Arabic', sans-serif;
  --font-en:      'Inter', system-ui, sans-serif;
  --font-serif:   'Source Serif 4', Georgia, serif;

  /* Layout */
  --nav-h:        60px;
  --topbar-h:     36px;
  --ticker-h:     40px;
  --container:    1280px;
  --container-sm: 960px;
  --gutter:       24px;
}

/* Dark mode */
[data-theme="dark"] {
  --bg:           #111111;
  --bg-card:      #1d1d1d;
  --bg-nav:       #0d0d0d;
  --bg-topbar:    #000000;
  --bg-section:   #161616;
  --bg-skeleton:  #2a2a2a;

  --text-main:    #eeeeee;
  --text-muted:   #999999;
  --text-faint:   #666666;

  --border:       #2a2a2a;
  --border-mid:   #3a3a3a;
  --border-strong:#4a4a4a;

  --shadow-xs:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.5);
  --shadow-md:    0 4px 18px rgba(0,0,0,0.6);
  --shadow-lg:    0 8px 36px rgba(0,0,0,0.7);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--font-ar);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-main);
  background: var(--bg);
  direction: rtl;
  text-align: right;
  transition: background-color var(--t-mid), color var(--t-mid);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100%;
  position: relative;
}

body[dir="ltr"] { direction: ltr; text-align: left; font-family: var(--font-en); }

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--red); border-radius: 2px; }

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */
.container {
  max-width: min(var(--container), 100%);
  margin: 0 auto;
  /* Physical L/R: notch / home-indicator safe areas */
  padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px))
           0 max(var(--gutter), env(safe-area-inset-left, 0px));
}

.container-sm {
  max-width: min(var(--container-sm), 100%);
  margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px))
           0 max(var(--gutter), env(safe-area-inset-left, 0px));
}

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

/* ============================================================
   TOP UTILITY BAR  (Al Jazeera-style dark strip)
   ============================================================ */
.topbar {
  background: var(--bg-topbar);
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 1200;
  width: 100%;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

/* Inner row: full width inside .container padding, no horizontal overflow */
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
  gap: 8px 12px;
}

.topbar-date {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.topbar-date i {
  color: var(--red);
  font-size: 10px;
  flex-shrink: 0;
}

/* Wrapper so ellipsis works on long dates (RTL/LTR) */
.topbar-date-text {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-date-full {
  display: inline;
}

.topbar-date-short {
  display: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.topbar-social {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-inline-start: 12px;
}

.topbar-social a {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  transition: background var(--t-fast), color var(--t-fast);
}

.topbar-social a:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Lang switcher in topbar */
.topbar-langs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: rgba(255,255,255,0.07);
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

.topbar-lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 9px;
  border-radius: calc(var(--r-sm) - 1px);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  transition: all var(--t-fast);
  letter-spacing: 0.3px;
  box-sizing: border-box;
}

.topbar-lang-btn.active,
.topbar-lang-btn:hover {
  background: var(--red);
  color: #fff;
}

/* Theme toggle */
.topbar-theme {
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  transition: all var(--t-fast);
  flex-shrink: 0;
  box-sizing: border-box;
}

.topbar-theme:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ============================================================
   BREAKING NEWS TICKER
   ============================================================ */
.breaking-bar {
  height: var(--ticker-h);
  background: var(--bg-ticker);
  display: flex;
  align-items: center;
  overflow: hidden;
  max-width: 100%;
  position: -webkit-sticky;
  position: sticky;
  top: var(--topbar-h);
  z-index: 1100;
}

.breaking-label {
  flex-shrink: 0;
  background: rgba(0,0,0,0.25);
  color: #fff;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.5px;
  border-left: none;
  position: relative;
  box-sizing: border-box;
}

[dir="rtl"] .breaking-label::after {
  content: '';
  position: absolute;
  left: -10px;
  top: 0; bottom: 0;
  width: 0;
  height: 0;
  border-top: 40px solid rgba(0,0,0,0.25);
  border-left: 10px solid transparent;
}

[dir="ltr"] .breaking-label::after {
  left: auto;
  right: -10px;
  border-top: 40px solid rgba(0,0,0,0.25);
  border-right: 10px solid transparent;
  border-left: none;
}

.breaking-label .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulseDot 1.4s ease-in-out infinite;
}

@keyframes pulseDot {
  0%,100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(0.5); opacity: 0.4; }
}

.breaking-track-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
}

.breaking-track {
  display: inline-flex;
  align-items: center;
  gap: 56px;
  animation: marqueeRTL 40s linear infinite;
  white-space: nowrap;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
}

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

.breaking-sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  flex-shrink: 0;
}

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

[dir="ltr"] .breaking-track { animation-name: marqueeLTR; }
@keyframes marqueeLTR {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============================================================
   NAVBAR  (clean white bar, Al Jazeera-style)
   ============================================================ */
.navbar {
  background: var(--bg-nav);
  border-bottom: 3px solid var(--red);
  height: var(--nav-h);
  min-height: var(--nav-h);
  position: -webkit-sticky;
  position: sticky;
  top: calc(var(--topbar-h) + var(--ticker-h));
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  transition: box-shadow var(--t-mid), top var(--t-mid);
  isolation: isolate; /* predictable stacking for mega-menu vs page */
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.navbar.no-ticker { top: var(--topbar-h); }

.nav-inner {
  height: 100%;
  min-height: var(--nav-h);
  display: flex;
  flex-direction: row; /* direction: rtl/ltr on body handles start/end */
  align-items: center;
  gap: 10px 12px;
  flex-wrap: nowrap;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Logo */
.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 1;
  min-width: 0;
  max-width: min(240px, 46vw);
  text-decoration: none;
}

.logo-wordmark {
  font-size: 26px;
  font-weight: 900;
  color: var(--red);
  line-height: 1;
  letter-spacing: -0.5px;
}

.logo-tagline {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

.logo-img {
  display: block;
  max-height: 44px;
  height: auto;
  width: auto;
  max-width: min(200px, 42vw);
  object-fit: contain;
  -o-object-fit: contain;
  flex-shrink: 1;
  vertical-align: middle;
}

/* Nav divider */
.nav-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* Primary nav links */
.nav-menu {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

[dir="ltr"] .nav-menu {
  justify-content: flex-start;
}

.nav-item {
  display: flex;
  align-items: stretch;
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -3px; /* overlap navbar border */
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
  position: relative;
}

.nav-link:hover,
.nav-link.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

.nav-link .chevron {
  font-size: 9px;
  transition: transform var(--t-fast);
  margin-top: 1px;
}

.nav-item:hover .nav-link .chevron,
.nav-item:focus-within .nav-link .chevron {
  transform: rotate(180deg);
}

/* ── Mega Menu ────────────────────────────────────────────── */
.mega-menu {
  position: absolute;
  top: calc(100% + 3px);
  right: 0;
  min-width: min(560px, calc(100vw - 48px));
  max-width: calc(100vw - 32px);
  max-height: min(420px, 70vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--red);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity var(--t-mid) var(--ease), transform var(--t-mid) var(--ease), visibility var(--t-mid);
  /* Above navbar chrome, below mobile drawer (2000) */
  z-index: 1205;
}

[dir="ltr"] .mega-menu { right: auto; left: 0; }

.nav-item:hover .mega-menu,
.nav-item:focus-within .mega-menu,
.nav-item.is-mega-open .mega-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 1200px) {
  .mega-menu {
    grid-template-columns: repeat(3, 1fr);
    min-width: min(480px, calc(100vw - 48px));
  }
}

.mega-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  transition: background var(--t-fast), color var(--t-fast);
}

.mega-item:hover { background: var(--red-soft); color: var(--red); }

.mega-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Search */
.nav-search-wrap {
  position: relative;
  flex-shrink: 0;
}

.nav-search-input {
  width: min(180px, 22vw);
  max-width: 100%;
  height: 34px;
  padding: 0 12px 0 36px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-full);
  background: var(--bg);
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all var(--t-mid);
  box-sizing: border-box;
}

[dir="rtl"] .nav-search-input { padding: 0 36px 0 12px; }

.nav-search-input:focus {
  width: min(220px, 28vw);
  max-width: min(220px, calc(100vw - 320px));
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-glow);
}

.nav-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

[dir="rtl"] .nav-search-icon { left: auto; right: 11px; }

/* Hamburger */
.hamburger {
  display: none;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5.5px;
  border-radius: var(--r-sm);
  margin-inline-start: auto;
  -webkit-tap-highlight-color: transparent;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-main);
  border-radius: 1px;
  transition: transform var(--t-mid), opacity var(--t-mid);
}

.hamburger.active span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* Mobile drawer */
.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  visibility: hidden;
}

.mobile-drawer.open { visibility: visible; }

.mobile-drawer-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  opacity: 0;
  transition: opacity var(--t-slow);
}

.mobile-drawer.open .mobile-drawer-bg { opacity: 1; }

.mobile-drawer-panel {
  position: absolute;
  top: 0; bottom: 0;
  right: 0;
  width: min(320px, 85vw);
  max-width: 100%;
  background: var(--bg-card);
  transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}

[dir="ltr"] .mobile-drawer-panel { right: auto; left: 0; transform: translateX(-100%); }
.mobile-drawer.open .mobile-drawer-panel { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 2px solid var(--red);
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
  flex-shrink: 0;
}

.drawer-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  color: var(--text-muted);
  font-size: 14px;
  transition: all var(--t-fast);
}

.drawer-close:hover { background: var(--red); color: #fff; }

.drawer-brand-title {
  font-size: clamp(16px, 4vw, 18px);
  font-weight: 900;
  color: var(--red);
  line-height: 1.2;
  overflow-wrap: anywhere;
  max-width: calc(100% - 48px);
}

.drawer-search {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-search-form {
  display: flex;
  gap: 8px;
}

.drawer-search-input {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--border-mid);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.drawer-search-input:focus { border-color: var(--red); }

.drawer-nav { flex: 1; padding: 12px 0; }

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  transition: all var(--t-fast);
}

.drawer-nav-item:hover {
  background: var(--red-soft);
  color: var(--red);
}

.drawer-nav-item i {
  width: 20px;
  text-align: center;
  font-size: 14px;
}

.drawer-langs {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-lang-btn {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border-mid);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  transition: all var(--t-fast);
}

.drawer-lang-btn.active,
.drawer-lang-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* Drawer theme (paired with .topbar-theme hidden on very narrow screens) */
.drawer-footer-util {
  display: none;
  margin-top: auto;
  padding: 4px 20px 20px;
  flex-shrink: 0;
}

.drawer-theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border-mid);
  background: var(--bg-section);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.drawer-theme-toggle:hover {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.drawer-theme-toggle-text {
  flex: 1;
  text-align: center;
}

/* ============================================================
   EDITORIAL HERO — Al Jazeera/BBC style
   ============================================================ */
.editorial-hero {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 24px 0;
}

/* Top feature: large + side stack */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }

/* Main feature — all slides absolutely stacked (Chrome/Safari: no per-slide position toggle) */
.hero-main {
  position: relative;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  min-height: clamp(220px, 34vw, 440px);
  max-height: min(62vh, 580px);
}

@supports not (aspect-ratio: 1) {
  .hero-main { min-height: 320px; }
}

@media (max-width: 768px) {
  .hero-main {
    aspect-ratio: 4 / 3;
    min-height: clamp(200px, 52vw, 300px);
    max-height: min(56vh, 440px);
  }
}

.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.65s ease, visibility 0.65s;
  z-index: 0;
  pointer-events: none;
}

.hero-slide.active {
  opacity: 1;
  visibility: visible;
  z-index: 1;
  pointer-events: auto;
}

.hero-main-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -o-object-fit: cover;
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: transform 8s ease;
}

.hero-slide.active .hero-main-img { transform: scale(1.04); }
.hero-slide:not(.active) .hero-main-img { transform: scale(1); }

.hero-main-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.90) 0%,
    rgba(0,0,0,0.50) 40%,
    rgba(0,0,0,0.10) 70%,
    transparent 100%
  );
  pointer-events: none;
}

.hero-main-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 2;
  padding: clamp(16px, 4vw, 32px) clamp(14px, 3vw, 28px);
  padding-bottom: max(clamp(16px, 4vw, 28px), env(safe-area-inset-bottom, 0px));
  color: #fff;
  text-align: start;
  pointer-events: none;
}

.hero-main-content a,
.hero-main-content .hero-cat-pill {
  pointer-events: auto;
}

.hero-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red);
  color: #fff;
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.hero-headline {
  font-size: clamp(17px, 2.4vw + 0.6rem, 32px);
  font-weight: 900;
  line-height: 1.22;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.hero-headline a { color: #fff; }
.hero-headline a:hover { color: rgba(255,255,255,0.85); }

.hero-summary {
  font-size: 14px;
  opacity: 0.82;
  line-height: 1.55;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-byline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
  opacity: 0.75;
}

.hero-byline span { display: flex; align-items: center; gap: 4px; }

/* Hero slider controls — above stacked slides */
.hero-dots {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 20;
  pointer-events: auto;
}

.hero-dot {
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.hero-dot::before {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transition: width var(--t-fast), border-radius var(--t-fast), background var(--t-fast);
}

.hero-dot.active::before {
  width: 22px;
  border-radius: 3.5px;
  background: #fff;
}

.hero-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: rgba(0,0,0,0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 20;
  transition: background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}

.hero-arrow:hover { background: var(--red); border-color: var(--red); }
.hero-arrow-prev { right: 14px; }
.hero-arrow-next { left: 14px; }
[dir="ltr"] .hero-arrow-prev { right: auto; left: 14px; }
[dir="ltr"] .hero-arrow-next { left: auto; right: 14px; }

/* Hero sidebar stack */
.hero-stack {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.hero-stack-item {
  display: flex;
  flex-direction: column;
  flex: 1;
  border-bottom: 1px solid var(--border);
  padding: 14px;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast);
  position: relative;
}

.hero-stack-item:last-child { border-bottom: none; }
.hero-stack-item:hover { background: var(--bg-section); }

.hero-stack-item::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--red);
  opacity: 0;
  transition: opacity var(--t-fast);
}

[dir="ltr"] .hero-stack-item::before { right: auto; left: 0; }
.hero-stack-item:hover::before { opacity: 1; }

.hero-stack-img {
  aspect-ratio: 16/9;
  border-radius: 0;
  overflow: hidden;
  background: var(--bg-skeleton);
  flex-shrink: 0;
}

.hero-stack-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}

.hero-stack-item:hover .hero-stack-img img { transform: scale(1.04); }

.hero-stack-cat {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--red);
}

.hero-stack-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-stack-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: auto;
  display: flex;
  gap: 10px;
}

/* ============================================================
   NEWS CARDS — BBC/Al Jazeera editorial style
   ============================================================ */

/* Section label with left border + title */
.sec-label {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 18px;
}

.sec-label-bar {
  width: 4px;
  height: 100%;
  min-height: 24px;
  background: var(--red);
  flex-shrink: 0;
}

.sec-label-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  font-size: 17px;
  font-weight: 900;
  color: var(--text-main);
  padding: 0 12px;
  letter-spacing: -0.2px;
  border-bottom: none;
}

.sec-label-cat-icon {
  font-size: 14px;
  margin-left: 4px;
}

[dir="ltr"] .sec-label-cat-icon { margin-left: 0; margin-right: 4px; }

.sec-label-more {
  margin-right: auto;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--t-fast);
  white-space: nowrap;
}

[dir="ltr"] .sec-label-more { margin-right: 0; margin-left: auto; }
.sec-label-more:hover { gap: 7px; }

.sec-label-icon {
  flex-shrink: 0;
  font-size: 15px;
  color: var(--red);
  opacity: 0.95;
}

.sec-divider {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 14px;
}

/* ─ Card container ─ */
.card {
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  transition: box-shadow var(--t-mid), transform var(--t-mid);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

@media (hover: none) {
  .card:hover { transform: none; }
  .card:active { opacity: 0.96; }
}

/* Card image */
.card-img {
  position: relative;
  overflow: hidden;
  background: var(--bg-skeleton);
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow) var(--ease);
  display: block;
}

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

/* Card body */
.card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Category pill on card */
.card-cat {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--red);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* On-image category badge */
.card-cat-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--red);
  color: #fff;
  padding: 4px 12px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

[dir="ltr"] .card-cat-badge { right: auto; left: 0; }

.card-breaking-badge {
  position: absolute;
  top: 0;
  left: 0;
  background: #000;
  color: var(--red);
  padding: 4px 12px;
  font-size: 10.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
}

[dir="ltr"] .card-breaking-badge { left: auto; right: 0; }

/* Title */
.card-title {
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.38;
  color: var(--text-main);
  margin-bottom: 8px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: -0.1px;
}

.card-title a { color: inherit; }
.card-title a:hover { color: var(--red); }

.card-title--lg {
  font-size: 19px;
  -webkit-line-clamp: 4;
}

.card-title--sm {
  font-size: 13.5px;
  font-weight: 700;
  -webkit-line-clamp: 2;
}

/* Summary */
.card-summary {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

/* Meta row */
.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.card-meta span { display: flex; align-items: center; gap: 4px; }

/* Views count — logical margin for RTL/LTR */
.card-views {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ── Aspect ratios ─────────────────────────────────────────── */
.ar-16-9, .ar-16-10, .ar-4-3, .ar-3-2, .ar-1-1 {
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.ar-16-9  { aspect-ratio: 16/9; }
.ar-16-10 { aspect-ratio: 16/10; }
.ar-4-3   { aspect-ratio: 4/3; }
.ar-3-2   { aspect-ratio: 3/2; }
.ar-1-1   { aspect-ratio: 1/1; }

/* Ensure images fill aspect-ratio containers perfectly */
.ar-16-9 img, .ar-16-10 img, .ar-4-3 img, .ar-3-2 img, .ar-1-1 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -o-object-fit: cover;
  display: block;
}

/* Default aspect-ratio for card images in grid — prevents uneven heights */
.news-grid-4 .card-img,
.news-grid-3 .card-img,
.news-grid-2 .card-img,
.featured-layout .card-img {
  aspect-ratio: 16/9;
  overflow: hidden;
}
.news-grid-4 .card-img img,
.news-grid-3 .card-img img,
.news-grid-2 .card-img img,
.featured-layout .card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Grid layouts ─────────────────────────────────────────── */
.news-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.news-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.news-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

/* Equal-height cards in editorial grids (Chrome/Safari grid stretch) */
.news-grid-2 > .card,
.news-grid-3 > .card,
.news-grid-4 > .card,
.featured-layout > .card,
.featured-layout-right > .card {
  height: 100%;
  min-height: 0;
  min-width: 0;
}

/* List view: no horizontal scroll from horizontal cards */
#newsList {
  overflow-x: hidden;
  max-width: 100%;
}

#newsList .card-h {
  max-width: 100%;
}

/* BBC-style featured layout: big left + 2 right stack */
.featured-layout {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.featured-layout-right {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
}

.featured-layout-right .card {
  flex: 1;
}

/* ── Horizontal card (for lists) ──────────────────────────── */
.card-h {
  flex-direction: row;
  gap: 0;
}

.card-h .card-img {
  width: 120px;
  min-width: 120px;
}

.card-h .card-img.ar-1-1 { width: 110px; min-width: 110px; }

.card-h .card-body { padding: 12px 14px; }
.card-h .card-title { font-size: 13.5px; }

/* ── Numbered list card ───────────────────────────────────── */
.card-ranked {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast);
}

.card-ranked:last-child { border-bottom: none; }
.card-ranked:hover .card-ranked-num { color: var(--red); }
.card-ranked:hover .card-ranked-title { color: var(--red); }

.card-ranked-num {
  font-size: 28px;
  font-weight: 900;
  color: var(--border-mid);
  line-height: 1;
  min-width: 32px;
  text-align: center;
  transition: color var(--t-fast);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.card-ranked-thumb {
  width: 80px;
  height: 60px;
  flex-shrink: 0;
  border-radius: var(--r-xs);
  overflow: hidden;
  background: var(--bg-skeleton);
}

.card-ranked-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}

.card-ranked:hover .card-ranked-thumb img { transform: scale(1.06); }

.card-ranked-content { flex: 1; min-width: 0; }

.card-ranked-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  transition: color var(--t-fast);
  color: var(--text-main);
}

.card-ranked-meta { font-size: 11px; color: var(--text-faint); display: flex; gap: 8px; }

/* ── Opinion / Author card ────────────────────────────────── */
.card-opinion {
  border-top: 3px solid var(--red);
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--red);
}

.card-opinion-author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-opinion-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-skeleton);
  border: 2px solid var(--border);
}

.card-opinion-name { font-size: 13.5px; font-weight: 800; }
.card-opinion-role { font-size: 11.5px; color: var(--text-muted); }

.card-opinion-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-opinion-title:hover { color: var(--red); }

/* ── Video card overlay ───────────────────────────────────── */
.card-video-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.2);
  transition: background var(--t-fast);
}

.card:hover .card-video-play { background: rgba(0,0,0,0.35); }

.play-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--red);
  transition: transform var(--t-fast);
}

.card:hover .play-btn { transform: scale(1.1); }

/* ============================================================
   CATEGORY TABS — horizontal scrollable
   ============================================================ */
.cat-tabs-wrap {
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.cat-tabs-wrap::-webkit-scrollbar { display: none; }

.cat-tabs {
  display: inline-flex;
  gap: 0;
  white-space: nowrap;
}

.cat-tab {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color var(--t-fast), border-color var(--t-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.cat-tab i { font-size: 12px; }
.cat-tab:hover { color: var(--text-main); }
.cat-tab.active { color: var(--red); border-bottom-color: var(--red); }

/* ============================================================
   PAGE LAYOUT — two-column content + sidebar grid
   Used on: category, article, events, weather, exchange pages
   ============================================================ */
.page-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 36px;
  align-items: start;
}

/* Prevent grid blowout + overflow (article media / long words) */
.page-layout > * {
  min-width: 0;
}

@media (max-width: 1024px) {
  .page-layout { grid-template-columns: 1fr 280px; gap: 24px; }
}
@media (max-width: 768px) {
  .page-layout { grid-template-columns: 1fr; }
}

/* ============================================================
   SECTION HEADER — titled block header with red accent
   Used above each news/events/weather section
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
  position: relative;
}

/* Red accent line under the title */
.section-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 0;
  width: 56px;
  height: 2px;
  background: var(--red);
  border-radius: 2px;
}
[dir="ltr"] .section-header::after { right: auto; left: 0; }

.section-title {
  font-size: clamp(17px, 2.2vw, 21px);
  font-weight: 900;
  color: var(--text-main);
  line-height: 1.2;
}

.section-view-all {
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: opacity var(--t-fast);
}
.section-view-all:hover { opacity: .75; }

/* ============================================================
   SIDEBAR WIDGET — card wrapper for sidebar blocks
   ============================================================ */
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.sidebar-widget .widget-header {
  padding: 12px 16px 10px;
  margin: 0;
  font-size: 13px;
  font-weight: 900;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-section);
  border-bottom: 2px solid var(--red);
}

.sidebar-widget .widget-body {
  padding: 14px 16px;
}

/* ============================================================
   SIDEBAR — editorial style
   ============================================================ */
.sidebar { display: flex; flex-direction: column; gap: 28px; }

.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.widget-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 0 12px 0;
  margin: 0 16px;
  border-bottom: 2px solid var(--red);
  margin-bottom: 0;
}

.widget-header-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 900;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 0 10px;
}

.widget-header-icon {
  flex-shrink: 0;
  font-size: 15px;
  opacity: 0.95;
}

.widget-header-icon--fire { color: var(--red); }
.widget-header-icon--weather { color: #1a6ea8; }
.widget-header-icon--exchange { color: var(--green); }
.widget-header-icon--events { color: var(--red); }

/* Upcoming events rows (homepage sidebar widget) */
.widget-event-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}

.widget-event-row:last-child { border-bottom: none; }

.widget-event-date {
  background: var(--red);
  color: #fff;
  padding: 8px 10px;
  text-align: center;
  min-width: 48px;
  flex-shrink: 0;
  border-radius: var(--r-sm);
}

.widget-event-day {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.widget-event-mon {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.9;
  margin-top: 2px;
}

.widget-event-body { min-width: 0; flex: 1; }

.widget-event-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text-main);
}

.widget-event-loc {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 4px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}

.widget-body { padding: 12px 0; }

/* Sidebar news list */
.widget-news-list { display: flex; flex-direction: column; }

.widget-news-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast);
}

.widget-news-item:last-child { border-bottom: none; }
.widget-news-item:hover { background: var(--bg-section); }

.widget-news-thumb {
  width: 76px;
  height: 58px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bg-skeleton);
}

.widget-news-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow);
}

.widget-news-item:hover .widget-news-thumb img { transform: scale(1.06); }

.widget-news-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.widget-news-item:hover .widget-news-title { color: var(--red); }
.widget-news-time { font-size: 11px; color: var(--text-faint); }

/* ============================================================
   WEATHER WIDGET
   ============================================================ */
.weather-widget-card {
  background: linear-gradient(135deg, #0a3d6b 0%, #1a6ea8 100%);
  color: #fff;
  padding: 20px 16px;
  text-align: center;
}

.weather-w-city { font-size: 14px; font-weight: 700; opacity: 0.85; }
.weather-w-temp { font-size: 44px; font-weight: 900; line-height: 1; }
.weather-w-icon {
  margin: 6px 0;
  color: rgba(255, 255, 255, 0.94);
  line-height: 1;
}
.weather-w-icon i,
.weather-w-icon .weather-w-icon-glyph {
  font-size: 2.5rem;
  vertical-align: middle;
  color: inherit;
}
.weather-w-desc { font-size: 13px; opacity: 0.8; margin-bottom: 14px; }

.weather-w-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.weather-w-detail {
  background: rgba(255,255,255,0.12);
  border-radius: var(--r-sm);
  padding: 8px;
  font-size: 12px;
}

.weather-w-detail-val { font-size: 16px; font-weight: 800; }
.weather-w-detail-lbl { opacity: 0.7; font-size: 11px; }

/* ============================================================
   EXCHANGE MINI WIDGET
   ============================================================ */
.exchange-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.exchange-row:last-child { border-bottom: none; }
.exchange-flag { font-size: 20px; }
.currency-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-alt);
  color: var(--red);
  font-size: 14px;
  flex-shrink: 0;
}
.exchange-code { font-weight: 800; font-size: 13px; }
.exchange-name { font-size: 11px; color: var(--text-muted); }
.exchange-rate { font-size: 15px; font-weight: 900; }
.exchange-chg-up   { font-size: 11px; color: #1a7a4a; font-weight: 700; }
.exchange-chg-down { font-size: 11px; color: var(--red); font-weight: 700; }

/* ============================================================
   PAGE LAYOUT (article, category, search)
   ============================================================ */
.page-with-sidebar {
  display: grid;
  grid-template-columns: 1fr min(300px, 32vw);
  gap: 28px;
  align-items: start;
}

.page-with-sidebar > * {
  min-width: 0;
}

.main-content {
  min-width: 0;
}

@media (max-width: 1024px) {
  .page-with-sidebar {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  /* Main column first in DOM = stays on top; sidebar full-width below */
  .page-with-sidebar .sidebar {
    max-width: 100%;
  }
}

/* ============================================================
   ARTICLE PAGE
   ============================================================ */
.article-hero-figure {
  margin: 0 0 28px;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--bg-skeleton);
}

.article-hero-img {
  width: 100%;
  max-height: min(500px, 55vh);
  object-fit: cover;
  -o-object-fit: cover;
  display: block;
}

@media (max-width: 640px) {
  .article-hero-img { max-height: min(320px, 42vh); }
}

.article-wrapper { max-width: 780px; }

.article-cat-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red);
  color: #fff;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 14px;
}

.article-title {
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 900;
  line-height: 1.25;
  color: var(--text-main);
  margin-bottom: 12px;
  letter-spacing: -0.3px;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  text-wrap: balance;
}

.article-subtitle {
  font-size: 17px;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.6;
  margin-bottom: 18px;
  padding-right: 14px;
  border-right: 3px solid var(--red);
}

[dir="ltr"] .article-subtitle { border-right: none; border-left: 3px solid var(--red); padding-right: 0; padding-left: 14px; }

.article-meta-bar,
.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.article-author {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-main);
}

.article-author-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-skeleton);
  border: 2px solid var(--border);
}

.article-meta-item { display: flex; align-items: center; gap: 5px; }

.article-body {
  font-size: 17px;
  line-height: 1.9;
  color: var(--text-main);
}

.article-body h2 { font-size: 22px; font-weight: 800; margin: 30px 0 12px; letter-spacing: -0.2px; }
.article-body h3 { font-size: 18px; font-weight: 700; margin: 24px 0 10px; }
.article-body p  { margin-bottom: 20px; }

.article-body a {
  color: var(--red);
  text-decoration: underline;
  text-decoration-color: rgba(193,11,27,0.35);
  text-underline-offset: 3px;
}

.article-body a:hover { text-decoration-color: var(--red); }

.article-body blockquote {
  border-right: 4px solid var(--red);
  padding: 14px 20px;
  margin: 24px 0;
  background: var(--bg-section);
  font-style: italic;
  color: var(--text-muted);
  font-size: 16px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

[dir="ltr"] .article-body blockquote { border-right: none; border-left: 4px solid var(--red); border-radius: var(--r-sm) 0 0 var(--r-sm); }

/* Rich text: never overflow viewport; admin-uploaded images scale down */
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  margin: 22px auto;
  display: block;
  box-sizing: border-box;
}

/* Embedded video / maps from editor (YouTube, etc.) */
.article-body iframe,
.article-body embed,
.article-body object {
  display: block;
  max-width: 100%;
  width: 100%;
  min-height: 200px;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: var(--r-sm);
  margin: 22px auto;
  background: var(--gray-800);
}

.article-body video {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
  margin: 22px auto;
  display: block;
}

@supports not (aspect-ratio: 1) {
  .article-body iframe {
    height: min(56.25vw, 400px);
  }
}

/* Long strings / URLs in prose */
.article-body p,
.article-body li {
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

.article-body ul, .article-body ol { padding-right: 24px; margin-bottom: 20px; }
[dir="ltr"] .article-body ul, [dir="ltr"] .article-body ol { padding-right: 0; padding-left: 24px; }
.article-body li { margin-bottom: 8px; }

/* Share bar */
.share-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  border-top: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 28px 0;
  flex-wrap: wrap;
}

.share-label { font-size: 13px; font-weight: 800; margin-left: 4px; }
[dir="ltr"] .share-label { margin-left: 0; margin-right: 4px; }

.share-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--t-fast), transform var(--t-fast);
}

.share-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.share-btn.fb   { background: #1877f2; }
.share-btn.tw   { background: #000; }
.share-btn.wa   { background: #25d366; }
.share-btn.tg   { background: #0088cc; }
.share-btn.copy { background: var(--gray-600); }

@media (max-width: 640px) {
  .share-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .share-label {
    margin-inline-start: 0;
    margin-bottom: 4px;
  }
  .share-btn {
    justify-content: center;
    min-height: 44px;
    width: 100%;
  }
}

/* Gallery */
.article-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 24px 0;
}

.gallery-item {
  margin: 0; /* figure reset */
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
  background: var(--bg-skeleton);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.gallery-item img,
.gallery-item .gallery-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -o-object-fit: cover;
  transition: transform var(--t-slow);
}

.gallery-item:hover img,
.gallery-item:hover .gallery-thumb-img,
.gallery-item--stacked:hover .gallery-item-img-wrap img,
.gallery-item--stacked:hover .gallery-item-img-wrap .gallery-thumb-img {
  transform: scale(1.07);
}

.gallery-caption {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
  padding: 8px 4px 0;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Gallery cell: image + optional caption without breaking aspect grid */
.gallery-item--stacked {
  aspect-ratio: auto;
  display: flex;
  flex-direction: column;
}

.gallery-item--stacked .gallery-item-img-wrap {
  aspect-ratio: 4/3;
  overflow: hidden;
  flex-shrink: 0;
}

.gallery-item--stacked .gallery-item-img-wrap img,
.gallery-item--stacked .gallery-item-img-wrap .gallery-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -o-object-fit: cover;
}

@media (max-width: 640px) {
  .article-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
  .article-gallery .gallery-item:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 400px) {
  .article-gallery {
    grid-template-columns: 1fr;
  }
  .article-gallery .gallery-item:first-child {
    grid-column: unset;
  }
}

/* Article: video gallery + section headings (replaces inline styles) */
.article-media-block { margin: 24px 0; }

.article-section-title {
  font-size: clamp(16px, 4vw, 18px);
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-main);
}

.article-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  background: #000;
}

.article-video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -o-object-fit: contain;
}

/* Article meta: push actions to visual start in RTL / end in LTR */
.article-meta-actions {
  display: flex;
  gap: 6px;
  margin-inline-start: auto;
}

/* ============================================================
   WEATHER PAGE
   ============================================================ */
.weather-main-card {
  background: linear-gradient(135deg, #0a2240 0%, #1a6ea8 100%);
  color: #fff;
  padding: 40px;
  position: relative;
  overflow: hidden;
  border-radius: 0;
}

.weather-main-card::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.weather-city-name  { font-size: 30px; font-weight: 900; }
.weather-date-str   { font-size: 13px; opacity: 0.7; margin-bottom: 20px; }
.weather-big-temp   { font-size: 72px; font-weight: 900; line-height: 1; }
.weather-condition  { font-size: 18px; opacity: 0.88; margin-top: 6px; }

.weather-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 28px;
}

@media (max-width: 640px) { .weather-stats { grid-template-columns: repeat(2,1fr); } }

.weather-stat {
  background: rgba(255,255,255,0.1);
  padding: 14px;
  text-align: center;
  border-radius: var(--r-sm);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.weather-stat-icon  { font-size: 22px; margin-bottom: 6px; }
.weather-stat-val   { font-size: 20px; font-weight: 900; }
.weather-stat-label { font-size: 11px; opacity: 0.7; margin-top: 3px; }

.city-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-mid);
}

.city-card:hover { border-color: var(--red); box-shadow: var(--shadow-sm); }
.city-card-name  { font-size: 15px; font-weight: 800; margin-bottom: 4px; }
.city-card-icon  { font-size: 36px; margin: 8px 0; }
.city-card-temp  { font-size: 32px; font-weight: 900; color: var(--red); }
.city-card-desc  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   EXCHANGE PAGE
   ============================================================ */
.rate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--t-mid);
}

.rate-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-mid); }
.rate-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-alt);
  font-size: 22px;
  color: var(--red);
  flex-shrink: 0;
}
.rate-info { flex: 1; }
.rate-currency-name { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.rate-value { font-size: 22px; font-weight: 900; }
.rate-change { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 3px; }
.rate-change.up   { color: var(--green); }
.rate-change.down { color: var(--red); }

/* ============================================================
   EVENTS / CALENDAR
   ============================================================ */
.calendar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--red);
  color: #fff;
}

.calendar-month-title { font-size: 16px; font-weight: 800; }

.cal-nav-btn {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
}

.cal-nav-btn:hover { background: rgba(255,255,255,0.25); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  background: rgba(193,11,27,0.06);
}

.cal-weekday {
  padding: 8px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  gap: 1px;
  background: var(--border);
}

.cal-day {
  background: var(--bg-card);
  min-height: 64px;
  padding: 6px;
  position: relative;
  cursor: pointer;
  transition: background var(--t-fast);
}

.cal-day:hover { background: var(--bg-section); }
.cal-day.other { opacity: 0.3; }
.cal-day.today { background: rgba(193,11,27,0.04); }

.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.cal-day.today .cal-day-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.cal-event-indicator {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 3px;
}

.event-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right: 4px solid var(--red);
  transition: all var(--t-mid);
  margin-bottom: 1px;
}

[dir="ltr"] .event-card { border-right: none; border-left: 4px solid var(--red); }
.event-card:hover { box-shadow: var(--shadow-sm); }

.event-date-box {
  text-align: center;
  background: var(--red);
  color: #fff;
  padding: 10px 14px;
  min-width: 58px;
  flex-shrink: 0;
}

.event-day   { font-size: 24px; font-weight: 900; line-height: 1; }
.event-month { font-size: 11px; font-weight: 700; opacity: 0.85; letter-spacing: 0.5px; text-transform: uppercase; }

.event-info-title { font-size: 15px; font-weight: 800; margin-bottom: 5px; }
.event-info-desc  { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; line-height: 1.55; }
.event-info-meta  { display: flex; gap: 14px; font-size: 12px; color: var(--text-faint); }

/* Event modal */
.event-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-mid), visibility var(--t-mid);
}

.event-modal-backdrop.show { opacity: 1; visibility: visible; }

.event-modal-box {
  background: var(--bg-card);
  max-width: 460px;
  width: 100%;
  border-top: 4px solid var(--red);
  box-shadow: var(--shadow-xl);
  transform: translateY(16px) scale(0.97);
  transition: transform var(--t-mid) var(--ease-out);
  text-align: center;
  padding: 36px;
}

.event-modal-backdrop.show .event-modal-box { transform: translateY(0) scale(1); }

.event-modal-icon  { font-size: 52px; margin-bottom: 14px; color: var(--red); line-height: 1; }
.event-modal-title { font-size: 20px; font-weight: 900; margin-bottom: 10px; }
.event-modal-desc  { color: var(--text-muted); line-height: 1.7; margin-bottom: 22px; font-size: 14px; }

/* ============================================================
   CALENDAR PAGE — full-page calendar (.ev-calendar)
   These supplement the sidebar widget classes (.calendar-widget)
   ============================================================ */

/* Full-page calendar wrapper */
.ev-calendar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Header bar (month name + nav arrows) */
.ev-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--red);
  color: #fff;
}

/* Calendar grid — expose underlying widget styles on full-page cal too */
.ev-calendar .cal-weekdays {
  background: rgba(193,11,27,0.06);
}

.ev-calendar .cal-days {
  border-top: 1px solid var(--border);
}

/* Clickable day cells with events */
.cal-day.has-event {
  background: var(--bg-section);
}
.cal-day.has-event:hover {
  background: rgba(193,11,27,0.07);
}
.cal-day.has-event .cal-day-num {
  color: var(--primary);
  font-weight: 900;
}

/* Event color dot inside day cell */
.cal-event-dot, .cal-event-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 3px;
  flex-shrink: 0;
}

/* "other" month cells (alias for the .other class used in widget) */
.cal-day.other-month {
  opacity: 0.3;
  pointer-events: none;
}

/* ── Event card for upcoming list ─────────────────────────── */
.ev-calendar ~ div .event-card,
.event-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right: 4px solid var(--red);
  transition: all var(--t-mid);
  margin-bottom: 1px;
}
[dir="ltr"] .event-card { border-right: none; border-left: 4px solid var(--red); }
.event-card:hover { box-shadow: var(--shadow-sm); transform: translateX(-2px); }
[dir="ltr"] .event-card:hover { transform: translateX(2px); }

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.search-hero {
  background: var(--navy);
  color: #fff;
  padding: 50px 0;
  text-align: center;
}

.search-hero-title { font-size: clamp(24px, 4vw, 38px); font-weight: 900; margin-bottom: 22px; }

.search-form-wrap {
  max-width: 580px;
  margin: 0 auto;
  display: flex;
  background: #fff;
  border: none;
  box-shadow: var(--shadow-lg);
}

.search-input-lg {
  flex: 1;
  padding: 16px 20px;
  border: none;
  font-size: 16px;
  color: #111;
  outline: none;
  font-family: var(--font-ar);
}

.search-submit-btn {
  padding: 16px 22px;
  background: var(--red);
  color: #fff;
  font-size: 18px;
  border: none;
  cursor: pointer;
  transition: background var(--t-fast);
  display: flex;
  align-items: center;
}

.search-submit-btn:hover { background: var(--red-dark); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--t-fast);
  letter-spacing: 0.1px;
}

.btn-red     { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: 0 4px 12px var(--red-glow); }

.btn-outline  { background: transparent; border-color: var(--border-mid); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--red); color: var(--red); }

.btn-navy     { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-mid); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 12px 26px; font-size: 15px; }

/* Load more */
.load-more-wrap { padding: 28px 0; text-align: center; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 32px 0;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0 10px;
  transition: all var(--t-fast);
}

.page-btn:hover   { border-color: var(--red); color: var(--red); }
.page-btn.active  { background: var(--red); color: #fff; border-color: var(--red); }
.page-btn.disabled{ opacity: 0.4; pointer-events: none; }

/* ============================================================
   SKELETON LOADER
   ============================================================ */
.skeleton {
  background: var(--bg-skeleton);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.5) 50%, transparent 100%);
  animation: shimmer 1.6s infinite;
}

[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0,0,0,0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px))
           max(16px, env(safe-area-inset-right, 0px))
           max(16px, env(safe-area-inset-bottom, 0px))
           max(16px, env(safe-area-inset-left, 0px));
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-mid), visibility var(--t-mid);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-overflow-scrolling: touch;
}

.lightbox.open { opacity: 1; visibility: visible; }

.lightbox-img {
  max-width: min(92vw, 1200px);
  max-height: 88dvh;
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  -o-object-fit: contain;
  box-shadow: var(--shadow-xl);
}

[dir="rtl"] .lightbox-close {
  right: auto;
  left: max(18px, env(safe-area-inset-left, 0px));
}

.lightbox-close {
  position: absolute;
  top: max(18px, env(safe-area-inset-top, 0px));
  right: max(18px, env(safe-area-inset-right, 0px));
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
}

.lightbox-close:hover { background: var(--red); }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: max(22px, env(safe-area-inset-bottom, 0px));
  right: max(22px, env(safe-area-inset-right, 0px));
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

[dir="ltr"] .toast-container {
  right: auto;
  left: max(22px, env(safe-area-inset-left, 0px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-right: 3px solid var(--red);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 600;
  max-width: 320px;
  animation: toastIn var(--t-mid) var(--ease-out);
}

[dir="ltr"] .toast { border-right: none; border-left: 3px solid var(--red); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast.success { border-color: #1a7a4a; }
.toast.success .toast-icon { color: #1a7a4a; }
.toast.error   .toast-icon { color: var(--red); }
.toast.info    .toast-icon { color: var(--blue); }

/* ============================================================
   BACK TO TOP
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: 70px;
  right: 22px;
  width: 40px;
  height: 40px;
  background: var(--red);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-mid), visibility var(--t-mid), transform var(--t-fast);
  z-index: 800;
}

[dir="ltr"] .back-to-top { right: auto; left: 22px; }
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-2px); }

/* iOS safe area support */
@supports (bottom: env(safe-area-inset-bottom)) {
  .back-to-top {
    bottom: calc(70px + env(safe-area-inset-bottom));
    right: calc(22px + env(safe-area-inset-right));
  }
  [dir="ltr"] .back-to-top {
    right: auto;
    left: calc(22px + env(safe-area-inset-left));
  }
  .footer-bottom {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

/* ============================================================
   FOOTER — BBC/Al Jazeera editorial dark footer
   ============================================================ */
.footer {
  background: var(--bg-footer);
  margin-top: 0;
}

.footer-top-strip {
  background: var(--red);
  height: 4px;
}

.footer-main {
  padding: 48px 0 36px;
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1.6fr;
  gap: 40px;
  border-bottom: 1px solid #2a2a2a;
}

@media (max-width: 992px) { .footer-main { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .footer-main { grid-template-columns: 1fr; gap: 28px; } }

.footer-brand-text {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.footer-brand-text span { color: var(--red); }

.footer-tagline {
  font-size: 13px;
  color: #888;
  line-height: 1.7;
  margin-bottom: 20px;
}

.footer-socials {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-social-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #888;
  border: 1px solid #2a2a2a;
  transition: all var(--t-fast);
}

.footer-social-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }

.footer-col-title {
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #2a2a2a;
}

.footer-links { display: flex; flex-direction: column; gap: 8px; }

.footer-link {
  font-size: 13px;
  color: #888;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--t-fast), gap var(--t-fast);
}

.footer-link:hover { color: #fff; gap: 9px; }
.footer-link i { font-size: 10px; color: var(--red); }

/* Newsletter */
.newsletter-wrap { margin-top: 4px; }

.newsletter-desc {
  font-size: 13px;
  color: #888;
  margin-bottom: 14px;
  line-height: 1.6;
}

.newsletter-form { display: flex; flex-direction: column; gap: 8px; }

.newsletter-input {
  padding: 10px 14px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast);
}

.newsletter-input::placeholder { color: #555; }
.newsletter-input:focus { border-color: var(--red); }

.footer-bottom {
  padding: 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-copyright { font-size: 12px; color: #555; }
.footer-legal { display: flex; gap: 16px; }
.footer-legal a { font-size: 12px; color: #555; transition: color var(--t-fast); }
.footer-legal a:hover { color: #fff; }

/* ============================================================
   SECTION SPACING
   ============================================================ */
.section       { padding: 32px 0; }
.section-lg    { padding: 48px 0; }
.section-sm    { padding: 20px 0; }
.mt-0          { margin-top: 0; }
.mb-0          { margin-bottom: 0; }

/* Section background variants */
.bg-card    { background: var(--bg-card); }
.bg-section { background: var(--bg-section); }

/* ============================================================
   LAZY LOAD
   ============================================================ */
img[data-src] { opacity: 0; transition: opacity var(--t-mid); }
img.loaded    { opacity: 1; }

/* ============================================================
   RESPONSIVE BREAKPOINTS — Mobile-first with full device coverage
   ============================================================ */

/* ── 1200px: Large laptops ───────────────────────────────── */
@media (max-width: 1200px) {
  .news-grid-4 { grid-template-columns: repeat(3, 1fr); }
}

/* Navbar: tighter links + search so row fits without overlap (tablet / small laptop) */
@media (max-width: 1200px) and (min-width: 993px) {
  .nav-link {
    padding: 0 10px;
    font-size: 13.5px;
  }

  .nav-search-input {
    width: min(150px, 16vw);
  }

  .nav-search-input:focus {
    width: min(190px, 22vw);
    max-width: min(220px, calc(100vw - 360px));
  }
}

/* ── 1024px: Small laptops / large tablets ───────────────── */
@media (max-width: 1024px) {
  .hero-grid { grid-template-columns: 1fr; }
  /* .hero-main height from aspect-ratio + clamp — avoid fighting Safari */
  .hero-stack { flex-direction: row; }
  .hero-stack-item { flex: 1; min-width: 0; border-bottom: none; border-left: 1px solid var(--border); }
  [dir="rtl"] .hero-stack-item { border-left: none; border-right: 1px solid var(--border); }
  .hero-stack-item:first-child { border: none; }
}

/* ── 992px: Tablet landscape / nav collapse ──────────────── */
@media (max-width: 992px) {
  :root {
    /* 44px touch targets + lang strip padding — bar must not clip controls */
    --topbar-h: 52px;
  }

  .nav-menu        { display: none; }
  .nav-search-wrap { display: none; }
  .hamburger       { display: flex; }

  /* Mobile header: logo + menu only — no orphan divider */
  .nav-divider     { display: none; }

  .nav-logo {
    max-width: min(200px, calc(100% - 56px));
  }

  .nav-logo .logo-wordmark {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .nav-logo > div {
    min-width: 0;
    overflow: hidden;
    max-width: 100%;
  }

  /* Primary article grids: single column + card separation (no half-width squeeze) */
  .news-grid-3 {
    grid-template-columns: 1fr;
    gap: 14px;
    background: transparent;
    border: none;
    padding: 0;
  }

  .news-grid-3 > .card {
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    height: auto;
    min-height: 0;
  }

  .news-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .featured-layout { grid-template-columns: 1fr; }
  /* Stack category “side” stories — row of 4 tiny cards was unreadable on tablets/phones */
  .featured-layout-right {
    flex-direction: column;
    gap: 12px;
    background: transparent;
  }
  .featured-layout-right .card {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  .page-layout  { grid-template-columns: 1fr; }
}

/* ── 768px: Tablet portrait ──────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --gutter: 20px;
    --nav-h:  56px;
  }

  .topbar-social { display: none; }

  /* Narrow top bar: compact date (weekday omitted in PHP); full date in title="" */
  .topbar-date {
    font-size: 11px;
    line-height: 1.3;
    gap: 5px;
  }

  .topbar-date-full {
    display: none !important;
  }

  .topbar-date-short {
    display: inline !important;
  }

  /* Hero — rely on aspect-ratio; extra padding for dots/arrows */
  .hero-main-content { padding: 20px 16px 52px; }
  .hero-headline    { font-size: clamp(17px, 4.5vw, 26px); }
  .hero-summary     { display: none; }
  .hero-stack       { flex-direction: column; }
  .hero-stack-item  { border-left: none !important; border-right: none !important; border-bottom: 1px solid var(--border) !important; }

  /* Breaking bar */
  .breaking-label   { padding: 0 12px; font-size: 12px; }

  /* Section */
  .section      { padding: 24px 0; }
  .section-lg   { padding: 36px 0; }

  /* Footer */
  .footer-main  { grid-template-columns: 1fr 1fr; gap: 28px; }

  /* Article */
  .article-title  { font-size: 24px; }
  .article-header { padding: 24px 0 20px; }

  /* Page layout */
  .page-layout { grid-template-columns: 1fr; }
  .page-layout > .sidebar { order: -1; }

  /* Category tab bar — horizontal scroll */
  .cat-tabs-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }

  /* Events calendar */
  .ev-calendar  { font-size: 13px; }

  /* Exchange/weather page */
  .page-with-sidebar { grid-template-columns: 1fr; }
}

/* ── 640px: Large phones ─────────────────────────────────── */
@media (max-width: 640px) {
  :root { --gutter: 16px; }

  .news-grid-2,
  .news-grid-3,
  .news-grid-4  { grid-template-columns: 1fr; }

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

  .section      { padding: 20px 0; }

  .card-h .card-img { width: 110px; min-width: 110px; }

  .footer-socials  { justify-content: center; }
  .footer-main     { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom   { flex-direction: column; text-align: center; gap: 8px; }
  .footer-legal    { justify-content: center; }

  .article-title   { font-size: 21px; }
  .article-body    { font-size: 15px; }
  .article-share   { gap: 8px; }

  .topbar-date {
    font-size: 10.5px;
    line-height: 1.25;
    gap: 4px;
  }

  /* Mega menu — shown inline on mobile (handled by drawer, hidden here) */
  .mega-menu       { display: none !important; }

  /* Trending / ranked cards */
  .card-ranked-num { font-size: 22px; }

  /* Section header */
  .sec-label-text  { font-size: 15px; }
}

/* ── 480px: Small phones ─────────────────────────────────── */
@media (max-width: 480px) {
  :root {
    --gutter: 12px;
    /* Aligned with ≤992 topbar */
    --topbar-h: 52px;
    --ticker-h: 36px;
  }

  .logo-wordmark   { font-size: 22px; }
  .logo-img        { height: 36px; }

  /* Breaking bar */
  .breaking-label  { padding: 0 10px; font-size: 11px; }
  .breaking-label .pulse-dot { display: none; }

  /* Cards */
  .card-body       { padding: 10px 12px; }
  .card-title      { font-size: 14.5px; }
  .card-h .card-img { width: 90px; min-width: 90px; }

  /* Article */
  .article-title   { font-size: 19px; }
  .article-author  { flex-wrap: wrap; gap: 8px; }

  /* Events */
  .ev-calendar .cal-day { font-size: 12px; min-height: 40px; padding: 4px; }

  /* Footer */
  .newsletter-form { flex-direction: column; }
}

/* ── 400px: Very small phones ────────────────────────────── */
@media (max-width: 400px) {
  .card-h .card-img { width: 80px; min-width: 80px; }
  .hero-headline    { font-size: 16px; }
  .topbar-inner     { gap: 4px 6px; }
  .topbar-langs     { gap: 0; padding: 0; }
  .topbar-lang-btn  {
    padding: 2px 5px;
    font-size: 9px;
    min-height: 26px;
    min-width: 0;
  }
}

/* Very narrow: drop theme from utility strip — use drawer footer toggle */
@media (max-width: 420px) {
  .topbar-theme {
    display: none !important;
  }

  .drawer-footer-util {
    display: block;
  }

  .breaking-label {
    max-width: min(46%, 160px);
    padding: 0 10px;
  }
}

/* ============================================================
   MOBILE PREMIUM — homepage feed, widgets, RTL (≤768 / ≤640)
   Single column, no squeezed side stacks, calmer spacing
   ============================================================ */

.news-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.news-toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.news-toolbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.news-list-view {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Full-width trending strip: one column earlier than generic grids */
@media (max-width: 768px) {
  .trending-home-grid.news-grid-4 {
    grid-template-columns: 1fr;
    gap: 14px;
    background: transparent;
    border: none;
    padding: 0;
  }

  .trending-home-grid.news-grid-4 > .card {
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
  }

  .trending-home-grid .card-title--sm {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.42;
    -webkit-line-clamp: 3;
  }

  .trending-home-grid .card-meta {
    font-size: 11px;
    color: var(--text-faint);
    padding-top: 8px;
    gap: 10px 14px;
  }
}

@media (max-width: 640px) {
  /* Section rhythm */
  .section {
    padding: 22px 0;
  }

  .sec-label {
    margin-bottom: 16px;
    align-items: flex-start;
  }

  .sec-label-bar {
    margin-top: 3px;
  }

  .sec-label-text {
    font-size: clamp(15px, 4.2vw, 17px);
    padding: 0 10px;
    line-height: 1.35;
  }

  .sec-divider {
    margin: 0 8px;
    align-self: center;
  }

  .sec-label-more {
    font-size: 12px;
    padding: 2px 0;
  }

  /* Latest grid: card stack with breathing room (not 1px tile grid) */
  .news-grid-3,
  .news-grid-4,
  .news-grid-2 {
    gap: 14px;
    background: transparent;
    border: none;
    padding: 0;
  }

  .news-grid-3 > .card,
  .news-grid-4 > .card,
  .news-grid-2 > .card {
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    height: auto;
    min-height: 0;
  }

  .news-grid-3 .card-body,
  .news-grid-4 .card-body,
  .news-grid-2 .card-body {
    padding: 14px 16px 16px;
  }

  .news-grid-3 .card-title,
  .news-grid-4 .card-title,
  .news-grid-2 .card-title {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.42;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
  }

  .news-grid-3 .card-summary,
  .news-grid-4 .card-summary,
  .news-grid-2 .card-summary {
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 8px;
  }

  .news-grid-3 .card-meta,
  .news-grid-4 .card-meta,
  .news-grid-2 .card-meta {
    font-size: 11px;
    padding-top: 8px;
    gap: 8px 12px;
    border-top-color: var(--border);
    opacity: 0.92;
  }

  .news-grid-3 .card-views,
  .news-grid-4 .card-views,
  .news-grid-2 .card-views {
    font-size: 10.5px;
  }

  /* Category featured: separated cards */
  .featured-layout {
    gap: 14px;
    background: transparent;
    border: none;
  }

  .featured-layout > .card {
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
  }

  .featured-layout-right {
    gap: 14px;
  }

  .featured-layout-right .card {
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
  }

  .featured-layout .card-title--lg {
    font-size: clamp(17px, 4.8vw, 20px);
    line-height: 1.38;
  }

  /* Horizontal list: thumb + text, proportional width */
  .card-h--latest-list {
    flex-direction: row;
    align-items: stretch;
    margin-bottom: 12px;
    border-radius: var(--r-md);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    min-height: 0;
  }

  .card-h--latest-list .card-img--list-thumb {
    width: 34%;
    max-width: 132px;
    min-width: 0;
    flex-shrink: 0;
    align-self: stretch;
    aspect-ratio: 4/3;
    height: auto;
  }

  .card-h--latest-list .card-img--list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    -o-object-fit: cover;
  }

  .card-h--latest-list .card-body {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    justify-content: center;
  }

  .card-h--latest-list .card-title--sm {
    font-size: 14.5px;
    font-weight: 800;
    line-height: 1.4;
    -webkit-line-clamp: 3;
  }

  .card-h--latest-list .card-meta {
    padding-top: 6px;
    margin-top: 4px;
    border-top: none;
    font-size: 10.5px;
    gap: 8px;
  }

  /* Category stack items: stable thumb + title */
  .card-h--category-stack .card-img--category-thumb {
    width: 100px;
    min-width: 100px;
    max-width: 32%;
    aspect-ratio: 1;
    height: auto;
  }

  .card-h--category-stack .card-body {
    padding: 12px 14px;
    min-width: 0;
  }

  .card-h--category-stack .card-title--sm {
    font-size: 14px;
    line-height: 1.42;
    -webkit-line-clamp: 3;
  }

  /* Sidebar widgets full-bleed calm */
  .sidebar {
    gap: 22px;
  }

  .widget {
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
  }

  .widget-header {
    margin: 0 14px;
    padding-bottom: 10px;
  }

  .widget-body {
    padding: 4px 0 8px;
  }

  /* Ranked / trending sidebar list */
  .card-ranked {
    padding: 14px 12px;
    gap: 12px;
    align-items: center;
    border-radius: var(--r-sm);
    margin: 0 4px;
  }

  .card-ranked-num {
    font-size: 20px;
    font-weight: 900;
    min-width: 26px;
    width: auto;
    line-height: 1;
    color: var(--text-faint);
  }

  .card-ranked-thumb {
    width: 88px;
    height: auto;
    aspect-ratio: 4/3;
    border-radius: var(--r-sm);
  }

  .card-ranked-title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.45;
    -webkit-line-clamp: 3;
    margin-bottom: 6px;
  }

  .card-ranked-meta {
    font-size: 10.5px;
    gap: 10px;
    flex-wrap: wrap;
    opacity: 0.9;
  }

  .card-ranked-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  /* Weather mini widget */
  .weather-widget-card {
    padding: 18px 16px 20px;
    text-align: center;
  }

  .weather-w-city {
    font-size: 13px;
    line-height: 1.4;
    padding: 0 4px;
  }

  .weather-w-temp {
    font-size: 36px;
    letter-spacing: -0.02em;
  }

  .weather-w-icon {
    font-size: 32px;
    margin: 8px 0;
  }

  .weather-w-icon .fas,
  .weather-w-icon i,
  .weather-w-icon .weather-w-icon-glyph {
    font-size: inherit !important;
  }

  .weather-w-desc {
    font-size: 12.5px;
    line-height: 1.45;
    margin-bottom: 12px;
    padding: 0 6px;
  }

  .weather-w-details {
    gap: 10px;
  }

  .weather-w-detail {
    padding: 10px 8px;
    min-width: 0;
  }

  .weather-w-detail-val {
    font-size: 15px;
  }

  .weather-w-detail-lbl {
    font-size: 10.5px;
    margin-top: 2px;
  }

  .load-more-wrap {
    padding: 22px 0 8px;
  }

  .news-toolbar {
    margin-bottom: 14px;
  }
}

@media (max-width: 400px) {
  .card-h--latest-list .card-img--list-thumb {
    max-width: 118px;
    width: 32%;
  }

  .card-h--category-stack .card-img--category-thumb {
    width: 88px;
    min-width: 88px;
  }

  .card-ranked {
    padding-inline: 8px;
    gap: 10px;
  }

  .card-ranked-num {
    font-size: 18px;
    min-width: 22px;
  }

  .card-ranked-thumb {
    width: 80px;
  }
}

/* ── Extra wide screens ──────────────────────────────────── */
@media (min-width: 1600px) {
  :root { --container: 1440px; }
  .news-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .topbar, .breaking-bar, .navbar, .sidebar,
  .share-bar, .footer, .back-to-top,
  .toast-container, .lightbox { display: none !important; }
  .article-body { font-size: 12pt; line-height: 1.8; }
}

/* ============================================================
   ANIMATIONS & MICRO-INTERACTIONS
   ============================================================ */

/* ── Core keyframes ───────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(-24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes borderGrow {
  from { width: 0; }
  to   { width: 100%; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes heartBeat {
  0%   { transform: scale(1); }
  14%  { transform: scale(1.25); }
  28%  { transform: scale(1); }
  42%  { transform: scale(1.2); }
  70%  { transform: scale(1); }
}

@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(0.6); }
}

@keyframes navbarShrink {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Scroll-reveal system ─────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
  will-change: opacity, transform;
}

.reveal.from-left  { transform: translateX(32px); }
.reveal.from-right { transform: translateX(-32px); }
.reveal.scale-in   { transform: scale(0.94); }

.reveal.visible {
  opacity: 1;
  transform: none;
}

/* Stagger siblings */
.reveal-group .reveal:nth-child(1) { transition-delay: 0ms; }
.reveal-group .reveal:nth-child(2) { transition-delay: 80ms; }
.reveal-group .reveal:nth-child(3) { transition-delay: 160ms; }
.reveal-group .reveal:nth-child(4) { transition-delay: 240ms; }
.reveal-group .reveal:nth-child(5) { transition-delay: 320ms; }
.reveal-group .reveal:nth-child(6) { transition-delay: 400ms; }
.reveal-group .reveal:nth-child(7) { transition-delay: 480ms; }
.reveal-group .reveal:nth-child(8) { transition-delay: 560ms; }
.reveal-group .reveal:nth-child(9) { transition-delay: 640ms; }

/* ── Reading progress bar ─────────────────────────────────── */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 9000;
  pointer-events: none;
}

.reading-progress-bar {
  height: 100%;
  background: var(--red);
  width: 0%;
  transition: width 0.1s linear;
  transform-origin: left;
}

/* ── Navbar — compact on scroll ───────────────────────────── */
.navbar.scrolled {
  box-shadow: 0 3px 18px rgba(0,0,0,0.12);
}

.navbar.compact {
  height: 50px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.14);
}

.navbar.compact .logo-wordmark { font-size: 22px; }
.navbar.compact .logo-img      { height: 36px; }
.navbar { transition: height 0.3s var(--ease), box-shadow 0.3s var(--ease); }
.logo-wordmark { transition: font-size 0.3s var(--ease); }
.logo-img      { transition: height 0.3s var(--ease); }

/* ── Ripple effect ────────────────────────────────────────── */
.btn { position: relative; overflow: hidden; }

.ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

/* ── Enhanced card hover ──────────────────────────────────── */
.card {
  transition: box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--red);
  opacity: 0;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}

.card:hover::after { opacity: 0.25; }

/* Image overlay shimmer on card hover */
.card-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0) 40%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0) 60%);
  background-size: 200% 200%;
  opacity: 0;
  transition: opacity 0.3s;
}

.card:hover .card-img::after {
  opacity: 1;
  animation: cardShimmer 1s ease;
}

@keyframes cardShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Section label animated border ───────────────────────── */
.sec-label-bar {
  position: relative;
  overflow: hidden;
  transition: height 0.3s var(--ease);
}

.sec-label-bar::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 100%;
  background: rgba(255,255,255,0.3);
  transition: width 0.4s var(--ease);
}

.sec-label:hover .sec-label-bar::after { width: 100%; }

/* ── Nav link — animated underline ───────────────────────── */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -3px;
  right: 50%;
  left: 50%;
  height: 3px;
  background: var(--red);
  transition: right 0.25s var(--ease), left 0.25s var(--ease);
}

.nav-link:hover::after,
.nav-link.active::after {
  right: 0;
  left: 0;
}

/* ── Breaking ticker — enhanced pulse ────────────────────── */
.breaking-label .pulse-dot {
  box-shadow: 0 0 0 0 rgba(255,255,255,0.6);
  animation: pulseDot 1.4s ease-in-out infinite, pulseRing 1.4s ease-in-out infinite;
}

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

/* ── Hero stack item — slide-in border ───────────────────── */
.hero-stack-item {
  transition: background 0.2s, padding 0.2s;
}

/* ── Back to top — progress ring ─────────────────────────── */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

[dir="ltr"] .back-to-top { right: auto; left: 24px; }

.back-to-top svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.back-to-top svg circle {
  fill: none;
  stroke: rgba(255,255,255,0.35);
  stroke-width: 2.5;
}

.back-to-top svg .progress-ring {
  stroke: #fff;
  stroke-dasharray: 126;
  stroke-dashoffset: 126;
  transition: stroke-dashoffset 0.15s linear;
  stroke-linecap: round;
}

/* ── Bookmark / like button ───────────────────────────────── */
.btn-bookmark.active i { color: var(--red); animation: heartBeat 0.7s ease; }
.btn-like.active i     { color: var(--red); animation: heartBeat 0.7s ease; }

/* ── Float-up reaction emoji ──────────────────────────────── */
.float-emoji {
  position: fixed;
  font-size: 18px;
  line-height: 1;
  color: var(--red);
  pointer-events: none;
  z-index: 9999;
  animation: floatUp 0.9s ease forwards;
}
.float-emoji .fa-bookmark { color: var(--gold, #c09a2e); }
.float-emoji .fa-retweet  { color: var(--blue, #1a6ea8); }
.float-emoji .fa-comment  { color: #25d366; }
.float-emoji .fa-paper-plane { color: #0088cc; }
.float-emoji .fa-check    { color: #28a745; }
.float-emoji .fa-thumbs-up { color: #1877f2; }

/* ── Image load fade-in ───────────────────────────────────── */
img { transition: opacity 0.4s var(--ease); }
img[data-src] { opacity: 0; }
img.loaded    { opacity: 1; }

/* ── Mega-menu slide ──────────────────────────────────────── */
.mega-menu {
  transform-origin: top center;
}

/* ── Category tab indicator ───────────────────────────────── */
.cat-tab {
  position: relative;
}

.cat-tab::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 50%;
  left: 50%;
  height: 3px;
  background: var(--red);
  transition: right 0.25s var(--ease), left 0.25s var(--ease);
}

.cat-tab.active::after,
.cat-tab:hover::after {
  right: 0;
  left: 0;
}

/* ── Topbar fade-in on load ───────────────────────────────── */
.topbar  { animation: fadeInDown 0.4s var(--ease-out) both; }
.navbar  { animation: fadeInDown 0.5s 0.1s var(--ease-out) both; }
.breaking-bar { animation: fadeInDown 0.4s 0.05s var(--ease-out) both; }

/* ── Widget header red bar grow ───────────────────────────── */
.widget-header {
  position: relative;
  overflow: hidden;
}

.widget-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  height: 2px;
  background: var(--red);
  width: 0;
  transition: width 0.6s var(--ease-out);
}

.widget:hover .widget-header::after { width: 100%; }

/* ── Counter number style ─────────────────────────────────── */
.counter-value {
  display: inline-block;
  animation: countUp 0.5s var(--ease-out) both;
  font-variant-numeric: tabular-nums;
}

/* ── Smooth search expand ─────────────────────────────────── */
.nav-search-input {
  transition: width 0.3s var(--ease), border-color 0.2s, box-shadow 0.2s;
}

/* ── Card ranked num pop ──────────────────────────────────── */
.card-ranked:hover .card-ranked-num {
  animation: heartBeat 0.5s ease;
}

/* ── Footer social hover bounce ──────────────────────────── */
.footer-social-btn {
  transition: all 0.2s var(--ease);
}

.footer-social-btn:hover {
  transform: translateY(-3px) scale(1.12);
}

/* ── Toast slide-in from edge ─────────────────────────────── */
.toast {
  animation: toastSlide 0.35s var(--ease-out) both;
}

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(24px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

[dir="ltr"] .toast { animation-name: toastSlideLTR; }

@keyframes toastSlideLTR {
  from { opacity: 0; transform: translateX(-24px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ── Event modal pop ──────────────────────────────────────── */
.event-modal-box {
  transition: transform 0.4s var(--ease-out), opacity 0.4s;
}

/* ── Drawer panel slide ───────────────────────────────────── */
.mobile-drawer-panel {
  transition: transform 0.38s var(--ease-out);
}

/* ── Hero dots animated ───────────────────────────────────── */
.hero-dot {
  transition: width 0.35s var(--ease), background 0.25s;
}

/* ── Skeleton pulse improvement ───────────────────────────── */
.skeleton {
  animation: skeletonPulse 1.8s ease-in-out infinite alternate;
}

@keyframes skeletonPulse {
  from { opacity: 1; }
  to   { opacity: 0.55; }
}

.skeleton::after {
  animation: shimmer 1.8s infinite;
}

/* ── Page transition overlay ──────────────────────────────── */
.page-transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--red);
  z-index: 99999;
  transform: scaleX(0);
  transform-origin: right;
  pointer-events: none;
}

@keyframes pageOut {
  to { transform: scaleX(1); transform-origin: right; }
}

@keyframes pageIn {
  from { transform: scaleX(1); transform-origin: left; }
  to   { transform: scaleX(0); transform-origin: left; }
}

/* ── Reduce motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:    0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration:   0.01ms !important;
  }

  .reveal { opacity: 1; transform: none; }
}

/* ============================================================
   SAFARI / iOS / CROSS-BROWSER COMPATIBILITY FIXES
   ============================================================ */

/* ── iOS viewport height fix (avoids address-bar jump) ─────── */
html {
  height: -webkit-fill-available;
}
body {
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* ── iOS Safari — prevent input zoom when font-size < 16px ─── */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="url"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* ── iOS tap highlight removal ──────────────────────────────── */
a, button, [role="button"], input[type="button"], input[type="submit"] {
  -webkit-tap-highlight-color: transparent;
}

/* ── Safari flex-gap fallback (Safari < 14) ─────────────────── */
@supports not (gap: 1px) {
  .nav-inner > * + *  { margin-right: 16px; }
  .topbar-inner > * + * { margin-right: 12px; }
  .card-meta span + span { margin-right: 12px; }
}

/* ── Mobile touch targets — minimum 44×44px ─────────────────── */
@media (max-width: 992px) {
  .drawer-nav-item,
  .drawer-lang-btn,
  .hamburger {
    min-height: 44px;
    min-width: 44px;
    padding-inline: 10px;
  }

  .drawer-nav-item  { padding-top: 14px; padding-bottom: 14px; }
  .nav-link         { min-height: 44px; }
  .topbar-social a  {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }

  .topbar-theme {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 14px;
  }
}

/* Top bar language chips — compact on tablet/phone (full switcher stays in drawer) */
@media (max-width: 992px) {
  .topbar-langs {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1px;
    gap: 1px;
    border-radius: var(--r-sm);
  }

  .topbar-lang-btn {
    min-width: 0;
    min-height: 30px;
    padding: 2px 7px;
    padding-inline: 6px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.2;
    border-radius: calc(var(--r-sm) - 2px);
  }
}

@media (max-width: 640px) {
  .topbar-lang-btn {
    min-height: 28px;
    padding: 2px 6px;
    font-size: 9.5px;
    letter-spacing: 0.15px;
  }

  .topbar-langs {
    gap: 0;
    padding: 1px;
  }
}

/* ── Sticky headers inside mobile drawer ────────────────────── */
.drawer-header {
  position: -webkit-sticky;
  position: sticky;
}

/* ── -webkit-overflow-scrolling for iOS momentum scroll ──────── */
.mobile-drawer-panel,
.mega-menu,
.drawer-nav {
  -webkit-overflow-scrolling: touch;
}

/* ── Safari: flex children min-width: 0 prevents overflow ────── */
.nav-menu > .nav-item,
.hero-stack > .hero-stack-item,
.card-h > .card-body,
.footer-main > * {
  min-width: 0;
}

/* ── Prevent overflow on breaking-bar ticker ─────────────────── */
.breaking-track-wrap { overflow: hidden; max-width: 100%; }

/* ── Safari: object-fit on img inside flex ───────────────────── */
.card-img { display: block; overflow: hidden; }
.hero-main-img { -o-object-fit: cover; object-fit: cover; }
.logo-img { -o-object-fit: contain; object-fit: contain; }

/* ── Safari: smooth scroll fallback ─────────────────────────── */
@media not all and (prefers-reduced-motion: reduce) {
  html { scroll-behavior: smooth; }
}

/* ── Safari: position:fixed modal backdrop fix ───────────────── */
.mobile-drawer,
.event-modal-backdrop,
#todayEventPopup {
  /* Use translate3d to force GPU compositing layer on Safari */
  -webkit-transform: translate3d(0, 0, 0);
}

/* ── Fix scrollbar gutter for Chrome/Safari consistency ──────── */
html { scrollbar-gutter: stable; }

/* ── Image loading performance hints ─────────────────────────── */
.card-img img,
.hero-main-img,
.hero-stack-img img {
  will-change: transform;
}

/* ── Consistent selection colour ────────────────────────────── */
::selection         { background: var(--red); color: #fff; }
::-moz-selection    { background: var(--red); color: #fff; }

/* ============================================================
   ADDITIONAL LAYOUT POLISH
   ============================================================ */

/* ── Horizontal card fix on very small screens ───────────────── */
@media (max-width: 360px) {
  .card-h               { flex-direction: column; }
  .card-h .card-img     { width: 100%; min-width: 0; aspect-ratio: 16/9; }
}

/* ── Popup modal responsive ──────────────────────────────────── */
.event-modal-box {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Breaking bar responsive ─────────────────────────────────── */
@media (max-width: 480px) {
  .breaking-bar { height: 34px; }
  :root { --ticker-h: 34px; }
  .navbar { top: calc(var(--topbar-h) + 34px); }
  .navbar.no-ticker { top: var(--topbar-h); }
}

/* ── Logo responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .logo-wordmark { font-size: 21px; }
  .logo-tagline  { display: none; }
  .logo-img      { height: 34px; }
}

/* ── Footer responsive improvement ──────────────────────────── */
@media (max-width: 992px) {
  .footer-main { grid-template-columns: 1fr 1fr; gap: 28px; }
}
@media (max-width: 640px) {
  .footer-main { grid-template-columns: 1fr; }
}

/* ── Calendar responsive ─────────────────────────────────────── */
@media (max-width: 640px) {
  .ev-calendar .cal-grid { font-size: 13px; }
  .ev-calendar .cal-day  { min-height: 42px; padding: 4px 2px; }
  .ev-cal-header         { flex-wrap: wrap; gap: 8px; justify-content: center; }
}

/* ── Weather + exchange responsive ───────────────────────────── */
@media (max-width: 480px) {
  .weather-stats { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .weather-hero  { padding: 28px 16px; min-height: 160px; }
  .weather-temp  { font-size: 52px; }
}

/* ── Dark mode: ensure images don't get too dark ─────────────── */
[data-theme="dark"] img { filter: brightness(0.92) contrast(1.02); }
[data-theme="dark"] .hero-main-img,
[data-theme="dark"] .hero-stack-img img { filter: none; }
