/* ==========================================================
   أثر — Motion layer (behaviour in public/js/motion.js)
   Restrained, purposeful motion: things float, glow and respond to the visitor.
   Colours use the theme's role tokens with light-theme fallbacks, so this layer
   works with or without dark mode.
   Everything here is switched off for prefers-reduced-motion.
   ========================================================== */

/* ---- 1. Gold dust floating behind the green heroes (canvas added by motion.js) ---- */
.dust { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; opacity: .9; }

/* ---- 2. Large faint 8-point stars drifting in the light sections ---- */
.section--mint, .section--paper { position: relative; overflow: hidden; }
.section--mint::after, .section--paper::after {
  content: ''; position: absolute; z-index: 0; pointer-events: none;
  width: 340px; height: 340px; inset-inline-end: -90px; top: -70px; opacity: .1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cg fill='none' stroke='%23C9A24B' stroke-width='2'%3E%3Crect x='40' y='40' width='120' height='120'/%3E%3Crect x='40' y='40' width='120' height='120' transform='rotate(45 100 100)'/%3E%3Ccircle cx='100' cy='100' r='36'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  animation: orn-drift 26s ease-in-out infinite;
}
.section--paper::after { inset-inline-end: auto; inset-inline-start: -110px; top: auto; bottom: -90px; animation-duration: 32s; animation-direction: reverse; }
.section--mint > .container, .section--paper > .container { position: relative; z-index: 1; }
@keyframes orn-drift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-26px, 22px) rotate(22deg); }
}

/* ---- 3. Cursor spotlight on cards ---- */
.spot { position: relative; isolation: isolate; }
.spot::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), rgba(201, 162, 75, .16), transparent 65%);
  opacity: 0; transition: opacity .35s ease;
}
.spot:hover::after { opacity: 1; }

