/* News & blog: the article grid on the landing page and the article pages (blog.html).
   Uses the page's own tokens (--surface, --line, --accent, --r-card...), so both themes follow.
   Logical properties throughout, so Arabic (RTL) mirrors without extra rules. */

/* ---------- Section on the landing page ---------- */

.news { padding: clamp(4.5rem, 9vw, 7.5rem) 0; border-top: 1px solid var(--line); }
.news[hidden] { display: none; }
.sec-head.news-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1.25rem 2rem; max-width: none; }
.news-head > div { max-width: 46rem; }
.news-all { flex: none; }
.news-all i { transition: transform 0.3s var(--ease-out); }
.news-all:hover i { transform: translateX(3px); }
[dir="rtl"] .news-all i { transform: scaleX(-1); }
[dir="rtl"] .news-all:hover i { transform: scaleX(-1) translateX(3px); }

/* ---------- Article grid (landing page): up to three equal cards ---------- */

/* Its own name: index.html's feature section already has a 12-column .bento. */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.9rem, 1.6vw, 1.25rem);
}

@media (max-width: 960px) {
  .news-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  /* Stacked on a phone: a clear gap between one card and the next. */
  .news-grid { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
}

/* ---------- Card ---------- */

.nc {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.45s var(--ease-out), box-shadow 0.45s var(--ease-out), border-color 0.3s var(--ease-io);
  animation: nc-in 0.6s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
/* Mouse only: on a touch screen the hover sticks after a tap and lifts the card into its neighbour. */
@media (hover: hover) {
  .nc:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
}
.nc:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@keyframes nc-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.nc-media { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: var(--surface-2); flex: none; }
.nc-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.8s var(--ease-out); }
@media (hover: hover) { .nc:hover .nc-media img { transform: scale(1.04); } }

/* No featured image: a calm tinted panel with the category icon, never an empty box. */
.nc-ph {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 85% 10%, var(--accent-glow), transparent 60%),
    linear-gradient(135deg, var(--accent-tint), var(--surface-2));
  color: var(--accent);
}
.nc-ph i { font-size: clamp(2rem, 4vw, 3rem); opacity: 0.55; }

.nc-body { display: flex; flex: 1; flex-direction: column; gap: 0.6rem; padding: clamp(1.05rem, 1.8vw, 1.35rem); min-width: 0; }
.nc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; font-size: 0.8rem; color: var(--ink-3); }
.nc-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.nc-cat {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.55rem; border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.02em;
  background: var(--accent-soft); color: var(--accent);
}
.nc-cat--tips { background: var(--warn-soft); color: var(--warn-ink); }
.nc-cat--blog { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
html[lang="ar"] .nc-cat { font-family: inherit; letter-spacing: 0; }
.nc-title { font-size: 1.08rem; line-height: 1.3; letter-spacing: -0.015em; font-weight: 600; transition: color 0.3s var(--ease-io); overflow-wrap: anywhere; }
.nc:hover .nc-title { color: var(--accent); }
.nc-excerpt { color: var(--ink-2); font-size: 0.92rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nc-more { margin-top: auto; padding-top: 0.35rem; display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.86rem; font-weight: 560; color: var(--accent); }
.nc-more i { transition: transform 0.3s var(--ease-out); }
.nc:hover .nc-more i { transform: translateX(3px); }
[dir="rtl"] .nc-more i { transform: scaleX(-1); }
[dir="rtl"] .nc:hover .nc-more i { transform: scaleX(-1) translateX(3px); }

/* Compact: image and title only, so two stack neatly beside the feature. */
.nc--compact .nc-excerpt { display: none; }
.nc--compact .nc-media { aspect-ratio: 16 / 8; }

/* Feature: the newest article, large, image filling the top. */
.nc--feature .nc-media { aspect-ratio: auto; flex: 1 1 auto; min-height: 15rem; }
.nc--feature .nc-title { font-size: clamp(1.35rem, 2.3vw, 1.85rem); line-height: 1.18; letter-spacing: -0.025em; }
.nc--feature .nc-excerpt { font-size: 0.98rem; -webkit-line-clamp: 2; }
.nc--feature .nc-body { flex: none; padding: clamp(1.25rem, 2.2vw, 1.75rem); }

/* Wide: image beside the text. */
.nc--wide { flex-direction: row; }
.nc--wide .nc-media { aspect-ratio: auto; width: 42%; min-height: 100%; }
.nc--wide .nc-excerpt { -webkit-line-clamp: 2; }
@media (max-width: 960px) {
  .nc--wide { flex-direction: column; }
  .nc--wide .nc-media { width: 100%; aspect-ratio: 16 / 9; min-height: 0; }
  .nc--feature .nc-media { aspect-ratio: 16 / 9; flex: none; min-height: 0; }
}

/* Loading placeholders while the API answers. */
.nc-skel { border-radius: var(--r-card); background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-alt) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: nc-shimmer 1.4s linear infinite; min-height: 15rem; }
@keyframes nc-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- blog.html: list ---------- */

.blog-hero { padding: clamp(2.5rem, 5vw, 4.4rem) 0 clamp(1.75rem, 3.5vw, 2.5rem); }
.blog-hero h1 { font-size: var(--t-h1); line-height: 1.06; letter-spacing: -0.03em; margin-top: 0.8rem; }
.blog-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.75rem; }
.blog-chip {
  appearance: none; cursor: pointer;
  padding: 0.5rem 1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: 0.88rem; font-weight: 520;
  transition: background 0.25s var(--ease-io), color 0.25s var(--ease-io), border-color 0.25s var(--ease-io);
}
.blog-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.blog-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.blog-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.blog-list { padding-bottom: clamp(4.5rem, 9vw, 7rem); }
.blog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(0.9rem, 1.6vw, 1.25rem); }
.blog-grid > .nc--wide { grid-column: 1 / -1; }
.blog-grid > .nc--wide .nc-media { width: 55%; aspect-ratio: 16 / 9; }
.blog-grid > .nc--wide .nc-title { font-size: clamp(1.35rem, 2.3vw, 1.85rem); line-height: 1.18; }
@media (max-width: 960px) { .blog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .blog-grid > .nc--wide .nc-media { width: 100%; } }
@media (max-width: 600px) { .blog-grid { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; } }

