/*
 * «تعلّم مدار» and «أخبار مدار» — the pages the API builds for /learn and /news (CONTENT_CMS_PLAN §3,
 * mockup docs/plans/mockups/learn-and-channels §7). Loaded after style.css: the header, footer,
 * buttons and tokens are the site's own; only what an article needs is here. Logical properties
 * throughout, so an English (left-to-right) page needs no new layout. The pages read fully without
 * JavaScript; an interactive lesson's lesson-player.js only turns its steps into one at a time.
 */

/* ── header: brand, the two sections, one action — one line down to 360px */
.cm .top .wrap { gap: 12px; }
.cm-nav { display: flex; align-items: center; gap: 22px; margin-inline-end: auto; font-size: 15px; color: var(--ink-soft); min-width: 0; }
.cm-nav a { text-decoration: none; white-space: nowrap; }
.cm-nav a:hover, .cm-nav a[aria-current="page"] { color: var(--primary); }
.cm-nav a[aria-current="page"] { font-weight: 700; }
@media (max-width: 560px) {
  .cm-actions { display: none; }
  .cm-nav { gap: 14px; font-size: 14px; }
  .cm .brand { font-size: 18px; }
  .cm .brand img { width: 32px; height: 32px; }
}

/* ── body */
.cm-main { padding: 20px 0 72px; }
.cm-main h1 { font-size: clamp(26px, 3.2vw, 36px); font-weight: 700; margin-top: 8px; overflow-wrap: anywhere; }
.cm-main h2 { font-size: 21px; font-weight: 700; margin-top: 32px; }
.cm-main h3 { font-size: 16px; font-weight: 700; }
.cm-main p { color: var(--ink-soft); font-size: 16px; margin-top: 12px; overflow-wrap: anywhere; }
.cm-lede { font-size: 17px; max-width: 760px; }
.cm-meta { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.cm-empty { color: var(--muted); }

.cm-crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.cm-crumbs li { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cm-crumbs li + li::before { content: '›'; margin-inline-end: 6px; }
.cm-crumbs a { text-decoration: none; }
.cm-crumbs a:hover { color: var(--primary); }

/* An article with its side column; one column on phones. */
.cm-article { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; align-items: start; margin-top: 8px; }
.cm-article > article { min-width: 0; }
.cm-aside { display: grid; gap: 14px; position: sticky; top: 88px; }
@media (max-width: 900px) {
  .cm-article { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .cm-aside { position: static; }
}

.cm-hero { display: block; width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius-sm); margin-top: 16px; background: var(--surface); }

/* ── blocks */
.cm-steps ol { margin: 12px 0 0; padding-inline-start: 22px; color: var(--ink-soft); font-size: 16px; }
.cm-steps li { margin-top: 8px; padding-inline-start: 4px; overflow-wrap: anywhere; }
.cm-steps li::marker { color: var(--primary); font-weight: 700; }
.cm-figure { margin: 18px 0 0; }
.cm-figure img { display: block; max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }
.cm-video { margin: 18px 0 0; }
.cm-video iframe { display: block; width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: var(--radius-sm); background: var(--night); }
.cm-video figcaption { margin-top: 6px; font-size: 13px; }
.cm-video a { color: var(--primary); }
.cm-faq-item { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 10px 14px; }
.cm-faq-item summary { cursor: pointer; font-weight: 600; overflow-wrap: anywhere; }
.cm-faq-item p { margin-top: 6px; }
.cm-callout { margin-top: 16px; border-radius: var(--radius-sm); padding: 4px 16px 14px; border-inline-start: 4px solid var(--primary); background: var(--primary-soft); }
.cm-callout.cm-warn { border-inline-start-color: var(--amber); background: var(--amber-soft); }
.cm-callout.cm-warn p { color: var(--warn); }
.cm-button { margin-top: 18px; }
.cm-button .btn { white-space: normal; text-align: center; }
.cm-table { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.cm-table table { width: 100%; border-collapse: collapse; font-size: 14.5px; table-layout: fixed; }
.cm-table th, .cm-table td { padding: 9px 12px; text-align: start; border-top: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: top; }
.cm-table thead th { border-top: 0; background: var(--ground); color: var(--ink); }

/* ── previous / next */
.cm-pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 36px; }
.cm-pager .btn { white-space: normal; text-align: center; max-width: 100%; }
@media (max-width: 560px) { .cm-pager .btn { flex: 1 1 100%; } }

/* ── side column cards */
.cm-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; }
.cm-card h3 a { text-decoration: none; }
.cm-card p { font-size: 14px; margin-top: 4px; }
.cm-cta { background: var(--primary-soft); border-color: transparent; }
.cm-cta .btn { margin-top: 12px; width: 100%; }
.cm-series { margin: 10px 0 0; padding-inline-start: 20px; font-size: 14px; color: var(--ink-soft); }
.cm-series li { margin-top: 6px; overflow-wrap: anywhere; }
.cm-series a { text-decoration: none; }
.cm-series a:hover { color: var(--primary); }
.cm-series li[aria-current="page"] { color: var(--primary); font-weight: 700; }
.cm-channels { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.cm-channel { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); text-decoration: none; font-size: 14px; font-weight: 600; }
.cm-channel:hover { color: var(--primary); border-color: var(--primary); }

/* ── lists: series cards and article rows */
.cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin: 24px 0 0; padding: 0; list-style: none; }
.cm-list { display: grid; gap: 12px; margin: 16px 0 0; padding: 0; list-style: none; }
.cm-item a { display: flex; gap: 14px; align-items: flex-start; height: 100%; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); text-decoration: none; transition: border-color .2s, box-shadow .2s; }
.cm-item a:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.cm-grid .cm-item a { flex-direction: column; }
.cm-thumb { flex: none; width: 96px; height: 64px; object-fit: cover; border-radius: 9px; background: var(--ground); }
.cm-grid .cm-thumb { width: 100%; height: 140px; }
.cm-item-text { display: grid; gap: 2px; min-width: 0; }
.cm-item-text strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-item-text > span:not(.cm-tag) { color: var(--ink-soft); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cm-item-text small { color: var(--primary); font-weight: 600; font-size: 12.5px; }

.cm-tag { display: inline-block; justify-self: start; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 0 9px; background: var(--primary-soft); color: var(--primary); }
.cm-tag-tip { background: var(--amber-soft); color: var(--warn); }
.cm-tag-notice { background: var(--ground); color: var(--ink-soft); border: 1px solid var(--line-strong); }

.cm-notfound { padding: 48px 0; }
.cm-notfound .btn { margin-top: 20px; }

/* ── interactive lesson (CONTENT_CMS_PLAN phase B; mockup docs/plans/mockups/academy).
   Without a script: every step in order, both screenshots and the two cards — the page search
   engines read. lesson-player.js adds .cm-lesson-js: one step at a time behind the bar. */
.cm-article.cm-has-lesson { grid-template-columns: minmax(0, 1fr); }
.cm-has-lesson .cm-aside { position: static; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); align-items: start; }

