/*
  واضح design system.
  Mobile-first: the main rules are for phones; wider screens are adjusted in media queries.
  Use logical properties (padding-inline, margin-inline-start…), never left/right, so RTL just works.
  The one exception is the hero drawing's labels, which sit on fixed points of an SVG.
*/

/* ---------- Design tokens ---------- */

/*
  Meaning of the colours (decision 035):
  - forest (--heading): headings, links, primary buttons, focus ring
  - lime: only "open now" and "your next step" (never small text)
  - amber: restrictions and "not open yet"
  - grey (--ink-muted): closed, secondary text
  Every text/background pair used here is checked for contrast in tests/test_design.py.
*/

/* Light theme: the default for everyone (decision 022). */
:root {
  color-scheme: light;

  --paper: #f6f4ee;          /* page canvas: warm ivory */
  --surface: #fbfaf6;        /* raised surfaces */
  --surface-strong: #ffffff;
  --ink: #101713;            /* body text: deep charcoal */
  --ink-muted: #4f5a54;      /* secondary text (contrast ≥ 6:1 on paper) */
  --heading: #184b3a;        /* headings, links, primary actions: forest green */
  --on-heading: #f6f4ee;     /* text on a forest button */
  --line: #e2ded2;           /* fine borders between rows */
  --line-strong: #cfc9ba;
  --control-border: #4f5a54; /* inputs and selects: ≥ 3:1 against the page (WCAG 1.4.11) */
  --lime: #d8ed9b;           /* "open now" and "your next step" only. Never small text. */
  --on-lime: #101713;
  --amber: #774c0c;          /* restrictions and "not open yet" (darkened for contrast on tints) */
  --sea: #1d6470;            /* Red Sea path accent */
  --band: #184b3a;           /* the Tuwaiq band background */
  --focus: #184b3a;          /* keyboard focus ring */

  --font-body: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-heading: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-editorial: "Noto Naskh Arabic", "IBM Plex Sans Arabic", serif; /* wordmark + quotes only */

  /* One type scale. Nothing smaller than --text-xs: small Arabic text is hard to read. */
  --text-xs: 0.8125rem;      /* 13px: tags */
  --text-sm: 0.9375rem;      /* 15px: notes, meta, sources */
  --text-base: 1.0625rem;    /* 17px: body */
  --text-lg: 1.1875rem;      /* 19px: lead, h3 */
  --text-xl: 1.5rem;         /* h2 */
  --text-2xl: 1.875rem;      /* h1 */
  --text-hero: clamp(2rem, 1.35rem + 2.8vw, 3.1rem);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 40px;
  --space-6: 64px;
  --space-7: 88px;

  --wide: 1240px;            /* the page grid */
  --page: 1040px;            /* tool pages: explorer, university, program, news */
  --measure: 720px;          /* comfortable reading column */
  --radius: 8px;
}

/* Dark theme: only when the student picks it (data-theme="dark"). Designed, not inverted. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #101713;
  --surface: #16211c;
  --surface-strong: #1c2a23;
  --ink: #ece9e0;
  --ink-muted: #a9b4ad;
  --heading: #9ad3b4;
  --on-heading: #101713;
  --line: #26332d;
  --line-strong: #34443c;
  --control-border: #8a968f;
  --lime: #d8ed9b;
  --on-lime: #101713;
  --amber: #e0b26a;
  --sea: #6cc3cf;
  --band: #16211c;
  --focus: #d8ed9b;
}

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  /* iPhone Safari enlarges text when the phone turns sideways; keep the sizes we set. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.8;
  overflow-wrap: break-word; /* long URLs and English names wrap instead of widening the page (WCAG 1.4.10) */
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.4;
  color: var(--heading);
  text-wrap: balance;
  /* Never add letter-spacing to Arabic: it breaks the joins between letters. */
}

h1 {
  font-size: var(--text-2xl);
  line-height: 1.3;
  margin-block: 0 var(--space-3);
}

h2 {
  font-size: var(--text-xl);
  margin-block: var(--space-6) var(--space-3);
}

h3 {
  font-size: var(--text-lg);
}

p {
  margin-block: 0 var(--space-3);
}

a {
  color: var(--heading);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* A clear ring for keyboard users, in both themes (WCAG 2.4.7). Bands with a dark
   background switch --focus to lime so the ring never disappears. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection {
  background: var(--lime);
  color: var(--on-lime);
}

/* Hidden visually, still read by screen readers. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* English names and terms inside Arabic text (always with lang="en" dir="ltr"). */
.term-en {
  font-weight: 400;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* Lets keyboard users jump over the header (WCAG 2.4.1). Visible only when focused. */
.skip-link {
  position: absolute;
  inset-inline-start: var(--space-3);
  top: -200px;
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--heading);
  color: var(--on-heading);
  font-weight: 700;
}

.skip-link:focus {
  top: var(--space-2);
}

main:focus {
  outline: none; /* focused only as the skip link's target */
}

/* ---------- Layout ---------- */

/* The page grid: header, homepage, and footer share these edges. */
.container {
  max-width: var(--wide);
  margin-inline: auto;
  padding-inline: var(--space-3);
}

@media (min-width: 600px) {
  .container {
    padding-inline: var(--space-4);
  }
}

@media (min-width: 1024px) {
  .container {
    padding-inline: var(--space-5);
  }
}

/* Tool pages (explorer, university, program, news) share one width. */
.page-wide {
  max-width: var(--page);
  margin-inline: auto;
}

/* Reading pages (grades, about) keep a comfortable line length inside the grid. */
.measure {
  max-width: var(--measure);
  margin-inline: auto;
}

main {
  padding-block: var(--space-5) var(--space-6);
}

main:has(> .hero) {
  padding-top: 0;
}

/* ---------- Header ---------- */

.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 72px;
  padding-block: var(--space-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--heading);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--font-editorial);
  font-weight: 700;
  font-size: 1.85rem;
  color: var(--heading);
}

