/* ---------- Tokens ---------- */
:root {
  --bg: #f4f3ef;
  --fg: #0e0e0f;
  --muted: #77767066;
  --muted-fg: #6d6c66;
  --line: #0e0e0f1a;
  --card: #ebe9e3;
  --accent: #ff4d1c;
  --accent-soft: #ff4d1c22;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --pad: clamp(16px, 4vw, 56px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0b0c;
  --fg: #ecebe6;
  --muted-fg: #8d8c86;
  --line: #ecebe61a;
  --card: #151517;
  --accent: #ff5a2b;
  --accent-soft: #ff5a2b26;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c;
    --fg: #ecebe6;
    --muted-fg: #8d8c86;
    --line: #ecebe61a;
    --card: #151517;
    --accent: #ff5a2b;
    --accent-soft: #ff5a2b26;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.55 "Inter Tight", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .5s var(--ease), color .5s var(--ease);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.03em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.ico { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.skip {
  position: fixed; left: var(--pad); top: 12px; z-index: 80;
  padding: 10px 16px; border-radius: 99px; background: var(--fg); color: var(--bg);
  transform: translateY(-160%); transition: transform .3s var(--ease);
}
.skip:focus-visible { transform: none; }
main:focus { outline: none; }

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; letter-spacing: 0.01em; }
.muted { color: var(--muted-fg); }

/* ---------- Progress + cursor ---------- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60;
  background: var(--accent);
  transform-origin: 0 50%; transform: scaleX(0);
}

.cursor {
  position: fixed; top: 0; left: 0; z-index: 70; pointer-events: none;
  width: 92px; height: 92px; margin: -46px 0 0 -46px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font: 500 13px "JetBrains Mono", monospace;
  transform: translate3d(var(--x, -200px), var(--y, -200px), 0) scale(0);
  transition: transform .45s var(--ease);
}
.cursor.is-on { transform: translate3d(var(--x), var(--y), 0) scale(1); }
@media (hover: none) { .cursor { display: none; } }

/* ---------- Nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px var(--pad);
  mix-blend-mode: difference; color: #fff;
}
.nav__logo { font-weight: 600; letter-spacing: -0.02em; font-size: 18px; }
.nav__links { display: flex; align-items: center; gap: clamp(14px, 3vw, 32px); font-size: 15px; }
.nav__links a { position: relative; }
.nav__links a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: right;
  transition: transform .5s var(--ease);
}
.nav__links a:hover::after,
.nav__links a.is-active::after { transform: scaleX(1); transform-origin: left; }

.theme {
  width: 34px; height: 20px; padding: 0; border-radius: 99px; cursor: pointer;
  border: 1px solid currentColor; background: transparent; color: inherit;
  position: relative;
}
.theme::before { content: ""; position: absolute; inset: -12px -5px; }
.theme__dot {
  position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%;
  background: currentColor; transition: transform .5s var(--ease);
}
:root[data-theme="dark"] .theme__dot { transform: translateX(14px); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme__dot { transform: translateX(14px); } }

.lang {
  display: inline-flex; gap: 6px; padding: 0; border: 0; background: none; color: inherit;
  cursor: pointer; font-size: 12px; min-height: 32px; position: relative;
}
.lang::before { content: ""; position: absolute; inset: -6px -4px; }
.lang span { opacity: .45; transition: opacity .3s; }
.lang[data-current="en"] [data-l="en"],
.lang[data-current="uk"] [data-l="uk"] { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.lang:hover span { opacity: 1; }

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 120px var(--pad) 40px;
  position: relative;
}
.hero__eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: #2fc26b; position: relative;
}
.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: #2fc26b;
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse { to { transform: scale(3.2); opacity: 0; } }

.hero__title {
  font-size: clamp(64px, 15.5vw, 260px);
  line-height: .88; letter-spacing: -0.065em; font-weight: 500;
  margin-left: -0.05em;
}
.hero__title .line { display: block; overflow: hidden; padding-bottom: .04em; }
.split { display: inline-block; white-space: nowrap; }
.split .ch { display: inline-block; transform: translateY(105%); }
.hero__title .ch,
.c-hero__title .ch {
  animation: rise 1.1s var(--ease) forwards;
  animation-delay: calc(var(--i) * 45ms + 150ms);
}
.contact__title .ch { transition: transform 1s var(--ease); transition-delay: calc(var(--i) * 22ms); }
.contact__title.is-in .ch { transform: none; }
.hero__title { will-change: transform, opacity; }
@keyframes rise { to { transform: translateY(0); } }

.hero__meta {
  display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: end;
  margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line);
}
.hero__lead { max-width: 30ch; font-size: clamp(19px, 2vw, 24px); line-height: 1.35; letter-spacing: -0.01em; }
.hero__facts { display: flex; gap: 40px; margin: 0; }
.hero__facts dt { color: var(--muted-fg); margin-bottom: 4px; }
.hero__facts dd { margin: 0; }

.hero__scroll {
  position: absolute; right: var(--pad); top: 120px;
  display: flex; align-items: center; gap: 10px; color: var(--muted-fg);
  transition: color .3s;
}
.hero__scroll:hover { color: var(--fg); }
.hero__arrow { display: inline-flex; animation: bob 2.2s var(--ease) infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ---------- Marquee ---------- */
.marquee {
  overflow: hidden; border-block: 1px solid var(--line); padding: 18px 0;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.marquee__track {
  display: flex; gap: 28px; width: max-content; white-space: nowrap;
  font-size: 14px; text-transform: uppercase; letter-spacing: .08em;
  animation: marquee 38s linear infinite;
}
.marquee__track i { width: 6px; height: 6px; background: var(--accent); transform: rotate(45deg); align-self: center; flex: none; }
.js .marquee__track { animation: none; will-change: transform; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Sections ---------- */
section { padding: clamp(80px, 12vw, 160px) var(--pad) 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding-bottom: 20px; margin-bottom: clamp(32px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
}
.section-head h2 { font-size: clamp(32px, 4.5vw, 56px); }

/* Word-by-word heading rise */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .06em; }
.w > span { display: inline-block; transform: translateY(110%); transition: transform .9s var(--ease); transition-delay: calc(var(--n) * 60ms); }
.is-in .w > span, html:not(.js) .w > span { transform: none; }

/* About text lights up word by word as it scrolls in */
.sw { transition: opacity .4s var(--ease); }
.js .sw { opacity: .2; }
.js .sw.on { opacity: 1; }

/* ---------- Projects ---------- */
.project { margin-bottom: clamp(56px, 8vw, 120px); }
.project__link {
  display: grid; grid-template-columns: 1.35fr 1fr; gap: clamp(24px, 4vw, 64px); align-items: center;
}
.project:nth-of-type(even) .project__link { grid-template-columns: 1fr 1.35fr; }
.project:nth-of-type(even) .project__preview { order: 2; }

.project__preview {
  aspect-ratio: 16 / 11; border-radius: 18px; overflow: hidden;
  background: var(--card); position: relative;
  clip-path: inset(0 round 18px);
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: clip-path .9s var(--ease), transform .6s var(--ease);
}
.js .project:not(.is-in) .project__preview { clip-path: inset(100% 0 0 0 round 18px); }
.js .project.is-in .project__preview { transition: clip-path 1.3s var(--ease), transform .6s var(--ease); }
.project__preview::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), var(--accent-soft), transparent 60%);
  transition: opacity .5s var(--ease);
}
.project__link:hover .project__preview::after { opacity: 1; }
.project__preview > div {
  position: absolute; inset: 0;
  transform: scale(1.0) translate3d(0, var(--py, 0px), 0);
  transition: transform 1.1s var(--ease);
}
.project__link:hover .project__preview { clip-path: inset(10px round 22px); }
.project__link:hover .project__preview > div { transform: scale(1.06) translate3d(0, var(--py, 0px), 0); }

