/* =====================================================================
   SUBPAGE GRADIENT SYSTEM
   Active only when <body> has .is-subpage (set in layouts/default.vue for
   every public route except "/"), so the landing page is untouched.
   Built from the existing brand palette only:
     orange #fe8719 (accent) · blue #007dbf (brand blue) · ink #0f0f0f (base)
   plus darkened steps of those two. Per-page emphasis = body[data-page]
   moving the mesh fields / changing intensity — never the palette.
   ===================================================================== */

:root {
  /* palette as rgb triplets so every layer can set its own alpha */
  --c-orange: 254, 135, 25;
  --c-orange-d: 150, 66, 10;   /* burnt step of the brand orange */
  --c-blue: 0, 125, 191;
  --c-blue-d: 0, 47, 74;      /* deep step of the brand blue */
  --c-blue-l: 77, 184, 240;   /* light step already used by the border beams */
  --g-k: 1;                    /* global intensity multiplier (lowered on phones) */

  /* mesh field anchors (x y, % of the mesh box) + per-page strength */
  --m1x: 72%; --m1y: 14%;      /* orange   */
  --m2x: 28%; --m2y: 36%;      /* burnt    */
  --m3x: 12%; --m3y: 10%;      /* blue     */
  --m4x: 88%; --m4y: 48%;      /* deep blue / light-blue accent */
  --mesh-k: 1;

  /* surfaces + edges (--g-base = opaque ground so the edge gradient shows only in the 1px border) */
  --g-base: linear-gradient(#131313, #131313);
  --g-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012));
  --g-surface-primary:
    radial-gradient(120% 70% at 50% 0%, rgba(var(--c-orange), 0.08), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  --g-edge: linear-gradient(160deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04) 45%, rgba(var(--c-blue-l), 0.18));
  --g-edge-primary: linear-gradient(160deg, rgba(var(--c-orange), 0.45), rgba(255, 255, 255, 0.06) 40%, rgba(var(--c-blue-l), 0.35));

  /* section rhythm */
  --g-band: linear-gradient(180deg, transparent, rgba(var(--c-blue), 0.07) 30%, rgba(var(--c-blue), 0.07) 70%, transparent);
  --g-rule: linear-gradient(90deg, transparent, rgba(var(--c-orange), 0.5), rgba(var(--c-blue-l), 0.35), transparent);
}

/* ---- per-page emphasis (positions/intensity only) ---- */
/* Director: warmth gathers behind the profile card */
body.is-subpage[data-page='direktor'] { --m1x: 50%; --m1y: 24%; --m2x: 50%; --m2y: 46%; --m3x: 18%; --m3y: 8%; --m4x: 84%; --m4y: 30%; }
/* Sales: weight on the message + CTA side, blue toward the product photo */
body.is-subpage[data-page='prodaja'] { --m1x: 24%; --m1y: 28%; --m2x: 38%; --m2y: 52%; --m3x: 82%; --m3y: 16%; --m4x: 72%; --m4y: 56%; }
/* Service: warm workshop light on the image / technical side */
body.is-subpage[data-page='servis'] { --m1x: 78%; --m1y: 26%; --m2x: 62%; --m2y: 50%; --m3x: 14%; --m3y: 18%; --m4x: 28%; --m4y: 60%; }
/* Info: restrained, blue-led */
body.is-subpage[data-page='info'] { --m1x: 74%; --m1y: 8%; --m3x: 30%; --m3y: 20%; --mesh-k: 0.65; }

/* ---------------- animated mesh ----------------
   <div class="sp-mesh"> (components/common/MeshGradient.vue) is rendered by
   layouts/default.vue on every public page, landing included.
   Four soft elliptical fields (closest-side radials → no hard edges, no blur
   filter needed) drift/rotate/scale on transform only (compositor-friendly).
   Coprime durations (18/23/29/37s) keep the combined motion from visibly
   looping. The layer sits under all content. */
/* let the mesh read through the page shells; body is the same #0f0f0f */
body.is-subpage main.main-bg,
main.home-handoff { background: transparent !important; }

/* the mesh is a viewport-sized layer that stays put while the page scrolls
   over it, so it sits behind EVERY section, top to bottom. */
