/* ==========================================================================
   tareqdesign — Editorial Long-Form Article Detail System (blog-details.php)
   100% Unified with index.php, portfolio.php, blog.php, services.php & project.php
   Warm Obsidian (#080a0d) · Warm Paper (#f3f1ec) · Studio Teal (#23b5a4)
   Supports Arabic RTL, English LTR, Dark Mode & Light Mode (tt-light-style-on)
   ========================================================================== */

:root {
  --bg: #080a0d;
  --bg-2: #0e1217;
  --ink: #f3f1ec;
  --ink-2: rgba(243, 241, 236, 0.82);
  --ink-3: rgba(243, 241, 236, 0.56);
  --line: rgba(243, 241, 236, 0.09);
  --line-strong: rgba(243, 241, 236, 0.16);

  --brand: #23b5a4;
  --brand-bright: #4fd1c2;
  --brand-deep: #158074;
  --brand-ink: #071716;
  --amber: #dfb253;

  --glass-bg: rgba(16, 20, 26, 0.64);
  --glass-bg-strong: rgba(14, 18, 24, 0.90);
  --glass-rim: linear-gradient(155deg, rgba(243, 241, 236, 0.18), rgba(243, 241, 236, 0.04) 48%, rgba(35, 181, 164, 0.12));
  --glass-shadow: 0 24px 56px -28px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --sheen-color: rgba(255, 255, 255, 0.085);

  --r-sm: 12px;
  --r-md: 20px;
  --r-lg: 26px;
  --r-xl: 34px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: 'Rethink Sans', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Instrument Serif', Georgia, serif;
  --font-ar: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;

  --maxw: 1240px;
  --gutter: clamp(18px, 4vw, 56px);
  --prose-size: 17.5px;
}

/* Light Mode Tokens */
body.tt-light-style-on.ar-page {
  --bg: #f6f5f1;
  --bg-2: #edeae2;
  --ink: #12171d;
  --ink-2: rgba(18, 23, 29, 0.82);
  --ink-3: rgba(18, 23, 29, 0.56);
  --line: rgba(18, 23, 29, 0.09);
  --line-strong: rgba(18, 23, 29, 0.18);
  --brand: #0f766e;
  --brand-bright: #0d9488;
  --brand-ink: #ffffff;
  --amber: #b47b17;
  --glass-bg: rgba(255, 255, 255, 0.84);
  --glass-bg-strong: rgba(255, 255, 255, 0.96);
  --glass-rim: linear-gradient(155deg, rgba(18, 23, 29, 0.12), rgba(18, 23, 29, 0.03) 50%, rgba(15, 118, 110, 0.16));
  --glass-shadow: 0 22px 50px -28px rgba(18, 23, 29, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --sheen-color: rgba(15, 118, 110, 0.065);
}

/* Safe Base Reset */
body.ar-page,
body.ar-page *,
body.ar-page *::before,
body.ar-page *::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  max-width: 100%;
}

body.ar-page {
  margin: 0;
  background: var(--bg) !important;
  color: var(--ink) !important;
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: clip;
  max-width: 100%;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

html[lang="ar"] body.ar-page {
  font-family: var(--font-ar);
}

:where(body.ar-page a) { color: inherit; text-decoration: none; }
:where(body.ar-page button) { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:where(body.ar-page img) { display: block; max-width: 100%; }

::selection { background: var(--brand); color: var(--brand-ink); }

/* Top Reading Progress Bar */
.ar-progress {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-bright));
  z-index: 10050;
  pointer-events: none;
  transition: width 0.08s linear;
}

/* ==========================================================================
   1. Atmospheric Field + Crystal Optical Cursor
   ========================================================================== */
.ar-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse 92% 72% at 50% -10%, #10161e 0%, var(--bg) 68%);
}

