/* ==========================================================================
   Cizi Code — Aktif Bağlantı Haritası
   Tüm seçiciler .cbh altında scope'lu. Global reset YOK, mevcut UI'ya
   enjekte edildiğinde dışarı sızmaz.

   RENK KURALI: hiçbir kuralın içinde sabit renk yok. Her renk .cbh üzerindeki
   bir belirteçten gelir; gömüldüğü arayüz o belirteçleri ezerek haritanın
   tamamını (kart, hayalet, ikon kutusu, nokta, süpürme, kablo, pin, parça)
   kendi temasına bağlar. Buradaki değerler yalnız tek başına kullanım için
   varsayılan: videodan piksel örneklemesiyle alınmış koyu palet.
   ========================================================================== */

.cbh {
  /* --- yüzeyler --- */
  --cbh-panel:      #1b2431;
  --cbh-card:       #1e2531;   /* model kartı */
  --cbh-card-2:     #131c27;   /* araç kartı (daha koyu) */
  --cbh-provider:   #1f2833;
  --cbh-provider-glow: #26303d;
  --cbh-line:       #2c3540;
  --cbh-line-soft:  #262f3b;

  /* --- mürekkep --- */
  --cbh-text:       #e8eef6;
  --cbh-muted:      #8c9bad;
  --cbh-dim:        #5d6b7c;
  --cbh-title:      #c3cedb;

  /* --- süs yüzeyleri: boş slot hayaleti, ışık süpürmesi, ikon kutusu --- */
  --cbh-ghost:      rgb(255 255 255 / 2.2%);
  --cbh-ghost-mark: #5c6878;
  --cbh-sheen:      rgb(255 255 255 / 7.5%);
  --cbh-cloud:      #cfd9e5;
  --cbh-ticon-bg:   #182231;
  --cbh-ticon-line: #38424f;
  --cbh-ticon-ink:  #b9c5d3;

  /* --- kablolar: iki demet, iki renk. Sol demet (sağlayıcı → model) --cbh-wire,
         sağ demet (model → araç) --cbh-wire-b. Opaklık türetilebilsin diye rgb
         komponenti olarak yazılırlar. Tek başına kullanımda ikisi aynı. --- */
  --cbh-wire:       249 115 22;    /* #f97316 */
  --cbh-wire-b:     var(--cbh-wire);
  --cbh-ok:         #34d399;
  --cbh-dot:        6px;      /* çevrimiçi ışığının çapı */

  /* --- geometri (videodaki oranlar) --- */
  --cbh-card-h:     56px;
  --cbh-card-h-min: 24px;
  --cbh-card-h-max: var(--cbh-card-h);
  --cbh-row-gap:    12px;
  --cbh-col-w:      150px;      /* provider kolonu */
  --cbh-col-gap:    clamp(84px, 13vw, 184px);
  --cbh-radius:     10px;

  /* --- kablo --- */
  --cbh-wire-w:      1.6px;
  --cbh-wire-glow-w: 7px;
  --cbh-pulse-w:     2.1px;
  --cbh-blur:        4px;

  position: relative;
  /* Sahne kalan yüksekliğin tamamını alır: köke bir yükseklik verildiğinde
     (gömüldüğü panelde olduğu gibi) kartlar o alana yayılır, içeriğin bittiği
     yerde durup altında ölü bir boşluk bırakmaz. */
  display: flex;
  flex-direction: column;
  padding: 16px 20px 22px;
  border-radius: 12px;
  background: var(--cbh-panel);
  color: var(--cbh-text);
  font-family: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  contain: layout paint;
}

/* --- panel başlığı ------------------------------------------------------ */
.cbh__head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 18px;
}
.cbh__title {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--cbh-title);
}
.cbh__help {
  display: grid;
  place-items: center;
  width: 13px; height: 13px;
  border: 1px solid var(--cbh-dim);
  border-radius: 50%;
  font-size: 9px;
  color: var(--cbh-muted);
  cursor: default;
}

/* --- sahne: grid + iki SVG katmanı ------------------------------------- */
.cbh__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--cbh-col-w) 1fr 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: var(--cbh-col-gap);
  row-gap: 10px;
  align-items: stretch;
  /* Kart sayısı sahnenin dışına taşamaz: kolonlar kalan yükseklikte küçülür,
     artan yığın paneli aşıp grafiğin üstüne binmez. */
  overflow: hidden;
}

