/* ============================================================
   Phim của Đức — lớp hoàn thiện giao diện đa thiết bị

   File này chỉ nâng bề mặt, khoảng cách và trạng thái tương tác trên
   hệ thiết kế tối / ruby hiện có. Không thay đổi cấu trúc DOM hoặc logic.
   ============================================================ */

:root {
  --polish-surface: rgba(20, 23, 29, 0.82);
  --polish-surface-strong: rgba(24, 27, 34, 0.94);
  --polish-line: rgba(255, 255, 255, 0.1);
  --polish-line-strong: rgba(255, 255, 255, 0.16);
  --polish-ruby: #df173d;
  --polish-ruby-bright: #ff526c;
  --polish-shadow-sm: 0 12px 32px -20px rgba(0, 0, 0, 0.8);
  --polish-shadow-lg: 0 28px 70px -30px rgba(0, 0, 0, 0.88);
  --polish-glow: 0 18px 46px -20px rgba(223, 23, 61, 0.5);
  --polish-radius-card: 16px;
  --polish-radius-panel: 20px;
  --polish-fast: 180ms;
  --polish-normal: 320ms;
  --polish-slow: 560ms;
  --motion-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  scroll-padding-top: calc(var(--topbar-h, 92px) + 16px);
}

body {
  overflow-x: clip;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"],
.card,
.tv-card,
.tv-row {
  touch-action: manipulation;
}

:focus-visible {
  outline-color: #fff;
  outline-width: 2px;
  outline-offset: 3px;
}

/* ---------- Thanh điều hướng ---------- */

.topbar {
  border-bottom-color: var(--polish-line);
  background: rgba(10, 11, 14, 0.9);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
}

body.page-home .topbar {
  background: linear-gradient(180deg, rgba(5, 5, 7, 0.72), rgba(5, 5, 7, 0.2) 72%, transparent);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

body.page-home .topbar--scrolled {
  border-bottom: 1px solid var(--polish-line);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
}

.brand__mark {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 8px 22px -10px rgba(0, 0, 0, 0.9);
}

.topnav a,
.nav-more__btn,
.topbar__join,
.search-toggle {
  min-height: 44px;
}

.topnav a,
.nav-more__btn {
  border-radius: 999px;
  transition: color var(--polish-fast) ease, background-color var(--polish-fast) ease, transform var(--polish-fast) var(--motion-ease);
}

.topnav a:hover,
.nav-more__btn:hover,
.topnav a.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.topbar__search {
  right: var(--search-right, 54px);
  background: rgba(18, 19, 23, 0.94);
  border-color: var(--polish-line-strong);
  box-shadow: var(--polish-shadow-sm);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.topbar__search:focus-within {
  border-color: rgba(255, 82, 108, 0.72);
  box-shadow: 0 0 0 3px rgba(223, 23, 61, 0.12), var(--polish-shadow-sm);
}

/* ---------- Nút và bộ lọc ---------- */

.btn {
  min-height: 44px;
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  transition:
    transform var(--polish-fast) var(--motion-ease),
    background-color var(--polish-fast) ease,
    border-color var(--polish-fast) ease,
    box-shadow var(--polish-normal) var(--motion-ease);
}

.chip,
.dd__btn,
.pagination button,
.bottom-nav__item,
.tab,
.icon-btn {
  transition:
    color var(--polish-fast) ease,
    background-color var(--polish-fast) ease,
    border-color var(--polish-fast) ease,
    transform var(--polish-fast) var(--motion-ease),
    box-shadow var(--polish-normal) var(--motion-ease);
}

.nav-more__menu,
.dd__pop {
  transition:
    opacity 220ms ease,
    transform 280ms var(--motion-ease),
    visibility 0s linear 280ms;
}

.nav-more.is-open .nav-more__menu,
.dd.is-open .dd__pop {
  transition:
    opacity 220ms ease,
    transform 280ms var(--motion-ease),
    visibility 0s;
}

.btn--primary,
.btn--light {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, var(--polish-glow);
}

.chip,
.dd__btn,
.mfilter__chip {
  min-height: 44px;
  border-color: var(--polish-line-strong);
  background-color: rgba(29, 32, 39, 0.8);
}

.chip:hover,
.dd__btn:hover,
.mfilter__chip:hover {
  border-color: rgba(255, 255, 255, 0.26);
  background-color: rgba(42, 46, 55, 0.92);
}

.chip.is-active {
  border-color: rgba(255, 82, 108, 0.54);
  background: rgba(223, 23, 61, 0.16);
  color: #fff;
}

.dd__pop {
  border-color: var(--polish-line-strong);
  background: rgba(25, 27, 32, 0.98);
  box-shadow: var(--polish-shadow-lg);
}

/* ---------- Hero trang chủ ---------- */

.hero__title {
  max-width: 15ch;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.35);
}

.hero__desc {
  max-width: 62ch;
  color: #d5d8de;
}

.hero__cta {
  gap: 10px;
  margin-top: 4px;
}

.hero__tag,
.flag {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(12, 14, 18, 0.72);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Quality labels need a light, opaque surface so their dark text stays legible. */
.flag.flag--quality {
  border-color: rgba(255, 255, 255, 0.78);
  background: #f5f6f8;
  color: #11141a;
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.85);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.hero-carousel {
  border-radius: var(--polish-radius-panel);
  box-shadow: 0 34px 80px -30px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.hero-flip__face {
  border-radius: var(--polish-radius-panel);
}

.hero-carousel__nav {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(8, 9, 12, 0.78);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* ---------- Danh mục và thẻ phim ---------- */

.catalog__head {
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.kicker {
  color: var(--polish-ruby-bright);
  letter-spacing: 0.13em;
}

.continue {
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--polish-radius-panel);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.012));
}

.continue__row {
  gap: 16px;
  scroll-snap-type: x proximity;
  overscroll-behavior-inline: contain;
}

.continue__row .card {
  scroll-snap-align: start;
}

.grid {
  gap: 28px 18px;
}

.card {
  border-radius: var(--polish-radius-card);
  transition: transform var(--polish-normal) var(--motion-ease), filter var(--polish-normal) ease;
}

.card__frame {
  border-radius: var(--polish-radius-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--polish-shadow-sm);
  transition: border-color var(--polish-normal) ease, box-shadow var(--polish-normal) var(--motion-ease);
}

.card__frame img {
  transform: scale(1.001);
  transition: transform 520ms var(--motion-ease);
}

.card--enter {
  animation: card-group-arrive 460ms var(--motion-ease) both;
  animation-delay: calc(var(--card-enter-i, 0) * 28ms);
}

@keyframes card-group-arrive {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.card__frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.card__title {
  margin-top: 11px;
  font-size: 0.95rem;
}

.card__meta {
  min-height: 1.35em;
  color: #adb3bd;
}

.card__progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.26);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.card__progress > span {
  background: linear-gradient(90deg, var(--accent), var(--polish-ruby-bright));
}

.search-banner,
.empty {
  border-color: var(--polish-line-strong);
  border-radius: 14px;
  background: var(--polish-surface);
}

.footer {
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.22));
}

/* ---------- Trang xem phim ---------- */

body.watch-page {
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(223, 23, 61, 0.08), transparent 62%),
    var(--bg);
}

