@import "tailwindcss";

/* ═════════════════════════════════════════════════════════════════════════════
   FlixTV design tokens
   ─────────────────────────────────────────────────────────────────────────────
   A single source of truth for colour, radius, motion and elevation.

   Design language
     • Near-monochrome charcoal base so artwork does the talking.
     • One restrained crimson accent, used only for "active" / "live" states.
     • White is the primary call-to-action colour (never the accent).
     • One radius scale (10 / 12 / 16) plus pills.
     • One easing curve for every hover, so the whole UI moves as one object.
   ═════════════════════════════════════════════════════════════════════════════ */

@theme {
  --color-bg: #08080a;
  --color-bg-soft: #0d0d11;
  --color-surface: #131318;
  --color-surface-2: #1a1a21;
  --color-surface-3: #22222b;
  --color-ink: #ffffff;
  --color-ink-soft: #a1a1aa;
  --color-ink-muted: #71717a;
  --color-ink-faint: #52525b;
  --color-line: rgba(255, 255, 255, 0.08);
  --color-line-strong: rgba(255, 255, 255, 0.16);

  --color-brand-300: #fda4b4;
  --color-brand-400: #fb7185;
  --color-brand-500: #f43f5e;
  --color-brand-600: #e11d48;
  --color-brand-700: #be123c;

  --color-gold: #f5c518;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* `next/font` injects --font-flixtv-sans / --font-flixtv-display onto <html>.
     The theme tokens below must point at those, never at themselves, otherwise
     the declaration is self-referential and resolves to the invalid value. */
  --font-sans: var(--font-flixtv-sans), ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font-flixtv-display), var(--font-flixtv-sans), ui-sans-serif, system-ui,
    sans-serif;

  --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  --shadow-card: 0 4px 20px -6px rgba(0, 0, 0, 0.65);
  --shadow-lift: 0 18px 44px -12px rgba(0, 0, 0, 0.8);
  --shadow-pill: 0 10px 30px -8px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 60px -20px rgba(244, 63, 94, 0.35);
}

/* Optional light theme. Toggled from Settings; mirrored in a cookie so the
   first server render is already correct. */
[data-theme="light"] {
  --color-bg: #f6f6f8;
  --color-bg-soft: #ffffff;
  --color-surface: #ffffff;
  --color-surface-2: #f1f1f4;
  --color-surface-3: #e6e6ea;
  --color-ink: #0a0a0c;
  --color-ink-soft: #52525b;
  --color-ink-muted: #71717a;
  --color-ink-faint: #a1a1aa;
  --color-line: rgba(0, 0, 0, 0.09);
  --color-line-strong: rgba(0, 0, 0, 0.18);
}

/* ── Base ──────────────────────────────────────────────────────────────────── */

@layer base {
  * {
    border-color: var(--color-line);
  }

  html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
    color-scheme: dark;
  }

  [data-theme="light"] html,
  html[data-theme="light"] {
    color-scheme: light;
  }

  body {
    background-color: var(--color-bg);
    color: var(--color-ink);
    font-family: var(--font-sans);
    font-feature-settings: "cv02", "cv03", "cv04", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
  }

  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
  }

  ::selection {
    background: var(--color-brand-500);
    color: #fff;
  }

  :focus-visible {
    outline: 2px solid var(--color-brand-500);
    outline-offset: 2px;
    border-radius: 4px;
  }

  /* Slim, unobtrusive scrollbars that match the surface palette. */
  * {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  }
  *::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }
  *::-webkit-scrollbar-track {
    background: transparent;
  }
  *::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
  }
  *::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.28);
  }
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */

@utility no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
  &::-webkit-scrollbar {
    display: none;
  }
}

@utility rail {
  /* Negative margin + matching padding so card hover-scaling and shadows are
     never clipped by the scroll container. */
  margin-block: -20px;
  padding-block: 20px;
}

