/* feed.css — homepage video listing: controls, 16:9 grid, card, states.
   Loaded after tokens.css + header.css. */

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter);
  /* respect notch insets so edge content/chips never clip */
  padding-left: max(var(--gutter), var(--safe-left));
  padding-right: max(var(--gutter), var(--safe-right));
}

a { color: inherit; text-decoration: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.page-title {
  font-size: var(--fs-400); font-weight: var(--fw-bold);
  letter-spacing: -0.02em; margin: 0 0 var(--sp-4);
  color: var(--c-text);
}
.page-title .count { color: var(--c-text-subtle); font-weight: var(--fw-regular); font-size: var(--fs-200); }

/* ---- Controls: sort tabs + category chips -------------------------------- */
.controls { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-5); }

.scroller {
  display: flex; gap: var(--sp-2);
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scroll-padding-inline: var(--sp-4);
}
.scroller::-webkit-scrollbar { display: none; }

.sort-tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; min-height: 36px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-200); font-weight: var(--fw-semibold);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border); border-radius: var(--r-pill);
  background: var(--c-bg-elevated);
  white-space: nowrap;
  transition: color var(--d-base) var(--e-out), border-color var(--d-base) var(--e-out), background var(--d-base) var(--e-out);
}
@media (hover: hover) { .sort-tab:hover { color: var(--c-accent-text); border-color: var(--c-brand); } }
.sort-tab.active {
  color: #1a1205; background: var(--c-brand); border-color: var(--c-brand);
}

/* "All categories" pill — nav (not a sort filter): brand-tinted, gap before it, grid icon. */
.sort-tab--cats {
  gap: 6px; margin-left: auto;
  color: var(--c-brand);
  border-color: color-mix(in srgb, var(--c-brand) 45%, var(--c-border));
}
.sort-tab--cats svg { width: 15px; height: 15px; flex: 0 0 auto; }
@media (hover: hover) {
  .sort-tab--cats:hover {
    color: var(--c-brand); border-color: var(--c-brand);
    background: color-mix(in srgb, var(--c-brand) 12%, var(--c-bg-elevated));
  }
}
/* Overflow scroller: margin-auto collapses, so keep a real gap before the pill. */
@media (pointer: coarse) { .sort-tab--cats { margin-left: var(--sp-2); } }

/* Touch devices: guarantee a 44px hit area without bloating the desktop pills. */
@media (pointer: coarse) {
  .sort-tab, .cat-chip { min-height: 44px; }
  .scroller { gap: var(--sp-3); }
}

.cat-chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; min-height: 32px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-100); font-weight: var(--fw-medium);
  color: var(--c-text-subtle);
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  background: transparent;
  white-space: nowrap;
  transition: color var(--d-base) var(--e-out), border-color var(--d-base) var(--e-out);
}
@media (hover: hover) { .cat-chip:hover { color: var(--c-text); border-color: var(--c-border-strong); } }
.cat-chip.active {
  color: var(--c-text); border-color: var(--c-brand);
  background: color-mix(in srgb, var(--c-brand) 14%, transparent);
}

/* Category chip row: single line + edge arrows when it overflows (desktop). The arrows
   are shown/hidden by JS based on scroll position; each doubles as a fade so the row
   visibly runs off the edge instead of being hard-cut (the "nothing after Babe" issue). */
.cat-nav { position: relative; }
.cat-nav__edge {
  position: absolute; top: 0; bottom: 0; z-index: 2; width: 48px; padding: 0;
  display: flex; align-items: center; border: 0; cursor: pointer; color: var(--c-text);
}
.cat-nav__edge svg { width: 20px; height: 20px; }
.cat-nav__edge--prev { left: 0; justify-content: flex-start;
  background: linear-gradient(to right, var(--c-bg) 45%, transparent); }
.cat-nav__edge--next { right: 0; justify-content: flex-end;
  background: linear-gradient(to left, var(--c-bg) 45%, transparent); }
