/*
 * kpm.decoded motion layer.
 * Animations play for every visitor by design (no reduced-motion opt-out).
 * Everything stays visible if JavaScript does not run: the hidden "before"
 * states only apply once the head script has added .kpm-motion-on, and a
 * failsafe reveals everything if motion.js has not started within 2.5s.
 */

/* ---------- Sticky, glassy header ---------- */
.wp-site-blocks > header {
  position: sticky;
  top: var(--wp-admin--admin-bar--height, 0px);
  z-index: 60;
}
.kpm-masthead {
  transition: background-color .35s ease, box-shadow .35s ease, border-color .35s ease;
}
.kpm-masthead.is-scrolled {
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  box-shadow: 0 10px 30px -18px rgba(11, 18, 32, .45);
  border-bottom-color: transparent;
}
.kpm-masthead-inner { transition: min-height .35s ease; }
.kpm-masthead.is-scrolled .kpm-masthead-inner { min-height: 3.9rem; }

/* Nav links: cyan underline that grows from the left. */
.kpm-primary-nav .wp-block-navigation-item__content { position: relative; }
.kpm-primary-nav a:hover { text-decoration: none; }
.kpm-primary-nav .wp-block-navigation-item__content::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -.3rem; height: 2px;
  background: var(--kpm-cyan); border-radius: 2px;
  transform: scaleX(0); transform-origin: left; transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.kpm-primary-nav .wp-block-navigation-item__content:hover::after,
.kpm-primary-nav .current-menu-item > .wp-block-navigation-item__content::after { transform: scaleX(1); }

/* ---------- Hero ---------- */
.kpm-hero::before { animation: kpm-kenburns 22s ease-in-out infinite alternate; transform-origin: 70% 50%; }
@keyframes kpm-kenburns { from { transform: scale(1); } to { transform: scale(1.08); } }

/* Moving grid + drifting cyan glow. */
.kpm-hero::after {
  content: ""; position: absolute; z-index: -1; inset: -40px; pointer-events: none;
  background:
    radial-gradient(circle at 72% 45%, rgba(34, 211, 238, .22), transparent 32%),
    linear-gradient(rgba(34, 211, 238, .06) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(90deg, rgba(34, 211, 238, .06) 1px, transparent 1px) 0 0 / 56px 56px;
  animation: kpm-grid-drift 16s linear infinite, kpm-glow 7s ease-in-out infinite alternate;
}
@keyframes kpm-grid-drift { to { background-position: 0 0, 56px 56px, 56px 56px; } }
@keyframes kpm-glow { from { opacity: .65; } to { opacity: 1; } }

/* Headline: first line rises, then "decoded." types in with a blinking cursor. */
.kpm-hero h1 { animation: kpm-rise .8s cubic-bezier(.2,.8,.2,1) both; }
.kpm-hero h1 mark {
  position: relative;
  animation: kpm-type 1s steps(8, end) .55s both;
}
.kpm-hero h1 mark::after {
  content: "_"; color: var(--kpm-cyan);
  animation: kpm-blink 1s steps(1) 1.6s infinite both;
}
@keyframes kpm-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes kpm-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes kpm-rise { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
.kpm-hero-description { animation: kpm-rise .8s cubic-bezier(.2,.8,.2,1) .25s both; }
.kpm-hero-search { animation: kpm-rise .8s cubic-bezier(.2,.8,.2,1) .4s both; }
.kpm-hero-search .wp-block-search__inside-wrapper { transition: box-shadow .3s ease, transform .3s ease; }
.kpm-hero-search .wp-block-search__inside-wrapper:hover,
.kpm-hero-search .wp-block-search__inside-wrapper:focus-within {
  box-shadow: 0 0 0 4px rgba(34, 211, 238, .25), 0 18px 40px -18px rgba(34, 211, 238, .55);
  transform: translateY(-2px);
}

/* ---------- Buttons: light sweep on hover ---------- */
.kpm-hero-search .wp-block-search__button,
.kpm-service-band .wp-block-button__link {
  position: relative; overflow: hidden; transition: transform .2s ease, filter .2s ease;
}
.kpm-hero-search .wp-block-search__button::after,
.kpm-service-band .wp-block-button__link::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-20deg); transition: left .6s ease;
}
.kpm-hero-search .wp-block-search__button:hover::after,
.kpm-service-band .wp-block-button__link:hover::after { left: 130%; }
.kpm-service-band .wp-block-button__link:hover { transform: translateY(-2px); }