@utility line-clamp-1x {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@utility line-clamp-2x {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@utility line-clamp-3x {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@utility line-clamp-4x {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@utility glass {
  background: color-mix(in srgb, var(--color-surface) 72%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--color-line);
}

@utility glass-strong {
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  border: 1px solid var(--color-line);
}

@utility text-shadow-hero {
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.65);
}

/* Large outlined numerals behind the "Top 10" posters. */
@utility rank-numeral {
  font-family: var(--font-display);
  font-weight: 900;
  line-height: 0.78;
  color: transparent;
  -webkit-text-stroke: 2px rgba(255, 255, 255, 0.75);
  user-select: none;
  pointer-events: none;
}

/* ── Component classes ─────────────────────────────────────────────────────── */

@layer components {
  .card-poster {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface-2);
    box-shadow: var(--shadow-card);
    transition:
      transform 0.5s var(--ease-out-quad),
      box-shadow 0.4s var(--ease-soft);
  }

  .group:hover .card-poster {
    transform: scale(1.045);
    box-shadow: var(--shadow-lift);
  }

  .card-poster img {
    transition: transform 0.55s var(--ease-out-quad);
  }
  .group:hover .card-poster img {
    transform: scale(1.06);
  }

  .hero-scrim-left {
    background: linear-gradient(
      to right,
      color-mix(in srgb, var(--color-bg) 92%, transparent) 0%,
      color-mix(in srgb, var(--color-bg) 62%, transparent) 38%,
      transparent 78%
    );
  }

  .hero-scrim-bottom {
    background: linear-gradient(
      to top,
      var(--color-bg) 0%,
      color-mix(in srgb, var(--color-bg) 88%, transparent) 18%,
      color-mix(in srgb, var(--color-bg) 46%, transparent) 40%,
      color-mix(in srgb, var(--color-bg) 10%, transparent) 60%,
      transparent 76%
    );
  }

  /* Keeps hero copy legible under a light patch of artwork and stops the
     floating navigation bar from reading against a bright backdrop. The band is
     deep enough to carry the transparent top header's controls, which sit in the
     top 64px of the hero. */
  .hero-scrim-top {
    background: linear-gradient(
      to bottom,
      color-mix(in srgb, var(--color-bg) 72%, transparent) 0%,
      color-mix(in srgb, var(--color-bg) 40%, transparent) 45%,
      transparent 90%
    );
  }

  /* Cinematic watch surface.

     The stage is a fixed-position, viewport-sized layer. Fixed positioning is what
     guarantees the two things a `w-full` block cannot: it is exactly the width of
     the initial containing block (so a provider iframe can never introduce a
     horizontal scrollbar) and it is exactly the viewport height (so the video is
     never letterboxed inside a page that has other content around it).

     `100svh` rather than `100vh` on the element that establishes the height, so
     a mobile browser's collapsing address bar cannot crop the bottom of the
     video. `overflow: hidden` then guarantees nothing inside — an overshooting
     transform on a provider overlay, a long unbroken error string — can turn
     into page scroll. */
  .watch-stage {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: #000;
    /* Both axes are clipped by the stage, so scrollbars can only ever come from
       the iframe's own content, which is itself `overflow: hidden`. */
    overflow: hidden;
    /* A horizontal swipe inside a provider's own embed should pan that embed,
       not the page. Vertical scroll is kept out for the same reason. */
    overscroll-behavior: contain;
  }

  .row-tick {
    width: 3px;
    height: 22px;
    border-radius: 2px;
    background: var(--color-brand-500);
    flex-shrink: 0;
  }

  .skeleton {
    position: relative;
    overflow: hidden;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
  }

  /* Legal prose: /terms and /privacy. Kept as plain element styles rather than a
     utility class soup so the copy stays readable in the markup. */
  .legal-prose p {
    margin: 0;
  }
  .legal-prose strong {
    color: var(--color-ink);
    font-weight: 600;
  }
  .legal-prose code {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.875em;
    padding: 0.1em 0.4em;
    border-radius: 4px;
    background: var(--color-surface-3);
    color: var(--color-ink-soft);
  }
  .legal-prose a {
    color: var(--color-ink);
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.2s var(--ease-soft);
  }
  .legal-prose a:hover {
    color: var(--color-brand-400);
  }
  .legal-prose ul {
    margin: 0;
  }
  .legal-prose li > p {
    margin: 0;
  }

  .skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
      90deg,
      transparent,
      rgba(255, 255, 255, 0.06),
      transparent
    );
    animation: flixtv-shimmer 1.6s infinite;
  }

  @keyframes flixtv-shimmer {
    100% {
      transform: translateX(100%);
    }
  }

  .animate-in-up {
    animation: flixtv-in-up 0.7s var(--ease-out-expo) both;
  }

  @keyframes flixtv-in-up {
    from {
      opacity: 0;
      transform: translateY(28px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .animate-fade-in {
    animation: flixtv-fade 0.9s var(--ease-soft) both;
  }

  @keyframes flixtv-fade {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  /* Hero cross-fade partner: the incoming frame eases up from a slight
     overscan, so a slide change reads as a slow push-in. Suppressed under
     prefers-reduced-motion by the global rule at the end of this file. */
  .animate-hero-settle {
    animation: flixtv-hero-settle 7.2s var(--ease-out-quad) both;
  }

  @keyframes flixtv-hero-settle {
    from {
      transform: scale(1.06);
    }
    to {
      transform: scale(1);
    }
  }

  .animate-pop {
    animation: flixtv-pop 0.28s var(--ease-out-expo) both;
  }

  @keyframes flixtv-pop {
    from {
      opacity: 0;
      transform: scale(0.96) translateY(4px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  .animate-spin-slow {
    animation: flixtv-spin 1.1s linear infinite;
  }

  @keyframes flixtv-spin {
    to {
      transform: rotate(360deg);
    }
  }
}

/* ── Accessibility ─────────────────────────────────────────────────────────── */

@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;
  }
}

[data-reduce-motion="true"] *,
[data-reduce-motion="true"] *::before,
[data-reduce-motion="true"] *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