.cat-nav__edge[hidden] { display: none; }
@media (hover: hover) { .cat-nav__edge:hover { color: var(--c-brand); } }
.cat-scroller { scroll-behavior: smooth; }

/* Mobile: inline category chips give way to the hamburger drawer. */
@media (max-width: 768px) {
  .cat-nav { display: none; }
}

/* ---- Grid: 16:9 cards ---------------------------------------------------- */
.video-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(264px, 1fr));
}
@media (max-width: 600px) {
  /* mobile: 1 video per row (PH-style) — full-width cards */
  .video-grid { grid-template-columns: 1fr; gap: var(--sp-3) 0; }
}

.vcard {
  display: flex; flex-direction: column;
  background: var(--c-bg-elevated);
  border-radius: var(--r-md); overflow: hidden;
}
@supports (content-visibility: auto) {
  .vcard { content-visibility: auto; contain-intrinsic-size: auto 280px; }
}

.vcard__thumb {
  position: relative; display: block;
  aspect-ratio: 16 / 9;
  background: var(--c-gray-950);
  overflow: hidden;
  /* press-and-hold to preview must NOT pop the OS callout (save/open image, link menu)
     or select text/drag the image; JS also preventDefaults contextmenu on touch. */
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
}
.vcard__thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  -webkit-user-drag: none; user-drag: none; pointer-events: none;  /* touches go to the <a>, no image menu */
  transition: opacity var(--d-medium) var(--e-out), transform var(--d-slow) var(--e-out);
}
/* fade-in is a JS-only enhancement (html.js set sync in <head>); without JS
   images stay visible so the page is fully usable. */
html.js .vcard__thumb img { opacity: 0; }
html.js .vcard__thumb.is-loaded img { opacity: 1; }
@media (hover: hover) { .vcard:hover .vcard__thumb img { transform: scale(1.05); } }
/* hover preview clip (JS-injected, local /media/preview/<id>/fb.mp4) */
.vcard__thumb video.vpreview {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 2; background: var(--c-gray-950); display: block;
  transition: opacity .15s ease;     /* smooth sprite → video upgrade (mobile) */
  pointer-events: none;              /* taps fall through to the <a> so a tap always navigates */
}
/* sprite-sheet fallback (JS-injected when mp4 autoplay is blocked). Each frame is
   one grid cell scaled to fill the thumb; JS steps background-image/position. */
.vcard__thumb .vsprite {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 1; background-color: var(--c-gray-950);
  background-repeat: no-repeat; background-origin: border-box; display: block;
  pointer-events: none;              /* taps fall through to the <a> so a tap always navigates */
}
/* PH-style loading bar: fills left→right at the TOP of the thumb the moment a preview is
   triggered, so you can SEE it loading in the background; completes + fades when it plays. */
.vcard__thumb .vpreview-bar {
  position: absolute; top: 0; left: 0; height: 2px; width: 0; z-index: 3;
  background: #ffd400;                 /* thin yellow loading bar */
  box-shadow: 0 0 5px rgba(255, 212, 0, .6);
  transition: width .14s linear, opacity .35s ease;
  pointer-events: none;
}
.vcard__thumb .vpreview-bar.is-done { opacity: 0; }

/* badges hidden until the image paints — JS-gated for the same reason */
html.js .vcard__thumb:not(.is-loaded) .vcard__dur,
html.js .vcard__thumb:not(.is-loaded) .vcard__q { visibility: hidden; }

