/*!
 * Egil Matic UI enhancements: stylesheet  v1.0
 * Pair with enhancements.js. Load it AFTER nicepage.css and the page CSS.
 *
 * Every rule is scoped to a class that enhancements.js adds (html.egm, .egm-*),
 * so nothing on the page changes until the script runs, and switching a feature
 * off in the script's CONFIG also switches off its styles.
 *
 * Colours are the site's own Nicepage palette, read from egilmatic.com:
 *   teal  #006b6b (palette-4-base)   red    #e73132 (palette-2-base)
 *   yellow #f6d54e (palette-3-base)  grey   #e5e5e5 (header, u-grey-10)
 */

:root {
  --egm-teal: #006b6b;
  --egm-teal-dark: #204f4f;
  --egm-teal-rgb: 0, 107, 107;
  --egm-red: #e73132;
  --egm-red-light: #ee6b6c;
  --egm-yellow: #f6d54e;
  --egm-yellow-light: #f9e182;
  --egm-ink: #111111;
  --egm-ease: cubic-bezier(.2, .7, .2, 1);
  --egm-spring: cubic-bezier(.34, 1.56, .64, 1);
  /* Set by the script from the header's own background colour. */
  --egm-glass-rgb: 229, 229, 229;
  --egm-glass-alpha: .72;
  --egm-spot-rgb: 0, 107, 107;
  --egm-spot-warm-rgb: 246, 213, 78;
}

/* ==========================================================================
   5 + 6. Sticky nav with frosted glass
   The blur sits on an injected .egm-glass layer, not on the header itself:
   backdrop-filter on the header would trap Nicepage's fixed mobile menu
   (.u-nav-container-collapse) inside the header box.
   ========================================================================== */
/* (The script also sets position: relative if the header was static, so the
   glass layer has a box to sit in; Nicepage's fixed/absolute headers keep theirs.) */
html .u-header.egm-glass-on {
  z-index: 60;
  background-color: transparent !important;
}

html .u-header.egm-sticky {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 60;
}

/* Pages where Nicepage lays the header over the first section. */
html body.u-overlap .u-header.egm-sticky {
  position: fixed;
  left: 0;
  right: 0;
}

/* Lift the header (and the Nicepage mobile menu inside it) above everything
   while the mobile menu is open. */
html body.u-offcanvas-opened .u-header.egm-sticky,
html body.u-offcanvas-opened .u-header.egm-glass-on {
  z-index: 100001;
}

.egm-glass {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: rgba(var(--egm-glass-rgb), var(--egm-glass-top, 1));
  transition: background-color .35s ease, box-shadow .35s ease;
}

.u-header.is-scrolled > .egm-glass {
  background-color: rgba(var(--egm-glass-rgb), var(--egm-glass-alpha));
  -webkit-backdrop-filter: saturate(170%) blur(14px);
  backdrop-filter: saturate(170%) blur(14px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .06), 0 12px 30px -14px rgba(0, 40, 40, .45);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .u-header.is-scrolled > .egm-glass {
    background-color: rgba(var(--egm-glass-rgb), .97);
  }
}

/* ==========================================================================
   8. Dropdown menus (desktop) and expandable sub-lists (mobile menu)
   ========================================================================== */
.egm-dd-item {
  position: relative;
}

/* Nicepage renders each menu link as a block inside an inline-block <li>;
   lay the link and its toggle out side by side. */
html .u-nav > li.egm-dd-item {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}

.egm-dd-toggle,
.egm-subnav-toggle {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0 0 0 2px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--egm-dd-toggle-color, var(--egm-teal));
  vertical-align: middle;
  cursor: pointer;
  line-height: 1;
  transition: background-color .2s ease, color .2s ease;
}

.egm-dd-toggle svg,
.egm-subnav-toggle svg {
  width: 12px;
  height: 12px;
  transition: rotate .25s var(--egm-ease);
}

.egm-dd-item.is-open > .egm-dd-toggle svg,
.egm-subnav-item.is-open > .egm-subnav-toggle svg {
  rotate: 180deg;
}

.egm-dd-toggle:hover,
.egm-dd-item.is-open > .egm-dd-toggle {
  background-color: rgba(var(--egm-teal-rgb), .1);
  color: var(--egm-red);
}

.egm-dd-toggle:focus-visible,
.egm-subnav-toggle:focus-visible {
  outline: 2px solid var(--egm-red);
  outline-offset: 2px;
}

.egm-dd {
  position: absolute;
  top: 100%;
  left: -16px;
  z-index: 5;
  min-width: 250px;
  margin: 0;
  padding: 8px;
  list-style: none;
  text-align: left;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  backdrop-filter: saturate(160%) blur(16px);
  border-top: 3px solid var(--egm-red);
  border-radius: 4px 4px 12px 12px;
  box-shadow: 0 22px 44px -18px rgba(0, 40, 40, .5), 0 2px 8px rgba(0, 0, 0, .06);
  opacity: 0;
  visibility: hidden;
  translate: 0 10px;
  transition: opacity .2s ease, translate .25s var(--egm-ease), visibility 0s linear .25s;
}

