/* وصلها 4 — page compositions (design doc §5). */

/* ---------- Today ---------- */
.today-hero { display: grid; gap: var(--space-2); }
.today-hero .display { font-size: var(--text-2xl); }
.today-greeting { color: var(--text-2); font-size: var(--text-sm); }
.resume {
  position: relative; display: grid; gap: var(--space-4); padding: var(--card-pad);
  border-radius: var(--radius-sheet); border: 1px solid var(--line);
  background:
    radial-gradient(600px 240px at 100% 0%, color-mix(in srgb, var(--ribbon) 16%, transparent), transparent 70%),
    var(--grain), var(--surface-1);
}
.resume-title { display: grid; gap: var(--space-1); }
.resume-title h2 { font-size: var(--text-xl); }
.resume-place { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); color: var(--text-2); font-size: var(--text-sm); line-height: var(--leading-ui); }
.resume-foot { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-4); }
.resume-foot .meters { flex: 1 1 260px; max-width: 420px; }
.next-steps { display: grid; gap: var(--space-3); grid-template-columns: 1fr; }
.step-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--space-3); padding: var(--space-4); line-height: var(--leading-ui); }
.step-card strong { font-size: var(--text-md); }
.step-card small { display: block; font-size: var(--text-sm); color: var(--text-2); }
.step-card .step-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-card); background: var(--accent-soft); color: var(--accent); }
.step-card strong { display: block; font-weight: 600; }
.step-card small { color: var(--text-2); }
/* Two steps fill the row instead of leaving a third of it empty. */
@media (min-width: 900px) { .next-steps { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } .step-card { grid-template-columns: auto 1fr; } .step-card .row-arrow { display: none; } }

