:root {
  --bg: #141414;
  --fg: #e5e5e5;
  --muted: #a3a3a3;
  --accent: #e50914;
  --card-radius: 4px;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}
body.no-scroll { overflow: hidden; }

button { font: inherit; cursor: pointer; }

.brand {
  color: var(--accent);
  font-weight: 900;
  font-size: 1.8rem;
  letter-spacing: 0.02em;
  text-decoration: none;
}
.brand--large { font-size: 2.6rem; position: absolute; top: 24px; left: 4%; }

.btn {
  border: 0;
  border-radius: var(--card-radius);
  padding: 0.6rem 1.4rem;
  font-weight: 600;
  font-size: 1rem;
}
.btn--primary { background: var(--accent); color: white; }
.btn--primary:hover { background: #c11119; }
.btn--play { background: white; color: black; }
.btn--play:hover { background: rgba(255, 255, 255, 0.75); }
.btn--secondary { background: rgba(109, 109, 110, 0.7); color: white; }
.btn--secondary:hover { background: rgba(109, 109, 110, 0.4); }
.btn--ghost { background: transparent; color: var(--fg); padding: 0.4rem 0.6rem; font-size: 0.9rem; }
.btn--ghost:hover { color: white; text-decoration: underline; }

/* ---------- Login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.4) 60%, rgba(0, 0, 0, 0.85)),
    radial-gradient(ellipse at 30% 20%, #3b0a0d, transparent 60%),
    radial-gradient(ellipse at 80% 90%, #1b1b3a, transparent 50%),
    #000;
}
.login__card {
  width: min(420px, 92vw);
  background: rgba(0, 0, 0, 0.75);
  padding: 3rem 3.5rem;
  border-radius: var(--card-radius);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login__card h1 { margin: 0 0 0.5rem; font-size: 2rem; color: white; }
.login__card input {
  background: #333;
  border: 0;
  border-radius: var(--card-radius);
  padding: 1rem;
  color: white;
  font-size: 1rem;
}
.login__card input:focus { outline: 2px solid #8c8c8c; background: #454545; }
.login__card .btn { padding: 0.9rem; margin-top: 1rem; }
.login__error { color: #e87c03; margin: 0; font-size: 0.9rem; }

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 4%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  transition: background 0.3s;
}
.topbar--solid { background: var(--bg); }
.topbar__right { display: flex; align-items: center; gap: 1rem; }
.topbar__user { color: var(--muted); font-size: 0.9rem; }

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.6);
  padding: 0.35rem 0.6rem;
}
.search svg { width: 18px; height: 18px; fill: white; }
.search input {
  background: transparent;
  border: 0;
  outline: 0;
  color: white;
  width: min(240px, 40vw);
  font-size: 0.95rem;
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  height: 80vh;
  min-height: 420px;
  background-size: cover;
  background-position: center top;
  display: flex;
  align-items: center;
}
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(77deg, rgba(0, 0, 0, 0.75), transparent 70%),
    linear-gradient(to top, var(--bg), transparent 30%);
}
.hero__content { position: relative; z-index: 1; padding: 0 4%; max-width: 640px; }
.hero__content h1 { font-size: clamp(2rem, 5vw, 3.8rem); margin: 0 0 1rem; text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.45); }
.hero__content p {
  font-size: 1.1rem;
  line-height: 1.4;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.45);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero__actions { display: flex; gap: 0.8rem; margin-top: 1.5rem; }

/* ---------- Rows ---------- */

.rows { position: relative; z-index: 1; margin-top: -8vh; padding-bottom: 4rem; }
.hero[hidden] + .rows { margin-top: 0; padding-top: 6rem; }
.row { margin-bottom: 2.5rem; }
.row h2 { font-size: 1.3rem; margin: 0 4% 0.6rem; }
.row__track {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem 4% 1rem;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.row__track::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 auto;
  width: clamp(120px, 14vw, 200px);
  aspect-ratio: 2 / 3;
  position: relative;
  border: 0;
  padding: 0;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: linear-gradient(135deg, #2b2b2b, #1a1a1a);
  scroll-snap-align: start;
  transition: transform 0.25s, box-shadow 0.25s;
}
.card:hover, .card:focus-visible {
  transform: scale(1.08);
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  outline: none;
}
.card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.8rem;
  text-align: center;
  font-weight: 700;
  color: var(--fg);
}

/* ---------- Search ---------- */

.search-results { padding: 6rem 4% 4rem; }
.search-results h2 { font-weight: 400; color: var(--muted); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.2rem 0.6rem;
}
.grid .card { width: 100%; }

.empty { padding: 8rem 4%; color: var(--muted); font-size: 1.1rem; }

/* ---------- Modal ---------- */

.modal { position: fixed; inset: 0; z-index: 20; overflow-y: auto; padding: 2rem 1rem; }
.modal__backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); }
.modal__card {
  position: relative;
  max-width: 850px;
  margin: 0 auto;
  background: #181818;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}
.modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: #181818;
  color: white;
}
.modal__hero {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000 center / cover;
  display: flex;
  align-items: flex-end;
}
.modal__hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #181818, transparent 50%);
}
.modal__hero-content { position: relative; z-index: 1; padding: 0 3rem 2rem; }
.modal__hero-content h2 { font-size: 2.4rem; margin: 0 0 1rem; }
.modal__body {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  padding: 0 3rem 3rem;
  line-height: 1.5;
}
.meta { color: #46d369; font-weight: 600; margin-top: 0; }
.tagline { font-style: italic; color: var(--muted); }
.modal__credits { margin: 0; font-size: 0.9rem; }
.modal__credits dt { color: var(--muted); }
.modal__credits dd { margin: 0 0 0.8rem; word-break: break-word; }

@media (max-width: 700px) {
  .modal__body { grid-template-columns: 1fr; padding: 0 1.5rem 2rem; }
  .modal__hero-content { padding: 0 1.5rem 1.5rem; }
  .topbar__user { display: none; }
}

/* ---------- Player ---------- */

.player { position: fixed; inset: 0; z-index: 30; background: black; }
.player video { width: 100%; height: 100%; }
.player__back {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 1;
  border: 0;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--card-radius);
  font-size: 1rem;
}

