/*
Theme Name: MenaGamer
Theme URI: https://menagamer.net
Author: MenaGamer
Description: Dark-first RTL gaming & tech news magazine theme for MenaGamer.net — Stories rail, dense content grids, zero bloat.
Version: 0.8.0
Requires at least: 6.4
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: menagamer
*/

/* ========================================================================
   1. Fonts — Alexandria variable (self-hosted, one file per script)
   ===================================================================== */
@font-face {
  font-family: "Alexandria";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("assets/fonts/alexandria-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
}
@font-face {
  font-family: "Alexandria";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("assets/fonts/alexandria-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+2000-206F, U+2122, U+2212;
}

/* ========================================================================
   2. Design tokens
   ===================================================================== */
:root {
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #1a1f2a;
  --line: #222836;
  --text: #f1f3f8;
  --muted: #8d95a8;
  --accent: #ff5a1f;            /* ember */
  --accent-hi: #ff7a3d;
  --accent-soft: rgba(255, 90, 31, 0.13);
  --on-accent: #140a03;         /* text on ember/red — white fails AA at badge sizes */
  --breaking: #f43f5e;
  --ok: #4ade80;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
  --wrap: 1200px;
  --header-h: 64px;

  /* Theme-invariant: text/gradients over images never flip with the theme */
  --on-media: #fff;
  --overlay-strong: rgba(5, 6, 9, 0.88);
  --overlay-soft: rgba(5, 6, 9, 0.25);
  --header-veil: rgba(11, 13, 18, 0.82);
  --glow: rgba(255, 90, 31, 0.09);
  color-scheme: dark;

  --font: "Alexandria", "Segoe UI", Tahoma, system-ui, sans-serif;
  --fs-hero: clamp(1.45rem, 1rem + 2vw, 2.3rem);
  --fs-section: clamp(1.15rem, 1rem + 0.8vw, 1.5rem);
  --fs-title: clamp(1rem, 0.92rem + 0.45vw, 1.22rem);
  --fs-body: clamp(0.98rem, 0.93rem + 0.25vw, 1.06rem);
  --fs-meta: 0.78rem;
}

[data-theme="light"] {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eaecf2;
  --line: #d9dde6;
  --text: #171a22;
  --muted: #58627a;
  --accent: #e0480f;
  --accent-hi: #c23e0d;
  --accent-soft: rgba(224, 72, 15, 0.10);
  --header-veil: rgba(244, 245, 248, 0.85);
  --glow: rgba(224, 72, 15, 0.07);
  --ok: #15803d;
  --shadow: 0 18px 40px -20px rgba(23, 26, 34, 0.25);
  color-scheme: light;
}

/* ========================================================================
   3. Base
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 420px at 85% -12%, var(--glow), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.8;
  text-align: start;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.45; margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }

::selection { background: var(--accent); color: var(--on-accent); }

:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }

.skip-link {
  position: absolute;
  inset-inline-start: -999px;
  top: 8px;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 18px;
  border-radius: var(--radius-s);
  font-weight: 700;
}
.skip-link:focus { inset-inline-start: 8px; }

.screen-reader-text {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* ========================================================================
   4. Header
   ===================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-veil);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-block-end: 1px solid var(--line);
}

.header-bar {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: var(--header-h);
}

.site-logo {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.site-logo .logo-mark { color: var(--accent); }
.site-logo img { height: auto; width: auto; max-height: 42px; max-width: 190px; object-fit: contain; }

/* Primary nav + dropdowns */
.primary-nav { flex: 1; }
.primary-nav > ul { display: flex; gap: 4px; }
.primary-nav li { position: relative; }
.primary-nav li > a {
  display: block;
  padding: 8px 13px;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--muted);
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.primary-nav li > a:hover,
.primary-nav .current-menu-item > a,
.primary-nav .current-menu-ancestor > a { color: var(--text); background: var(--surface-2); }

.primary-nav .sub-menu {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  translate: 0 8px;
  transition: opacity 0.18s, translate 0.18s, visibility 0.18s;
}
.primary-nav li:hover > .sub-menu,
.primary-nav li:focus-within > .sub-menu { opacity: 1; visibility: visible; translate: 0 0; }
.primary-nav .sub-menu li > a { padding: 9px 12px; }
.primary-nav .sub-menu li > a:hover { color: var(--accent-hi); background: var(--surface-2); }

/* Mega panels — li goes static so the panel spans the whole nav */
.primary-nav { position: relative; }
.primary-nav .has-mega { position: static; }
.mega-panel {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 6px);
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  translate: 0 8px;
  transition: opacity 0.18s, translate 0.18s, visibility 0.18s;
}
.has-mega:hover > .mega-panel,
.has-mega:focus-within > .mega-panel { opacity: 1; visibility: visible; translate: 0 0; }

.mega-card { display: block; padding: 0; }
.mega-thumb {
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  margin-block-end: 8px;
}
.mega-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.mega-card:hover .mega-thumb img { transform: scale(1.05); }
.mega-card h4 {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.55;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}
.mega-card:hover h4 { color: var(--accent-hi); }
.mega-all {
  grid-column: 1 / -1;
  justify-self: end;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  transition: color 0.15s;
}
.mega-all:hover { color: var(--accent-hi); }

/* Search popover */
.search-pop { position: relative; }
.search-pop summary {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.search-pop summary:hover, .search-pop[open] summary { color: var(--text); background: var(--surface-2); }
.search-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 10px);
  width: min(340px, 82vw);
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
}
.search-form { display: flex; gap: 8px; }
.search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.search-form input:focus { outline: none; border-color: var(--accent); }
.search-form button {
  padding: 10px 16px;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: var(--on-accent);
  font-weight: 700;
  transition: background 0.15s;
}
.search-form button:hover { background: var(--accent-hi); }