.vcard__dur {
  position: absolute; right: var(--sp-2); bottom: var(--sp-2);
  background: rgba(0, 0, 0, 0.82); color: #fff;
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  font-size: var(--fs-100); font-weight: var(--fw-semibold); line-height: 1.3;
}
.vcard__q {
  position: absolute; left: var(--sp-2); bottom: var(--sp-2);
  background: var(--c-brand); color: #1a1205;
  padding: 2px var(--sp-2); border-radius: var(--r-sm);
  font-size: var(--fs-100); font-weight: var(--fw-bold); letter-spacing: 0.02em; line-height: 1.3;
}
.vcard__q[data-q="SD"] { background: rgba(0,0,0,0.82); color: #fff; }

/* play glyph appears on hover (desktop) */
.vcard__thumb::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at center,
      var(--c-play-overlay-bg) 0 30px, transparent 31px) no-repeat center;
  opacity: 0;
  transition: opacity var(--d-base) var(--e-out);
  pointer-events: none;
}
.vcard__play {
  position: absolute; top: 50%; left: 50%;
  width: 0; height: 0;
  border-style: solid; border-width: 9px 0 9px 15px;
  border-color: transparent transparent transparent var(--c-play-overlay-fg);
  transform: translate(-40%, -50%) scale(0.9);
  opacity: 0; transition: opacity var(--d-base) var(--e-out), transform var(--d-base) var(--e-out);
  pointer-events: none;
}
@media (hover: hover) {
  .vcard:hover .vcard__thumb::after { opacity: 1; }
  .vcard:hover .vcard__play { opacity: 1; transform: translate(-40%, -50%) scale(1); }
}

.vcard__body { padding: var(--sp-2) var(--sp-1) var(--sp-3); display: flex; flex-direction: column; gap: 4px; }
.vcard__title {
  font-size: var(--fs-200); font-weight: var(--fw-semibold);
  line-height: var(--lh-snug); color: var(--c-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color var(--d-base) var(--e-out);
}
@media (hover: hover) { .vcard:hover .vcard__title { color: var(--c-accent-text); } }
.vcard__studio { font-size: var(--fs-100); color: var(--c-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard__meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--sp-2);
  font-size: var(--fs-100); color: var(--c-text-subtle);
}
.vcard__meta .dot { color: var(--c-border-strong); }
.vcard__rating { color: var(--c-success); font-weight: var(--fw-semibold); }
.lang-badge {
  margin-left: auto;
  text-transform: uppercase; letter-spacing: 0.04em;
  font-size: var(--fs-100); font-weight: var(--fw-bold);
  color: var(--c-text-muted);
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  padding: var(--sp-px) var(--sp-1);
}

/* mobile: tighten card chrome */
@media (max-width: 600px) {
  .vcard { border-radius: var(--r-sm); }
  @supports (content-visibility: auto) {
    .vcard { contain-intrinsic-size: auto 160px; }  /* match the shorter 2-col card */
  }
  .vcard__body { padding: var(--sp-2) 2px var(--sp-2); }
  .vcard__studio { display: none; }
  .vcard__meta .lang-badge { margin-left: 0; }       /* don't detach on its own line */
  .vcard__title { font-size: clamp(13px, 3.4vw, 14px); }
}

/* ---- States: empty / error / loading ------------------------------------- */
.feed-state {
  grid-column: 1 / -1;
  text-align: center; padding: var(--sp-20) var(--sp-4);
  color: var(--c-text-muted);
}
.feed-state__icon { font-size: 48px; line-height: 1; margin-bottom: var(--sp-3); }
.feed-state h2 { margin: 0 0 var(--sp-2); color: var(--c-text); font-size: var(--fs-500); letter-spacing: -0.01em; }
.feed-state p { margin: 0 auto; max-width: 42ch; line-height: var(--lh-base); }
.feed-state .btn { margin-top: var(--sp-4); }

.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 var(--sp-5);
  border: 0; border-radius: var(--r-pill); cursor: pointer;
  font: inherit; font-size: var(--fs-200); font-weight: var(--fw-bold);
  background: var(--c-brand); color: #1a1205;
  transition: background var(--d-base) var(--e-out), transform var(--d-fast) var(--e-out);
}
@media (hover: hover) { .btn:hover { background: var(--c-brand-strong); } }
.btn:active { transform: translateY(1px); }

