/*
 * PRODEV hover system — "signal" interactions for links, buttons, cards, images.
 * Loaded on every page, after the other theme layers.
 *
 * Cards     pointer-lit border, a dot-matrix field under the pointer, HUD corner
 *           brackets and one scan sweep on entry. Builds on the .pdvx-glow layer
 *           that enhance.js creates (it already tracks --pdvx-x / --pdvx-y).
 * Buttons   a plasma edge that orbits while hovered, magnetic pull, light that
 *           follows the pointer and a pulse on press. Elements come from
 *           hover-fx.js on first hover, so idle pages pay nothing.
 * Links     "circuit trace": a gradient line draws in with a data packet riding
 *           its leading edge; nav and footer links get a one-shot signal glitch.
 * Images    [data-fx-holo] frames: holographic sheen and a scan line; large
 *           content images get a luminous edge.
 *
 * Performance rules for this site: hover-only, transform/opacity animation, no
 * endless effects outside an active hover, nothing on touch-only devices.
 */

html body.pd-brand {
  --fx-c1: #4A9FD4;
  --fx-c2: #8FE3FF;
  --fx-hot: #E6FBFF;
  --fx-ease: cubic-bezier(.2, .8, .2, 1);
}
html:not(.pdvx-dark) body.pd-brand { --fx-c1: #1E5A9C; --fx-c2: #2F9BD8; --fx-hot: #1E5A9C; }

/* ═══════════════════════════ LINKS ═══════════════════════════ */

html body.pd-brand :is(
  #content p a:not([class]), #content li > a:not([class]), #content dd a,
  .pd-pf-crumbs a, .pdv-foot-col a:not(.pd-foot-contact), .pdv-foot-bottom-links a, .pd-project-direct a, .pd-project-privacy a
) {
  text-decoration: none;
  background-image:
    linear-gradient(90deg, var(--fx-c1), var(--fx-c2)),
    radial-gradient(circle, var(--fx-hot) 0 1.5px, color-mix(in srgb, var(--fx-c2) 70%, transparent) 2.2px, transparent 4px);
  background-repeat: no-repeat;
  background-size: 0% 1px, 8px 8px;
  background-position: 0 calc(100% - 1px), -12px 100%;
  padding-bottom: 3px;
  transition: background-size 480ms var(--fx-ease), background-position 480ms var(--fx-ease), color 220ms ease, text-shadow 260ms ease;
}
html body.pd-brand :is(
  #content p a:not([class]), #content li > a:not([class]), #content dd a,
  .pd-pf-crumbs a, .pdv-foot-col a:not(.pd-foot-contact), .pdv-foot-bottom-links a, .pd-project-direct a, .pd-project-privacy a
):is(:hover, :focus-visible) {
  background-size: 100% 1px, 8px 8px;
  background-position: 0 calc(100% - 1px), calc(100% + 6px) 100%;
  text-decoration: none;
  padding-left: 0;
}
@media (hover: hover) and (pointer: fine) {
  html.pdvx-dark body.pd-brand :is(.pdv-foot-col a:not(.pd-foot-contact), .pd-pf-crumbs a, #content p a:not([class])):hover {
    color: #DFF6FF; text-shadow: 0 0 18px #4A9FD48C;
  }
}

/* Footer contact rows: icon lights and nudges. */
html body.pd-brand .pd-foot-contact .pd-cinema-icon { transition: transform 320ms var(--fx-ease), color 220ms ease, filter 220ms ease; }
html body.pd-brand .pd-foot-contact:is(:hover, :focus-visible) .pd-cinema-icon { transform: translateX(2px) scale(1.12); color: var(--fx-c2); }

/* One-shot chromatic "signal" glitch on navigation and footer links. */
@keyframes fxGlitch {
  0%   { text-shadow: -2px 0 #FF4FD8B0, 2px 0 #3FE9FFB0; transform: translateX(.5px); }
  25%  { text-shadow: 2px 0 #FF4FD890, -2px 0 #3FE9FF90; transform: translateX(-.5px); }
  50%  { text-shadow: -1px 0 #FF4FD860, 1px 0 #3FE9FF60; transform: none; }
  100% { text-shadow: none; transform: none; }
}
@media (hover: hover) and (pointer: fine) {
  html body.pd-brand :is(.pdv-menu > li > a, .pdv-foot-col a:not(.pd-foot-contact), .pd-pf-card-title, .pdv-mega-name):hover,
  html body.pd-brand .pd-pf-card-link:hover .pd-pf-card-title,
  html body.pd-brand .pdv-mega-item:hover .pdv-mega-name {
    animation: fxGlitch 360ms steps(3, end) 1;
  }
}

/* Text being decoded by hover-fx.js keeps its width. */
html body .fx-decoding { white-space: nowrap; }

/* ═══════════════════════════ BUTTONS ═══════════════════════════ */

html body .fx-btn {
  position: absolute; inset: 0; z-index: 0; border-radius: inherit; overflow: hidden; pointer-events: none;
}
html body .fx-btn > .fx-ring {
  position: absolute; inset: 0; border-radius: inherit; padding: 1.5px; opacity: 0;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  transition: opacity 280ms ease;
}
html body .fx-btn > .fx-ring::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: max(260%, 220px); aspect-ratio: 1; translate: -50% -50%;
  background: conic-gradient(from 0deg, transparent 0 58%, #4A9FD4 72%, #8FE3FF 80%, #FFFFFF 84%, #B58CFF 90%, transparent 97%);
  animation: fxOrbit 2.4s linear infinite paused;
}
@keyframes fxOrbit { to { rotate: 360deg; } }
html body .fx-btn > .fx-spot {
  position: absolute; inset: 0; opacity: 0; transition: opacity 260ms ease;
  background: radial-gradient(120px circle at var(--fx-x, 50%) var(--fx-y, 50%), #FFFFFF38, transparent 65%);
}
html body .fx-btn > .fx-pulse {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: radial-gradient(circle, #FFFFFFAA, #8FE3FF55 45%, transparent 70%);
  animation: fxPulse 620ms var(--fx-ease) forwards;
}
@keyframes fxPulse { from { transform: scale(.4); opacity: 1; } to { transform: scale(14); opacity: 0; } }

@media (hover: hover) and (pointer: fine) {
  html body .fx-host:hover > .fx-btn > .fx-ring { opacity: 1; }
  html body .fx-host:hover > .fx-btn > .fx-ring::before { animation-play-state: running; }
  html body .fx-host:hover > .fx-btn > .fx-spot { opacity: 1; }
  html body .fx-host.fx-magnet { transition-property: transform, box-shadow, background-color, color, border-color, translate !important; transition-duration: 240ms, 240ms, 180ms, 180ms, 180ms, 380ms !important; }
}
/* Keyboard users get the edge without the orbit. */
html body .fx-host:focus-visible > .fx-btn > .fx-ring { opacity: 1; }
html:not(.pdvx-dark) .fx-btn > .fx-spot { background: radial-gradient(120px circle at var(--fx-x, 50%) var(--fx-y, 50%), #FFFFFF4D, transparent 65%); }

/* Ghost buttons: a light rail sweeps along the bottom edge. */
html body.pd-brand :is(.pd-pf-btn.is-ghost, .btn-ghost, .pd-action-outline) { background-image: linear-gradient(90deg, transparent, var(--fx-c2), transparent); background-repeat: no-repeat; background-size: 40% 1.5px; background-position: -60% 100%; transition-property: transform, box-shadow, background-color, border-color, color, background-position; transition-duration: 260ms, 260ms, 200ms, 200ms, 200ms, 700ms; }
html body.pd-brand :is(.pd-pf-btn.is-ghost, .btn-ghost, .pd-action-outline):hover { background-position: 160% 100%; }

/* ═══════════════════════════ CARDS ═══════════════════════════ */

/* Pointer-lit border, drawn inside the existing glow layer. */
html body.pd-brand .pdvx-glow::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: radial-gradient(240px circle at var(--pdvx-x, 50%) var(--pdvx-y, 50%), #CFF6FF, #4A9FD4AA 30%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
html:not(.pdvx-dark) body.pd-brand .pdvx-glow::before { background: radial-gradient(240px circle at var(--pdvx-x, 50%) var(--pdvx-y, 50%), #1E5A9C, #4A9FD488 35%, transparent 70%); }

/* HUD corner brackets replace the earlier top signal line. */
html body.pd-brand .pdvx-glow::after {
  content: ''; position: absolute; inset: 9px; left: 9px; right: 9px; top: 9px; height: auto; border-radius: 0; pointer-events: none;
  --b: color-mix(in srgb, var(--fx-c2) 85%, transparent);
  background:
    linear-gradient(var(--b), var(--b)) 0 0 / 14px 1.5px, linear-gradient(var(--b), var(--b)) 0 0 / 1.5px 14px,
    linear-gradient(var(--b), var(--b)) 100% 0 / 14px 1.5px, linear-gradient(var(--b), var(--b)) 100% 0 / 1.5px 14px,
    linear-gradient(var(--b), var(--b)) 0 100% / 14px 1.5px, linear-gradient(var(--b), var(--b)) 0 100% / 1.5px 14px,
    linear-gradient(var(--b), var(--b)) 100% 100% / 14px 1.5px, linear-gradient(var(--b), var(--b)) 100% 100% / 1.5px 14px;
  background-repeat: no-repeat;
  opacity: 0; transform: scale(1.06); transform-origin: center;
  filter: drop-shadow(0 0 1.5px #000000B3);
  transition: opacity 260ms ease, transform 520ms var(--fx-ease);
}
html body.pd-brand .pdvx-hovering > .pdvx-glow::after { opacity: 1; transform: scale(1); }

/* Dot-matrix field revealed around the pointer. */
html body .pdvx-glow > .fx-grid {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 320ms ease;
  background-image: radial-gradient(circle, #8FE3FF66 0 1px, transparent 1.4px);
  background-size: 14px 14px;
  -webkit-mask-image: radial-gradient(160px circle at var(--pdvx-x, 50%) var(--pdvx-y, 50%), #000, transparent 72%);
  mask-image: radial-gradient(160px circle at var(--pdvx-x, 50%) var(--pdvx-y, 50%), #000, transparent 72%);
}
html:not(.pdvx-dark) .pdvx-glow > .fx-grid { background-image: radial-gradient(circle, #1E5A9C40 0 1px, transparent 1.4px); }
html body .pdvx-hovering > .pdvx-glow > .fx-grid { opacity: 1; }

/* One scan sweep each time the pointer enters. */
html body .pdvx-glow > .fx-scan {
  position: absolute; left: 0; right: 0; top: 0; height: 45%; pointer-events: none; opacity: 0; border-radius: inherit;
  background: linear-gradient(180deg, transparent, #8FE3FF14 60%, #8FE3FF40 97%, #E6FBFF 100%);
  transform: translateY(-110%);
}
html:not(.pdvx-dark) .pdvx-glow > .fx-scan { background: linear-gradient(180deg, transparent, #4A9FD412 60%, #4A9FD433 97%, #1E5A9C 100%); }
html body .pdvx-hovering > .pdvx-glow > .fx-scan { animation: fxScan 1100ms var(--fx-ease) 1 both; }
@keyframes fxScan {
  0%   { transform: translateY(-110%); opacity: 0; }
  12%  { opacity: 1; }
  100% { transform: translateY(240%); opacity: 0; }
}

/* ═══════════════════════════ IMAGES ═══════════════════════════ */

html body [data-fx-holo] { position: relative; overflow: hidden; isolation: isolate; }
html body [data-fx-holo] img { transition: transform 900ms var(--fx-ease), filter 400ms ease; }
html body [data-fx-holo]::after {
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0;
  background: linear-gradient(115deg, transparent 32%, #8FE3FF26 44%, #FFFFFF3D 50%, #B58CFF26 56%, transparent 68%);
  transform: translateX(-70%); transition: transform 1000ms var(--fx-ease), opacity 300ms ease;
}
html body [data-fx-holo]::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; z-index: 3; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, transparent, #8FE3FF, #FFFFFF, #8FE3FF, transparent);
  box-shadow: 0 0 18px 2px #4A9FD4AA;
}
@media (hover: hover) and (pointer: fine) {
  html body :is(a, .pd-pf-shot, .pd-pf-figure):hover [data-fx-holo] img,
  html body [data-fx-holo]:hover img { transform: scale(1.045); filter: saturate(1.08) contrast(1.03); }
  html body :is(a, .pd-pf-shot, .pd-pf-figure):hover [data-fx-holo]::after,
  html body [data-fx-holo]:hover::after { opacity: 1; transform: translateX(70%); }
  html body :is(a, .pd-pf-shot, .pd-pf-figure):hover [data-fx-holo]::before,
  html body [data-fx-holo]:hover::before { animation: fxLine 1200ms var(--fx-ease) 1 both; }
  html body .pd-pf-shot:hover .pd-pf-phone { transform: translateY(-8px) rotate(-1.5deg); }
}
@keyframes fxLine {
  0% { opacity: 0; transform: translateY(0); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translateY(var(--fx-h, 420px)); }
}
html body .pd-pf-card-media[data-fx-holo] { --fx-h: 230px; }
html body .pd-pf-mini-media[data-fx-holo] { --fx-h: 130px; }

/* Large content images tagged by hover-fx.js. */
html body.pd-brand img.fx-img { transition: box-shadow 380ms ease, filter 380ms ease, transform 600ms var(--fx-ease); }
@media (hover: hover) and (pointer: fine) {
  html body.pd-brand img.fx-img:hover {
    filter: saturate(1.08) brightness(1.03);
    box-shadow: 0 0 0 1px #8FE3FF88, 0 24px 60px -24px #4A9FD4AA;
  }
}

/* ═══════════════════════════ PREFERENCES ═══════════════════════════ */

html.pd-motion-reduced :is(.fx-btn, .fx-grid, .fx-scan) { display: none !important; }
html.pd-motion-reduced body.pd-brand :is([data-fx-holo]::before, [data-fx-holo]::after) { display: none; }
html.pd-motion-reduced body.pd-brand [data-fx-holo] img { transform: none !important; }
html.pd-motion-reduced body.pd-brand :is(.pdv-menu > li > a, .pdv-foot-col a, .pd-pf-card-title, .pdv-mega-name) { animation: none !important; }
html.pd-motion-reduced body.pd-brand .pdvx-glow::after { transform: none; }
@media (prefers-reduced-motion: reduce) {
  html body .fx-btn, html body .fx-grid, html body .fx-scan, html body [data-fx-holo]::before, html body [data-fx-holo]::after { display: none !important; }
  html body [data-fx-holo] img { transform: none !important; }
  html body.pd-brand :is(.pdv-menu > li > a, .pdv-foot-col a, .pd-pf-card-title):hover { animation: none !important; }
}

/* Portfolio cards: the full-card link sits above content, so lift the glow above it
   (it never takes pointer events). */
html body.pd-brand :is(.pd-pf-card, a.pd-pf-mini) > .pdvx-glow { z-index: 2; transform: translateZ(0); }

/* Footer links are wider than their text, so the underline used to run to the
   column edge. Size the link to its text. */
html body.pd-brand .pdv-foot-col li > a:not(.pd-foot-contact) { display: inline-block; width: auto; max-width: 100%; }