body.tt-light-style-on .ar-field {
  background: radial-gradient(ellipse 95% 75% at 50% -12%, #ffffff 0%, var(--bg) 72%);
}

.ar-bloom {
  position: absolute;
  border-radius: 50%;
  filter: blur(130px);
  opacity: 0.22;
  will-change: transform;
}

body.tt-light-style-on .ar-bloom { opacity: 0.14; }

.ar-bloom.b1 {
  width: 56vw; height: 56vw; left: -14vw; top: -18vw;
  background: radial-gradient(circle, rgba(28, 128, 118, 0.48), transparent 64%);
}
.ar-bloom.b2 {
  width: 48vw; height: 48vw; right: -14vw; top: 30vh;
  background: radial-gradient(circle, rgba(212, 168, 86, 0.24), transparent 64%);
}

.ar-grain {
  position: fixed; inset: -10%; width: 120%; height: 120%; opacity: 0.04; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body.tt-light-style-on .ar-grain { opacity: 0.022; }

/* ==========================================================================
   2. Primitives & Layout Wrappers
   ========================================================================== */
.ar-main { position: relative; z-index: 2; }
.ar-wrap { width: min(var(--maxw), calc(100% - var(--gutter) * 2)); margin-inline: auto; min-width: 0; }

.ar-glass {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
  box-shadow: var(--glass-shadow);
  isolation: isolate;
}
.ar-glass::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: var(--glass-rim);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  pointer-events: none; z-index: 2;
}

.ar-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border-radius: 999px; padding: 12px 20px; font-size: 13.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  transition: transform 0.35s var(--ease), background 0.25s ease, color 0.25s ease;
}
.ar-btn:hover { transform: translateY(-2px); }
.ar-btn-solid {
  color: var(--brand-ink) !important;
  background: linear-gradient(180deg, #32c4b3 0%, #20a797 100%);
}
body.tt-light-style-on .ar-btn-solid { color: #ffffff !important; background: linear-gradient(180deg, #12877d 0%, #0f766e 100%); }

/* ==========================================================================
   3. Section 1: Article Editorial Masthead + Cover Stage (#arHero)
   ========================================================================== */
.ar-hero {
  padding: clamp(124px, 14vw, 170px) 0 clamp(32px, 4.5vw, 50px);
}

.ar-hero-inner {
  max-width: 920px;
  margin-inline: auto;
  text-align: center;
}

.ar-crumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 22px;
}
.ar-crumb a:hover { color: var(--brand); }
.ar-crumb .ar-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }

.ar-meta-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.ar-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.ar-pill--cat {
  border-color: rgba(35, 181, 164, 0.34);
  background: rgba(35, 181, 164, 0.12);
  color: var(--brand-bright);
  font-weight: 700;
}

.ar-title {
  margin: 0 auto 28px;
  font-size: clamp(30px, 4.6vw, 60px);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.03em;
  color: var(--ink);
}

html[lang="ar"] .ar-title {
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1.28;
  letter-spacing: -0.01em;
  font-weight: 900;
}

.ar-author-deck {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px 28px;
  padding: 12px 22px;
  border-radius: 999px;
  margin-bottom: clamp(28px, 4vw, 44px);
}

.ar-author-id {
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: start;
}

.ar-monogram {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(35, 181, 164, 0.16);
  border: 1px solid rgba(35, 181, 164, 0.36);
  color: var(--brand-bright);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}

.ar-author-id strong { display: block; font-size: 14px; color: var(--ink); line-height: 1.2; }
.ar-author-id small { display: block; font-size: 11.5px; color: var(--ink-3); }

.ar-deck-stats {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.ar-deck-stats span { display: inline-flex; align-items: center; gap: 6px; }
.ar-deck-stats i { color: var(--brand); }

.ar-cover-frame {
  max-width: 1040px;
  margin-inline: auto;
  border-radius: var(--r-xl);
  padding: 12px;
  overflow: hidden;
}

.ar-cover-media {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  overflow: hidden;
  background: var(--bg-2);
}

.ar-cover-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ==========================================================================
   4. Section 2: Asymmetric Editorial Reading Stage (Sticky TOC + Prose)
   ========================================================================== */
.ar-stage {
  padding: 0 0 clamp(68px, 8vw, 112px);
}

.ar-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.38fr) minmax(0, 1.12fr);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}

/* Sticky Reading Sidebar (TOC + Font Controls + Progress) */
.ar-sidebar {
  position: sticky;
  top: 108px;
  display: grid;
  gap: 16px;
}

.ar-side-card {
  border-radius: var(--r-lg);
  padding: 22px;
  text-align: start;
}

.ar-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.ar-side-head span {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}