.project__top { display: flex; align-items: baseline; gap: 16px; margin-bottom: 18px; }
.project__top h3 { font-size: clamp(30px, 3.6vw, 48px); flex: 1; }
.project__go {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); font-size: 18px; flex: none;
  transition: background .4s var(--ease), color .4s var(--ease), transform .6s var(--ease), border-color .4s;
}
.project__link:hover .project__go { background: var(--accent); border-color: var(--accent); color: #fff; transform: rotate(45deg); }
.project__info p { color: var(--muted-fg); max-width: 46ch; }
.project__url {
  display: inline-block; margin-top: 16px; color: var(--fg);
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  transition: background-size .6s var(--ease);
}
.project__link:hover .project__url { background-size: 100% 1px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.tags li {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 12px;
  transition: border-color .3s, color .3s;
}
.project__link:hover .tags li { border-color: var(--muted); }

/* In-progress badge */
.badge {
  display: inline-block; margin-left: 12px; padding: 7px 14px; border-radius: 99px;
  background: var(--accent); color: #fff; font: 600 14px "JetBrains Mono", monospace;
  letter-spacing: .08em; text-transform: uppercase; vertical-align: middle;
}
.badge--card { position: absolute; top: 20px; left: 20px; margin: 0; z-index: 1; padding: 10px 18px; font-size: 16px; }

/* Real screenshot inside the card */
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; }

/* ---------- About ---------- */
.about__grid { max-width: 1100px; }
.about__text { font-size: clamp(22px, 2.6vw, 34px); line-height: 1.3; letter-spacing: -0.02em; }

/* ---------- Contact ---------- */
.contact { padding-bottom: clamp(80px, 10vw, 140px); }
.contact__title {
  font-size: clamp(48px, 9vw, 150px); line-height: .92; letter-spacing: -0.055em;
  margin: 18px 0 clamp(36px, 5vw, 64px);
}
.contact__links { display: flex; flex-wrap: wrap; gap: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 18px 30px; border-radius: 99px; border: 1px solid var(--fg);
  font-size: 18px; position: relative; overflow: hidden; isolation: isolate;
  transition: color .5s var(--ease), transform .4s var(--ease);
}
.pill::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--fg);
  border-radius: inherit; transform: translateY(101%); transition: transform .55s var(--ease);
}
.pill:hover { color: var(--bg); }
.pill:hover::before { transform: translateY(0); }
.pill__arrow { display: inline-flex; transition: transform .5s var(--ease); }
.pill:hover .pill__arrow { transform: rotate(45deg); }

