/* =====================================================================
   Al Hadi — shared graphics & motion (app screens, website pages, dashboards)
   Pure CSS animation on transform/opacity only (cheap on phones).
   Switched off automatically for "reduce motion" and trimmed on low-end phones.
   ===================================================================== */

/* ---------- themed banner at the top of every app screen ---------- */
.m-banner {
  --mb1: #fdf1d4; --mb2: #f7dca4; --m1: #8b1a1a; --m2: #c9982a;
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  overflow: hidden; border-radius: 18px; padding: 14px 16px; margin: 10px 0 14px; min-height: 84px;
  background: linear-gradient(135deg, var(--mb1), var(--mb2));
  border: 1px solid rgba(0, 0, 0, .06); box-shadow: 0 6px 18px rgba(94, 15, 15, .10);
  animation: mBannerIn .6s cubic-bezier(.2, .8, .3, 1) both;
}
.m-banner::after {                       /* soft light sweep across the banner */
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 30%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: skewX(-18deg); animation: mSweep 7s ease-in-out 1.2s infinite;
}
.m-txt { position: relative; z-index: 1; min-width: 0; }
.m-txt em { display: block; font-style: normal; font-size: 10.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--m1); opacity: .85; margin-bottom: 3px; }
.m-txt b { display: block; font-family: 'Playfair Display', Georgia, serif; font-size: 15.5px; line-height: 1.25; color: color-mix(in srgb, var(--m1) 78%, #000); }
.m-emblem { position: relative; z-index: 1; width: 72px; height: 72px; flex: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .14)); }
.m-emblem svg { width: 100%; height: 100%; display: block; overflow: visible; }
.m-banner.m-compact { min-height: 62px; padding: 10px 14px; margin: 0 0 14px; border-radius: 14px; }
.m-banner.m-compact .m-emblem { width: 52px; height: 52px; }
.m-banner.m-compact .m-txt b { font-size: 14px; }
.m-banner.m-compact .m-txt em { font-size: 9.5px; margin-bottom: 1px; }

