/* ============================================================================
   NORTHWHICH COLLEGE — WEBSITE MOTION  ·  "the lion wakes up"
   ---------------------------------------------------------------------------
   The public website's animation layer, built on the brand: indigo light
   sweeping across the crest, cyan glints from the banner, the crest's rule
   drawing itself under every heading, the banner's circuit lines drifting
   behind the dark band.

   Loaded by database/brand.php on the home page and the public pages, after
   their own CSS. Works with the page script's own reveal (.rv → .rv.in).
   Companion script: assets/brand/motion.js (adds the nw-* hooks used here).
   Everything that moves sits inside prefers-reduced-motion: no-preference;
   with reduced motion the site is simply still.
   ========================================================================== */

/* ── always on (no movement involved) ────────────────────────────────────── */
.nw-prog {
    position: fixed; left: 0; top: 0; z-index: 10000; height: 3px; width: 100%; pointer-events: none;
    background: linear-gradient(90deg, #2e3192, #4f5bd5 60%, #22b8d6);
    transform-origin: 0 50%; transform: scaleX(var(--nw-p, 0));
    box-shadow: 0 0 10px rgba(34,184,214,.55);
}
.nw-top {
    position: fixed; right: 22px; bottom: 92px; z-index: 950; width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    background: #2e3192; color: #fff; border: 0; box-shadow: 0 10px 26px rgba(46,49,146,.35);
    opacity: 0; visibility: hidden; transform: translateY(14px) scale(.9);
    transition: opacity .3s, visibility .3s, transform .35s cubic-bezier(.16,1,.3,1), background .2s;
}
.nw-top.on { opacity: 1; visibility: visible; transform: none; }
.nw-top:hover { background: #1f2178; }
.nw-top svg { position: absolute; inset: -3px; width: 54px; height: 54px; transform: rotate(-90deg); pointer-events: none; }
.nw-top svg circle { fill: none; stroke-width: 3; }
.nw-top svg .tr { stroke: rgba(46,49,146,.15); }
.nw-top svg .pg { stroke: #22b8d6; stroke-linecap: round; stroke-dasharray: 157; stroke-dashoffset: calc(157 - 157 * var(--nw-p, 0)); }
.nw-top i { font-size: 16px; }
@media (max-width: 768px) { .nw-top { right: 16px; bottom: 84px; width: 44px; height: 44px; } .nw-top svg { width: 50px; height: 50px; } }

/* welcome title words sit on their own line boxes so they can rise */
.nw-w { display: inline-block; white-space: pre; }
.nw-wm { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }

@media (prefers-reduced-motion: no-preference) {

/* ── logo intro: a sweep of light across the crest ───────────────────────── */
.pl-on .pl {
    background:
        radial-gradient(600px 380px at 50% 45%, rgba(46,49,146,.08), transparent 70%),
        #fff !important;
}
.pl-in { position: relative; }
.pl-in::before {                      /* the shine, cut to the logo's own shape */
    content: ''; position: absolute; left: 50%; top: 0; z-index: 2; pointer-events: none;
    width: min(300px, 70vw); aspect-ratio: 1007 / 308; transform: translateX(-50%);
    -webkit-mask: url("../../uploads/settings/bm-logo-horizontal.png?v=nw1") center / contain no-repeat;
            mask: url("../../uploads/settings/bm-logo-horizontal.png?v=nw1") center / contain no-repeat;
    background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.95) 48%, rgba(127,227,245,.9) 52%, transparent 65%) 0 0 / 260% 100% no-repeat;
    background-position: 130% 0; animation: nwShine 1.4s cubic-bezier(.45,.05,.3,1) .55s forwards;
}
.pl-bar { width: 190px !important; height: 3px !important; background: #eceefa !important; }
.pl-bar i { background: linear-gradient(90deg, #2e3192, #22b8d6) !important; }

/* ── banner: slow breathing, glints, a light sweep, gentle parallax ──────── */
.sl .sl-track { transform: translate3d(0, var(--nw-py, 0px), 0); will-change: transform; }
.sl-slide.is-contain .sl-img { animation: nwBreath 14s ease-in-out infinite alternate; transform-origin: 70% 50%; }
/* the banner's lion sits on its right edge: a softer zoom keeps it whole */
.sl-slide.is-cover.is-active .sl-img { transform: scale(1.03) !important; }
.sl-slide.is-contain .sl-blur { animation: nwBreath 18s ease-in-out infinite alternate-reverse; }
.nw-glints { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.nw-glints i {
    position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #fff;
    box-shadow: 0 0 10px 3px rgba(127,227,245,.9), 0 0 30px 8px rgba(34,184,214,.45);
    opacity: 0; animation: nwGlint 4.8s ease-in-out infinite;
}
.nw-glints i::before, .nw-glints i::after {   /* lens-flare cross, like the banner's lights */
    content: ''; position: absolute; left: 50%; top: 50%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.9), transparent);
    width: 70px; height: 1px; transform: translate(-50%, -50%);
}
.nw-glints i::after { width: 1px; height: 46px; background: linear-gradient(180deg, transparent, rgba(255,255,255,.85), transparent); }
.nw-glints i:nth-child(1) { left: 8%;  top: 22%; animation-delay: .2s; }
.nw-glints i:nth-child(2) { left: 26%; top: 78%; animation-delay: 1.6s; }
.nw-glints i:nth-child(3) { left: 63%; top: 14%; animation-delay: 2.7s; }
.nw-glints i:nth-child(4) { left: 91%; top: 68%; animation-delay: 3.6s; }
.nw-glints i:nth-child(5) { left: 47%; top: 88%; animation-delay: 4.3s; }
.nw-sweep {
    position: absolute; inset: 0; z-index: 2; pointer-events: none;
    background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.28) 50%, transparent 60%) 0 0 / 300% 100% no-repeat;
    animation: nwSweep 7s ease-in-out 1.2s infinite;
}

/* ── welcome: the name rises word by word, the motto follows ─────────────── */
.js .welcome-copy .nw-w { transform: translateY(105%); transition: transform 1s cubic-bezier(.16,1,.3,1); transition-delay: calc(120ms + var(--i, 0) * 90ms); }
.js .welcome-copy.in .nw-w { transform: none; }
.js .welcome-copy .welcome-tag > * , .js .welcome-copy .welcome-tag .nw-mt { opacity: 0; transform: translateY(8px); transition: opacity .6s, transform .6s cubic-bezier(.16,1,.3,1); transition-delay: calc(500ms + var(--i, 0) * 120ms); }
.js .welcome-copy.in .welcome-tag > *, .js .welcome-copy.in .welcome-tag .nw-mt { opacity: 1; transform: none; }
.welcome-tag i { animation: nwPulse 2.6s ease-in-out infinite; }
.welcome-tag i:nth-of-type(2) { animation-delay: .5s; }
.welcome { position: relative; overflow: hidden; }
.welcome > .wrap { position: relative; z-index: 1; }
.nw-motes { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.nw-motes i {
    position: absolute; bottom: -20px; width: var(--s, 6px); height: var(--s, 6px); border-radius: 50%;
    background: radial-gradient(circle, rgba(34,184,214,.55), rgba(46,49,146,0) 70%);
    animation: nwMote var(--t, 14s) linear var(--dl, 0s) infinite;
}
.welcome .nw-lion {                  /* the crest, faint, slowly breathing behind */
    position: absolute; right: -60px; top: 50%; width: 420px; height: 390px; z-index: 0; pointer-events: none; transform: translateY(-50%);
    background: url("../../uploads/settings/bm-logo-mark-color.png?v=nw1") center / contain no-repeat; opacity: .04;
    animation: nwFloat 9s ease-in-out infinite;
}
@media (max-width: 900px) { .welcome .nw-lion { width: 260px; height: 240px; right: -70px; top: 30%; } }

/* ── section headings: kicker opens out, title words rise, rule draws ────── */
.js .sx-head .sx-kicker, .js .faq-side .sx-kicker, .js .tc-copy .sx-kicker { letter-spacing: .5em; transition: opacity .6s, transform .6s, letter-spacing 1.1s cubic-bezier(.16,1,.3,1); }
.js .sx-head.in .sx-kicker, .js .faq-side.in .sx-kicker, .js .tc-copy.in .sx-kicker { letter-spacing: .14em; }
.js .nw-split .nw-w { transform: translateY(105%); transition: transform .9s cubic-bezier(.16,1,.3,1); transition-delay: calc(150ms + var(--i, 0) * 70ms); }
.js .in .nw-split .nw-w, .js .nw-split.in .nw-w { transform: none; }

/* ── cards: lift + 3D tilt toward the pointer (motion.js sets --rx/--ry) ─── */
.js .rv.in.nw-tilt {
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--ty, 0px));
    transition: transform .5s cubic-bezier(.16,1,.3,1), box-shadow .3s, border-color .3s, background .25s;
}
.js .rv.in.nw-tilt.nw-hov { --ty: -6px; transition: transform .12s linear, box-shadow .3s, border-color .3s, background .25s; }
.nw-tilt.nw-hov { box-shadow: 0 22px 44px rgba(46,49,146,.16) !important; }

/* icons pop in with their card and float on hover */
.js .rv :is(.why-ico, .vm-ico, .rs-ico, .cl-top > i:first-child) { transform: scale(.4) rotate(-25deg); opacity: 0; transition: transform .9s cubic-bezier(.34,1.56,.64,1) .25s, opacity .4s .25s; }
.js .rv.in :is(.why-ico, .vm-ico, .rs-ico, .cl-top > i:first-child) { transform: none; opacity: 1; }
.why:hover .why-ico, .vm-card:hover .vm-ico { animation: nwBob 1.4s ease-in-out infinite; box-shadow: 0 0 0 6px rgba(34,184,214,.12), 0 0 24px rgba(34,184,214,.35); }
.why-ico { transition: box-shadow .3s; }

/* ── the dark band: circuit lines drift, a light follows the pointer ─────── */
.sec-navy { position: relative; overflow: hidden; isolation: isolate; }
.sec-navy::before {
    content: ''; position: absolute; inset: -220px 0 0 -220px; z-index: -1; pointer-events: none; opacity: .14;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' fill='none' stroke='%23ffffff' stroke-width='1'%3E%3Cpath d='M0 40h70l30 30h120M0 150h40l40-40h60l30-30h50M110 220v-50l30-30h80M30 0v20l20 20'/%3E%3Ccircle cx='100' cy='70' r='2.5' fill='%2322b8d6'/%3E%3Ccircle cx='140' cy='140' r='2.5' fill='%2322b8d6'/%3E%3C/svg%3E") 0 0 / 220px 220px;
    animation: nwDrift 40s linear infinite;
}
.sec-navy::after {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: radial-gradient(520px 360px at var(--mx, 50%) var(--my, 30%), rgba(79,91,213,.38), transparent 70%);
    transition: background-position .2s;
}
/* the cards stay solid enough to keep the grid's hairlines, thin enough to
   let the drifting lines and the pointer light show through */
.sec-navy .why { background: rgba(21,23,90,.86) !important; }
.sec-navy .why:hover { background: rgba(31,33,120,.82) !important; }

/* ── buttons: a light passes across on hover; arrows nudge forward ───────── */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn::after {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%) 0 0 / 250% 100% no-repeat;
    background-position: 140% 0; transition: background-position 0s;
}
.btn:hover::after { background-position: -40% 0; transition: background-position .7s ease; }
.btn .fa-arrow-right { transition: transform .25s cubic-bezier(.16,1,.3,1); }
.btn:hover .fa-arrow-right { transform: translateX(4px); }
.btn-lg.nw-mag { transition: transform .25s cubic-bezier(.16,1,.3,1), background .2s, color .2s, border-color .2s, box-shadow .2s; transform: translate(var(--bx, 0px), var(--by, 0px)); }

