/*
 * listing.css — Phần đầu trang chuyên mục (/anime, /hoat-hinh-trung-quoc, /phim-ai, /the-loai-khac)
 * và trang thể loại (/the-loai/…): khung tiêu đề, thanh công cụ, chip thể loại.
 * HTML: listing_render_head() trong core/functions/listing.func.php. Nạp qua listing_head_css() (filemtime).
 */

/* ── Màu riêng từng chuyên mục ── */
.lt-head { --lt-c: var(--ah-accent, #ff3b5c); --lt-c2: #7c73ff; }
.lt-head--anime                { --lt-c: #ff4d8d; --lt-c2: #a855f7; }
.lt-head--hoat-hinh-trung-quoc { --lt-c: #ff6b3d; --lt-c2: #f5b301; }
.lt-head--phim-ai              { --lt-c: #38bdf8; --lt-c2: #7c73ff; }
.lt-head--the-loai-khac        { --lt-c: #2dd4bf; --lt-c2: #22c55e; }
.lt-head--genre                { --lt-c: #a78bfa; --lt-c2: #ff3b5c; }

/* ── Khung tiêu đề gọn ── */
.lt-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 4px 0 12px;
  padding: 14px 18px;
  border-radius: var(--ah-radius, 12px);
  border: 1px solid var(--ah-border, rgba(255,255,255,.06));
  background:
    linear-gradient(110deg, color-mix(in srgb, var(--lt-c) 16%, transparent) 0%, color-mix(in srgb, var(--lt-c2) 8%, transparent) 45%, transparent 80%),
    var(--ah-surface, #13131e);
  overflow: hidden;
}
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .lt-head { background: var(--ah-surface, #13131e); }
}
.lt-head::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(var(--lt-c), var(--lt-c2));
}
.lt-head__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--lt-c), var(--lt-c2));
  box-shadow: 0 6px 18px -6px var(--lt-c);
}
.lt-head__icon .material-icons-round { font-size: 26px; }
.lt-head__body { flex: 1 1 auto; min-width: 0; }
.lt-head__title {
  margin: 0 0 4px;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  line-height: 1.2;
  color: var(--ah-text, #eee);
  overflow-wrap: anywhere;
}
.lt-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 12.5px;
  color: var(--ah-text-muted, #a0a0bb);
}
.lt-head__count strong { color: var(--ah-text, #eee); font-weight: 700; }
.lt-head__pill {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--lt-c);
  background: color-mix(in srgb, var(--lt-c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--lt-c) 30%, transparent);
}
.lt-head__pill--page { color: var(--ah-text-muted, #a0a0bb); background: var(--ah-surface-2, #1b1b2a); border-color: var(--ah-border, rgba(255,255,255,.06)); }

/* ── Thanh công cụ: Sắp xếp · Trạng thái · Năm (· Số tập) ── */
.lt-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 10px;
  margin: 0 0 12px;
}
.lt-tool { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lt-tool__label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--ah-text-dim, #7c7c9e);
}
.lt-tool__label .material-icons-round { font-size: 14px; }
.lt-tool select {
  appearance: none;
  -webkit-appearance: none;
  min-width: 132px;
  max-width: 100%;
  height: 36px;
  padding: 0 32px 0 12px;
  border-radius: 10px;
  border: 1px solid var(--ah-border, rgba(255,255,255,.08));
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a0a0bb'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 8px center / 18px,
    var(--ah-surface-2, #1b1b2a);
  color: var(--ah-text, #eee);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.lt-tool select:hover { border-color: rgba(255,255,255,.18); }
.lt-tool select:focus-visible { outline: none; border-color: var(--ah-accent, #ff3b5c); box-shadow: 0 0 0 3px var(--ah-accent-soft, rgba(255,59,92,.15)); }
.lt-tool select option { background: #1b1b2a; color: #eee; }
.lt-tools__go,
.lt-tools__reset {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.lt-tools__go { border: 0; background: var(--ah-accent, #ff3b5c); color: #fff; }
.lt-tools__reset { color: var(--ah-text-muted, #a0a0bb); border: 1px solid var(--ah-border, rgba(255,255,255,.08)); }
.lt-tools__reset:hover { color: var(--ah-text, #eee); border-color: rgba(255,255,255,.2); }
.lt-tools__reset .material-icons-round { font-size: 16px; }

/* ── Chip thể loại ── */
.lt-chips { position: relative; margin: 0 0 16px; }
.lt-chips__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 72px;               /* 2 hàng chip (32px) + khoảng cách */
  overflow: hidden;
}
.lt-chips.is-open .lt-chips__list { max-height: none; }
.lt-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--ah-border, rgba(255,255,255,.08));
  background: var(--ah-surface, #13131e);
  color: var(--ah-text-muted, #b8b8cc);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: color .15s, border-color .15s, background .15s;
}
.lt-chip:hover { color: var(--ah-text, #eee); border-color: rgba(255,255,255,.2); }
.lt-chip:focus-visible { outline: 2px solid var(--ah-accent, #ff3b5c); outline-offset: 2px; }
.lt-chip__n { font-size: 10.5px; font-weight: 600; color: var(--ah-text-dim, #7c7c9e); }
.lt-chip.is-active { color: #fff; background: var(--ah-accent, #ff3b5c); border-color: var(--ah-accent, #ff3b5c); font-weight: 700; }
.lt-chip.is-active .lt-chip__n { color: rgba(255,255,255,.8); }
.lt-chips__more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: 8px;
  padding: 4px 10px 4px 12px;
  border-radius: 999px;
  border: 1px dashed rgba(255,255,255,.18);
  background: transparent;
  color: var(--ah-text-muted, #b8b8cc);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.lt-chips__more:hover { color: var(--ah-text, #eee); border-color: rgba(255,255,255,.32); }
.lt-chips__more .material-icons-round { font-size: 18px; }
.lt-chips__more[hidden] { display: none; }

/* Mobile: 1 hàng vuốt ngang, mờ 2 mép, bắt dính từng chip */
@media (max-width: 640px) {
  .lt-head { gap: 12px; padding: 12px 14px; }
  .lt-head__icon { width: 40px; height: 40px; border-radius: 10px; }
  .lt-head__icon .material-icons-round { font-size: 22px; }

  .lt-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
  .lt-tool select { min-width: 0; width: 100%; padding: 0 22px 0 9px; font-size: 12.5px; background-position: right 3px center, 0 0; background-size: 16px, auto; }
  .lt-tools__reset { justify-content: center; grid-column: 1 / -1; }

  .lt-chips { margin: 0 -16px 14px; }
  .lt-chips__list {
    flex-wrap: nowrap;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 16px;
    scroll-snap-type: x proximity;
    scroll-padding: 0 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
  }
  .lt-chips__list::-webkit-scrollbar { display: none; }
  .lt-chip { scroll-snap-align: start; flex: 0 0 auto; }
  .lt-chips__more { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .lt-chip, .lt-tool select { transition: none; }
}

/* ── Mobile: nút "Thể loại" + bảng chọn thể loại (tìm không dấu, Nhiều phim / A–Z) ── */
.lt-chips__all, .lt-chip--sheet { display: none; }
.lt-sheet[hidden] { display: none; }

@media (max-width: 640px) {
  .lt-chips { display: flex; align-items: center; }
  .lt-chips__all {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    max-width: 46%;
    height: 34px;
    margin-left: 16px;
    padding: 0 9px 0 8px;
    border-radius: 999px;
    border: 1px solid var(--ah-accent, #ff3b5c);
    background: var(--ah-accent-soft, rgba(255,59,92,.12));
    color: var(--ah-text, #eee);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }
  .lt-chips__all .material-icons-round { font-size: 18px; color: var(--ah-accent, #ff3b5c); }
  .lt-chips__all-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lt-chips__all-n {
    flex-shrink: 0;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(255,255,255,.1);
    color: var(--ah-text-muted, #b8b8cc);
    font-size: 10.5px;
  }
  .lt-chips__list { flex: 1 1 auto; min-width: 0; padding: 2px 16px 2px 8px; }
  .lt-chip { height: 34px; }
  .lt-chip--extra { display: none; }
  .lt-chip--sheet {
    display: inline-flex;
    border-style: dashed;
    background: transparent;
    color: var(--ah-accent, #ff3b5c);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
}

.lt-sheet { position: fixed; inset: 0; z-index: 1000; }
.lt-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  opacity: 0;
  transition: opacity .18s ease;
}
.lt-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: min(78vh, 680px);        /* cố định: lọc không làm bảng co giật */
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--ah-border, rgba(255,255,255,.08));
  background: var(--ah-surface, #13131e);
  box-shadow: 0 -12px 40px rgba(0,0,0,.5);
  transform: translateY(100%);
  transition: transform .2s cubic-bezier(.2,.8,.2,1);
  outline: none;
}
.lt-sheet.is-open .lt-sheet__backdrop { opacity: 1; }
.lt-sheet.is-open .lt-sheet__panel { transform: none; }
@media (min-width: 641px) {
  .lt-sheet__panel { left: 50%; right: auto; width: 560px; transform: translate(-50%, 100%); }
  .lt-sheet.is-open .lt-sheet__panel { transform: translate(-50%, 0); }
}
.lt-sheet__grip { width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: rgba(255,255,255,.2); }
.lt-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 16px;
  font-size: 15px;
  color: var(--ah-text, #eee);
}
.lt-sheet__x {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ah-text-muted, #b8b8cc);
  cursor: pointer;
}
.lt-sheet__x:hover, .lt-sheet__x:focus-visible { background: rgba(255,255,255,.08); outline: none; }
.lt-sheet__bar { display: flex; align-items: center; gap: 8px; padding: 0 16px 10px; }
.lt-sheet__search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--ah-border, rgba(255,255,255,.08));
  background: var(--ah-surface-2, #1b1b28);
}
.lt-sheet__search:focus-within { border-color: var(--ah-accent, #ff3b5c); }
.lt-sheet__search .material-icons-round { font-size: 18px; color: var(--ah-text-dim, #7c7c9e); }
.lt-sheet__search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ah-text, #eee);
  font: inherit;
  font-size: 16px;                 /* ≥16px: iOS không tự phóng to khi gõ */
}
.lt-sheet__sort {
  display: flex;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--ah-border, rgba(255,255,255,.08));
}
.lt-sheet__sort button {
  height: 40px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--ah-text-muted, #b8b8cc);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.lt-sheet__sort button[aria-pressed="true"] { background: var(--ah-accent, #ff3b5c); color: #fff; }
.lt-sheet__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-content: start;
  flex: 0 1 auto;
  min-height: 0;
  padding: 4px 16px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.lt-sheet__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--ah-border, rgba(255,255,255,.08));
  background: var(--ah-surface-2, #1b1b28);
  color: var(--ah-text, #eee);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.lt-sheet__item[hidden] { display: none; }
.lt-sheet__item:active { transform: scale(.98); }
.lt-sheet__item:focus-visible { outline: 2px solid var(--ah-accent, #ff3b5c); outline-offset: 2px; }
.lt-sheet__item--all { grid-column: 1 / -1; justify-content: center; font-weight: 700; }
.lt-sheet__item.is-active { border-color: var(--ah-accent, #ff3b5c); background: var(--ah-accent, #ff3b5c); color: #fff; font-weight: 700; }
.lt-sheet__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-sheet__n { flex-shrink: 0; font-size: 11px; color: var(--ah-text-dim, #7c7c9e); }
.lt-sheet__item.is-active .lt-sheet__n { color: rgba(255,255,255,.8); }
.lt-sheet__empty { margin: 0; padding: 4px 16px 20px; text-align: center; font-size: 13px; color: var(--ah-text-muted, #b8b8cc); }

@media (prefers-reduced-motion: reduce) {
  .lt-sheet__backdrop, .lt-sheet__panel { transition: none; }
}
