/* ==========================================================================
   COMPONENTS — pieces used by more than one section
   ========================================================================== */

/* --- CTA: ring + arrow + label --------------------------------------------
   Used in the footer («В дірект») and under the cases teaser on the main
   page («Усі кейси»). One component, so a visitor who met it once
   recognises the second one without learning it again.

   Geometry from Figma: ring 52 × 52, arrow 15 wide centred in the ring,
   label 10 after the ring. The whole thing is ONE link, so the tap target
   is the full 52-tall row, not just the words.

   <a class="cta" href="…">
     <span class="cta__ring" aria-hidden="true"><svg class="cta__arrow">…</svg></span>
     <span class="cta__label t-marker">Label</span>
   </a>

   Feedback — one animation for every device:
   - the ring fills with accent from the centre, the arrow turns cream,
     runs out through the right edge and comes back in from the left;
     on a mouse it plays on HOVER (and keyboard focus), on a touch screen
     on the PRESS. A tap is too short to play an animation on :active —
     the state would drop the moment the finger lifts — so js/cta.js
     latches it with the .is-pressed class until the page is left or the
     tap turns into a scroll;
   - a mouse CLICK (.is-leaving, js/cta.js): the arrow leaves through the
     right edge and does not come back — the link is on its way.
   -------------------------------------------------------------------------- */

.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;                 /* 10 */
  color: var(--color-ink);
  /* No grey flash box from mobile browsers on tap: the ring's own fill
     is the feedback. */
  -webkit-tap-highlight-color: transparent;
}

.cta__ring {
  position: relative;
  isolation: isolate;            /* keeps the fill's z-index inside the ring */
  overflow: hidden;              /* clips the arrow as it leaves the circle */
  flex: none;
  display: grid;
  place-items: center;
  width: 3.25rem;                /* 52 */
  height: 3.25rem;
  border-radius: 50%;
  /* A hairline accent ring, 0.5 px as in Figma: on 2x/3x phones that is
     one or two device pixels. The accent already draws the other thin
     lines of the site (the X over «фабрика», the ellipse around the
     desktop portrait), so the button belongs to the same family.
     The ring is an inset shadow, not a border. A border sits OUTSIDE
     the clipped area, so the ink fill would meet it edge to edge and the
     two anti-aliased curves leave a thin cream seam between them. The
     inset shadow is painted inside the clip, under the fill: at full size
     the fill simply covers it and there is only one edge left. */
  box-shadow: inset 0 0 0 0.5px var(--color-accent);
  transition: box-shadow 200ms ease;
}

/* The fill: an accent disc under the arrow, scaled to nothing at rest.
   Accent, not ink: the press is a moment of emphasis, and the ring is
   already drawn in the accent — the fill completes the same colour.
   The cream arrow on it: 3.99:1, above the 3:1 asked of icons. */
.cta__ring::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background: var(--color-accent);
  transform: scale(0);
  transition: transform 600ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.cta__arrow {
  width: 0.9375rem;              /* 15 */
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  transition: transform 200ms ease, color 400ms ease;
}

/* --- Pressed (touch) and hovered (mouse) ---------------------------------
   Hover only where a real mouse exists: on touch screens :hover sticks
   after a tap and would leave the button looking "stuck pressed". */

.cta.is-pressed .cta__ring::before,
.cta:focus-visible .cta__ring::before {
  transform: scale(1);
}

.cta.is-pressed .cta__arrow,
.cta:focus-visible .cta__arrow {
  color: var(--color-bg);
  animation: cta-arrow-through 900ms both;
}

@media (hover: hover) and (pointer: fine) {
  .cta:hover .cta__ring::before {
    transform: scale(1);
  }

  .cta:hover .cta__arrow {
    color: var(--color-bg);
    animation: cta-arrow-through 900ms both;
  }
}

/* --- Clicked (mouse) ------------------------------------------------------
   Declared after hover so it wins: a new animation name restarts the
   arrow from wherever it is and sends it out for good ("forwards"). */

.cta.is-leaving .cta__ring::before {
  transform: scale(1);
}