.cm-lesson { margin-top: 28px; scroll-margin-top: 84px; }
.cm-lsteps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 18px; }
.cm-lstep { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; scroll-margin-top: 84px; }
.cm-lstep-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cm-lstep-head h3 { min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.cm-lstep-n { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--surface); font-size: 13px; font-weight: 700; }
.cm-main .cm-lstep-do { margin-top: 8px; color: var(--ink); font-weight: 600; }
.cm-lstep-body { display: grid; gap: 14px; margin-top: 12px; min-width: 0; }

.cm-shots { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 210px); gap: 16px; align-items: start; }
.cm-shot { margin: 0; display: grid; gap: 6px; justify-items: center; min-width: 0; }
.cm-shot figcaption { font-size: 12.5px; color: var(--muted); }
.cm-frame { width: 100%; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.cm-frame-desktop { border: 1px solid var(--line-strong); border-radius: 12px; }
.cm-chrome { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; background: var(--ground); border-bottom: 1px solid var(--line); }
.cm-chrome i { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.cm-frame-phone { max-width: 330px; border: 8px solid var(--night); border-radius: 30px; }
/* The marked place is measured on the image, which has no reading direction: physical left/top,
   inside a box that is left-to-right whatever the page's language. */
.cm-screen { position: relative; direction: ltr; }
.cm-screen img { display: block; width: 100%; height: auto; }
.cm-hotspot { position: absolute; left: var(--x); top: var(--y); width: var(--w); height: var(--h); outline: 3px dashed var(--primary); outline-offset: 3px; border-radius: 8px; }
a.cm-hotspot { cursor: pointer; }
a.cm-hotspot:focus-visible { outline-style: solid; }
.cm-tip { display: none; }

.cm-lnotes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); align-content: start; min-width: 0; }
.cm-lnote h4 { margin: 0 0 4px; font-size: 15px; }
.cm-lnote ul { margin: 0; padding-inline-start: 18px; color: var(--ink-soft); font-size: 14.5px; }
.cm-lnote li { overflow-wrap: anywhere; }
.cm-lnote-does h4 { color: var(--primary); }
.cm-main .cm-captured { font-size: 12.5px; color: var(--muted); }
.cm-tag-lesson { background: var(--primary-soft); color: var(--primary); }

