:root {
  --bg-0: #eef2f6;
  --bg-1: #e2e8f0;
  --ink: #15202b;
  --ink-soft: #4b5c6b;
  --line: rgba(21, 32, 43, 0.12);
  --accent: #c81e3a;
  --accent-deep: #a3152d;
  --surface: rgba(255, 255, 255, 0.78);
  --watched: #0f766e;
  --shadow: 0 18px 40px rgba(21, 32, 43, 0.1);
  --radius: 14px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--bg-0);
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1100px 560px at 8% -8%, rgba(200, 30, 58, 0.12), transparent 55%),
    radial-gradient(900px 480px at 92% 4%, rgba(15, 118, 110, 0.1), transparent 50%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 50%, #d8e0ea);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.site-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 1.5rem;
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 720px) {
  .site-header {
    grid-template-columns: 1.4fr 0.8fr;
    align-items: end;
    padding-top: 3.25rem;
  }
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 4.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 0.95;
  animation: rise 0.7s ease both;
}

.tagline {
  margin: 0.55rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  font-weight: 500;
  color: var(--ink-soft);
  animation: rise 0.7s ease 0.08s both;
}

.lede {
  margin: 0.75rem 0 0;
  max-width: 34rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  animation: rise 0.7s ease 0.14s both;
}

.progress-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  animation: rise 0.7s ease 0.18s both;
}

.progress-label {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.progress-value {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
}

.progress-bar {
  margin-top: 0.75rem;
  height: 8px;
  border-radius: 999px;
  background: rgba(28, 25, 21, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--watched));
  transition: width 0.35s ease;
}

.controls {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.filter-tab:hover {
  border-color: rgba(200, 30, 58, 0.35);
  transform: translateY(-1px);
}

.filter-tab.is-active {
  background: var(--ink);
  color: #f5f8fb;
  border-color: var(--ink);
}

.search-field {
  flex: 1 1 220px;
  max-width: 320px;
}

.search-field input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-field input:focus {
  border-color: rgba(200, 30, 58, 0.45);
  box-shadow: 0 0 0 3px rgba(200, 30, 58, 0.14);
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 3.5rem;
}

.sidebar-label {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.category-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.category-nav a:hover,
.category-nav a.is-active {
  color: var(--ink);
  background: rgba(21, 32, 43, 0.06);
  border-color: var(--line);
}

.catalog {
  min-width: 0;
}

.category-section {
  margin-top: 2rem;
  scroll-margin-top: 1rem;
  animation: rise 0.55s ease both;
}

.category-section:first-child {
  margin-top: 0.25rem;
}

.back-to-menu {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: var(--ink);
  color: #f5f8fb;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(21, 32, 43, 0.28);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.back-to-menu:not([hidden]) {
  display: inline-flex;
}

.back-to-menu:hover {
  transform: translateY(-2px);
}

/* Desktop: бокове меню */
@media (min-width: 900px) {
  .layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
    gap: 2rem;
  }

  .sidebar {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow: auto;
    padding: 1rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    scrollbar-width: thin;
  }

  .category-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .category-nav a {
    display: block;
    width: 100%;
  }

  .back-to-menu {
    display: none !important;
  }
}

/* Mobile: липке меню зверху */
@media (max-width: 899px) {
  html {
    scroll-padding-top: 5.5rem;
  }

  .sidebar-label {
    display: none;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0 -1.25rem 0.35rem;
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: rgba(238, 242, 246, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 24px rgba(21, 32, 43, 0.08);
  }

  .category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.45rem;
  }

  .category-section {
    scroll-margin-top: 5.5rem;
  }
}

.category-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
}

.category-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
}

.category-count {
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 600;
}

.film-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

@media (min-width: 640px) {
  .film-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
  }
}

@media (min-width: 960px) {
  .film-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1120px) {
  .film-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.film-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
  color: inherit;
}

.poster-wrap {
  position: relative;
  display: block;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #c9d3de;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.2s ease;
}

.poster-wrap:hover {
  transform: translateY(-3px);
}

.poster-wrap:focus-visible {
  outline: 3px solid rgba(200, 30, 58, 0.4);
  outline-offset: 4px;
}

.poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.25s ease, transform 0.35s ease, opacity 0.25s ease;
}

.film-card:hover .poster-wrap img {
  transform: scale(1.03);
}

.film-card.is-watched .poster-wrap img {
  filter: grayscale(0.35) brightness(0.85);
  opacity: 0.85;
}

.poster-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink-soft);
  background: linear-gradient(160deg, #dbe4ee, #c5d0dc);
}

.watched-badge {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--watched);
  color: #f4fff6;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 6px 16px rgba(28, 25, 21, 0.25);
}

.film-card.is-watched .watched-badge {
  opacity: 1;
  transform: scale(1);
}

.featured-chip {
  position: absolute;
  left: 0.55rem;
  top: 0.55rem;
  z-index: 2;
  background: rgba(21, 32, 43, 0.84);
  color: #f5f8fb;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
}

.poster-rating {
  position: absolute;
  left: 0.55rem;
  bottom: 0.55rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.22rem 0.45rem;
  border-radius: 6px;
  background: #f5c518;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.film-card.is-featured .poster-rating {
  left: auto;
  right: 0.55rem;
}

.film-meta {
  padding: 0.65rem 0.1rem 0;
  display: grid;
  gap: 0.2rem;
}

.film-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
}

.film-title-en {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.film-actions {
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.imdb-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: #000;
}

.imdb-link:hover .imdb-logo {
  filter: brightness(0.95);
}

.imdb-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.12rem 0.28rem 0.08rem;
  border-radius: 3px;
  background: #f5c518;
  color: #000;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1;
  text-transform: none;
}

.imdb-score {
  display: inline-flex;
  align-items: center;
  gap: 0.12rem;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.imdb-star {
  color: #f5c518;
  font-size: 0.95rem;
  line-height: 1;
}

.watch-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.watch-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--watched);
  cursor: pointer;
}

.empty-state {
  margin: 3rem auto;
  max-width: 28rem;
  text-align: center;
  color: var(--ink-soft);
  font-size: 1.1rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