/* Invisible bridge so the pointer can travel from the link to the panel. */
.egm-dd::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 14px;
}

.egm-dd.egm-dd--end {
  left: auto;
  right: -16px;
}

.egm-dd-item.is-open > .egm-dd {
  opacity: 1;
  visibility: visible;
  translate: 0 4px;
  transition-delay: 0s;
}

.egm-dd > li {
  display: block;
  float: none;
  margin: 0 !important;
  padding: 0;
}

.egm-dd a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--egm-teal-dark);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .2s ease, color .2s ease;
}

.egm-dd a::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--egm-red);
  opacity: .35;
  transition: opacity .2s ease, scale .2s ease;
}

.egm-dd a:hover,
.egm-dd a:focus-visible {
  background-color: rgba(var(--egm-teal-rgb), .08);
  color: var(--egm-teal);
}

.egm-dd a:hover::before,
.egm-dd a:focus-visible::before {
  opacity: 1;
  scale: 1.4;
}

.egm-dd a:focus-visible {
  outline: 2px solid var(--egm-teal);
  outline-offset: -2px;
}

/* Mobile (Nicepage off-canvas menu) */
.egm-subnav-item {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.egm-subnav-toggle {
  color: inherit;
  margin-left: 6px;
}

.egm-subnav {
  flex: 0 0 100%;
  margin: 0 0 10px;
  padding: 4px 0;
  list-style: none;
  border-top: 1px solid rgba(255, 255, 255, .18);
  border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.egm-subnav[hidden] {
  display: none;
}

.egm-subnav a {
  display: block;
  padding: 7px 10px;
  color: inherit;
  font-size: 16px;
  line-height: 1.3;
  text-decoration: none;
  opacity: .9;
}

.egm-subnav a:hover,
.egm-subnav a:focus-visible {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ==========================================================================
   7. Hover feedback: links, buttons, cards
   ========================================================================== */

/* Buttons: light sheen sweep plus a small scale; the site's own colour change stays. */
html.egm-hover .u-btn {
  background-image: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .38) 50%, transparent 65%);
  background-repeat: no-repeat;
  background-size: 260% 100%;
  background-position: 130% 0;
  transition-property: background-color, color, border-color, box-shadow, background-position, scale, translate;
  transition-duration: .25s, .25s, .25s, .25s, .7s, .25s, .45s;
  transition-timing-function: ease, ease, ease, ease, ease, var(--egm-ease), var(--egm-spring);
}

html.egm-hover .u-btn:focus-visible {
  outline: 3px solid var(--egm-yellow);
  outline-offset: 3px;
}

/* Magnetic button follows the pointer quickly while pulled, springs back after. */
html.egm-hover .u-btn.egm-magnet.is-pulled {
  transition-duration: .25s, .25s, .25s, .25s, .7s, .25s, .18s;
}

html:not(.egm-hover) .egm-magnet {
  transition: translate .45s var(--egm-spring);
}

html:not(.egm-hover) .egm-magnet.is-pulled {
  transition-duration: .18s;
}

/* Nav links: animated underline (the current page keeps it). */
html.egm-hover .u-header .u-nav-container .u-nav > li > a.u-nav-link {
  background-image: linear-gradient(var(--egm-red), var(--egm-red));
  background-repeat: no-repeat;
  background-position: 0 calc(100% - 4px);
  background-size: 0% 2px;
  transition: background-size .3s var(--egm-ease), color .2s ease;
}

html.egm-hover .u-header .u-nav-container .u-nav > li > a.u-nav-link.active,
html.egm-hover .u-header .u-nav-container .u-nav > li > a.u-nav-link:focus-visible {
  background-size: 100% 2px;
}

html.egm-hover .u-header .u-nav-container .u-nav > li > a.u-nav-link:focus-visible,
html.egm-hover .u-footer a:focus-visible,
html.egm-hover .u-language-url:focus-visible,
html.egm-hover .u-logo:focus-visible {
  outline: 2px solid var(--egm-red);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Footer and in-text links */
html.egm-hover .u-footer .u-nav-link,
html.egm-hover section .u-text a:not(.u-btn):not(.u-button-style) {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size .3s var(--egm-ease), opacity .2s ease;
}

/* Language flags and logo */
html.egm-hover .u-language-url .u-icon {
  transition: scale .2s var(--egm-spring);
}

html.egm-hover .u-logo {
  transition: opacity .2s ease;
}

/* Cards (service tiles and image tiles) */
.egm-card {
  position: relative;
  transition: transform .5s var(--egm-ease), box-shadow .35s ease;
}

.egm-card.is-tilting {
  transition: transform .12s linear, box-shadow .35s ease;
  will-change: transform;
}

html.egm-hover .egm-card .u-icon-circle {
  transition: scale .4s var(--egm-spring), box-shadow .3s ease;
}

.egm-glare {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(circle at var(--egm-gx, 50%) var(--egm-gy, 50%), rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 55%);
  opacity: 0;
  transition: opacity .35s ease;
}

.egm-card.is-tilting > .egm-glare {
  opacity: 1;
}

@media (hover: hover) {
  html.egm-hover .u-btn:hover {
    background-position: -30% 0;
    scale: 1.045;
  }

  html.egm-hover .u-btn:active {
    scale: .97;
  }

  html.egm-hover .u-header .u-nav-container .u-nav > li > a.u-nav-link:hover {
    background-size: 100% 2px;
  }

  html.egm-hover .u-footer .u-nav-link:hover,
  html.egm-hover section .u-text a:not(.u-btn):not(.u-button-style):hover {
    background-size: 100% 1px;
  }

  html.egm-hover .u-language-url:hover .u-icon {
    scale: 1.18;
  }

  html.egm-hover .u-logo:hover {
    opacity: .85;
  }

  html.egm-hover .egm-card:hover {
    box-shadow: 0 26px 48px -22px rgba(0, 40, 40, .55), 0 6px 14px -8px rgba(0, 0, 0, .18);
    z-index: 2;
  }

  html.egm-hover .egm-card:hover .u-icon-circle {
    scale: 1.08;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, .14);
  }
}

html.egm-hover .egm-card:focus-within {
  box-shadow: 0 0 0 3px var(--egm-yellow);
}

/* ==========================================================================
   4. Scroll reveal
   ========================================================================== */
.egm-reveal {
  opacity: 0;
  translate: 0 var(--egm-reveal-distance, 28px);
  transition: opacity .8s ease var(--egm-delay, 0ms), translate .9s var(--egm-ease) var(--egm-delay, 0ms);
}

.egm-reveal.is-in {
  opacity: 1;
  translate: none;
}

/* ==========================================================================
   2 + 9. Cursor spotlight and custom cursor
   Both live in one fixed, clipped layer that never takes clicks.
   ========================================================================== */
.egm-fx {
  position: fixed;
  inset: 0;
  z-index: 2147482000;
  overflow: hidden;
  pointer-events: none;
}

.egm-spotlight {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--egm-spot-size, 560px);
  height: var(--egm-spot-size, 560px);
  margin: calc(var(--egm-spot-size, 560px) / -2) 0 0 calc(var(--egm-spot-size, 560px) / -2);
  border-radius: 50%;
  background: radial-gradient(closest-side,
    rgba(var(--egm-spot-warm-rgb), .22),
    rgba(var(--egm-spot-rgb), .10) 45%,
    rgba(var(--egm-spot-rgb), 0) 100%);
  opacity: 0;
  transition: opacity .5s ease;
  will-change: transform;
}

