:root {
  --void: #240A11;
  --field-hi: #5E1B31;
  --field-lo: #350D1C;
  --bone: #F5EDE8;
  --bone-dim: rgba(245, 237, 232, 0.62);
  --bone-faint: rgba(245, 237, 232, 0.34);
  --bone-hair: rgba(245, 237, 232, 0.14);
  --light: #FFD9CF;

  --edge: clamp(20px, 5.2vw, 76px);
  --measure: 1180px;

  --display: 'Bodoni Moda', 'Times New Roman', serif;
  --sans: 'Archivo', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--void);
  color: var(--bone-dim);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: -9999px;
  top: 0;
  z-index: 40;
  padding: 12px 20px;
  background-color: var(--bone);
  color: var(--void);
  font-family: var(--mono);
  font-size: 12px;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
}

:focus-visible {
  outline: 1px solid var(--light);
  outline-offset: 6px;
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.stage-field {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 82% at 14% 6%, var(--field-hi) 0%, rgba(94, 27, 49, 0) 58%),
    radial-gradient(110% 96% at 88% 96%, var(--field-lo) 0%, rgba(53, 13, 28, 0) 62%),
    var(--void);
}

/* Dwie animowane warstwy grawerunku odpowiadaly za 66% czasu klatki -
   zmierzone przez wylaczanie po kolei. Skladaly sie na to trzy rzeczy:
   `filter` (przy kazdej klatce trzeba go nalozyc na nowo), `scale`
   w animacji (wymusza ponowne rasteryzowanie gradientu w nowej skali)
   i `inset: -35%`, czyli warstwa o powierzchni prawie trzech ekranow.
   Blur 0,35 px byl i tak niewidoczny, skala siega najwyzej 1.07 (wiec
   12% zapasu wystarcza), a `will-change` promuje warstwe tak, ze sam
   transform robi juz tylko kompozytor, bez malowania od nowa. */
.stage-engraving {
  position: absolute;
  inset: -12%;
  will-change: transform;
}

.stage-engraving-a {
  background-image: repeating-radial-gradient(circle at 50% 46%,
    rgba(245, 237, 232, 0) 0 47px,
    rgba(245, 237, 232, 0.055) 47px 48px);
  animation: drift-a 74s ease-in-out infinite;
}

.stage-engraving-b {
  background-image: repeating-radial-gradient(circle at 43% 57%,
    rgba(245, 237, 232, 0) 0 53px,
    rgba(245, 237, 232, 0.042) 53px 54px);
  animation: drift-b 96s ease-in-out infinite;
}

@keyframes drift-a {
  0%, 100% { transform: translate3d(-1.6%, -1%, 0) scale(1.02); }
  50%      { transform: translate3d(1.8%, 1.6%, 0) scale(1.07); }
}

@keyframes drift-b {
  0%, 100% { transform: translate3d(2%, 1.4%, 0) scale(1.05); }
  50%      { transform: translate3d(-1.4%, -1.8%, 0) scale(1.01); }
}

.stage-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(460px circle at var(--gx, 50%) var(--gy, 26%),
    rgba(255, 217, 207, 0.15) 0%,
    rgba(255, 217, 207, 0.05) 38%,
    rgba(255, 217, 207, 0) 72%);
  opacity: 0;
  transition: opacity 0.8s ease;
}

.stage-glow.is-live {
  opacity: 1;
}

/* `mix-blend-mode: overlay` zmusza przegladarke do skladania calego
   kontekstu przez tryb mieszania przy kazdej klatce - 21% czasu klatki
   za efekt, ktorego przy 5% krycia i tak nie widac. Zwykle krycie,
   podniesione tak, zeby ziarno bylo tak samo mocne. */
.stage-grain {
  position: absolute;
  inset: 0;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.portfolio-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px var(--edge);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.header-mark,
.header-mail {
  color: var(--bone-faint);
  text-decoration: none;
  transition: color 0.4s ease;
}

.header-mark:hover,
.header-mail:hover {
  color: var(--bone);
}

.portfolio-main {
  position: relative;
  z-index: 1;
}

.shout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: 108px var(--edge) 40px;
}

.shout-kicker,
.shout-meta,
.work-kicker,
.piece-stack {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bone-faint);
}

.shout-kicker {
  align-self: start;
  opacity: 0;
  animation: fade-up 1.2s ease 0.9s forwards;
}

.shout-line {
  align-self: center;
  margin: 0;
  padding: 6vh 0;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(3.4rem, 13vw, 11.5rem);
  line-height: 0.86;
  letter-spacing: -0.025em;
  color: var(--bone);
}

