/* Grand TV - premium dark design system
   Design read: premium consumer streaming app, cinematic dark-tech language.
   One theme (dark), one accent (rose #ff2d55), one radius scale. Mobile-first. */

:root {
  --bg: #0a0a0f;
  --bg-2: #0e0e15;
  --surface: #15151f;
  --surface-2: #1c1c28;
  --surface-3: #24243200;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f6fa;
  --text-dim: #aab0c0;
  --text-mute: #757b8c;
  --ink: #0a0a0f;
  --accent: #ff2d55;
  --accent-soft: rgba(255, 45, 85, 0.16);
  --accent-text: #ff6b85;
  --accent-press: #e11d48;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-pop: 0 24px 70px rgba(0, 0, 0, 0.6);

  --appbar-h: 60px;
  --bottomnav-h: 64px;
  --maxw: 1360px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 260ms;

  --card-w: 150px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

/* Ambient background wash */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 640px at 82% -8%, rgba(255, 45, 85, 0.14), transparent 60%),
    radial-gradient(900px 560px at 8% 6%, rgba(61, 123, 255, 0.10), transparent 62%),
    var(--bg);
}

img { max-width: 100%; display: block; }
button { font-family: inherit; color: inherit; cursor: pointer; }

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --------------------------------------------------------------- loading */
.app-loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  gap: 20px;
  background: var(--bg);
}
.app-loading__mark {
  font-weight: 800;
  font-size: 30px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
}
.app-loading__mark span { color: var(--accent); }
.app-loading__bar {
  width: 180px;
  height: 3px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 0 auto;
}
.app-loading__bar span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 3px;
  background: var(--accent);
  animation: loadbar 1.1s var(--ease) infinite;
}
@keyframes loadbar {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(360%); }
}

/* --------------------------------------------------------------- appbar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(to bottom, rgba(10, 10, 15, 0.92), rgba(10, 10, 15, 0.72));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  white-space: nowrap;
}
.brand span { color: var(--accent); }

.nav--top { display: none; }
.nav__item {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav--top .nav__item:hover { color: var(--text); }
.nav--top .nav__item.is-active { color: var(--text); }
.nav--top .nav__item.is-active::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 6px;
  border-radius: 2px;
  background: var(--accent);
}

.region-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.region-btn:hover { border-color: var(--accent); }
.region-btn:active { transform: scale(0.97); }
.region-btn svg { color: var(--text-dim); }
.region-current { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------- main / views */
.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 0 calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 24px);
}
.view { animation: fadein var(--dur) var(--ease); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.view__title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 22px 16px 14px;
}
.view__title--sub { font-size: 19px; margin-top: 30px; }
.view__hint { color: var(--text-mute); margin: 0 16px 14px; font-size: 14px; }

/* --------------------------------------------------------------- hero */
.hero {
  position: relative;
  min-height: 64vh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  isolation: isolate;
}
.hero__bg {
  position: absolute;
  inset: -10%;
  z-index: -2;
  background-size: cover;
  background-position: center;
  filter: blur(46px) saturate(1.3);
  transform: scale(1.25);
  opacity: 0.55;
}
.hero__shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top, var(--bg) 4%, rgba(10, 10, 15, 0.35) 55%, rgba(10, 10, 15, 0.55) 100%),
    linear-gradient(to right, rgba(10, 10, 15, 0.85), transparent 70%);
}
.hero__body { padding: 0 16px 30px; max-width: 640px; }
.hero__eyebrow {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.hero__title {
  font-size: clamp(30px, 8vw, 60px);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.hero__sub {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 20px;
  max-width: 46ch;
}
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* --------------------------------------------------------------- buttons */
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--text); color: var(--ink); }
.btn--primary:hover { background: #fff; }
.btn--ghost { background: rgba(255, 255, 255, 0.08); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.14); }
.btn--sm { padding: 9px 16px; font-size: 14px; background: var(--surface-2); border-color: var(--border); }
.btn--sm:hover { border-color: var(--accent); }

/* --------------------------------------------------------------- rails */
.rails { padding-top: 8px; }
.rail { margin: 26px 0; }
.rail.reveal { opacity: 0; transform: translateY(18px); transition: opacity 520ms var(--ease), transform 520ms var(--ease); }
.rail.reveal.is-visible { opacity: 1; transform: none; }
.rail__head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 16px 12px; }
.rail__title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.rail__track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 16px 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.rail__track::-webkit-scrollbar { display: none; }

/* --------------------------------------------------------------- chips */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips--wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-dim);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip--active { color: var(--accent-text); background: var(--accent-soft); border-color: var(--accent); }

/* --------------------------------------------------------------- cards */
.card {
  flex: 0 0 auto;
  width: var(--card-w);
  scroll-snap-align: start;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.grid .card { width: auto; }
.card__thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 30% 20%, rgba(255, 255, 255, 0.06), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.card__thumb img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}
.card:hover .card__thumb { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow-card); }
.card__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 10, 15, 0.5);
  color: #fff;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.card__play svg { transform: translateX(1px); background: var(--accent); border-radius: 999px; padding: 12px; width: 44px; height: 44px; box-shadow: 0 8px 24px rgba(255, 45, 85, 0.4); }
