:root {
  --bar: #10281c;
  --bar-2: #1b3a2a;
  --ink: #eaf3ee;
  --accent: #1f9d55;
  --answer: #c2185b;   /* gosterilen dogru cevap */
  --student: #1565c0;  /* ogrencinin kendi yazdigi / sectigi */
  --right: #14804a;
  --wrong: #c62828;
  --near: #b26a00;     /* dogru kelime, yanlis buyuk/kucuk harf */
  --radius: 10px;
  --chrome: 52px;
}

* { box-sizing: border-box; }

/* display:flex/grid kurallari [hidden]'i ezmesin */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1a13;
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
}

#stage { cursor: grab; }
#stage:active { cursor: grabbing; }

button { font: inherit; color: inherit; cursor: pointer; }
/* Tanitim sitesine donus baglantisi da bir "chip" gibi gorunsun: <a> oldugu
   icin tarayicinin varsayilan mavi link rengini aliyordu, ikonun stroke'u da
   currentColor oldugu icin ikon maviye donuyordu. */
a.chip { text-decoration: none; color: var(--ink); }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .1);
  transition: background .15s;
}
.chip:hover { background: rgba(255, 255, 255, .2); }
.chip:disabled { opacity: .3; cursor: default; }
.chip svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.primary {
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}
.primary:disabled { opacity: .4; cursor: default; }

/* ---------- ust cubuk ---------- */

#topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--chrome);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--bar);
  z-index: 30;
}
#unit-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
#pager { display: flex; align-items: center; gap: 6px; }
#page-label { min-width: 62px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- sahne ---------- */

#stage {
  position: fixed;
  inset: var(--chrome) 0 0 0;
  overflow: hidden;
  touch-action: none;
}

#page {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  transition: transform .38s cubic-bezier(.22, .68, .3, 1);
  will-change: transform;
}
#page.instant { transition: none; }
/* Tarayicinin kendi resim surukleme davranisi pointer olaylarini engelliyordu */
#page img {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

#lines, #overlay, #hotspots {
  position: absolute;
  inset: 0;
}
#lines { pointer-events: none; }
#overlay { pointer-events: none; }

/* ---------- buyutec ikonlari ---------- */

.mag {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.mag b { font-size: 20px; line-height: 1; }
.mag svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.mag.has-audio::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffb300;
  border: 2px solid var(--bar);
}

/* ---------- cevap katmani ---------- */
/* Ayni katman iki isi goruyor: ogrenci buraya cevabini yaziyor/tikliyor,
   ogretmen de ayni yerde dogru cevabi gosteriyor. */

.step {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--answer);
  font-weight: 700;
}

/* --- yazilan cevaplar --- */

.step.text {
  pointer-events: auto;
  white-space: nowrap;
  gap: .22em;
}
.step.text input.ans {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  color: var(--student);
  text-align: center;
  user-select: text;
  outline: none;
}
/* Bos bosluklar hafif isaretli durur ki yazilabilecekleri anlasilsin;
   ilk harf yazilinca isaret kendiliginden kalkar. */
.step.text input.ans:placeholder-shown { background: rgba(31, 157, 85, .13); }
.step.text input.ans:focus { background: rgba(31, 157, 85, .24); }

.step.text.revealed input.ans { color: var(--answer); }
.step.text.right input.ans { color: var(--right); }

/* Yanlisa dogru cevabi ogrencinin cevabinin YANINA yazmak sigmiyordu
   (1d'de bosluk 32px, iki metin 49px istiyor). Bunun yerine boslukta artik
   dogru cevap YALNIZ BASINA duruyor; renk hukmu soyluyor.
   Ogrencinin yazdigi kaybolmadi - kutuya dokununca geri geliyor. */
.step.text.wrong input.ans { color: var(--wrong); cursor: pointer; }
.step.text.near input.ans { color: var(--near); cursor: pointer; }

/* --- tiklanabilir secenekler (tick / circle / underline / mark) --- */
/* underline: dairenin kardesi, cizgi metnin altinda (Unit 7 3d, 7b, 8g).
   mark: dokundukca isaret degisir. Gosterilen isaret .on / .missed iken
   dogrusu (data-v), degilse ogrencinin sectigi (data-sel). README Open
   questions 3 ve 4, Metin 23 Eylul 2026. */