/* kablolar kartların ARKASINDA, pinler ÖNÜNDE */
.cbh__wires,
.cbh__pins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.cbh__wires { z-index: 1; }
.cbh__pins  { z-index: 3; }

.cbh__coltitle {
  grid-row: 1;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--cbh-dim);
}
.cbh__coltitle--provider { grid-column: 1; text-align: center; }
.cbh__coltitle--models   { grid-column: 2; }
.cbh__coltitle--tools    { grid-column: 3; }

/* Kolonlar satırın tamamını kaplar. Yığın kalan yüksekliğe yayılır: az kart
   varken kartlar --cbh-card-h-max'a kadar büyür ve aralarındaki boşluk eşit
   dağılır; çok kart varken --cbh-card-h-min'e kadar küçülüp yan yana dizilir.
   Her iki uçta da harita panelin dışına çıkmaz ve içinde ölü alan bırakmaz. */
.cbh__col {
  position: relative;
  grid-row: 2;
  z-index: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: var(--cbh-row-gap);
}
.cbh__col--provider { grid-column: 1; }
.cbh__col--models   { grid-column: 2; }
.cbh__col--tools    { grid-column: 3; }

/* --- boş slot hayaleti ("+" kutusu) ------------------------------------ */
.cbh__ghost {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* Süs öğesi. `is-out` yalnızca opacity'yi sıfırlıyor, öğe DOM'da kalıyor ve
     z-index 1 ile kartların üstünde duruyordu: araç kartlarının tıklanabilir
     alanı, hayaletin ölçüsü dışında kalan birkaç piksellik şeride iniyordu. */
  pointer-events: none;
  display: grid;
  place-items: center;
  border-radius: var(--cbh-radius);
  background: var(--cbh-ghost);
  transition: opacity .5s ease, transform .5s ease;
}
.cbh__ghost::before {
  content: "";
  width: 20px; height: 20px;
  background:
    linear-gradient(var(--cbh-ghost-mark), var(--cbh-ghost-mark)) center/100% 1.4px no-repeat,
    linear-gradient(var(--cbh-ghost-mark), var(--cbh-ghost-mark)) center/1.4px 100% no-repeat;
  opacity: .85;
}
.cbh__ghost.is-out { opacity: 0; transform: scale(.985); }

/* ==========================================================================
   KARTLAR
   ========================================================================== */
.cbh__card {
  position: relative;
  /* Kart yüksekliği iki sınır arasında serbest: yığın kısaysa kartlar büyür,
     uzunsa küçülür. Sahnenin dışına taşmak yok. */
  flex: 1 1 auto;
  min-height: var(--cbh-card-h-min);
  max-height: var(--cbh-card-h-max);
  border: 1px solid var(--cbh-line);
  border-radius: var(--cbh-radius);
  overflow: hidden;
  /* giriş başlangıç durumu — JS .is-in ekleyince açılır */
  opacity: 0;
  transform: translateX(-26px) scale(.93);
  filter: blur(7px);
  transition:
    opacity   var(--in-dur, 500ms) cubic-bezier(.16, 1, .3, 1) var(--in-delay, 0ms),
    transform var(--in-dur, 500ms) cubic-bezier(.16, 1, .3, 1) var(--in-delay, 0ms),
    filter    var(--in-dur, 500ms) cubic-bezier(.16, 1, .3, 1) var(--in-delay, 0ms),
    box-shadow 700ms ease,
    border-color 700ms ease;
}
.cbh__card.is-in {
  opacity: 1;
  transform: none;
  filter: none;
}
/* kablo kartın kenarına değdiği andaki parlama */
.cbh__card.is-flash {
  border-color: rgb(var(--cbh-wire) / .75);
  box-shadow:
    0 0 0 1px rgb(var(--cbh-wire) / .25),
    0 0 22px -4px rgb(var(--cbh-wire) / .45);
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

/* --- provider kartı ---------------------------------------------------- */
.cbh__card--provider {
  flex: 1 1 auto;
  min-height: 140px;
  max-height: none;
  display: grid;
  place-content: center;
  gap: 9px;
  justify-items: center;
  background:
    radial-gradient(115% 75% at 28% 16%, var(--cbh-provider-glow) 0%, transparent 60%),
    var(--cbh-provider);
  transform: scale(.4);            /* provider ortadan büyüyerek gelir */
  filter: blur(10px);
}
.cbh__card--provider.is-in { transform: none; }

.cbh__card--provider .cbh__pname {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: .01em;
}
.cbh__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--cbh-ok);
}
/* Çevrimiçi ışığı: rengi ve çapı tek belirteçten. Halesi rengin kendisinden
   türer, ikinci bir renk tanımlamaya gerek kalmaz. */