/* ---------- Subject cards ---------- */
.subject-grid { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .subject-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .subject-grid.is-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.subject-card {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4);
  min-height: 208px; padding: var(--space-6) var(--card-pad) var(--card-pad); overflow: hidden; isolation: isolate;
}
.subject-card-body { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.subject-card .subject-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xl); line-height: var(--leading-ui); overflow-wrap: normal; word-break: normal; text-wrap: balance; }
.subject-card .subject-en { color: var(--text-2); font-size: var(--text-sm); text-align: end; }
.subject-card .subject-meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); color: var(--text-2); font-size: var(--text-sm); margin-block: var(--space-2) 0; }
.subject-meta > span { white-space: nowrap; }
.subject-card .subject-action { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-block-start: auto; padding-block-start: var(--space-4); color: var(--accent); font-size: var(--text-sm); font-weight: 600; }
/* The meter sits at the bottom, so cards in one row line up whatever the title length. */
.subject-card .meter { margin-block-start: auto; padding-block-start: var(--space-4); }
.subject-photo { position: absolute; inset-block: 0; inset-inline-end: 0; width: 40%; z-index: -1; opacity: .2;
  mask-image: linear-gradient(to left, #000 15%, transparent 92%); -webkit-mask-image: linear-gradient(to left, #000 15%, transparent 92%);
  filter: grayscale(.35) contrast(1.05); }
[dir="rtl"] .subject-photo { mask-image: linear-gradient(to right, #000 15%, transparent 92%); -webkit-mask-image: linear-gradient(to right, #000 15%, transparent 92%); }
.subject-photo img { width: 100%; height: 100%; object-fit: cover; }
.subject-card.is-compact { min-height: 0; grid-template-columns: 1fr; }
.subject-card.is-compact .subject-name { font-size: var(--text-lg); }
.subject-card.is-compact .meter { padding-block-start: var(--space-3); }
.subject-card.is-compact .meter-label { flex-wrap: wrap; gap: 0 var(--space-2); }
.subject-strip { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
/* Phones: two short tiles per row instead of six tall cards. */
@media (max-width: 639px) {
  .subject-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subject-strip .subject-card { padding: var(--space-5) var(--space-3) var(--space-3); }
  .subject-strip .subject-meta { margin-block-start: var(--space-1); font-size: var(--text-xs); }
}

/* ---------- Subject page ---------- */
.subject-hero { position: relative; display: grid; gap: var(--space-3); padding-block: var(--space-4) var(--space-2); isolation: isolate; overflow: clip; border-radius: var(--radius-sheet); }
.subject-hero .display { color: var(--text); }
.subject-hero .display-en { color: var(--text-3); font-size: var(--text-lg); font-weight: 500; }
.subject-hero-photo { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(52%, 520px); z-index: -1; opacity: .35;
  mask-image: radial-gradient(closest-side, #000 30%, transparent); -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent); }
.subject-hero-photo img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.4); }
.hero-stats { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-6); margin-block-start: var(--space-2); }
.hero-stat { display: grid; gap: var(--space-1); }
.hero-stat .numeral { font-size: var(--text-2xl); color: var(--text); }
.hero-stat small { font-size: var(--text-sm); }
.hero-stat small { color: var(--text-2); }
.hero-ribbon { width: 56px; height: 6px; border-radius: var(--radius-pill); background: var(--ribbon); }

/* ---------- Lecture rows ---------- */
.lecture-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.lecture-row {
  position: relative; display: grid; grid-template-columns: var(--space-7) minmax(0, 1fr); gap: var(--space-4); align-items: start;
  padding: var(--card-pad);
}
/* The number sits in a tile so "١" reads as a numeral, not a bar. */
.lecture-row .lecture-number { display: grid; place-items: center; width: var(--space-7); aspect-ratio: 1; border: 1px solid var(--line-strong); border-radius: var(--radius-control); background: var(--surface-2); font-family: var(--font-display); font-weight: 800; font-size: var(--text-xl); line-height: 1; color: var(--ribbon); }
.lecture-row .lecture-status { grid-column: 2; }
.lecture-row .lecture-kicker { color: var(--text-3); font-size: var(--text-xs); }
.lecture-row h3 { font-size: var(--text-lg); }
.lecture-row .lecture-en { display: block; color: var(--text-3); font-size: var(--text-sm); }
.lecture-row .lecture-facts { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-block-start: var(--space-2); }
.lecture-row .meters { margin-block-start: var(--space-3); max-width: 460px; }
@media (min-width: 900px) {
  .lecture-row { grid-template-columns: var(--space-7) minmax(0, 1fr) 260px; align-items: center; }
  .lecture-row .lecture-status { grid-column: auto; }
  .lecture-row .meters { margin: 0; }
}

/* ---------- Lecture page ---------- */
.lecture-head { display: grid; gap: var(--space-3); }
.lecture-head .lecture-en { color: var(--text-3); }
/* «الملف PDF · صفحة ١٢»: where the reader will open. */
.btn-note { padding-inline-start: var(--space-2); border-inline-start: 1px solid color-mix(in srgb, currentColor 40%, transparent); font-weight: 500; opacity: .9; }
/* Phones: «الملف PDF» across the full width, the two other actions side by side below it. */
@media (max-width: 479px) {
  .lecture-head .btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lecture-head .btn-row .btn-primary { grid-column: 1 / -1; }
}
.panel { display: grid; gap: var(--space-4); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.panel-head h2 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xl); }
.panel-head h2 .icon { color: var(--accent); }
.level-cards { display: grid; gap: var(--space-3); grid-template-columns: 1fr; }
@media (min-width: 640px) { .level-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.level-card { display: grid; gap: var(--space-2); padding: var(--card-pad); text-align: start; font: inherit; color: inherit; line-height: var(--leading-ui); }
.level-card .level-name { font-weight: 600; font-size: var(--text-md); }
.level-card .level-score { font-family: var(--font-display); font-weight: 800; font-size: var(--text-xl); line-height: 1; }
.level-card small { color: var(--text-2); font-size: var(--text-sm); }
.side-stack { display: grid; gap: var(--space-4); }
.side-stack .card h2 { font-size: var(--text-lg); margin-block-end: var(--stack); }
.file-links { list-style: none; margin: 0; padding: 0; display: grid; }
.file-links li + li { border-block-start: 1px solid var(--line); }
.file-links a { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-height); color: var(--text); font-size: var(--text-md); line-height: var(--leading-ui); text-decoration: none; }
.file-links a:hover { color: var(--accent); }
.file-links .icon { flex: none; color: var(--text-3); }
.file-link-text { display: grid; padding-block: var(--space-2); }
.file-link-text small { color: var(--text-3); font-size: var(--text-xs); }

/* ---------- Video topics ---------- */
.video-stage { display: grid; gap: var(--space-4); }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-card); overflow: hidden; background: #000; border: 1px solid var(--line); }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-poster { position: absolute; inset: 0; display: grid; place-items: center; gap: var(--space-3); padding: var(--space-5); text-align: center; background: radial-gradient(circle at 50% 40%, var(--surface-2), #000); color: var(--text); }
.play-button { display: grid; place-items: center; width: var(--space-8); height: var(--space-8); border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); }
.play-button .icon { width: 28px; height: 28px; margin-inline-start: 4px; fill: currentColor; }
.topic-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.topic-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--space-3); width: 100%; padding: var(--space-3) var(--space-4); border: 1px solid transparent; border-radius: var(--radius-card); background: none; text-align: start; font: inherit; color: var(--text-2); }
.topic-item:hover { background: var(--surface-1); color: var(--text); }
.topic-item[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.topic-item .numeral { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-control); background: var(--surface-2); font-size: var(--text-sm); color: var(--text-2); }
.topic-item[aria-current="true"] .numeral { background: var(--accent); color: var(--on-accent); }
.topic-item small { display: block; color: var(--text-3); }

