/* İzleme görünümü: video alanı, başlık, durum katmanı, kumanda çubuğu.
   Performans: backdrop-filter, büyük gölge ve animasyonlu pahalı efekt yok. */

.watch {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  background: var(--zemin);
}

.watch-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
  background: var(--zemin);
}

/* 16:9 çerçeve alanı doldurur (konteyner sorgusu yoksa genişliğe oturur). */
.watch-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 100%;
  background: var(--zemin);
  overflow: hidden;
}
@supports (width: 1cqw) {
  .watch-frame { width: min(100cqw, calc(100cqh * 16 / 9)); }
}

.watch.ytwatch {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: start;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  background: var(--zemin);
}

.watch-main { min-width: 0; min-height: 0; }

.ytwatch .watch-stage {
  position: relative;
  display: block;
  min-height: 0;
  container-type: normal;
  background: var(--zemin);
}

/* 16:9 çerçeve: genişliğe oturur (oynarken boyutu değişmez); kumanda çerçevenin içindedir. */
.ytwatch .watch-frame {
  position: relative;
  width: 100%;
  max-height: none;
  aspect-ratio: 16 / 9;
  background: var(--zemin);
  overflow: hidden;
}

/* Alt bilgi bloğu: başlık (en çok 2 satır) + tek satır "kanal · izlenme · tarih" */
.watch-meta { padding: 8px 16px 10px; }
.watch-meta[hidden] { display: none; }
.watch-meta-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 2px;
  font-family: var(--font-baslik);
  font-weight: 500;
  font-size: calc(16px * var(--fs, 1));
  line-height: 1.25;
}
.watch-meta-line {
  display: flex;
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
  color: var(--metin-ikincil);
  font-size: calc(13px * var(--fs, 1));
}
.watch-meta-line > span { flex: none; }
.watch-meta-line > span:first-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.watch-meta-line > span + span::before { content: "\00B7"; margin: 0 8px; }
.watch-meta-channel { color: var(--metin); font-weight: 500; }