.blog-state { text-align: center; padding: clamp(3rem, 8vw, 5rem) 1rem; color: var(--ink-2); border: 1px dashed var(--line-strong); border-radius: var(--r-card); }
.blog-state i { display: block; font-size: 2rem; color: var(--accent); margin-bottom: 0.75rem; }
.blog-state h2 { font-size: 1.35rem; color: var(--ink); letter-spacing: -0.02em; }
.blog-state p { margin: 0.5rem auto 1.25rem; max-width: 46ch; }

/* ---------- blog.html: single article ---------- */

.read-progress { position: fixed; inset-inline: 0; top: 0; height: 3px; z-index: 60; background: transparent; pointer-events: none; }
.read-progress span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
[dir="rtl"] .read-progress span { transform-origin: right; }

.art { padding-top: clamp(1.5rem, 3.5vw, 2.5rem); }
.art-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--ink-3); }
.art-crumbs a { color: var(--ink-2); text-decoration: none; }
.art-crumbs a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.art-crumbs i { font-size: 0.75rem; }
[dir="rtl"] .art-crumbs i { transform: scaleX(-1); }

.art-head { max-width: 50rem; margin: clamp(1.5rem, 3vw, 2.25rem) auto 0; text-align: center; }
.art-head h1 { font-size: clamp(2rem, 4.4vw, 3.25rem); line-height: 1.08; letter-spacing: -0.032em; margin-top: 1rem; overflow-wrap: anywhere; }
.art-head .nc-meta { justify-content: center; font-size: 0.88rem; }
.art-lede { margin: 1.1rem auto 0; max-width: 40rem; font-size: clamp(1.05rem, 1.4vw, 1.2rem); color: var(--ink-2); line-height: 1.55; }

.art-cover { max-width: 68rem; margin: clamp(1.75rem, 4vw, 2.75rem) auto 0; border-radius: calc(var(--r-card) + 4px); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-md); background: var(--surface-2); }
.art-cover img { display: block; width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; }