.brand-descriptor {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.site-nav {
  display: none; /* phones use the menu; shown from 900px */
  gap: var(--space-4);
}

.site-nav a {
  padding-block: var(--space-1);
  color: var(--ink);
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--heading);
  text-decoration: underline;
}

/* Where you are: the section's link is forest and underlined (WCAG: never colour alone). */
.site-nav a[aria-current] {
  color: var(--heading);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 0.55em;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-inline-start: auto;
}

.theme-toggle,
.menu-button,
.mylist-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.theme-toggle:hover,
.menu-button:hover,
.mylist-link:hover {
  border-color: var(--heading);
}

.theme-toggle svg,
.mylist-link svg {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
}


.mylist-link[aria-current] {
  border-color: var(--heading);
  color: var(--heading);
}

.mylist-count:empty {
  display: none;
}

.mylist-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5em;
  padding-inline: 4px;
  border-radius: 999px;
  background: var(--heading);
  color: var(--on-heading);
  font-size: var(--text-xs);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-button svg {
  width: 18px;
  height: 18px;
}

.menu-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + var(--space-2));
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: var(--space-2);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 23, 19, 0.14);
}

.menu-panel a {
  padding: 10px var(--space-3);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.menu-panel a:hover {
  background: color-mix(in srgb, var(--heading) 10%, var(--surface-strong));
  color: var(--heading);
}

.menu-panel a[aria-current] {
  border-inline-start: 3px solid var(--heading);
  border-start-start-radius: 0;
  border-end-start-radius: 0;
  color: var(--heading);
  font-weight: 700;
}

@media (min-width: 900px) {
  .site-nav {
    display: flex;
    margin-inline-start: var(--space-4);
  }

  .menu {
    display: none;
  }
}

/* ---------- Hero (decision 035) ---------- */

.hero {
  padding-block: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--line);
}

.hero-grid {
  display: grid;
  gap: var(--space-5);
  align-items: center;
}

.hero-kicker {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--heading);
}

/* A short lime bar: a graphic accent, not text. */
.hero-kicker::before {
  content: "";
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: var(--lime);
  flex-shrink: 0;
}

.hero h1 {
  margin-bottom: var(--space-3);
  font-size: var(--text-hero);
  line-height: 1.25;
}

.lead {
  max-width: 34em;
  font-size: var(--text-lg);
  line-height: 1.85;
  color: var(--ink-muted);
}

/* The main way in: your grade. The biggest targets on the page. */
.hero-grades {
  max-width: 560px;
  margin-top: var(--space-4);
}

.start-title {
  margin-bottom: var(--space-3);
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--heading);
}

.grade-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.grade-choices a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 76px;
  padding: var(--space-2);
  border: 2px solid var(--heading);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--heading);
  text-align: center;
  text-decoration: none;
}

.grade-name {
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.4;
}

.grade-hint {
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink-muted);
}

.grade-choices a:hover {
  background: var(--heading);
  color: var(--on-heading);
}

.grade-choices a:hover .grade-hint {
  color: var(--on-heading);
}

/* The second way in: search the official lists. A quieter panel beside (or under) the grades. */
.hero-search {
  padding: var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-strong);
}

.hero-search-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
}

.hero-search-examples {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-3) 0 var(--space-2);
  font-size: var(--text-sm);
}

.hero-search-examples a {
  font-weight: 700;
}

.hero-search-examples-label {
  color: var(--ink-muted);
}

.hero-search-meta {
  margin: 0;
  padding-top: var(--space-2);
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); /* grades on the right (RTL start), search on the left */
    gap: var(--space-6);
  }
}

/* ---------- Homepage sections ---------- */

.section {
  margin-block: var(--space-7);
}

.section:first-child {
  margin-top: var(--space-6);
}

/* ---------- News board (decision 033) ---------- */

.board {
  display: grid;
  border-top: 1px solid var(--line-strong);
}

.board-group {
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.board-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
}

.board-group--open .board-title::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 2px var(--heading);
}

