/* ============================================================
   motion.css — smooth, playful motion layer (loaded last).
   Purely additive: no menus, content or layout are changed.
   All of it is switched off for users who prefer reduced motion
   (global.css) and for printing.
   ============================================================ */

/* ---------- page / menu transitions ---------- */
#app { transition: opacity .16s ease, transform .16s ease; }
#app.page-out { opacity: 0; transform: translateY(-8px); pointer-events: none; }
#app.page-in > * { animation: fxSectionIn .6s cubic-bezier(.22,1,.36,1) both; }
#app.page-in > *:nth-child(2) { animation-delay: .07s; }
#app.page-in > *:nth-child(3) { animation-delay: .14s; }
#app.page-in > *:nth-child(4) { animation-delay: .21s; }
#app.page-in > *:nth-child(n+5) { animation-delay: .28s; }
@keyframes fxSectionIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* thin gold bar that sweeps across the top when you change page */
#route-bar { position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 1100; pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--gold-500), #fff3d1, var(--gold-500)); transform: scaleX(0); transform-origin: left; opacity: 0; }
#route-bar.go { animation: fxRoute .75s cubic-bezier(.22,1,.36,1); }
@keyframes fxRoute { 0% { transform: scaleX(0); opacity: 1; } 70% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }

/* reading progress */
#scroll-progress { position: fixed; left: 0; bottom: 0; height: 3px; width: 100%; z-index: 1100; pointer-events: none;
  background: linear-gradient(90deg, var(--maroon-600), var(--gold-500)); transform: scaleX(0); transform-origin: left; }

/* back-to-top */
#to-top { position: fixed; right: 18px; bottom: 18px; width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--gold-500);
  background: var(--maroon-900); color: var(--gold-300); font-size: 1.25rem; line-height: 1; cursor: pointer; z-index: 700;
  box-shadow: 0 8px 20px rgba(43,8,16,.3); opacity: 0; transform: translateY(16px) scale(.6); pointer-events: none;
  transition: opacity .3s ease, transform .35s cubic-bezier(.34,1.56,.64,1), background-color .2s, color .2s; }
#to-top.show { opacity: 1; transform: none; pointer-events: auto; }
#to-top:hover { background: var(--gold-500); color: var(--maroon-950); transform: translateY(-3px); }

/* ---------- header & navigation ---------- */
.site-header { transition: box-shadow .3s ease, background-color .3s ease; }
.site-header.scrolled { box-shadow: 0 8px 24px rgba(43,8,16,.35); }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,243,209,.95), transparent) -40% 0 / 30% 100% no-repeat; animation: fxHeaderShine 6s linear infinite; }
@keyframes fxHeaderShine { to { background-position: 140% 0; } }
.brand-mark { transition: transform .35s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease; }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.1); box-shadow: 0 0 0 4px rgba(198,156,78,.35); }
.brand-name { transition: letter-spacing .3s ease, color .3s ease; }
.brand:hover .brand-name { letter-spacing: .06em; color: var(--gold-300); }

.main-nav a { position: relative; transition: color .25s ease, background-color .25s ease, transform .25s ease; }
.main-nav a::after { content: ""; position: absolute; left: 50%; bottom: 3px; height: 2px; width: 0; border-radius: 2px;
  background: var(--gold-500); transform: translateX(-50%); transition: width .3s cubic-bezier(.22,1,.36,1); }
.main-nav a:hover { transform: translateY(-1px); }
.main-nav a:hover::after { width: 55%; }
.main-nav a.active::after { width: 70%; }
.user-chip { transition: background-color .25s, transform .25s cubic-bezier(.34,1.56,.64,1); }
.user-chip:hover { background: rgba(255,255,255,.18); transform: translateY(-1px) scale(1.03); }
.user-menu.open { animation: fxMenuPop .22s cubic-bezier(.22,1,.36,1); transform-origin: top right; }
@keyframes fxMenuPop { from { opacity: 0; transform: translateY(-8px) scale(.96); } to { opacity: 1; transform: none; } }
.user-menu a, .user-menu button { transition: background-color .18s, padding-left .2s ease; }
.user-menu a:hover, .user-menu button:hover { padding-left: 16px; }

