/* =========================================================
   FX KIT — фішки з топ-сайтів Awwwards, без бібліотек.
   Підключення: <link rel="stylesheet" href="fx.css"> + <script src="fx.js" defer></script>
   Кожна фішка вмикається атрибутом data-fx або класом fx-*.
   ========================================================= */

:root {
  --fx-ease: cubic-bezier(.16, 1, .3, 1);   /* «expo out» — плавне гальмування, як у топ-студій */
  --fx-dur: 1.1s;
}

/* 1. Розкриття тексту по словах (маска + рух знизу) — data-fx="split" */
[data-fx="split"] .fx-w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .1em; margin-bottom: -.1em; }
[data-fx="split"] .fx-wi { display: inline-block; transform: translateY(110%); transition: transform var(--fx-dur) var(--fx-ease); transition-delay: calc(var(--i) * 45ms); }
[data-fx="split"].is-in .fx-wi { transform: none; }

/* 2. Поява знизу — data-fx="up" */
[data-fx="up"] { opacity: 0; transform: translateY(40px); transition: opacity .9s var(--fx-ease), transform .9s var(--fx-ease); }
[data-fx="up"].is-in { opacity: 1; transform: none; }

/* 3. Шторка clip-path для фото — data-fx="clip" (можна data-dir="left") */
[data-fx="clip"] { clip-path: inset(100% 0 0 0); transition: clip-path 1.3s var(--fx-ease); }
[data-fx="clip"][data-dir="left"] { clip-path: inset(0 100% 0 0); }
[data-fx="clip"].is-in { clip-path: inset(0 0 0 0); }
[data-fx="clip"] img { transform: scale(1.25); transition: transform 1.8s var(--fx-ease); }
[data-fx="clip"].is-in img { transform: scale(1); }

/* 4. Бігучий рядок — .fx-marquee > .fx-marquee__track (JS дублює вміст) */
.fx-marquee { overflow: hidden; white-space: nowrap; --speed: 30s; }
.fx-marquee__track { display: inline-flex; animation: fx-marquee var(--speed) linear infinite; }
.fx-marquee[data-reverse] .fx-marquee__track { animation-direction: reverse; }
.fx-marquee:hover .fx-marquee__track { animation-play-state: paused; }
@keyframes fx-marquee { to { transform: translateX(-50%); } }

/* 5. Свій курсор (тільки ПК) — створюється JS, якщо на <body> є data-fx-cursor */
.fx-cursor { position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none; mix-blend-mode: difference; opacity: 0; transition: opacity .3s; }
.fx-cursor.is-active { opacity: 1; }
.fx-cursor__dot { width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: #fff; }
.fx-cursor__ring {
  position: fixed; left: 0; top: 0; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%;
  border: 1px solid #fff; display: grid; place-items: center; font: 600 11px/1 system-ui, sans-serif; color: #000;
  transition: width .35s var(--fx-ease), height .35s var(--fx-ease), margin .35s var(--fx-ease), background .35s;
}
.fx-cursor.is-hover .fx-cursor__ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; }
.fx-cursor.is-label .fx-cursor__ring { width: 92px; height: 92px; margin: -46px 0 0 -46px; background: #fff; }
.fx-cursor__label { opacity: 0; transition: opacity .2s; letter-spacing: .04em; text-transform: uppercase; }
.fx-cursor.is-label .fx-cursor__label { opacity: 1; }
html.fx-has-cursor, html.fx-has-cursor a, html.fx-has-cursor button { cursor: none; }

/* 6. Магнітні кнопки — data-magnetic (рух робить JS) */
[data-magnetic] { transition: transform .5s var(--fx-ease); will-change: transform; }

/* 7. Sticky-стос карток — .fx-stack > .fx-stack__card */
.fx-stack { display: grid; gap: 24px; }
.fx-stack__card { position: sticky; top: calc(90px + var(--i, 0) * 18px); transform-origin: 50% 0; }

/* 8. Горизонтальна галерея при вертикальному скролі — .fx-hscroll > .fx-hscroll__sticky > .fx-hscroll__track */
.fx-hscroll { position: relative; }               /* висоту задає JS = ширина доріжки */
.fx-hscroll__sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; display: flex; align-items: center; }
.fx-hscroll__track { display: flex; gap: 28px; will-change: transform; padding: 0 6vw; }