.board-count {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.board-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.board-item {
  padding-block-end: var(--space-3);
  border-bottom: 1px dashed var(--line);
}

.board-item:last-child {
  border-bottom: 0;
  padding-block-end: 0;
}

.board-name {
  margin: 0;
  font-weight: 700;
  line-height: 1.6;
}

.board-program,
.board-when,
.board-empty {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.board-when {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin-block-start: var(--space-1);
}

.board-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  font-weight: 700;
}

.board-more {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  font-weight: 700;
}

.board-list--plain {
  padding-block: var(--space-3);
}

@media (min-width: 900px) {
  .board {
    grid-template-columns: repeat(3, 1fr);
  }

  .board-group {
    padding-inline: var(--space-4);
    border-bottom: 0;
  }

  .board-group:first-child {
    padding-inline-start: 0;
  }

  .board-group + .board-group {
    border-inline-start: 1px solid var(--line);
  }
}

/* ---------- Shared components (decision 035) ---------- */

/* Buttons: forest = the main action on a page; outlined = the second action. Lime is never a button. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid var(--heading);
  border-radius: var(--radius);
  background: transparent;
  color: var(--heading);
  font: inherit;
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn--primary {
  background: var(--heading);
  color: var(--on-heading);
}

.btn--primary:hover {
  background: color-mix(in srgb, var(--heading) 85%, var(--ink));
  border-color: color-mix(in srgb, var(--heading) 85%, var(--ink));
}

.btn--secondary:hover {
  background: color-mix(in srgb, var(--heading) 9%, transparent);
}

.btn svg {
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.btn[hidden] {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-block: var(--space-4);
}

/*
  Status tags: the state of an application (GOV.UK "tag": text + colour, never colour alone).
  Rendered only through the status_tag macro in components.html.
*/
.status {
  --chip: var(--ink-muted);
  display: inline-block;
  padding: 1px var(--space-2);
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.75;
  white-space: nowrap;
  color: var(--chip);
  background: var(--surface);
  background: color-mix(in srgb, var(--chip) 13%, var(--paper));
}

.status--open {
  background: var(--lime);
  color: var(--on-lime);
}

.status--not_open {
  --chip: var(--amber);
}

.status--closed,
.status--none_open {
  --chip: var(--ink-muted);
}

.status--invitation {
  --chip: var(--ink);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* «حتى 15 نوفمبر 2026» beside an open status. */
.status-until {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}

/* Info tags: facts about something (track membership, «لخريجي الثانوية»). Never lime. */
.tag {
  display: inline-block;
  padding: 0 var(--space-2);
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.85;
  color: var(--ink);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

/* A restriction the student must notice («ماجستير فقط»). */
.tag--warn {
  color: var(--amber);
  background: color-mix(in srgb, var(--amber) 12%, var(--paper));
  box-shadow: none;
}

/* Saved in «قائمتي». */
.tag--saved {
  color: var(--heading);
  box-shadow: inset 0 0 0 1px var(--heading);
}

.tag[hidden] {
  display: none;
}

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

/* Notices: something to read before deciding (GOV.UK "inset text"). */
.notice {
  margin-block: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-inline-start: 4px solid var(--heading);
  background: var(--surface);
}

.notice--warn {
  border-color: var(--amber);
}

.notice > :last-child {
  margin-bottom: 0;
}

.notice-title {
  margin: 0 0 var(--space-1);
  font-weight: 700;
  color: var(--heading);
}

/* Summary list: one row per question and its answer (GOV.UK "summary list"). */
.summary-list {
  margin: 0;
  border-top: 1px solid var(--line-strong);
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px var(--space-4);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.summary-row dt {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-muted);
}

.summary-row dd {
  margin: 0;
}

.summary-row dd > :last-child {
  margin-bottom: 0;
}

@media (min-width: 640px) {
  .summary-row {
    grid-template-columns: 11rem minmax(0, 1fr);
  }
}

/* A small "source" link at the end of a value. */
.src {
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Back link: back to where the student came from (GOV.UK "back link"). */
.back-link-wrap {
  margin: 0 0 var(--space-4);
}

.back-link {
  font-size: var(--text-sm);
  font-weight: 700;
}

/* Section heading with an optional link beside it. */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
}

.section-title {
  margin: 0;
  font-size: var(--text-xl);
}

.section-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.section-link {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
}

/* Rows divided by fine lines: the default way to list things (no grids of identical cards). */
.rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-strong);
}

.rows > li {
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--line);
}

/* Form controls. Borders are dark enough to see (WCAG 1.4.11: 3:1). */
.field-label {
  display: block;
  margin-bottom: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}

.field-hint {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.input,
.select {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--control-border);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
}

.input {
  font-size: var(--text-lg);
}

.input:focus,
.select:focus {
  border-color: var(--focus);
}

.select:disabled {
  border-style: dashed;
  color: var(--ink-muted);
  cursor: not-allowed;
}

/* ---------- Programs on the homepage: facts first, image as a small identifier ---------- */

.path-list {
  border-top: 1px solid var(--line-strong);
}

.path-row {
  --accent: var(--heading);
  display: grid;
  gap: var(--space-3);
  padding-block: var(--space-5);
  border-bottom: 1px solid var(--line);
}

.theme-world {
  --accent: var(--heading);
}

.theme-desert {
  --accent: var(--amber);
}

.theme-sea {
  --accent: var(--sea);
}

/* Logo or photo: small, so the facts lead (decision 035). Credits are on /about. */
.path-photo,
.path-logo,
.path-art {
  position: relative;
  margin: 0;
  height: 96px;
  overflow: hidden;
  border-radius: var(--radius);
}

.path-photo {
  background: var(--line);
}

