/* ═══ km-nav: the one round button for every gallery, slider and rail ═══
   Glass at rest; on hover a spruce fill grows from the centre and the arrow
   flies out and back in the direction it points; a press springs. --dark is
   the same button over a dark viewer.

   Each component keeps its own position, display, transform and opacity
   (where it sits, when it hides, how it lifts). This sheet only DRAWS the
   button, but it has to win over page sheets that style the old buttons with
   !important and id hacks — hence the strong selector `.km-nav:not(#…)` (3 ids)
   and !important on drawing properties only. Size: set --nav-size on the
   component (default 52px, 44px on phones).

   Markup: <button class="… km-nav km-nav--next">{% include 'includes/km_nav_icon.html' with icon='arrow' %}</button> */
@property --km-p { syntax: '<number>'; inherits: false; initial-value: 0; }

:where(.km-nav) { position: relative; display: inline-grid; place-items: center; }
.km-nav { --nav-size: 52px; --nav-bg: rgb(255 255 255 / 88%); --nav-ink: var(--brand-spruce, #0d4924); --nav-fill: var(--brand-spruce, #0d4924); --nav-on-fill: #fff; --dir: 1; }
.km-nav--prev { --dir: -1; }
.km-nav--dark { --nav-ink: #fff; --nav-fill: #fff; --nav-on-fill: #0f1a14; }
@media (max-width: 600px) { .km-nav { --nav-size: 44px; } }

.km-nav:not(#km-a):not(#km-b):not(#km-c) {
  isolation: isolate !important;
  width: var(--nav-size) !important;
  height: var(--nav-size) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: var(--nav-bg) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.7) !important;
  backdrop-filter: blur(14px) saturate(1.7) !important;
  color: var(--nav-ink) !important;
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 90%),
    0 0 0 1px rgb(13 73 36 / 7%),
    0 1px 2px rgb(13 73 36 / 8%),
    0 14px 30px -14px rgb(13 73 36 / 50%) !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    color .3s ease, box-shadow .4s cubic-bezier(.22, 1, .36, 1), opacity .25s ease,
    transform .5s cubic-bezier(.34, 1.56, .64, 1), scale .5s cubic-bezier(.34, 1.56, .64, 1) !important;
}
.km-nav--dark:not(#km-a):not(#km-b):not(#km-c) {
  background: rgb(14 20 17 / 42%) !important;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 22%), 0 14px 34px -14px rgb(0 0 0 / 70%) !important;
}
/* the fill that grows from the centre (old buttons drew arrows with ::before: replaced) */
.km-nav:not(#km-a):not(#km-b):not(#km-c)::before {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  z-index: -1 !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: var(--nav-fill) !important;
  -webkit-mask: none !important;
  mask: none !important;
  filter: none !important;
  transform: none !important;
  opacity: 1 !important;
  scale: 0;
  transition: scale .5s cubic-bezier(.22, 1, .36, 1) !important;
}
.km-nav:not(#km-a):not(#km-b):not(#km-c) > svg,
.km-nav:not(#km-a):not(#km-b):not(#km-c) .km-nav__icon {
  display: block !important;
  width: 22px !important;
  height: 22px !important;
  pointer-events: none;
}
.km-nav--prev .km-nav__icon { transform: scaleX(-1); }
@media (max-width: 600px) {
  .km-nav:not(#km-a):not(#km-b):not(#km-c) .km-nav__icon { width: 20px !important; height: 20px !important; }
}

@media (hover: hover) and (pointer: fine) {
  .km-nav:not(#km-a):not(#km-b):not(#km-c):hover:not(:disabled) {
    color: var(--nav-on-fill) !important;
    box-shadow: 0 2px 4px rgb(13 73 36 / 12%), 0 18px 36px -14px rgb(13 73 36 / 65%) !important;
  }
  .km-nav--dark:not(#km-a):not(#km-b):not(#km-c):hover:not(:disabled) { box-shadow: 0 18px 40px -14px rgb(0 0 0 / 80%) !important; }
  .km-nav:not(#km-a):not(#km-b):not(#km-c):hover:not(:disabled)::before { scale: 1; }
}
.km-nav:active:not(:disabled) { scale: .88; }
.km-nav:not(#km-a):not(#km-b):not(#km-c):focus-visible { outline: 3px solid var(--brand-turf, #17a34a) !important; outline-offset: 3px !important; }
.km-nav--dark:not(#km-a):not(#km-b):not(#km-c):focus-visible { outline-color: #fff !important; }
.km-nav:disabled { opacity: .32; cursor: default; }

/* autoplay countdown: a thin ring round the "next" button while it counts */
.km-nav--ring::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(var(--brand-turf, #17a34a) calc(var(--km-p) * 1turn), rgb(13 73 36 / 12%) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
.km-nav--ring.is-counting::after { opacity: 1; animation: km-nav-ring var(--nav-ms, 4800ms) linear both; }
.km-nav--ring.is-counting.is-held::after { animation-play-state: paused; }

@media (prefers-reduced-motion: no-preference) {
  @media (hover: hover) and (pointer: fine) {
    .km-nav:hover:not(:disabled) .km-nav__icon { animation: km-nav-fly .55s cubic-bezier(.22, 1, .36, 1); }
  }
}
@media (prefers-reduced-motion: reduce) { .km-nav--ring::after { display: none; } }
@keyframes km-nav-fly {
  0% { translate: 0 0; opacity: 1; }
  38% { translate: calc(var(--dir) * 16px) 0; opacity: 0; }
  39% { translate: calc(var(--dir) * -16px) 0; opacity: 0; }
  100% { translate: 0 0; opacity: 1; }
}
@keyframes km-nav-ring { from { --km-p: 0; } to { --km-p: 1; } }

/* sizes that fit their place */
.catalog-category-strip__arrow.km-nav { --nav-size: 38px; }
.catalog-category-strip__arrow.km-nav:not(#km-a):not(#km-b):not(#km-c) .km-nav__icon { width: 18px !important; height: 18px !important; }
.home-parent-guide__controls .km-nav,
.home-spx__nav .km-nav { --nav-bg: #fff; }
.home-parent-guide__controls .km-nav,
.home-spx__nav .km-nav,
.home-rail-nav-btn.km-nav { --nav-size: 46px; }