.shout-word {
  display: block;
  clip-path: inset(0 0 106% 0);
  opacity: 0;
  animation: unveil 1.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.shout-word:nth-child(2) {
  margin-left: clamp(18px, 11vw, 210px);
  animation-delay: 0.16s;
}

.shout-word em {
  font-style: italic;
  font-weight: 500;
}

@keyframes unveil {
  from {
    clip-path: inset(0 0 106% 0);
    transform: translateY(0.2em);
    opacity: 0;
  }
  to {
    clip-path: inset(-34% -9% -26% -9%);
    transform: none;
    opacity: 1;
  }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.shout-foot {
  opacity: 0;
  animation: fade-up 1.2s ease 1.05s forwards;
}

.work {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(90px, 16vh, 190px) var(--edge) 0;
}

.work-kicker {
  margin-bottom: clamp(46px, 8vh, 88px);
}

.piece + .piece {
  margin-top: clamp(110px, 17vh, 210px);
}

.frame {
  margin: 0;
}

.frame-glass {
  position: relative;
  padding: 14px;
  border-radius: 30px;
  border: 1px solid var(--bone-hair);
  background:
    linear-gradient(158deg, rgba(255, 255, 255, 0.13) 0%, rgba(255, 255, 255, 0.05) 46%, rgba(255, 255, 255, 0.085) 100%);
  /* Bylo `backdrop-filter: blur(20px) saturate(160%)` - 30% czasu klatki.
     Rozmycie tla liczy sie przy kazdej klatce, a widac je wylacznie
     w 14-pikselowym marginesie wokol filmu, bo reszte zaslania sam film.
     Statyczny gradient robi to samo wrazenie za darmo. */
  box-shadow:
    0 44px 96px -34px rgba(12, 2, 7, 0.9),
    0 8px 26px -14px rgba(12, 2, 7, 0.7);
  overflow: hidden;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.7s ease;
}

.piece:hover .frame-glass {
  transform: translateY(-5px);
  box-shadow:
    0 58px 116px -34px rgba(12, 2, 7, 0.94),
    0 10px 30px -14px rgba(12, 2, 7, 0.72);
}

.frame-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  object-fit: cover;
  background-color: rgba(20, 5, 10, 0.55);
}

.frame-sheen {
  position: absolute;
  inset: -40% -60%;
  background: linear-gradient(112deg,
    rgba(255, 255, 255, 0) 38%,
    rgba(255, 255, 255, 0.14) 48%,
    rgba(255, 255, 255, 0) 58%);
  transform: translateX(-38%);
  opacity: 0;
  pointer-events: none;
  transition: transform 1.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease;
}

.piece:hover .frame-sheen {
  transform: translateX(38%);
  opacity: 1;
}

.frame-edge {
  position: absolute;
  inset: 0;
  border-radius: 30px;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.piece-caption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px 48px;
  padding: 30px 4px 0;
}

.piece-title {
  grid-column: 1;
  margin: 0;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(2rem, 4.4vw, 3.3rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--bone);
}

.piece-line {
  grid-column: 1;
  max-width: 46ch;
  font-size: 17px;
  color: var(--bone-dim);
}

.piece-stack {
  grid-column: 2;
  grid-row: 1;
  text-align: right;
}

.piece-link {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--bone-hair);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-dim);
  text-decoration: none;
  transition: color 0.4s ease, border-color 0.4s ease;
}

.piece-link-arrow {
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.piece-link:hover {
  color: var(--bone);
  border-bottom-color: var(--light);
}

.piece-link:hover .piece-link-arrow {
  transform: translateX(5px);
}

.outro {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(140px, 26vh, 300px) var(--edge) clamp(90px, 14vh, 150px);
}

.outro-line {
  margin: 0 0 clamp(40px, 7vh, 76px);
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 400;
  font-size: clamp(3rem, 11vw, 9rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--bone);
}

.outro-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 52px;
  padding-top: 26px;
  border-top: 1px solid var(--bone-hair);
}

.outro-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bone-faint);
  text-decoration: none;
  transition: color 0.4s ease;
}

.outro-link:hover {
  color: var(--bone);
}

.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 1.1s cubic-bezier(0.16, 1, 0.3, 1), transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (max-width: 860px) {
  .piece-caption {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .piece-stack,
  .piece-link {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    text-align: left;
  }

  .piece-link {
    align-self: start;
    margin-top: 8px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .portfolio-header {
    padding: 20px var(--edge);
    font-size: 10px;
    letter-spacing: 0.16em;
  }

  .shout {
    padding-top: 92px;
  }

  .shout-line {
    line-height: 0.9;
  }

  .frame-glass {
    padding: 9px;
    border-radius: 22px;
  }

  .frame-edge {
    border-radius: 22px;
  }

  .frame-video {
    aspect-ratio: 4 / 3;
    border-radius: 15px;
  }
}

@media (hover: none) {
  .stage-glow {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .stage-engraving {
    animation: none;
  }

  .shout-word,
  .shout-kicker,
  .shout-foot {
    opacity: 1;
    clip-path: none;
    transform: none;
    animation: none;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .piece:hover .frame-glass {
    transform: none;
  }

  .frame-sheen {
    display: none;
  }
}