.path-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.path-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  opacity: 0.12;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* Official logo: shown whole, on white, so its colours stay true in dark mode. */
.path-logo {
  display: grid;
  place-items: center;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  background: #ffffff;
}

/* A logo that's white on its owner's dark background (e.g. SDAIA) keeps that background. */
.path-logo--dark,
.program-logo--dark {
  border-color: transparent;
  background: #0d0e58;
}

.path-logo img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

/* Drawn scene: fallback for a program without a photo. */
.path-art {
  background: var(--surface);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.path-art-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.s-fill-1 {
  fill: var(--line);
  fill: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.s-fill-2 {
  fill: var(--line);
  fill: color-mix(in srgb, var(--accent) 34%, var(--surface));
}

.s-line-soft {
  stroke: var(--line);
  stroke: color-mix(in srgb, var(--accent) 30%, var(--surface));
  stroke-width: 1.5;
}

.s-route {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 6 6;
}

.s-dot {
  fill: var(--accent);
}

.s-dot-hollow {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
}

/* The facts column, marked with the program's accent line. */
.path-facts {
  min-width: 0;
  padding-inline-start: var(--space-4);
  border-inline-start: 3px solid var(--accent);
}

.path-addon {
  margin: 0 0 var(--space-2);
}

.path-item-name {
  margin: 0;
  font-size: 1.4rem;
}

.path-item-name a {
  text-decoration: none;
}

.path-item-name a:hover {
  text-decoration: underline;
}

.path-item-en {
  width: fit-content;
  margin: 2px 0 var(--space-1);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-align: end;  /* sits on the same side as the Arabic text */
}

.path-provider {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink);
}

.fact-list {
  display: grid;
  gap: var(--space-2);
  max-width: 680px; /* keep facts and statuses readable on wide screens */
  margin: 0 0 var(--space-3);
}

/* Phones: the label above its text, so the text gets the full width. */
.fact {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: baseline;
}

@media (min-width: 560px) {
  .fact {
    grid-template-columns: 4.5rem minmax(0, 1fr);
    gap: var(--space-3);
  }
}

.fact dt {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-muted);
}

.fact dd {
  margin: 0;
  line-height: 1.75;
}

.track-list {
  list-style: none;
  max-width: 680px;
  margin: 0 0 var(--space-3);
  padding: 0;
  border-top: 1px solid var(--line);
}

/* Each track: name + note on one side, status on the other; stacks neatly on phones. */
.track {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  padding-block: var(--space-2);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
}

.track-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.6;
}

.track-name {
  font-weight: 700;
}

.track-note {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.track-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.path-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin: 0;
}

.path-link {
  font-size: var(--text-sm);
  font-weight: 700;
}

@media (min-width: 900px) {
  /* Facts on the right (read first), the image small on the left. */
  .path-row {
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: var(--space-6);
    align-items: start;
  }

  .path-photo,
  .path-logo,
  .path-art {
    grid-column: 2;
    grid-row: 1;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .path-facts {
    grid-column: 1;
    grid-row: 1;
  }
}

/* «مفتوح للتقديم الآن» on the homepage. */
.open-item {
  display: grid;
  gap: var(--space-1) var(--space-4);
  align-items: center;
}

.open-main p,
.open-when,
.open-source {
  margin: 0;
}

.open-name {
  font-size: var(--text-base);
  font-weight: 700;
}

.open-name a {
  text-decoration: none;
}

.open-name a:hover {
  text-decoration: underline;
}

.open-program {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

@media (min-width: 760px) {
  .open-item {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
}

/* ---------- Tuwaiq band: contained, dark, quiet ---------- */

.tuwaiq {
  --focus: var(--lime); /* a forest ring would vanish on the forest band */
  padding-block: var(--space-6);
  background: var(--band);
  color: #ece9e0;
}

.tuwaiq-inner {
  display: grid;
  gap: var(--space-5);
  align-items: center;
}

@media (min-width: 900px) {
  .tuwaiq-inner {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }
}

.tuwaiq-quote {
  margin: 0;
}

.tuwaiq-quote p {
  margin: 0;
  font-family: var(--font-editorial);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.7;
  text-wrap: balance;
}

.tuwaiq-quote footer {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: #c2cbc5;
}

.tuwaiq-message {
  margin: var(--space-4) 0 0;
}

.tuwaiq-credit {
  margin: 0;
  padding-block: var(--space-2);
  font-size: var(--text-xs);
  color: #c2cbc5;
}

/* Click-to-play video: our own artwork first, YouTube only after a click. */
.video-facade {
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--space-2);
  aspect-ratio: 16 / 9;
  width: 100%;
  border: 1px solid rgba(236, 233, 224, 0.25);
  border-radius: 10px;
  background: #101713;
  color: #ece9e0;
  text-decoration: none;
}

.video-facade--empty {
  border-style: dashed;
}

.video-play {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--lime);
  color: var(--on-lime);
}

.video-play svg {
  width: 28px;
  height: 28px;
}

.video-facade:hover .video-play {
  background: #ffffff;
}

.video-label {
  font-weight: 700;
}

.video-note {
  font-size: var(--text-xs);
  color: #c2cbc5;
}

.video-source {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  color: #c2cbc5;
}

.video-source a {
  color: #ece9e0;
}

.video-player {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 10px;
}

/* ---------- Components (templates/components.html) ---------- */

/* Path steps: numbers on the start side, joined by a thin vertical line. */
.path-steps {
  list-style: none;
  counter-reset: step;
  margin: var(--space-4) 0;
  padding: 0;
}

.path-step {
  counter-increment: step;
  position: relative;
  padding-inline-start: 52px;
  padding-block-end: var(--space-4);
}

.path-step::before {
  content: counter(step, arabic-indic);
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--heading);
  border-radius: 50%;
  background: var(--paper);
  color: var(--heading);
  font-weight: 700;
  z-index: 1;
}