/* ---------- Quiz runner ---------- */
.quiz { max-width: 760px; margin-inline: auto; width: 100%; display: grid; gap: var(--space-4); padding: var(--space-4); }
.quiz-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--space-3); padding-block: var(--space-3); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); }
.quiz-progress { flex: 1; display: flex; gap: var(--space-1); }
.quiz-progress span { flex: 1; height: var(--space-1); border-radius: var(--radius-pill); background: var(--surface-3); }
.quiz-progress span.is-done { background: var(--text-3); }
.quiz-progress span.is-correct { background: var(--success); }
.quiz-progress span.is-wrong { background: var(--danger); }
.quiz-progress span.is-current { background: var(--accent); }
.question-card { display: grid; gap: var(--space-4); padding: var(--card-pad); }
.question-text { font-size: var(--text-xl); line-height: var(--leading-ui); font-weight: 500; }
.question-text[lang="en"] { text-align: left; }
.options { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.option {
  display: grid; grid-template-columns: var(--control-sm) minmax(0, 1fr) auto; align-items: center; gap: var(--space-3);
  width: 100%; min-height: var(--control-height); padding: var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-card);
  background: var(--surface-1); color: var(--text); font: inherit; font-size: var(--text-md); line-height: var(--leading-ui); text-align: start;
  transition: border-color var(--fast) var(--ease-out), background var(--fast) var(--ease-out);
}
.option:hover:not(:disabled) { border-color: var(--control); background: var(--surface-2); }
.option-key { display: grid; place-items: center; width: var(--control-sm); height: var(--control-sm); border-radius: var(--radius-control); border: 1px solid var(--line-strong); color: var(--text-2); font-family: var(--font-mono); font-size: var(--text-sm); }
.option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
/* The chosen key fills in, so selection is not shown by colour of the border alone. */
.option[aria-pressed="true"] .option-key { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.option.is-correct { border-color: var(--success); background: var(--success-soft); }
.option.is-correct .option-key { border-color: var(--success); color: var(--success); }
.option.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.option.is-wrong .option-key { border-color: var(--danger); color: var(--danger); }
.option:disabled { cursor: default; }
.option-mark { font-size: var(--text-sm); font-weight: 600; }
.feedback { display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4); font-size: var(--text-md); line-height: var(--leading-ui); border-radius: var(--radius-card); border: 1px solid var(--line); background: var(--surface-1); }
.feedback.is-correct { border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.feedback.is-wrong { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.feedback-title { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; }
.feedback.is-correct .feedback-title { color: var(--success); }
.feedback.is-wrong .feedback-title { color: var(--danger); }
.quiz-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: space-between; align-items: center; }

/* ---------- Results ---------- */
.result-hero { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-4); text-align: center; }
.result-score { font-family: var(--font-display); font-weight: 900; font-size: var(--text-display); line-height: 1.1; color: var(--accent); }
.result-score small { font-size: var(--text-lg); color: var(--text-2); font-weight: 700; }