.sp-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  opacity: calc(var(--g-k) * var(--mesh-k));
}

/* sections that painted their own band (sub-bg) + white hairlines top/bottom
   (bord-*-grd) cut the mesh into blocks; drop both so the background flows
   continuously from one section into the next (landing main + subpages only) */
:is(main.home-handoff, body.is-subpage main) :is(section.sub-bg, .main-marq.sub-bg) { background: transparent !important; }
:is(main.home-handoff, body.is-subpage main) .bord-top-grd::before,
:is(main.home-handoff, body.is-subpage main) .bord-bottom-grd::after { display: none; }
/* marquee edge fades were painted in solid #0f0f0f (hard boxes over the mesh);
   fade the belt itself with a mask instead — same look on a plain background */
:is(main.home-handoff, body.is-subpage main) .main-marq:not(.shadow-off)::after { display: none; }
:is(main.home-handoff, body.is-subpage main) .main-marq:not(.shadow-off) {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 280px, #000 calc(100% - 280px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 280px, #000 calc(100% - 280px), transparent);
}
.sp-mesh > i {
  position: absolute;
  display: block;
  transform: translate(-50%, -50%);
  will-change: transform;
  mix-blend-mode: screen;
  animation: 34s ease-in-out infinite alternate both;
}
.sp-mesh > i:nth-child(1) {
  left: var(--m1x); top: var(--m1y);
  width: 78vw; height: 62vh; min-width: 640px; min-height: 480px;
  background: radial-gradient(closest-side, rgba(var(--c-orange), 0.30), rgba(var(--c-orange), 0.12) 45%, transparent);
  animation-name: mesh-a; animation-duration: 18s;
}
.sp-mesh > i:nth-child(2) {
  left: var(--m2x); top: var(--m2y);
  width: 64vw; height: 58vh; min-width: 560px; min-height: 440px;
  background: radial-gradient(closest-side, rgba(var(--c-orange-d), 0.42), rgba(var(--c-orange-d), 0.14) 50%, transparent);
  animation-name: mesh-b; animation-duration: 23s; animation-delay: -7s;
}
.sp-mesh > i:nth-child(3) {
  left: var(--m3x); top: var(--m3y);
  width: 70vw; height: 66vh; min-width: 600px; min-height: 500px;
  background: radial-gradient(closest-side, rgba(var(--c-blue), 0.5), rgba(var(--c-blue-d), 0.3) 50%, transparent);
  animation-name: mesh-c; animation-duration: 29s; animation-delay: -13s;
}
.sp-mesh > i:nth-child(4) {
  left: var(--m4x); top: var(--m4y);
  width: 52vw; height: 48vh; min-width: 460px; min-height: 380px;
  background: radial-gradient(closest-side, rgba(var(--c-blue-l), 0.12), rgba(var(--c-blue), 0.12) 55%, transparent);
  animation-name: mesh-d; animation-duration: 37s; animation-delay: -19s;
}
/* each field takes its own path: drift + slow rotation (ellipses rotating read
   as organic flow rather than round blobs) + gentle breathing in scale */
