/*
Theme Name: KR Portfolio
Author: Krystian Rodziewicz
Description: Personal portfolio — dark, animated.
Version: 1.0
*/

:root {
  --bg: #0b0b0c;
  --fg: #ededea;
  --dim: #6f6f6b;
  --accent: #d8f34a;
  --line: rgba(237, 237, 234, 0.12);
  --edge: clamp(20px, 4vw, 60px);
  --sans: "Space Grotesk", sans-serif;
  --serif: "Instrument Serif", serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }

@media (hover: hover) { * { cursor: none; } }

.cursor {
  position: fixed;
  top: 0; left: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: width 0.3s var(--ease), height 0.3s var(--ease), background 0.3s var(--ease);
  mix-blend-mode: difference;
}
.cursor.is-hover { width: 46px; height: 46px; background: var(--fg); }
@media (hover: none) { .cursor { display: none; } }

.grain {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.loader {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--bg);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: var(--edge);
}
.loader__num {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(3rem, 11vw, 8rem);
  line-height: 0.8;
  color: var(--fg);
}
.loader.is-done { transform: translateY(-100%); transition: transform 1s var(--ease); }

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--edge) var(--edge) 0;
  mix-blend-mode: difference;
}
.nav__logo { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.02em; }
.nav__logo span { color: var(--accent); }
.nav__links { display: flex; gap: clamp(16px, 2vw, 34px); font-size: 0.9rem; }
.nav__links a { position: relative; padding-bottom: 3px; }
.nav__links a::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 100%; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 0.4s var(--ease);
}
.nav__links a:hover::after { transform: scaleX(1); transform-origin: left; }
.nav__status { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--dim); }
.nav__status i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (max-width: 700px) { .nav__status { display: none; } }

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--edge);
  padding-bottom: clamp(30px, 5vh, 60px);
}
.hero__eyebrow {
  display: flex;
  gap: 2rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 2rem;
}
.hero__title {
  font-weight: 500;
  font-size: clamp(2.4rem, 10vw, 8.5rem);
  line-height: 0.9;
  letter-spacing: -0.02em;
}
.hero__title .line { display: block; overflow: hidden; }
.hero__title .line > span { display: block; transform: translateY(110%); }
.hero__foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  margin-top: clamp(2rem, 5vh, 4rem);
}
.hero__desc { max-width: 30rem; font-size: clamp(1rem, 1.4vw, 1.25rem); line-height: 1.5; color: var(--fg); }
.hero__desc em { color: var(--accent); }
.hero__scroll { display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.hero__scroll i { width: 1px; height: 46px; background: var(--line); position: relative; overflow: hidden; }
.hero__scroll i::after { content: ""; position: absolute; top: -50%; left: 0; width: 100%; height: 50%; background: var(--accent); animation: scrolldot 2s var(--ease) infinite; }
@keyframes scrolldot { to { top: 100%; } }
@media (max-width: 700px) { .hero__scroll { display: none; } }

.marquee {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  padding: 1.4rem 0;
  white-space: nowrap;
}
.marquee__track { display: inline-flex; align-items: center; gap: 2rem; animation: scroll 30s linear infinite; }
.marquee span { font-size: clamp(1rem, 2.2vw, 1.7rem); font-weight: 300; text-transform: uppercase; }
.marquee b { color: var(--accent); }
@keyframes scroll { to { transform: translateX(-50%); } }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0 var(--edge);
  margin-bottom: clamp(2rem, 5vh, 4rem);
}
.section-head__idx { font-size: 0.8rem; color: var(--accent); }
.section-head h2 { font-weight: 400; font-size: clamp(1.4rem, 3vw, 2.2rem); letter-spacing: -0.01em; }

.work { position: relative; padding: clamp(80px, 12vh, 160px) 0; }
.projects { list-style: none; border-top: 1px solid var(--line); }
.project { border-bottom: 1px solid var(--line); }
.project a {
  display: grid;
  grid-template-columns: 3rem 1fr auto 3rem;
  align-items: center;
  gap: 1.5rem;
  padding: clamp(1.4rem, 3.5vw, 2.6rem) var(--edge);
  transition: background 0.4s var(--ease), padding-left 0.4s var(--ease);
}
.project a:hover { background: var(--fg); color: var(--bg); padding-left: calc(var(--edge) + 20px); }
.project__idx { font-size: 0.8rem; color: var(--dim); }
.project a:hover .project__idx { color: var(--bg); }
.project__name { font-size: clamp(1.4rem, 3.6vw, 2.8rem); font-weight: 400; letter-spacing: -0.02em; }
.project__tags { font-size: 0.85rem; color: var(--dim); text-align: right; }
.project a:hover .project__tags { color: var(--bg); }
.project__arrow { font-size: 1.4rem; text-align: right; }
@media (max-width: 700px) {
  .project a { grid-template-columns: 2rem 1fr; }
  .project__tags, .project__arrow { display: none; }
}

