/* ═══════════════════════════════════════════════════════════════
   UX PHASE 2 — Animations · Smart Search · Timeline View
   مدارس المجد الأهلية
   ═══════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────
   A) PAGE TRANSITION ANIMATIONS
   Uses CSS `translate` (individual property) so it composes
   safely alongside transform:scale in presentation mode
   ─────────────────────────────────────────────────────────────- */
@keyframes ux-enter-next {
  from { opacity: 0; translate: 36px 0; }
  to   { opacity: 1; translate:  0px 0; }
}
@keyframes ux-enter-prev {
  from { opacity: 0; translate: -36px 0; }
  to   { opacity:  1; translate:   0px 0; }
}
almajd-page.ux-anim-next {
  animation: ux-enter-next 0.34s cubic-bezier(0.4, 0, 0.2, 1) both;
}
almajd-page.ux-anim-prev {
  animation: ux-enter-prev 0.34s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ──────────────────────────────────────────────────────────────
   B) SMART SEARCH PANEL
   ─────────────────────────────────────────────────────────────- */
.ux-search-section {
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(160deg, var(--surface-3) 0%, var(--surface) 100%);
  flex-shrink: 0;
}

/* Search input */
.ux-search-wrap {
  position: relative;
  margin-bottom: 8px;
}
.ux-search-wrap input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 9px 38px 9px 11px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.ux-search-wrap input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(35,220,213,.12);
}
.ux-search-icon {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
  opacity: .5;
}

/* Stage filter */
.ux-stage-filter {
  margin-bottom: 9px;
}
.ux-stage-filter select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 11px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  color: var(--navy);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.ux-stage-filter select:focus { border-color: var(--cyan); }

/* Results container */
.ux-results {
  max-height: 230px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* Single result card */
.ux-result-card {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
  user-select: none;
}
.ux-result-card:hover {
  border-color: var(--navy);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.ux-result-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  flex-shrink: 0;
}
.ux-result-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ux-result-stage {
  font-size: 9px;
  font-weight: 900;
  color: var(--muted);
  margin-top: 2px;
}
.ux-result-card mark {
  background: rgba(227,188,52,.38);
  color: inherit;
  border-radius: var(--radius-pill);
  padding: 0 2px;
}
.ux-no-results {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 16px;
}
.ux-search-hint {
  font-size: 10px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  padding: 8px 0 0;
  line-height: 1.7;
}
.ux-search-hint kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 17px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--navy);
  font-weight: 900;
  font-size: 9px;
  padding: 0 4px;
  font-family: inherit;
}

/* ──────────────────────────────────────────────────────────────
   C) TIMELINE VIEW
   ─────────────────────────────────────────────────────────────- */

/* Toggle button in topbar */
.ux-tl-toggle-btn {
  position: relative;
  background: linear-gradient(135deg, var(--navy), var(--navy2)) !important;
  color: #fff !important;
}
.ux-tl-toggle-btn::after {
  content: 'جديد';
  position: absolute;
  inset-inline-start: 7px;
  top: -9px;
  background: var(--gold);
  color: #10213d;
  border-radius: var(--radius-pill);
  padding: 1px 5px;
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}
body[data-ux-view="timeline"] .ux-tl-toggle-btn {
  background: var(--gradient-accent) !important;
  color: #10213d !important;
}

/* Timeline container */
#ux-timeline {
  display: none;
  direction: rtl;
  padding-bottom: 48px;
  animation: ux-enter-next 0.38s cubic-bezier(0.4,0,0.2,1) both;
}
body[data-ux-view="timeline"] #ux-timeline        { display: block; }
body[data-ux-view="timeline"] #book               { display: none !important; }
body[data-ux-view="timeline"] #v2ReviewBoard      { display: none !important; }
body[data-ux-view="timeline"] #v2StageStrip       { display: none !important; }

/* Timeline header banner */
.ux-tl-header {
  padding: 22px 22px 20px;
  background: var(--gradient-brand);
  color: #fff;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.ux-tl-header::before {
  content: '';
  position: absolute;
  inset-inline-end: -30px;
  top: -30px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(35,220,213,.18), transparent 70%);
}
.ux-tl-header::after {
  content: '٩٨';
  position: absolute;
  left: 14px;
  bottom: -22px;
  font-size: 96px;
  font-weight: 900;
  color: rgba(255,255,255,.055);
  line-height: 1;
}
.ux-tl-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 900;
  position: relative;
}
.ux-tl-header p {
  margin: 0;
  opacity: .74;
  font-size: 12px;
  font-weight: 800;
  position: relative;
}
.ux-tl-kpis {
  display: flex;
  gap: 12px;
  margin-top: 14px;
  position: relative;
  flex-wrap: wrap;
}
.ux-tl-kpi {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  min-width: 70px;
}
.ux-tl-kpi strong { display: block; font-size: 22px; font-weight: 900; line-height: 1; }
.ux-tl-kpi span   { display: block; font-size: 10px; font-weight: 900; opacity: .75; margin-top: 3px; }

/* Stage list */
.ux-tl-stages {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.ux-tl-stages::before {
  content: '';
  position: absolute;
  inset-inline-end: 44px;
  top: 26px;
  bottom: 26px;
  width: 3px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--cyan) 100%);
  border-radius: 3px;
  opacity: .28;
  z-index: 0;
}

/* Single stage card */
.ux-tl-stage {
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: 12px;
  align-items: start;
  background: var(--surface);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 14px 14px 14px 16px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
  position: relative;
  z-index: 1;
}
.ux-tl-stage:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateX(-3px);
}
.ux-tl-stage.ux-current-stage {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(227,188,52,.18), var(--shadow-md);
}

/* Stage body */
.ux-tl-stage-label {
  font-size: 10px;
  font-weight: 900;
  color: var(--cyan);
  letter-spacing: .05em;
  margin-bottom: 3px;
}
.ux-tl-stage-title {
  font-size: 14px;
  font-weight: 900;
  color: var(--navy);
  margin-bottom: 10px;
  line-height: 1.4;
}

/* Page dots grid */
.ux-tl-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ux-tl-dot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: 1.5px solid var(--line);
  color: var(--navy);
  font-size: 9px;
  font-weight: 900;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
  position: relative;
}
.ux-tl-dot:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  transform: scale(1.18);
  z-index: 2;
}
.ux-tl-dot.ux-active-page {
  background: var(--gradient-accent);
  border-color: transparent;
  color: #10213d;
  box-shadow: var(--shadow-sm);
  transform: scale(1.14);
  z-index: 2;
}

/* Stage node (circular number on right) */
.ux-tl-node {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--gradient-brand);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  transition: background .2s, box-shadow .2s;
  margin-top: 2px;
}
.ux-tl-node.ux-current-node {
  background: var(--gradient-accent);
  color: #10213d;
  box-shadow: var(--shadow-md);
}

/* Print: hide UX additions */
@media print {
  #ux-timeline,
  .ux-search-section,
  .ux-tl-toggle-btn { display: none !important; }
}

/* Responsive */
@media (max-width: 900px) {
  .ux-tl-kpis { gap: 8px; }
  .ux-tl-kpi  { padding: 6px 10px; }
  .ux-tl-kpi strong { font-size: 18px; }
  .ux-tl-stages::before { display: none; }
  .ux-tl-stage { grid-template-columns: 1fr 44px; }
  .ux-tl-node  { width: 44px; height: 44px; font-size: 16px; }
}