.art-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 42rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 3vw, 2.5rem);
  margin-top: clamp(2.25rem, 5vw, 3.5rem);
  padding-bottom: clamp(3rem, 6vw, 4.5rem);
}
.art-body { grid-column: 2; min-width: 0; }
.art-aside { grid-column: 3; align-self: start; position: sticky; top: calc(var(--nav-h) + 1.5rem); display: grid; gap: 1.5rem; max-width: 15rem; }
@media (max-width: 1100px) {
  .art-layout { grid-template-columns: minmax(0, 1fr); max-width: 42rem; margin-inline: auto; }
  .art-body, .art-aside { grid-column: 1; }
  .art-aside { position: static; max-width: none; border-top: 1px solid var(--line); padding-top: 1.75rem; }
}
.art-aside h2 { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.7rem; }
html[lang="ar"] .art-aside h2 { font-family: inherit; letter-spacing: 0; text-transform: none; font-size: 0.85rem; }
.share-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.share-btn {
  appearance: none; cursor: pointer;
  display: inline-grid; place-items: center;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: 1.1rem; text-decoration: none;
  transition: color 0.25s var(--ease-io), border-color 0.25s var(--ease-io), background 0.25s var(--ease-io), transform 0.25s var(--ease-out);
}
.share-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-tint); transform: translateY(-2px); }
.share-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-btn.copied { color: var(--ok-ink); border-color: var(--ok); background: var(--ok-soft); }
.tag-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag { padding: 0.25rem 0.65rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.8rem; color: var(--ink-2); }

/* The article text itself. */
.prose { font-size: clamp(1.02rem, 1.2vw, 1.1rem); line-height: 1.75; color: var(--ink-2); overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.15em; }
.prose > p:first-child { font-size: 1.12em; color: var(--ink); }
.prose h2 { font-size: clamp(1.4rem, 2.2vw, 1.7rem); line-height: 1.25; letter-spacing: -0.022em; color: var(--ink); margin-top: 2em; }
.prose h3 { font-size: clamp(1.15rem, 1.6vw, 1.3rem); line-height: 1.3; letter-spacing: -0.015em; color: var(--ink); margin-top: 1.7em; }
.prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
.prose strong, .prose b { color: var(--ink); font-weight: 620; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-inline-start: 1.35em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li + li { margin-top: 0.45em; }
.prose li::marker { color: var(--accent); }
.prose li > p { margin: 0; }
.prose blockquote { margin-inline: 0; padding-block: 0.35em; padding-inline: 1.25em 0; border-inline-start: 3px solid var(--accent); font-size: 1.08em; color: var(--ink); font-style: italic; }
.prose pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1em 1.15em; overflow-x: auto; font-size: 0.88em; line-height: 1.6; direction: ltr; }
.prose code { font-family: var(--font-mono); font-size: 0.9em; }
.prose :not(pre) > code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 0.1em 0.35em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose img { display: block; max-width: 100%; height: auto; margin-inline: auto; border-radius: var(--r-sm); border: 1px solid var(--line); }

.art-related { border-top: 1px solid var(--line); padding: clamp(3rem, 6vw, 4.5rem) 0; }
.art-related h2 { font-size: clamp(1.35rem, 2.2vw, 1.75rem); letter-spacing: -0.022em; margin-bottom: 1.5rem; }

.art-cta { padding-bottom: clamp(4rem, 8vw, 6rem); }
.art-cta-box {
  position: relative; overflow: hidden;
  border-radius: calc(var(--r-card) + 6px);
  background: var(--deep); color: var(--deep-ink);
  padding: clamp(2rem, 5vw, 3.25rem);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.5rem;
}
.art-cta-box::before { content: ""; position: absolute; inset: 0; background: radial-gradient(70% 120% at 100% 0%, rgba(95, 195, 146, 0.22), transparent 60%); pointer-events: none; }
.art-cta-box > * { position: relative; }
.art-cta-box h2 { font-size: clamp(1.4rem, 2.6vw, 2rem); letter-spacing: -0.025em; line-height: 1.15; max-width: 24ch; }
.art-cta-box p { color: var(--deep-ink-2); margin-top: 0.6rem; max-width: 48ch; }

.art-skel { max-width: 50rem; margin: 2rem auto 0; display: grid; gap: 1rem; justify-items: center; }
/* Their own display would otherwise beat the hidden attribute the script sets once the article is in. */
.art-skel[hidden], .art-layout[hidden] { display: none; }
.art-skel span { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--bg-alt) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: nc-shimmer 1.4s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .nc, .nc-media img, .share-btn { animation: none; transition: none; }
  .nc:hover, .share-btn:hover { transform: none; }
  .nc:hover .nc-media img { transform: none; }
  .nc-skel, .art-skel span { animation: none; }
}
[dir="rtl"] .art-back i { transform: scaleX(-1); }
