/* ==========================================================================
   ÇBY Global — Hero 3D sahnesi (CSS 3D)
   Yerleşim ve metin: home.css. Davranış: assets/js/hero.js.

   JS'in güncellediği değişkenler (.hero üzerinde):
     --mx, --my   fare konumu, yumuşatılmış (-1…1) — yalnızca hassas işaretçi + hareket izni
     --lx, --ly   ışık noktası (% — sahne içinde)
     --hover      fare sahnenin üzerindeyken 1
     --explode    katmanların derinlikte ayrılması (kaydırma anlatımı)
     --flat       sahnenin önden görünüme dönmesi (kaydırma anlatımının sonu)
     --sp         hafif kaydırma eğimi (tablet / telefon), 0…1
   JS yoksa veya hareket azaltma açıksa varsayılan değerlerle durağan bir kompozisyon görünür.
   ========================================================================== */

.hero {
  --mx: 0;
  --my: 0;
  --lx: 70%;
  --ly: 30%;
  --hover: 0;
  --explode: 0.35;
  --flat: 0;
  --sp: 0;
}

/* --- Sahne kutusu ------------------------------------------------------- */
.hero__scene {
  position: relative;
  width: 100%;
  height: clamp(400px, 58vh, 560px);
  perspective: 1500px;
  perspective-origin: 50% 42%;
}
.scene {
  --tilt-x: calc(12deg * (1 - var(--flat)) + var(--my) * -6deg + var(--sp) * 10deg);
  --tilt-y: calc(20deg * (1 - var(--flat)) + var(--mx) * 9deg);
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  /* Katmanlar ayrıldıkça sahne hafifçe sola alınır; böylece derinlik artarken ekran dışına taşmaz */
  transform: translateX(calc((var(--explode) - 0.35) * -12%)) rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) scale(calc(var(--scene-scale, 1) * (0.9 + var(--flat) * 0.12 - (var(--explode) - 0.35) * 0.08)));
}