/* Locale switcher — renders only when Polylang is active */
.lang-switch ul { display: flex; gap: 2px; }
.lang-switch a {
  display: block;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  border-radius: 8px;
}
.lang-switch a:hover { color: var(--text); background: var(--surface-2); }
.lang-switch .current-lang a { color: var(--accent); }

/* Theme toggle — visible at all breakpoints */
.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  flex: 0 0 auto;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle .ico-sun { display: none; }
[data-theme="light"] .theme-toggle .ico-sun { display: block; }
[data-theme="light"] .theme-toggle .ico-moon { display: none; }

/* Mobile drawer */
.drawer { display: none; }
.drawer summary {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 10px;
  color: var(--text);
}
.drawer summary:hover { background: var(--surface-2); }
.drawer-panel {
  position: absolute;
  inset-inline: 0;
  top: 100%;
  padding: 10px 20px 22px;
  background: var(--surface);
  border-block-end: 2px solid var(--accent);
  box-shadow: var(--shadow);
  animation: drop 0.22s ease;
}
.drawer-panel a {
  display: block;
  padding: 13px 6px;
  font-weight: 700;
  font-size: 1.05rem;
  border-block-end: 1px solid var(--line);
}
.drawer-panel a:hover { color: var(--accent-hi); }
.drawer-panel .sub-menu a { padding-inline-start: 24px; font-weight: 500; color: var(--muted); }

@keyframes drop { from { opacity: 0; translate: 0 -10px; } }

/* ========================================================================
   4b. Breaking ticker — CSS marquee, rightward in RTL
   ===================================================================== */
.ticker {
  background: var(--surface);
  border-block-end: 1px solid var(--line);
}
.ticker-inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 9px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ticker-label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 13px;
  background: var(--breaking);
  color: var(--on-accent);
  font-size: 0.74rem;
  font-weight: 800;
  border-radius: 99px;
  white-space: nowrap;
}
.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.3s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }

.ticker-viewport {
  flex: 1;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}