.project-preview {
  position: fixed;
  top: 0; left: 0;
  width: 22vw;
  height: 28vh;
  border-radius: 6px;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
  background-size: cover;
  background-position: center;
}
.project-preview.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
@media (hover: none) { .project-preview { display: none; } }

.about { padding: clamp(80px, 12vh, 160px) 0; }
.about__grid { padding: 0 var(--edge); display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 6vw, 6rem); }
.about__lead { font-size: clamp(1.2rem, 2vw, 1.9rem); line-height: 1.4; font-weight: 300; letter-spacing: -0.01em; }
.about__lead em { color: var(--accent); }
.about__stack { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-content: start; }
.about__stack h3 { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.6rem; }
.about__stack p { color: var(--dim); line-height: 1.7; font-size: 0.95rem; }
@media (max-width: 820px) { .about__grid { grid-template-columns: 1fr; } }

.contact {
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: var(--edge);
  text-align: center;
  border-top: 1px solid var(--line);
}
.contact__eyebrow { font-size: 0.85rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.contact__mail {
  font-size: clamp(1.6rem, 5vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1;
  position: relative;
}
.contact__mail::after { content: ""; position: absolute; left: 0; bottom: 4px; width: 100%; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: right; transition: transform 0.5s var(--ease); }
.contact__mail:hover::after { transform: scaleX(1); transform-origin: left; }
.contact__social { list-style: none; display: flex; gap: 2.5rem; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; }
.contact__social a { color: var(--dim); transition: color 0.3s var(--ease); }
.contact__social a:hover { color: var(--fg); }

.�oot {
  display: flex;
  justify-content: space-between;
  padding: var(--edge);
  font-size: 0.8rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.reveal { opacity: 0; transform: translateY(30px); }
.reveal.in { opacity: 1; transform: translateY(0); transition: opacity 1s var(--ease), transform 1s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .marquee__track, .nav__status i, .hero__scroll i::after { animation: none; }
}


/* scroll driven frame sequence */
.seq { padding: clamp(60px, 10vh, 120px) 0 0; }
.seq__stage { height: 420vh; position: relative; }
.seq__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.seq__canvas {
  width: min(92vw, 1100px);
  height: auto;
  max-height: 78vh;
  display: block;
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}
.seq__canvas.is-ready { opacity: 1; }
.seq__copy {
  position: absolute;
  left: var(--edge);
  bottom: clamp(40px, 12vh, 110px);
  display: grid;
  gap: 0.55rem;
  pointer-events: none;
}
.seq__step {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  font-size: clamp(1rem, 2.2vw, 1.6rem);
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--dim);
  opacity: 0.35;
  transform: translateY(6px);
  transition: opacity 0.5s var(--ease), color 0.5s var(--ease), transform 0.5s var(--ease);
}
.seq__step b { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.12em; color: var(--dim); }
.seq__step.is-on { opacity: 1; color: var(--fg); transform: translateY(0); }
.seq__step.is-on b { color: var(--accent); }
.seq__hint {
  position: absolute;
  right: var(--edge);
  bottom: clamp(40px, 12vh, 110px);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}
@media (max-width: 700px) {
  .seq__stage { height: 320vh; }
  .seq__hint { display: none; }
  .seq__copy { left: var(--edge); right: var(--edge); }
}

/* about photo */
.about__col { display: grid; gap: clamp(1.6rem, 4vh, 2.6rem); align-content: start; }
.about__photo { position: relative; overflow: hidden; }
.about__photo img {
  width: 100%;
  height: auto;
  display: block;
  filter: grayscale(1) contrast(1.06);
  transform: scale(1.04);
  transition: filter 0.7s var(--ease), transform 1.2s var(--ease);
}
.about__photo:hover img { filter: grayscale(0); transform: scale(1); }
.about__photo figcaption {
  margin-top: 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.about__photo::after {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 34px; height: 2px;
  background: var(--accent);
}

.about__grid { grid-template-columns: 0.8fr 1.2fr; align-items: start; }
.about__photo { max-width: 380px; }
.about__photo img { aspect-ratio: 4 / 5; object-fit: cover; }
@media (max-width: 820px) { .about__grid { grid-template-columns: 1fr; } .about__photo { max-width: 280px; } }

/* feather the frame into the page background */
.seq__canvas {
  width: min(96vw, 1240px);
  max-height: 84vh;
  filter: brightness(0.94) contrast(1.03);
  -webkit-mask-image: radial-gradient(ellipse 76% 74% at 50% 48%, #000 34%, rgba(0,0,0,0.82) 58%, rgba(0,0,0,0.35) 76%, transparent 92%);
  mask-image: radial-gradient(ellipse 76% 74% at 50% 48%, #000 34%, rgba(0,0,0,0.82) 58%, rgba(0,0,0,0.35) 76%, transparent 92%);
}
.seq__sticky::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 62% 52% at 50% 46%, transparent 55%, var(--bg) 96%);
}

.seq__sticky::after { z-index: 1; }
.seq__copy, .seq__hint { z-index: 2; }

/* about portrait canvas */
.about__photo { position: relative; }
.about__canvas { width: 100%; height: auto; display: block; opacity: 0; transition: opacity 0.7s var(--ease); filter: contrast(1.05); }
.about__canvas.is-ready { opacity: 1; }
.about__fallback { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.5s var(--ease); }
.about__fallback.is-off { opacity: 0; }
.about__photo:hover .about__canvas { filter: contrast(1.05) brightness(1.08); }

/* 3d scroll scene */
.seq { padding: 0; }
.seq__stage { height: 460vh; }
.seq__sticky { perspective: 1400px; }
.seq__scene { transform-style: preserve-3d; will-change: transform; }
.seq__canvas { width: min(96vw, 1240px); max-height: 84vh; }
.seq__line {
  position: absolute; z-index: 2;
  left: var(--edge); right: var(--edge);
  bottom: clamp(28px, 6vh, 56px);
  height: 1px; background: var(--line);
}
.seq__line i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
.hero, .marquee, .work, .about, .contact { perspective: 1200px; }
.hero__title, .marquee__track, .project, .about__stack > div, .contact__mail { transform-style: preserve-3d; will-change: transform; }
.project-preview { width: 26vw; height: 17vw; border-radius: 4px; }
@media (max-width: 700px) {
  .seq__stage { height: 320vh; }
  .seq__canvas { width: 108vw; }
}
@media (prefers-reduced-motion: reduce) {
  .seq__scene { transform: none !important; }
}

/* crop rig — the window changes shape, the pixels never stretch */
.seq__flight { will-change: transform; }
.seq__win {
  width: min(92vw, 1080px);
  aspect-ratio: 1100 / 614;
  overflow: hidden;
  transform-origin: 50% 50%;
  will-change: transform;
  -webkit-mask-image: radial-gradient(ellipse 88% 86% at 50% 50%, #000 58%, rgba(0,0,0,.6) 82%, transparent 100%);
          mask-image: radial-gradient(ellipse 88% 86% at 50% 50%, #000 58%, rgba(0,0,0,.6) 82%, transparent 100%);
}
.seq__img { width: 100%; height: 100%; transform-origin: 50% 50%; will-change: transform; }
.seq__canvas { width: 100% !important; height: 100% !important; max-height: none !important; display: block; filter: brightness(0.96) contrast(1.03); }
.seq__canvas { -webkit-mask-image: none; mask-image: none; }
@media (max-width: 700px) { .seq__win { width: 112vw; } }

/* keyboard taken apart across the page */
.rig { position: relative; }
.rig__stage { height: 460vh; position: relative; }
.rig__sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden;
}
.rig__layer {
  position: absolute;
  left: 50%; top: 50%;
  width: min(96vw, 1240px);
  transform: translate(-50%, -50%);
  will-change: transform;
  pointer-events: none;
}
.rig__layer img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%),
    linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to bottom, transparent 0, #000 14%, #000 86%, transparent 100%),
    linear-gradient(to right, transparent 0, #000 7%, #000 93%, transparent 100%);
          mask-composite: intersect;
}
.rig__layer--caps  { z-index: 4; }
.rig__layer--plate { z-index: 3; }
.rig__layer--pcb   { z-index: 2; }
.rig__layer--case  { z-index: 1; }
.rig__line {
  position: absolute; z-index: 6;
  left: var(--edge); right: var(--edge);
  bottom: clamp(28px, 6vh, 56px);
  height: 1px; background: var(--line);
}
.rig__line i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
@media (max-width: 700px) {
  .rig__stage { height: 340vh; }
  .rig__layer { width: 128vw; }
}

/* the page keeps moving, the keyboard comes apart as it passes */
.rig__stage { height: auto; }
.rig__scene {
  position: relative;
  height: 132vh;
  overflow: visible;
}
.rig__sticky { position: static; height: auto; overflow: visible; }
.rig__line { position: absolute; bottom: auto; top: 50%; }
@media (max-width: 700px) {
  .rig__scene { height: 108vh; }
}

.rig { margin-top: -8vh; }
.rig__scene { height: 118vh; }
@media (max-width: 700px) { .rig__scene { height: 96vh; } }

/* marquee is driven by gsap now */
.marquee__track { animation: none; will-change: transform; }


/* hover preview disabled */
#preview { display: none !important; }