/* Pixel icons: HackerNoon Pixel Icon Library v1.1.0 (icons CC BY 4.0,
   https://pixeliconlibrary.com, https://creativecommons.org/licenses/by/4.0/).
   Source SVGs vendored unchanged in /images/pixel-icons/ with the LICENSE.
   Inline icons use fill="currentColor", so they follow the colour tokens
   of the element they sit in, in light and dark mode. */

/* Base: 24px boxes keep their original footprint (no layout shift); the
   pixel glyph is drawn at 16px inside, which matches the optical size of
   the old 12-14px Unicons glyphs. */
svg.px-icon {
  box-sizing: border-box;
  flex: none;
  padding: 4px;
  overflow: visible;
}

/* Text-sized icons that replace glyphs like the old north-east arrow.
   0.8em keeps them close to the width of the mono glyph they replace. */
svg.px-icon.px-icon--inline {
  width: 0.8em;
  height: 0.8em;
  padding: 0;
  vertical-align: -0.05em;
}

/* Icons that should fill their box (slider chevrons). */
svg.px-icon.px-icon--full {
  padding: 0;
}

/* Video play button: white on the video, as before. 48px desktop,
   34px from the existing breakpoints; the glyph keeps the old proportion. */
svg.play-icon.px-icon--play {
  color: #fff;
  padding: 4%;
}

/* Video popup close: the old white SVG disappeared on the light circle.
   The circle keeps its size (40px, 32px on small screens); the cross uses
   the text token so it reads in both modes. */
.close-button-white.px-close {
  color: var(--color--text);
}

.close-button-white.px-close svg.px-icon {
  width: 60%;
  height: 60%;
  padding: 0;
}

/* Testimonial slider: library chevrons replace the Webflow icon font. */
.icon-2.px-slider-icon {
  display: flex;
  justify-content: center;
  line-height: 0;
}

/* Webflow lightbox controls: swap the built-in arrows and close for the
   library glyphs, white on the dark lightbox backdrop. */
.w-lightbox-control {
  background-image: none !important;
}

.w-lightbox-control::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 24px;
  height: 24px;
  background-color: #fff;
  -webkit-mask: var(--px-mask) center / contain no-repeat;
  mask: var(--px-mask) center / contain no-repeat;
}

.w-lightbox-left {
  --px-mask: url("../images/pixel-icons/angle-left.svg");
}

.w-lightbox-right {
  --px-mask: url("../images/pixel-icons/angle-right.svg");
}

.w-lightbox-close {
  --px-mask: url("../images/pixel-icons/times.svg");
}

.w-lightbox-close::before {
  width: 18px;
  height: 18px;
}

/* ------------------------------------------------------------------
   Icon weight matches the text (LAW-4)
   The library glyphs are drawn with 2-unit strokes on a 24-unit grid, so
   at 16-20px one stroke came out at 1.3-1.7px, under the text stroke and
   off the pixel grid (soft edges). Next to text the icons now use bold
   variants (*-bold.svg) drawn on a 1-unit-stroke grid, and one unit is
   set to the font's own pixel stroke:
     Departure Mono: 1 font pixel = 1em / 11 (550 upm, 50-unit pixels)
     PP NeueBit Bold: strokes are 2 font pixels = 1em / 14
   That unit is rounded to whole device pixels (1px at 1x, 0.5px at 2x,
   1/3px at 3x), so the icon edges stay crisp. The inline <svg> keeps its
   markup; its glyph is hidden and the bold variant is painted as a mask
   in currentColor. Glyphs are picked by the library polygon, so no HTML
   change is needed. Browsers without :has() or round() keep the
   original icons.
   ------------------------------------------------------------------ */

:root {
  --px-dp: 1px;
}

@media (min-resolution: 2dppx) {
  :root {
    --px-dp: 0.5px;
  }
}

@media (min-resolution: 3dppx) {
  :root {
    --px-dp: calc(1px / 3);
  }
}

/* Which bold glyph each library icon becomes, with its grid size. */
svg.px-icon:has(> polygon[points^="23 11 23 13 22 13"]) {
  --px-b: url("../images/pixel-icons/arrow-right-bold.svg");
  --px-bw: 9;
  --px-bh: 7;
}

svg.px-icon:has(> polygon[points^="23 11 23 13 5 13"]) {
  --px-b: url("../images/pixel-icons/arrow-left-bold.svg");
  --px-bw: 9;
  --px-bh: 7;
}