.egm-spotlight.is-on {
  opacity: 1;
}

.egm-cursor-dot,
.egm-cursor-ring {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  opacity: 0;
  will-change: transform;
}

.egm-cursor-dot {
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--egm-red);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85);
  transition: opacity .2s ease, scale .2s ease;
}

/* The ring stays centred on the dot. Over links and buttons its diameter
   doubles (--egm-ring), while the border stays 2px thin. */
.egm-cursor-ring {
  --egm-ring: 38px;
  width: var(--egm-ring);
  height: var(--egm-ring);
  margin: calc(var(--egm-ring) / -2) 0 0 calc(var(--egm-ring) / -2);
  border: 2px solid rgba(var(--egm-teal-rgb), .75);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .5), inset 0 0 0 1px rgba(255, 255, 255, .35);
  transition: opacity .2s ease,
    width .3s var(--egm-ease), height .3s var(--egm-ease), margin .3s var(--egm-ease),
    scale .2s ease, background-color .25s ease, border-color .25s ease;
}

.egm-cursor-visible .egm-cursor-dot,
.egm-cursor-visible .egm-cursor-ring {
  opacity: 1;
}

.egm-cursor-ring.is-hover {
  --egm-ring: 76px;
  border-color: var(--egm-red);
  background-color: rgba(var(--egm-teal-rgb), .08);
}

.egm-cursor-ring.is-down {
  scale: .85;
}

.egm-cursor-visible.egm-cursor-text .egm-cursor-dot,
.egm-cursor-visible.egm-cursor-text .egm-cursor-ring {
  opacity: 0;
}

