/* ============================================================
   Süreç animasyonu — bölüm yerleşimi, CAD penceresi, sahne arayüzü
   Sitenin mevcut tokenları (renk, font, boşluk) kullanılır.
   ============================================================ */

/* ---------- Sabit canvas (§3.1) ---------- */
.process-canvas {
  position: fixed; left: 0; top: 0;
  width: 100%; height: 100lvh;
  z-index: 5;               /* bölüm arka planlarının üstünde, site menüsünün altında */
  pointer-events: none;     /* tıklamalar sayfaya geçer */
  opacity: 0; transition: opacity 0.6s var(--ease-out);
}
html.process-ready .process-canvas { opacity: 1; }
html.no-webgl .process-canvas { display: none; }

/* ---------- Bölüm (§3.2) ---------- */
.process-section {
  position: relative;
  /* Mobil tarayıcı çubuğu küçülünce altta boş şerit kalmasın: arka plan en büyük görünüm yüksekliği */
  height: 100lvh;
  overflow: hidden;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-divider);
}
.process-section::before { /* teknik çizim ızgarası */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 55%, #000 20%, transparent 80%);
}
.process-section::after { /* arka plandaki büyük bölüm numarası */
  content: attr(data-num);
  position: absolute; right: 3vw; bottom: -0.12em;
  font-family: var(--font-display); font-weight: 600; font-size: clamp(8rem, 22vw, 20rem); line-height: 1;
  color: transparent; -webkit-text-stroke: 1px var(--color-border); opacity: 0.6;
  pointer-events: none; user-select: none;
}
.process-section--left::after { right: auto; left: 3vw; }

.process-section__inner {
  position: relative; z-index: 1;
  /* İçerik, çubuklar açıkken bile görünen en küçük yükseklikte durur */
  height: 100svh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: clamp(2rem, 4vw, 4rem);
  padding-top: var(--header-h);
  padding-bottom: 1.5rem;
}
.process-section--left .process-section__text { order: 2; }

.process-section__text { max-width: 34rem; }
.process-section__text h2 { font-size: var(--text-2xl); line-height: 1.02; margin-bottom: var(--space-5); }
.process-section__text h2 em { font-style: normal; color: var(--color-accent); }
.process-section__text > p, .process-copy > p { color: var(--color-text-muted); font-size: var(--text-lg); max-width: 42ch; }

/* Boş yer tutucu: 3D buraya hizalanır. 4:3, sütunu doldurur ama ekrana sığar */
.process-section__stage {
  justify-self: center;
  width: min(100%, calc((100svh - var(--header-h) - 3rem) * 4 / 3));
  aspect-ratio: 4 / 3;
}

/* ---------- Sahne etiketi (StepBadge) ---------- */
.step-badge {
  display: inline-flex; align-items: center; gap: 0.6rem;
  margin-top: var(--space-6);
  padding: 0.55rem 0.95rem 0.55rem 0.75rem;
  border: 1px solid color-mix(in oklab, var(--color-accent) 45%, var(--color-border));
  border-radius: 999px;
  background: color-mix(in oklab, var(--color-bg) 70%, transparent);
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.06em; color: var(--color-text);
  opacity: 0; min-height: 2.2rem;
}
.step-badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 4px var(--color-accent-soft); flex: none; }

.process-readout { margin-top: var(--space-4); font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-text); min-height: 1.4em; }

