/* Quảng cáo, footer, điều hướng di động, responsive, tinh chỉnh mobile & banner cập nhật (phần 9/9, tách từ main.css). */
/* Thứ tự nạp (cascade) của bộ: base → hero → cards → movie → watch → account → categories → search → chrome → motion. */
/* ============ Quảng cáo ============ */
.ad-slot { margin: var(--space-lg) 0; display: flex; flex-direction: column; gap: 8px; }
.ad-slot .ad-item { display: block; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.ad-slot .ad-item img { width: 100%; aspect-ratio: 960 / 120; object-fit: cover; }
.ad-sidebar { align-self: stretch; }
.ad-sidebar .ad-item img { aspect-ratio: 160 / 600; }

/* ============ Footer ============ */
.site-footer { background: var(--bg-secondary); margin-top: var(--space-xl); }
.site-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-sm) var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
}
.footer-nav { display: flex; flex-wrap: wrap; gap: var(--space-md); }
.footer-nav a { color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.footer-nav a:hover { color: var(--gold-bright); }
.footer-copy { color: var(--text-secondary); font-size: 12px; }
.footer-tagline { color: rgba(255, 220, 161, 0.8); font-size: 12px; }

/* ============ Điều hướng di động ============ */
.bottom-nav { display: none; }

/* ============ Responsive ============ */
@media (max-width: 1023px) {
  .watch-layout { grid-template-columns: 1fr; }
  .ad-sidebar { display: none; }
  .movie-hero-grid { grid-template-columns: 180px 1fr; gap: var(--space-lg); }
  .hero { min-height: 520px; }
}

@media (max-width: 767px) {
  :root { --gutter: 1rem; --margin: 1rem; }
  .main-nav { display: none; }
  .header-username { display: none; }
  /* Tìm kiếm qua icon header (/tim-kiem) — không còn thanh tìm kiếm dưới header */
  /* né bottom-nav (62px + safe-area thực trên iPhone nhờ viewport-fit=cover) */
  .site-main { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 60;
    background: rgba(14,14,14,0.97);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 10px 0 12px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    min-height: 62px;
    justify-content: center;
  }
  .bottom-nav-item.is-active { color: var(--gold); }
  .bottom-nav-item:hover { color: var(--gold); }

  .search-form { flex-direction: column; }
  .movie-hero-grid { grid-template-columns: 1fr; }
  .movie-poster-frame { max-width: none; width: 100%; } /* ảnh dẫn mắt full-width như spotlight */
  .hero { min-height: 420px; }
  .shelf-row { grid-auto-columns: minmax(128px, 42vw); }
  .movie-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
  .continue-row, .continue-grid { grid-template-columns: 1fr 1fr; }
  .watch-intro-thumb { width: 96px; }
  .btn { min-height: 44px; }
  .page-btn { min-width: 44px; min-height: 44px; }
}

/* Giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.continue-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.continue-title-row .card-title { min-width: 0; }
.continue-ep { font-size: 11px; line-height: 14px; color: var(--gold-bright); flex-shrink: 0; font-weight: 500; }

/* ============================================================
   Mobile UX — tinh chỉnh theo tham chiếu allshorts.net (26/11/2026)
   Nguyên tắc: nội dung lên trước, chrome gọn, danh sách tập pill-grid,
   breadcrumb 1 dòng, hero chức năng thu nhỏ. Chỉ áp dụng ≤767px —
   desktop giữ nguyên spec Stitch đã duyệt.
   ============================================================ */
@media (max-width: 767px) {
  /* --- Header một hàng gọn theo Stitch mobile (h-14 = 56px) --- */
  .site-header-inner { gap: var(--space-sm); height: 56px; }
  .brand-logo { height: 32px; }
  .brand-name { font-size: 13px; letter-spacing: 0.04em; white-space: nowrap; }
  .brand-tag { display: none; }
  .header-actions { gap: 6px; }
  .header-actions .btn { min-height: 36px; padding: 6px 12px; }

  /* --- Breadcrumb một dòng cuộn ngang (trước đây xuống 2–4 dòng) --- */
  .breadcrumb, .breadcrumb-hero {
    display: flex;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .breadcrumb::-webkit-scrollbar, .breadcrumb-hero::-webkit-scrollbar { display: none; }
  .breadcrumb .is-current, .breadcrumb-hero .is-current {
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* --- Hero trang chức năng nén theo Stitch mobile (title 20-24px) --- */
  .page-title-hero { font-size: clamp(20px, 6vw, 24px); line-height: 1.25; }
  .search-hero { padding: var(--space-md) var(--gutter); }
  .search-hero-inner { gap: var(--space-md); }
  .search-version-badge {
    font-size: 10px;
    padding: 3px 10px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Omnisearch một hàng như Stitch mobile: icon + input + submit */
  .omnisearch-inner { flex-direction: row; }
  .omnisearch-actions .omnisearch-prompt-chip { display: none; }
  .omnisearch-submit { padding: 8px 12px; font-size: 13px; }

  /* --- Chi tiết phim: poster thu gọn + CTA full-width --- */
  .movie-hero-inner { padding: var(--space-md) var(--gutter); }
  .movie-actions { display: grid; grid-template-columns: 1fr; gap: 10px; } /* track 1fr: không co theo max-content của nút */
  .movie-actions .btn { width: 100%; }
  .movie-poster-col { align-items: stretch; } /* poster full-width + quickbar dãn theo (cần cho layout ảnh-trên-cùng) */

  /* --- Lưới số tập mobile: nút nhỏ hơn --- */
  .ep-grid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }

  /* --- Trang xem phim: topbar một hàng --- */
  .watch-topbar { padding: var(--space-xs) var(--gutter); }

  /* --- Rail cuộn ngang: ẩn scrollbar, thêm scroll-snap --- */
  .shelf-row {
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--gutter);
  }
  .shelf-row::-webkit-scrollbar { display: none; }
  .shelf-row > * { scroll-snap-align: start; }
  .genre-pill-bar { scrollbar-width: none; scroll-snap-type: x proximity; }
  .genre-pill-bar::-webkit-scrollbar { display: none; }
  .genre-pill-bar .genre-pill { scroll-snap-align: start; }

  /* ============================================================
     Audit mobile 27/11/2026 — nén hero, ẩn chrome trang trí,
     vùng chạm đạt chuẩn. Desktop (≥768px) giữ nguyên spec Stitch.
     ============================================================ */

  /* --- Hero trang chủ: nội dung chính lên trước, bỏ khối trang trí --- */
  .hero-content { padding: 64px var(--gutter) 24px; }
  .hero-badge-sub { display: none; }
  .hero-desc { -webkit-line-clamp: 2; }
  /* CTA chính full-width, hai nút phụ chia đôi hàng dưới */
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero-actions .btn { width: 100%; }
  .hero-actions .btn:first-child { grid-column: 1 / -1; }
  .hero-subrow { margin-top: var(--space-md); }

  /* --- Spotlight /the-loai mobile: ẢNH TRÊN CÙNG, dưới là giới thiệu + nút xem --- */
  .catalog-spotlight-art { order: -1; } /* ảnh dẫn mắt, text + CTA theo sau (yêu cầu chủ sở hữu 28/11) */
  .catalog-spotlight-body { padding: var(--space-md); gap: var(--space-md); }
  .catalog-spotlight-desc { -webkit-line-clamp: 2; }
  /* hai nút cạnh nhau min-content ~390px tràn cả khối ở ≤420px — xếp dọc full-width
     (cùng pattern CTA full-width của movie-actions/hero-actions) */
  .catalog-spotlight-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }
  .catalog-spotlight-actions .btn { width: 100%; }
  .catalog-spotlight-actions .inline-form { display: contents; } /* form không cản grid track */

  .catalog-head .page-kicker-row { display: none; }
  .search-version-badge,
  .search-quickpills { display: none; }
  .search-hero .gold-word { display: none; }
  .search-hero { padding: var(--space-md) var(--gutter) var(--space-sm); }
  .catalog-filterbar { margin-bottom: var(--space-md); }

  /* --- Vùng chạm đạt chuẩn (≥44px hoặc mở rộng vô hình) --- */
  .continue-close { width: 32px; height: 32px; margin: -4px -6px -4px auto; }
  .shelf-more { padding: 8px 2px; }
  .collections-more { padding: 8px 4px; }
  .breadcrumb a, .breadcrumb-hero a { padding: 6px 2px; }
  .chip { min-height: 36px; }
  .genre-pill { padding: 11px 16px; }
  .ad-banner-chip { font-size: 11px; }

  /* --- Cấm zoom khi focus input: iOS Safari tự zoom ô nhập có font-size
     <16px — mọi ô nhập trên mobile phải ≥16px (meta viewport + gesture
     events trong motion.js lo pinch/double-tap). Liệt kê type để hoà
     specificity với .form-field input[type="…"] của account.css và thắng
     theo cascade (chrome.css nạp sau account.css). --- */
  .form-field input[type="text"], .form-field input[type="password"],
  .form-field input[type="number"], .form-field input[type="search"],
  .form-field input[type="url"], .form-field input[type="email"],
  .form-field input[type="tel"], .form-field select, .form-field textarea,
  .omnisearch input[type="search"],
  .comment-composer textarea { font-size: 16px; }

  /* --- Vòng 2 review (27/11): gọn footer trùng nav, tiêu đề thẻ 2 dòng, auth nhỏ gọn --- */
  .site-footer { display: none; } /* bottom-nav đã phủ điều hướng — footer chỉ lặp lại link */
  .card-title h3 {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .auth-card { padding: var(--space-lg); }
  .comments-section { padding-inline: var(--gutter); }
  .empty-state .btn { margin-top: 6px; }

  /* --- Vòng 3 review (27/11): mật độ thông tin + thứ tự nội dung --- */
  /* Tag xu hướng: cuộn nội bộ không hiện scrollbar + vệt mờ cạnh phải gợi ý còn thẻ */
  .trending-tags { scrollbar-width: none; }
  .trending-tags::-webkit-scrollbar { display: none; }
  .trending-tags {
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  }
  /* Dòng đếm còn lại sau khi ẩn khối lọc giả — bỏ vỏ card cho nhẹ */
  .catalog-filterbar { padding: 0; background: none; box-shadow: none; margin-bottom: var(--space-md); }
  /* Hero: tên tập 1 lặp thông tin trang chi tiết — bỏ bớt metadata (ẩn cả dấu chấm đứng trước) */
  .hero-ep-name, .hero-ep-dot { display: none; }
  /* Nút xoá continue-card: vùng chạm hiệu dụng 44px qua hit-area vô hình */
  .continue-close { position: relative; }
  .continue-close::before { content: ''; position: absolute; inset: -6px; }
  /* Chi tiết phim mobile (yêu cầu chủ 28/11): bỏ breadcrumb + tag thể loại cho gọn.
     Thứ tự: TÊN PHIM → banner ảnh (note số tập) → nút xem → mô tả → thông số */
  body.movie-page .breadcrumb-hero { display: none; }
  .movie-hero-grid .chip-row { display: none; }
  /* stretch: rule gốc có align-items:start (cho grid 2 cột desktop) — flex dọc cần
     con dãn full hàng, nếu không mọi khối co theo content (nút xem 186px) */
  .movie-hero-grid { display: flex; flex-direction: column; align-items: stretch; }
  .movie-info-col { display: contents; }
  .movie-title { order: 1; }
  .movie-hero-grid > .movie-poster-col { order: 2; }
  .movie-actions { order: 3; }
  .movie-info-col > div:has(> .movie-desc) { order: 4; }
  /* Tài khoản: card gọn hơn trên mobile */
  .account-card { padding: var(--space-md); }
  .account-row { margin-bottom: var(--space-md); }
}

/* Nút hiện/ẩn mật khẩu (app.js bọc input trong .pw-wrap) */
.pw-wrap { position: relative; display: block; width: 100%; }
.form-field .pw-wrap input { width: 100%; padding-right: 44px; }
.pw-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.pw-toggle:hover { color: var(--gold-bright); }

/* Badge không xuống dòng khi bảng/hàng hẹp */
.badge { white-space: nowrap; }

/* Số tập tách riêng khỏi tiêu đề trang xem — không bị ellipsis che khi tên phim dài */
.watch-topbar-ep {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  white-space: nowrap;
}

/* ============ Banner cập nhật (service worker) ============ */
.update-banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 90;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: 12px;
  background: rgba(14, 14, 14, 0.97); border: 1px solid var(--gold);
  color: var(--text); font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 32px);
  min-width: 360px; /* desktop: thanh cân đối, chữ trái — CTA phải (span flex:1) */
}
.update-banner-close {
  display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer;
}
.update-banner-close:hover { color: var(--text); background: var(--interactive); }

/* Text chiếm phần còn lại của thanh (đẩy CTA sát mép phải), 1 dòng + ellipsis khi hẹp */
.update-banner > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.update-banner .btn, .update-banner-close { flex-shrink: 0; }

@media (max-width: 767px) {
  /* Thanh mảnh trải dài gần hết chiều ngang, né bottom-nav (62px + safe-area) */
  .update-banner {
    left: 10px; right: 10px; transform: none;
    max-width: none;
    min-width: 0; /* bỏ min-width desktop 360px — màn nhỏ hơn 360px không bị tràn ngang */
    padding: 6px 6px 6px 14px; border-radius: 10px;
    gap: 10px; font-size: 13px;
    bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .update-banner .btn { min-height: 30px; padding: 4px 12px; }
  .update-banner-close { width: 26px; height: 26px; }
}
