/*
 * Web editörü (editor.js): proje listesi + düzenleme ekranı. Masaüstünde üç sütun (medya · önizleme · ayarlar) ve altta
 * zaman çizelgesi (≥1100 px); daha darda önizleme + araç çubuğu + zaman çizelgesi, medya ve ayarlar sayfacıkta. Zaman çizelgesi
 * her dilde soldan sağa akar. Renk / boşluk tokens.css ve app.css'ten; editöre özel ölçüler aşağıdaki :root'ta.
 */
:root {
  --ed-bin-w: 300px;
  --ed-insp-w: 300px;
  --ed-top-h: 60px;
  --ed-tl-h: clamp(220px, 34vh, 300px);
  --ed-tl-h-sm: clamp(190px, 30vh, 240px);
  --ed-ruler-h: 26px;
  --ed-lane-gap: 6px;
  --ed-lane-text: 30px;
  --ed-lane-video: 60px;
  --ed-lane-audio: 40px;
  --ed-handle-w: 10px;
  --ed-playhead-w: 2px;
  --ed-play: 44px;
  --ed-swatch: 30px;
  --ed-card-min: 200px;
  --ed-bin-cell: 92px;
  --ed-after: rgb(10 10 10 / 0.6);
  --ed-drop: rgb(237 237 237 / 0.06);
}

/* ---------- Proje listesi ---------- */
.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--ed-card-min), 1fr)); gap: var(--sp-5) var(--sp-4); }
.ed-card { position: relative; }
.ed-card-link { display: flex; flex-direction: column; gap: var(--sp-2-5); text-decoration: none; border-radius: var(--r-md); }
.ed-card-cover { aspect-ratio: 16 / 10; border-radius: var(--r-md); border: var(--bw) solid var(--c-line); }
.ed-card-link:hover .ed-card-cover { border-color: var(--c-line-3); }
.ed-card-text { display: flex; flex-direction: column; gap: var(--sp-0-5); min-width: 0; padding: 0 var(--sp-1); }
.ed-card-title { font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-card-meta { font-size: var(--fs-xs); color: var(--c-text-3); }
.ed-card:hover .lib-more, .ed-card:focus-within .lib-more { opacity: 1; }
.ed-sk-cover { aspect-ratio: 16 / 10; border-radius: var(--r-md); }
.ed-usage { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-8); max-width: var(--app-sheet-w); }
.ed-usage.is-compact { margin-top: var(--sp-4); }
.ed-usage-text { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-3); }
.ed-usage-text .icon { width: var(--icon-sm); height: var(--icon-sm); }
.ed-boot { min-height: 60vh; display: grid; place-items: center; }

/* ---------- Düzenleme ekranı ---------- */
html.ed-open, html.ed-open body { overflow: hidden; }
/* Editör tam ekran: masaüstünde de yan menü gizlenir (geri düğmesi proje listesine döner). */
@media (min-width: 900px) { html.ed-open .shell { display: block; } html.ed-open .side { display: none; } }
.ed {
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto var(--ed-tl-h-sm); height: 100dvh; min-height: 0;
  background: var(--c-bg); position: relative;
}
.ed-top { grid-row: 1; } .ed-banner { grid-row: 2; } .ed-main { grid-row: 3; } .ed-toolbar { grid-row: 4; } .ed-tl { grid-row: 5; }
.ed.is-dropping::after { content: ""; position: absolute; inset: var(--sp-2); border: var(--bw-2) dashed var(--c-line-4); border-radius: var(--r-lg); background: var(--ed-drop); pointer-events: none; z-index: 20; }

.ed-top { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--ed-top-h); padding: 0 var(--sp-3); padding-top: env(safe-area-inset-top); border-bottom: var(--bw) solid var(--c-line); }
.ed-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ed-title-input { width: 100%; min-width: 0; background: transparent; border: var(--bw) solid transparent; border-radius: var(--r-xs); padding: var(--sp-0-5) var(--sp-1-5); font-size: var(--fs-body); font-weight: var(--fw-semibold); text-overflow: ellipsis; }
.ed-title-input:hover { border-color: var(--c-line-2); }
.ed-title-input:focus { outline: none; border-color: var(--c-line-4); background: var(--c-s1); }
.ed-save { padding: 0 var(--sp-1-5); font-size: var(--fs-2xs); color: var(--c-text-3); white-space: nowrap; }
.ed-save.is-error, .ed-save.is-conflict { color: var(--c-error); }
.ed-top-actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.ed-top-actions .icon-btn:disabled { opacity: 0.4; }
.ed-banner:empty { display: none; }
.ed-conflict { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-bottom: var(--bw) solid var(--c-line); }
.ed-conflict .error-banner { flex: 1 1 280px; }
.ed-conflict-actions { display: flex; gap: var(--sp-2); }