.ticker-track {
  display: flex;
  width: max-content;
  animation: ticker-rtl 45s linear infinite;
}
[dir="ltr"] .ticker-track { animation-name: ticker-ltr; }
.ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker-rtl { to { transform: translateX(50%); } }
@keyframes ticker-ltr { to { transform: translateX(-50%); } }

.ticker-group { display: flex; }
.ticker-track a {
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  transition: color 0.15s;
}
.ticker-track a:hover { color: var(--accent-hi); }
.ticker-track a::after {
  content: "◆";
  font-size: 0.45rem;
  color: var(--breaking);
  opacity: 0.6;
  margin-inline: 22px;
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
  .ticker-viewport { overflow-x: auto; }
}

/* ========================================================================
   5. Stories rail
   ===================================================================== */
.stories { position: relative; padding-block: 22px 8px; }

.stories-rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-block: 4px;
}
.stories-rail::-webkit-scrollbar { display: none; }

.story-card {
  position: relative;
  flex: 0 0 148px;
  aspect-ratio: 9 / 16;
  scroll-snap-align: start;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--surface);
  transition: border-color 0.2s, transform 0.2s;
  animation: rise 0.5s backwards;
}
.story-card:hover { border-color: var(--accent); transform: translateY(-3px); }

/* Unread ring — Instagram cue for posts < 24h old */
.story-card.is-new {
  border-color: transparent;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    conic-gradient(from 210deg, var(--accent), var(--breaking), var(--accent-hi), var(--accent)) border-box;
}

.story-card > a {
  position: absolute;
  inset: 2px;
  border-radius: calc(var(--radius) - 4px);
  overflow: hidden;
  display: block;
}
.story-card img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.story-card:hover img { transform: scale(1.06); }
.story-card > a::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--overlay-strong) 0%, var(--overlay-soft) 45%, transparent 62%);
}

.story-badge {
  position: absolute;
  z-index: 2;
  top: 9px;
  inset-inline-start: 9px;
  padding: 2px 9px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.66rem;
  font-weight: 800;
  border-radius: 99px;
}
.story-title {
  position: absolute;
  z-index: 2;
  bottom: 0;
  inset-inline: 0;
  padding: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.55;
  color: var(--on-media);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Story viewer dialog */
.story-view {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(420px, 92vw);
  width: 100%;
  overflow: visible;
}
.story-view::backdrop { background: var(--overlay-strong); backdrop-filter: blur(6px); }
.story-view figure {
  position: relative;
  margin: 0;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.story-view img { width: 100%; height: 100%; object-fit: cover; }
.sv-body {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  padding: 22px;
  background: linear-gradient(to top, var(--overlay-strong), transparent);
  border-radius: 0 0 var(--radius) var(--radius);
  display: grid;
  gap: 10px;
  justify-items: start;
}
.sv-badge[hidden] { display: none; }
.sv-title { color: var(--on-media); font-size: 1.15rem; font-weight: 800; line-height: 1.5; }
.sv-close, .sv-nav {
  position: absolute;
  z-index: 2;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
}
.sv-close:hover, .sv-nav:hover { border-color: var(--accent); }
.sv-close { top: -14px; inset-inline-end: -14px; }
.sv-prev { top: 50%; translate: 0 -50%; inset-inline-start: -52px; }
.sv-next { top: 50%; translate: 0 -50%; inset-inline-end: -52px; }
@media (max-width: 560px) {
  .sv-prev, .sv-next { display: none; } /* rail swipe covers adjacency on touch */
  .sv-close { inset-inline-end: 4px; top: 4px; }
}

/* Rail arrows — desktop pointer devices only */
.rail-btn {
  display: none;
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  z-index: 3;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: background 0.15s, border-color 0.15s;
}
.rail-btn:hover { background: var(--surface-2); border-color: var(--accent); }
.rail-btn.prev { inset-inline-start: -8px; }
.rail-btn.next { inset-inline-end: -8px; }
@media (hover: hover) and (min-width: 900px) { .rail-btn { display: grid; place-items: center; } }

/* ========================================================================
   6. Section heads
   ===================================================================== */
.home-section, .related-posts { padding-block: 26px 8px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-block-end: 18px;
}
.section-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-section);
  font-weight: 800;
}
.section-head h2::before {
  content: "";
  width: 13px; height: 24px;
  background: var(--accent);
  transform: skewX(-16deg);
  border-radius: 3px;
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.section-more {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s;
}
.section-more:hover { color: var(--accent-hi); }

/* ========================================================================
   7. Cards
   ===================================================================== */
/* Hero card (large, overlay) */
.c-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  aspect-ratio: 16 / 9;   /* height source when stacked — children are absolute */
  min-height: 100%;       /* stretch to side column on desktop */
  animation: rise 0.5s backwards;
}
.c-hero img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s;
}
.c-hero:hover img { transform: scale(1.04); }
.c-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--overlay-strong) 0%, var(--overlay-soft) 55%, transparent 75%);
}
.c-hero-body {
  position: absolute;
  z-index: 2;
  bottom: 0;
  inset-inline: 0;
  padding: 22px;
  color: var(--on-media);
}
.c-hero-body h2, .c-hero-body h1 { font-size: var(--fs-hero); font-weight: 800; }
.c-hero-body h2 a::before, .c-card h3 a::before, .c-item h3 a::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Grid card */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}
.c-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  animation: rise 0.5s backwards;
}
.c-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.c-card-media { position: relative; aspect-ratio: 16 / 9; overflow: hidden; }
.c-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.c-card:hover .c-card-media img { transform: scale(1.05); }
.c-card-body { padding: 14px 16px 16px; }
.c-card h3 {
  font-size: var(--fs-title);
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
}
.c-card:hover h3 { color: var(--accent-hi); }

