/* ============================================================
   Sergey Kopytov — portfolio
   Clean rewrite (no Webflow)
   ============================================================ */

:root {
  --black: #0e1f15;
  --spring-green: #00ff6f;
  --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
  --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
  --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);
  --ease-out-back: cubic-bezier(0.42, 0, 0.58, 1);
  --container: 1440px;
  --section-pad: 40px;
}

/* --- Reset (minimal) --- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--black);
  background-image: url("../images/noise.png");
  background-position: 0 0;
  background-size: 250px;
  color: var(--spring-green);
  font-family: "NeueMachina", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* --- Typography --- */

h1 {
  font-family: "Migra", sans-serif;
  font-size: 78px;
  font-weight: 700;
  line-height: 100%;
}

h2 {
  font-size: 20px;
  font-weight: 400;
  line-height: 24px;
}

h3 {
  font-size: 14px;
  font-weight: 400;
  line-height: 24px;
}

h4 {
  font-size: 12px;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

p {
  font-size: 16px;
  font-weight: 200;
  line-height: 160%;
}

/* --- Layout --- */

.section {
  padding-left: var(--section-pad);
  padding-right: var(--section-pad);
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-left: auto;
  margin-right: auto;
}

/* --- Header --- */

.header {
  position: relative;
  display: flex;
  height: 80px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.brand h4 {
  white-space: nowrap;
}

.logo {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: inherit;
}

.logo svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.contacts {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: none;
}

.ic-link {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  overflow: hidden;
}

.ic-24 {
  display: flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  transition: transform 0.2s var(--ease-out-cubic);
}

.ic-24 svg {
  width: 24px;
  height: 24px;
}

.ic-link:hover .ic-24 {
  transform: rotateY(360deg);
}

.ic-link.discogs:hover .ic-24 {
  transform: rotate(360deg);
}

/* --- Hero --- */

.hero {
  display: flex;
  min-height: 500px;
  align-items: center;
}

/* --- Main grid --- */

.content-grid {
  display: grid;
  grid-template-columns: minmax(200px, 800px) max-content;
  gap: 60px;
}

.stack {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: min-content;
  gap: 0;
}

.stack > h4 {
  margin-bottom: 0;
}

/* --- Experience accordion --- */

.faq {
  width: 100%;
}

.faq-head {
  display: flex;
  width: 100%;
  align-items: flex-start;
  padding: 12px 0;
  cursor: pointer;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}

.faq-title {
  font-size: 20px;
  font-weight: 400;
  line-height: 24px;
}

.faq-arrow {
  width: 24px;
  height: 24px;
  margin-left: 16px;
  flex-shrink: 0;
  font-size: 20px;
  font-weight: 400;
  line-height: 24px;
  text-align: center;
  transition: transform 0.3s var(--ease-out-cubic);
  will-change: transform;
}

.faq-head:hover .faq-arrow {
  transform: translateY(4px);
}

.faq.is-open .faq-head:hover .faq-arrow,
.faq.is-open .faq-arrow {
  transform: translateY(3px) rotate(180deg);
}

.faq-body {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.3s var(--ease-out-cubic);
}

.faq.is-open .faq-body {
  grid-template-rows: 1fr;
}

.faq-body-inner {
  min-height: 0;
  overflow: hidden;
}

.faq.is-open .faq-body-inner {
  overflow: visible;
}

.faq-info {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto;
  column-gap: 16px;
  row-gap: 0;
  margin-top: 12px;
  margin-bottom: 24px;
  align-items: start;
}

.faq-logo {
  grid-row: 1 / span 2;
  grid-column: 1;
  width: 48px;
  height: 48px;
  border-radius: 2px;
  overflow: hidden;
  color: inherit;
}

.faq-logo svg {
  width: 48px;
  height: 48px;
}

.faq-years {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 24px;
  position: relative;
}

.years-line {
  width: 32px;
  height: 1px;
  border-radius: 10px;
  background-color: currentColor;
  flex-shrink: 0;
}

.faq-tags {
  grid-row: 2;
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 24px;
  gap: 0 0;
  row-gap: 0;
}

.faq-tags h4 {
  white-space: nowrap;
}

.tag-sep {
  width: 1px;
  height: 16px;
  margin: 0 16px;
  background-color: currentColor;
  flex-shrink: 0;
}

.faq-body p {
  max-width: 100%;
}

.faq-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
  justify-content: flex-start;
  align-items: flex-start;
}

.faq-spacer {
  width: 100%;
  height: 48px;
}

/* --- External text links --- */

.ext-link {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 32px;
  transition: opacity 0.2s var(--ease-in-out-quad);
}

.ext-link:hover {
  opacity: 0.75;
}

.ext-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ext-link-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.ext-link-icon svg {
  width: 24px;
  height: 24px;
  overflow: visible;
}

.ext-link-underline {
  width: 100%;
  height: 1px;
  background-color: currentColor;
}

/* --- Projects --- */

.prj {
  display: flex;
  align-items: flex-start;
  padding: 12px 0;
  cursor: pointer;
}

.prj .faq-arrow {
  transition: transform 0.3s var(--ease-out-cubic);
}

.prj:hover .faq-arrow {
  transform: translate(8px, -8px);
}

/* --- About --- */

.paragraph {
  max-width: 600px;
  margin-top: 48px;
  margin-bottom: 48px;
}

/* --- Themes (random on load) --- */

.theme-1 {
  color: #6740b6;
  background-color: #fffb07;
}

.theme-2 {
  color: #ffc800;
  background-color: #101110;
}

.theme-3 {
  color: #0b1b27;
  background-color: #fff;
}

.theme-4 {
  color: #1c306e;
  background-color: #f7f1de;
}

.theme-5 {
  color: #072369;
  background-color: #aad3cc;
}

.theme-6 {
  color: #f14d4d;
  background-color: #121413;
}

.theme-7 {
  color: #000;
  background-color: #86bedd;
}

.theme-8 {
  color: #292b2a;
  background-color: #a8b6ae;
}

.theme-9 {
  color: #9fe7ff;
  background-color: #2a1023;
}

/* --- Reveal on scroll ---
   Outer .reveal is observed (layout box stays real — IO works).
   Inner .reveal-motion is fully masked with clip-path (does NOT break IO).
   Critical hide before wrap: .js .reveal:not(.is-ready) in <head>.
*/

.reveal {
  --reveal-delay: 0ms;
  overflow: hidden;
  /* Paint containment stops subpixel leak outside the box */
  contain: paint;
}

.reveal-motion {
  display: block;
  /* Fully hidden until .is-visible — clip-path on INNER is safe for IO */
  transform: translate3d(0, 2.5rem, 0);
  clip-path: inset(0 0 100% 0);
  transition:
    transform 0.95s var(--ease-out-quart) var(--reveal-delay),
    clip-path 0.95s var(--ease-out-quart) var(--reveal-delay);
  will-change: transform, clip-path;
}

/* Hard hide before reveal starts (fixes flex/link paint leaks) */
.reveal:not(.is-visible) .reveal-motion {
  visibility: hidden;
}

.reveal.is-visible .reveal-motion {
  visibility: visible;
  transform: translate3d(0, 0, 0);
  clip-path: inset(0 0 0 0);
}

/* Header: slide down from above */
.header.reveal .reveal-motion {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: space-between;
  transform: translate3d(0, -1.5rem, 0);
  clip-path: inset(100% 0 0 0);
}

.header.reveal.is-visible .reveal-motion {
  transform: translate3d(0, 0, 0);
  clip-path: inset(0 0 0 0);
}

/* Hero: longer rise */
.hero-block.reveal .reveal-motion {
  transform: translate3d(0, 3.5rem, 0);
  transition-duration: 1.15s;
}

.hero-block.reveal.is-visible .reveal-motion {
  transform: translate3d(0, 0, 0);
  clip-path: inset(0 0 0 0);
}

/* Project links: flex row stays inside motion; force clip */
.prj.reveal {
  overflow: hidden;
}

.prj .reveal-motion {
  display: flex;
  width: 100%;
  align-items: flex-start;
}

/* --- Logo micro-animation (KC mark) --- */

@keyframes logo-c-bot {
  0% {
    transform: translate(9px, 10px);
    animation-timing-function: var(--ease-out-back);
  }
  8.3333% { transform: translate(9px, 20px); }
  50% {
    transform: translate(9px, 20px);
    animation-timing-function: var(--ease-out-back);
  }
  58.3333% { transform: translate(9px, 10px); }
  100% { transform: translate(9px, 10px); }
}

@keyframes logo-c-top {
  0% {
    transform: translate(9px, 10px);
    animation-timing-function: var(--ease-out-back);
  }
  8.3333% { transform: translate(9px, 0); }
  50% {
    transform: translate(9px, 0);
    animation-timing-function: var(--ease-out-back);
  }
  58.3333% { transform: translate(9px, 10px); }
  100% { transform: translate(9px, 10px); }
}

.logo-c-bot {
  animation: logo-c-bot 6s linear infinite both;
}

.logo-c-top {
  animation: logo-c-top 6s linear infinite both;
}

/* --- Eye icon micro-animation (external links) --- */

@keyframes eye-blink {
  0%,
  22.2222% {
    d: path("M12,19C7.5,19,3,14.625,3,12C3,9.375,7.5,5,12,5C16.5,5,21,9.375,21,12C21,14.625,16.5,19,12,19Z");
  }
  26.1111% {
    d: path("M12,13C7.5,13,3,12.375,3,12C3,11.625,7.5,11,12,11C16.5,11,21,11.625,21,12C21,12.375,16.5,13,12,13Z");
    animation-timing-function: var(--ease-out-back);
  }
  30% {
    d: path("M12,18C7.5,18,3,14.25,3,12C3,9.75,7.5,6,12,6C16.5,6,21,9.75,21,12C21,14.25,16.5,18,12,18Z");
    animation-timing-function: var(--ease-out-back);
  }
  33.8889% {
    d: path("M12,13C7.5,13,3,12.375,3,12C3,11.625,7.5,11,12,11C16.5,11,21,11.625,21,12C21,12.375,16.5,13,12,13Z");
    animation-timing-function: var(--ease-out-back);
  }
  37.7778%,
  100% {
    d: path("M12,19C7.5,19,3,14.625,3,12C3,9.375,7.5,5,12,5C16.5,5,21,9.375,21,12C21,14.625,16.5,19,12,19Z");
  }
}

@keyframes eye-pupil {
  0%,
  66.6666% {
    transform: translate(12px, 12px);
    animation-timing-function: var(--ease-out-back);
  }
  71.1111%,
  95.5555% {
    transform: translate(10px, 12px);
    animation-timing-function: var(--ease-out-back);
  }
  100% {
    transform: translate(12px, 12px);
  }
}

.eye-lid {
  animation: eye-blink 4.5s linear infinite both;
}

.eye-pupil {
  animation: eye-pupil 4.5s linear infinite both;
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    overflow: visible;
    contain: none;
  }

  .reveal-motion,
  .header.reveal .reveal-motion,
  .hero-block.reveal .reveal-motion {
    transform: none !important;
    clip-path: none !important;
    visibility: visible !important;
    transition: none !important;
  }

  .faq-body,
  .faq-arrow,
  .ic-24,
  .ext-link,
  .logo-c-bot,
  .logo-c-top,
  .eye-lid,
  .eye-pupil {
    animation: none !important;
    transition: none !important;
  }

  .faq-body {
    grid-template-rows: 0fr;
  }

  .faq.is-open .faq-body {
    grid-template-rows: 1fr;
  }
}

/* --- Responsive --- */

@media screen and (max-width: 991px) {
  h1 {
    font-size: 73px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  /* Projects above Experience on smaller screens */
  .content-grid > .stack:first-child {
    order: 2;
  }

  .content-grid > .stack:last-child {
    order: 1;
  }
}

@media screen and (max-width: 767px) {
  h1 {
    font-size: 55px;
  }

  .header {
    height: auto;
    padding-top: 24px;
    justify-content: flex-start;
  }

  /* Same specificity as desktop .header.reveal .reveal-motion */
  .header.reveal .reveal-motion {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 12px;
  }

  .contacts {
    flex-wrap: wrap;
    justify-content: flex-start;
    row-gap: 8px;
  }
}

@media screen and (max-width: 479px) {
  :root {
    --section-pad: 24px;
  }

  h1 {
    font-size: 34px;
  }

  .hero {
    min-height: 432px;
  }
}

/* --- Fonts --- */

@font-face {
  font-family: "Migra";
  src: url("../fonts/Migra-Extrabold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "NeueMachina";
  src: url("../fonts/NeueMachina-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "NeueMachina";
  src: url("../fonts/NeueMachina-Ultralight.woff") format("woff");
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}
