This is a bit difficult but important part of Croatian.
koji: Adjective Clauses
There's a way to turn any sentence into a clause appended to a noun. To see what I'm talking about, let's see how we can decribe a book:
Čitam dobru knjigu. "I'm reading a good book."
Čitam tu knjigu. I'm reading that book."
Čitam tvoju knjigu. I'm reading your book."
But maybe you want to say something else, that "you wrote that book." and now "I'm reading a book." English uses a simple modification of sentence:
"I'm reading a book (which) you wrote."
"A book you wrote" is a kind of book, similar to "my book", but not described using a simple attribute, but a whole sentence. Now, how to say it in Croatian? First, start with the sentence:
Napisala si tu knjigu. "You wrote that book."
Second, transform it by inserting the same case/number/gender of koji instead of the words (tu knjigu) you are going to replace, and move it to the front:
Koju si napisala "that/which you wrote"
Then, use it after the noun in the main sentence:
Čitam knjigu [koju si napisala]. "I'm reading a book (which) you wrote."
The word koju cannot be left out. It doesn't change, it's locked in its case, together with the rest of the clause:
pročitao säm u knjizi [koju si napisala]... (knjizi = dat.)
iz knjige [koju si napisala]..."from the book [you wrote]" (knjige = gen.)
s knjigom [koju si napisala]..."with the book [you wrote]" (knjigom = ins.)
However, if you read "books", then she wrote "books", so koju must go in plural:
Čitam knjige [koje si napisala]. "I'm reading (the) books [you wrote]."
One could say that koji agrees with the noun it follows in its number and in gender, but its case (here: acc.) is defined by its role in the inserted sentence (= clause). We can use any role in the sentence:
Probudio säm ženu [koja je spavala u autu]. "I woke up a woman [who was sleeping in the car]."
As in questions, English demands "who" in properties of a subject, but Croatian uses always the same pattern. In the above example, koja is in the nom.sg.f.
If the word in the inserted sentence is a part of a prepositional phrase, the preposition comes to the first place before koji (it sticks to it, as in questions):
Čistim sobu [u kojoj si spavala]. "I'm cleaning the room [you were sleeping in]."
U toj sobi si spavala.
There's another, possibly a simpler way to understand this. You want to insert a sentence about the "book" in the main sentence that also has to do with the same "book". Rearrange two sentences so that both "books" come as close as possible:
Čitam knjigu. Tu knjigu si napisala.
Čistim sobu. U toj sobi si spavala.
You must respect constraints of word order, and this is as close as it gets. Now, replace phrase ta knjiga "that book" (adjusted for case) with an appropriate gender/case/number of koji "what/which", and just join the sentences:
Čitam knjigu koju si napisala.
Čistim sobu u kojoj si spavala.
It is now glued to a noun, the clause cannot be separated:
U sobi [u kojoj si spavala] je hladno. "It's cold in the room [you slept in]."
Such clauses are often called relative clauses, and koji serves as a "relative pronoun", "relative conjunction" etc. Names are not that important.
Other Adjective Clauses
There are three other ways to make adjective clauses, similar to three other types of questions about adjectives. But the main confusion is with quality-clauses made with kakäv. Such questions and clauses are only regarding what some things are like. Straightforward:
Čitam knjigu [kakvu si napisala].
This sentence looks slightly awkward to a Croatian speaker, but it's regular. It means:
"I'm reading a book like (the) one you wrote."
It's just a "similar book". But with koji, it's really determining — exactly the same "book", one of them, etc.
Everything said about koji-clauses applies to kakav-clauses applies to this type as well, but it's likeness. They are much less often used, so I'm not going to write about such sentences much more.
The third type of determining is by possession. Creating them follows the same rules, just replace with čiji "whose":
Došao je čovjek [čiji auto säm vozio] "A man [whose car I drove] came"
došao je čovjek + njegov auto säm vozio
All these types were just appended to a noun. But similar clauses can be appended to adverbs such as tako, ovdjë, tamo, tada, etc. making them more specific:
Idemo tamo. "We're going there."
Ondjë/tamo je toplo. "It's warm there."
To insert a clause, use question-words gdjë, kako, kamo, kad(a), koliko, etc. The word tamo (or ondjë) from the second sentence is replaced by gdjë:
Idemo tamo [gdjë je toplo]. "We're going where it's warm."
Since adverbs are predictable, they can be removed:
Idemo [gdjë je toplo]. Vratit ću se [kad nađem posao]. "I'll return when I find a job."
Nisam jeo od [kada sam se probudio]. "I didn't eat since I had woken up." (lit. "from when")
Platit ću [koliko sam dužän]. "I'll pay as much as I owe."
Napravio sam [kako si mi rekla]. "I did how you had told me."
As with questions, there are fused variants otkad(a) etc.
Another word used to make relational subclauses is dok "while"; it's not used to pose questions:
Pojeli smo ručäk [dok si gledao televiziju]. "We ate the lunch [while you were watching TV]."
Adverb Clauses with Verbs of Knowledge and Perception
Such clauses can be used with verbs like znam "know", vidim "see", čujem "hear" etc., to represent information, same as in English:
Znam [gdjë su ključevi]. "I know [where the keys are]"
Vidjëla si [kad sam došao]. "You saw [when I came]."
A completely different type of compound sentences are replacements for nouns. The clauses above were just attachments to nouns, but we can make a sentences like:
"I took what was in the box."
One can, of course, rephrase it as "I took things that were in the box", but it's now less generic, maybe there was just one thing. Nevertheless, because of such rephrasing, these constructs are much less used.
In Croatian, you start with sentences:
Uzeo säm nešto. "I took something."
Što je bilo u kutiji. "What was in the box."
You then replace nešto "something" from the first sentence with the entire second one:
Uzeo säm [što je bilo u kutiji].
The inserted sentence is identical to a question. A tko (for persons) or što (for everything else) must be put in the appropriate case.
Što je u kutiji? (što = acc.)
Što jede? (što = acc.) "What is (he/she) eating?"
S kim šeće? (kim = ins.) "Who is (he/she) walking with?"
Na čemu su ključevi? "What are the keys on?"
Vidim [što je u kutiji]. "I see what is in the box."
Vidim [što jede]. "I see what he/she is eating."
Znam [s kim šeće]. "I know who he/she is walking with."
Znam [na čemu su ključevi]. "I know what the keys are on."
Znam [tko je pred vratima]. "I know [who is in front of the door].
Ne znam [kome si poslao pismo]. "I don't know [who you sent the letter to]."
Sometimes, people leave pronouns in front of tko/što, so it could be:
Vidim nešto što je u kutiji. Znam nekog s kim šeće.
It has a slightly different meaning — you see "something that's in the box", "somebody he walks with", etc. But possibly not all. Without netko/nešto, you see/know all that's in.
Some other pronouns can be used in front of tko/što:
Vidim ono [što je u kutiji]. "I see what is in the box."
Vidim to [što jede]. "I see what he/she is eating."
Znam onoga [s kim šeće]. "I know who he/she is walking with."
Znam ono [na čemu su ključevi]. "I know what the keys are on."
With such pronouns there's no change of meaning, ono što is really the same as ono. So, tko/što can be used on its own, or attached to pronouns, or as a replacement for pronouns and nouns.
Again, the case of tko/što is fully determined by the inserted clause, it nothing to do with the whole sentence. The inserted clause starts with the question-word, so it's at the first place, short words follow it immediately, according to the placement rule.
Also, regarding the tenses, there are no problems really, just put one sentence into another, nothing needs to be adjusted, contrary to English.
Of all types, koji-clauses are the most often used.
Clauses talking more about a noun — come after the noun:
"which" knjiga koju si napisala ← tu knjigu si napisala "what like" knjiga kakvu si napisala ← takvu knjigu si napisala "as much as" novca koliko si imala ← toliko novca si imala "whose" žena čiju knjigu čitam ← njegovu/njenu knjigu čitam (don't remove knjigu)
Turning a whole sentence into a time, location, manner, etc. clause, or to an addition to an adverb:
"how" (tako/ovako...) kako si rekla ← tako si rekla "where" (tu/ovdje...) gdjë si spavala ← tu si spavala "when" (tada/onda...) kad(a) si došla ← tada si došla ... ... ...
All question-words for adverb-type sentences can be used.
Replacing noun or talking more about a pronoun:
"exactly" "some" "who" (onaj) tko je napisao netko tko je napisao "what" (ono) što si napisala nešto što si napisala
Relative clauses are really often used, one account says when translating from Russian, their amount triples in the Croatian text compared to the Russian one. Croatian really likes them since they replace some constructs common in other languages.