.player-card {
  border-color: rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  box-shadow: 0 34px 90px -34px rgba(0, 0, 0, 0.96), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.quality-btn,
.quality-menu {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  background: rgba(12, 14, 18, 0.82);
}

.quality-btn {
  min-height: 40px;
}

.meta-block {
  margin-top: 24px;
  padding: 0 2px;
}

.meta-block h1 {
  text-wrap: balance;
}

.tag {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.035);
}

.episodes {
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.ep-card,
.ep-pill {
  border-color: rgba(255, 255, 255, 0.09);
  background: linear-gradient(145deg, rgba(29, 32, 39, 0.9), rgba(20, 23, 29, 0.82));
  box-shadow: 0 10px 30px -24px rgba(0, 0, 0, 0.9);
}

.ep-card.is-active,
.ep-pill.is-active {
  border-color: rgba(255, 82, 108, 0.58);
  background: linear-gradient(145deg, rgba(223, 23, 61, 0.2), rgba(92, 9, 27, 0.13));
  box-shadow: 0 0 0 1px rgba(223, 23, 61, 0.08), var(--polish-glow);
}

.sidebar {
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--polish-radius-panel);
  background: linear-gradient(160deg, rgba(27, 30, 37, 0.96), rgba(14, 16, 21, 0.97));
  box-shadow: var(--polish-shadow-lg);
}

.tabs {
  background: rgba(8, 10, 13, 0.48);
}

.tab {
  min-height: 52px;
}

.ep-card,
.ep-pill {
  transition:
    transform var(--polish-fast) var(--motion-ease),
    color var(--polish-fast) ease,
    background-color var(--polish-normal) ease,
    border-color var(--polish-fast) ease,
    box-shadow var(--polish-normal) var(--motion-ease);
}