.ed-main { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }
.ed-bin, .ed-inspector { display: none; }
.ed-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--c-ink); }
.ed-stage { position: relative; flex: 1 1 auto; min-height: 0; display: grid; place-items: center; padding: var(--sp-3); overflow: hidden; }
.ed-stage-box { position: relative; border-radius: var(--r-xs); overflow: hidden; background: var(--c-ink); outline: var(--bw) solid var(--c-line); }
.ed-canvas { display: block; width: 100%; height: 100%; }
.ed-stage-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--sp-4); overflow: auto; }
.ed-stage-empty .empty-card { max-width: var(--app-sheet-w); }
.ed-transport { display: flex; align-items: center; justify-content: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-top: var(--bw) solid var(--c-line); background: var(--c-bg); }
.ed-play { display: grid; place-items: center; width: var(--ed-play); height: var(--ed-play); border-radius: 50%; background: var(--c-light); color: var(--c-on-light); }
.ed-play .icon { width: var(--icon-lg); height: var(--icon-lg); }
.ed-play:hover { background: var(--c-light-hover); }
.ed-time { min-width: 9.5em; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--c-text-2); text-align: center; }

/* Araç çubuğu */
.ed-toolbar { display: flex; align-items: center; gap: var(--sp-1); padding: var(--sp-1-5) var(--sp-2); border-top: var(--bw) solid var(--c-line); border-bottom: var(--bw) solid var(--c-line); overflow-x: auto; scrollbar-width: none; }
.ed-toolbar::-webkit-scrollbar { display: none; }
.ed-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-0-5); min-width: var(--sp-14); min-height: var(--tap-lg); padding: var(--sp-1) var(--sp-2); border-radius: var(--r-sm); color: var(--c-text-2); flex: none; }
.ed-tool .icon { width: var(--icon); height: var(--icon); }
.ed-tool:hover:not(:disabled) { background: var(--c-s2); color: var(--c-text); }
.ed-tool:disabled { opacity: 0.35; }
.ed-tool.is-primary { color: var(--c-text); }
.ed-tool.is-primary .icon { background: var(--c-light); color: var(--c-on-light); border-radius: 50%; padding: var(--sp-0-5); }
.ed-tool-label { font-size: var(--fs-2xs); font-weight: var(--fw-medium); white-space: nowrap; }
.ed-zoom { display: flex; gap: var(--sp-1-5); flex: none; padding-inline-start: var(--sp-2); }

/* ---------- Zaman çizelgesi ---------- */
.ed-tl { position: relative; overflow: auto; background: var(--c-bg); user-select: none; -webkit-user-select: none; overscroll-behavior: contain; }
.ed-tl:focus-visible { outline: var(--bw-2) solid var(--c-line-4); outline-offset: calc(-1 * var(--bw-2)); }
.ed-tl-inner { position: relative; min-height: 100%; padding-bottom: var(--sp-3); }
.ed-ruler { position: sticky; top: 0; z-index: 4; height: var(--ed-ruler-h); background: var(--c-bg); border-bottom: var(--bw) solid var(--c-line); cursor: pointer; touch-action: none; }
.ed-tick { position: absolute; bottom: 0; left: 0; width: var(--bw); height: var(--sp-1-5); background: var(--c-line-3); }
.ed-tick.is-major { height: var(--sp-2-5); background: var(--c-line-4); }
.ed-tick-label { position: absolute; bottom: var(--sp-2-5); left: var(--sp-1); font-family: var(--font-mono); font-size: var(--fs-3xs); color: var(--c-text-3); white-space: nowrap; }
.ed-lane { position: relative; margin-top: var(--ed-lane-gap); touch-action: none; }
.ed-lane-text { height: var(--ed-lane-text); }
.ed-lane-video { height: var(--ed-lane-video); }
.ed-lane-audio { height: var(--ed-lane-audio); }
.ed-lane-add, .ed-lane-hint {
  position: absolute; top: 0; bottom: 0; left: var(--sp-4); display: inline-flex; align-items: center; gap: var(--sp-1-5);
  padding: 0 var(--sp-3); font-size: var(--fs-xs); color: var(--c-text-3); white-space: nowrap;
}
.ed-lane-add { border: var(--bw) dashed var(--c-line-3); border-radius: var(--r-xs); }
.ed-lane-add:hover { color: var(--c-text); border-color: var(--c-line-4); background: var(--c-s1); }
.ed-lane-add .icon, .ed-lane-hint .icon { width: var(--icon-sm); height: var(--icon-sm); }
.ed-lane-hint { pointer-events: none; border: var(--bw) dashed var(--c-line); border-radius: var(--r-xs); }

