/* ==========================================================================
   BroadSpectra motion & polish layer
   Loaded on every public page. Only adds presentation; no content changes.
   Reveal classes are applied by bs-motion.js, so pages without JS look as before.
   ========================================================================== */

/* ---------- Scroll progress bar ---------- */
.bs-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: 0 50%;
    transform: scaleX(0);
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), #00e5ff);
    z-index: 1100;
    pointer-events: none;
    box-shadow: 0 0 12px rgba(255, 148, 80, 0.55);
}

/* ---------- Page entrance ---------- */
@keyframes bsPageIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
main { animation: bsPageIn 0.6s ease both; }

/* ---------- Scroll reveal (uses the independent `translate` property so hover transforms keep working) ---------- */
.bs-reveal {
    opacity: 0;
    translate: 0 28px;
    transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), translate 0.75s cubic-bezier(0.16, 1, 0.3, 1), scale 0.75s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--bs-delay, 0s);
}
.bs-reveal.bs-from-left { translate: -36px 0; }
.bs-reveal.bs-from-right { translate: 36px 0; }
.bs-reveal.bs-zoom-in { translate: none; scale: 0.94; }
.bs-reveal.bs-in {
    opacity: 1;
    translate: none;
    scale: none;
}

/* ---------- Images: soft load-in, hover zoom, sheen ---------- */
img.bs-img { opacity: 0; transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.16, 1, 0.3, 1), filter 0.6s ease; }
img.bs-img.bs-loaded { opacity: 1; }
.bs-media-loading {
    background: linear-gradient(110deg, rgba(255, 255, 255, 0.03) 30%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 70%) 0 0 / 250% 100%, #0b1329 !important;
    animation: bsShimmer 1.6s linear infinite;
}
@keyframes bsShimmer { to { background-position: -250% 0, 0 0; } }
.bs-hover-zoom:hover img.bs-img,
.bs-hover-parent:hover .bs-hover-zoom img.bs-img { transform: scale(1.07); filter: saturate(1.12) contrast(1.04); }
.bs-media.bs-hover-zoom::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.16) 50%, transparent 65%);
    transform: translateX(-120%);
    transition: transform 0.9s ease;
    pointer-events: none;
}
.bs-media.bs-hover-zoom:hover::after,
.bs-hover-parent:hover .bs-media.bs-hover-zoom::after { transform: translateX(120%); }

/* ---------- Photo heroes (Solutions, Technology, Projects, Insights, Contact) ---------- */
section.bs-photo-hero {
    isolation: isolate;
    background: #060b19;
}
section.bs-photo-hero::after {
    content: '';
    position: absolute;
    inset: -4%;
    z-index: -2;
    background:
        linear-gradient(180deg, rgba(6, 11, 25, 0.86) 0%, rgba(6, 11, 25, 0.8) 45%, rgba(10, 17, 40, 0.97) 100%),
        linear-gradient(90deg, rgba(3, 7, 18, 0.75) 0%, rgba(3, 7, 18, 0.25) 100%),
        var(--hero-img) center / cover no-repeat;
    animation: bsKenBurns 28s ease-in-out infinite alternate;
    will-change: transform;
}
@keyframes bsKenBurns {
    from { transform: scale(1) translate3d(0, 0, 0); }
    to { transform: scale(1.08) translate3d(-1.5%, -1%, 0); }
}

/* Textured photo backdrop for selected content sections */
.bs-photo-section { isolation: isolate; }
.bs-photo-section > .bs-photo-layer {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--section-img) center / cover no-repeat;
    opacity: 0.12;
    filter: grayscale(0.35);
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
    mask-image: linear-gradient(180deg, transparent 0%, #000 22%, #000 78%, transparent 100%);
    pointer-events: none;
}

/* ---------- Animated fibre light-lines behind sections ---------- */
.bs-fibre-lines {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: -1;
}
.bs-fibre-lines span {
    position: absolute;
    height: 1px;
    width: 38%;
    left: -40%;
    background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.75), rgba(255, 148, 80, 0.75), transparent);
    filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.6));
    animation: bsFibre 9s linear infinite;
    opacity: 0.55;
}
.bs-fibre-lines span:nth-child(1) { top: 18%; animation-delay: 0s; }
.bs-fibre-lines span:nth-child(2) { top: 46%; animation-delay: 3.2s; animation-duration: 11s; }
.bs-fibre-lines span:nth-child(3) { top: 78%; animation-delay: 6s; animation-duration: 8s; }
@keyframes bsFibre { to { left: 110%; } }