.tab.is-active {
  color: #fff;
  border-bottom-color: var(--polish-ruby-bright);
}

.field input,
.chat-input input {
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(8, 10, 14, 0.76);
}

.field input:focus,
.chat-input input:focus {
  border-color: rgba(255, 82, 108, 0.66);
  box-shadow: 0 0 0 3px rgba(223, 23, 61, 0.12);
}

/* ---------- Dialog, bottom sheet và màn tìm kiếm mobile ---------- */

.room-dialog__body,
.cinfo__panel,
.sheet__panel {
  border-color: var(--polish-line-strong);
  background: linear-gradient(155deg, rgba(26, 29, 36, 0.99), rgba(12, 14, 18, 0.99));
  box-shadow: var(--polish-shadow-lg);
}

.sheet__panel {
  border-radius: 24px 24px 0 0;
}

.bottom-nav {
  border-top-color: rgba(255, 255, 255, 0.11);
  background: rgba(10, 12, 16, 0.9);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
  box-shadow: 0 -16px 40px -26px rgba(0, 0, 0, 0.9);
}

.bottom-nav__item {
  min-width: 64px;
  min-height: 48px;
  border-radius: 12px;
}

.sheet__backdrop { transition: opacity 220ms ease; }
.sheet__panel { transition: transform 340ms var(--motion-ease); }

.bottom-nav__item.is-active {
  background: rgba(223, 23, 61, 0.14);
  color: #fff;
}

.msearch,
.msearch__bar {
  background-color: #0d0f13;
}

/* ---------- Desktop có chuột ---------- */

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    transform: translateY(-1px);
  }

  .btn:active {
    transform: translateY(0) scale(0.98);
  }

  .card:hover {
    transform: translateY(-3px);
    filter: brightness(1.04);
  }

  .card:hover .card__frame img { transform: scale(1.045); }

  .card:hover .card__frame {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 28px 58px -28px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(223, 23, 61, 0.14);
  }

  .ep-card:hover {
    transform: translateY(-2px);
  }
}

.card:active { transform: scale(0.985); }
.chip:active,
.dd__btn:active,
.pagination button:active,
.bottom-nav__item:active,
.icon-btn:active { transform: scale(0.96); }

/* ---------- Tablet ---------- */

@media (min-width: 769px) and (max-width: 1100px) {
  .shell {
    width: min(calc(100% - 48px), 980px);
  }

  .hero__grid {
    grid-template-columns: minmax(0, 1fr) minmax(250px, 36vw);
    gap: 38px;
  }

  .catalog {
    padding-bottom: 72px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .watch-shell {
    width: min(100% - 48px, 980px);
  }
}

/* ---------- Điện thoại ---------- */

@media (max-width: 768px) {
  :root {
    --polish-radius-card: 13px;
    --polish-radius-panel: 18px;
  }

  html {
    scroll-padding-top: calc(var(--topbar-h, 60px) + 12px);
  }

  .shell {
    width: min(calc(100% - 28px), 680px);
  }

  .topbar {
    -webkit-backdrop-filter: blur(16px) saturate(1.1);
    backdrop-filter: blur(16px) saturate(1.1);
  }

  body.page-home .hero {
    padding-bottom: 0;
  }

  .hero__grid {
    gap: 22px;
  }

  body.page-home .hero__poster {
    width: 100%;
    margin: 0;
  }

  .hero__title {
    max-width: 18ch;
    min-height: auto;
    margin-bottom: 10px;
  }

  .hero__desc {
    color: #cbd0d8;
    line-height: 1.62;
  }

  .hero__cta {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    width: 100%;
  }

  .hero__cta .btn {
    width: 100%;
    padding-inline: 12px;
  }

  .catalog {
    padding-top: 20px;
    padding-bottom: 56px;
  }

  .catalog__head {
    align-items: start;
    margin-bottom: 22px;
    padding-bottom: 14px;
  }

  .continue {
    margin-inline: -6px;
    padding: 16px 12px;
  }

  .continue__row {
    gap: 12px;
    padding-right: 12px;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 12px;
  }

  .card__title {
    margin-top: 9px;
    font-size: 0.9rem;
  }

  .card__meta {
    font-size: 0.74rem;
  }

  .watch-shell {
    width: calc(100% - 24px);
    padding-top: 12px;
  }

  body.watch-page .topbar__in {
    gap: 8px;
  }

  body.watch-page .topnav--solo {
    margin-left: auto;
  }

  body.watch-page .topnav--solo a {
    min-height: 44px;
    padding-inline: 10px;
    white-space: nowrap;
  }

  body.watch-page .topbar__in > .account-button {
    max-width: 112px;
    padding-inline: 9px;
  }

  .crumbs {
    margin-bottom: 10px;
  }

  .player-card {
    border-radius: 12px;
  }

  .meta-block {
    margin-top: 18px;
  }

  .episodes {
    margin-top: 24px;
    padding-top: 20px;
  }

  .sidebar {
    border-radius: 16px;
  }

  .sheet__panel {
    padding-inline: max(18px, env(safe-area-inset-left));
  }
}

@media (max-width: 560px) {
  body.watch-page .brand__word {
    display: none;
  }

  body.watch-page .topbar__in > .account-button {
    max-width: 108px;
  }
}

@media (max-width: 390px) {
  .shell {
    width: calc(100% - 24px);
  }

  .hero__cta {
    grid-template-columns: 1fr;
  }

  .grid {
    gap-inline: 10px;
  }

  .continue {
    margin-inline: -4px;
  }

}

@media (max-height: 560px) and (orientation: landscape) {
  .hero {
    padding-block: 24px 36px;
  }

  .hero__grid {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 30vw);
    gap: 28px;
  }

  .hero__poster {
    order: 2;
    width: min(190px, 30vw);
    margin: 0;
  }

  .hero__info {
    order: 1;
  }

  .hero__desc {
    -webkit-line-clamp: 2;
    min-height: auto;
  }
}

