/*
 * Josoor design system — the public catalog (/courses/) and a section hub (/<section>/[<specialty>/]).
 * Prefixes `cat-` (catalog) and `hub-` (hub); the cards and the header are public.css. Tokens only.
 * The catalog template still carries the body classes ds / ds-legacy (legacy-bridge.css): this page uses none of its
 * old classes, so nothing of it applies here.
 */
.cat-page { display: block; min-height: 60vh; font-family: var(--font); color: var(--text); line-height: 1.75; outline: none; }
.cat-page h1, .cat-page h2, .cat-page h3 { margin: 0; line-height: 1.35; font-weight: var(--fw-bold); text-wrap: balance; }
.cat-page p { margin: 0; }

.cat-crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-3); padding-top: var(--sp-6); }
.cat-crumbs a { color: var(--text-2); text-decoration: none; }
.cat-crumbs a:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.cat-crumbs [aria-current] { color: var(--text); }
.cat-crumbs svg.icon.pi { width: 14px; height: 14px; }

/* ── Catalog head ─────────────────────────────────────────────────────────────── */
.cat-phead { padding-bottom: var(--sp-6); }
.cat-phead h1 { font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.375rem); margin-top: 12px; }
.cat-lead { color: var(--text-2); margin-top: 6px !important; max-width: 640px; }
.cat-phead-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.cat-phead-row > div { min-width: 0; }
.cat-scope-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-3); }
.cat-search { position: relative; width: min(420px, 100%); }
.cat-search > svg.icon.pi { position: absolute; inset-inline-start: 12px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
.cat-search .ds-input { height: 44px; padding-inline-start: 40px; font-size: var(--fs-base); }

/* ── Layout: filter panel + main ──────────────────────────────────────────────── */
.cat-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 36px; align-items: start; padding-bottom: 72px; }
.cat-panel { position: sticky; top: calc(var(--pub-hdr-h) + 20px); max-height: calc(100vh - var(--pub-hdr-h) - 40px); overflow: auto; padding: 4px; scrollbar-width: thin; }
.cat-panel:empty { display: none; }
.cat-layout:has(.cat-panel:empty) { grid-template-columns: minmax(0, 1fr); }
.cat-fgroup { padding: 14px 0; border-bottom: 1px solid var(--border); }
.cat-fgroup:first-child { padding-top: 0; }
.cat-fgroup > h3 { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text); margin-bottom: 8px; }
.cat-check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-md); color: var(--text); min-height: 32px; }
.cat-check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; flex: none; }
.cat-check .c { margin-inline-start: auto; color: var(--text-3); font-size: var(--fs-xs); }
.cat-check:has(input:disabled) { color: var(--text-3); cursor: default; }
.cat-check input:disabled { opacity: .5; }
.cat-tree details { margin-top: 2px; }
.cat-tree summary { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; list-style: none; font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); }
.cat-tree summary::-webkit-details-marker { display: none; }
.cat-tree summary .chev { width: 16px; height: 16px; color: var(--text-3); transition: rotate .15s; rotate: 90deg; }
.cat-tree details[open] summary .chev { rotate: 0deg; }
.cat-tree summary .c { margin-inline-start: auto; font-size: var(--fs-xs); color: var(--text-3); font-weight: var(--fw-regular); }
.cat-tree .kids { padding-inline-start: 24px; border-inline-start: 1px solid var(--border); margin-inline-start: 7px; }
.cat-fclear { margin-top: 14px; }
.cat-main { min-width: 0; }
.cat-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cat-count { font-size: var(--fs-md); color: var(--text-2); }
.cat-toolbar .cat-count { margin-inline-end: auto !important; }
.cat-sort { display: flex; align-items: center; gap: 8px; }
.cat-sort label { font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.cat-sort .ds-select { height: 38px; width: auto; min-width: 170px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.cat-chips:empty { display: none; }
.cat-chip-x { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 6px 0 12px; border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--brand-soft); color: var(--text); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap; }
.cat-chip-x:hover { border-color: var(--brand-line); }
.cat-chip-x svg.icon.pi { color: var(--text-2); }
.cat-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; border-radius: var(--radius-pill); background: var(--brand); color: var(--brand-ink); font-size: 11px; padding: 0 6px; }
.cat-badge[hidden] { display: none; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 252px), 1fr)); gap: 20px; }
.cat-grid > * { min-width: 0; }
.cat-grid:empty { display: none; }
.cat-empty { text-align: center; padding: 56px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.cat-empty[hidden] { display: none; }
.cat-empty > svg.icon.pi { width: 36px; height: 36px; color: var(--text-3); margin: 0 auto 12px; display: block; }
.cat-empty h3 { font-size: var(--fs-lg); margin-bottom: 6px; }
.cat-empty p { color: var(--text-2); margin-bottom: 16px; }
.cat-empty.bad > svg.icon.pi { color: var(--bad); }
.cat-select { position: relative; min-width: 0; }
.cat-select .ds-select { appearance: none; padding-inline-end: 36px; cursor: pointer; }
.cat-select > svg.icon.pi { position: absolute; inset-inline-end: 10px; top: 50%; translate: 0 -50%; pointer-events: none; color: var(--text-3); }

/* Tabs a module prints over the catalog («الدورات | الباقات») */
.cat-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.cat-tabs [role="tab"] { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border: 0; background: none; color: var(--text-2);
  font: inherit; font-weight: var(--fw-semibold); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.cat-tabs [role="tab"]:hover { color: var(--text); }
.cat-tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); }
.cat-tabs .c { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-3); background: var(--muted-soft); border-radius: var(--radius-pill); padding: 0 8px; line-height: 20px; }
.cat-layout.is-bundles { grid-template-columns: minmax(0, 1fr); }
.cat-layout.is-bundles .cat-panel, .cat-layout.is-bundles [data-cat-courses] { display: none; }