.step.tick, .step.circle, .step.underline, .step.mark {
  pointer-events: auto;
  cursor: pointer;
  color: var(--student);
  border-radius: 6px;
}
.step.circle { border: .16em solid transparent; border-radius: 50%; }
.step.underline { border-bottom: .14em solid transparent; border-radius: 0; }
.step.mark { border: .16em solid transparent; }
/* Gorunmez dokunma payi. .15em siniri olcerek bulundu: en sikisik
   etkinliklerde (starter 1e, unit8 1e ve 7d) alanlarin birbirine girmedigi en
   buyuk deger; .25em'de cakisma basliyor ve celdiriciler DOM'da sonra geldigi
   icin cakismayi onlar kazaniyor. Telefonda rahat tiklamanin asil yolu pinch.

   DIKKAT: bunu olcerken getComputedStyle sayfa DUZLEMI biriminde deger
   doner, getBoundingClientRect ise EKRAN biriminde. Ikisini karsilastirmadan
   once pay, o anki olcekle carpilmali - yoksa olmayan cakismalar gorunur. */
.step.tick::after, .step.circle::after, .step.underline::after, .step.mark::after {
  content: "";
  position: absolute;
  inset: calc(-1 * min(var(--hit, 0px), .15em));
}
.step.tick:hover, .step.circle:hover, .step.underline:hover, .step.mark:hover {
  background: rgba(31, 157, 85, .18);
}
.step.tick:focus-visible, .step.circle:focus-visible,
.step.underline:focus-visible, .step.mark:focus-visible { outline: 3px solid var(--accent); }

.step.tick.sel::before,
.step.tick.on::before,
.step.tick.missed::before { content: "\2713"; font-size: 1.6em; line-height: 0; }
.step.circle.sel, .step.circle.on, .step.circle.missed { border-color: currentColor; }
.step.underline.sel, .step.underline.on, .step.underline.missed { border-bottom-color: currentColor; }

.step.mark.on[data-v="tick"]::before,
.step.mark.missed[data-v="tick"]::before,
.step.mark.sel[data-sel="tick"]:not(.on):not(.missed)::before { content: "\2713"; font-size: 1.6em; line-height: 0; }
.step.mark.on[data-v="cross"]::before,
.step.mark.missed[data-v="cross"]::before,
.step.mark.sel[data-sel="cross"]:not(.on):not(.missed)::before { content: "\2717"; font-size: 1.6em; line-height: 0; }
.step.mark.on[data-v="circle"],
.step.mark.missed[data-v="circle"],
.step.mark.sel[data-sel="circle"]:not(.on):not(.missed) { border-color: currentColor; border-radius: 50%; }
.step.mark.on[data-v="underline"],
.step.mark.missed[data-v="underline"],
.step.mark.sel[data-sel="underline"]:not(.on):not(.missed) {
  border-color: transparent transparent currentColor; border-radius: 0;
}

.step.tick.on, .step.circle.on, .step.underline.on, .step.mark.on { color: var(--answer); }
.step.tick.right, .step.circle.right, .step.underline.right, .step.mark.right { color: var(--right); }
.step.tick.wrong, .step.circle.wrong, .step.underline.wrong, .step.mark.wrong { color: var(--wrong); }
/* Kacirilan dogru cevap: soluk yesil - "bu da dogruydu" demek. */
.step.tick.missed, .step.circle.missed, .step.underline.missed, .step.mark.missed {
  color: var(--right); opacity: .5;
}

/* --- not kutulari --- */

.step.note {
  color: #1b3a2a;
  background: rgba(255, 235, 160, .95);
  border-radius: 6px;
  padding: .3em .5em;
  font-weight: 600;
  white-space: normal;
  text-align: center;
  opacity: 0;
  transform: scale(.8);
  transition: opacity .25s, transform .25s;
}
.step.note.on { opacity: 1; transform: none; }

#lines line {
  stroke: var(--answer);
  stroke-width: 5;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity .25s;
}
#lines line.on { opacity: 1; }

