/* ==========================================================================
   Amiar & Kolesnik — Motion system (CSS part, integrated build)
   Works together with js/animations.js (GSAP 3 + ScrollTrigger).

   Principles
   - One easing everywhere: --ease (expo-out feel), fast hovers (0.2–0.35s),
     calm entrances (0.8–1.1s).
   - Initial "hidden" states are set here (not in JS) so there is no flash of
     content before JS runs. They apply ONLY when:
       1) <html> has class "js" (set by the inline snippet in <head>), and
       2) the user has no "reduce motion" preference.
   - If JS fails, <html> gets class "ak-fallback" after 3s and everything
     becomes visible.
   ========================================================================== */

:root {
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 0.2s;
  --dur-mid: 0.35s;
}

/* --------------------------------------------------------------------------
   1. Masks for line / word reveals
   -------------------------------------------------------------------------- */
.a-mask { display: block; overflow: hidden; }
.a-mask__inner { display: block; will-change: transform; }

/* words created by JS from [data-anim="words"] */
.a-word { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.a-word__inner { display: inline-block; will-change: transform; }

/* --------------------------------------------------------------------------
   2. Initial states (pre-animation). Only with JS + motion allowed.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  .js:not(.ak-fallback) [data-hero-line] .a-mask__inner,
  .js:not(.ak-fallback) [data-anim="lines"] .a-mask__inner { transform: translateY(110%); }

  .js:not(.ak-fallback) [data-anim="words"] { visibility: hidden; } /* un-hidden after split */

  /* .a-done is added by JS when the entrance has finished */
  .js:not(.ak-fallback) [data-anim="fade-up"]:not(.a-done),
  .js:not(.ak-fallback) [data-hero-fade]:not(.a-done),
  .js:not(.ak-fallback) [data-stagger] > *:not(.a-done):not([data-stagger-ignore]) { opacity: 0; transform: translateY(24px); }

  .js:not(.ak-fallback) [data-anim="reveal"] { clip-path: inset(100% 0 0 0); }
  .js:not(.ak-fallback) [data-anim="reveal"] [data-reveal-scale] { transform: scale(1.12); }
}

/* --------------------------------------------------------------------------
   3. Drawn borders — JS injects <span class="a-rule"> for each border of an
      element with [data-draw] and makes the real border transparent.
   -------------------------------------------------------------------------- */
[data-draw] { position: relative; }
.a-rule {
  position: absolute; pointer-events: none; z-index: 1;
  background: var(--line, #f6f7fb);
}
.a-rule--top    { left: 0; right: 0; top: -1px;    height: 1px; transform-origin: left center; }
.a-rule--bottom { left: 0; right: 0; bottom: -1px; height: 1px; transform-origin: left center; }
.a-rule--left   { top: 0; bottom: 0; left: -1px;   width: 1px;  transform-origin: center top; }
.a-rule--right  { top: 0; bottom: 0; right: -1px;  width: 1px;  transform-origin: center top; }

/* --------------------------------------------------------------------------
   4. Nav: hide on scroll down / show on scroll up + progress bar + active link
   -------------------------------------------------------------------------- */
.nav { transition: transform 0.5s var(--ease); }
.nav.is-hidden { transform: translateY(-100%); }
.nav.is-open { transform: none; }

.scroll-progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--accent, #e5ce16); transform-origin: left center; transform: scaleX(0);
  pointer-events: none; z-index: 2;
}