/* ---------- Case study pages ---------- */
.c-hero { padding: 130px var(--pad) 0; }
.c-back {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 28px;
  color: var(--muted-fg); transition: color .3s;
}
.c-back:hover { color: var(--fg); }
.c-back .ico { transition: transform .5s var(--ease); }
.c-back:hover .ico { transform: translateX(-4px); }
.c-hero__title {
  font-size: clamp(56px, 12vw, 200px); line-height: .9; letter-spacing: -0.06em;
  margin: 14px 0 0 -0.04em;
}
.c-hero__title .line { display: block; overflow: hidden; padding-bottom: .04em; }
.c-hero__sub {
  display: block; margin-top: .3em; font-size: clamp(24px, 3.4vw, 52px); line-height: 1.05;
  letter-spacing: -0.03em; color: var(--muted-fg);
}
.c-hero__meta {
  display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: end;
  margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line);
}
.c-hero__lead { max-width: 40ch; font-size: clamp(19px, 2vw, 24px); line-height: 1.35; letter-spacing: -0.01em; }
.c-facts { display: flex; gap: 36px; margin: 0; }
.c-facts dt { color: var(--muted-fg); margin-bottom: 4px; }
.c-facts dd { margin: 0; }
.c-hero__cta { margin-top: 32px; }

.c-cover { margin: clamp(48px, 7vw, 96px) var(--pad) 0; }
.c-cover__btn, .c-shot button, .c-photo button {
  display: block; width: 100%; padding: 0; border: 0; background: var(--card); cursor: zoom-in;
  border-radius: 18px; overflow: hidden; border: 1px solid var(--line);
}
.c-video video { display: block; width: 100%; height: auto; border-radius: 18px; border: 1px solid var(--line); background: #000; }
.c-video figcaption { margin-top: 12px; }
.c-cover img, .c-shot img, .c-photo img {
  display: block; width: 100%; height: auto; transition: transform 1.1s var(--ease);
}
.c-cover__btn:hover img, .c-shot button:hover img, .c-photo button:hover img { transform: scale(1.03); }

.c-numbers {
  display: grid; grid-template-columns: repeat(4, 1fr);
  margin: clamp(48px, 7vw, 96px) var(--pad) 0; padding: 0;
  border-block: 1px solid var(--line);
}
.c-num { padding: 28px 20px 28px 0; display: flex; flex-direction: column; gap: 6px; }
.c-num + .c-num { padding-left: 20px; border-left: 1px solid var(--line); }
.c-num b { font-size: clamp(28px, 3.6vw, 52px); font-weight: 500; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.c-num span { color: var(--muted-fg); }

.c-prose { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 4vw, 64px); }
.c-prose p { font-size: clamp(18px, 1.7vw, 21px); line-height: 1.5; }
.c-prose p + p { color: var(--muted-fg); }

.c-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; padding: 0; list-style: none; }
.c-steps li { padding: 0 24px 0 0; display: flex; flex-direction: column; gap: 12px; }
.c-steps li + li { padding-left: 24px; border-left: 1px solid var(--line); }
.c-steps h3 { font-size: clamp(22px, 2.2vw, 30px); }
.c-steps p { color: var(--muted-fg); }
.c-steps--3 { grid-template-columns: repeat(3, 1fr); row-gap: 40px; }
.c-steps--3 li:nth-child(3n+1) { padding-left: 0; border-left: 0; }

.c-shots { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(16px, 2.5vw, 32px); }
.c-shot { margin: 0; }
.c-shot--wide { grid-column: 1 / -1; }
.c-shot figcaption { margin-top: 12px; }