/* Compact list item */
.c-item {
  position: relative;
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-s);
  transition: background 0.15s;
  animation: rise 0.5s backwards;
}
.c-item:hover { background: var(--surface-2); }
.c-item-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-s);
  overflow: hidden;
  background: var(--surface-2);
}
.c-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.c-item h3 {
  font-size: 0.9rem;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.c-item:hover h3 { color: var(--accent-hi); }

/* Shared card bits */
.cat-badge {
  display: inline-block;
  padding: 3px 11px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 99px;
  margin-block-end: 9px;
}
a.cat-badge { position: relative; z-index: 2; transition: background 0.15s; }
a.cat-badge:hover { background: var(--accent-hi); }
.c-card .cat-badge {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  margin: 0;
}
.score-pill {
  position: absolute;
  bottom: 10px;
  inset-inline-end: 10px;
  min-width: 38px;
  padding: 4px 8px;
  text-align: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  font-weight: 900;
  border-radius: 10px;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  margin-block-start: 8px;
  font-size: var(--fs-meta);
  color: var(--muted);
}
.c-hero-body .meta-row { color: var(--on-media); opacity: 0.78; }

/* ========================================================================
   8. Homepage — hero block, most-read
   ===================================================================== */
.hero-block {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 22px;
  padding-block: 18px 8px;
}
.hero-side { display: grid; gap: 8px; align-content: start; }

.home-duo {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
  padding-block: 26px 8px;
}

/* Most-read: ghost numerals */
.most-read { counter-reset: mr; display: grid; gap: 4px; }
.most-read li { counter-increment: mr; }
.most-read a {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px 10px;
  border-radius: var(--radius-s);
  transition: background 0.15s;
}
.most-read a:hover { background: var(--surface-2); }
.most-read a::before {
  content: counter(mr, decimal-leading-zero);
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  color: var(--line); /* solid fallback; outlined when stroke is supported */
  text-align: center;
  transition: -webkit-text-stroke-color 0.15s;
}
@supports (-webkit-text-stroke: 1px #000) {
  .most-read a::before { color: transparent; -webkit-text-stroke: 1.5px var(--line); }
}
.most-read a:hover::before { -webkit-text-stroke-color: var(--accent); }
.most-read h3 { font-size: 0.95rem; font-weight: 700; }
.most-read a:hover h3 { color: var(--accent-hi); }

/* Community CTA */
.cta-panel {
  align-self: start;
  padding: 28px 26px;
  background:
    radial-gradient(400px 200px at 80% -30%, var(--accent-soft), transparent),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.cta-panel h3 { font-size: 1.25rem; font-weight: 800; margin-block-end: 8px; }
.cta-panel p { color: var(--muted); margin: 0 0 18px; font-size: 0.92rem; }
.btn-accent {
  display: inline-block;
  padding: 11px 26px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
  border-radius: 10px;
  transition: background 0.15s, transform 0.15s;
}
.btn-accent:hover { background: var(--accent-hi); transform: translateY(-2px); }

/* ========================================================================
   9. Single post
   ===================================================================== */
.entry-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-block-start: 22px;
  aspect-ratio: 21 / 10;
  min-height: 300px;
  background: var(--surface);
}
.entry-hero img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.entry-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--overlay-strong) 0%, var(--overlay-soft) 55%, transparent 100%);
}
.entry-hero-body {
  position: absolute;
  z-index: 2;
  bottom: 0;
  inset-inline: 0;
  padding: clamp(18px, 4vw, 36px);
  color: var(--on-media);
}
.entry-hero-body h1 { font-size: var(--fs-hero); font-weight: 800; max-width: 26ch; }

