/* ============================================================
   carrothood.ru — Cinema Design System
   Mobile-first, dark/light theme, system fonts, CLS-safe ads
   Target: < 15 KB, Lighthouse 95+
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Light theme */
  --bg: #fafafa;
  --bg-alt: #f0f0f3;
  --bg-card: #ffffff;
  --text: #141424;
  --text-secondary: #555770;
  --text-muted: #8a8ca5;
  --accent: #e63946;
  --accent-hover: #d12b37;
  --accent-light: #fef0f1;
  --accent-gold: #e09100;
  --border: #e2e3ec;
  --border-light: #ededf3;
  --success: #2ec4b6;
  --warning: #ff9f1c;
  --error: #e63946;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 6px;
  --max-w: 960px;
  --sidebar-w: 280px;
  --nav-h: 48px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b0c14;
  --bg-alt: #12131f;
  --bg-card: #181928;
  --text: #e8e9f0;
  --text-secondary: #9fa2b8;
  --text-muted: #616480;
  --accent: #ff4d5a;
  --accent-hover: #ff6b76;
  --accent-light: #2a1520;
  --accent-gold: #f0a830;
  --border: #252640;
  --border-light: #1d1e32;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.6);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; display: block; }

/* --- Typography (Material Type Scale + Ководство) --- */
h1, h2, h3, h4 { color: var(--text); }
h1 { font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 800; line-height: 1.2; margin-bottom: 0.5em; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.5rem); font-weight: 700; line-height: 1.25; margin-top: 1.5em; margin-bottom: 0.4em; }
h3 { font-size: 1rem; font-weight: 700; line-height: 1.3; margin-top: 1em; margin-bottom: 0.3em; }
h4 { font-size: 0.875rem; font-weight: 700; line-height: 1.35; margin-bottom: 0.3em; }
p { margin-bottom: 0.75em; }
ul, ol { margin-bottom: 0.75em; padding-left: 1.5em; }

/* --- Layout --- */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 16px; }

.layout-main { min-height: calc(100vh - var(--nav-h) - 200px); }

.layout-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

@media (min-width: 1024px) {
  .layout-with-sidebar {
    grid-template-columns: 1fr var(--sidebar-w);
  }
}

.sidebar { display: none; }
@media (min-width: 1024px) {
  .sidebar { display: block; }
}

/* --- Navbar --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  height: var(--nav-h);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gap);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

/* Logo: support both .navbar-logo and .logo class */
.navbar-logo, .navbar .logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.navbar-logo span, .navbar .logo span { color: var(--accent); }

/* Nav links: support both .navbar-nav and .nav-links class */
.navbar-nav, .nav-links {
  display: none;
  list-style: none;
  gap: 4px;
  padding: 0;
  margin: 0;
}
@media (min-width: 768px) {
  .navbar-nav, .nav-links { display: flex; }
}

.navbar-nav a, .nav-links a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.navbar-nav a:hover, .nav-links a:hover,
.navbar-nav a.active, .nav-links a.active {
  color: var(--accent);
  background: var(--accent-light);
}

/* Mobile nav toggle */
.mobile-nav-toggle {
  display: flex;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-secondary);
}
.mobile-nav-toggle::before { content: '☰'; }
@media (min-width: 768px) {
  .mobile-nav-toggle { display: none; }
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-theme {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.btn-theme:hover { background: var(--bg-alt); }

.btn-menu {
  display: flex;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-secondary);
}
@media (min-width: 768px) {
  .btn-menu { display: none; }
}

/* Mobile nav overlay */
.mobile-nav {
  display: none;
  position: fixed;
  inset: var(--nav-h) 0 0 0;
  background: var(--bg);
  z-index: 99;
  padding: 16px;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  display: block;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border-light);
}
.mobile-nav a:hover { background: var(--accent-light); color: var(--accent); }

/* --- Hero Section (Lebedev: generous padding, no gradient) --- */
.hero {
  background: var(--bg-alt);
  padding: 48px 0 36px;
}
.hero h1 { margin-bottom: 0.3em; }
.hero p { color: var(--text-secondary); font-size: 0.9375rem; max-width: 55ch; line-height: 1.6; }

/* --- Cards Grid (Lebedev: space between groups) --- */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 20px 0 40px;
}
@media (min-width: 480px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 768px) {
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- Movie Card (poster grid) — Material Surface tonal --- */
.movie-card {
  background: var(--bg-alt);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
}
.movie-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.movie-card-poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-muted);
  overflow: hidden;
}
.movie-card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-card-rating {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.75);
  color: var(--accent-gold);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.movie-card-body {
  padding: 14px 16px 16px;
}

.movie-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.movie-card-title a { color: inherit; }
.movie-card-title a:hover { color: var(--accent); }

.movie-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Genre Tags --- */
.genre-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.genre-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-alt);
  transition: all 0.15s;
}
.genre-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Collection Card (for homepage) — Material Surface tonal --- */
.collection-card {
  background: var(--bg-alt);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.2s, transform 0.15s;
}
.collection-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.collection-card-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

/* Genre tag inside collection card — compact, top position */
.collection-card > .genre-tags { margin: 0 0 10px; }
.collection-card > .genre-tags .genre-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
}

.collection-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 6px;
  color: var(--text);
}
.collection-card-title a { color: inherit; }
.collection-card-title a:hover { color: var(--accent); }