/* ---------- Watch progress ---------- */

.progress {
  display: block;
  height: 4px;
  background: rgba(128, 128, 128, 0.6);
  overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--accent); }
.card__progress { position: absolute; left: 8px; right: 8px; bottom: 8px; border-radius: 2px; }

.modal__actions { display: flex; gap: 0.8rem; }
.modal__progress {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--fg);
}
.modal__progress .progress { width: min(260px, 40vw); }

/* ---------- Downloads ---------- */

.downloads { max-width: 640px; margin-top: 10vh; padding: 2rem 2.5rem 2.5rem; }
.downloads h2 { margin: 0 0 0.4rem; }
.downloads__hint { color: var(--muted); margin: 0 0 1.5rem; font-size: 0.9rem; }
.downloads__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.2rem; }
.download__form { display: flex; gap: 0.5rem; }
.download__url {
  flex: 1;
  min-width: 0;
  background: #333;
  border: 0;
  border-radius: var(--card-radius);
  padding: 0.8rem 1rem;
  color: white;
  font-size: 0.95rem;
}
.download__url:focus { outline: 2px solid #8c8c8c; background: #454545; }
.download__url:read-only { background: #222; color: var(--muted); outline: none; }
.download__remove {
  flex: 0 0 auto;
  width: 40px;
  border: 0;
  border-radius: var(--card-radius);
  background: #333;
  color: white;
}
.download__remove:hover { background: #454545; }
.download__status { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.5rem; font-size: 0.85rem; color: var(--muted); }
.download__bar { flex: 1; border-radius: 2px; }
.download__bar > span { width: 0; transition: width 0.4s; }
.download__text { flex: 0 0 auto; min-width: 9rem; text-align: right; }
.download--done .download__bar > span { background: #46d369; }
.download--done .download__text { color: #46d369; }
.download--error .download__text { color: #e87c03; }
.download--indeterminate .download__bar > span { width: 30% !important; animation: indeterminate 1.2s linear infinite; }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
