/* Telegram Mini App «Новогодние фильмы»
   Оформление опирается на переменные темы Telegram, поэтому приложение
   выглядит родным и в светлой, и в тёмной теме. */

:root {
  --bg: var(--tg-theme-bg-color, #12161f);
  --bg2: var(--tg-theme-secondary-bg-color, #1b2130);
  --fg: var(--tg-theme-text-color, #eef2f8);
  --hint: var(--tg-theme-hint-color, #93a0b8);
  --link: var(--tg-theme-link-color, #7cb0ff);
  --btn: var(--tg-theme-button-color, #e0483d);
  --btn-fg: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-section-bg-color, #1a2130);
  --nope: #5a6579;
  --sep: rgba(140, 155, 180, .18);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

.hidden { display: none !important; }

/* =================== верхняя панель =================== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--sep);
  padding: calc(10px + env(safe-area-inset-top)) 14px 0;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }

.counter {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--sep); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.counter .heart { font-size: 15px; }

.tabs { display: flex; gap: 6px; margin: 12px 0 0; }
.tab {
  flex: 1; padding: 9px 6px; font-size: 13.5px; font-weight: 600;
  background: transparent; color: var(--hint);
  border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--fg); border-bottom-color: var(--btn); }

/* =================== фильтры =================== */
.filters { padding: 10px 0 0; }
.search-row { position: relative; }
#search {
  width: 100%; padding: 10px 36px 10px 13px; font-size: 15px;
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--sep); border-radius: 10px; outline: none;
}
#search:focus { border-color: var(--btn); }
.clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--hint);
  font-size: 15px; padding: 6px 9px; cursor: pointer;
}

.chips { display: flex; gap: 7px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 13px; font-size: 13.5px; font-weight: 550;
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--sep); border-radius: 999px; cursor: pointer;
}
.chip.active { background: var(--btn); color: var(--btn-fg); border-color: transparent; }

.selects { display: flex; gap: 7px; padding: 8px 0 2px; }
.selects select {
  flex: 1; min-width: 0; padding: 8px 10px; font-size: 13.5px;
  background: var(--bg2); color: var(--fg);
  border: 1px solid var(--sep); border-radius: 10px; outline: none;
}

.statusline { padding: 8px 0 9px; font-size: 12.5px; color: var(--hint); }

.banner {
  background: #7a5b12; color: #fff2cf; font-size: 13px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px; text-align: center;
}

/* =================== кнопки оценки =================== */
/* Важно: эти правила относятся ТОЛЬКО к кнопкам в .vote-row.
   Раньше они были общими (.like / .dislike) и ломали кнопки в карточке:
   те становились маленькими абсолютно позиционированными кружками. */
.vote-row {
  display: flex; gap: 10px; margin: 14px 0;
}
.vote-row .act {
  flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 6px; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 650; line-height: 1.15;
  border: 1px solid var(--sep);
  background: var(--bg2); color: var(--fg);
  transition: transform .12s, background .15s, box-shadow .15s;
  text-align: center;
}
.vote-row .act .ico { font-size: 16px; line-height: 1; flex: 0 0 auto; }
.vote-row .act:active { transform: scale(.97); }
.vote-row .act.like { background: var(--btn); color: var(--btn-fg); border-color: transparent; }
.vote-row .act.dislike { background: var(--bg2); color: var(--fg); }
.vote-row .act.like.chosen { box-shadow: 0 0 0 2px var(--btn) inset, 0 0 0 3px rgba(224, 72, 61, .3); }
.vote-row .act.dislike.chosen { box-shadow: 0 0 0 2px var(--nope) inset; }

/* =================== сетка каталога =================== */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 12px 14px 0;
}
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 880px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--sep); cursor: pointer;
  display: flex; flex-direction: column;
}
.card:active { transform: scale(.985); }
.card .poster { position: relative; aspect-ratio: 2 / 3; background: var(--bg2); }
.card .poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .noposter {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--hint); font-size: 12px; text-align: center; padding: 8px;
}

/* маленькие круглые кнопки — только на постере карточки каталога */
.poster .badge {
  position: absolute; top: 7px; left: 7px;
  font-size: 11px; font-weight: 650; padding: 3px 7px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(4px);
}
.poster .like, .poster .dislike {
  position: absolute; bottom: 7px;
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .5); color: #fff; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; backdrop-filter: blur(4px); transition: transform .12s;
}
.poster .like { right: 7px; font-size: 17px; }
.poster .dislike { right: 47px; font-size: 15px; filter: grayscale(1) brightness(1.4); }
.poster .like.on { background: var(--btn); }
.poster .dislike.on { background: var(--nope); filter: none; }
.poster .like:active, .poster .dislike:active { transform: scale(.9); }