/* 9. Список з картинкою біля курсора — .fx-hoverlist li[data-img] */
.fx-hoverimg {
  position: fixed; left: 0; top: 0; width: 260px; aspect-ratio: 4 / 5; z-index: 90; pointer-events: none;
  border-radius: 12px; overflow: hidden; opacity: 0; transform: translate(-50%, -50%) scale(.8);
  transition: opacity .3s, transform .45s var(--fx-ease);
}
.fx-hoverimg.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.fx-hoverimg img { width: 100%; height: 100%; object-fit: cover; }

/* 10. Смужка прогресу скролу — <div class="fx-progress"></div> */
.fx-progress { position: fixed; left: 0; top: 0; height: 3px; width: 100%; z-index: 999; background: var(--fx-progress, #e4573d); transform-origin: 0 50%; transform: scaleX(0); }

/* 11. Шапка-інверсія над будь-яким фоном */
.fx-blend { mix-blend-mode: difference; color: #fff; }

/* 12. Прелоадер-лічильник (до 1 с!) — <div class="fx-loader"><span class="fx-loader__num">0</span></div> */
.fx-loader {
  position: fixed; inset: 0; z-index: 10000; background: #111; color: #fff; display: flex; align-items: flex-end;
  justify-content: flex-end; padding: 4vw; transition: transform 1s var(--fx-ease);
}
.fx-loader__num { font: 700 clamp(4rem, 14vw, 12rem)/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.fx-loader.is-done { transform: translateY(-100%); }

/* 13. Зерно (шум) поверх сторінки — <div class="fx-grain"></div> */
.fx-grain {
  position: fixed; inset: -50%; z-index: 998; pointer-events: none; opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: fx-grain 1s steps(4) infinite;
}
@keyframes fx-grain { 25% { transform: translate(-3%, 2%); } 50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -2%); } }

/* 14. «Чорнильне» органічне розкриття (як у Cartier) — .fx-ink > .fx-ink__sticky > (.fx-ink__bg, .fx-ink__content)
   JS додає SVG з плямами, які ростуть зі скролом; краї «живі» завдяки feTurbulence + feDisplacementMap */
.fx-ink { position: relative; height: 260vh; }
.fx-ink__sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; }
.fx-ink__bg { position: absolute; inset: 0; }
.fx-ink__bg img { width: 100%; height: 100%; object-fit: cover; }
.fx-ink__svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fx-ink__svg g { fill: var(--ink, #f4f1ec); }
.fx-ink__content { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 6vw; opacity: 0; transform: translateY(30px); transition: opacity .8s var(--fx-ease), transform .8s var(--fx-ease); }
.fx-ink.is-revealed .fx-ink__content { opacity: 1; transform: none; }

/* 15. Предмет, що пливе в кольоровому сяйві (як камені Cartier) — .fx-float[style="--glow:#2ecc71"] */
.fx-float { position: relative; display: inline-block; animation: fx-bob 6s ease-in-out infinite; animation-delay: var(--delay, 0s); }
.fx-float::before {
  content: ""; position: absolute; inset: -32%; z-index: -1; border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow, #ff5b2e) 35%, transparent); filter: blur(30px); opacity: .85;
  transition: opacity .6s var(--fx-ease), transform .6s var(--fx-ease);
}
.fx-float:hover::before { opacity: 1; transform: scale(1.25); }
.fx-float > * { transition: transform .8s var(--fx-ease); }
.fx-float:hover > * { transform: scale(1.06) rotate(-3deg); }
@keyframes fx-bob { 50% { transform: translateY(-14px) rotate(1.5deg); } }

/* 16. ВЛАСНА ІДЕЯ: маршрут, що малюється скролом (перевезення, доставка, туризм)
   .fx-route > .fx-route__sticky > svg.fx-route__map (path.fx-route__path + g.fx-route__car) + .fx-route__stops li[data-at="0.3"] */
.fx-route { position: relative; height: 240vh; }
.fx-route__sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; display: grid; grid-template-columns: 1.4fr 1fr; align-items: center; gap: 4vw; padding: 0 5vw; }
.fx-route__map { width: 100%; height: auto; max-height: 80vh; overflow: visible; }
.fx-route__ghost { fill: none; stroke: currentColor; stroke-opacity: .15; stroke-width: 3; stroke-dasharray: 2 10; stroke-linecap: round; }
.fx-route__path { fill: none; stroke: var(--route, #ff5b2e); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.fx-route__dot { fill: var(--route-bg, #0f0e0d); stroke: currentColor; stroke-opacity: .35; stroke-width: 3; transition: fill .4s, stroke .4s; }
.fx-route__dot.is-on { fill: var(--route, #ff5b2e); stroke: var(--route, #ff5b2e); stroke-opacity: 1; }
.fx-route__stops { list-style: none; display: grid; gap: 14px; }
.fx-route__stops li { padding: 16px 18px; border-radius: 14px; border: 1px solid rgba(127,127,127,.25); opacity: .35; transform: translateX(14px); transition: opacity .5s var(--fx-ease), transform .5s var(--fx-ease), border-color .5s; }
.fx-route__stops li.is-on { opacity: 1; transform: none; border-color: var(--route, #ff5b2e); }
@media (max-width: 760px) { .fx-route__sticky { grid-template-columns: 1fr; align-content: center; gap: 18px; } .fx-route__stops { grid-template-columns: 1fr 1fr; gap: 8px; } .fx-route__stops li { padding: 10px 12px; font-size: .85rem; transform: none; } }

/* 17. ВЛАСНА ІДЕЯ: сайт живе за часом доби (кав'ярні, ресторани, пекарні)
   JS ставить data-daypart="morning|day|evening|night" на .fx-daytime; показує [data-show="evening"] лише ввечері */
.fx-daytime { --dt-bg: #fff3e4; --dt-fg: #2b1c12; --dt-accent: #e0702b; background: var(--dt-bg); color: var(--dt-fg); transition: background 1s var(--fx-ease), color 1s var(--fx-ease); }
.fx-daytime[data-daypart="day"] { --dt-bg: #f4f7f0; --dt-fg: #1d2a1a; --dt-accent: #3f9a4a; }
.fx-daytime[data-daypart="evening"] { --dt-bg: #2a1730; --dt-fg: #f6e9ef; --dt-accent: #ff8fa3; }
.fx-daytime[data-daypart="night"] { --dt-bg: #0e1424; --dt-fg: #dfe6ff; --dt-accent: #8fb4ff; }
.fx-daytime [data-show] { display: none; }
.fx-daytime[data-daypart="morning"] [data-show~="morning"], .fx-daytime[data-daypart="day"] [data-show~="day"],
.fx-daytime[data-daypart="evening"] [data-show~="evening"], .fx-daytime[data-daypart="night"] [data-show~="night"] { display: revert; animation: fx-dt-in .7s var(--fx-ease); }
@keyframes fx-dt-in { from { opacity: 0; transform: translateY(12px); } }

/* Повага до «зменшеного руху» і телефонів */
@media (prefers-reduced-motion: reduce) {
  [data-fx], [data-fx] * { transition: none !important; transform: none !important; clip-path: none !important; opacity: 1 !important; }
  .fx-marquee__track, .fx-grain, .fx-float { animation: none; }
  .fx-ink { height: auto; } .fx-ink__sticky { position: relative; } .fx-ink__svg { display: none; } .fx-ink__content { opacity: 1; transform: none; background: var(--ink, #f4f1ec); }
}
@media (hover: none) { .fx-cursor, .fx-hoverimg { display: none; } }