.c-hack { max-width: 62ch; font-size: clamp(18px, 1.7vw, 21px); line-height: 1.5; margin-bottom: clamp(24px, 4vw, 48px); }
.c-photos { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2vw, 24px); }
.c-photo { margin: 0; }
.c-photo button { aspect-ratio: 4 / 3; }
.c-photo img { height: 100%; object-fit: cover; }
.c-cert { margin: clamp(24px, 4vw, 48px) 0 0; max-width: 820px; }
.c-cert button {
  display: block; width: 100%; padding: 0; background: var(--card); cursor: zoom-in;
  border-radius: 18px; overflow: hidden; border: 1px solid var(--line);
}
.c-cert img { display: block; width: 100%; height: auto; }
.c-cert figcaption { margin-top: 12px; }
.c-cert figcaption a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

.c-todo { margin: 0; padding: 0; list-style: none; max-width: 900px; }
.c-todo li {
  display: grid; grid-template-columns: 48px 1fr; gap: 16px; padding: 18px 0;
  border-bottom: 1px solid var(--line); font-size: clamp(17px, 1.6vw, 20px);
}
.c-todo li:first-child { border-top: 1px solid var(--line); }

.case .tags { margin-top: 0; }
.c-next {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: clamp(80px, 12vw, 160px); padding: clamp(48px, 7vw, 96px) var(--pad);
  border-top: 1px solid var(--line);
}
.c-next__title {
  display: inline-flex; align-items: center; gap: .25em;
  font-size: clamp(48px, 9vw, 150px); line-height: .92; letter-spacing: -0.055em; font-weight: 500;
}
.c-next__title .ico { transition: transform .6s var(--ease); }
.c-next:hover .c-next__title .ico { transform: translateX(.15em); color: var(--accent); }

.zoom {
  width: min(96vw, 1600px); max-height: 94vh; padding: 0; border: 0; border-radius: 14px;
  background: var(--bg); color: var(--fg); overflow: auto;
}
.zoom::backdrop { background: #000c; }
.zoom img { display: block; width: 100%; height: auto; cursor: zoom-out; }
.zoom form { position: sticky; top: 0; display: flex; justify-content: flex-end; padding: 10px; background: var(--bg); }
.zoom__close {
  min-height: 36px; padding: 0 16px; border-radius: 99px; border: 1px solid var(--line);
  background: none; color: inherit; cursor: pointer;
}

/* ---------- Footer ---------- */
.footer {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 24px var(--pad); border-top: 1px solid var(--line);
}
.credit a { text-decoration: underline; text-underline-offset: 3px; }
.credit a:hover { color: var(--fg); }
.totop { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; transition: color .3s; }
.totop:hover { color: var(--fg); }
.totop .ico { transition: transform .5s var(--ease); }
.totop:hover .ico { transform: translateY(-4px); }

/* ---------- Reveal ---------- */
.js .reveal { opacity: 0; transform: translateY(32px); transition: opacity 1s var(--ease), transform 1.1s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }
.hero .reveal { transition-delay: .7s; }
.hero .hero__facts.reveal { transition-delay: .85s; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .hero__meta { grid-template-columns: 1fr; gap: 24px; }
  .hero__scroll { display: none; }
  .project__link,
  .project:nth-of-type(even) .project__link { grid-template-columns: 1fr; }
  .project:nth-of-type(even) .project__preview { order: 0; }
  .project__preview { aspect-ratio: 4 / 3.6; }
  .nav__links a[href="#about"] { display: none; }
  .c-hero__meta { grid-template-columns: 1fr; gap: 24px; }
  .c-numbers { grid-template-columns: 1fr 1fr; }
  .c-num:nth-child(3) { padding-left: 0; border-left: 0; }
  .c-num:nth-child(n+3) { border-top: 1px solid var(--line); }
  .c-prose { grid-template-columns: 1fr; gap: 20px; }
  .c-steps { grid-template-columns: 1fr 1fr; row-gap: 32px; }
  .c-steps li:nth-child(3) { padding-left: 0; border-left: 0; }
  .c-steps--3 li:nth-child(n) { padding-left: 24px; border-left: 1px solid var(--line); }
  .c-steps--3 li:nth-child(odd) { padding-left: 0; border-left: 0; }
  .c-shots { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .hero__title { font-size: 13.5vw; }
  .contact__title { font-size: 10.5vw; }
  .pill { padding: 15px 24px; font-size: 16px; }
  .footer { flex-direction: column; align-items: flex-start; }
  .c-facts { flex-wrap: wrap; gap: 20px 28px; }
  .c-steps { grid-template-columns: 1fr; }
  .c-steps li, .c-steps li + li, .c-steps--3 li:nth-child(n) { padding: 0; border-left: 0; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .marquee__track { animation: none; }
  .split .ch, .w > span { transform: none; }
  .c-cover__btn:hover img, .c-shot button:hover img, .c-photo button:hover img { transform: none; }
  .js .project:not(.is-in) .project__preview { clip-path: inset(0 round 18px); }
}