.collection-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.collection-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Movie List (horizontal card — HIG + Material + Ководство) --- */
.movie-list {
  counter-reset: film;
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.movie-item {
  counter-increment: film;
  display: grid;
  grid-template-columns: 24px 140px 1fr;
  gap: 0 16px;
  padding: 12px;
  align-items: start;
  border-radius: 8px;
  transition: background 0.15s;
}
.movie-item:hover {
  background: var(--bg-alt);
}

/* Number column */
.movie-item::before {
  content: counter(film);
  grid-column: 1;
  grid-row: 1 / -1;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
  padding-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Thumbnail link wrapper (when thumb is inside <a>) */
.movie-item-link {
  grid-column: 2;
  grid-row: 1 / -1;
  display: block;
  width: 140px;
  height: 79px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.movie-item-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Thumbnail (when not wrapped in <a>) */
.movie-item-thumb {
  grid-column: 2;
  grid-row: 1 / -1;
  width: 140px;
  height: 79px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-alt);
  display: block;
}
/* When thumb is inside a link, let the link handle grid placement */
.movie-item-link .movie-item-thumb {
  grid-column: auto;
  grid-row: auto;
  width: 100%;
  height: 100%;
}

/* Content body */
.movie-item-body {
  grid-column: 3;
  min-width: 0;
}

.movie-item-body h3 {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 2px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.movie-item-score {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent-gold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-left: auto;
}

.movie-item-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.4;
}

.movie-item-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  max-width: 65ch;
  margin: 0;
}

/* Mobile: stack vertically */
@media (max-width: 767px) {
  .movie-item {
    grid-template-columns: 1fr;
    gap: 8px 0;
    padding: 12px 0;
  }
  .movie-item::before {
    display: none;
  }
  .movie-item-link {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
  }
  .movie-item-thumb {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
  }
  .movie-item-body {
    grid-column: 1;
    grid-row: auto;
  }
}

/* Legacy class fallbacks (for pages not yet converted) */
.movie-list-item { /* alias → movie-item */ }
.movie-cover { max-width: 140px; height: 79px; object-fit: cover; border-radius: 6px; background: var(--bg-alt); }
.movie-list-desc { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.55; max-width: 65ch; margin: 0; }
.movie-list-details { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 4px; }
.movie-rating-inline { font-weight: 700; color: var(--accent-gold); font-variant-numeric: tabular-nums; }

/* --- Content wrapper (podborki/article pages) --- */
.content {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
}
.main-content {
  min-width: 0;
}

/* Title links — Lebedev style: inherit color, accent on hover */
.movie-item-body h3 a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}
.movie-item-body h3 a:hover {
  color: var(--accent);
}

/* --- Film metadata line (Lebedev: separate hierarchy, no baseline jumps) --- */
.film-meta {
  margin-bottom: 20px;
}
.film-meta .genre-tags {
  margin: 0 0 6px;
}
.film-meta-detail {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* --- Article --- */
.article-header { margin-bottom: 1.5em; padding-top: 16px; }
.article-header .genre-tag { margin-bottom: 8px; }

.article-body p { max-width: 65ch; }
.article-body h2 { border-bottom: 1px solid var(--border-light); padding-bottom: 0.3em; }

/* Lead paragraph */
.lead { font-size: 0.9375rem; color: var(--text-secondary); line-height: 1.55; max-width: 60ch; margin-bottom: 1.5em; }

/* --- Review Card --- */
.review-verdict {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
  text-align: center;
}
.review-verdict-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-gold);
  line-height: 1;
}
.review-verdict-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* --- Buzzoola Ad Slots --- */
.bz-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 24px 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-alt);
}

.bz-desktop-only { display: none; }
@media (min-width: 1024px) {
  .bz-desktop-only {
    display: flex;
    position: sticky;
    top: calc(var(--nav-h) + 16px);
  }
}

.bz-mobile-only {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  margin: 0;
  border-radius: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
@media (min-width: 768px) {
  .bz-mobile-only { display: none; }
}

.bz-close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 1;
}

/* --- Section Header (Lebedev: generous whitespace, minimal dividers) --- */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 48px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}
.section-header h2 { margin: 0; border: none; padding: 0; }
.section-header a {
  font-size: 0.85rem;
  font-weight: 600;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 12px 0;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs span { color: var(--text-muted); }

/* --- Footer (Lebedev: generous spacing) --- */
.footer {
  margin-top: 64px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 640px) {
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 840px) {
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
}

.footer h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.footer ul { list-style: none; padding: 0; }
.footer li { margin-bottom: 6px; }
.footer a { color: var(--text-secondary); font-size: 0.9rem; }
.footer a:hover { color: var(--accent); }

.footer-bottom {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* --- Cookie Banner --- */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 0.85rem;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}
.cookie-banner.show { display: flex; flex-wrap: wrap; }
.cookie-banner p { margin: 0; color: var(--text-secondary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-alt); }

/* --- Quiz (movie quiz) --- */
.quiz-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  margin: 6px 0;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text);
}
.quiz-option:hover { border-color: var(--accent); background: var(--accent-light); }
.quiz-option.correct { border-color: var(--success); background: #e8f8f5; }
.quiz-option.wrong { border-color: var(--error); background: #fde8ea; }
[data-theme="dark"] .quiz-option.correct { background: #1a3a2f; }
[data-theme="dark"] .quiz-option.wrong { background: #3a1a1e; }

.quiz-progress {
  height: 6px;
  background: var(--bg-alt);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}
.quiz-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.quiz-result {
  text-align: center;
  padding: 32px 16px;
}
.quiz-score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
}

/* --- Utility --- */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* Bottom padding for sticky mobile ad */
@media (max-width: 767px) {
  body { padding-bottom: 80px; }
}