/* Önerilen videolar paneli */
.watch-side { min-width: 0; padding: 12px; border-top: 1px solid var(--sinir); }
.side-title {
  margin: 0 0 12px;
  font-family: var(--font-baslik);
  font-weight: 500;
  font-size: calc(15px * var(--fs, 1));
}
.side-body { display: flex; flex-direction: column; gap: 10px; }
.side-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-note { margin: 0; color: var(--metin-ikincil); font-size: calc(14px * var(--fs, 1)); }
.rel-card {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  width: 100%;
  height: 94px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-kart);
  background: transparent;
  color: var(--metin);
  text-align: left;
  content-visibility: auto;
  contain-intrinsic-size: auto 94px;
  -webkit-tap-highlight-color: transparent;
}
.rel-card:active { border-color: var(--vurgu); }
.rel-thumb {
  position: relative;
  width: 168px;
  height: 94px;
  overflow: hidden;
  border-radius: var(--radius-kart);
  background: var(--sinir);
}
.rel-thumb img { display: block; width: 168px; height: 94px; object-fit: cover; }
.rel-thumb img.is-broken { visibility: hidden; }
.rel-duration {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--zemin-saydam);
  color: var(--metin-video);
  font-family: var(--font-sayi);
  font-size: calc(12px * var(--fs, 1));
  font-variant-numeric: tabular-nums;
}
.rel-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-right: 4px; }
.rel-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 500;
  font-size: calc(13px * var(--fs, 1));
  line-height: 1.3;
}
.rel-channel {
  color: var(--metin-ikincil);
  font-size: calc(12px * var(--fs, 1));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dar ekran: bölümler normal akışta alt alta dizilir, görünüm kayar. Izgara satırları
   pencere yüksekliğine sıkışıp öneriler bilgi bloğunun üstüne biniyordu (773x601'de ölçüldü). */
@container app (max-width: 999px) {
  .watch.ytwatch:not(.is-full) { display: block; }
  .ytwatch:not(.is-full) .watch-main,
  .ytwatch:not(.is-full) .watch-side { overflow: visible; }
}

/* Geniş ekran: video solda, öneriler sağda (her biri kendi içinde kayar). */
@container app (min-width: 1000px) {
  .watch.ytwatch {
    grid-template-columns: minmax(0, 1fr) 360px;
    grid-template-rows: minmax(0, 1fr);
    overflow: hidden;
  }
  .watch-main { overflow-y: auto; }
  /* contain: kartlar eklenirken yerleşim/boyama video sütununa taşmaz. */
  .watch-side { overflow-y: auto; border-top: 0; border-left: 1px solid var(--sinir); contain: layout paint; }
}

.watch-canvas {
  display: block;
  width: 100%;
  height: 100%;
  /* Goruntu kendi en-boy oranini korur (4:3 ya da dikey yayin 16:9 cerceveye esnetilmez) */
  object-fit: contain;
  background: var(--zemin);
}

/* Başlık ve geri dönüş */
.watch-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--zemin-saydam);
  color: var(--metin-video);
  transition: opacity 0.2s;
}
.watch-back {
  flex: none;
  background: transparent;
  color: var(--metin-video);
}
.watch-title {
  margin: 0;
  min-width: 0;
  font-family: var(--font-baslik);
  font-weight: 500;
  font-size: calc(16px * var(--fs, 1));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
/* Başlık tek yerde: normalde alt bilgi bloğunda, tam alanda yalnız üst çubukta. */
.ytwatch .watch-title { display: none; }
.ytwatch.is-full .watch-title { display: block; }
.ytwatch .net-slot { margin-left: auto; }
.watch-top .net-badge { border-color: transparent; color: var(--metin-video); }

/* Durum katmanı: küçük rozet, canvas'ı karartmaz/bulanıklaştırmaz. */
.watch-status {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--sinir);
  border-radius: var(--radius-buton);
  background: var(--zemin-saydam);
  color: var(--metin-video);
  font-weight: 500;
  pointer-events: none;
}
.watch-status[hidden] { display: none; }
.watch-status svg { width: 26px; height: 26px; }

/* Kalite gecisi bildirimi: videonun sol ustunde, dokunusu engellemez */
.quality-notice {
  position: absolute;
  left: 16px;
  top: 16px;
  padding: 8px 16px;
  border: 1px solid var(--vurgu);
  border-radius: var(--radius-buton);
  background: var(--zemin-saydam);
  color: var(--metin-video);
  font-weight: 600;
  pointer-events: none;
}
.quality-notice[hidden] { display: none; }
.quality-notice.is-busy { border-color: var(--sinir); }
.quality-notice.is-error { border-color: var(--hata); color: var(--hata); }
/* Belirgin balon: gecisin tamamlandigi an ve giris uyarisi ekranin ortasinda, buyuk ve opak zeminde */
.quality-notice.is-prominent {
  left: 50%;
  top: 50%;
  z-index: 5;
  max-width: min(86%, 640px);
  padding: 16px 28px;
  border-width: 2px;
  background: var(--zemin);
  font-size: 1.5em;
  line-height: 1.3;
  text-align: center;
  transform: translate(-50%, -50%);
  animation: notice-pop 0.22s ease-out;
}
@keyframes notice-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.86); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .quality-notice.is-prominent { animation: none; }
}
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Orta katman: oynat, bitti, hata */
.watch-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 90%;
  padding: 22px 28px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--sinir);
  border-radius: var(--radius-kart);
  background: var(--zemin-saydam);
  color: var(--metin-video);
  text-align: center;
}
.watch-overlay[hidden] { display: none; }
.watch-overlay.is-error .overlay-msg { color: var(--hata); }
.overlay-msg { margin: 0; font-size: calc(16px * var(--fs, 1)); font-weight: 500; }
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.btn-big { min-height: 72px; padding: 0 34px; font-size: calc(18px * var(--fs, 1)); }
.btn-big svg { width: 32px; height: 32px; }