svg.px-icon:has(> polygon[points^="23 12 23 13 22 13"]) {
  --px-b: url("../images/pixel-icons/arrow-down-bold.svg");
  --px-bw: 7;
  --px-bh: 9;
}

svg.px-icon:has(> polygon[points^="14 13 15 13 15 14"]) {
  --px-b: url("../images/pixel-icons/times-bold.svg");
  --px-bw: 8;
  --px-bh: 8;
}

svg.px-icon:has(> rect[y="11"][height="2"]) {
  --px-b: url("../images/pixel-icons/bars-bold.svg");
  --px-bw: 9;
  --px-bh: 7;
}

/* Text pixel per context (--px-t, before rounding). The em is the
   font-size of the svg, which inherits it from the text it sits in;
   where the icon sits in its own box, that box gets the text's size. */
.button-link .icon-right-button,
.link .px-icon,
.case-outline-back .px-icon,
.back-button.stories-button .px-icon {
  --px-t: calc(1em / 11); /* Departure Mono */
}

.back-button:not(.stories-button) .px-icon {
  --px-t: calc(1em / 14); /* PP NeueBit Bold */
}

/* Icon boxes beside .button-link-text: mirror the text size
   (20px; .sm 18px; .big 24px; 18px under 480px except .big). */
.button-link .icon-right-button {
  font-size: 20px;
}

.button-link:has(> .button-link-text.sm) .icon-right-button {
  font-size: 18px;
}

.button-link:has(> .button-link-text.big) .icon-right-button {
  font-size: 24px;
}

@media screen and (max-width: 479px) {
  .button-link .icon-right-button {
    font-size: 18px;
  }

  .button-link:has(> .button-link-text.big) .icon-right-button {
    font-size: 24px;
  }
}

/* Standalone controls with no text beside them: a fixed 2px unit, the
   same stroke as the 24px lightbox arrows. */
.close-button-white .px-icon,
.icon-menu .px-icon,
:is(.button.link.overlay, .button-2.link.overlay) .px-icon {
  --px-t: 2px;
}

/* Paint the bold glyph. */
:is(
  .button-link .icon-right-button,
  .link,
  .case-outline-back,
  .back-button,
  .close-button-white,
  .icon-menu,
  .button.link.overlay,
  .button-2.link.overlay
) svg.px-icon:is(:has(> polygon), :has(> rect)) {
  --px-u: max(var(--px-dp), round(nearest, var(--px-t, calc(1em / 11)), var(--px-dp)));
  box-sizing: content-box;
  width: calc(var(--px-bw) * var(--px-u));
  height: calc(var(--px-bh) * var(--px-u));
  padding: 0;
  background-color: currentColor;
  -webkit-mask: var(--px-b) 0 0 / 100% 100% no-repeat;
  mask: var(--px-b) 0 0 / 100% 100% no-repeat;
}

:is(
  .button-link .icon-right-button,
  .link,
  .case-outline-back,
  .back-button,
  .close-button-white,
  .icon-menu,
  .button.link.overlay,
  .button-2.link.overlay
) svg.px-icon > * {
  display: none;
}

/* Inline icons: the 7-unit arrows sit on the baseline, which centres
   them on the lowercase and cap height of both pixel fonts (Departure
   Mono caps are 8 px tall, NeueBit caps 7 units). The gap before the
   arrow is one text pixel times two. */
:is(.link, .case-outline-back, .back-button) svg.px-icon {
  vertical-align: 0;
}

/* Image badge (case-pixel.css sets 16px; this is one notch more specific). */
:is(.case-study-section, .case-study-section-2) :is(.button.link.overlay, .button-2.link.overlay) svg.px-icon {
  width: calc(var(--px-bw) * var(--px-u));
  height: calc(var(--px-bh) * var(--px-u));
}

/* Close buttons: centre the bold cross in the old 24px box. */
.close-button-white .px-icon {
  margin: auto;
}

/* Lightbox close: the bold cross at a 2px unit (16px), like the arrows. */
.w-lightbox-close {
  --px-mask: url("../images/pixel-icons/times-bold.svg");
}

.w-lightbox-close::before {
  width: 16px;
  height: 16px;
}

/* A bit more air between icon and label in buttons (bold icons are
   tighter than the old 24-grid boxes). */
.back-button svg.px-icon {
  margin-right: 4px;
}

.button-link .icon-right-button {
  margin-left: 4px;
}