/* ---- 4. Card icons re-draw on hover ---- */
.house:hover .house__arch svg [data-len] { animation: icon-draw .9s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes icon-draw { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
.house__arch svg [data-len] { stroke-dasharray: var(--len); }

/* ---- 5. Magnetic buttons (transform set inline by motion.js) ---- */
.magnetic { transition: transform .35s cubic-bezier(.22, 1, .36, 1), box-shadow .2s, background .2s, color .2s; will-change: transform; }

/* ---- 6. Ink ripple on press ---- */
.ripple-host { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); opacity: .45;
  background: radial-gradient(circle, rgba(232, 210, 154, .9) 0%, rgba(201, 162, 75, .5) 45%, transparent 70%);
  animation: ripple .65s cubic-bezier(.22, 1, .36, 1) forwards;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---- 7. Sliding gold line under the menu ---- */
.nav__list { position: relative; }
.nav__ink {
  position: absolute; bottom: -6px; height: 2px; border-radius: 2px; pointer-events: none;
  background: linear-gradient(to left, var(--gold-500), var(--teal-500));
  box-shadow: 0 0 10px rgba(201, 162, 75, .55);
  transition: left .45s cubic-bezier(.22, 1, .36, 1), width .45s cubic-bezier(.22, 1, .36, 1), opacity .3s;
}

/* ---- 8. Header slims down after scrolling ---- */
.site-header__inner { transition: min-height .35s ease; }
.brand__logo { transition: height .35s ease, transform .3s ease, filter .3s ease; }
.site-header.is-scrolled .site-header__inner { min-height: 62px; }
.site-header.is-scrolled .brand__logo { height: 48px; }
@media (max-width: 640px) {
  .site-header.is-scrolled .site-header__inner { min-height: 60px; }
  .site-header.is-scrolled .brand__logo { height: 40px; }
}

/* ---- 9. Back-to-top with a reading-progress ring ---- */
.to-top { overflow: visible; }
.to-top__ring { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); transform: rotate(-90deg); pointer-events: none; }
.to-top__ring circle { fill: none; stroke-width: 3; }
.to-top__ring .track { stroke: rgba(201, 162, 75, .25); }
.to-top__ring .bar { stroke: var(--teal-500); stroke-linecap: round; transition: stroke-dashoffset .15s linear; }
.to-top:hover { transform: translateY(-3px); }

/* ---- 10. Section ornaments draw in when the heading appears ---- */
.js .section__head .ornament::before, .js .section__head .ornament::after { width: 0; transition: width 1s cubic-bezier(.22, 1, .36, 1) .25s; }
.js .section__head.is-visible .ornament::before, .js .section__head.is-visible .ornament::after { width: 64px; }
.js .section__head .ornament svg { transform: rotate(-135deg) scale(.4); opacity: 0; transition: transform 1s cubic-bezier(.22, 1, .36, 1) .1s, opacity .6s .1s; }
.js .section__head.is-visible .ornament svg { transform: none; opacity: 1; }

/* ---- 11. A light sweep across the gold words of the hero title ---- */
.hero__accent {
  background: linear-gradient(110deg, var(--gold-500) 0%, var(--gold-500) 40%, #fff4d6 50%, var(--gold-500) 60%, var(--gold-500) 100%);
  background-size: 260% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: title-shine 7s ease-in-out 1.6s infinite;
}
@keyframes title-shine { 0%, 55% { background-position: 100% 0; } 85%, 100% { background-position: 0 0; } }

/* ---- Eyebrow labels: a soft breathing glow ---- */
.eyebrow { position: relative; }
.section__head.is-visible .eyebrow { animation: eyebrow-glow 4s ease-in-out 1s infinite; }
@keyframes eyebrow-glow { 50% { box-shadow: 0 0 0 4px rgba(43, 163, 155, .12); } }

@media (prefers-reduced-motion: reduce) {
  .section--mint::after, .section--paper::after, .hero__accent, .section__head.is-visible .eyebrow { animation: none !important; }
  .dust { display: none; }
  .magnetic { transform: none !important; }
  .ripple { display: none; }
  .js .section__head .ornament::before, .js .section__head .ornament::after { width: 64px; transition: none; }
  .js .section__head .ornament svg { transform: none; opacity: 1; transition: none; }
}

/* ===================== Layer 2 — every page, every section ===================== */

/* 10. Auto-reveal (classes are added by motion.js only when motion is allowed) */
.mo { transition: opacity .6s ease, transform .75s cubic-bezier(.22, 1, .36, 1); transition-delay: var(--mo-d, 0ms); }
.mo:not(.mo-in) { opacity: 0; }
.mo--up:not(.mo-in) { transform: translateY(22px); }
.mo--row:not(.mo-in) { transform: translateY(10px); }
.mo--side:not(.mo-in) { transform: translateX(16px); }          /* RTL: slides in from the reading start */
.mo--pop:not(.mo-in) { transform: scale(.82); }

/* 11. Section titles word by word */
.mo-words .mo-w { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .08em; }
.mo-words .mo-w > span { display: inline-block; transform: translateY(105%); transition: transform .8s cubic-bezier(.22, 1, .36, 1) var(--wd, 0ms); }
.mo-words.mo-in .mo-w > span { transform: none; }

/* 12. Inner-page hero pattern drifts with scroll */
.page-hero::before { transform: translateY(var(--mo-pat, 0)); }

/* 13. Reading progress line */
.mo-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 1000; pointer-events: none; transform-origin: right; transform: scaleX(0);
  background: linear-gradient(to left, var(--gold-500, #c9a24b), var(--teal-500, #2ba39b)); box-shadow: 0 0 10px rgba(201, 162, 75, .5); }

/* 14. Hover polish shared by all pages */
main .card, main .school-card, main .text-card, main .level-card, main .stat { transition: transform .35s cubic-bezier(.22, 1, .36, 1), box-shadow .35s ease, border-color .35s ease; }
@media (hover: hover) {
  main .card:hover, main .school-card:hover, main .text-card:hover, main .level-card:hover, main .stat:hover { box-shadow: 0 16px 36px rgba(20, 38, 29, .14), 0 0 0 1px rgba(201, 162, 75, .35); }
  main .school-card:not([data-tilt]):hover, main .text-card:not([data-tilt]):hover, main .level-card:not([data-tilt]):hover, main .stat:not([data-tilt]):hover { transform: translateY(-4px); }
  main table tbody tr { transition: background-color .25s ease, box-shadow .25s ease; }
  main table tbody tr:hover { background-color: rgba(201, 162, 75, .09); box-shadow: inset -3px 0 0 var(--gold-500, #c9a24b); }
  .site-footer a { background: linear-gradient(currentColor, currentColor) no-repeat 100% 100% / 0 1px; transition: background-size .35s ease, color .25s ease; }
  .site-footer a:hover { background-size: 100% 1px; }
}
.btn { position: relative; overflow: hidden; }
.btn::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 45%; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent); transform: translateX(-160%) skewX(-20deg); }
@media (hover: hover) { .btn:hover::after { transition: transform .8s ease; transform: translateX(330%) skewX(-20deg); } }
main input:not([type=checkbox]):not([type=radio]), main select, main textarea { transition: box-shadow .3s ease, border-color .3s ease; }
main input:focus-visible, main select:focus-visible, main textarea:focus-visible { box-shadow: 0 0 0 4px rgba(43, 163, 155, .18); }

/* 15. Smooth page-to-page transitions (cross-document View Transitions; ignored where unsupported) */
@view-transition { navigation: auto; }
.site-header { view-transition-name: site-header; }
::view-transition-old(root) { animation: mo-vt-out .22s ease both; }
::view-transition-new(root) { animation: mo-vt-in .5s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes mo-vt-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes mo-vt-in { from { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  .mo, .mo-words .mo-w > span { opacity: 1 !important; transform: none !important; transition: none !important; }
  .mo-progress, .btn::after { display: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .page-hero::before { transform: none; }
}
