/* Bordro Motoru: "tek kaynak" tarifesi ve "kaynaktan araca" hattı.
   İçerik tools/diyagram.js ile motordan üretilir; burada yalnız çizim.
   Renkler site tokenlarından; vurgu yalnız seçili hatta ve etkin adımda. */

.tk-bolum, .bh-bolum { --hat-cizgi: var(--rule); --hat-vurgu: var(--marka); }

.tk-bas { max-width: 46rem; }
.tk-ust {
  margin: 0 0 1rem; font: 600 var(--type-label)/1.5 var(--font-mono);
  letter-spacing: .16em; text-transform: uppercase; color: var(--text-muted);
}
.tk-bas h2 {
  margin: 0 0 1rem; font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem);
  line-height: 1.08; letter-spacing: -.035em; text-wrap: balance;
}
.tk-bas p:not(.tk-ust) { margin: 0; max-width: 62ch; color: var(--text-muted); }

/* ---------------- tarife ve hatlar ---------------- */

.tk-sahne {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  align-items: stretch; margin-top: clamp(2rem, 4vw, 3rem);
}
.tk-sol { position: relative; padding-bottom: 3.25rem; }
.tk-svg { display: block; width: 100%; height: auto; overflow: visible; }

/* Yüzde kenar boşluğu genişliğe göre çözülür: 1 birim = genişlik / 640. */
.tk-etiket { position: absolute; margin: 0; font: 600 var(--type-label)/1.45 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); }
.tk-etiket-kaynak { top: 0; left: 0; margin-top: calc(402 / 640 * 100%); }
.tk-etiket-govde { bottom: 0; left: calc(257 / 640 * 100%); transform: translateX(-50%); text-align: center; white-space: nowrap; }
.tk-etiket-govde b { display: block; font: 800 var(--type-card-title)/1.2 var(--font-display); letter-spacing: -.01em; text-transform: none; color: var(--text); }
.tk-etiket-govde span { letter-spacing: .04em; text-transform: none; }