.entry-plain { padding-block-start: 34px; max-width: 76ch; margin-inline: auto; }
.entry-plain h1 { font-size: var(--fs-hero); font-weight: 800; }

.prose {
  max-width: 76ch;
  margin-inline: auto;
  padding-block: 30px 10px;
  font-size: 1.04rem;
  line-height: 1.95;
}
.prose > * + * { margin-block-start: 1.1em; }
/* Imported content: inline colors from source sites are void here.
   Links/code/mark keep their own component styles. */
.prose :where(p, li, span, h1, h2, h3, h4, h5, h6, strong, em, b, i, td, th, div, font) {
  color: inherit !important;
  background-color: transparent !important;
}
.prose h2, .prose h3 { font-weight: 800; margin-block-start: 1.8em; }
.prose h2 { font-size: 1.4rem; }
.prose h3 { font-size: 1.15rem; }
.prose a { color: var(--accent-hi); text-decoration: underline; text-underline-offset: 4px; }
.prose img, .prose figure { border-radius: var(--radius-s); }
.prose figcaption { font-size: 0.8rem; color: var(--muted); text-align: center; margin-block-start: 8px; }
.prose blockquote {
  margin-inline: 0;
  padding: 4px 22px;
  border-inline-start: 3px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius-s);
  color: var(--muted);
}
.prose code {
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.9em;
}
.prose pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 18px; overflow-x: auto; }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose ul { list-style: disc; }

.entry-foot {
  max-width: 76ch;
  margin-inline: auto;
  padding-block: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  border-block-start: 1px solid var(--line);
  margin-block-start: 30px;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list a {
  padding: 5px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.tag-list a:hover { color: var(--text); border-color: var(--accent); }

.share-row { display: flex; gap: 8px; }
.share-row a {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s, transform 0.15s;
}
.share-row a:hover { color: var(--accent-hi); border-color: var(--accent); transform: translateY(-2px); }

.post-navigation { max-width: 76ch; margin-inline: auto; padding-block: 10px; }
.post-navigation .nav-links { display: flex; justify-content: space-between; gap: 16px; }
.post-navigation a { color: var(--muted); font-size: 0.88rem; font-weight: 600; max-width: 34ch; }
.post-navigation a:hover { color: var(--accent-hi); }

/* ========================================================================
   10. Archives, search, pagination, 404
   ===================================================================== */
.archive-head { padding-block: 34px 6px; }
.archive-head h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.2rem);
  font-weight: 900;
}
.archive-head h1::before {
  content: "";
  width: 15px; height: 30px;
  background: var(--accent);
  transform: skewX(-16deg);
  border-radius: 3px;
}
.archive-head .archive-description { color: var(--muted); max-width: 70ch; }
.archive-grid { padding-block: 22px; }