@keyframes mesh-a {
  0%   { transform: translate(-50%, -50%) rotate(-14deg) scale(0.92); }
  33%  { transform: translate(-28%, -62%) rotate(16deg) scale(1.22); }
  66%  { transform: translate(-62%, -34%) rotate(34deg) scale(1.05); }
  100% { transform: translate(-40%, -48%) rotate(-4deg) scale(1.3); }
}
@keyframes mesh-b {
  0%   { transform: translate(-50%, -50%) rotate(24deg) scale(1.1); }
  33%  { transform: translate(-72%, -36%) rotate(-8deg) scale(0.86); }
  66%  { transform: translate(-36%, -66%) rotate(-30deg) scale(1.25); }
  100% { transform: translate(-58%, -42%) rotate(6deg) scale(0.95); }
}
@keyframes mesh-c {
  0%   { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
  33%  { transform: translate(-24%, -40%) rotate(-24deg) scale(1.2); }
  66%  { transform: translate(-60%, -68%) rotate(18deg) scale(0.9); }
  100% { transform: translate(-38%, -56%) rotate(-10deg) scale(1.15); }
}
@keyframes mesh-d {
  0%   { transform: translate(-50%, -50%) rotate(12deg) scale(0.9); }
  33%  { transform: translate(-74%, -64%) rotate(40deg) scale(1.2); }
  66%  { transform: translate(-30%, -36%) rotate(-12deg) scale(1.1); }
  100% { transform: translate(-56%, -60%) rotate(22deg) scale(0.95); }
}

/* surfaces: gradient fill + gradient 1px edge (padding-box / border-box);
   component hover rules that set border-color still win visibly */
body.is-subpage .g-surface,
body.is-subpage .dc-box,
body.is-subpage .di-item,
body.is-subpage .cert-card,
body.is-subpage .part-card,
body.is-subpage .side-box,
body.is-subpage .quote-aside,
body.is-subpage .kon-map {
  border: 1px solid transparent;
  background: var(--g-surface) padding-box, var(--g-base) padding-box, var(--g-edge) border-box;
}

/* primary surface: the page's focal panel (strongest treatment) */
body.is-subpage .g-surface--primary,
body.is-subpage .svc-detail {
  border: 1px solid transparent;
  background: var(--g-surface-primary) padding-box, var(--g-base) padding-box, var(--g-edge-primary) border-box;
  box-shadow: 0 40px 90px -50px rgba(var(--c-orange), 0.25), 0 30px 60px -40px rgba(0, 0, 0, 0.9);
}

/* section band: a soft blue lift that separates a section without a box */
body.is-subpage .g-band { background-image: var(--g-band); }

/* hairline divider in brand gradient (replaces flat grey rules where used) */
body.is-subpage .g-rule { border-top-color: transparent !important; border-image: var(--g-rule) 1; }

/* ---------------- department page specifics ---------------- */
/* avatar ring picks up the same edge gradient as the card */
body.is-subpage .dh-avatar {
  border: 1px solid transparent;
  background:
    radial-gradient(circle at 50% 30%, rgba(var(--c-orange), 0.16), rgba(var(--c-orange), 0.04) 70%) padding-box,
    var(--g-base) padding-box,
    linear-gradient(160deg, rgba(var(--c-orange), 0.7), rgba(var(--c-blue-l), 0.4)) border-box;
}
body.is-subpage[data-page='direktor'] .dh-avatar { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.025), 0 18px 50px -12px rgba(var(--c-orange), 0.35); }

/* ---------------- mobile: fewer, calmer fields ---------------- */
@media (max-width: 575px) {
  :root { --g-k: 0.75; }
  body.is-subpage[data-page] { --m1x: 70%; --m1y: 12%; --m3x: 20%; --m3y: 22%; }
  .sp-mesh > i:nth-child(2),
  .sp-mesh > i:nth-child(4) { display: none; }
  .sp-mesh > i:nth-child(1) { animation-duration: 24s; }
  .sp-mesh > i:nth-child(3) { animation-duration: 33s; }
  body.is-subpage .g-surface--primary,
  body.is-subpage .svc-detail { box-shadow: 0 24px 50px -36px rgba(var(--c-orange), 0.22); }
}

/* reduced motion: same mesh, frozen */
@media (prefers-reduced-motion: reduce) {
  .sp-mesh > i:nth-child(n) { animation: none; } /* :nth-child(n) matches the per-field specificity */
}

/* =====================================================================
   BORDER BEAM (shared): an orange comet with a brand-blue tail orbiting
   the 1px edge of a card. Add class="beam" to any rounded card.
   Used by the department contact card, landing "Naša snaga" cards and
   the certificate cards.
   ===================================================================== */
@property --beam-a {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
.beam { position: relative; isolation: isolate; }
.beam::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -1;
  padding: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: conic-gradient(
    from var(--beam-a),
    transparent 0deg 250deg,
    rgba(0, 125, 191, 0.45) 290deg,
    rgba(254, 135, 25, 0.55) 330deg,
    #fe8719 357deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: beam-spin 9s linear infinite;
  animation-delay: var(--beam-delay, 0s);
}
@keyframes beam-spin { to { --beam-a: 360deg; } }
@media (prefers-reduced-motion: reduce) { .beam::before { animation: none; } }