/* --- Işık ve zemin ------------------------------------------------------- */
.scene__light {
  position: absolute;
  inset: -10% -15%;
  border-radius: 50%;
  background:
    radial-gradient(40% 40% at 55% 45%, rgba(183, 154, 255, 0.26), transparent 70%),
    radial-gradient(30% 30% at 30% 75%, rgba(93, 145, 240, 0.18), transparent 70%);
  filter: blur(20px);
  transform: translateZ(-360px);
}
/* Perspektifli ızgara düzlemi: sahnenin altında yatay duran gerçek bir 3D yüzey */
.scene__plane {
  position: absolute;
  left: -45%;
  width: 190%;
  top: 78%;
  height: 160%;
  transform-origin: 50% 0;
  transform: translateZ(-120px) rotateX(82deg);
  pointer-events: none;
}
.scene__plane i {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(183, 154, 255, 0.22) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(183, 154, 255, 0.22) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(50% 45% at 50% 20%, #000 30%, transparent 75%);
  mask-image: radial-gradient(50% 45% at 50% 20%, #000 30%, transparent 75%);
}

/* --- Paneller ------------------------------------------------------------
   Her panelin konumu, derinliği (--z), açısı (--ry/--rz) ve paralaks çarpanı (--d)
   kendi sınıfında tanımlıdır. Önde olan (--d büyük) fareye daha çok tepki verir. */
.pane,
.chip {
  --z: 0px;
  --ry: 0deg;
  --rz: 0deg;
  --d: 1;
  --fade: 1;                       /* sahne önden görünüme dönerken kaybolma oranı */
  position: absolute;
  transform-style: preserve-3d;
  transform:
    translate3d(
      calc(var(--mx) * var(--d) * 16px),
      calc(var(--my) * var(--d) * 11px),
      calc(var(--z) * (1 + var(--explode) * 0.7) * (1 - var(--flat) * 0.92))
    )
    rotateY(calc(var(--ry) * (1 - var(--flat))))
    rotateZ(calc(var(--rz) * (1 - var(--flat))));
  opacity: calc(1 - var(--flat) * var(--fade));
  transition: opacity var(--dur) var(--ease-out);
}
.pane__in {
  position: relative;
  height: 100%;
  border-radius: 14px;
  border: 1px solid rgba(207, 192, 255, 0.24);
  background: rgba(41, 32, 51, 0.86);
  box-shadow:
    calc(var(--mx) * -14px) calc(18px + var(--my) * -10px) 40px -16px rgba(5, 2, 10, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.pane.is-active .pane__in {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px var(--accent-2), 0 0 50px -12px rgba(93, 145, 240, 0.6);
}
.pane__label {
  position: absolute;
  top: 10px; left: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--lilac-300);
}

/* Tasarım sistemi (arka sol) */
.pane--palette { left: 2%; top: 2%; width: 42%; height: 34%; --z: -200px; --ry: -14deg; --d: 0.35; }
.palette { position: absolute; inset: 30px 12px 12px; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; }
.palette__aa { grid-row: span 2; font-family: var(--font-serif); font-style: italic; font-size: 44px; line-height: 1; color: var(--ivory-100); }
.palette__swatches { display: flex; gap: 5px; }
.palette__swatches i { width: 16px; height: 16px; border-radius: 50%; }
.palette__swatches i:nth-child(1) { background: var(--plum-900); box-shadow: inset 0 0 0 1px var(--line-strong); }
.palette__swatches i:nth-child(2) { background: var(--lilac-400); }
.palette__swatches i:nth-child(3) { background: var(--accent-2); }
.palette__swatches i:nth-child(4) { background: var(--ivory-100); }
.palette__swatches i:nth-child(5) { background: var(--carbon-900); box-shadow: inset 0 0 0 1px var(--line-strong); }
.palette__scale { display: flex; gap: 6px; font-size: 9px; color: var(--text-muted); }
.palette__scale b { font-weight: 600; padding: 2px 6px; border-radius: 4px; background: var(--surface-2); }

/* Site haritası (arka sağ) */
.pane--map { left: 60%; top: 0; width: 44%; height: 32%; --z: -150px; --ry: 12deg; --d: 0.45; }
.pane--map .pane__in {
  background:
    linear-gradient(rgba(183, 154, 255, 0.08) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, rgba(183, 154, 255, 0.08) 1px, transparent 1px) 0 0 / 16px 16px,
    rgba(17, 12, 23, 0.9);
}
.sitemap { position: absolute; inset: 28px 10px 8px; width: calc(100% - 20px); height: calc(100% - 36px); }
.sitemap rect { fill: rgba(183, 154, 255, 0.14); stroke: var(--lilac-400); stroke-width: 1.4; }
.sitemap rect.dash { fill: none; stroke-dasharray: 3 3; stroke: rgba(245, 241, 247, 0.4); }
.sitemap path { fill: none; stroke: rgba(183, 154, 255, 0.55); stroke-width: 1.4; }

/* Kod (orta sol) */
.pane--code { left: 0; top: 56%; width: 42%; height: 32%; --z: -40px; --ry: -12deg; --rz: -2deg; --d: 0.8; }
.pane--code .pane__in { background: rgba(23, 17, 31, 0.94); border-color: rgba(93, 145, 240, 0.3); }
.code { position: absolute; inset: 30px 12px 8px; margin: 0; font: 10.5px/1.75 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; color: var(--ivory-100); white-space: pre; overflow: hidden; }
.code b { font-weight: 400; color: var(--lilac-400); }
.code i { font-style: normal; color: var(--accent-2); }
.code u { text-decoration: none; color: var(--state-success); }

/* Arama sonucu (orta sağ, öne yakın) */
.pane--serp { left: 66%; top: 66%; width: 42%; height: auto; --z: 60px; --ry: 10deg; --rz: 2deg; --d: 1.15; }
.pane--serp .pane__in { padding: 12px 14px; background: #fff; border-color: rgba(255, 255, 255, 0.7); display: grid; gap: 3px; }
.serp2__url { font-size: 9.5px; color: var(--light-muted); }
.serp2__title { font-size: 12px; font-weight: 700; color: var(--color-accent-deep); line-height: 1.25; }
.serp2__desc { font-size: 10px; color: var(--light-text); line-height: 1.35; }

/* --- Ana tarayıcı (ön) ---------------------------------------------------- */
.pane--browser { left: 20%; top: 20%; width: 66%; height: 58%; --z: 110px; --ry: 0deg; --d: 1.45; --fade: 0; }
.pane--browser .pane__in {
  display: flex;
  flex-direction: column;
  background: var(--ivory-100);
  border-color: rgba(255, 255, 255, 0.6);
  color: var(--carbon-900);
  container-type: inline-size;
  box-shadow:
    calc(var(--mx) * -22px) calc(30px + var(--my) * -14px) 70px -20px rgba(5, 2, 10, 0.85),
    0 0 0 1px rgba(255, 255, 255, 0.35);
}
.bw__bar { display: flex; align-items: center; gap: 2.4cqw; padding: 2cqw 3cqw; background: var(--color-light-2); border-bottom: 1px solid rgba(23, 17, 31, 0.08); }
.bw__dots { display: flex; gap: 1.2cqw; }
.bw__dots i { width: 1.9cqw; height: 1.9cqw; border-radius: 50%; background: rgba(23, 17, 31, 0.18); }
.bw__dots i:first-child { background: var(--accent-2); }
.bw__url { display: inline-flex; align-items: center; gap: 1cqw; flex: 1; max-width: 46cqw; padding: 0.7cqw 2.4cqw; border-radius: 99px; background: rgba(255, 255, 255, 0.85); font-size: 2.4cqw; color: var(--light-muted); }
.bw__lock { width: 1.6cqw; height: 1.8cqw; border: 1.5px solid var(--color-text-faint); border-radius: 2px 2px 3px 3px; }
.bw__tabs { display: flex; gap: 1.2cqw; padding: 1.6cqw 3cqw 0; background: var(--color-light-2); }
.bw__tabs span { padding: 0.9cqw 2.2cqw; border-radius: 1.4cqw 1.4cqw 0 0; font-size: 2.1cqw; font-weight: 700; color: var(--color-text-faint); transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out); }
[data-view="strateji"] [data-tab="strateji"],
[data-view="arayuz"] [data-tab="arayuz"],
[data-view="kod"] [data-tab="kod"],
[data-view="gorunurluk"] [data-tab="gorunurluk"] { background: var(--ivory-100); color: var(--plum-900); }

.bw__page { position: relative; flex: 1; display: flex; flex-direction: column; gap: 2.6cqw; padding: 3cqw; overflow: hidden; }
.bw__nav { display: flex; align-items: center; justify-content: space-between; }
.bw__brand { display: inline-flex; align-items: center; gap: 1.4cqw; font-size: 2.4cqw; font-weight: 800; font-family: var(--font-display); }
.bw__brand img { width: auto; height: 4.2cqw; border-radius: 3px; }
.bw__links { display: flex; gap: 2.6cqw; font-size: 2.1cqw; color: var(--light-muted); }
.bw__links i { font-style: normal; }
.bw__hero {
  position: relative;
  display: grid;
  gap: 1.2cqw;
  padding: 4cqw;
  border-radius: 2.4cqw;
  color: var(--ivory-100);
  background:
    radial-gradient(80% 90% at 100% 0%, rgba(183, 154, 255, 0.6), transparent 60%),
    var(--plum-900);
  transition: background var(--dur-slow) var(--ease-out);
}
.bw__kicker { font-size: 1.9cqw; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-2); font-weight: 700; }
.bw__title { font-family: var(--font-display); font-weight: 700; font-size: 5.2cqw; line-height: 1.05; letter-spacing: -0.02em; }
.bw__title em { font-family: var(--font-serif); font-weight: 400; color: var(--lilac-300); }
.bw__text { font-size: 2.3cqw; color: rgba(245, 241, 247, 0.75); }
.bw__btns { display: flex; gap: 1.6cqw; margin-top: 0.8cqw; }
.bw__btn { font-style: normal; padding: 1.1cqw 2.8cqw; border-radius: 99px; background: var(--lilac-400); color: var(--plum-900); font-size: 2.1cqw; font-weight: 800; }
.bw__btn--ghost { background: transparent; color: var(--ivory-100); box-shadow: inset 0 0 0 1px rgba(245, 241, 247, 0.4); }
.bw__cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2cqw; }
.bw__cards span { display: grid; gap: 1.2cqw; padding: 2cqw; border-radius: 1.8cqw; background: #fff; box-shadow: 0 1px 0 rgba(23, 17, 31, 0.06); }
.bw__cards b { font-size: 2.1cqw; font-weight: 800; }
.bw__cards i { height: 1.2cqw; width: 70%; border-radius: 1cqw; background: rgba(23, 17, 31, 0.12); }
.bw__shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(40% 50% at var(--lx) var(--ly), rgba(255, 255, 255, 0.55), transparent 70%);
  mix-blend-mode: soft-light;
  opacity: calc(0.25 + var(--hover) * 0.55);
  transition: opacity var(--dur) var(--ease-out);
}

/* Bölüme özel görünümler: Strateji = tel kafes, Kod = kod katmanı, Görünürlük = arama katmanı */
.bw__page > * { transition: opacity var(--dur) var(--ease-out), filter var(--dur) var(--ease-out); }
[data-view="strateji"] .bw__hero,
[data-view="strateji"] .bw__cards span { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(91, 63, 196, 0.55); color: transparent; }
[data-view="strateji"] .bw__hero > *,
[data-view="strateji"] .bw__cards b { color: transparent; background: rgba(91, 63, 196, 0.16); border-radius: 4px; box-shadow: none; }
[data-view="strateji"] .bw__title em { color: transparent; }
.bw__overlay {
  position: absolute;
  left: 6cqw; right: 6cqw; bottom: 4cqw;
  display: grid;
  gap: 1cqw;
  padding: 2.6cqw 3cqw;
  border-radius: 2cqw;
  opacity: 0;
  transform: translate3d(0, 4cqw, 0);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.bw__overlay--kod { background: rgba(23, 17, 31, 0.95); }
.bw__overlay--kod code { font: 2.2cqw/1.5 ui-monospace, Menlo, monospace; color: var(--lilac-300); }
.bw__overlay--kod code:nth-child(2) { color: var(--accent-2); }
.bw__overlay--gorunurluk { background: #fff; box-shadow: 0 10px 30px -12px rgba(23, 17, 31, 0.45); }
.bw__overlay--gorunurluk b { font-size: 2.3cqw; color: var(--color-accent-deep); }
.bw__overlay--gorunurluk span { font-size: 2cqw; color: var(--light-muted); }
.bw__overlay--gorunurluk i { height: 1.2cqw; width: 80%; border-radius: 1cqw; background: rgba(23, 17, 31, 0.14); }
[data-view="kod"] .bw__overlay--kod,
[data-view="gorunurluk"] .bw__overlay--gorunurluk { opacity: 1; transform: none; }
[data-view="kod"] .bw__cards,
[data-view="gorunurluk"] .bw__cards { opacity: 0.25; }

/* --- Rozetler -------------------------------------------------------------- */
.chip .pane__in {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: auto;
  padding: 7px 12px;
  border-radius: 99px;
  background: rgba(23, 17, 31, 0.92);
  border-color: var(--line-strong);
  font-size: 11px;
  font-weight: 700;
  color: var(--ivory-100);
  white-space: nowrap;
}
.chip .pane__in::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--state-success); }
.chip--a { left: 60%; top: 8%; --z: 170px; --d: 1.3; --fade: 1; }
.chip--b { left: 26%; top: 6%; --z: 150px; --d: 1.2; --fade: 1; }
.chip--b .pane__in::before { background: var(--lilac-400); }
.chip--c { left: 36%; top: 88%; --z: 170px; --d: 1.4; --fade: 1; }
.chip--c .pane__in::before { background: var(--accent-2); }

/* --- Giriş ve süzülme ------------------------------------------------------
   Konum dönüşümü dış öğede (.pane), giriş ve süzülme iç öğede (.pane__in) olduğu için
   fare / kaydırma dönüşümleriyle çakışmaz. */
@media (prefers-reduced-motion: no-preference) {
  .pane__in { animation: paneIn 1.1s var(--ease-out) backwards, paneFloat 7s var(--ease-in-out) 1.4s infinite alternate; }
  .pane--palette .pane__in { animation-delay: 0.15s, 1.6s; }
  .pane--map .pane__in     { animation-delay: 0.25s, 2.4s; }
  .pane--code .pane__in    { animation-delay: 0.35s, 1.9s; }
  .pane--serp .pane__in    { animation-delay: 0.5s, 2.8s; }
  .pane--browser .pane__in { animation-delay: 0.05s, 1.4s; animation-duration: 1.2s, 8s; }
  .chip--a .pane__in { animation-delay: 0.7s, 2s; }
  .chip--b .pane__in { animation-delay: 0.8s, 3s; }
  .chip--c .pane__in { animation-delay: 0.9s, 2.5s; }
  .scene__light { animation: lightPulse 9s var(--ease-in-out) infinite alternate; }
  /* Ekran dışındayken veya sekme arka plandayken yalnızca SÜREKLİ animasyonlar durur;
     giriş animasyonu (ilk değer) her zaman tamamlanır, aksi hâlde paneller görünmez kalırdı. */
  .hero.is-paused .pane__in { animation-play-state: running, paused; }
  .hero.is-paused .scene__light { animation-play-state: paused; }
}
@keyframes paneIn { from { opacity: 0; transform: translate3d(0, 40px, 0) scale(0.92); } }
@keyframes paneFloat { from { translate: 0 0; } to { translate: 0 -7px; } }
@keyframes lightPulse { to { opacity: 0.7; scale: 1.06; } }

/* 3D desteklenmeyen ortamda: paneller düz, üst üste kaydırılmış biçimde */
@supports not (transform-style: preserve-3d) {
  .scene, .pane, .chip, .scene__plane { transform: none !important; }
  .scene__plane, .chip { display: none; }
}

/* --- Kaydırma anlatımı (masaüstü) ---------------------------------------- */
.hero.is-scrolly .hero__scene { height: min(62vh, 580px); }

/* --- Küçük masaüstü / dizüstü: sahne biraz küçülür, öndeki rozetler ekran içinde kalır */
@media (max-width: 1279px) {
  .scene { --scene-scale: 0.84; }
  .hero__scene { perspective: 1800px; }
}
@media (min-width: 1024px) and (max-width: 1120px) {
  .scene { --scene-scale: 0.78; }
}

/* --- Tablet ---------------------------------------------------------------- */
@media (max-width: 1023px) {
  .hero__scene { height: clamp(360px, 62vw, 480px); max-width: 620px; margin-inline: auto; }
  .scene { --tilt-y: calc(14deg + var(--mx) * 7deg); }
  .chip--c { display: none; }
}

/* --- Telefon ----------------------------------------------------------------
   Daha az katman, daha düşük perspektif açısı; sahne kendi kutusunda kırpılır,
   böylece başlık ve CTA'larla asla çakışmaz. Fare efekti yoktur. */
@media (max-width: 767px) {
  .hero__scene {
    height: auto;
    aspect-ratio: 1 / 0.92;
    max-height: 440px;
    overflow: hidden;
    perspective: 1100px;
    border-radius: var(--radius-lg);
  }
  .scene { --tilt-x: calc(8deg + var(--sp) * 8deg); --tilt-y: 10deg; transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y)) scale(0.9); }
  .pane--palette, .chip--b, .chip--c { display: none; }
  .pane--map { left: 50%; top: 2%; width: 48%; height: 28%; }
  .pane--browser { left: 6%; top: 14%; width: 88%; height: 60%; --z: 70px; }
  .pane--code { left: -2%; top: 62%; width: 52%; height: 30%; --z: 10px; }
  .pane--serp { left: 52%; top: 70%; width: 46%; --z: 120px; }
  .chip--a { left: 58%; top: 6%; --z: 140px; }
  .code { font-size: 9px; }
  .pane__label { font-size: 9px; }
}
@media (max-width: 380px) {
  .pane--serp { display: none; }
}

/* Telefonda sürekli süzülme ve ışık animasyonu kapalı: yalnızca giriş animasyonu çalışır
   (pil ve işlemci yükünü azaltır; sahne durağan ama 3D yerleşim korunur) */
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  .pane__in { animation-name: paneIn, none; }
  .scene__light { animation: none; }
}