/* ---------- gorev cubugu ---------- */

/* Alt cubuklar: ortalanmis bir sutun. Sabit piksel ofseti yok, bu yuzden
   biri iki satira sarsa bile digerinin uzerine binmez. */
#bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  pointer-events: none;
}
#bottom > * { pointer-events: auto; }

#taskbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px;
  border-radius: 14px;
  background: rgba(16, 40, 28, .95);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 26px rgba(0, 0, 0, .45);
}
#task-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding: 0 4px; }
#task-id {
  flex: none;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent);
  font-weight: 700;
  font-size: 13px;
}
#task-instruction { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
/* Ic grup da sarabilmeli - yoksa 5 dugme dar ekranda cubuktan tasiyor. */
#steps-controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 6px; }
#step-count { opacity: .75; font-weight: 500; }
.chip.audio { background: #ffb300; color: #201400; }
.chip.audio:hover { background: #ffc233; }
/* "Show answer" yesil, "Check answers" mavi - ogrenci rengi ile ayni. */
.primary.check { background: var(--student); }

/* ---------- ses cubugu ---------- */

#audiobar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(640px, 100%);
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(27, 58, 42, .96);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 26px rgba(0, 0, 0, .45);
}
#au-track { font-weight: 600; white-space: nowrap; }
#au-time { font-variant-numeric: tabular-nums; font-size: 13px; opacity: .8; white-space: nowrap; }
#au-seek { flex: 1; min-width: 60px; accent-color: var(--accent); }

/* ---------- kucuk resimler ---------- */

#thumbs {
  position: fixed;
  inset: var(--chrome) auto 0 0;
  width: 190px;
  padding: 10px;
  overflow-y: auto;
  background: var(--bar);
  z-index: 25;
  display: grid;
  gap: 10px;
  align-content: start;
}
#thumbs button {
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 0;
  background: none;
  line-height: 0;
}
#thumbs button.on { border-color: var(--accent); }
#thumbs img { width: 100%; border-radius: 4px; }
#thumbs span { display: block; padding-top: 4px; font-size: 12px; line-height: 1.2; opacity: .7; }

#fatal {
  max-width: 46ch;
  margin: 18vh auto 0;
  padding: 0 20px;
  text-align: center;
  line-height: 1.7;
  opacity: .85;
}

#toast {
  position: fixed;
  left: 50%;
  top: calc(var(--chrome) + 14px);
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .82);
  z-index: 40;
}

/* Dar VEYA kisa ekran (yatay telefon) - komut metni cubugu sardirmasin. */
@media (max-width: 780px), (max-height: 540px) {
  #task-instruction { display: none; }
  #unit-title { display: none; }
  #thumbs { width: 130px; }
}

/* Cok dar veya cok kisa: cubuklar sarar, kaydirici kendi satirina iner. */
@media (max-width: 520px), (max-height: 440px) {
  :root { --chrome: 48px; }
  #bottom { bottom: 8px; gap: 6px; padding: 0 6px; }
  #taskbar, #audiobar { gap: 6px; padding: 6px; }
  .chip { min-width: 34px; height: 34px; padding: 0 8px; }
  .primary { height: 34px; padding: 0 12px; font-size: 14px; }
  .long { display: none; }   /* "Check answers" -> "Check" */

  /* Ust cubuk dar ekranda tasiyordu: unite secici ve sayfa sayaci kuculur,
     boylece tam ekran dugmesi ekran disinda kalmaz. */
  #topbar { gap: 5px; padding: 0 6px; }
  #unit-picker { height: 34px; max-width: 82px; padding: 0 4px; font-size: 13px; }
  #page-label { min-width: 46px; font-size: 13px; }

  /* Kaydirici dar satirda ezilmesin diye tam genislik alir. */
  #au-seek { flex: 1 0 100%; order: 10; margin: 0; }
  #au-track, #au-time { font-size: 13px; }
}

/* Unite secici - ust cubuktaki diger dugmelerle ayni dilde dursun. */
#unit-picker {
  height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .1);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
#unit-picker option { color: #10281c; background: #fff; }

