/* Movies Torrent — design system.
 *
 * The palette is lifted from the Flutter app's AppColors so the two read as one
 * product. The neutrals are deliberately WARM — tinted toward the brand hue
 * rather than true grey. That is what makes surfaces feel soft instead of
 * clinical, and it keeps the chrome from fighting the posters.
 */

:root {
  --brand: #EA1E41;
  --brand-deep: #B3122F;
  --brand-bright: #FF4A68;

  --bg: #FBF8F9;
  --surface: #FFFFFF;
  --surface-muted: #F4EEF0;
  --on-surface: #1B1216;
  --on-surface-muted: #75626A;
  --outline: #E9DFE2;
  --brand-wash: #FFE8ED;

  --imdb: #F5C518;
  --youtube: #FF0000;
  --seed-up: #2EA860;
  --seed-down: #E08A1E;

  --shadow-sm: 0 1px 2px rgb(27 18 22 / 0.06), 0 1px 3px rgb(27 18 22 / 0.04);
  --shadow-md: 0 4px 12px rgb(27 18 22 / 0.08), 0 2px 4px rgb(27 18 22 / 0.04);
  --shadow-lg: 0 12px 32px rgb(27 18 22 / 0.12), 0 4px 8px rgb(27 18 22 / 0.06);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --font-display: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --page-max: 1340px;
  --gutter: 20px;
  color-scheme: light;
}

/* The guard lets an explicit [data-theme="light"] win over the OS preference. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131015;
    --surface: #1D191E;
    --surface-muted: #272128;
    --on-surface: #F5F0F2;
    --on-surface-muted: #ADA0A6;
    --outline: #342D35;
    --brand-wash: #3B1420;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 12px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131015;
  --surface: #1D191E;
  --surface-muted: #272128;
  --on-surface: #F5F0F2;
  --on-surface-muted: #ADA0A6;
  --outline: #342D35;
  --brand-wash: #3B1420;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.55);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base -- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 .5em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); }
h2 { font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.6rem); }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; text-wrap: pretty; }

a { color: var(--brand); text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--brand-deep); text-decoration-color: currentColor; }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--brand); color: #fff; padding: .6rem 1rem;
  border-radius: var(--radius-sm); font-weight: 700;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; color: #fff; }

.container {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* -------------------------------------------------------------- masthead -- */

.masthead {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--outline);
}