.cta.is-leaving .cta__arrow {
  color: var(--color-bg);
  animation: cta-arrow-out 320ms cubic-bezier(0.5, 0, 0.9, 0.5) forwards;
}

@keyframes cta-arrow-out {
  to {
    transform: translateX(2.25rem);
  }
}

/* The arrow leaves through the right edge, jumps (unseen, outside the
   clipped circle) to the left, and slides back to the centre. 2.25rem is
   enough for a 15-wide arrow centred in a 52 ring to clear the edge
   completely: 26 + 7.5 < 36. */
@keyframes cta-arrow-through {
  0% {
    transform: translateX(0);
    animation-timing-function: cubic-bezier(0.5, 0, 0.9, 0.5);   /* ease-in */
  }
  42% {
    transform: translateX(2.25rem);
    animation-timing-function: steps(1, end);                   /* jump */
  }
  43% {
    transform: translateX(-2.25rem);
    animation-timing-function: cubic-bezier(0.1, 0.5, 0.3, 1);  /* ease-out */
  }
  100% {
    transform: translateX(0);
  }
}

/* ==========================================================================
   CURSOR — the inverting circle (js/cursor.js), mouse only
   --------------------------------------------------------------------------
   Outer box: moved by the script every frame, no transition (the trail is
   done in JS). Inner dot: the visible circle; its size changes with a
   transition — 56 at rest, a 10-px dot over anything clickable, a thin
   ring over photos and video. mix-blend-mode: difference with white is a
   true invert of whatever is underneath, on cream and on ink alike.
   ========================================================================== */
.cursor {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity 200ms ease;
}

.cursor.is-active {
  opacity: 1;
}

.cursor__dot {
  position: absolute;
  top: -1.75rem;
  left: -1.75rem;
  width: 3.5rem;                               /* 56 */
  height: 3.5rem;
  border: 1.5px solid #fff;
  border-radius: 50%;
  background: #fff;
  transition: transform 250ms cubic-bezier(0.2, 0.7, 0.2, 1),
              background-color 200ms ease;
}

.cursor.is-link .cursor__dot {
  transform: scale(0.18);                      /* ≈ 10 px */
}

.cursor.is-media .cursor__dot {
  background: transparent;
}

/* The system pointer goes only once the circle is there. */
.has-cursor,
.has-cursor * {
  cursor: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .cursor__dot {
    transition: none;
  }
}

/* ==========================================================================
   SCROLLBAR — a 4-px thumb over the page's right edge (js/scrollbar.js)
   --------------------------------------------------------------------------
   Mouse only. The browser's own bar is hidden only when the script runs
   (html.has-scrollbar), so without JS nothing is lost. Inverted against
   what is under it: light on the black Hero, dark on cream.
   ========================================================================== */
.has-scrollbar {
  scrollbar-width: none;                 /* Firefox, Chrome 121+ */
}

.has-scrollbar::-webkit-scrollbar {
  display: none;                         /* Safari, older Chrome */
}

.scrollbar {
  position: fixed;
  z-index: 90;                           /* over the header bar and the menu */
  top: 0;
  right: 0;
  bottom: 0;
  width: 0.875rem;                       /* 14: the hit strip, wider than the thumb */
  mix-blend-mode: difference;
}

/* While the thumb is held: no text gets selected as the pointer sweeps
   across the page. */
.is-scroll-dragging,
.is-scroll-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

.scrollbar {
  touch-action: none;
}

.scrollbar__thumb {
  position: absolute;
  top: 0;
  right: 0.25rem;                        /* 4 from the edge */
  width: 0.25rem;                        /* 4 */
  border-radius: 0.125rem;
  background: #fff;
  opacity: 0.28;
  transition: opacity 300ms ease, width 150ms ease;
  will-change: transform;
}

.scrollbar.is-active .scrollbar__thumb,
.scrollbar:hover .scrollbar__thumb,
.scrollbar.is-dragging .scrollbar__thumb {
  opacity: 0.6;
}

.scrollbar:hover .scrollbar__thumb,
.scrollbar.is-dragging .scrollbar__thumb {
  width: 0.375rem;                       /* 6 */
}

@media (prefers-reduced-motion: reduce) {
  .scrollbar__thumb {
    transition: none;
  }
}