.path-step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-inline-start: 17.25px;
  top: 36px;
  bottom: 0;
  width: 1.5px;
  background: var(--line);
}

.path-step-title {
  margin: 4px 0 var(--space-1);
  font-size: var(--text-base);
}

.path-step p {
  margin: 0;
  color: var(--ink-muted);
}

/* Source stamp: small, quiet, like a footnote. */
.source-stamp {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-1);
  margin-block: var(--space-1) var(--space-3);
  padding-inline-start: var(--space-2);
  border-inline-start: 2px solid var(--line-strong);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.source-stamp-label {
  font-weight: 700;
}

/* Next step: the lime highlight. */
.next-step {
  margin-block: var(--space-4);
  padding: var(--space-4);
  border-radius: 10px;
  background: var(--lime);
  color: var(--on-lime);
}

.next-step p {
  margin: 0;
}

.next-step-label {
  font-size: var(--text-sm);
  font-weight: 700;
}

.next-step-text {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.55;
}

.next-step-link {
  display: inline-block;
  margin-top: var(--space-2);
  color: var(--on-lime);
  font-weight: 700;
}

/* ---------- Content pages (Markdown) ---------- */

/* The three years as one journey (decision 040): each year's job, the current one filled. */
.grade-journey ol {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}

.grade-journey a {
  display: grid;
  gap: 2px;
  min-height: 44px;
  height: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
}

.grade-journey a:hover {
  border-color: var(--heading);
}

.grade-journey-name {
  font-size: var(--text-sm);
  font-weight: 700;
}

.grade-journey-hint {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.grade-journey a[aria-current] {
  border-color: var(--heading);
  background: var(--heading);
  color: var(--on-heading);
}

.grade-journey a[aria-current] .grade-journey-hint {
  color: var(--on-heading);
}

.page-header .lead {
  margin-bottom: var(--space-2);
}

/* ---------- Grade pages (decision 038): one structure for every grade ---------- */

.grade-stage {
  margin: 0 0 var(--space-1);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-muted);
}

.prose h3 {
  scroll-margin-top: var(--space-4);
}

.grade-tool,
.grade-resources {
  margin-top: var(--space-5);
}

.grade-tool h2,
.grade-resources h2 {
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
  scroll-margin-top: var(--space-4);
}

/* ثالث ثانوي month by month (decision 040). The current month's row is marked «الآن». */
.year-list > li {
  display: grid;
  gap: var(--space-1);
  padding-inline-start: var(--space-3);
  border-inline-start: 3px solid transparent;
}

.year-list > li.is-now {
  border-inline-start-color: var(--heading);
}

.year-list p {
  margin: 0;
}

.year-when {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-muted);
}

.year-title {
  font-weight: 700;
  color: var(--heading);
}

.year-fact {
  font-size: var(--text-sm);
}

.year-sources {
  display: block;
  color: var(--ink-muted);
}

.year-upcoming {
  margin-top: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.year-upcoming-title {
  font-size: var(--text-sm);
  font-weight: 700;
}

.year-upcoming-list {
  margin: var(--space-1) 0 0;
  padding-inline-start: var(--space-4);
  font-size: var(--text-sm);
}

.tag--here {
  color: var(--on-heading);
  background: var(--heading);
  box-shadow: none;
}

.year-scholarship {
  margin-top: var(--space-4);
}

.year-scholarship h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
}

.grade-page .prose ol > li {
  margin-block: var(--space-3);
}

.resource-list > li {
  display: grid;
  gap: 2px;
}

.resource-why {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.next-grade {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
  font-weight: 700;
}

.prose h2 {
  scroll-margin-top: var(--space-4);
}

.prose h2 {
  margin-block: var(--space-5) var(--space-2);
  font-size: var(--text-lg);
}

.prose ul {
  padding-inline-start: var(--space-4);
}

.prose li {
  margin-block: var(--space-1);
}

/* ---------- Program pages ---------- */

/* Every section starts at the same edge as the table, so the page reads as one column. */
.program .measure,
.program .fact-items {
  max-width: var(--measure);
  margin-inline: 0;
}

.program-header {
  margin-block-end: var(--space-5);
}

/* The program's official logo at the top of its page: small, on a white plate. */
.program-logo {
  display: block;
  width: 250px;
  max-width: 100%;
  height: auto;
  margin-block-end: var(--space-4);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: #ffffff;
}

.program-disclaimer {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* Official links, grouped under one label instead of a row of equal links. */
.program-links {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
}

.program-links-title {
  margin: 0 0 var(--space-1);
  font-weight: 700;
  color: var(--ink-muted);
}

.program-links ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.program-links a {
  display: inline-block;
  padding-block: 2px;
  font-weight: 700;
}

.program .page-contents {
  margin-inline: 0;
}

.program-section {
  margin-block-end: var(--space-5);
}

.program-section > h2 {
  margin-block-start: var(--space-5);
}

.program-subtitle {
  margin-block: var(--space-5) var(--space-2);
}

/* Comparison table: same fields for every track. */
.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: 1.7;
}

.compare th,
.compare td {
  padding: var(--space-2) var(--space-3);
  text-align: start;
  vertical-align: top;
}

.compare thead th {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line-strong);
}