/* ---------- TV 10-foot ---------- */

.tv-page .tv-header__in {
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 1rem;
  background: rgba(13, 15, 19, 0.76);
  box-shadow: 0 22px 60px -34px rgba(0, 0, 0, 0.9);
}

.tv-page .tv-brand__mark {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.13), 0 14px 32px -18px #000;
}

.tv-page .tv-btn {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(31, 35, 43, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tv-page .tv-btn--primary {
  border-color: transparent;
  background: linear-gradient(135deg, #e21b43, #b70e2d);
  box-shadow: 0 18px 40px -18px rgba(226, 27, 67, 0.68);
}

.tv-page .tv-hero {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 1.25rem;
  box-shadow: 0 34px 90px -40px rgba(0, 0, 0, 0.96);
}

.tv-page .tv-hero__shade {
  background:
    linear-gradient(90deg, rgba(8, 9, 12, 0.97) 0%, rgba(8, 9, 12, 0.68) 44%, rgba(8, 9, 12, 0.08) 80%),
    linear-gradient(0deg, rgba(8, 9, 12, 0.98) 3%, rgba(8, 9, 12, 0) 58%);
}

.tv-page .tv-card__frame {
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 22px 52px -28px rgba(0, 0, 0, 0.94);
}

.tv-page .tv-card:focus-visible,
.tv-page .tv-card:focus {
  transform: scale(1.055) translateY(-0.25rem);
  outline-color: #fff;
  box-shadow: 0 30px 72px -28px rgba(0, 0, 0, 0.98), 0 0 0 0.18rem rgba(223, 23, 61, 0.85);
}

.tv-page .tv-dialog {
  border-color: rgba(255, 255, 255, 0.16);
  border-radius: 1.2rem;
  background: linear-gradient(155deg, rgba(28, 31, 39, 0.99), rgba(13, 15, 19, 0.99));
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.96);
}

body.tv-mode .player-card {
  border-radius: 1rem;
  box-shadow: 0 36px 96px -36px rgba(0, 0, 0, 0.98);
}

body.tv-mode .sidebar {
  border-left-color: rgba(255, 255, 255, 0.13);
  background: linear-gradient(160deg, rgba(29, 32, 40, 0.99), rgba(11, 13, 17, 0.99));
}

/* ---------- Ít chuyển động ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .btn,
  .card,
  .card__frame,
  .card img,
  .ep-card,
  .ep-pill,
  .tv-page .tv-card,
  .tv-page .tv-btn {
    transition: none !important;
  }

  .card--enter { animation: none !important; }

  .btn:hover,
  .card:hover,
  .ep-card:hover,
  .tv-page .tv-card:focus-visible,
  .tv-page .tv-card:focus {
    transform: none !important;
  }
}

@media (forced-colors: active) {
  .card__frame,
  .continue,
  .sidebar,
  .player-card,
  .tv-page .tv-hero,
  .tv-page .tv-card__frame {
    border: 1px solid CanvasText;
  }
}