.pagination { padding-block: 30px; }
.pagination .nav-links { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.pagination .page-numbers {
  display: grid;
  place-items: center;
  min-width: 42px; height: 42px;
  padding-inline: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 700;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.pagination .page-numbers:hover { color: var(--text); border-color: var(--accent); }
.pagination .page-numbers.current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.error-404 { text-align: center; padding-block: 70px 40px; }
.error-404 .glitch-num {
  font-size: clamp(6rem, 20vw, 11rem);
  font-weight: 900;
  line-height: 1;
  color: var(--line);
  display: block;
}
@supports (-webkit-text-stroke: 1px #000) {
  .error-404 .glitch-num { color: transparent; -webkit-text-stroke: 2.5px var(--line); }
}
.error-404 h1 { font-size: 1.4rem; margin-block: 10px 6px; }
.error-404 p { color: var(--muted); margin-block-end: 26px; }
.error-404 .search-form { max-width: 420px; margin-inline: auto; }

.no-results { padding-block: 40px; color: var(--muted); }

/* Review score box — ring fill driven by --sc (score × 10%) */
.review-box {
  max-width: 76ch;
  margin-inline: auto;
  margin-block: 30px 6px;
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 26px;
  align-items: center;
  padding: 26px;
  background:
    radial-gradient(420px 200px at 15% -40%, var(--accent-soft), transparent),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.review-score { display: grid; justify-items: center; gap: 12px; }
.score-ring {
  width: 116px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--sc, 0%), var(--line) 0);
  display: grid;
  place-items: center;
}
.score-ring span {
  width: calc(100% - 18px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 900;
}
.score-label {
  padding: 4px 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.8rem;
  font-weight: 800;
  border-radius: 99px;
}
.review-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.review-cols h3 { font-size: 0.95rem; font-weight: 800; margin-block-end: 10px; }
.review-cols li {
  display: flex;
  gap: 9px;
  padding-block: 5px;
  font-size: 0.92rem;
  line-height: 1.7;
}
.review-pros li::before { content: "+"; color: var(--ok); font-weight: 900; }
.review-cons li::before { content: "−"; color: var(--breaking); font-weight: 900; }
@media (max-width: 640px) {
  .review-box { grid-template-columns: 1fr; justify-items: center; text-align: start; }
  .review-cols { width: 100%; grid-template-columns: 1fr; }
}

/* Comments — minimal fallback; Disqus replaces this template in production */
.comments-area { max-width: 76ch; margin-inline: auto; padding-block: 26px; }
.comment-list { display: grid; gap: 14px; }
.comment-list .comment-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 16px;
  font-size: 0.95rem;
}
.comment-list .children { padding-inline-start: 26px; display: grid; gap: 14px; margin-block-start: 14px; }
.comment-list .avatar { border-radius: 50%; margin-inline-end: 10px; vertical-align: middle; }
.comment-form { display: grid; gap: 12px; }
.comment-form label { font-size: 0.85rem; color: var(--muted); }
.comment-form input:not([type="submit"]):not([type="checkbox"]),
.comment-form textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
.comment-form input:focus, .comment-form textarea:focus { outline: none; border-color: var(--accent); }
.comment-form input[type="submit"] {
  justify-self: start;
  padding: 11px 26px;
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}
.comment-form input[type="submit"]:hover { background: var(--accent-hi); }

/* ========================================================================
   10b. Ad slots — every container reserves its dimensions (CLS = 0)
   ===================================================================== */
.ad-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.ad-slot::after {
  content: "إعلان";
  position: absolute;
  top: 5px;
  inset-inline-end: 9px;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.7;
  pointer-events: none;
}

.ad-leaderboard { min-height: 100px; margin-block: 24px 4px; }

.ad-in-grid { grid-column: 1 / -1; min-height: 120px; }

.prose .ad-in-content { min-height: 280px; }

/* Sponsored story card */
.story-ad .ad-slot {
  position: absolute;
  inset: 2px;
  border-radius: calc(var(--radius) - 4px);
  border: 0;
}
.story-ad .ad-slot::after { content: "مُموّل"; top: 9px; inset-inline-start: 9px; inset-inline-end: auto; opacity: 1; }

/* Sticky sidebar (single post, desktop) */
.single-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  align-items: start;
}
.single-aside { position: sticky; top: calc(var(--header-h) + 20px); }
.ad-sidebar-sticky { min-height: 600px; }
@media (max-width: 1024px) {
  .single-layout { grid-template-columns: 1fr; }
  .single-aside { display: none; } /* mobile-anchor covers small screens */
}