.compare tbody tr {
  border-bottom: 1px solid var(--line);
}

.compare tbody th {
  display: flex;
  flex-direction: column;
  font-weight: 400;
}

/* Phones: each track becomes a stacked block, and each value gets its column name. */
@media (max-width: 759px) {
  .compare thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .compare tr,
  .compare td {
    display: block;
  }

  .compare tbody tr {
    padding-block: var(--space-3);
  }

  .compare th,
  .compare td {
    padding: var(--space-1) 0;
  }

  .compare td::before {
    content: attr(data-label);
    display: block;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--ink-muted);
  }
}

/* Facts with their source stamps. */
.fact-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fact-item {
  padding-block: var(--space-3) var(--space-1);
  border-bottom: 1px solid var(--line);
}

.fact-text {
  margin-block-end: var(--space-1);
}

.fact-note {
  margin-block-end: var(--space-1);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.prose h3 {
  margin-block: var(--space-4) var(--space-1);
  font-size: var(--text-base);
}

.prose ol {
  padding-inline-start: var(--space-4);
}

/* ---------- Universities explorer (decision 035) ---------- */

.explorer-header .lead {
  max-width: 44em;
  margin-bottom: var(--space-2);
}

.explorer-source {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.explorer-scope {
  max-width: 44em;
  margin-block: 0 var(--space-2);
  font-size: var(--text-sm);
}

.explorer-form {
  display: grid;
  gap: var(--space-3);
  margin-block: var(--space-4) var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-strong);
}

.search-field .field-hint {
  margin-bottom: var(--space-2);
}

/* The search box and its button side by side; the suggestions open underneath. */
.search-box {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.search-submit {
  min-height: 48px;
  padding-inline: var(--space-4);
}

.filters-toggle {
  justify-self: start;
}

.filters-count {
  font-variant-numeric: tabular-nums;
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  min-width: 0; /* a fieldset is as wide as its content by default, which breaks small screens */
  margin: 0;
  padding: 0;
  border: 0;
}

.filter-hint {
  margin: var(--space-1) 0 0;
  font-size: var(--text-xs);
}

@media (min-width: 760px) {
  .filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.filters-wide {
  grid-column: 1 / -1;
}

.tracks-help > summary {
  width: fit-content;
  padding-block: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--heading);
  cursor: pointer;
}

.tracks-help[open] > summary {
  margin-bottom: var(--space-2);
}

.tracks-help p {
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
  font-weight: 700;
}

.explorer-results {
  scroll-margin-top: var(--space-4);
}

.explorer-results:focus {
  outline: none;
}

.explorer-results[aria-busy="true"] {
  opacity: 0.6;
}

/* «تبحث في:» and the removable filter tags (MOJ "filter a list" / Baymard "applied filters"). */
.applied {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.applied-label {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-muted);
}

.applied-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.applied-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 2px 14px;
  border: 1.5px solid var(--heading);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--heading);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
}

.applied-chip:hover {
  background: color-mix(in srgb, var(--heading) 10%, var(--surface-strong));
}

.applied-x {
  font-size: var(--text-xs);
}

.applied-clear {
  display: inline-block;
  padding: 6px 4px;
  font-size: var(--text-sm);
  font-weight: 700;
}

.major-summary-list {
  margin: 0;
  padding-inline-start: var(--space-4);
}

.result-section {
  margin-block-end: var(--space-5);
}

.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  border-bottom: 1px solid var(--line-strong);
}

.result-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}

.result-field {
  color: var(--ink);
}

.result-count,
.result-note,
.result-empty,
.result-explain {
  margin: var(--space-2) 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.result-count {
  font-weight: 700;
}

.result-empty {
  padding: var(--space-3) var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
}

.result-empty p:last-child {
  margin-bottom: 0;
}

/* Ranked lists stay a real table: rank, name, country, notes can be compared down the column. */
/* الرواد in a major search (decision 041): ranked names only, in columns on wide screens. */
.compact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2);
  padding-block: var(--space-2);
  border-bottom: 1px solid var(--line);
}

.compact-rank {
  min-width: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.compact-list .save-mini {
  margin-block-start: 0;
}

.compact-rank {
  line-height: 1.5;
}

.uni-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: 1.7;
}

.uni-table th,
.uni-table td {
  padding: var(--space-2) var(--space-3);
  text-align: start;
  vertical-align: top;
}

.uni-table thead th {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line-strong);
}

.uni-table tbody tr {
  border-bottom: 1px solid var(--line);
}

.uni-table tbody th {
  font-weight: 400;
}

.uni-table .uni-rank {
  width: 4.5rem;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
}

.uni-cell-notes {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}