/* skeleton cards while first/next page loads */
.skeleton .vcard__thumb {
  background: linear-gradient(100deg,
    var(--c-bg-elevated) 30%, color-mix(in srgb, var(--c-text) 8%, var(--c-bg-elevated)) 50%, var(--c-bg-elevated) 70%);
  background-size: 200% 100%;
  animation: skel 1.2s linear infinite;
}
.skeleton .vcard__line {
  height: 10px; border-radius: var(--r-sm); margin: 8px 2px 0;
  background: color-mix(in srgb, var(--c-text) 8%, var(--c-bg-elevated));
}
.skeleton .vcard__line.short { width: 55%; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---- Load more / infinite scroll ----------------------------------------- */
.load-more-wrap {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  padding: var(--sp-8) 0 var(--sp-4); min-height: 80px;
}
.load-more-spinner { display: none; gap: var(--sp-2); align-items: center; }
.load-more-wrap.is-loading .load-more-spinner { display: flex; }
.lm-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-brand);
  animation: lmBounce 1s ease-in-out infinite;
}
.lm-dot:nth-child(2) { animation-delay: 0.15s; }
.lm-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes lmBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

.load-more-btn {
  min-width: 220px; min-height: 44px; padding: 0 var(--sp-6);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-bg-elevated); color: var(--c-text);
  font: inherit; font-size: var(--fs-200); font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background var(--d-base) var(--e-out), border-color var(--d-base) var(--e-out);
}
@media (hover: hover) { .load-more-btn:hover { border-color: var(--c-brand); color: var(--c-brand); } }
.load-more-btn[hidden] { display: none; }
.load-more-status { font-size: var(--fs-100); color: var(--c-text-subtle); }
.load-more-wrap.is-loading .load-more-btn { display: none; }
.load-more-error { color: var(--c-error); font-size: var(--fs-200); }

/* Categories katalog kısayolu (homepage chip strip) */
.cat-chip--all { color: var(--c-brand); font-weight: var(--fw-bold); }

/* ---- Fallback-search: harici PH sonuçları (etiketsiz — feed'e sorunsuz karışır) ---------- */
.discover { margin-top: var(--sp-5); }
.search-web-placeholder { color: var(--c-text-muted); font-size: var(--fs-200); padding: var(--sp-4) 0; }
/* Sonsuz-scroll: durum satırı ("Loading more…" / son) + IntersectionObserver sentinel'i */
.discover-more { text-align: center; color: var(--c-text-muted); font-size: var(--fs-200); padding: var(--sp-5) 0; }
.discover-sentinel { height: 1px; margin-top: -1px; }

/* Harici kart: normal .vcard'ı miras eder; tek fark tıkla→yükle (ingest) durumu */
.vcard--ext .vcard__thumb { cursor: pointer; }
/* Tıkla → "Açılıyor…" overlay + spinner */
.vcard__ext-spin { display: none; }
.vcard--ext.is-loading .vcard__thumb::after {
  content: ''; position: absolute; inset: 0; z-index: 3;
  background: rgba(0, 0, 0, 0.6);
}
.vcard--ext.is-loading .vcard__ext-spin {
  display: block; position: absolute; z-index: 4; top: 50%; left: 50%;
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: var(--c-brand);
  border-radius: 50%; animation: disc-spin 0.8s linear infinite;
}
.vcard--ext.is-error .vcard__thumb::after {
  content: 'Tekrar deneyin'; position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  background: rgba(120, 20, 20, 0.72); color: #fff; font-size: var(--fs-200); font-weight: var(--fw-semibold);
}
@keyframes disc-spin { to { transform: rotate(360deg); } }
/* Discover/related manuel "Load more" butonu (otomatik yükleme durunca; ortalı blok) */
.discover-loadmore { display: block; margin: var(--sp-4) auto var(--sp-6); }