/* header logo: the crest settles in, the nav underline glides */
.js .hd-logo img { animation: nwLogoIn 1s cubic-bezier(.16,1,.3,1) .15s both; }
.pl-on:not(.pl-done) .hd-logo img { animation-play-state: paused; }
.hd-nav a { position: relative; }
.hd-nav a::after { content: ''; position: absolute; left: 50%; right: 50%; bottom: -6px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #2e3192, #22b8d6); transition: left .3s cubic-bezier(.16,1,.3,1), right .3s cubic-bezier(.16,1,.3,1); }
.hd-nav a:hover::after { left: 10%; right: 10%; }

/* "at a glance" numbers glow once when they finish counting */
.glance b.nw-done { animation: nwGlow 1.2s ease-out; }

/* gallery: a cyan frame draws on hover */
.gl-item { position: relative; }
.gl-item::after { content: ''; position: absolute; inset: 8px; border: 1.5px solid rgba(255,255,255,.0); border-radius: 6px; pointer-events: none; transition: border-color .35s, inset .35s cubic-bezier(.16,1,.3,1); }
.gl-item:hover::after { border-color: rgba(127,227,245,.9); inset: 12px; }

/* footer: the crest rises into place */
.ft { position: relative; overflow: hidden; isolation: isolate; }
.ft::before {
    content: ''; position: absolute; right: -40px; bottom: -30px; width: 340px; height: 316px; z-index: -1; pointer-events: none;
    background: url("../../uploads/settings/bm-logo-mark.png?v=nw1") center / contain no-repeat; opacity: 0; transform: translateY(40px);
    transition: opacity 1.4s ease, transform 1.6s cubic-bezier(.16,1,.3,1);
}
.ft.nw-seen::before { opacity: .05; transform: none; }

/* inner pages (subjects, gallery, contact …): their dark page heads get the
   same drifting circuit lines as the home page's dark band */
html[data-bm="public"] :is(.l3-hero, .page-hero, .pg-hero) { position: relative; overflow: hidden; isolation: isolate; }
html[data-bm="public"] :is(.l3-hero, .page-hero, .pg-hero)::before {
    content: ''; position: absolute; inset: -220px 0 0 -220px; z-index: -1; pointer-events: none; opacity: .12;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' fill='none' stroke='%23ffffff' stroke-width='1'%3E%3Cpath d='M0 40h70l30 30h120M0 150h40l40-40h60l30-30h50M110 220v-50l30-30h80M30 0v20l20 20'/%3E%3Ccircle cx='100' cy='70' r='2.5' fill='%2322b8d6'/%3E%3C/svg%3E") 0 0 / 220px 220px;
    animation: nwDrift 40s linear infinite;
}
html[data-bm="public"] .nw-enter { animation: nwEnter .8s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(var(--i, 0) * 80ms); }

/* ── keyframes ───────────────────────────────────────────────────────────── */
@keyframes nwShine { to { background-position: -30% 0; } }
@keyframes nwBreath { from { transform: scale(1); } to { transform: scale(1.045); } }
@keyframes nwGlint { 0%, 100% { opacity: 0; transform: scale(.4); } 45%, 55% { opacity: 1; transform: scale(1); } }
@keyframes nwSweep { 0% { background-position: 140% 0; } 45%, 100% { background-position: -40% 0; } }
@keyframes nwPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34,184,214,.5); } 50% { transform: scale(1.25); box-shadow: 0 0 0 5px rgba(34,184,214,0); } }
@keyframes nwMote { from { transform: translateY(0) translateX(0); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } to { transform: translateY(-110vh) translateX(var(--dx, 30px)); opacity: 0; } }
@keyframes nwFloat { 0%, 100% { transform: translateY(-50%); } 50% { transform: translateY(calc(-50% - 14px)); } }
@keyframes nwBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes nwDrift { to { transform: translate(220px, 220px); } }
@keyframes nwLogoIn { from { opacity: 0; transform: translateX(-14px) scale(.96); filter: blur(4px); } }
@keyframes nwGlow { 0% { text-shadow: 0 0 0 rgba(34,184,214,0); } 30% { text-shadow: 0 0 18px rgba(34,184,214,.75); } 100% { text-shadow: 0 0 0 rgba(34,184,214,0); } }
@keyframes nwEnter { from { opacity: 0; transform: translateY(22px); } }
}