/* Phones: rank beside the name; country and notes underneath; no column headings. */
@media (max-width: 759px) {
  .uni-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .uni-table tr {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr);
    column-gap: var(--space-2);
    padding-block: var(--space-3);
  }

  .uni-table tbody th,
  .uni-table td {
    grid-column: 2;
    padding: 0;
  }

  .uni-table td.uni-rank {
    grid-column: 1;
    grid-row: 1 / span 3;
    width: auto;
    line-height: 1.5;
  }

  .uni-cell-country {
    margin-top: 2px;
  }

  .uni-cell-notes:empty {
    display: none;
  }
}

.uni-name {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.5;
  text-decoration: none;
}

.uni-name-ar {
  font-size: var(--text-base);
  font-weight: 700;
}

.uni-name-en {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-align: end;  /* dir="ltr", so "end" is the right side, under the Arabic name */
}

a.uni-name:hover .uni-name-ar,
a.uni-name:hover .uni-name-en:only-child {
  text-decoration: underline;
}

.uni-name + .save-mini {
  margin-block-start: var(--space-1);
}

.uni-country {
  font-size: var(--text-sm);
}

.uni-deadline {
  font-size: var(--text-sm);
  color: var(--ink);
}

/* «باختصار» in a result row: SAT/ACT · IELTS · the next university date · the admissions page (decision 038). */
.key-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-3);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink);
}

.key-facts--unknown {
  color: var(--ink-muted);
}

.req-past {
  color: var(--ink-muted);
}

.uni-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.uni-item {
  display: grid;
  gap: var(--space-1);
  padding-block: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.uni-item-name {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-1) var(--space-3);
}

.uni-item-meta,
.memberships {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
}

/* ---------- One university (decision 035) ---------- */

.uni-header h1 {
  margin-bottom: 0;
}

.uni-header-en {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  color: var(--ink-muted);
  text-align: end;  /* dir="ltr": under the Arabic name, on the same side */
  width: fit-content;
}

.uni-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
}

/* «احفظ في قائمتي»: an outlined button beside the facts, never louder than them. */
.save-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}

.save-toggle svg {
  fill: none;
}

.save-toggle.is-saved svg {
  fill: currentColor;
}

/* «احفظ» in a result row (decision 039): small, but a full 32px target. */
.save-mini {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-block-start: var(--space-1);
  padding: 0 12px;
  border: 1.5px solid var(--heading);
  border-radius: 999px;
  background: transparent;
  color: var(--heading);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
}

.save-mini:hover {
  background: color-mix(in srgb, var(--heading) 10%, transparent);
}

.save-mini.is-saved {
  border-color: var(--heading);
  background: var(--heading);
  color: var(--on-heading);
}

/* Until mylist.js is ready: keep the space (no layout jump), but don't show or announce it. */
.save-mini[data-pending] {
  visibility: hidden;
}

.save-note {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

/* «باختصار»: the answers, before the details. */
.uni-summary {
  margin-block: var(--space-4) var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-strong);
}

.uni-summary-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lg);
}

.uni-summary .notice {
  margin-block: var(--space-3) 0;
  background: var(--surface);
}

.uni-summary .actions {
  margin-block: var(--space-3) 0;
}

/* «في هذه الصفحة»: jump links for long pages (GOV.UK "contents list"). */
.page-contents {
  margin-block: 0 var(--space-5);
  font-size: var(--text-sm);
}

.page-contents-title {
  margin: 0 0 var(--space-1);
  font-weight: 700;
  color: var(--ink-muted);
}

.page-contents ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.page-contents a {
  display: inline-block;
  padding-block: 2px;
  font-weight: 700;
}

.uni-section {
  margin-block: var(--space-5);
  scroll-margin-top: var(--space-4);
}

.uni-section > h2 {
  margin-block: 0 var(--space-3);
}

.uni-track {
  margin-block-end: var(--space-4);
}

.uni-track h3 {
  margin-block: var(--space-4) var(--space-2);
}