.cbh__dot {
  flex: none;
  width: var(--cbh-dot); height: var(--cbh-dot);
  border-radius: 50%;
  background: var(--cbh-ok);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--cbh-ok) 18%, transparent),
    0 0 8px color-mix(in srgb, var(--cbh-ok) 75%, transparent);
}
.cbh__dot--muted { background: var(--cbh-dim); box-shadow: none; }

/* provider üzerinden geçen tek seferlik ışık süpürmesi */
.cbh__sheen {
  position: absolute;
  inset: -40% -60%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, var(--cbh-sheen) 50%, transparent 62%);
  transform: translateX(-70%);
  opacity: 0;
}
.cbh__card--provider.is-sheen .cbh__sheen {
  animation: cbh-sheen 1150ms cubic-bezier(.4, 0, .2, 1) 1 both;
}
@keyframes cbh-sheen {
  0%   { opacity: 0;  transform: translateX(-70%); }
  22%  { opacity: 1; }
  100% { opacity: 0;  transform: translateX(70%); }
}

/* --- model kartı ------------------------------------------------------- */
.cbh__card--model {
  flex-basis: var(--cbh-card-h);
  max-height: var(--cbh-card-h-max);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 14px;
  background: var(--cbh-card);
}
.cbh__mname {
  font-size: 13px;
  font-weight: 500;
}
.cbh__meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 10.5px;
  color: var(--cbh-muted);
}

/* --- araç kartı: önce boş çerçeve, sonra içerik ------------------------ */
.cbh__card--tool {
  flex-basis: var(--cbh-card-h);
  max-height: var(--cbh-card-h-max);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 14px;
  background: var(--cbh-card-2);
  border-color: var(--cbh-line-soft);
  /* çerçeve fazı: sadece kutu görünür, içerik değil */
  transform: translateX(0) scale(.985);
  filter: none;
}
.cbh__card--tool .cbh__ticon,
.cbh__card--tool .cbh__tname {
  opacity: 0;
  transform: translateY(5px);
  transition:
    opacity   var(--fill-dur, 440ms) cubic-bezier(.16, 1, .3, 1) var(--fill-delay, 0ms),
    transform var(--fill-dur, 440ms) cubic-bezier(.16, 1, .3, 1) var(--fill-delay, 0ms);
}
.cbh__card--tool.is-filled .cbh__ticon,
.cbh__card--tool.is-filled .cbh__tname {
  opacity: 1;
  transform: none;
}
.cbh__tname { font-size: 13px; font-weight: 500; }
.cbh__card--tool .cbh__dot { margin-left: auto; opacity: 0; transition: opacity .45s ease var(--fill-delay, 0ms); }
.cbh__card--tool.is-filled .cbh__dot { opacity: 1; }

/* --- ikonlar ----------------------------------------------------------- */
.cbh__icon { flex: none; display: block; }
.cbh__icon--cloud  { width: 30px; height: 30px; color: var(--cbh-cloud); }
.cbh__icon--model  {
  width: 17px; height: 17px;
  color: rgb(var(--cbh-wire));
  filter: drop-shadow(0 0 5px rgb(var(--cbh-wire) / .55));
}
.cbh__ticon {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px; height: 22px;
  border: 1px solid var(--cbh-ticon-line);
  border-radius: 6px;
  color: var(--cbh-ticon-ink);
  background: var(--cbh-ticon-bg);
}
.cbh__ticon svg { width: 12px; height: 12px; }

