*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  overflow-x: hidden;
}

img,
video,
iframe {
  max-width: 100%;
}

.container {
  width: min(100% - 24px, 950px);
  margin-inline: auto;
  padding-inline: 0;
}

:root {
  --bg: #f0f2f5;

  --card: #ffffff;

  --text: #333;

  --accent: #3498db;

  --header-bg: #ffffff;

  --border: #eeeeee;

  --logo-accent: #312a2a;
}

[data-theme="dark"] {
  --bg: #1a222d;

  --card: #212d3b;

  --text: #ffffff;

  --header-bg: #151b24;

  --logo-accent: #ffffff;

  --border: #2d3d4f;
}

body {
  margin: 0;

  background: var(--body-bg, var(--bg));
  color: var(--header-color, var(--text));

  font-family: "NeoSansArabic", sans-serif;

  transition: 0.3s;
}

/* HEADER */

.main-header {
  background-color: var(--header-bg);

  height: 70px;

  display: flex;

  align-items: center;

  justify-content: center;

  position: sticky;

  top: 0;

  z-index: 1000;

  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);

  padding: 0 20px;
}

.logo {
  font-size: clamp(20px, 5vw, 30px);

  font-weight: 1000;

  text-transform: uppercase;

  text-decoration: none;

  cursor: pointer;
}

.logo .accent-text {
  color: var(--logo-accent);
}

.logo .blue {
  color: var(--accent);
}

.header-controls {
  position: absolute;
  display: flex;
  align-items: center;
}

.control-btn {
  background: var(--card);

  border: 1px solid var(--border);

  color: var(--text);

  cursor: pointer;

  padding: 5px;

  border-radius: 8px;

  font-size: 13px;

  font-weight: bold;

  display: flex;

  align-items: center;

  justify-content: center;

  width: 40px;

  height: 40px;

  transition: 0.2s;
}

.control-btn:hover {
  background: var(--accent);

  color: white;
}

/* ARTICLE */

.article-wrapper {
  max-width: 1000px;

  margin: 30px auto;

  padding: 0 15px;
}

.article-container {
  background: var(--card);

  border-radius: 18px;

  overflow: hidden;

  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body > .article-container {
  width: min(100% - 24px, 1100px);
  margin-inline: auto;
}

.article-image {
  width: 100%;

  height: 500px;
  aspect-ratio: 16 / 9;

  object-fit: cover;
  display: block;
  background: color-mix(in srgb, var(--card) 84%, var(--bg));
}

.article-content {
  padding: 35px;
}

.article-title {
  font-size: 42px;

  line-height: 1.5;

  margin-bottom: 20px;
}

.article-meta {
  opacity: 0.84;

  font-size: 14px;

  margin-bottom: 35px;
}

.article-text {
  line-height: 2.2;

  font-size: 20px;
}

/* ADS */

.ad-box {
  width: 100%;

  background: rgba(0, 0, 0, 0.03);

  border: 1px dashed #bbb;

  border-radius: 14px;

  display: flex;

  align-items: center;

  justify-content: center;

  color: #888;

  overflow: hidden;
}

.ad-top {
  height: 120px;

  margin: 25px 0;
}

.ad-middle {
  height: 280px;

  margin: 40px 0;
}

.ad-bottom {
  height: 120px;

  margin-top: 40px;
}

/* BACK BUTTON */

.back-btn {
  display: inline-flex;

  align-items: center;

  gap: 8px;

  text-decoration: none;

  background: var(--accent);

  color: white;

  padding: 12px 22px;

  border-radius: 10px;

  margin-bottom: 30px;

  font-weight: bold;
}

.back-btn:hover {
  opacity: 0.9;
}

#relatedArticles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.article-load-more,
.load-more-btn {
  margin: 22px auto 0;
  display: block;
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 22px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}

.article-load-more:hover,
.load-more-btn:hover {
  opacity: 0.9;
}

.article-suggestion-card,
#relatedArticles > a {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0 !important;
  min-width: 0;
  min-height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: inherit;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  margin-bottom: 0 !important;
}

.article-suggestion-card:hover,
#relatedArticles > a:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
}

.article-suggestion-card img,
#relatedArticles > a > img {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 0 !important;
  background: rgba(0, 0, 0, 0.05);
}

.article-suggestion-body,
#relatedArticles > a > div {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  min-height: 110px;
}

.article-suggestion-title,
#relatedArticles > a > div > div:first-child {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-suggestion-meta {
  margin-top: auto;
  color: #77808c;
  font-size: 12px;
}

#relatedArticles > a > div > div:last-child {
  margin-top: auto;
  color: #77808c;
  font-size: 12px;
}

@media (max-width: 768px) {
  .article-image {
    height: 280px;
  }

  .article-title {
    font-size: 30px;
  }

  .article-text {
    font-size: 18px;
  }

  .article-content {
    padding: 22px;
  }

  #relatedArticles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 520px) {
  .article-suggestions,
  #relatedArticles {
    grid-template-columns: 1fr;
  }
}

/* Cross-browser article image wrapper */
.article-picture {
  display: block;
  width: 100%;
}

.article-picture .article-image {
  display: block;
  width: 100%;
}

/* تنسيق الأخبار المرتبطة */
.article-wrapper {
  max-width: 1100px !important;
}
.article-wrapper > .article-container,
.related-articles-container {
  width: min(100%, 1100px) !important;
  margin-inline: auto !important;
}
.related-articles-container {
  margin-top: 30px !important;
  padding: 25px !important;
}
#relatedArticles > .related-ad-card {
  min-width: 0;
  min-height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  padding: 0 !important;
}
#relatedArticles > .related-ad-card iframe,
#relatedArticles > .related-ad-card img,
#relatedArticles > .related-ad-card ins {
  width: 100% !important;
  height: 100% !important;
  min-height: 220px !important;
  display: block !important;
  object-fit: cover;
}
@media (max-width: 768px) {
  .article-wrapper {
    width: min(100% - 16px, 1100px);
  }
  .related-articles-container {
    width: min(100% - 16px, 1100px) !important;
    padding: 16px !important;
  }
}

/* موضع الإعلان الأوسط */
.article-content .ad-middle,
.article-content .ad-middle[data-ad-loaded="1"] {
  width: min(300px, 100%) !important;
  min-height: 250px !important;
  height: auto !important;
  margin: 34px auto !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  line-height: 0 !important;
}

.article-content .ad-middle iframe,
.article-content .ad-middle img,
.article-content .ad-middle ins {
  width: 300px !important;
  height: 250px !important;
  max-width: 100% !important;
  display: block !important;
}