.ar-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.ar-toc {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.ar-toc a {
  display: block;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13.2px;
  line-height: 1.45;
  color: var(--ink-3);
  border-inline-start: 2px solid transparent;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.ar-toc a.is-sub { padding-inline-start: 20px; font-size: 12.5px; }
.ar-toc a:hover { color: var(--ink); background: rgba(255, 255, 255, 0.03); }
.ar-toc a.is-active {
  color: var(--brand-bright);
  background: rgba(35, 181, 164, 0.10);
  border-inline-start-color: var(--brand);
  font-weight: 600;
}

.ar-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ar-font-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.ar-font-btn {
  width: 34px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  transition: background 0.2s ease, color 0.2s ease;
}
.ar-font-btn:hover { background: var(--brand); color: var(--brand-ink); }

.ar-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  transition: color 0.2s ease;
}
.ar-back-link:hover { color: var(--brand-bright); }

/* Main Article Canvas */
.ar-article-card {
  border-radius: var(--r-xl);
  padding: clamp(26px, 4.5vw, 54px);
  text-align: start;
}

.ar-summary-box {
  padding: 20px 24px;
  border-radius: 18px;
  border-inline-start: 3px solid var(--brand);
  background: rgba(35, 181, 164, 0.07);
  margin-bottom: 32px;
  font-size: 17px;
  line-height: 1.78;
  color: var(--ink);
  font-weight: 500;
}

/* Serene Editorial Prose Typography */
.ar-prose {
  font-size: var(--prose-size);
  line-height: 1.92;
  color: var(--ink-2);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.ar-prose p { margin: 0 0 1.4em; color: var(--ink-2) !important; }
.ar-prose h1, .ar-prose h2, .ar-prose h3, .ar-prose h4, .ar-prose strong, .ar-prose b {
  color: var(--ink) !important;
}
.ar-prose h2 {
  font-size: clamp(22px, 2.3vw, 30px);
  font-weight: 800;
  line-height: 1.3;
  margin: 2.2em 0 0.8em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 112px;
}
.ar-prose h3 {
  font-size: clamp(19px, 1.8vw, 23px);
  font-weight: 700;
  line-height: 1.35;
  margin: 1.8em 0 0.65em;
  scroll-margin-top: 112px;
}
.ar-prose a {
  color: var(--brand-bright);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.ar-prose ul, .ar-prose ol {
  margin: 0 0 1.4em;
  padding-inline-start: 1.5em;
}
.ar-prose li { margin-bottom: 0.55em; color: var(--ink-2) !important; }
.ar-prose blockquote {
  margin: 1.8em 0;
  padding: 18px 24px;
  border-inline-start: 3px solid var(--brand);
  background: rgba(35, 181, 164, 0.06);
  border-radius: 14px;
  font-style: italic;
  color: var(--ink) !important;
}
.ar-prose blockquote * {
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--ink) !important;
}
.ar-prose img {
  border-radius: 18px;
  margin: 2em 0;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
}
.ar-prose code {
  background: rgba(35, 181, 164, 0.12);
  color: var(--brand-bright) !important;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
}
.ar-prose pre {
  padding: 18px 20px;
  border-radius: 16px;
  background: #0d1117;
  border: 1px solid var(--line);
  overflow-x: auto;
  margin: 1.6em 0;
}
.ar-prose pre code { background: transparent; padding: 0; color: #e6edf3 !important; }

/* Tags, Likes & Share Footer Inside Article */
.ar-footer-block {
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.ar-footer-label {
  display: block;
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ar-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: border-color 0.25s ease, color 0.25s ease;
}
.ar-tag:hover { border-color: var(--brand); color: var(--brand-bright); }

.ar-engagement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
}

/* Harmonize content-like-btn */
body.ar-page .content-like-btn {
  min-height: 46px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 1px solid rgba(35, 181, 164, 0.36);
  background: rgba(35, 181, 164, 0.12);
  color: var(--brand-bright);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.3s var(--ease);
}
body.ar-page .content-like-btn:hover { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
body.ar-page .content-like-btn.is-liked { background: rgba(239, 68, 68, 0.18); border-color: rgba(248, 113, 113, 0.48); color: #fda4af; }
body.tt-light-style-on.ar-page .content-like-btn.is-liked { color: #e11d48; }

/* ==========================================================================
   5. Section 3: Related Essays Grid (#arRelated)
   ========================================================================== */
.ar-related {
  padding: clamp(56px, 7vw, 96px) 0;
  border-top: 1px solid var(--line);
}

.ar-rel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}

.ar-rel-head h2 {
  margin: 0;
  font-size: clamp(26px, 3vw, 40px);
  font-weight: 800;
  color: var(--ink);
}

.ar-rel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(18px, 2.2vw, 26px);
}

.ar-rel-card {
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: start;
  transition: transform 0.45s var(--ease);
}

.ar-rel-card:hover { transform: translateY(-4px); }

.ar-rel-media {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-2);
}

.ar-rel-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.75s var(--ease);
}

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

.ar-rel-body {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.ar-rel-cat {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}

.ar-rel-body h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.25s ease;
}

.ar-rel-card:hover .ar-rel-body h3 { color: var(--brand-bright); }

/* ==========================================================================
   6. Responsive Breakpoints (320px -> 1440px Zero-Overflow Guarantee)
   ========================================================================== */
@media (max-width: 1024px) {
  .ar-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
  .ar-sidebar { position: static; order: 2; }
  .ar-article-card { order: 1; }
  .ar-rel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  :root { --gutter: 16px; --prose-size: 16.5px; }
  .ar-hero { padding-top: 122px; }
  .ar-author-deck { border-radius: 22px; width: 100%; justify-content: center; }
  .ar-rel-grid { grid-template-columns: minmax(0, 1fr); }
}