/* ==========================================================================
   KABLOLAR
   Her yol kendi demetinin rengini yerel `--w` belirtecinden okur: soldaki
   demet --cbh-wire, sağdaki --cbh-wire-b. Aşağıdaki kuralların hiçbiri hangi
   demette olduğunu bilmek zorunda değil.
   ========================================================================== */
.cbh__wires path,
.cbh__pin { --w: var(--cbh-wire); }
.cbh__wires path.is-stage-b,
.cbh__pin.is-stage-b { --w: var(--cbh-wire-b); }

.cbh__wire-glow {
  fill: none;
  stroke: rgb(var(--w) / .30);
  stroke-width: var(--cbh-wire-glow-w);
  stroke-linecap: round;
  filter: blur(var(--cbh-blur));
}
.cbh__wire-core {
  fill: none;
  stroke: rgb(var(--w) / .72);
  stroke-width: var(--cbh-wire-w);
  stroke-linecap: round;
  transition: stroke 900ms ease, stroke-width 900ms ease;
}
/* büyüme sırasında kablo "sıcak": kendi renginin tam parlak hâli */
.cbh__wire-core.is-hot { stroke: rgb(var(--w) / .96); stroke-width: 1.9px; }
.cbh__wire-glow.is-hot { stroke: rgb(var(--w) / .5); }
.cbh__wire-core.is-wire-installed { stroke: rgb(var(--w) / .42); stroke-width: 1.35px; }
.cbh__wire-glow.is-wire-installed { stroke: rgb(var(--w) / .12); filter: blur(3px); }
.cbh__wire-core.is-wire-absent { stroke: rgb(var(--w) / .16); stroke-width: 1px; }
.cbh__wire-glow.is-wire-absent { stroke: rgb(var(--w) / .035); filter: blur(2px); }

.cbh__wire-pulse {
  fill: none;
  /* Parça, kablosunun rengidir: kablo .72 opaklıkta akarken parça tam opak ve
     haleli olduğu için ışık şeridi değil, akan bir nokta gibi okunur. */
  stroke: rgb(var(--w));
  stroke-width: var(--cbh-pulse-w);
  stroke-linecap: round;
  opacity: 0;
  filter:
    drop-shadow(0 0 2px rgb(var(--w) / .95))
    drop-shadow(0 0 6px rgb(var(--w) / .7));
}
.cbh--settled .cbh__wire-pulse.is-energy-active { opacity: 1; }

/* --- pinler (kart kenarındaki noktalar) -------------------------------- */
.cbh__pin {
  fill: rgb(var(--w));
  filter: drop-shadow(0 0 5px rgb(var(--w) / .85));
  opacity: 0;
}
.cbh__pin.is-wire-installed { fill: rgb(var(--w) / .55); filter: none; }
.cbh__pin.is-wire-absent { fill: rgb(var(--w) / .25); filter: none; }

/* --- provider bloom (yerleşme sonrası periyodik enerji dalgası) -------- */
.cbh__bloom {
  position: absolute;
  z-index: 0;
  width: 190px; height: 190px;
  margin: -95px 0 0 -95px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgb(var(--cbh-wire) / .30) 0%, transparent 68%);
}
.cbh--settled .cbh__bloom {
  animation: cbh-bloom 4200ms ease-in-out 600ms infinite;
}
.cbh[data-energy="off"] .cbh__bloom { animation: none; }
@keyframes cbh-bloom {
  0%, 62%, 100% { opacity: 0;   transform: scale(.75); }
  12%           { opacity: 1;   transform: scale(1); }
  38%           { opacity: .25; transform: scale(1.12); }
}

/* ==========================================================================
   Erişilebilirlik / performans
   ========================================================================== */
.cbh[data-perf="low"] {
  --cbh-blur: 0px;
  --cbh-wire-glow-w: 4px;
}
.cbh[data-perf="low"] .cbh__wire-pulse,
.cbh[data-perf="low"] .cbh__pin { filter: none; }

@media (prefers-reduced-motion: reduce) {
  .cbh__card,
  .cbh__ghost { transition: none !important; }
  .cbh--settled .cbh__bloom,
  .cbh__card--provider.is-sheen .cbh__sheen { animation: none !important; }
  .cbh--settled .cbh__wire-pulse { opacity: 0; }
}