.ed-item {
  position: absolute; top: 0; bottom: 0; left: 0; display: flex; align-items: flex-end; gap: var(--sp-1); overflow: hidden;
  border-radius: var(--r-xs); background: var(--c-s4); border: var(--bw) solid var(--c-line-3); cursor: grab; touch-action: none;
}
.ed-item:active { cursor: grabbing; }
.ed-item-audio { background: var(--c-s3); color: var(--c-text-3); align-items: center; }
.ed-item-text { background: var(--c-s5); align-items: center; }
.ed-item.is-selected { border-color: var(--c-text); box-shadow: inset 0 0 0 var(--bw) var(--c-text); z-index: 2; }
.ed-item.is-missing { background: var(--c-error-surface); border-color: var(--c-error-border); }
.ed-film { position: absolute; inset: 0; background-repeat: repeat-x; background-size: auto 100%; background-position: left center; opacity: 0.9; }
.ed-wave { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--c-text-3); }
.ed-item.is-selected .ed-wave { color: var(--c-text-2); }
.ed-item-label {
  position: relative; max-width: calc(100% - 2 * var(--sp-1)); margin: var(--sp-1); padding: 0 var(--sp-1-5); border-radius: var(--r-2xs);
  background: var(--c-media-scrim); color: var(--c-on-media); font-size: var(--fs-2xs); font-weight: var(--fw-medium); line-height: 1.6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ed-item-text .ed-item-label { background: none; color: var(--c-text); }
.ed-item-badges { position: absolute; top: var(--sp-1); right: var(--sp-1); display: flex; gap: var(--sp-1); }
.ed-item-badge { display: inline-flex; align-items: center; height: var(--ctl-3xs); padding: 0 var(--sp-1); border-radius: var(--r-2xs); background: var(--c-media-scrim); color: var(--c-on-media); font-family: var(--font-mono); font-size: var(--fs-3xs); }
.ed-item-badge .icon { width: var(--icon-2xs); height: var(--icon-2xs); }
.ed-handle { position: absolute; top: 0; bottom: 0; width: var(--ed-handle-w); cursor: ew-resize; z-index: 1; }
.ed-handle.is-start { left: 0; }
.ed-handle.is-end { right: 0; }
.ed-item.is-selected .ed-handle { background: var(--c-text); }
.ed-item.is-selected .ed-handle::after { content: ""; position: absolute; top: 35%; bottom: 35%; left: calc(50% - var(--bw)); width: var(--bw-2); border-radius: var(--r-pill); background: var(--c-on-light); }
.ed-item:hover .ed-handle { background: var(--c-line-4); }
.ed-item.is-selected:hover .ed-handle { background: var(--c-text); }
.ed-end { position: absolute; top: calc(-1 * var(--sp-1)); bottom: calc(-1 * var(--sp-1)); left: 0; border-left: var(--bw) dashed var(--c-line-4); pointer-events: none; }
.ed-after-end { position: absolute; top: var(--ed-ruler-h); bottom: 0; left: 0; width: 100000px; background: var(--ed-after); pointer-events: none; z-index: 3; }
.ed-playhead { position: absolute; top: 0; bottom: 0; left: calc(-1 * var(--ed-playhead-w) / 2); width: var(--ed-playhead-w); background: var(--c-light); pointer-events: none; z-index: 5; }
.ed-playhead-knob { position: absolute; top: 0; left: calc(var(--ed-playhead-w) / 2 - var(--sp-1-5)); width: var(--sp-3); height: var(--sp-3); border-radius: 0 0 var(--r-2xs) var(--r-2xs); background: var(--c-light); }

/* ---------- Medya kutusu ---------- */
.ed-panel-title { font-size: var(--fs-h4); font-weight: var(--fw-semibold); letter-spacing: var(--tr-snug); margin-bottom: var(--sp-3); overflow-wrap: anywhere; }
.ed-bin-inner { display: flex; flex-direction: column; gap: var(--sp-3); }
.ed-bin-tools { display: flex; flex-direction: column; gap: var(--sp-2); }
.ed-bin-search { height: var(--btn-h-sm); }
.ed-bin-kinds { display: flex; gap: var(--sp-1-5); overflow-x: auto; scrollbar-width: none; }
.ed-bin-kinds .chip { height: var(--ctl-md); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.ed-bin-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.ed-bin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--ed-bin-cell), 1fr)); gap: var(--sp-3) var(--sp-2); }
.ed-bin-cell { position: relative; }
.ed-bin-cell:hover .lib-more, .ed-bin-cell:focus-within .lib-more { opacity: 1; }
.ed-bin-item { display: flex; flex-direction: column; gap: var(--sp-1-5); width: 100%; text-align: start; border-radius: var(--r-sm); cursor: grab; }
.ed-bin-item .thumb { aspect-ratio: 1; width: 100%; transition: transform var(--dur-fast) var(--ease); }
.ed-bin-item:hover .thumb { outline: var(--bw) solid var(--c-line-4); }
.ed-bin-item:active .thumb { transform: scale(0.97); }
.ed-bin-item:disabled { opacity: 0.5; }
.ed-bin-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--fs-xs); line-height: var(--lh-snug); color: var(--c-text-2); overflow-wrap: anywhere; }
.ed-bin-progress { position: absolute; inset-inline: var(--sp-1-5); bottom: var(--sp-1-5); }
.ed-drop-hint { font-size: var(--fs-xs); color: var(--c-text-3); }
.ed-bin-sheet .ed-bin-grid { max-height: 52vh; overflow-y: auto; }