/* ---------- Sapma lejantı ---------- */
.legend { margin-top: var(--space-5); max-width: 22rem; opacity: 0; }
.legend__bar { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #2f6bff, #22c3e6 25%, #2ecc71 50%, #f5d90a 75%, #ff3b30); }
.legend__scale { display: flex; justify-content: space-between; margin-top: 0.4rem; font-family: var(--font-mono); font-size: 0.7rem; color: var(--color-text-faint); }

/* ---------- Ölçü etiketleri (3D'ye bağlı HTML) ---------- */
.process-labels { position: fixed; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.dim-label {
  position: absolute; left: 0; top: 0;
  padding: 0.2rem 0.5rem; border-radius: 4px;
  background: rgba(22, 25, 29, 0.85); border: 1px solid #ff8a3d;
  color: #ffb27a; font-family: var(--font-mono); font-size: 0.72rem; white-space: nowrap;
  opacity: 0; will-change: transform, opacity;
}

/* ---------- CAD penceresi (hero, §6.3) ---------- */
.process-section--hero .process-section__inner { grid-template-columns: 0.95fr 1.05fr; }
.process-section--hero .kicker { white-space: nowrap; letter-spacing: 0.14em; }
.process-section--hero h1 { font-size: clamp(2.2rem, 4.4vw, 4.2rem); line-height: 1; margin-bottom: var(--space-5); }
.process-section--hero h1 em { font-style: normal; color: var(--color-accent); }
.hero-step { display: block; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-accent); margin: var(--space-2) 0 var(--space-2); }
.hero-step b { color: var(--color-text); font-weight: 500; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }

.cad {
  justify-self: stretch;
  width: min(100%, calc((100svh - var(--header-h) - 3rem) * 16 / 10));
  aspect-ratio: 16 / 10;
  display: grid; grid-template-rows: 30px 1fr 24px;
  border: 1px solid #2a2f35; border-radius: 12px; overflow: hidden;
  background: #0f1215; color: #c7ccd2;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.6);
  font-family: var(--font-body); font-size: 0.72rem;
}
.cad__bar { display: flex; align-items: center; gap: 1rem; padding: 0 0.75rem; background: #181c21; border-bottom: 1px solid #262b31; }
.cad__dots { display: flex; gap: 6px; }
.cad__dots i { width: 9px; height: 9px; border-radius: 50%; background: #3a4048; }
.cad__dots i:first-child { background: #ff5f57; } .cad__dots i:nth-child(2) { background: #febc2e; } .cad__dots i:nth-child(3) { background: #28c840; }
.cad__menu { display: flex; gap: 1rem; color: #9aa1a9; }
.cad__title { margin-left: auto; font-family: var(--font-mono); color: #6f7680; font-size: 0.68rem; }
.cad__body { display: grid; grid-template-columns: minmax(120px, 22%) 1fr; min-height: 0; }
.cad__tree { background: #13171b; border-right: 1px solid #262b31; padding: 0.6rem 0; overflow: hidden; }
.cad__tree h5 { font-family: var(--font-mono); font-weight: 500; font-size: 0.64rem; letter-spacing: 0.12em; text-transform: uppercase; color: #6f7680; padding: 0 0.75rem 0.5rem; }
.cad__tree ul { list-style: none; }
.cad__tree li { display: flex; align-items: center; gap: 0.5rem; padding: 0.32rem 0.75rem; color: #7d848d; border-left: 2px solid transparent; transition: color 0.25s, background 0.25s, border-color 0.25s; }
.cad__tree li::before { content: ''; width: 10px; height: 10px; border: 1px solid currentColor; border-radius: 2px; opacity: 0.7; }
.cad__tree li.is-done { color: #b9bfc6; }
.cad__tree li.is-active { color: #ff8a3d; background: rgba(255, 138, 61, 0.08); border-left-color: #ff8a3d; }
.cad__view {
  position: relative; min-height: 0;
  background-color: #16191d;
  background-image: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}
/* KARAR (§7.3): yükleme sırasında görünüm alanında p = 0 durumu olan açılış logosu durur;
   statik tasarim.webp yalnızca WebGL yoksa (yedek görünüm) gösterilir. */
.cad__view::before { content: ''; position: absolute; inset: 0; background: url('../assets/process/tasarim.webp') center / contain no-repeat; opacity: 0; }
.cad__intro {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 0.9rem; pointer-events: none;
}
.cad__intro img { width: clamp(84px, 30%, 168px); height: auto; filter: drop-shadow(0 0 28px rgba(255, 140, 0, 0.28)); }
.cad__intro span { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: #6f7680; white-space: nowrap; }
.cad__intro span::after { content: ''; display: block; width: 1px; height: 18px; margin: 0.5rem auto 0; background: linear-gradient(#ff8a3d, transparent); }
html.no-webgl .cad__intro { display: none; }
.cad__axes { position: absolute; left: 0.75rem; bottom: 0.6rem; width: 44px; height: 44px; }
.cad__props { position: absolute; right: 0.6rem; bottom: 0.6rem; padding: 0.45rem 0.6rem; border: 1px solid #2a2f35; border-radius: 6px; background: rgba(15, 18, 21, 0.85); font-family: var(--font-mono); font-size: 0.64rem; line-height: 1.55; color: #9aa1a9; }
.cad__props b { color: #e3e6ea; font-weight: 500; }
.cad__status { display: flex; align-items: center; gap: 1rem; padding: 0 0.75rem; background: #181c21; border-top: 1px solid #262b31; font-family: var(--font-mono); font-size: 0.64rem; color: #6f7680; }
.cad__status-sim { margin-left: auto; color: #2ecc71; opacity: 0; }

/* ---------- Montaj: tam genişlik sahne + kapanış kartı ---------- */
/* KARAR: şasi (1600 × 1000 mm) metnin üstüne binmesin diye montajda metin üstte, sahne altta kalan alanda */
.process-section--center .process-section__inner { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); align-items: stretch; gap: 0.5rem; }
.process-section--center .process-section__text { position: relative; max-width: 44rem; padding-top: 1.25rem; }
.process-section--center .process-section__text h2 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
.process-section--center .process-section__text .process-copy > p { font-size: var(--text-base); }
.process-section--center .step-badge { margin-top: var(--space-3); }
.process-section--center .process-section__stage { height: 100%; width: auto; max-width: 100%; aspect-ratio: 4 / 3; align-self: center; }
.closing-card {
  position: absolute; left: 0; top: 0; width: min(30rem, 88vw);
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border-radius: var(--radius-xl); border: 1px solid var(--color-border);
  background: color-mix(in oklab, var(--color-surface) 92%, transparent); backdrop-filter: blur(10px);
  opacity: 0; visibility: hidden;
}
.closing-card img { width: 52px; height: 52px; border-radius: 12px; margin-bottom: var(--space-4); }
.closing-card h3 { font-size: var(--text-2xl); line-height: 1; margin-bottom: var(--space-3); }
.closing-card h3 em { font-style: normal; color: var(--color-accent); }
.closing-card p { color: var(--color-text-muted); margin-bottom: var(--space-5); }
.closing-card .btn { pointer-events: auto; }

/* ---------- Debug paneli (?debug=1) ---------- */
.process-debug { position: fixed; left: 8px; top: 8px; z-index: 999; padding: 8px 10px; border-radius: 6px; background: rgba(0,0,0,0.82); color: #9fe870; font: 11px/1.45 var(--font-mono); white-space: pre; pointer-events: none; }

/* ---------- WebGL yoksa statik görseller (§7.2) ---------- */
html.no-webgl [data-stage] { background: center / contain no-repeat; }
html.no-webgl [data-stage="tasarim"]::before { opacity: 1; }
html.no-webgl [data-stage="kalip"] { background-image: url('../assets/process/kalip.webp'); }
html.no-webgl [data-stage="pres"] { background-image: url('../assets/process/pres.webp'); }
html.no-webgl [data-stage="olcum"] { background-image: url('../assets/process/olcum.webp'); }
html.no-webgl [data-stage="kaynak"] { background-image: url('../assets/process/kaynak.webp'); }
html.no-webgl [data-stage="montaj"] { background-image: url('../assets/process/montaj.webp'); }
html.no-webgl .step-badge, html.no-webgl .legend { opacity: 1; }

/* ============================================================
   Responsive (§7.1)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  .process-section__inner { grid-template-columns: 45fr 55fr; }
  .process-section--left .process-section__inner { grid-template-columns: 55fr 45fr; }
  .process-section--hero .process-section__inner { grid-template-columns: 45fr 55fr; }
  .process-section--center .process-section__inner { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .process-section__inner,
  .process-section--hero .process-section__inner {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;   /* metin doğal yüksekliğinde, sahne kalan alanı doldurur */
    align-items: stretch;
    gap: 0.75rem;
    padding-top: calc(var(--header-h) + 0.25rem);
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  .process-section__text, .process-section--left .process-section__text { order: 2; max-width: none; }
  .process-section__stage, .process-section--center .process-section__stage { order: 1; width: 100%; height: 100%; aspect-ratio: auto; }
  .process-section__text h2 { font-size: clamp(1.5rem, 6.6vw, 2rem); margin-bottom: var(--space-2); }
  .process-section__text .kicker { margin-bottom: var(--space-2); }
  .process-section__text > p, .process-copy > p { font-size: var(--text-sm); }
  .step-badge { margin-top: var(--space-3); }
  .process-section::after { font-size: 9rem; }
  /* Hero: CAD penceresi sadeleşir, özellik ağacı gizlenir */
  .process-section--hero h1 { font-size: clamp(1.6rem, 7.2vw, 2.1rem); margin-bottom: var(--space-2); }
  .hero-step { font-size: 0.72rem; margin: 0; }
  .hero-actions .btn { min-height: 44px; padding: 0.6rem 1.2rem; }
  .process-section--hero .hero-copy-p { display: none; }
  .hero-actions { margin-top: var(--space-3); }
  .cad { order: 1; width: 100%; height: 100%; aspect-ratio: auto; grid-template-rows: 26px 1fr 22px; }
  .cad__body { grid-template-columns: 1fr; }
  .cad__tree, .cad__menu, .cad__props { display: none; }
  .cad__status { white-space: nowrap; overflow: hidden; gap: 0.6rem; }
  .cad__status > span:nth-child(2) { display: none; }
  .process-section--center .process-section__inner { grid-template-rows: minmax(0, 1fr) auto; }
  .process-section--center .process-section__text { position: relative; padding-top: 0; }
  .process-section--center .process-section__stage { width: 100%; height: 100%; aspect-ratio: auto; }
  .closing-card { top: auto; bottom: 0; }
  .legend { margin-top: var(--space-3); }
  .process-readout { margin-top: var(--space-2); font-size: var(--text-xs); }
}

@media (prefers-reduced-motion: reduce) {
  .process-section { height: auto; min-height: 100svh; }
}