/* Underline link hover (nav, footer) */
.a-link { position: relative; transition: color var(--dur-fast) ease; }
.a-link::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: right center;
  transition: transform var(--dur-mid) var(--ease);
}
.a-link:hover, .a-link.is-active { color: var(--fg, #f6f7fb); }
.a-link:hover::after, .a-link.is-active::after { transform: scaleX(1); transform-origin: left center; }
.a-link.is-active::after { background: var(--accent, #e5ce16); }

/* Burger → X */
.nav__burger span { transition: transform var(--dur-mid) var(--ease), opacity var(--dur-fast) ease; }
.nav__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile menu: height auto via grid trick + staggered items */
.mobile-menu { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.5s var(--ease); }
.mobile-menu > .mobile-menu__clip { overflow: hidden; min-height: 0; }
.mobile-menu.is-open { grid-template-rows: 1fr; }
.mobile-menu__inner > * {
  opacity: 0; transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.4s var(--ease);
}
.mobile-menu.is-open .mobile-menu__inner > * { opacity: 1; transform: none; }
.mobile-menu.is-open .mobile-menu__inner > *:nth-child(1) { transition-delay: 0.08s; }
.mobile-menu.is-open .mobile-menu__inner > *:nth-child(2) { transition-delay: 0.12s; }
.mobile-menu.is-open .mobile-menu__inner > *:nth-child(3) { transition-delay: 0.16s; }
.mobile-menu.is-open .mobile-menu__inner > *:nth-child(4) { transition-delay: 0.20s; }
.mobile-menu.is-open .mobile-menu__inner > *:nth-child(5) { transition-delay: 0.24s; }
.mobile-menu.is-open .mobile-menu__inner > *:nth-child(6) { transition-delay: 0.28s; }

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
/* 5a. Text roll: JS wraps label in .a-roll > span×2 (for [data-roll]) */
.a-roll { position: relative; display: inline-block; overflow: hidden; vertical-align: top; }
.a-roll__row { display: block; transition: transform 0.5s var(--ease); }
.a-roll__row + .a-roll__row { position: absolute; left: 0; top: 100%; }
[data-roll]:hover .a-roll__row,
[data-roll]:focus-visible .a-roll__row { transform: translateY(-100%); }

/* 5b. Fill sweep from bottom (outline / ghost buttons) */
.a-fill { position: relative; isolation: isolate; overflow: hidden; transition: color var(--dur-mid) var(--ease), border-color var(--dur-mid) var(--ease); }
.a-fill::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--fill, var(--accent, #e5ce16));
  transform: scaleY(0); transform-origin: bottom center;
  transition: transform 0.45s var(--ease);
}
.a-fill:hover::before, .a-fill:focus-visible::before { transform: scaleY(1); }
.btn--outline.a-fill:hover { color: var(--bg, #0d1120); }
.btn--ghost.a-fill { --fill: var(--fg, #f6f7fb); }
.btn--ghost.a-fill:hover { color: var(--bg, #0d1120); border-color: var(--fg, #f6f7fb); }

/* 5c. Primary: subtle shine pass on hover */
.btn--primary { position: relative; overflow: hidden; }
.btn--primary::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.45), transparent);
  transform: skewX(-20deg); pointer-events: none;
}
.btn--primary:hover::after { animation: a-shine 0.8s var(--ease); }
@keyframes a-shine { to { left: 130%; } }

/* press feedback for all buttons */
.btn { transition: transform var(--dur-fast) var(--ease); }
.btn:active { transform: scale(0.97); }
/* magnetic buttons are moved by JS on a wrapper, so :active scale still works */
.a-magnet { display: inline-flex; will-change: transform; }

/* --------------------------------------------------------------------------
   6. Micro-interactions
   -------------------------------------------------------------------------- */
/* Tags */
.tag { transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-mid) var(--ease); }
.tag:hover { border-color: var(--accent, #e5ce16); color: var(--accent, #e5ce16); transform: translateY(-2px); }

/* Service card: title turns yellow, number slides, arrow appears */
.card--service .card__title { transition: color var(--dur-fast) ease, transform 0.5s var(--ease); }
.card--service:hover .card__title { color: var(--accent, #e5ce16); transform: translateX(8px); }
.card--service .mono { transition: color var(--dur-fast) ease; }
.card--service:hover .mono { color: var(--accent, #e5ce16); }

/* Principle accent bar grows */
.principle__bar { transform-origin: top center; transition: height 0.5s var(--ease); }
.principle:hover .principle__bar { height: 48px; }

/* Project media hover: slow zoom (on an extra wrapper so it doesn't fight parallax) */
.media__zoom { width: 100%; height: 100%; transition: transform 1.2s var(--ease); }
.media:hover .media__zoom { transform: scale(1.03); }
/* parallax needs extra image height so edges never show */
.media [data-parallax] { height: 116%; margin-top: -8%; }

/* Portrait: grayscale → color on hover */
.portrait img { filter: grayscale(0.35); transition: filter 0.6s var(--ease), transform 1s var(--ease); }
.card:hover .portrait img { filter: grayscale(0); transform: scale(1.04); }

/* Availability pulse dot */
.pulse-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #e5ce16); flex: none; }
.pulse-dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit;
  animation: a-pulse 2s var(--ease) infinite;
}
@keyframes a-pulse { from { transform: scale(1); opacity: 0.6; } to { transform: scale(3); opacity: 0; } }

/* Process progress line (desktop) */
.steps__track { display: none; }
@media (min-width: 1024px) {
  .steps__track { display: block; position: absolute; left: 0; right: 0; top: -1px; height: 2px; z-index: 2; pointer-events: none; }
  .steps__fill { height: 100%; background: var(--accent, #e5ce16); transform: scaleX(0); transform-origin: left center; }
}
.step .mono, .step__title { transition: color 0.4s ease; }
.step.is-active .mono { color: var(--accent, #e5ce16); }

/* Carousel */
.carousel__track { display: flex; height: 100%; transition: transform 0.8s var(--ease); }
.carousel__slide { flex: 0 0 100%; height: 100%; overflow: hidden; }
.carousel__slide img { transition: transform 1s var(--ease); transform: scale(1.06); }
.carousel__slide.is-active img { transform: scale(1); }
.dot { transition: width 0.4s var(--ease), background-color var(--dur-fast) ease, border-color var(--dur-fast) ease; cursor: pointer; }
.dot:hover:not(.is-active) { border-color: var(--fg, #f6f7fb); }

/* Form */
.input { transition: border-color var(--dur-fast) ease, background-color var(--dur-mid) ease; }
.input:focus { background-color: rgba(229, 206, 22, 0.03); }
.field.has-error .input { animation: a-shake 0.4s var(--ease); }
@keyframes a-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.form-success { animation: a-in 0.8s var(--ease) both; }
@keyframes a-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   7. Custom cursor label (desktop, fine pointer only; created by JS)
   -------------------------------------------------------------------------- */
.a-cursor { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; }
.a-cursor__inner {
  width: 88px; height: 88px; margin: -44px 0 0 -44px; border-radius: 50%;
  background: var(--accent, #e5ce16); color: var(--bg, #0d1120);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--font-mono, monospace); font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  transform: scale(0); opacity: 0;
  transition: transform 0.45s var(--ease), opacity 0.3s ease;
}
.a-cursor.is-visible .a-cursor__inner { transform: scale(1); opacity: 1; }
[data-cursor] { cursor: none; }
@media (hover: none), (pointer: coarse) { [data-cursor] { cursor: auto; } .a-cursor { display: none; } }

/* --------------------------------------------------------------------------
   8. Reduced motion — everything static and visible
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
  .pulse-dot::after { display: none; }
  .a-cursor { display: none; }
  [data-cursor] { cursor: auto; }
}

/* Carousel drag: no text/image selection */
[data-carousel] .media { user-select: none; -webkit-user-select: none; }

/* --------------------------------------------------------------------------
   9. Hero: interactive dot field + per-letter title
   -------------------------------------------------------------------------- */
.hero { position: relative; }
.hero > .container { position: relative; z-index: 1; }
.hero__bg {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none;
  /* dots are quieter behind the headline (left) and fully visible on the right */
  -webkit-mask-image: linear-gradient(90deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.7) 40%, #000 70%);
          mask-image: linear-gradient(90deg, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0.7) 40%, #000 70%);
}
@media (max-width: 1023.98px) {
  .hero__bg { -webkit-mask-image: linear-gradient(180deg, #000, rgba(0,0,0,0.45) 60%); mask-image: linear-gradient(180deg, #000, rgba(0,0,0,0.45) 60%); }
}

/* each word is its own mask so letters of line 1 never show over line 2 */
.a-cword { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.06em 0.02em 0.14em; margin: -0.06em -0.02em -0.14em; }
.a-cword.is-open { overflow: visible; }  /* after the intro, letters can lift on hover */
.a-char { display: inline-block; will-change: transform; }
.a-char--dot { color: var(--accent, #e5ce16); }

/* --------------------------------------------------------------------------
   10. Lightbox
   -------------------------------------------------------------------------- */
.a-lock, .a-lock body { overflow: hidden; }
@media (prefers-reduced-motion: reduce), (hover: none) { [data-lightbox] { cursor: zoom-in; } }
.a-lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 72px 24px 32px;
}
.a-lightbox[hidden] { display: none; }
.a-lightbox__backdrop { position: absolute; inset: 0; background: rgba(13, 17, 32, 0.94); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.a-lightbox__figure { position: relative; margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 16px; max-width: 100%; }
.a-lightbox__img { display: block; max-width: min(1280px, 100%); max-height: calc(100vh - 170px); width: auto; height: auto; will-change: transform, clip-path; }
.a-lightbox__caption { display: flex; gap: 16px; align-items: baseline; font-family: var(--font-mono, monospace); font-size: 12px; color: var(--muted, #d4d4d6); }
.a-lightbox__num { color: var(--accent, #e5ce16); }
.a-lightbox__close {
  position: absolute; top: 20px; right: 24px;
  font-family: var(--font-mono, monospace); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--fg, #f6f7fb); border: 1px solid var(--line-subtle, #777981); padding: 8px 14px; background: transparent; cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.a-lightbox__close:hover { border-color: var(--accent, #e5ce16); color: var(--accent, #e5ce16); }
.a-lightbox[data-cursor], .a-lightbox[data-cursor] * { cursor: none; }
@media (hover: none), (pointer: coarse) { .a-lightbox[data-cursor], .a-lightbox[data-cursor] * { cursor: auto; } }

/* cursor above the lightbox */
.a-cursor { z-index: 300; }