/* ---------- Ayarlar paneli ---------- */
.ed-prop { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.ed-prop-label { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--c-text-2); }
.ed-prop-value { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--c-text-3); }
.ed-prop .segmented { width: 100%; }
.ed-chips { display: flex; flex-wrap: wrap; gap: var(--sp-1-5); }
.ed-chips .chip { height: var(--ctl-md); padding: 0 var(--sp-2-5); font-family: var(--font-mono); font-size: var(--fs-xs); }
.ed-prop-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.ed-text-area { min-height: 84px; resize: vertical; }
.ed-swatches { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.ed-swatch { width: var(--ed-swatch); height: var(--ed-swatch); border-radius: 50%; background: var(--swatch); border: var(--bw-2) solid var(--c-line-3); }
.ed-swatch[aria-checked="true"] { outline: var(--bw-2) solid var(--c-text); outline-offset: var(--ring-offset); }
.ed-keys { margin: var(--sp-6) 0 var(--sp-4); }
.ed-keys h3 { font-size: var(--fs-sm); font-weight: var(--fw-semibold); margin-bottom: var(--sp-2); color: var(--c-text-2); }
.ed-keys ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--sp-1-5); font-size: var(--fs-xs); color: var(--c-text-3); }
.ed-inspector .receipt { margin-bottom: var(--sp-4); }
.ed-inspector-sheet { max-height: 62vh; overflow-y: auto; }

/* ---------- Dışa aktarma ---------- */
.ed-export .ed-prop { margin-bottom: var(--sp-4); }
.ed-export .receipt { margin: var(--sp-4) 0; }
.ed-export-progress { display: flex; flex-direction: column; gap: var(--sp-3); margin: var(--sp-6) 0; }
.ed-export-step { font-size: var(--fs-sm); color: var(--c-text-2); }
.ed-export-player { margin: var(--sp-4) 0; max-height: 50vh; display: grid; place-items: center; }
.ed-export-player .player { max-height: 50vh; }

/* Önizleme ve dışa aktarmanın medya öğeleri: görünmez ama çizilebilir (kareleri gelsin). */
.ed-media-host { position: fixed; left: 0; top: 0; width: 2px; height: 2px; overflow: hidden; opacity: 0.01; pointer-events: none; z-index: -1; }
.ed-media-host video, .ed-media-host audio { width: 2px; height: 2px; }

/* Kütüphane: editörden gelen klip */
.lib-editor-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); }
.lib-editor-link { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--c-text-2); text-decoration: none; }
.lib-editor-link:hover { color: var(--c-text); }
.lib-editor-link .icon { width: var(--icon-sm); height: var(--icon-sm); }

@media (min-width: 640px) {
  .ed { grid-template-rows: auto auto minmax(0, 1fr) auto var(--ed-tl-h); }
  .ed-tool { flex-direction: row; gap: var(--sp-1-5); min-height: var(--btn-h-sm); padding: 0 var(--sp-3); }
}
@media (min-width: 1100px) {
  .ed-main { grid-template-columns: var(--ed-bin-w) minmax(0, 1fr) var(--ed-insp-w); }
  .ed-bin, .ed-inspector { display: block; overflow-y: auto; padding: var(--sp-4); background: var(--c-bg); }
  .ed-bin { border-inline-end: var(--bw) solid var(--c-line); }
  .ed-inspector { border-inline-start: var(--bw) solid var(--c-line); }
}
@media (min-width: 1400px) {
  :root { --ed-bin-w: 340px; --ed-insp-w: 320px; }
}
@media (max-width: 479px) {
  .ed-top { gap: var(--sp-2); padding-inline: var(--sp-2); }
  .ed-top-actions .btn .btn-label { display: none; }
  .ed-top-actions .btn { padding: 0; width: var(--app-icon-btn); min-height: var(--app-icon-btn); }
}
