/* ============================================================
   Евгений Ткаченко - портфолио (новый лендинг)
   Палитра:
   фон #011425, поверхности #04203A, границы #1F4959,
   акцент #5C7C89, текст #FFFFFF / #C5D0D8 (кикеры чуть тише - #B8C4CC)
   ============================================================ */

:root {
  --bg: #011425;
  --surface: #04203A;
  --border: #1F4959;
  --accent: #5C7C89;
  --text: #FFFFFF;
  --muted: #C5D0D8;
  --muted-dim: #B8C4CC;
  --header-h: 92px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --container: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-padding-top: 104px;
  color-scheme: dark;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

::selection {
  background: rgba(92, 124, 137, 0.5);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(20px, 4vw, 32px);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted-dim);
}

/* ============ живой фон: canvas-сеть ============ */

.net-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  /* статичный фон-заглушка на случай reduced-motion / отсутствия JS */
  background:
    radial-gradient(60% 60% at 78% 22%, rgba(92, 124, 137, 0.12), transparent 70%),
    radial-gradient(55% 55% at 15% 85%, rgba(31, 73, 89, 0.18), transparent 70%),
    var(--bg);
}

/* весь контент над фоном */
.page {
  position: relative;
  z-index: 1;
}

/* ============ кастомный курсор ============ */

.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cursor-dot {
  width: 10px;
  height: 10px;
  background: #ffffff;
}

.cursor-ring {
  width: 40px;
  height: 40px;
  background: rgba(92, 124, 137, 0.4);
  transition: width 0.25s ease, height 0.25s ease,
    background-color 0.25s ease, opacity 0.3s ease;
}

html.cursor-active .cursor-dot,
html.cursor-active .cursor-ring {
  opacity: 1;
}

html.cursor-hover .cursor-ring {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.15);
}

/* прячем системный курсор только когда кастомный активен */
html.cursor-on,
html.cursor-on * {
  cursor: none;
}

