<?php
/** Plugin Name: AIB — Homepage video hero
 * Fullscreen video hero, Plastique headline, header hidden until scroll. Reversible: delete file. */
if(!defined('ABSPATH')) return;
add_action('wp_head', function(){ if(!is_front_page()) return; ?>
<link rel="preload" as="image" href="/wp-content/uploads/hero-poster.jpg" media="(min-width:768px)"><link rel="preload" as="image" href="/wp-content/uploads/hero-poster-portrait.jpg" media="(max-width:767px)"><style id="aib-vhero-css">
@font-face{font-family:'Plastique';src:url('/wp-content/uploads/fonts/Plastique.ttf') format('truetype');font-display:swap}
#header.ct-header{position:fixed !important;top:0;left:0;right:0;z-index:200;transform:translateY(-108%) !important;transition:transform .35s ease}
body.aib-show-hdr #header.ct-header{transform:translateY(0) !important;box-shadow:0 2px 14px rgba(0,0,0,.13);background:#fff !important}body.aib-show-hdr #header.ct-header [data-row],body.aib-show-hdr #header.ct-header .ct-header-row,body.aib-show-hdr #header.ct-header .ct-container,body.aib-show-hdr #header.ct-header .ct-container-full{background:#fff !important}
.aib-vhero{position:relative;width:100vw;margin-left:calc(50% - 50vw);height:100vh;min-height:520px;overflow:hidden;display:flex;align-items:flex-start;justify-content:flex-start;background:#efefef url(/wp-content/uploads/hero-poster.jpg) center center/cover no-repeat}@media (max-width:767px){.aib-vhero{background-image:url(/wp-content/uploads/hero-poster-portrait.jpg)}}
.aib-vhero video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:0}
.aib-vhero .ov{position:absolute;inset:0;background:linear-gradient(160deg,rgba(0,0,0,.30),rgba(0,0,0,.10) 42%,rgba(0,0,0,.42));z-index:1}
.aib-vhero .in{position:relative;z-index:2;padding:15vh 0 0 6vw;max-width:92%}@media (max-width:767px){.aib-vhero .in{padding:12vh 0 0 5vw;max-width:94%}}
.aib-vhero h1{font-family:'Plastique','Montserrat',sans-serif;font-size:clamp(1.6rem,6.2vw,4rem);font-weight:normal;line-height:1.04;margin:0;color:rgba(255,255,255,.5);text-shadow:0 2px 24px rgba(0,0,0,.4);white-space:normal;overflow-wrap:break-word;max-width:100%}
.aib-vhero .scroll{position:absolute;bottom:26px;left:50%;transform:translateX(-50%);z-index:2;color:rgba(255,255,255,.9);text-decoration:none;font-size:.72rem;letter-spacing:.22em;text-transform:uppercase;font-weight:600;display:flex;flex-direction:column;align-items:center;gap:5px;text-shadow:0 1px 8px rgba(0,0,0,.5)}
.aib-vhero .scroll .arr{font-size:1.7rem;line-height:1;animation:aibb 2s infinite}
@keyframes aibb{0%,100%{transform:translateY(0)}50%{transform:translateY(8px)}}
.stk-1b6aa2d .stk-block-subtitle__text{font-size:46px !important;line-height:1.18 !important;font-weight:600 !important}
@media (max-width:1023px){.stk-1b6aa2d .stk-block-subtitle__text{font-size:30px !important}}
@media (max-width:767px){.stk-1b6aa2d .stk-block-subtitle__text{font-size:24px !important}}
</style>
<?php });
add_action('wp_footer', function(){ if(!is_front_page()) return; ?>
<script>
document.addEventListener('DOMContentLoaded',function(){
 if(!document.querySelector('.aib-vhero')){
  var main=document.querySelector('main')||document.body;var art=main.querySelector('article, .entry-content, .site-main')||main;
  var h=document.createElement('section');h.className='aib-vhero';var vsrc=(window.matchMedia&&window.matchMedia('(min-width:900px)').matches)?'/wp-content/uploads/hero-1080.mp4':'/wp-content/uploads/hero-720-muted.mp4';
  h.innerHTML='<video autoplay muted loop playsinline preload=\"auto\" poster="/wp-content/uploads/hero-poster.jpg"><source src="'+vsrc+'" type="video/mp4"></video><div class="ov"></div><div class="in"><h1>We make it happen</h1></div><a class="scroll" href="#aib-store" aria-label="Scroll to see more">Scroll to see more<span class="arr">&#8964;</span></a>';
  var a=document.createElement('span');a.id='aib-store';art.parentNode.insertBefore(h,art);art.parentNode.insertBefore(a,art);
 }
 function hdr(){document.body.classList.toggle('aib-show-hdr', window.scrollY > window.innerHeight*0.62);}
 window.addEventListener('scroll',hdr,{passive:true}); hdr();
});
</script>
<?php });