/* ---------- Cards ---------- */
.kpm-card {
  transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s ease, border-color .35s ease;
}
.kpm-card:hover {
  transform: translateY(-6px);
  border-color: rgba(34, 211, 238, .7);
  box-shadow: 0 22px 45px -24px rgba(11, 18, 32, .55);
}
.kpm-card-image { overflow: hidden; }
.kpm-card-image img { transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.kpm-card:hover .kpm-card-image img { transform: scale(1.06); }
.kpm-card .wp-block-post-title a { transition: color .25s ease; }
.kpm-card:hover .wp-block-post-title a { color: #087d97; }

.kpm-category-section { transition: transform .35s ease, box-shadow .35s ease, border-color .35s ease; }
.kpm-category-section:hover {
  transform: translateY(-4px); border-top-color: var(--kpm-cyan);
  box-shadow: 0 18px 40px -26px rgba(11, 18, 32, .5);
}

/* ---------- Services band: moving light along the edge ---------- */
.kpm-service-band { position: relative; overflow: hidden; isolation: isolate; }
.kpm-service-band::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: repeating-linear-gradient(135deg, transparent 0 22px, rgba(34, 211, 238, .05) 22px 23px);
  animation: kpm-stripes 18s linear infinite;
}
.kpm-service-band::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 3px;
  background: linear-gradient(90deg, transparent, #fff, transparent) 0 0 / 30% 100% no-repeat, var(--kpm-cyan);
  animation: kpm-scan 3.2s ease-in-out infinite;
}
@keyframes kpm-stripes { to { background-position: 160px 0; } }
@keyframes kpm-scan { from { background-position: -40% 0, 0 0; } to { background-position: 140% 0, 0 0; } }

/* About icon gently floats. */
@media (min-width: 40rem) {
  .kpm-about::before { animation: kpm-float 4.5s ease-in-out infinite; }
}
@keyframes kpm-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- Scroll reveals ---------- */
.kpm-motion-on:not(.kpm-motion-failsafe) .kpm-reveal:not(.is-in) {
  opacity: 0; transform: translateY(28px);
}
.kpm-reveal {
  transition: opacity .7s cubic-bezier(.2,.8,.2,1), transform .7s cubic-bezier(.2,.8,.2,1);
  transition-delay: var(--kpm-d, 0ms);
}
/* Cards keep their quick hover transition once revealed. */
.kpm-card.kpm-reveal.is-in, .kpm-category-section.kpm-reveal.is-in {
  transition: opacity .7s cubic-bezier(.2,.8,.2,1) var(--kpm-d, 0ms), transform .35s cubic-bezier(.2,.8,.2,1),
    box-shadow .35s ease, border-color .35s ease;
}
.kpm-section-heading::before { transition: transform .6s cubic-bezier(.2,.8,.2,1) .15s; transform-origin: bottom; }
.kpm-motion-on:not(.kpm-motion-failsafe) .kpm-section-heading:not(.is-in)::before { transform: scaleY(0); }

/* ---------- Articles ---------- */
.kpm-progress {
  position: fixed; left: 0; top: var(--wp-admin--admin-bar--height, 0px); z-index: 70;
  width: 100%; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, var(--kpm-cyan), #7dd3fc);
  transform: scaleX(0); transform-origin: left;
  box-shadow: 0 0 10px rgba(34, 211, 238, .7);
}
.kpm-entry > .wp-block-post-featured-image { overflow: hidden; border-radius: .45rem; }
.kpm-entry > .wp-block-post-featured-image img { animation: kpm-zoom-in 1.1s cubic-bezier(.2,.8,.2,1) both; }
@keyframes kpm-zoom-in { from { transform: scale(1.06); opacity: .4; } to { transform: none; opacity: 1; } }
.kpm-entry-head { animation: kpm-rise .7s cubic-bezier(.2,.8,.2,1) both; }
.kpm-toc a { transition: color .2s ease, padding-left .2s ease; }
.kpm-toc a:hover { color: #087d97; padding-left: .25rem; }
.kpm-article-content h2.is-flash { animation: kpm-flash 1.4s ease; }
@keyframes kpm-flash { 0% { background: rgba(34, 211, 238, .35); } 100% { background: transparent; } }

/* ---------- Back to top ---------- */
.kpm-top {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 65;
  width: 2.9rem; height: 2.9rem; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--kpm-navy); color: var(--kpm-cyan);
  box-shadow: 0 10px 25px -10px rgba(11, 18, 32, .7);
  display: grid; place-items: center;
  opacity: 0; transform: translateY(14px) scale(.9); pointer-events: none;
  transition: opacity .3s ease, transform .3s ease, background-color .2s ease;
}
.kpm-top.is-shown { opacity: 1; transform: none; pointer-events: auto; }
.kpm-top:hover { background: #13203a; transform: translateY(-3px); }
.kpm-top svg { width: 1.2rem; height: 1.2rem; }