.card .info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 3px; }
.card h3 { margin: 0; font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.card .sub { margin: 0; font-size: 11.5px; color: var(--hint); }
.card .rate { display: flex; gap: 6px; font-size: 11.5px; margin-top: 2px; flex-wrap: wrap; }
.card .rate span { background: var(--bg2); border-radius: 6px; padding: 1px 6px; }
.card .rate .kp { color: #ffb340; }
.card .rate .imdb { color: #8ac6ff; }

.empty { padding: 44px 24px; text-align: center; color: var(--hint); font-size: 14.5px; line-height: 1.6; }
.sentinel { height: 1px; }

/* подвкладки «Моего списка» */
.subtabs { display: flex; gap: 8px; padding: 12px 14px 0; }
.subtab {
  flex: 1; padding: 9px 8px; font-size: 13px; font-weight: 600;
  background: var(--bg2); color: var(--hint);
  border: 1px solid var(--sep); border-radius: 10px; cursor: pointer;
}
.subtab.active { background: var(--card); color: var(--fg); border-color: var(--btn); }
.subtab span { opacity: .75; }

/* =================== режим подбора =================== */
.deck { padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }

.deck-card {
  background: var(--card); border: 1px solid var(--sep);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  animation: cardIn .22s ease-out;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.deck-card .dc-poster { position: relative; background: var(--bg2); }
.deck-card .dc-poster img {
  width: 100%; max-height: 44vh; object-fit: contain; display: block;
}
.deck-card .dc-poster .badge {
  position: absolute; top: 8px; left: 8px;
  font-size: 11.5px; font-weight: 650; padding: 3px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(4px);
}
.deck-card .dc-body { padding: 14px 16px 16px; }
.deck-card h3 { margin: 0 0 4px; font-size: 19px; line-height: 1.25; }
.deck-card .sub { margin: 0 0 8px; font-size: 13px; color: var(--hint); }
.deck-card .rate { display: flex; gap: 7px; font-size: 12.5px; flex-wrap: wrap; }
.deck-card .rate span { background: var(--bg2); border-radius: 7px; padding: 3px 8px; }
.deck-card .rate .kp { color: #ffb340; }
.deck-card .rate .imdb { color: #8ac6ff; }
.deck-card .text { margin: 0; font-size: 14.5px; line-height: 1.55; }

/* =================== карточка фильма =================== */
.detail {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg); display: flex; flex-direction: column;
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(14px); opacity: .4; } to { transform: none; opacity: 1; } }

.detail-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.detail-poster { position: relative; background: var(--bg2); }
.detail-poster img { width: 100%; max-height: 58vh; object-fit: contain; display: block; }
.close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px;
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 16px; cursor: pointer;
  backdrop-filter: blur(6px);
}
.badge.over-poster {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 10px;
  font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(6px);
}
.detail-body { padding: 14px 16px 8px; }
.detail-body h2 { margin: 0 0 3px; font-size: 21px; line-height: 1.25; }
.original { margin: 0 0 8px; color: var(--hint); font-size: 13.5px; font-style: italic; }
.meta, .genres { margin: 0 0 4px; color: var(--hint); font-size: 13.5px; }
.genres { font-style: italic; }

.ratings-big { display: flex; gap: 10px; margin: 12px 0 4px; }
.rating {
  flex: 1; background: var(--bg2); border: 1px solid var(--sep);
  border-radius: 12px; padding: 9px 11px; display: flex; flex-direction: column; gap: 2px;
}
.rating .label { font-size: 11.5px; color: var(--hint); }
.rating .value { font-size: 20px; font-weight: 700; }
.rating .votes { font-size: 11px; color: var(--hint); }

.score { margin: 8px 0 0; font-size: 13.5px; color: #7ee08a; }
.description { margin: 0 0 14px; font-size: 14.5px; line-height: 1.6; }
.kp-link { color: var(--link); font-size: 14px; text-decoration: none; }
.spacer { height: 24px; }

/* =================== уведомление =================== */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 90;
  background: rgba(20, 24, 34, .95); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  border: 1px solid var(--sep); box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  max-width: 88vw; text-align: center;
}

@media (max-width: 360px) {
  .vote-row .act { font-size: 13px; padding: 12px 8px; }
  .vote-row .act .ico { font-size: 16px; }
}