/* Kumanda çubuğu */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 16px 6px;
  background: var(--zemin-saydam);
  transition: opacity 0.2s;
}
.seek-row { display: flex; align-items: center; gap: 14px; }
.time {
  min-width: 64px;
  font-family: var(--font-sayi);
  font-size: calc(13px * var(--fs, 1));
  font-variant-numeric: tabular-nums;
  color: var(--metin);
}
.time:first-child { text-align: right; }

.progress {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  height: 56px;
  touch-action: none;
  cursor: pointer;
  --played: 0;
  --buffered: 0;
}
.progress-track {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--sinir);
}
.progress-buffer, .progress-played {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  transform-origin: 0 50%;
}
.progress-buffer { background: var(--metin-ikincil); transform: scaleX(var(--buffered)); }
.progress-played { background: var(--vurgu); transform: scaleX(var(--played)); }
.progress-thumb {
  position: absolute;
  top: 50%;
  left: calc(var(--played) * 100%);
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--vurgu);
  border: 2px solid var(--zemin);
}

.btn-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* Tek seçimli düğme grubu: oynatma hızı ve görüntü kalitesi. */
.seg {
  display: inline-flex;
  margin-right: 8px;
  border: 1px solid var(--sinir);
  border-radius: var(--radius-buton);
  overflow: hidden;
}
.seg-btn {
  min-width: 68px;
  min-height: 56px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--sinir);
  background: transparent;
  color: var(--metin);
  font-family: var(--font-sayi);
  font-size: calc(14px * var(--fs, 1));
  -webkit-tap-highlight-color: transparent;
}
.seg-btn:first-child { border-left: 0; }
.seg-btn.is-active { background: var(--vurgu); color: var(--vurgu-metin); }
.spacer { flex: 1; }
.ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 56px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-buton);
  background: transparent;
  color: var(--metin);
  -webkit-tap-highlight-color: transparent;
}
.ctl svg { width: 30px; height: 30px; }
.ctl:active { border-color: var(--ikincil); }
.ctl-main { background: var(--vurgu); color: var(--vurgu-metin); }
.ctl-main svg { width: 32px; height: 32px; }

.volume {
  width: 160px;
  height: 56px;
  margin: 0;
  background: transparent;
  accent-color: var(--vurgu);
  touch-action: none;
}

/* Hareketsizlik: oynarken kumanda ve başlık solar. */
.watch.is-idle .controls,
.watch.is-idle .watch-top {
  opacity: 0;
  pointer-events: none;
}

/* Tam alan: video pencereyi doldurur, kumanda üstte yüzer. */
.watch.is-full {
  position: fixed;
  inset: 0;
  z-index: 80;
  grid-template-rows: minmax(0, 1fr);
}
.watch.is-full .watch-stage { height: 100%; }

/* Sürüm rozeti izleme alanında kumandanın altında kalmasın. */
#app-root[data-view="watch"] .controls { padding-bottom: 22px; }