/* ============ кнопки ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  padding: 13px 24px;
  border-radius: 10px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: transform 0.25s ease, box-shadow 0.2s ease,
    border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background-color: #6b8fa0;
  background-image: linear-gradient(180deg, #78a0b1, #5f8496);
  color: #ffffff;
  box-shadow: 0 8px 22px rgba(107, 143, 160, 0.4), 0 1px 0 rgba(255, 255, 255, 0.12) inset;
}

.btn-primary:hover {
  background-image: linear-gradient(180deg, #86aebe, #6b91a3);
  box-shadow: 0 12px 28px rgba(107, 143, 160, 0.5), 0 1px 0 rgba(255, 255, 255, 0.15) inset;
}

.btn-ghost {
  border-color: var(--accent);
  background: transparent;
  color: var(--text);
}

.btn-ghost:hover {
  background: rgba(92, 124, 137, 0.16);
  border-color: #6d8f9d;
}

.btn-sm {
  padding: 9px 18px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* ============ шапка ============ */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(1, 20, 37, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.header.scrolled {
  background: rgba(1, 20, 37, 0.96);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

/* индикатор прогресса скролла - под шапкой */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 4px;
  background: linear-gradient(90deg, #5C7C89, #8fb1be);
  box-shadow: 0 0 10px rgba(92, 124, 137, 0.7);
  z-index: 200;
  pointer-events: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding-block: 6px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.logo-chip {
  width: 80px;
  height: 80px;
  flex: none;
  filter: drop-shadow(0 3px 11px rgba(92, 124, 137, 0.45));
}

.logo-slash {
  color: var(--accent);
  font-weight: 600;
}

.logo-name {
  font-weight: 600;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a {
  position: relative;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 12px;
  transition: color 0.15s ease;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.nav a:hover {
  color: var(--text);
}

.nav a:hover::after {
  transform: scaleX(1);
}

.nav-cta {
  margin-left: 8px;
}

/* ============ герой ============ */

.hero {
  height: 100vh;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding-top: 96px;
}

.hero .container {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: 60px;
  padding-right: 60px;
  width: 100%;
}

.hero-inner {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: clamp(40px, 6vw, 80px);
}

.hero-text {
  max-width: 640px;
}

.hero-text .kicker {
  display: block;
  margin-bottom: 20px;
}

h1 {
  font-size: clamp(2rem, 6.5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 22px;
}

.hero-sub {
  font-size: clamp(1.1rem, 2.1vw, 1.35rem);
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 16px;
}

.hero-desc {
  color: var(--muted);
  max-width: 520px;
  margin-bottom: 34px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.hero-photo {
  position: relative;
  will-change: transform;
}

.hero-photo::before {
  content: "";
  position: absolute;
  inset: -16%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(92, 124, 137, 0.28), transparent 66%);
  z-index: -1;
}

.photo-ring {
  width: 260px;
  aspect-ratio: 1;
  padding: 6px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 44px rgba(92, 124, 137, 0.4);
}

.photo-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ============ кейсы ============ */

.section {
  padding: 88px 0;
}

.cases .container,
.stack .container,
.about .container,
.contacts .container {
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: clamp(20px, 5vw, 60px);
}

.section-head {
  margin-bottom: 40px;
}

.section-head .kicker {
  display: block;
  margin-bottom: 12px;
}

.section-title {
  font-size: clamp(1.8rem, 3.6vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
}

.cases-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
}

.case-card {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* 4-я и 5-я карточки: широкие, по три колонки - второй ряд по центру под тремя */
.case-card:nth-child(n+4) {
  grid-column: span 3;
}

.case-card:hover {
  transform: translateY(-5px);
  border-color: #6d8f9d;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 8px 26px rgba(92, 124, 137, 0.3);
}

/* обязательная нормализация всех картинок кейсов */
.case-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 12px 12px 0 0;
}

/* CRM: два лого рядом, каждое по центру своей половины, единый фон карточки */
.case-logos {
  display: flex;
  position: relative;
  background: var(--surface);
}

/* тёмный оверлей поверх лого, чтобы они не выпадали цветным пятном */
.case-logos::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(1, 20, 37, 0.42);
  pointer-events: none;
}

.logo-half {
  width: 50%;
}

/* логотипы CRM показываем целиком, а не обрезаем по cover, и приглушаем */
.case-card .logo-half img {
  object-fit: contain;
  filter: brightness(0.72) saturate(0.82);
}

.logo-half:first-child img {
  border-radius: 12px 0 0 0;
}

.logo-half:last-child img {
  border-radius: 0 12px 0 0;
}

.case-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px 20px;
  flex: 1;
}

.case-niche {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.case-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--text);
}

.case-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.case-block-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.case-block-text {
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--muted);
}

.case-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.case-tags li {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  background: rgba(92, 124, 137, 0.08);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}

.case-link {
  margin-top: auto;
  padding-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  transition: color 0.15s ease;
}

.case-link:hover {
  color: var(--text);
}

.case-link .arr {
  transition: transform 0.18s ease;
}

.case-link:hover .arr {
  transform: translateX(4px);
}

@media (max-width: 980px) {
  .cases-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .case-card,
  .case-card:nth-child(n+4) {
    grid-column: auto;
  }
}

@media (max-width: 620px) {
  .cases-grid {
    grid-template-columns: 1fr;
  }
}

/* ============ стек: плитки инструментов ============ */

/* категории - колонки бок о бок; плитки внутри - вертикальный список */
.stack-cols {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  align-items: start;
}

.stack-cat-name {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 14px;
}

.tool-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 8px 12px;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.tool:hover {
  border-color: #6d8f9d;
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.38), 0 6px 20px rgba(92, 124, 137, 0.28);
}

.tool-ico {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.tool-mono {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(92, 124, 137, 0.1);
}

.tool-name {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

/* колонки-категории: 5 на десктопе, 3 на планшете, 2 и 1 на мобильном */
@media (max-width: 1080px) {
  .stack-cols {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 720px) {
  .stack-cols {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stack-cols {
    grid-template-columns: 1fr;
  }
}

/* ============ про меня ============ */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: clamp(36px, 5vw, 72px);
  align-items: center;
}

.about-text {
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: rgba(4, 32, 58, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: clamp(20px, 3vw, 32px);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.about-text p {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--muted);
}

.about-photo img {
  width: clamp(260px, 26vw, 340px);
  aspect-ratio: 1170 / 2007;
  height: auto;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.4);
  display: block;
}

@media (max-width: 860px) {
  .about-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .about-photo {
    order: -1;
    justify-self: center;
  }

  .about-photo img {
    width: min(72vw, 300px);
  }
}

/* ============ контакты ============ */

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.contact-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 20px 22px;
  text-align: center;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.contact-card:hover {
  transform: translateY(-5px);
  border-color: #6d8f9d;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(92, 124, 137, 0.3);
}

.contact-ico {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.contact-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.contact-btn {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  transition: color 0.15s ease;
}

.contact-card:hover .contact-btn {
  color: var(--text);
}

.contact-btn .arr {
  transition: transform 0.18s ease;
}

.contact-card:hover .contact-btn .arr {
  transform: translateX(4px);
}

@media (max-width: 820px) {
  .contacts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 460px) {
  .contacts-grid {
    grid-template-columns: 1fr;
  }
}

/* ============ футер ============ */

.footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.footer-tagline {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 22px;
}

.footer-nav a {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.15s ease;
}

.footer-nav a:hover {
  color: var(--text);
}

.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ============ гирлянда: кубики стека на вертикальной линии справа ============ */

.garland {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* верёвка - тонкая вертикальная линия вдоль правого края */
.garland-line {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 78px;
  width: 2px;
  background: rgba(92, 124, 137, 0.3);
}

/* точка крепления на линии, кубик центрируется по линии и висит под ней */
.gitem {
  position: absolute;
  right: 78px;
  transform: translateX(50%);
}

.gitem-swing {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform-origin: top center;
  animation: swing 5s ease-in-out infinite;
  will-change: transform;
}

/* нить от линии до верха кубика */
.gthread {
  width: 1.5px;
  height: 20px;
  background: rgba(92, 124, 137, 0.3);
}

.gchip {
  padding: 9px 15px;
  border-radius: 12px;
  border: 1px solid #1F4959;
  background: rgba(92, 124, 137, 0.06);
  font-family: var(--font-mono);
  font-size: 13px;
  color: rgba(197, 208, 216, 0.5);
  white-space: nowrap;
}

@supports ((backdrop-filter: blur(6px)) or (-webkit-backdrop-filter: blur(6px))) {
  .gchip {
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
}

/* разные длительности/задержки - качаются как маятники вразнобой */
.gitem:nth-child(2n) .gitem-swing { animation-duration: 5.6s; animation-delay: -1.5s; }
.gitem:nth-child(3n) .gitem-swing { animation-duration: 4.4s; animation-delay: -2.8s; }
.gitem:nth-child(4n) .gitem-swing { animation-duration: 6s; animation-delay: -0.7s; }
.gitem:nth-child(5n) .gitem-swing { animation-duration: 4.8s; animation-delay: -3.5s; }

@keyframes swing {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

@media (max-width: 768px) {
  .garland {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gitem-swing {
    animation: none;
  }
}

/* ============ scroll reveal ============
   Появление один раз при въезде в вьюпорт: fade-in + сдвиг вверх.
   Начальное скрытие только при js-reveal (класс ставит JS),
   так что без JS и при prefers-reduced-motion контент виден сразу.
   После завершения вешается .rv-done - правила перестают действовать,
   чтобы вернуть элементам их обычные hover-переходы. */

@media (prefers-reduced-motion: no-preference) {
  html.js-reveal :where(.section-head, .case-card, .tool, .contact-card, .about-grid):not(.rv-done) {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.55s ease-out, transform 0.55s ease-out;
  }

  html.js-reveal :where(.section-head, .case-card, .tool, .contact-card, .about-grid).is-visible:not(.rv-done) {
    opacity: 1;
    transform: none;
  }
}

/* ============ prefers-reduced-motion ============ */

@media (prefers-reduced-motion: reduce) {
  .btn:hover,
  .case-card:hover,
  .tool:hover,
  .contact-card:hover {
    transform: none;
  }
}

/* ============ адаптив ============ */

@media (max-width: 900px) {
  .hero {
    padding: 88px 0 56px;
  }

  .hero .container {
    padding-inline: clamp(20px, 4vw, 32px);
  }

  .hero-inner {
    flex-direction: column;
    justify-content: center;
    text-align: center;
  }

  .hero-text {
    padding-left: 0;
  }

  .hero-photo {
    order: -1;
    padding-right: 0;
  }

  .photo-ring {
    width: min(58vw, 240px);
  }

  .hero-desc {
    margin-inline: auto;
  }

  .hero-actions {
    justify-content: center;
  }
}

@media (max-width: 760px) {
  .nav-links {
    display: none;
  }

  .logo-chip {
    width: 46px;
    height: 46px;
  }

  :root {
    scroll-padding-top: 72px;
    --header-h: 60px;
  }
}
