/* Catalog layout adapted from devandres-tech/Netflix-Clone (MIT, © 2020 Andres Alcocer):
   dark theme, hero header with bottom fade, horizontal poster rows with hover zoom. */

:root {
  color-scheme: dark;
  --bg: #111111;
  --fg: #ffffff;
  --muted: #9a9a9a;
  --card: #1f1f1f;
  --accent: #e50914;
  --vip: #f5c542;
  --row-gap: 8px;
  --card-w: 140px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* Long-press on images/video must not offer "save" menus. */
img, video {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent);
}
a { color: inherit; cursor: pointer; }
.nav__brand { font-weight: 700; font-size: 1.15rem; color: var(--accent); letter-spacing: 0.02em; text-decoration: none; }
.nav__links { display: none; gap: 20px; margin-right: auto; margin-left: 32px; }
.nav__links a { text-decoration: none; color: #e5e5e5; font-size: 0.95rem; }
.nav__links a.active { color: #fff; font-weight: 700; }
.nav__right { display: flex; align-items: center; gap: 10px; }
.nav__icon { display: flex; color: #fff; }
.nav__account { position: relative; display: block; text-decoration: none; }
/* Avatar = first letter of the username on a colour picked from it. */
.nav__avatar, .profile__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  font-weight: 700;
  background: var(--avatar, #444);
  text-transform: uppercase;
}
.nav--solid { background: rgba(17, 17, 17, 0.96); }
.nav__badge {
  position: absolute;
  right: -6px;
  bottom: -6px;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--vip);
  color: #1a1200;
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 64px);
  transform: translateX(-50%);
  background: #222;
  border: 1px solid #333;
  padding: 10px 16px;
  border-radius: 6px;
  max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal__box {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: 100%;
  overflow-y: auto;
  background: #181818;
  border-radius: 10px;
  padding: 28px 22px 22px;
  text-align: center;
}
.modal__box h2 { margin: 0 0 16px; font-size: 1.3rem; }
.modal__close { position: absolute; top: 8px; right: 8px; font-size: 1.1rem; color: #aaa; background: none; border: 0; cursor: pointer; padding: 6px 10px; }
.hint { color: var(--muted); font-size: 0.85rem; }
.form__error { color: #ff6b6b; font-size: 0.9rem; margin: 0; }

input {
  font: inherit;
  color: var(--fg);
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 12px;
  width: 100%;
}

/* Pages other than home */
.page { padding: calc(env(safe-area-inset-top) + 76px) 16px 24px; }
.page__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page__title { font-size: 1.4rem; margin: 0 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 16px 10px; }
.grid .card { flex: none; }
.search input { font-size: 1.05rem; padding: 14px 16px; border-radius: 6px; }
.search { margin-bottom: 12px; }

/* Login / register pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 90px 16px 40px; }
.auth__box {
  width: 100%;
  max-width: 380px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #262626;
  border-radius: 10px;
  padding: 32px 24px;
  display: grid;
  gap: 14px;
}
.auth__box h1 { margin: 0; font-size: 1.6rem; }
.auth__box .hint { margin: -6px 0 6px; }
.auth__box label { display: grid; gap: 6px; font-size: 0.9rem; }
.auth__box label .hint { margin: 0; font-size: 0.78rem; }
.auth__links { margin: 0; text-align: center; color: var(--muted); font-size: 0.9rem; }
.auth__links a { color: #fff; text-decoration: underline; }

/* Profile */
.profile { max-width: 420px; margin: 0 auto; text-align: center; }
.profile__avatar { width: 80px; height: 80px; border-radius: 10px; font-size: 2rem; margin: 0 auto 12px; }
.profile h1 { margin: 0 0 4px; font-size: 1.4rem; }
.profile__vip { margin: 16px 0; padding: 14px; border-radius: 8px; background: var(--card); }
.profile__actions { display: grid; gap: 10px; }
.profile__actions .btn { text-align: center; text-decoration: none; }

/* Bottom tab bar on phones (like most streaming apps) */
.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(17, 17, 17, 0.97);
  border-top: 1px solid #222;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  font-size: 0.7rem;
  color: var(--muted);
  text-decoration: none;
}
.tabbar a.active { color: #fff; }
.tabbar svg { width: 22px; height: 22px; }
body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

/* "ดูต่อ" progress and popular rank on cards */
.card__progress { position: absolute; inset: auto 0 0 0; height: 4px; background: rgba(255, 255, 255, 0.25); }
.card__progress span { display: block; height: 100%; background: var(--accent); }
.card__rank {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 26px;
  padding: 2px 6px;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  background: var(--accent);
  border-bottom-right-radius: 5px;
}
.card__audio {
  position: absolute;
  right: 6px;
  bottom: 8px;
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.75);
}
.row__head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 16px; }
.row__head .row__heading { margin: 0 0 8px; padding: 0; }
.row__more { font-size: 0.85rem; color: var(--muted); text-decoration: none; }

.btn--accent { background: var(--accent); color: #fff; }
.btn--ghost { background: rgba(255, 255, 255, 0.12); color: #fff; }
.btn--vip { background: linear-gradient(135deg, #ffd76a, #e0a800); color: #1a1200; }
.btn--block { width: 100%; padding: 13px; font-size: 1rem; }
.nav .btn { padding: 6px 14px; font-size: 0.9rem; }

.vip__badge { display: inline-block; font-weight: 700; padding: 2px 10px; border-radius: 4px; background: var(--vip); color: #1a1200; margin-bottom: 10px; }
.vip__perks { text-align: left; color: #ddd; line-height: 1.9; padding-left: 20px; margin: 0 0 12px; }
/* Package choices: one card each; a single package shows as a plain price. */
.vip__plans { display: grid; gap: 8px; margin: 0 0 14px; }
.vip__plan {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  width: 100%; padding: 12px 14px; border-radius: 10px; cursor: pointer;
  font: inherit; color: #fff; text-align: left;
  background: rgba(255, 255, 255, 0.06); border: 1.5px solid rgba(255, 255, 255, 0.14);
}
.vip__plan[aria-checked="true"] { border-color: var(--vip); background: rgba(245, 197, 66, 0.12); }
.vip__plan b { font-size: 1.35rem; }
.vip__plan span { color: #ccc; }
.vip__plans--single .vip__plan { justify-content: center; cursor: default; background: none; border: 0; padding: 0; }
.vip__plans--single .vip__plan b { font-size: 2rem; }
.vip__amount { font-size: 1.6rem; font-weight: 700; margin: 0 0 12px; }
/* PromptPay QR card, styled like a Thai QR Payment slip */
.tqr { background: #fff; color: #1b1b1b; border-radius: 14px; overflow: hidden; margin: 4px 0 14px; }
.tqr__head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: #1a3a64;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-align: left;
}
.tqr__head svg { width: 30px; height: 30px; }
.tqr__body { padding: 16px 18px 18px; }
.tqr__pp {
  display: inline-flex;
  align-items: stretch;
  border: 2px solid #1a3a64;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1;
}
.tqr__pp span { background: #1a3a64; color: #fff; padding: 4px 5px; }
.tqr__pp b { color: #1a3a64; padding: 4px 6px; font-size: 1.15rem; }
.tqr__img { display: block; width: min(230px, 100%); height: auto; margin: 12px auto 6px; }
.tqr__amount { margin: 0; font-size: 1.9rem; font-weight: 700; color: #1a3a64; }
.tqr__hint { margin: 2px 0 0; color: #666; font-size: 0.88rem; }
.tqr hr { border: 0; border-top: 1px solid #e5e5e5; margin: 14px 0; }
.tqr__warn { margin: 0 0 10px; color: #e0141e; font-size: 0.9rem; line-height: 1.6; }
.tqr__note { margin: 0; color: #333; font-size: 0.88rem; line-height: 1.6; }
.qr__status { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 500; margin: 0 0 4px; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card__cover { position: relative; }
.card__free {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: #06c755;
  color: #fff;
}

.status { padding: 120px 16px; text-align: center; color: var(--muted); }

.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 4px;
  padding: 10px 22px;
  cursor: pointer;
  transition: transform 0.2s;
}
.btn:hover { transform: scale(1.05); }
.btn--primary { background: #fff; color: #000; }


/* Hero */
.hero {
  position: relative;
  height: 62vh;
  min-height: 320px;
  max-height: 640px;
  overflow: hidden;
  background: var(--bg);
}
/* Cover keeps its own aspect ratio (no cropping or zoom); every edge fades into the page background. */
/* Two nested single masks instead of mask-composite (which LINE's in-app browser ignores):
   the frame fades left/right, the image inside fades top/bottom; together every edge fades. */
.hero__frame {
  position: absolute;
  /* Start below the nav bar so the top edge has background to blend into. */
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  height: calc(100% - 56px);
  max-width: 100%;
  --fade-x: 8%;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-x), #000 calc(100% - var(--fade-x)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--fade-x), #000 calc(100% - var(--fade-x)), transparent);
}
.hero__img {
  display: block;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  /* Only a thin band at each edge blends into the background; the cover itself stays untouched. */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 78%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 78%, transparent);
}
@media (max-width: 767px) {
  /* Phones: frame hugs the cover (so the side fade lands on the cover's own edges), full banner height,
     never wider than the screen. Viewport units avoid a frame-width ⇄ image-width percentage loop.
     Dimmed slightly because the title sits over its lower part. */
  .hero__frame { top: 0; width: max-content; height: 100%; max-width: 100vw; }
  /* Flush to the top of the screen (no top fade); only the bottom blends into the rows below. */
  .hero__img {
    width: auto;
    height: 100%;
    max-width: 100vw;
    opacity: 0.85;
    -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent);
    mask-image: linear-gradient(to bottom, #000 75%, transparent);
  }
}
.hero__content { text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8); }
.hero__content { position: absolute; left: 16px; right: 16px; bottom: 18%; z-index: 2; }
.hero__title { font-size: clamp(1.6rem, 6vw, 3.4rem); margin: 0 0 16px; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
.hero__fade {
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background-image: linear-gradient(180deg, transparent, rgba(15, 15, 15, 0.61), var(--bg));
}

/* Rows */
.row { margin: 8px 0 22px; }
.row__heading { font-size: 1.05rem; font-weight: 500; margin: 0 16px 8px; }
.row__track {
  display: flex;
  gap: var(--row-gap);
  overflow-x: auto;
  overflow-y: visible;
  padding: 8px 16px 16px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.row__track::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 var(--card-w);
  cursor: pointer;
  scroll-snap-align: start;
  transition: opacity 450ms;
}
.card__cover {
  aspect-ratio: 2 / 3;
  border-radius: 5px;
  overflow: hidden;
  background: linear-gradient(160deg, #3a0d10, #141414 70%);
  transition: transform 450ms;
}
.card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
/* Title under the cover: up to two lines, then "…". */
.card__title {
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #e5e5e5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

@media (hover: hover) {
  .row__track:hover .card { opacity: 0.5; }
  .row__track .card:hover { opacity: 1; }
  .row__track .card:hover .card__cover { transform: scale(1.06); }
}

/* Banner slides crossfade; dots show which of the newest titles is up. */
/* Each slide carries its own glow tinted from its cover (--tint, set in JS), so the colour crossfades with it. */
.hero__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 900ms ease;
  --tint: #1d1d1d;
  background: radial-gradient(ellipse at 70% 40%, var(--tint), var(--bg) 70%);
}
@media (max-width: 767px) {
  .hero__slide { background: radial-gradient(ellipse at 50% 35%, var(--tint), var(--bg) 75%); }
}
.hero__slide.active { opacity: 1; }
.hero__content { transition: opacity 400ms ease; }
.hero__content.switching { opacity: 0; }
.hero__dots { position: absolute; right: 16px; bottom: 16px; z-index: 3; display: flex; gap: 6px; }
.hero__dots button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: background 300ms, width 300ms;
}
.hero__dots button.active { width: 20px; border-radius: 4px; background: #fff; }

@media (min-width: 768px) {
  :root { --card-w: 180px; }
  .nav, .row__head { padding-left: 48px; padding-right: 48px; }
  .nav__links { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 0; }
  .page { padding-left: 48px; padding-right: 48px; padding-top: 96px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 24px 14px; }
  .row__track { padding-left: 48px; padding-right: 48px; }
  .hero__content { left: 48px; max-width: 50%; }
  /* Desktop: cover sits on the right, title on the left like a streaming-service banner. */
  .hero__frame { left: auto; right: 6%; transform: none; max-width: 60%; }
  .hero__dots { right: 48px; }
}

/* Player */
.player {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  display: flex;
  flex-direction: column;
}
.player__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
}
.player__close { font: inherit; font-size: 1.3rem; color: #fff; background: none; border: 0; cursor: pointer; padding: 4px 8px; }
.player__title { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__fs { font: inherit; font-size: 1.3rem; color: #fff; background: none; border: 0; cursor: pointer; padding: 4px 8px; }
.player__stage { position: relative; flex: 1; min-height: 0; display: flex; }
.player__video { flex: 1; width: 100%; min-height: 0; background: #000; }
/* Viewer's name over the picture, moving now and then, so screen recordings can be traced. */
.player__wm {
  position: absolute;
  pointer-events: none;
  user-select: none;
  color: rgba(255, 255, 255, 0.28);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
  font-size: clamp(0.75rem, 1.6vw, 1.1rem);
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.6s;
}

/* Parts of a split title: a badge on the card, a picker under the player's title bar */
.card__parts { position: absolute; right: 6px; bottom: 6px; font-size: 0.7rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; background: rgba(0, 0, 0, 0.75); color: #fff; }
.player__parts { display: flex; gap: 8px; overflow-x: auto; padding: 0 12px 10px; scrollbar-width: none; }
.player__part { flex: none; font: inherit; font-size: 0.9rem; color: #ddd; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.player__part.is-current { color: #fff; background: var(--accent); border-color: var(--accent); }