/* Mobile anchor */
.anchor-wrap {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--header-veil);
  border-block-start: 1px solid var(--line);
}
.ad-mobile-anchor { min-height: 52px; flex: 0 1 320px; }
.anchor-close {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.75rem;
}
.anchor-close:hover { color: var(--text); border-color: var(--accent); }
@media (min-width: 761px) { .anchor-wrap { display: none; } }

/* ========================================================================
   11. Footer
   ===================================================================== */
.site-footer {
  margin-block-start: 60px;
  border-block-start: 1px solid var(--line);
  background: var(--surface);
}
.footer-main {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 40px;
  padding-block: 44px 30px;
}
.footer-brand p { color: var(--muted); font-size: 0.9rem; margin: 10px 0 0; max-width: 34ch; }
.footer-nav ul { display: flex; flex-wrap: wrap; gap: 6px 26px; }
.footer-nav a { color: var(--muted); font-size: 0.9rem; font-weight: 600; transition: color 0.15s; }
.footer-nav a:hover { color: var(--accent-hi); }
.footer-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding-block: 18px;
  border-block-start: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

/* ========================================================================
   12. Motion
   ===================================================================== */
@keyframes rise {
  from { opacity: 0; translate: 0 14px; }
}
/* Staggered page-load reveal */
.story-card:nth-child(1), .c-card:nth-child(1), .c-item:nth-child(1) { animation-delay: 0.03s; }
.story-card:nth-child(2), .c-card:nth-child(2), .c-item:nth-child(2) { animation-delay: 0.08s; }
.story-card:nth-child(3), .c-card:nth-child(3), .c-item:nth-child(3) { animation-delay: 0.13s; }
.story-card:nth-child(4), .c-card:nth-child(4), .c-item:nth-child(4) { animation-delay: 0.18s; }
.story-card:nth-child(5) { animation-delay: 0.23s; }
.story-card:nth-child(6) { animation-delay: 0.28s; }
.story-card:nth-child(7) { animation-delay: 0.33s; }
.story-card:nth-child(n+8) { animation-delay: 0.38s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* ========================================================================
   13. Responsive
   ===================================================================== */
@media (max-width: 1024px) {
  .hero-block { grid-template-columns: 1fr; }
  .hero-side { grid-template-columns: 1fr 1fr; }
  .home-duo { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .primary-nav, .search-pop { display: none; }
  .theme-toggle { margin-inline-start: auto; }
  .drawer { display: block; }
  .site-logo img { max-height: 34px; max-width: 150px; }
  .header-bar { gap: 12px; }
  .hero-side { grid-template-columns: 1fr; }
  .footer-main { grid-template-columns: 1fr; gap: 24px; }
  .story-card { flex-basis: 124px; }
  .entry-hero { aspect-ratio: 4 / 3; }
  .entry-foot { flex-direction: column; align-items: flex-start; }
}