@media (max-width: 760px) {
  .cm-shots { grid-template-columns: minmax(0, 1fr); }
  .cm-lstep { padding: 12px; }
}

/* ── the player */
.cm-lbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 12px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.cm-lbar[hidden] { display: none; }
.cm-main .cm-lcount { display: flex; align-items: baseline; gap: 8px; flex: 1 1 220px; min-width: 0; margin: 0; color: var(--ink); font-size: 15px; }
.cm-lcount-n { flex: none; color: var(--primary); font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.cm-lcount strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-device { display: flex; flex: none; padding: 3px; border-radius: 999px; background: var(--ground); }
.cm-device button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--ink-soft); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.cm-device button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.cm-device svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cm-lnav { display: flex; flex: none; gap: 8px; }
.cm-lnav .btn { min-height: 40px; padding: 0 16px; font-size: 14px; }
.cm-lnav .btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }

.cm-lesson-js .cm-lsteps { margin-top: 12px; }
.cm-lesson-js .cm-lstep { display: none; padding: 0; border: 0; background: none; }
.cm-lesson-js .cm-lstep.is-current { display: block; }
.cm-lesson-js .cm-lstep-head { display: none; }
.cm-lesson-js .cm-lstep-do { margin-top: 0; }
.cm-lesson-js .cm-shots { grid-template-columns: minmax(0, 1fr); }
.cm-lesson-js .cm-shot { display: none; }
.cm-lesson-js .cm-shot.is-shown { display: grid; }
.cm-lesson-js .cm-shot figcaption { display: none; }
.cm-lesson-js .cm-lnotes { grid-template-columns: minmax(0, 1fr); }
.cm-lesson-js .cm-tip { display: block; position: absolute; left: var(--tip-x); top: calc(var(--tip-top) + 12px); transform: translateX(-50%); width: max-content; max-width: min(22em, 80%); padding: 8px 12px; border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 600; line-height: 1.6; text-align: start; unicode-bidi: plaintext; pointer-events: none; }
.cm-lesson-js .cm-tip-above { top: auto; bottom: calc(var(--tip-bottom) + 12px); }
.cm-lesson-js .cm-shot-phone .cm-tip { font-size: 12.5px; }
@media (min-width: 1000px) {
  .cm-lesson-js .cm-lstep-body { grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
  .cm-lesson-js .cm-lstep-textonly { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .cm-device span { display: none; }
  .cm-lnav { flex: 1 1 100%; }
  .cm-lnav .btn { flex: 1; }
  .cm-lesson-js .cm-tip { font-size: 12px; padding: 6px 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .cm-lesson-js a.cm-hotspot { animation: cm-ring 1.6s ease-in-out infinite; }
}
@keyframes cm-ring { 50% { outline-offset: 7px; } }