/* ── living type ──────────────────────────────────────────────────────────────
   • the college name: a band of cyan light passes through it word by word,
     every few seconds, after it has risen into place
   • section titles: the same light passes once as each title arrives
   • the small labels above titles write themselves left to right
   • the motto: Learn, Grow, Excel take turns to glow */
@media (prefers-reduced-motion: no-preference) {
    .welcome-title .nw-w {
        background: linear-gradient(100deg, #2e3192 0%, #2e3192 38%, #4f5bd5 45%, #22b8d6 50%, #4f5bd5 55%, #2e3192 62%, #2e3192 100%) 100% 0 / 260% 100% no-repeat;
        -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
        animation: nwTextLight 5.5s ease-in-out infinite; animation-delay: calc(1.6s + var(--i, 0) * .18s);
    }
    .in .sx-title .nw-w, .sx-head.in .sx-title .nw-w, .faq-side.in .sx-title .nw-w, .tc-copy.in .sx-title .nw-w {
        background: linear-gradient(100deg, currentColor 0%, currentColor 38%, #22b8d6 50%, currentColor 62%, currentColor 100%) 100% 0 / 260% 100% no-repeat;
        -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
        animation: nwTextOnce 1.5s ease-out forwards; animation-delay: calc(.9s + var(--i, 0) * .09s);
    }
    .sec-navy .sx-head.in .sx-title .nw-w {
        background-image: linear-gradient(100deg, #fff 0%, #fff 38%, #7fe3f5 50%, #fff 62%, #fff 100%);
    }

    .js :is(.sx-head, .faq-side, .tc-copy, .welcome-copy) .sx-kicker { clip-path: inset(0 100% 0 0); }
    .js :is(.sx-head, .faq-side, .tc-copy, .welcome-copy).in .sx-kicker { clip-path: inset(0 0 0 0); transition: clip-path 1s cubic-bezier(.65,0,.35,1) .1s, opacity .6s, transform .6s, letter-spacing 1.1s cubic-bezier(.16,1,.3,1); }

    .welcome-tag .nw-mt { animation: nwMotto 4.5s ease-in-out infinite 2.2s; }
    .welcome-tag .nw-mt:nth-of-type(2) { animation-delay: 3.7s; }
    .welcome-tag .nw-mt:nth-of-type(3) { animation-delay: 5.2s; }

    @keyframes nwTextLight { 0% { background-position: 100% 0; } 35%, 100% { background-position: 0 0; } }
    @keyframes nwTextOnce { from { background-position: 100% 0; } to { background-position: 0 0; } }
    @keyframes nwMotto { 0%, 34%, 100% { color: var(--gold-dk, #0891b2); text-shadow: none; } 12%, 22% { color: #2e3192; text-shadow: 0 0 16px rgba(34,184,214,.55); } }
}