/* little school symbols floating up behind the banner */
.m-parts { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.m-parts i {
  position: absolute; bottom: -22px; left: var(--x); font-style: normal; font-size: var(--s, 15px); font-weight: 800;
  line-height: 1; color: var(--m2); opacity: 0; will-change: transform, opacity;
  animation: mRise var(--d) linear infinite; animation-delay: var(--dl);
}

/* ---------- animated emblem parts (inline SVG, class names a-*) ---------- */
.m-svg [class*="a-"] { transform-box: fill-box; transform-origin: center; }
.m-svg .a-float  { animation: mFloat 3s ease-in-out infinite; }
.m-svg .a-swing  { transform-origin: 50% 0; animation: mSwing 2.4s ease-in-out infinite; }
.m-svg .a-pulse  { animation: mPulse 2s ease-in-out infinite; }
.m-svg .a-beat   { animation: mBeat 1.6s ease-in-out infinite; }
.m-svg .a-spin   { animation: mSpin 14s linear infinite; }
.m-svg .a-twinkle { animation: mTw 2.4s ease-in-out infinite; }
.m-svg .d2 { animation-delay: -.8s; } .m-svg .d3 { animation-delay: -1.6s; }
.m-svg .a-coin   { animation: mCoin 2.6s ease-in infinite; } .m-svg .a-coin.d2 { animation-delay: -1.3s; }
.m-svg .a-bar    { transform-origin: 50% 100%; animation: mGrow 3s ease-in-out infinite; }
.m-svg .a-bar.b2 { animation-delay: -.5s; } .m-svg .a-bar.b3 { animation-delay: -1s; }
.m-svg .a-draw   { stroke-dasharray: 90; animation: mDraw 3s ease-in-out infinite; }
.m-svg .a-tick   { stroke-dasharray: 24; animation: mTick 4s ease-in-out infinite; }
.m-svg .a-tick.t2 { animation-delay: .25s; } .m-svg .a-tick.t3 { animation-delay: .5s; } .m-svg .a-tick.t4 { animation-delay: .75s; }
.m-svg .a-wave   { animation: mWave 2.2s ease-out infinite; }
.m-svg .a-bounce { animation: mBounce 1.8s ease-in-out infinite; }
.m-svg .a-write  { animation: mWrite 2.6s ease-in-out infinite; }
.m-svg .a-line   { transform-origin: 0 50%; animation: mLine 3.6s ease-out infinite; }
.m-svg .a-line.l2 { animation-delay: .3s; } .m-svg .a-line.l3 { animation-delay: .6s; }
.m-svg .a-fly    { animation: mFly 2.4s ease-in-out infinite alternate; }
.m-svg .a-pop    { animation: mPop 4s ease-in-out infinite; }
.m-svg .a-shine  { animation: mShine 3s ease-in-out infinite; }
.m-svg .a-toss   { animation: mToss 3.4s ease-in-out infinite; }
.m-svg .a-sway   { transform-origin: 50% 100%; animation: mSway 3.4s ease-in-out infinite; }
.m-svg .a-flag   { transform-origin: 0 50%; animation: mSway 1.4s ease-in-out infinite; }
.m-svg .a-hand   { transform-box: view-box; transform-origin: 32px 32px; animation: mHand 6s linear infinite; }
.m-svg .a-hand.slow { animation-duration: 48s; }
.m-svg .a-glow   { animation: mGlow 2.4s ease-in-out infinite; }

@keyframes mFloat  { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes mSwing  { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
@keyframes mPulse  { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes mBeat   { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.14); } 30% { transform: scale(1); } 45% { transform: scale(1.1); } }
@keyframes mSpin   { to { transform: rotate(360deg); } }
@keyframes mTw     { 0%, 100% { opacity: .25; transform: scale(.7); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes mCoin   { 0% { transform: translateY(-4px); opacity: 0; } 15% { opacity: 1; } 70% { transform: translateY(20px); opacity: 1; } 100% { transform: translateY(24px); opacity: 0; } }
@keyframes mGrow   { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }
@keyframes mDraw   { 0% { stroke-dashoffset: 90; } 60%, 100% { stroke-dashoffset: 0; } }
@keyframes mTick   { 0%, 10% { stroke-dashoffset: 24; } 35%, 85% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 24; } }
@keyframes mWave   { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes mBounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-7px); } }
@keyframes mWrite  { 0%, 100% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(-8px, 6px) rotate(-6deg); } }
@keyframes mLine   { 0% { transform: scaleX(0); } 40%, 100% { transform: scaleX(1); } }
@keyframes mFly    { 0% { transform: translate(0, 0); } 100% { transform: translate(38px, 12px); } }
@keyframes mPop    { 0%, 10% { transform: scale(0); opacity: 0; } 30% { transform: scale(1.15); opacity: 1; } 40%, 85% { transform: scale(1); opacity: 1; } 100% { transform: scale(0); opacity: 0; } }
@keyframes mShine  { 0%, 100% { transform: translateX(-8px); opacity: 0; } 50% { transform: translateX(14px); opacity: .6; } }
@keyframes mToss   { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-12px) rotate(-14deg); } 55% { transform: translateY(-4px) rotate(8deg); } }
@keyframes mSway   { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes mHand   { to { transform: rotate(360deg); } }
@keyframes mGlow   { 0%, 100% { filter: drop-shadow(0 0 0 rgba(246, 196, 83, 0)); } 50% { filter: drop-shadow(0 0 6px rgba(246, 196, 83, .95)); } }
@keyframes mRise   { 0% { transform: translateY(0) rotate(0); opacity: 0; } 15% { opacity: .7; } 100% { transform: translateY(var(--rise, -130px)) rotate(40deg); opacity: 0; } }
@keyframes mSweep  { 0%, 55% { left: -40%; } 100% { left: 130%; } }
@keyframes mBannerIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes mFadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes mPopIn  { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }
@keyframes mHeroGlow { 0%, 100% { text-shadow: 0 2px 12px rgba(246, 196, 83, 0); } 50% { text-shadow: 0 2px 18px rgba(246, 196, 83, .55); } }

/* ---------- entrance: cards glide in one after another when a screen / panel opens ---------- */
.m-enter > *:not(.m-banner) { animation: mFadeUp .55s cubic-bezier(.2, .8, .3, 1) both; animation-delay: calc(var(--mi, 0) * 55ms); }
.m-enter .menu-grid > *, .m-enter .stat-row > * { animation: mPopIn .5s cubic-bezier(.2, .9, .3, 1.1) both; animation-delay: calc(var(--mi, 0) * 50ms); }

/* ---------- website page heroes: floating school symbols + a big soft emblem ---------- */
.m-has-fx { position: relative; overflow: hidden; }
.m-has-fx > :not(.m-hero-fx) { position: relative; z-index: 1; }
.m-hero-fx { position: absolute; inset: 0; z-index: 0; pointer-events: none; --rise: -260px; }
.m-hero-fx .m-parts i { color: #f6c453; font-size: var(--s, 20px); }
.m-hero-emblem { position: absolute; right: 5%; top: 50%; width: 150px; height: 150px; margin-top: -75px; opacity: .26; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .25)); }
.m-hero-emblem svg { width: 100%; height: 100%; display: block; overflow: visible; }
.m-hero-fx.m-light .m-parts i { color: var(--m2); opacity: 0; }
.m-hero-fx.m-light .m-hero-emblem { opacity: .14; filter: none; }
.m-has-fx.portal-intro h1 { animation: none; }
.m-has-fx h1 { animation: mHeroGlow 5s ease-in-out infinite; }
@media (max-width: 700px) { .m-hero-emblem { width: 84px; height: 84px; margin-top: -42px; right: 2%; opacity: .2; } }

/* ---------- dark mode ---------- */
[data-theme="dark"] body.app-ui .m-banner { background: linear-gradient(135deg, color-mix(in srgb, var(--m1) 30%, #1d1614), #1d1614); border-color: rgba(255, 255, 255, .08); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
[data-theme="dark"] body.app-ui .m-txt b { color: #f6e6c4; }
[data-theme="dark"] body.app-ui .m-txt em { color: var(--m2); }
[data-theme="dark"] body.app-ui .m-banner::after { background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .12), transparent); }

/* ---------- housekeeping: off-screen = paused, low-end phones = lighter, reduced motion = still ---------- */
.m-off .m-svg *, .m-off .m-parts i, .m-off::after { animation-play-state: paused !important; }
html.m-lite .m-parts { display: none; }
html.m-lite .m-banner::after { display: none; }
@media (prefers-reduced-motion: reduce) {
  .m-banner, .m-banner::after, .m-svg *, .m-parts i, .m-has-fx h1, .m-enter > *, .m-enter .menu-grid > *, .m-enter .stat-row > * { animation: none !important; }
  .m-parts i { opacity: .35; }
}