/* Tam alan: video pencereyi doldurur, kumanda üstte yüzer; meta ve öneri paneli gizlenir. */
.watch.ytwatch.is-full {
  position: fixed;
  inset: 0;
  z-index: 80;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.ytwatch.is-full .watch-main { height: 100%; overflow: hidden; }
.ytwatch.is-full .watch-meta,
.ytwatch.is-full .watch-side { display: none; }
.ytwatch.is-full .watch-stage {
  display: grid;
  place-items: center;
  height: 100%;
  container-type: size;
}
.ytwatch.is-full .watch-frame { max-height: 100%; }
@supports (width: 1cqw) {
  .ytwatch.is-full .watch-frame { width: min(100cqw, calc(100cqh * 16 / 9)); }
}

/* Sürüm rozeti tam alanda kumandanın altında kalmasın. */
.ytwatch.is-full .controls { padding-bottom: 22px; }

/* Hız ve kalite: tek düğme, dokununca seçenekler yukarı açılır. */
.menu-wrap { position: relative; margin-right: 8px; }
.menu-btn {
  min-width: 76px;
  min-height: 56px;
  padding: 0 14px;
  border: 1px solid var(--sinir);
  border-radius: var(--radius-buton);
  background: transparent;
  color: var(--metin);
  font-family: var(--font-sayi);
  font-size: calc(14px * var(--fs, 1));
  -webkit-tap-highlight-color: transparent;
}
.menu-btn[aria-expanded="true"] { border-color: var(--vurgu); }
/* Secilen deger henuz uygulanmadi (kalite gecisi hazirlaniyor): hedef deger yanip soner. */
.menu-btn.is-pending {
  border-color: var(--vurgu);
  color: var(--vurgu);
  animation: menu-pending-blink 1s ease-in-out infinite;
}
@keyframes menu-pending-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.menu-pop {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 132px;
  border: 1px solid var(--sinir);
  border-radius: var(--radius-kart);
  background: var(--yuzey);
  box-shadow: var(--golge-kart);
  overflow: hidden;
}
.menu-pop[hidden] { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 16px 0 12px;
  border: 0;
  border-top: 1px solid var(--sinir);
  background: transparent;
  color: var(--metin);
  font-family: var(--font-sayi);
  font-size: calc(14px * var(--fs, 1));
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.menu-item:first-child { border-top: 0; }
.menu-item:active { background: var(--sinir); }
.menu-check { display: inline-flex; width: 24px; height: 24px; visibility: hidden; }
.menu-check svg { width: 24px; height: 24px; }
.menu-item.is-active { color: var(--vurgu); font-weight: 700; }
.menu-item.is-active .menu-check { visibility: visible; }
/* Bu videoda alinamayan secenek (ornegin 1080p): soluk ve secilemez */
.menu-item.is-disabled { opacity: 0.4; cursor: default; }
.menu-item.is-disabled:active { background: transparent; }

/* Normal (tam alan olmayan) görünümde kumanda çerçevenin içindedir; rozet payı gerekmez. */
#app-root[data-view="watch"] .ytwatch:not(.is-full) .controls { padding-bottom: 6px; }

/* ---- YouTube izleme: kumanda ve üst çubuk videonun üstüne biner, yer ayırmaz ---- */
.ytwatch .watch-top {
  padding: 8px 12px 24px;
  background: linear-gradient(to bottom, var(--zemin-saydam), transparent);
  pointer-events: none;
}
.ytwatch .watch-top > * { pointer-events: auto; }
.ytwatch .controls {
  padding: 20px 16px 6px;
  background: linear-gradient(to top, var(--zemin-saydam) 55%, transparent);
}
.ytwatch .progress { height: 44px; }
.ytwatch .btn-row { flex-wrap: nowrap; justify-content: space-between; gap: 8px; }
.ytwatch .btn-group { display: flex; align-items: center; gap: 4px; min-width: 0; }
.ytwatch .vol-group { display: flex; align-items: center; }
.ytwatch .ctl { min-width: 48px; min-height: 48px; }
.ytwatch .ctl svg, .ytwatch .ctl-main svg { width: 28px; height: 28px; }
.ytwatch .volume { width: 110px; height: 48px; }
.ytwatch .time {
  min-width: 0;
  padding: 0 8px;
  white-space: nowrap;
  color: var(--metin-video);
}
.ytwatch .menu-wrap { margin: 0; }
.ytwatch .menu-btn { min-width: 64px; min-height: 48px; padding: 0 12px; }

/* Dar ekran: ses kaydırıcısı gizlenir (sessiz düğmesi kalır), satır tek satırda sığar. */
@container app (max-width: 699px) {
  .ytwatch .volume { display: none; }
  .ytwatch .controls { padding-left: 8px; padding-right: 8px; }
}

/* ---- Üst şerit videonun dışında (üstünde), her zaman görünür; geri dön kırmızı ---- */
.ytwatch .watch-main { position: relative; }
.ytwatch:not(.is-full) .watch-top {
  position: static;
  padding: 6px 12px;
  background: var(--zemin);
  border-bottom: 1px solid var(--sinir);
}
/* Normal görünümde hareketsizlikte solmaz */
.ytwatch.is-idle:not(.is-full) .watch-top {
  opacity: 1;
  pointer-events: auto;
}
/* Tam alanda video pencereyi doldurur; şerit videonun üstünde yüzer ve hareketsizlikte solar */
.ytwatch.is-full .watch-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}
.ytwatch .watch-back {
  background: var(--hata);
  color: var(--metin-video);
  border-color: var(--hata);
  font-weight: 600;
}
.ytwatch .watch-back:hover,
.ytwatch .watch-back:focus-visible {
  filter: brightness(1.1);
}
/* Şerit ince kalsın: dokunma hedefi 44 px, video alanından en az yer alınır */
.ytwatch .watch-back { min-height: 44px; padding-top: 0; padding-bottom: 0; }
.ytwatch:not(.is-full) .watch-top { padding: 4px 12px; }
.ytwatch:not(.is-full) .watch-top .net-slot { min-height: 0; }

/* ---- Kumanda videonun DISINDA, hemen altinda (normal gorunum) ----
   Tam alanda kumanda videonun ustunde yuzer ve hareketsizlikte solar (temel .controls kurali). */
.ytwatch:not(.is-full) .controls {
  position: static;
  width: 100%;
  box-sizing: border-box;
  padding: 4px 16px 6px;
  background: var(--zemin);
  border-bottom: 1px solid var(--sinir);
}
.ytwatch.is-idle:not(.is-full) .controls { opacity: 1; pointer-events: auto; }
.ytwatch:not(.is-full) .time { color: var(--metin); }

/* Ayarlarda oneriler paneli kapali: video tum genisligi kullanir. */
.watch.ytwatch.no-side { grid-template-columns: minmax(0, 1fr); }
.watch-side[hidden] { display: none; }

/* Sagdan sola dillerde (Arapca) oynatici kumandasi yine soldan saga: zaman ekseni,
   ilerleme cubugu dokunusu ve "gecen / toplam" sirasi evrenseldir. */
.controls { direction: ltr; }

/* Genis duzende (video solda, oneriler sagda) video sutunu kaymaz: ust serit, kumanda ve
   bilgi satiri sabit boyda kalir, video kalan yuksekligi doldurur. Goruntu canvas'ta
   object-fit: contain ile oranini korur; artan alan yanlarda bos kalir. */
@container app (min-width: 1000px) {
  .ytwatch:not(.is-full) .watch-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }
  .ytwatch:not(.is-full) .watch-top,
  .ytwatch:not(.is-full) .controls,
  .ytwatch:not(.is-full) .watch-meta { flex: none; }
  .ytwatch:not(.is-full) .watch-stage {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .ytwatch:not(.is-full) .watch-frame {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    aspect-ratio: auto;
  }
  /* Baslik tek satir: video alanindan en az yer alinir */
  .ytwatch:not(.is-full) .watch-meta-title { -webkit-line-clamp: 1; }
}

/* Video sag ust kosesinde logo (eski projedeki filigran). Cerceve goruntuden genis/uzun olabilir
   (object-fit: contain); kose 16:9 goruntunun kendi kosesine hesaplanir (cerceve boyut konteyneri). */
.watch-frame { container-type: size; }
.watch-frame .logo-watermark {
  position: absolute;
  top: max(10px, calc((100cqh - 100cqw * 9 / 16) / 2 + 10px));
  right: max(12px, calc((100cqw - 100cqh * 16 / 9) / 2 + 12px));
  z-index: 3;
  font-size: calc(36px * var(--fs, 1));
  opacity: 0.92;
  pointer-events: none;
  /* Golge/filtre yok: drop-shadow harf kenarlarini yumusatip logoyu bulanik gosteriyordu */
}