/* ---------- Auth / welcome ---------- */
.welcome { display: grid; gap: var(--page-gap); align-items: center; min-height: calc(100dvh - var(--topbar-height) - var(--space-8)); padding-block: var(--space-6); }
@media (min-width: 960px) { .welcome { grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); } }
.welcome-statement .display em { font-style: normal; color: var(--accent); }
.welcome-points { list-style: none; margin: var(--space-5) 0 0; padding: 0; display: grid; gap: var(--space-4); line-height: var(--leading-ui); }
.welcome-points li { display: grid; grid-template-columns: var(--control-sm) 1fr; gap: var(--space-3); align-items: start; }
.welcome-points .icon-wrap { display: grid; place-items: center; width: var(--control-sm); height: var(--control-sm); border-radius: var(--radius-card); background: var(--surface-1); border: 1px solid var(--line); color: var(--accent); }
.welcome-points strong { display: block; }
.welcome-points p { color: var(--text-2); font-size: var(--text-sm); }
.auth-card { display: grid; gap: var(--space-4); padding: var(--card-pad); }

/* ---------- Glossary & timetable ---------- */
.term-card { display: grid; gap: var(--space-2); }
.term-card .term-en { font-size: var(--text-lg); font-weight: 600; text-align: left; }
.term-card .term-ar { color: var(--text); }
.term-card .term-note { color: var(--text-2); font-size: var(--text-sm); }
.day-list { display: grid; gap: var(--space-3); }
.session-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: var(--space-4); align-items: center; }
.session-time { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Search dialog ---------- */
.search-dialog { width: min(640px, calc(100vw - 2 * var(--space-4))); margin-block-start: 10vh; }
.search-results { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); max-height: 55vh; overflow: auto; }
.search-result { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); border-radius: var(--radius-control); color: var(--text); text-decoration: none; }
.search-result[aria-selected="true"], .search-result:hover { background: var(--accent-soft); color: var(--text); }
.search-result small { display: block; color: var(--text-3); }
.today-sessions .session-time { display: grid; gap: 2px; min-width: 88px; font-size: var(--text-md); white-space: nowrap; }
.today-sessions .list-row { border-inline-start: 3px solid var(--ribbon, var(--line-strong)); }
/* Public titles only. Study payloads are still checked by the server gate. */
.public-catalogue{max-inline-size:76rem;margin-inline:auto}
.public-catalogue-nav{display:flex;align-items:center;flex-wrap:wrap;gap:1.25rem;margin-block-end:2rem}
.public-catalogue-nav .btn{margin-inline-start:auto}
.public-subject-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,17rem),1fr));gap:1rem;margin-block:1.5rem}
.public-subject-card{display:flex;flex-direction:column;gap:.5rem;text-decoration:none;min-inline-size:0;padding:1.5rem}
.public-subject-card h2{font-size:clamp(1.3rem,3vw,1.8rem);line-height:1.6;overflow-wrap:normal;word-break:normal}
.public-subject-card p{margin:0}.public-subject-card span{margin-block-start:1rem}
.public-lecture-list{display:grid;gap:1rem;margin-block:1.5rem}
.public-lecture-card{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:1rem;padding:1.25rem}
.public-lecture-card>div{min-inline-size:0;flex:1 1 20rem}
.public-lecture-card h2{font-size:1.25rem;line-height:1.7;overflow-wrap:anywhere}
.public-catalogue-nav a,.public-subject-card{outline-offset:4px}
.interactive-explained{max-inline-size:86rem;margin-inline:auto}
.explain-layout{display:grid;grid-template-columns:minmax(14rem,19rem) minmax(0,1fr);gap:1.5rem;align-items:start}
.explain-layout>div,.explain-index,.explain-content{min-inline-size:0}
.explain-index{position:sticky;inset-block-start:1rem;padding:1rem;max-block-size:82vh;overflow:auto}
.explain-index ol{padding-inline-start:1.5rem;margin-block:1rem}
.explain-index li{margin-block:.25rem}
.explain-index [data-topic]{text-align:start;inline-size:100%;padding:.6rem;border:0;border-radius:4px;background:transparent;color:inherit;font:inherit;cursor:pointer}
.explain-index [aria-current]{background:var(--accent);color:var(--bg)}
.explain-content{padding:clamp(1rem,3vw,2.5rem);scroll-margin-block-start:1rem}
.explain-content h2{font-size:clamp(1.4rem,2.5vw,2rem);line-height:1.6}
.explain-content p,.explain-content li,.explain-appendix p{line-height:1.95;overflow-wrap:anywhere}
.explain-copy{font-size:1.12rem}.explain-copy p{margin-block:1rem 1.5rem}
.explain-source{font-size:.9rem;color:var(--text-2)}
.explain-formula{white-space:pre-wrap;overflow-wrap:anywhere;padding:1rem;border-inline-start:3px solid var(--accent);font-size:1.1rem;line-height:1.8}
.explain-terms{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,12rem),1fr));gap:.75rem;margin-block:1.5rem}
.explain-terms>div{border-block-end:1px solid var(--line);padding:.75rem}.explain-terms dd{margin:0}
.explain-diagram{margin:2rem 0;padding:1rem;border:1px solid var(--line);border-radius:4px}
.explain-diagram figcaption{line-height:1.8;font-weight:700;margin-block-end:1rem}
.explain-flow{display:grid;gap:.75rem}.explain-node{display:flex;align-items:center;gap:1rem;inline-size:100%;padding:1rem;background:var(--bg);color:inherit;border:1px solid var(--line);font:inherit;text-align:start;border-radius:4px;cursor:pointer}
.explain-node-number{display:grid;place-items:center;flex:0 0 2rem;block-size:2rem;border:1px solid currentColor;border-radius:50%}
.explain-node[aria-pressed=true],.explain-plot-controls [aria-pressed=true]{border-color:var(--accent);box-shadow:inset 3px 0 0 var(--accent)}
.explain-plot{display:block;inline-size:100%;block-size:auto;overflow:hidden;direction:ltr}
.explain-plot [data-plot-item]{opacity:.4}.explain-plot .is-selected{opacity:1;color:var(--accent)}
.explain-plot-controls{display:flex;flex-wrap:wrap;gap:.5rem}
.explain-plot-controls .btn{max-inline-size:100%;white-space:normal;overflow-wrap:anywhere;text-align:start;line-height:1.7}
.explain-table-scroll{overflow:auto;max-inline-size:100%}.explain-table-scroll table{border-collapse:collapse;inline-size:100%;font-size:1rem}.explain-table-scroll :is(th,td){border:1px solid var(--line);padding:.75rem;min-inline-size:7rem;line-height:1.6;text-align:start}
.explain-example,.explain-check,.explain-english{margin-block:1.25rem;padding:1rem;border-block-start:1px solid var(--line)}
.explain-content summary,.explain-appendix summary{cursor:pointer;line-height:1.8;min-block-size:2.75rem;align-content:center}
.explain-options{display:grid;gap:.75rem}.explain-options button{justify-content:start;white-space:normal;text-align:start;line-height:1.7}
.explain-navigation{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:.75rem;padding-block:1.5rem}
.explain-appendix{margin-block:1rem;padding:1rem}
@media(max-width:850px){.explain-layout{grid-template-columns:minmax(0,1fr)}.explain-index{position:static;max-block-size:none}.explain-index ol{display:none}.explain-navigation>p{order:-1;flex-basis:100%;text-align:center}}