.uni-track-rank {
  margin-inline-start: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* The doctorate lists, folded. */
.rnd-lists {
  margin-block: var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.rnd-lists > summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
}

.rnd-title {
  font-weight: 700;
  color: var(--heading);
}

.rnd-title::before {
  content: "▸ ";
}

.rnd-lists[open] .rnd-title::before {
  content: "▾ ";
}

.rnd-note {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.rnd-lists > summary::-webkit-details-marker {
  display: none;
}

.rnd-lists > summary {
  list-style: none;
}

.rnd-lists > .field-blocks {
  padding-inline: var(--space-4);
}

.uni-majors-title {
  margin: var(--space-2) 0 var(--space-1);
  font-weight: 700;
  font-size: var(--text-sm);
}

.major-list {
  margin: 0 0 var(--space-2);
  padding-inline-start: var(--space-4);
  font-size: var(--text-sm);
  columns: 1;
}

.req-scores {
  margin: 0;
  padding-inline-start: var(--space-4);
}

.req-scores li + li {
  margin-top: var(--space-1);
}

/* The university's own dates: date first, so they scan down the column. */
.uni-dates > li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.uni-date {
  min-width: 9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.uni-date-label {
  flex: 1 1 16rem;
}

.req-past .uni-date {
  color: var(--ink-muted);
  text-decoration: line-through;
}

/* ---------- «قائمتي» ---------- */

.mylist-privacy {
  max-width: 44em;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.mylist-rows {
  margin-top: var(--space-4);
}

.mylist-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.mylist-main {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  flex: 1 1 18rem;
}

.btn--small {
  min-height: 40px;
  padding: 4px 14px;
  font-size: var(--text-sm);
}

.mylist-empty {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

.mylist-empty-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--heading);
}

.mylist-loading {
  color: var(--ink-muted);
}

/* Phones (up to 479px, e.g. iPhone 13 at 390px): icon-only header buttons, so the header never overflows. */
@media (max-width: 479px) {
  .mylist-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .mylist-link {
    padding: 0 10px;
  }
}

/* واعد: the latest programs, in a toggle under the track list. */
.waaid-latest {
  max-width: 660px;
  margin-block: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.waaid-latest > summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

.waaid-summary-title {
  font-weight: 700;
  color: var(--heading);
}

.waaid-summary-title::before {
  content: "▸ ";
}

.waaid-latest[open] .waaid-summary-title::before {
  content: "▾ ";
}

.waaid-summary-note {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.waaid-list {
  margin: 0;
  padding: 0 var(--space-3);
  list-style: none;
}

.waaid-item {
  padding-block: var(--space-3);
  border-top: 1px solid var(--line);
}

.waaid-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  margin: 0 0 var(--space-1);
}

.waaid-meta {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.waaid-req {
  margin: var(--space-1) 0 0;
  padding-inline-start: var(--space-4);
  font-size: var(--text-sm);
}

.waaid-latest > .source-stamp {
  margin: 0;
  padding: var(--space-2) var(--space-3);
}

.target-list {
  columns: 2;
  column-gap: var(--space-5);
  padding-inline-start: var(--space-4);
}

@media (min-width: 800px) {
  .target-list {
    columns: 3;
  }
}

/* Search suggestions: our own panel (the browser's list can't be styled and scrolls too fast). */
.suggest {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 4px);
  z-index: 20;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;  /* scrolling the list never scrolls the page behind it */
  padding-block: var(--space-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: 0 10px 30px rgba(16, 23, 19, 0.16);
}

.suggest-group {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: var(--space-2) var(--space-3) var(--space-1);
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--heading);
}

.suggest-option {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 44px;
  padding: 10px var(--space-3);
  line-height: 1.5;
  cursor: pointer;
}

.suggest-option small {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.suggest-option[aria-selected="true"],
.suggest-option:hover {
  background: color-mix(in srgb, var(--heading) 10%, var(--surface-strong));
}

.suggest-option[aria-selected="true"] {
  box-shadow: inset -3px 0 0 var(--heading);
}

.suggest-empty {
  margin: 0;
  padding: var(--space-3);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* University page: one block per field (rank + majors), no clicking needed. */
.field-blocks {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.field-block {
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--line);
}

.field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  margin-block-end: var(--space-2);
}

.field-rank {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--heading) 10%, var(--paper));
  color: var(--heading);
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.field-rank-label {
  font-size: var(--text-xs);
}

.field-name {
  flex: 1;
  font-weight: 700;
  font-size: var(--text-base);
}

.field-block .major-list {
  columns: 1;
}

@media (min-width: 700px) {
  .field-block .major-list {
    columns: 2;
    column-gap: var(--space-5);
  }
}

.major-list--only {
  font-weight: 700;
}

.more-majors summary {
  cursor: pointer;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--heading);
}

.field-src {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.waaid-list--results {
  padding: 0;
}

.credits {
  padding-inline-start: var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.credits li {
  margin-block: var(--space-2);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: 1.8;
  padding-block: var(--space-5) var(--space-4);
}

.footer-grid {
  display: grid;
  gap: var(--space-5);
}

.footer-grid p {
  margin: 0 0 var(--space-2);
}

.footer-brand {
  font-family: var(--font-editorial);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--heading);
}

.footer-promise {
  max-width: 34em;
  font-weight: 700;
  color: var(--ink);
}

/* The owner's X account: a small icon under the footer text, in the footer's own colours. */
/* The X link: an icon tile plus one line inviting feedback (decision 043). */
.footer-x {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  margin-top: var(--space-2);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.footer-x-icon {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.footer-x:hover {
  color: var(--heading);
}

.footer-x:hover .footer-x-icon {
  border-color: var(--heading);
}

.footer-x svg {
  width: 16px;
  height: 16px;
}

/* ---------- Very narrow phones (e.g. 320–379px) ---------- */

@media (max-width: 379px) {
  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-name {
    font-size: 1.6rem;
  }
}

/* Phones up to 479px (most iPhones are 375–430px): icons only in the header, so it never overflows. */
@media (max-width: 479px) {
  .theme-toggle,
  .menu-button {
    padding: 0 10px;
  }

  /* Icons only; the buttons keep their accessible names. */
  .theme-toggle-label,
  .menu-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* ---------- Wider screens ---------- */

@media (min-width: 768px) {
  :root {
    --text-xl: 1.75rem;
    --text-2xl: 2.375rem;
  }

  .tuwaiq-quote p {
    font-size: 2.1rem;
  }

  .path-item-name {
    font-size: 1.65rem;
  }
}