/* ---------- Buttons: sheen sweep + press feedback ---------- */
.btn-primary, .btn-header, .btn-secondary, .btn-outline {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.btn-primary::after, .btn-header::after, .btn-secondary::after, .btn-outline::after {
    content: '';
    position: absolute;
    top: 0;
    left: -75%;
    width: 50%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.7s ease;
    z-index: -1;
    pointer-events: none;
}
.btn-primary:hover::after, .btn-header:hover::after, .btn-secondary:hover::after, .btn-outline:hover::after { left: 130%; }
.btn-primary:active, .btn-header:active, .btn-secondary:active, .btn-outline:active { scale: 0.97; }
.btn-header .fa-arrow-right, .btn-primary .fa-arrow-right { transition: transform 0.3s ease; }
.btn-header:hover .fa-arrow-right, .btn-primary:hover .fa-arrow-right { transform: translateX(4px); }

/* ---------- Cards: cursor-follow glow ---------- */
.bs-glow { position: relative; }
.bs-glow::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(0, 229, 255, 0.09), transparent 45%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: 0;
}
.bs-glow:hover::before { opacity: 1; }

/* ---------- Icons: gentle float on hover of their card ---------- */
.bs-hover-parent:hover i.fas, .bs-hover-parent:hover i.fa-solid { animation: bsIconPop 0.6s ease; }
@keyframes bsIconPop {
    0%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px) scale(1.08); }
}

/* ---------- Header polish ---------- */
header .logo img { filter: drop-shadow(0 0 0 rgba(0, 229, 255, 0)); transition: transform 0.3s ease, filter 0.4s ease; }
header .logo:hover img { filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.35)); }
header.scrolled .nav-container { padding-top: 0.8rem; padding-bottom: 0.8rem; }
.nav-container { transition: padding 0.35s ease; }

/* ---------- Back to top ---------- */
.bs-to-top {
    position: fixed;
    right: 1.4rem;
    bottom: 1.4rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(11, 19, 41, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 900;
    opacity: 0;
    translate: 0 16px;
    pointer-events: none;
    transition: opacity 0.35s ease, translate 0.35s ease, box-shadow 0.3s ease;
}
.bs-to-top.show { opacity: 1; translate: none; pointer-events: auto; }
/* Always sit on the opposite side to the chat assistant so they never overlap */
body:not(.bs-chat-left) .bs-to-top { right: auto; left: 1.4rem; }
.bs-to-top:hover { box-shadow: 0 0 22px rgba(0, 229, 255, 0.35); }
.bs-to-top svg { position: absolute; inset: -1px; width: calc(100% + 2px); height: calc(100% + 2px); transform: rotate(-90deg); }
.bs-to-top circle { fill: none; stroke-width: 2.5; }
.bs-to-top .track { stroke: rgba(255, 255, 255, 0.08); }
.bs-to-top .bar { stroke: url(#bsTopGrad); stroke-linecap: round; transition: stroke-dashoffset 0.15s linear; }

/* ---------- Footer: subtle animated top border ---------- */
footer::before { animation: bsFooterGlow 6s ease-in-out infinite; }
@keyframes bsFooterGlow {
    0%, 100% { opacity: 0.5; width: 600px; }
    50% { opacity: 1; width: 900px; }
}

/* ---------- Cards linked from the admin (Insights page) ---------- */
:where([data-bs-linked]) { position: relative; }
[data-bs-linked] { cursor: pointer; transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; }
.bs-card-link { position: absolute; inset: 0; z-index: 3; border-radius: inherit; }
.bs-card-link:focus-visible { outline: 2px solid var(--secondary-color); outline-offset: 3px; }
[data-bs-linked] a:not(.bs-card-link), [data-bs-linked] button { position: relative; z-index: 4; }
div[data-bs-linked]:hover, li[data-bs-linked]:hover, article[data-bs-linked]:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 148, 80, 0.55) !important;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 148, 80, 0.25);
}
span[data-bs-linked] { text-decoration: underline; text-decoration-color: rgba(255, 148, 80, 0.5); text-underline-offset: 3px; }
span[data-bs-linked]:hover { border-color: rgba(255, 148, 80, 0.8) !important; color: #fff; }

@media print {
    .bs-reveal, img.bs-img { opacity: 1 !important; translate: none !important; scale: none !important; }
    .bs-progress, .bs-to-top { display: none !important; }
}

/* ---------- Accessibility: honour reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .bs-reveal { opacity: 1 !important; translate: none !important; scale: none !important; }
    img.bs-img { opacity: 1 !important; }
    section.bs-photo-hero::after, .bs-fibre-lines span, .bs-media-loading { animation: none !important; }
    .bs-progress { display: none; }
}