/* Phone: the panel moves into a bottom sheet */
.cat-only-phone { display: none; }
@media (max-width: 1023px) {
  .cat-layout { grid-template-columns: minmax(0, 1fr); }
  .cat-layout > .cat-panel { display: none; }
  .cat-only-phone { display: inline-flex; }
  .cat-sort .ds-select { min-width: 0; }
}
@media (max-width: 520px) { .cat-sort label { display: none; } .cat-toolbar .cat-count { order: 3; width: 100%; } }
.pub-sheet { margin: auto 0 0; width: 100%; max-width: 100%; max-height: 86dvh; border-radius: 18px 18px 0 0; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); }
.pub-sheet[open] { display: flex; }
.pub-sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 10px auto 0; flex: none; }
.pub-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 10px; border-bottom: 1px solid var(--border); flex: none; }
.pub-sheet-head h2 { margin: 0; font-size: var(--fs-lg); }
.pub-sheet-body { overflow: auto; padding: 4px 16px 16px; flex: 1; }
.pub-sheet-body .cat-fgroup:first-child { padding-top: 14px; }
.pub-sheet-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex: none; }
.pub-sheet-foot .ds-btn-primary { flex: 1; }

/* ── Hub ──────────────────────────────────────────────────────────────────────── */
.hub-hero { position: relative; overflow: hidden; background: var(--surface); border-bottom: 1px solid var(--border); }
.hub-hero.is-featured { background: var(--section-soft); border-bottom-color: var(--section-line); }
.hub-art { position: absolute; inset-inline-end: 0; bottom: 0; width: min(560px, 48%); height: 100%; fill: none; stroke: var(--border-strong); stroke-width: 1.25; pointer-events: none; }
.hub-hero.is-featured .hub-art { stroke: var(--section-line); }
.hub-art * { vector-effect: non-scaling-stroke; }
@media (max-width: 767px) { .hub-art { display: none; } }
.hub-hero-in { position: relative; padding-block: 8px 44px; }
.hub-kicker { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text-2); margin-top: 28px; }
.hub-hero.is-featured .hub-kicker { color: var(--section); }
.hub-hero h1 { font-size: clamp(1.875rem, 1.2rem + 2.3vw, 2.75rem); margin: 10px 0 12px; overflow-wrap: anywhere; }
.hub-hero .hub-kicker + h1 { margin-top: 10px; }
.hub-hero .cat-crumbs + h1 { margin-top: 28px; }
.hub-lead { color: var(--text-2); font-size: var(--fs-lg); max-width: 640px; line-height: 1.85; overflow-wrap: anywhere; }
.hub-facts { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 28px; font-size: var(--fs-md); }
.hub-facts li { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.hub-facts svg.icon.pi { color: var(--section); }
.hub-body { padding-block: 28px 72px; }
.hub-tiles { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.htile { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  text-decoration: none; color: var(--text); min-width: 0; height: 100%; box-sizing: border-box; }
.htile:hover { border-color: var(--brand); }
.htile > svg.icon.pi { width: 30px; height: 30px; color: var(--brand); }
.htile > span { min-width: 0; }
.htile b { display: block; font-weight: var(--fw-semibold); font-size: var(--fs-md); line-height: 1.5; overflow-wrap: anywhere; }
.htile b + span { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.htile[aria-current="page"] { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
@media (max-width: 1079px) { .hub-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .hub-tiles { gap: 8px; } .htile { padding: 12px; gap: 10px; } .htile > svg.icon.pi { width: 24px; height: 24px; } .htile b { font-size: var(--fs-sm); } }
.cat-reshead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 16px; flex-wrap: wrap; }
.cat-reshead h2 { font-size: var(--fs-xl); }
.hub-fbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); margin-bottom: 16px; }
.hub-fbar[hidden] { display: none; }
.hub-field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 150px; min-width: 0; }
.hub-field label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-2); }
.hub-field .ds-select { height: 40px; }
.hub-bool { flex: 0 0 auto; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.hub-bool .c { margin-inline-start: 8px; }
.hub-sortf { margin-inline-start: auto; flex: 0 1 200px; }
@media (max-width: 520px) { .hub-fbar { padding: 12px; gap: 8px; } .hub-field { flex: 1 1 40%; } .hub-sortf { flex: 1 1 40%; margin-inline-start: 0; } .hub-bool { flex: 1 1 100%; } }
.hub-req { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 20px; font-size: var(--fs-md); color: var(--text-2); }
.hub-req[hidden] { display: none; }
.cat-empty .hub-req { justify-content: center; margin-top: 14px; }
.hub-block { margin-top: 56px; }
.hub-block > h2 { font-size: var(--fs-xl); margin-bottom: 16px; }

@media (prefers-reduced-motion: reduce) { .cat-page *, .pub-sheet * { transition: none !important; animation: none !important; } }