.hamburger { transition: background-color .2s, transform .2s; }
.hamburger:hover { background: rgba(255,255,255,.12); }
.hamburger:active { transform: scale(.92); }
.mobile-drawer.open #mobile-nav-links > * { animation: fxDrawerIn .45s cubic-bezier(.22,1,.36,1) both; }
.mobile-drawer.open #mobile-nav-links > *:nth-child(1) { animation-delay: .04s; } .mobile-drawer.open #mobile-nav-links > *:nth-child(2) { animation-delay: .08s; }
.mobile-drawer.open #mobile-nav-links > *:nth-child(3) { animation-delay: .12s; } .mobile-drawer.open #mobile-nav-links > *:nth-child(4) { animation-delay: .16s; }
.mobile-drawer.open #mobile-nav-links > *:nth-child(5) { animation-delay: .2s; }  .mobile-drawer.open #mobile-nav-links > *:nth-child(6) { animation-delay: .24s; }
.mobile-drawer.open #mobile-nav-links > *:nth-child(7) { animation-delay: .28s; } .mobile-drawer.open #mobile-nav-links > *:nth-child(8) { animation-delay: .32s; }
.mobile-drawer.open #mobile-nav-links > *:nth-child(n+9) { animation-delay: .36s; }
@keyframes fxDrawerIn { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }

/* ---------- buttons: pop, colour glide, shine, ripple ---------- */
.btn { position: relative; overflow: hidden; isolation: isolate;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease, background-position .5s ease, background-size .35s ease,
              background-color .25s ease, color .25s ease, border-color .25s ease; }
.btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 22px rgba(61,12,23,.24); }
.btn:active { transform: translateY(0) scale(.96); box-shadow: 0 2px 6px rgba(61,12,23,.2); transition-duration: .08s; }
.btn[disabled], .btn.disabled { opacity: .6; cursor: not-allowed; }
.btn[disabled]:hover { transform: none; box-shadow: none; }
.btn::after { content: ""; position: absolute; top: 0; left: -75%; width: 45%; height: 100%; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,.4), transparent); transform: skewX(-20deg); transition: left .7s ease; }
.btn:hover::after { left: 135%; }