/* Hide the system pointer only while the custom one is showing, only for a
   mouse or trackpad, and never when the visitor asked for reduced motion. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  html.egm-cursor-hide-native.egm-cursor-visible,
  html.egm-cursor-hide-native.egm-cursor-visible * {
    cursor: none !important;
  }

  html.egm-cursor-hide-native.egm-cursor-visible input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]),
  html.egm-cursor-hide-native.egm-cursor-visible textarea,
  html.egm-cursor-hide-native.egm-cursor-visible select,
  html.egm-cursor-hide-native.egm-cursor-visible [contenteditable] {
    cursor: auto !important;
  }
}

/* ==========================================================================
   10. Scroll cue in the hero (an in-page anchor that uses smooth scrolling)
   ========================================================================== */
.egm-has-cue {
  position: relative;
}

.egm-cue {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  border: 2px solid rgba(255, 255, 255, .65);
  border-radius: 50%;
  background: rgba(0, 0, 0, .2);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  text-decoration: none;
  transition: background-color .25s ease, border-color .25s ease, scale .25s var(--egm-spring);
}

.egm-cue svg {
  width: 18px;
  height: 18px;
  animation: egm-bob 1.9s ease-in-out infinite;
}

.egm-cue:hover,
.egm-cue:focus-visible {
  background-color: var(--egm-red);
  border-color: var(--egm-red);
  scale: 1.08;
}

.egm-cue:focus-visible {
  outline: 3px solid var(--egm-yellow);
  outline-offset: 3px;
}

@keyframes egm-bob {
  0%, 100% { translate: 0 -2px; }
  50% { translate: 0 4px; }
}

.egm-anchor-target:focus {
  outline: none;
}

@media (prefers-reduced-motion: no-preference) {
  html.egm-smooth {
    scroll-behavior: smooth;
  }
}

/* ==========================================================================
   11. Back-to-top button (replaces Nicepage's .u-back-to-top)
   ========================================================================== */
html.egm-top-on .u-back-to-top {
  display: none !important;
}

.egm-top {
  -webkit-appearance: none;
  appearance: none;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9990;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--egm-yellow);
  color: var(--egm-teal);
  box-shadow: 0 10px 24px -10px rgba(0, 40, 40, .55);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  translate: 0 16px;
  scale: .9;
  transition: opacity .3s ease, translate .4s var(--egm-spring), scale .3s var(--egm-ease),
    visibility 0s linear .4s, background-color .2s ease, box-shadow .2s ease;
}

.egm-top.is-visible {
  opacity: 1;
  visibility: visible;
  translate: none;
  scale: 1;
  transition-delay: 0s;
}

.egm-top svg {
  grid-area: 1 / 1;
  display: block;
}

.egm-top-ring {
  width: 100%;
  height: 100%;
  rotate: -90deg;
}

.egm-top-ring circle {
  fill: none;
  stroke: var(--egm-teal);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: var(--egm-progress, 100);
  opacity: .8;
}

.egm-top-arrow {
  width: 20px;
  height: 20px;
  transition: translate .25s var(--egm-ease);
}

.egm-top:focus-visible {
  outline: 3px solid var(--egm-teal);
  outline-offset: 3px;
}

@media (hover: hover) {
  .egm-top.is-visible:hover {
    background: var(--egm-yellow-light);
    box-shadow: 0 16px 30px -10px rgba(0, 40, 40, .6);
    translate: 0 -3px;
  }

  .egm-top:hover .egm-top-arrow {
    translate: 0 -2px;
  }
}

@media (max-width: 575px) {
  .egm-top {
    right: 14px;
    bottom: 14px;
    width: 48px;
    height: 48px;
  }

  .egm-dd {
    min-width: 0;
  }
}

/* ==========================================================================
   Touch screens: no custom cursor or spotlight
   ========================================================================== */
@media (hover: none), (pointer: coarse) {
  .egm-cursor-dot,
  .egm-cursor-ring,
  .egm-spotlight {
    display: none !important;
  }
}

/* ==========================================================================
   prefers-reduced-motion: no tilt, magnet, reveal, custom cursor or bobbing
   (the script also skips them; these rules cover a setting changed mid-visit)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .egm-reveal {
    opacity: 1 !important;
    translate: none !important;
    transition: none !important;
  }

  .egm-card {
    transform: none !important;
  }

  .egm-glare,
  .egm-cursor-dot,
  .egm-cursor-ring {
    display: none !important;
  }

  .u-btn.egm-magnet {
    translate: none !important;
  }

  .egm-cue svg {
    animation: none;
  }

  html.egm-hover .u-btn:hover,
  html.egm-hover .u-btn:active,
  .egm-top.is-visible:hover {
    scale: none;
    translate: none;
  }

  .egm-dd,
  .egm-dd-item.is-open > .egm-dd,
  .egm-top {
    translate: none;
  }
}

@media print {
  .egm-fx,
  .egm-top,
  .egm-cue,
  .egm-glare {
    display: none !important;
  }
}