.tk-belge { fill: var(--surface); stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.tk-belge-kat, .tk-belge-satir { fill: none; stroke: var(--text); stroke-width: 1.5; }
.tk-giris, .tk-cikis { fill: none; stroke: var(--text); stroke-width: 2.5; }
.tk-ok { fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.tk-basamak { fill: var(--text); stroke: var(--bg); stroke-width: 2; }
.tk-oran { font: 700 14px var(--font-mono); fill: var(--bg); }
.tk-esik { font: 500 12px var(--font-mono); fill: var(--text-muted); }
.tk-cetvel, .tk-taban { stroke: var(--text-muted); stroke-width: 1.5; }
.tk-bus { stroke: var(--text-muted); stroke-width: 1.5; }
/* Gravür: tarama aralığı orandan türer; yük arttıkça basamak koyulaşır. */
[id^="tk-tarama-"] path { stroke: color-mix(in srgb, var(--bg) 26%, transparent); stroke-width: 1.1; }
.tk-gravur { pointer-events: none; }

/* Araç aileleri: renk aileyi söyler, ad her zaman yazılı (--dv sırası sabit). */
.tk-ucret { --aile: var(--dv-1); --aile-yazi: var(--dv-1-ink); }
.tk-ayrilik { --aile: var(--dv-2); --aile-yazi: var(--dv-2-ink); }
.tk-beyan { --aile: var(--dv-3); --aile-yazi: var(--dv-3-ink); }
.tk-dugum { fill: var(--aile); }
.tk-isin { fill: none; stroke: var(--aile); stroke-width: 2; transition: stroke-width .2s ease; }
.tk-uc { fill: var(--bg); stroke: var(--aile); stroke-width: 2.25; transition: fill .2s ease; }
.tk-isin.on { stroke-width: 4; }
.tk-uc.on { fill: var(--aile); }
.tk-cikis li { border-left: 3px solid var(--aile); }
.tk-lejant { display: inline-flex; flex-wrap: wrap; gap: .4rem 1rem; font: 500 var(--type-label)/1.4 var(--font-mono); color: var(--text-muted); }
.tk-lejant span::before { content: ""; display: inline-block; width: .7em; height: .7em; margin-inline-end: .4em; border-radius: 2px; background: var(--aile); vertical-align: -.05em; }

/* Giriş hareketi: bölüm aşağıdan görüş alanına girerse bir kez oynar.
   Basamaklar sıfırdan değerine yükselir (değerini aşmaz), sonra hat araçlara
   uzanır. Yazılar hiç gizlenmez; betik yoksa ya da hareket azaltılmışsa yok. */
.tk-hazir .tk-sutun { transform: scaleY(0); transform-box: fill-box; transform-origin: 50% 100%; }
.tk-hazir .tk-giris, .tk-hazir .tk-cikis, .tk-hazir .tk-bus, .tk-hazir .tk-isin { stroke-dasharray: 100; stroke-dashoffset: 100; }
.tk-hazir .tk-dugum, .tk-hazir .tk-uc, .tk-hazir .tk-ok { opacity: 0; }
.tk-oynat .tk-sutun { transform: scaleY(1); transition: transform .7s cubic-bezier(.25, .8, .3, 1) calc(.25s + var(--s) * .11s); }
.tk-oynat .tk-giris { stroke-dashoffset: 0; transition: stroke-dashoffset .35s ease-out; }
.tk-oynat .tk-ok { opacity: 1; transition: opacity .2s ease .3s; }
.tk-oynat .tk-cikis { stroke-dashoffset: 0; transition: stroke-dashoffset .3s ease-out 1.05s; }
.tk-oynat .tk-bus { stroke-dashoffset: 0; transition: stroke-dashoffset .45s ease-out 1.3s; }
.tk-oynat .tk-isin { stroke-dashoffset: 0; transition: stroke-dashoffset .5s ease-out calc(1.55s + var(--s) * .07s), stroke-width .2s ease; }
.tk-oynat .tk-dugum { opacity: 1; transition: opacity .2s ease calc(1.5s + var(--s) * .07s); }
.tk-oynat .tk-uc { opacity: 1; transition: opacity .25s ease calc(1.95s + var(--s) * .07s), fill .2s ease; }

/* Satırlar hat uçlarıyla hizalı: liste, çizimle aynı yükseklikte sekiz eşit satır. */
.tk-cikis {
  display: grid; grid-template-rows: repeat(8, minmax(0, 1fr));
  margin: 0; padding: 0 0 3.25rem; list-style: none;
}
.tk-cikis li { display: flex; min-height: 0; }
.tk-cikis a {
  display: flex; flex-direction: column; justify-content: center; gap: .1rem;
  width: 100%; padding-inline: .9rem .25rem; color: var(--text); text-decoration: none;
}
.tk-cikis strong { font-size: var(--type-card-title); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.tk-cikis small { font: 400 var(--type-label)/1.4 var(--font-mono); color: var(--text-muted); }
.tk-cikis a:hover strong, .tk-cikis a:focus-visible strong { color: var(--aile-yazi); }
.tk-cikis a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.tk-alt {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .75rem 2rem;
  margin: 1.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--hat-cizgi);
}
.tk-not { font: 500 var(--type-metadata)/1.5 var(--font-mono); letter-spacing: .04em; color: var(--text-muted); }
.tk-alt a { font-size: var(--type-metadata); font-weight: 600; }

/* ---------------- hat: bordro şeridi ---------------- */

.bh-gorsel {
  margin-top: clamp(2rem, 4vw, 3rem);
  padding: clamp(1.1rem, 2.4vw, 1.6rem) clamp(.75rem, 2vw, 1.5rem) 1.1rem;
  background: var(--surface);
  border-top: 2px solid var(--text);
  border-bottom: 1px solid var(--hat-cizgi);
}
.bh-serit {
  --kx: clamp(48px, 5vw, 60px);
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  column-gap: .5rem; row-gap: 1rem;
}
.bh-dugum {
  grid-row: 1; position: relative; isolation: isolate;
  display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; padding-inline-end: .5rem;
}
.bh-dugum::before {
  content: ""; position: absolute; z-index: -1; left: var(--kx); right: -.5rem;
  top: calc(var(--kx) / 2); border-top: 1px dashed var(--text-muted);
}
.bh-dugum:last-of-type::before { display: none; }
.bh-karo { display: block; width: var(--kx); height: var(--kx); margin-bottom: .5rem; }
.bh-cerceve { fill: var(--surface); stroke: var(--text); stroke-width: 2; transition: stroke .3s ease, fill .3s ease; }
.bh-ikon { fill: none; stroke: var(--text); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; transition: stroke .3s ease; }
.bh-no { font: 500 var(--type-label)/1.3 var(--font-mono); color: var(--text-muted); }
.bh-ad { font-weight: 700; font-size: var(--type-card-description); line-height: 1.25; color: var(--text); }
.bh-alt { font: 400 var(--type-label)/1.35 var(--font-mono); color: var(--text-muted); }
.bh-ilerleme { grid-row: 2; grid-column: 1 / -1; height: 2px; background: var(--hat-cizgi); }
.bh-ilerleme span { display: block; height: 100%; width: 100%; background: var(--text); transform-origin: 0 50%; transition: transform .45s cubic-bezier(.2, .7, .2, 1); }

/* Betik çalışınca etkin adım izlenir; betik yoksa hepsi eşit ve tam görünür. */
.bh-js .bh-dugum.bekliyor .bh-cerceve { stroke: var(--text-muted); }
.bh-js .bh-dugum.bekliyor .bh-ikon { stroke: var(--text-muted); }
.bh-js .bh-dugum.bekliyor .bh-ad { color: var(--text-muted); font-weight: 600; }
.bh-js .bh-dugum.bitti .bh-cerceve { fill: var(--surface-2); }
.bh-js .bh-dugum.bitti::before { border-top: 2px solid var(--text); }
.bh-js .bh-dugum.aktif .bh-cerceve { stroke: var(--hat-vurgu); stroke-width: 2.5; fill: color-mix(in srgb, var(--hat-vurgu) 9%, var(--surface)); }
.bh-js .bh-dugum.aktif .bh-ikon { stroke: var(--hat-vurgu); }
.bh-js .bh-dugum.aktif .bh-ad { color: var(--hat-vurgu); }

.bh-adimlar { margin: clamp(1.5rem, 3vw, 2.5rem) 0 0; padding: 0; list-style: none; }
.bh-adim {
  display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: .75rem 2.5rem;
  padding-block: clamp(1.5rem, 3vw, 2.25rem); border-top: 1px solid var(--hat-cizgi);
}
.bh-adim-no { margin: .2rem 0 0; font: 600 var(--type-label)/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); }
.bh-adim-no span { margin-inline-end: .6rem; color: var(--text); letter-spacing: 0; }
.bh-adim h3 { margin: 0 0 .5rem; font-size: var(--type-card-title); line-height: 1.3; }
.bh-adim p { margin: 0; max-width: 64ch; }
.bh-adim > div > p:not([class]) { color: var(--text-muted); }
.bh-cipler { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem !important; }
.bh-cipler span {
  padding: .3rem .55rem; border-radius: var(--radius); background: var(--surface-2);
  font: 500 var(--type-label)/1.4 var(--font-mono); color: var(--text-muted);
}
.bh-git { margin-top: .9rem !important; font-size: var(--type-metadata); font-weight: 600; }
.bh-js .bh-adim.aktif .bh-adim-no span { color: var(--hat-vurgu); }

@media (min-width: 900px) and (min-height: 640px) {
  .bh-gorsel { position: sticky; top: 4.5rem; z-index: 2; }
}

@media (max-width: 760px) {
  .tk-sahne { grid-template-columns: 1fr; }
  .tk-sol { max-width: 30rem; }
  /* Dar ekranda çizim yarı boyuta iner: etiket akışa girer, eşikler
     okunmayacak kadar küçüleceği için gizlenir (oranlar büyür). */
  .tk-etiket-kaynak { position: static; margin: 0 0 .5rem; }
  .tk-etiket-kaynak br { display: none; }
  .tk-esik, .tk-cetvel { display: none; }
  .tk-oran { font-size: 19px; }
  .tk-cikis { grid-template-rows: none; grid-template-columns: 1fr 1fr; gap: 0 1rem; padding: 0; margin-top: 1.25rem; }
  .tk-cikis a { padding: .75rem 0; border-top: 1px solid var(--hat-cizgi); }
  .tk-cikis strong { font-size: var(--type-card-description); }
  .bh-serit { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 1.25rem; }
  .bh-ilerleme { display: none; }
  .bh-dugum { grid-row: auto; }
  .bh-dugum::before { display: none; }
  .bh-adim { grid-template-columns: 1fr; gap: .5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .tk-isin, .tk-uc, .bh-cerceve, .bh-ikon, .bh-ilerleme span { transition: none; }
  .tk-hazir .tk-sutun { transform: none; }
  .tk-hazir .tk-giris, .tk-hazir .tk-cikis, .tk-hazir .tk-bus, .tk-hazir .tk-isin { stroke-dashoffset: 0; }
  .tk-hazir .tk-dugum, .tk-hazir .tk-uc, .tk-hazir .tk-ok { opacity: 1; }
}