.btn-primary { background: linear-gradient(110deg, var(--maroon-700) 0%, var(--maroon-500) 50%, var(--maroon-700) 100%) 0 0 / 240% 100%; }
.btn-primary:hover { background: linear-gradient(110deg, var(--maroon-700) 0%, var(--maroon-500) 50%, var(--maroon-700) 100%) 100% 0 / 240% 100%; }
.btn-gold { background: linear-gradient(110deg, var(--gold-500) 0%, #e6c27a 50%, var(--gold-500) 100%) 0 0 / 240% 100%; }
.btn-gold:hover { background: linear-gradient(110deg, var(--gold-500) 0%, #e6c27a 50%, var(--gold-500) 100%) 100% 0 / 240% 100%; }
.btn-danger:hover { background: #a02a21; }
.btn-outline { background: linear-gradient(var(--maroon-700), var(--maroon-700)) no-repeat 0 100% / 100% 0%; }
.btn-outline:hover { background: linear-gradient(var(--maroon-700), var(--maroon-700)) no-repeat 0 100% / 100% 100%; color: #fff; }
.btn-ghost:hover { transform: translateY(-1px); box-shadow: none; }
.header-actions .btn-outline:hover { background: rgba(255,255,255,.16); }
.btn-sm:hover { transform: translateY(-1px) scale(1.03); }

.fx-ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.55); transform: scale(0); opacity: .9; pointer-events: none; z-index: -1;
  animation: fxRipple .65s ease-out forwards; }
.btn-outline .fx-ripple, .btn-ghost .fx-ripple { background: rgba(109,26,46,.25); }
@keyframes fxRipple { to { transform: scale(1); opacity: 0; } }
.fx-spark { position: fixed; z-index: 2000; pointer-events: none; color: var(--gold-500); font-size: 14px; line-height: 1; will-change: transform, opacity; }

/* breathing glow on the main call-to-action in the hero */
.hero .btn-gold { animation: fxCtaPulse 3.4s ease-out infinite; }
@keyframes fxCtaPulse { 0% { box-shadow: 0 0 0 0 rgba(198,156,78,.55); } 70%, 100% { box-shadow: 0 0 0 16px rgba(198,156,78,0); } }

/* ---------- cards: lift, cursor spotlight, tilt ---------- */
.card { position: relative; }
.card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s ease;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(198,156,78,.20), transparent 70%); }
.card:hover::after { opacity: 1; }
.card:hover { box-shadow: 0 14px 30px rgba(61,12,23,.14); }
.fx-tilt { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .18s ease-out, box-shadow .25s ease, border-color .22s ease; will-change: transform; backface-visibility: hidden; }
.fx-tilt:hover { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-5px); }
.stat-card { position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(180px circle at var(--mx, 50%) var(--my, 50%), rgba(198,156,78,.22), transparent 70%); }
.stat-card:hover::after { opacity: 1; }

/* thumbnails slowly shift colour */
.course-thumb { background: linear-gradient(135deg, var(--maroon-700), var(--maroon-900), var(--maroon-600), var(--maroon-900)) 0 0 / 300% 300%; animation: fxGradShift 10s ease infinite; transition: filter .3s; }
.course-card:hover .course-thumb { filter: saturate(1.25) brightness(1.1); }
@keyframes fxGradShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* ---------- scroll reveal (class names added by fx.js) ---------- */
.fx-pre { opacity: 0; transform: translateY(26px) scale(.98); }
.fx-in { animation: fxReveal .7s cubic-bezier(.22,1,.36,1) var(--fx-d, 0ms) backwards; }
@keyframes fxReveal { from { opacity: 0; transform: translateY(26px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- small delights ---------- */
.progress > span { transform-origin: left; animation: fxBarGrow 1.1s cubic-bezier(.22,1,.36,1) backwards; }
@keyframes fxBarGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.badge { transition: transform .2s cubic-bezier(.34,1.56,.64,1); }
.badge:hover { transform: scale(1.06); }
input, select, textarea { transition: border-color .2s ease, box-shadow .25s ease, background-color .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-600); box-shadow: 0 0 0 4px rgba(198,156,78,.22); background: #fffdf8; }
.quiz-opt { transition: transform .2s cubic-bezier(.22,1,.36,1), background-color .2s, border-color .2s, box-shadow .2s; }
.quiz-opt:hover { transform: translateX(5px); box-shadow: 0 4px 12px rgba(61,12,23,.1); }
.leader-row:hover, .list-row:hover, .material-row:hover { transform: translateX(3px); }
.leader-row, .list-row, .material-row { transition: background-color .18s, transform .2s ease; }
.modal { animation: fxModalPop .35s cubic-bezier(.34,1.56,.64,1); }
.modal-backdrop { animation: fxFade .25s ease; }
@keyframes fxModalPop { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fxFade { from { opacity: 0; } to { opacity: 1; } }
.toast { animation: fxToast .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes fxToast { from { opacity: 0; transform: translateX(40px) scale(.9); } to { opacity: 1; transform: none; } }
.auth-tabs a { transition: background-color .25s, color .25s; }
.admin-side button { transition: background-color .2s, padding-left .2s ease, border-color .2s; }
.admin-side button:hover { padding-left: 22px; }
.site-footer a { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .3s ease, color .2s ease; }
.site-footer a:hover { background-size: 100% 1px; }
.sched-item { transition: transform .2s cubic-bezier(.22,1,.36,1), box-shadow .2s ease; }
.sched-item:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 8px 18px rgba(61,12,23,.16); }
.hero-stats div { transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.hero-stats div:hover { transform: translateY(-4px) scale(1.06); }

@media (hover: none) { .fx-tilt:hover { transform: none; } .btn:hover { transform: none; } }
@media print {
  #route-bar, #scroll-progress, #to-top, .fx-spark, .fx-ripple { display: none !important; }
  .fx-pre { opacity: 1 !important; transform: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .fx-pre { opacity: 1; transform: none; }
  #app.page-out { opacity: 1; transform: none; }
  #route-bar, #scroll-progress { display: none; }
}

/* mobile drawer: stack the links in a column (they were running sideways) */
#mobile-nav-links { display: flex; flex-direction: column; gap: 2px; }
.mobile-drawer .panel #mobile-nav-links a, .mobile-drawer .panel #mobile-nav-links button { display: block; width: 100%; transition: background-color .2s, padding-left .25s ease, color .2s; }
.mobile-drawer .panel #mobile-nav-links a:hover, .mobile-drawer .panel #mobile-nav-links button:hover { padding-left: 16px; color: var(--gold-300); background: rgba(255,255,255,.05); }