.masthead__bar {
  display: flex; align-items: center; gap: 1rem;
  min-height: 68px; padding-block: .7rem;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.03em;
  color: var(--brand);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.wordmark:hover { color: var(--brand-deep); }

.masthead__search { flex: 1 1 auto; min-width: 0; max-width: 520px; }

.searchbox { display: flex; gap: .4rem; }
.searchbox input[type="search"] {
  flex: 1 1 auto; min-width: 0;
  font: inherit; font-size: .95rem;
  padding: .6rem .9rem;
  color: var(--on-surface);
  background: var(--surface-muted);
  border: 1px solid var(--outline);
  border-radius: 999px;
  appearance: none;
}
.searchbox input[type="search"]::placeholder { color: var(--on-surface-muted); }
.searchbox input[type="search"]:focus {
  background: var(--surface);
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.masthead__actions { display: flex; align-items: center; gap: .3rem; margin-left: auto; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--on-surface-muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--on-surface); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Genre rail under the masthead: the primary crawl path into the hub pages. */
.genre-rail {
  display: flex; gap: .45rem; overflow-x: auto;
  padding-block: .55rem; scrollbar-width: none;
  border-top: 1px solid var(--outline);
}
.genre-rail::-webkit-scrollbar { display: none; }
.genre-rail a {
  flex: 0 0 auto;
  font-size: .85rem; font-weight: 600;
  padding: .3rem .8rem;
  border-radius: 999px;
  color: var(--on-surface-muted);
  background: var(--surface-muted);
  text-decoration: none;
  white-space: nowrap;
}
.genre-rail a:hover { background: var(--brand-wash); color: var(--brand-deep); }
.genre-rail a[aria-current="page"] { background: var(--brand); color: #fff; }

/* ------------------------------------------------------------ movie grid -- */

.section { margin-block: 2.5rem; }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.1rem;
}
.section__head h2 { margin: 0; }
.section__count { color: var(--on-surface-muted); font-size: .9rem; font-weight: 500; }

/* 2 columns on a phone, and the columns multiply on wider screens rather than
 * the posters growing — YTS art stops being recognisable below ~140px wide. */
.grid {
  display: grid;
  gap: 1.3rem .9rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none; margin: 0; padding: 0;
}
@media (min-width: 520px)  { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 760px)  { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.6rem 1.1rem; } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1240px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.card { position: relative; min-width: 0; }
.card__link { display: block; text-decoration: none; color: inherit; }

.card__art {
  position: relative;
  aspect-ratio: 2 / 3;              /* fixed, so there is zero layout shift */
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-muted);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card__link:hover .card__art { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card__art img { width: 100%; height: 100%; object-fit: cover; }

/* Only rating and best quality overlay the art. Titles sit below it: posters
 * are busy, and gradient-over-text makes long titles hard to scan. */
.card__badges {
  position: absolute; inset: auto .5rem .5rem .5rem;
  display: flex; justify-content: space-between; gap: .4rem; pointer-events: none;
}
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .72rem; font-weight: 700; font-family: var(--font-display);
  padding: .2rem .5rem; border-radius: 999px;
  background: rgb(0 0 0 / 0.55); color: #fff;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.badge--rating svg { width: 11px; height: 11px; fill: var(--imdb); }
.badge--quality { background: color-mix(in srgb, var(--brand) 88%, transparent); }

.card__title {
  font-family: var(--font-display); font-weight: 600; font-size: .9rem;
  line-height: 1.3; margin: .6rem 0 .15rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta { font-size: .78rem; color: var(--on-surface-muted); }

/* ------------------------------------------------------------ pagination -- */

.pagination {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .4rem; margin-block: 2.5rem;
}
.pagination a, .pagination span {
  min-width: 42px; padding: .5rem .75rem;
  text-align: center; font-weight: 600; font-size: .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--outline);
  text-decoration: none; color: var(--on-surface);
  background: var(--surface);
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination [aria-current="page"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .is-gap { border: 0; background: none; color: var(--on-surface-muted); min-width: auto; }

/* ----------------------------------------------------------- movie page -- */

.backdrop {
  position: relative;
  min-height: 300px;
  margin-bottom: -120px;
  background-size: cover; background-position: center 20%;
}
/* The gradient fades into the page background so nothing has to be lifted with
 * a negative offset to sit "inside" it — doing that in the app silently hid the
 * top of the poster behind an opaque app bar. */
.backdrop::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--bg) 35%, transparent) 0%,
    color-mix(in srgb, var(--bg) 72%, transparent) 55%,
    var(--bg) 100%);
}

.movie { position: relative; z-index: 1; padding-top: 1rem; }

.movie__top {
  display: grid; gap: 1.6rem;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 820px) {
  .movie__top { grid-template-columns: 290px minmax(0, 1fr); gap: 2.2rem; }
}

.movie__poster {
  aspect-ratio: 2 / 3; width: 100%;
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-lg); background: var(--surface-muted);
}
.movie__poster img { width: 100%; height: 100%; object-fit: cover; }

.movie__title { margin-bottom: .3rem; }
.movie__tagline { color: var(--on-surface-muted); font-size: 1rem; margin-bottom: 1rem; }

.factbar { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin-bottom: 1.2rem; }
.fact { display: flex; align-items: center; gap: .4rem; font-size: .92rem; }
.fact svg { width: 16px; height: 16px; fill: none; stroke: var(--on-surface-muted); stroke-width: 1.8; }
.fact strong { font-family: var(--font-display); font-weight: 700; }
.fact--imdb strong { color: var(--on-surface); }
.fact--imdb svg { fill: var(--imdb); stroke: none; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.3rem; list-style: none; padding: 0; }
.chip {
  font-size: .82rem; font-weight: 600;
  padding: .3rem .75rem; border-radius: 999px;
  background: var(--surface-muted); color: var(--on-surface-muted);
  text-decoration: none;
}
.chip:hover { background: var(--brand-wash); color: var(--brand-deep); }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.5rem; }

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-display); font-weight: 700; font-size: .92rem;
  padding: .65rem 1.15rem; border-radius: 999px;
  border: 1px solid var(--outline); background: var(--surface);
  color: var(--on-surface); text-decoration: none; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.btn span { overflow: hidden; text-overflow: ellipsis; }