.card:hover .card__play, .card:focus-visible .card__play { opacity: 1; }
.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(10, 10, 15, 0.78);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
}
.card__name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card__meta { font-size: 12px; color: var(--text-mute); }

/* --------------------------------------------------------------- grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px 14px;
  padding: 6px 16px 20px;
}

/* --------------------------------------------------------------- skeleton */
.card--skeleton { width: var(--card-w); pointer-events: none; }
.grid .card--skeleton { width: auto; }
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
}
.card--skeleton .skeleton:first-child { aspect-ratio: 16 / 10; }
.skeleton--line { height: 12px; width: 70%; margin-top: 8px; border-radius: 6px; }
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }

/* --------------------------------------------------------------- empty */
.empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--text-mute);
  text-align: center;
}
.empty svg { color: var(--text-mute); }

/* --------------------------------------------------------------- browse + search fields */
.browse__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.select { display: flex; flex-direction: column; gap: 6px; margin: 22px 16px 6px; font-size: 12px; color: var(--text-mute); font-weight: 600; }
.select select {
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  min-width: 220px;
}
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 8px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
}
.search-field:focus-within { border-color: var(--accent); }
.search-field svg { color: var(--text-mute); flex: 0 0 auto; }
.search-field input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.search-field input::placeholder { color: var(--text-mute); }
.search-field--sm { margin: 0 0 12px; padding: 10px 14px; }

/* --------------------------------------------------------------- bottom nav */
.nav--bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: linear-gradient(to top, rgba(10, 10, 15, 0.98), rgba(10, 10, 15, 0.9));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.nav--bottom .nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-mute);
}
.nav--bottom .nav__item svg { color: var(--text-mute); transition: color var(--dur) var(--ease); }
.nav--bottom .nav__item.is-active { color: var(--text); }
.nav--bottom .nav__item.is-active svg { color: var(--accent); }

/* --------------------------------------------------------------- player */
.player-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; }
.player-overlay[hidden] { display: none; }
.player-overlay__backdrop { position: absolute; inset: 0; background: rgba(5, 5, 8, 0.92); backdrop-filter: blur(8px); }
.player-overlay.is-open .player { animation: pop var(--dur) var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.99); } to { opacity: 1; transform: none; } }
.player {
  position: relative;
  width: min(100%, 1100px);
  max-height: 100dvh;
  overflow-y: auto;
  padding: 12px 14px calc(24px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}
.player::-webkit-scrollbar { display: none; }
.player__topbar { display: flex; align-items: center; gap: 12px; padding: 6px 2px 12px; }
.player__heading { flex: 1; min-width: 0; }
.player__heading h2 { font-size: 17px; font-weight: 700; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__heading p { font-size: 13px; color: var(--text-mute); margin: 2px 0 0; }
.iconbtn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.iconbtn:hover { border-color: var(--border-strong); }
.iconbtn:active { transform: scale(0.94); }
.iconbtn.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.player__stage {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.player__stage video { width: 100%; height: 100%; background: #000; }
.player__status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: 88%;
  text-align: center;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(10, 10, 15, 0.82);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.player__status[data-state="error"] { border-color: var(--accent); color: var(--accent-text); }
.spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player__controls { display: flex; gap: 10px; justify-content: center; padding: 14px 0 4px; }
.player__upnext { padding-top: 12px; }
.player__upnext h3 { font-size: 15px; font-weight: 700; margin: 6px 2px 10px; }
.player__upnext .rail__track { padding-left: 2px; padding-right: 2px; }
.player__upnext .card { width: 132px; }

/* --------------------------------------------------------------- modal / region */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: end center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(5, 5, 8, 0.8); backdrop-filter: blur(6px); }
.modal__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-pop);
  animation: sheet var(--dur) var(--ease);
}
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal__head h2 { font-size: 19px; font-weight: 700; margin: 0; }
.region-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.region-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.region-item:hover { background: var(--surface-2); }
.region-item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.region-item__flag { font-size: 22px; flex: 0 0 auto; }
.region-item__name { flex: 1; font-weight: 600; font-size: 15px; }
.region-item__count { color: var(--text-mute); font-size: 13px; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 20px);
  z-index: 80;
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-pop);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- responsive */
@media (min-width: 768px) {
  :root { --card-w: 182px; --appbar-h: 68px; }
  .nav--top { display: flex; gap: 6px; margin-left: 20px; }
  .nav--bottom { display: none; }
  .main { padding-bottom: 40px; }
  .view__title { margin-left: 32px; margin-right: 32px; }
  .view__hint { margin-left: 32px; }
  .hero { min-height: 66vh; }
  .hero__body { padding: 0 32px 44px; }
  .rail__head, .chips, .select { margin-left: 32px; margin-right: 32px; }
  .rail__track, .grid, .search-field, .browse__head { padding-left: 32px; padding-right: 32px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 24px 18px; }
  .toast { bottom: 28px; }
  .modal { place-items: center; }
  .modal__panel { border-radius: var(--radius-lg); }
  .region-current { max-width: 200px; }
}

@media (min-width: 1200px) {
  .hero { min-height: 70vh; }
  .hero__sub { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .rail.reveal { opacity: 1; transform: none; }
}