.btn--brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--brand:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn--trailer:hover { border-color: var(--youtube); color: var(--youtube); }
.btn--imdb:hover { border-color: var(--imdb); color: #9a7b06; }

/* ------------------------------------------------------------- downloads -- */

/* Download sits directly under the movie info, above the genres and the rest.
 * It is what people open the page for and should never need a scroll. */
.downloads { margin-block: 1.6rem; }

.torrents { display: grid; gap: .7rem; }

.torrent {
  display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1rem;
  padding: .85rem 1rem;
  background: var(--surface); border: 1px solid var(--outline);
  border-radius: var(--radius);
}
.torrent__quality {
  font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  padding: .2rem .6rem; border-radius: var(--radius-sm);
  background: var(--brand-wash); color: var(--brand-deep);
  flex-shrink: 0;
}
:root[data-theme="dark"] .torrent__quality { color: var(--brand-bright); }
.torrent__spec { font-size: .83rem; color: var(--on-surface-muted); min-width: 0; flex: 1 1 140px; }
.torrent__size { font-weight: 700; font-size: .88rem; white-space: nowrap; }
.torrent__peers { display: flex; gap: .7rem; font-size: .8rem; white-space: nowrap; }
.torrent__peers .up { color: var(--seed-up); font-weight: 700; }
.torrent__peers .down { color: var(--seed-down); font-weight: 700; }
.torrent__links { display: flex; gap: .4rem; margin-left: auto; }
.torrent__links .btn { padding: .45rem .85rem; font-size: .83rem; }

/* ------------------------------------------------------------------ cast -- */

.cast {
  display: grid; gap: 1rem .8rem; list-style: none; padding: 0; margin: 0;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}
.cast__photo {
  aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-muted); margin-bottom: .45rem;
}
.cast__photo img { width: 100%; height: 100%; object-fit: cover; }
.cast__name { font-size: .83rem; font-weight: 700; line-height: 1.25; }
.cast__role { font-size: .76rem; color: var(--on-surface-muted); line-height: 1.3; }

/* ----------------------------------------------------------- screenshots -- */

.stills { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stills img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); }

/* --------------------------------------------------------------- prose --- */

.prose { max-width: 72ch; }
.prose p { font-size: 1.02rem; }

/* ---------------------------------------------------------------- misc --- */

.breadcrumbs { font-size: .85rem; color: var(--on-surface-muted); margin-block: 1rem .4rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; padding: 0; margin: 0; }
.breadcrumbs li::after { content: "/"; margin-left: .35rem; opacity: .5; }
.breadcrumbs li:last-child::after { content: ""; }
.breadcrumbs a { color: inherit; text-decoration: none; }
.breadcrumbs a:hover { color: var(--brand); }

.notice {
  padding: .9rem 1.1rem; border-radius: var(--radius);
  background: var(--surface-muted); color: var(--on-surface-muted);
  font-size: .9rem; border: 1px solid var(--outline);
}

.empty { text-align: center; padding: 4rem 1rem; color: var(--on-surface-muted); }
.empty h2 { color: var(--on-surface); }

.site-footer {
  margin-top: 4rem; padding-block: 2.5rem;
  border-top: 1px solid var(--outline);
  background: var(--surface);
  font-size: .88rem; color: var(--on-surface-muted);
}
.site-footer__cols { display: grid; gap: 1.8rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.site-footer h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--on-surface); }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--brand); }
.site-footer__legal { margin-top: 2rem; padding-top: 1.4rem; border-top: 1px solid var(--outline); }

/* ----------------------------------------------------------------- fonts -- */
/* Google serves ONE variable file per family — the per-weight CSS entries all
 * point at the same URL. Declaring each weight separately downloaded the same
 * 32KB file four times. Two files, two weight ranges, 57KB total.
 *
 * Self-hosted rather than the Google CDN: one less DNS lookup and TLS handshake
 * on the critical path, and no third-party request to explain in the privacy
 * policy. `swap` means text paints in the fallback immediately instead of
 * blocking LCP on a font. */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/outfit-var.woff2') format('woff2-variations'),
       url('/static/fonts/outfit-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/static/fonts/manrope-var.woff2') format('woff2-variations'),
       url('/static/fonts/manrope-var.woff2') format('woff2');
}

/* ------------------------------------------------- favourites: removing -- */

.card--removable { position: relative; }

/* ⚠️ Always visible, not hover-only. A control that only appears on hover is
 * invisible on every touch device, and the app's equivalent (a long press) has
 * no web analogue that is discoverable. */
.card__remove {
  position: absolute; top: .45rem; right: .45rem; z-index: 2;
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 999px; cursor: pointer;
  background: rgb(0 0 0 / 0.58); color: #fff;
  backdrop-filter: blur(8px);
}
.card__remove:hover { background: var(--brand); }
.card__remove svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* The toast. Undo is not optional polish here: a one-tap destructive action
 * with no way back is how people lose a list they spent time building. */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  z-index: 100; display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1rem .75rem 1.15rem;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  background: var(--on-surface); color: var(--bg);
  font-size: .9rem; max-width: calc(100vw - 2rem);
  animation: toast-in .18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast button {
  font: inherit; font-weight: 700; cursor: pointer;
  background: none; border: 0; padding: .1rem .2rem;
  color: var(--brand-bright); text-decoration: underline;
}
