/* Палитра: только чёрный, белый и красный #890C0C. Оттенки — это белый с прозрачностью. */
:root {
  --black: #000;
  --white: #fff;
  --red: #890c0c;

  --bg: var(--black);
  --text: var(--white);
  --muted: rgba(255, 255, 255, .58);
  --line: rgba(255, 255, 255, .14);
  --surface: rgba(255, 255, 255, .035);
  --surface-2: rgba(255, 255, 255, .08);
  --accent: var(--red);

  --panel-w: 360px;
  --row-h: 58px;
  --radius: 14px;
}

/* Фирменный шрифт плашки «Twiglles Киношная» */
@font-face {
  font-family: "Benzin";
  src: url("benzin-semibold.woff") format("woff");
  font-weight: 600;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--white); }

/* ---------- раскладка ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  min-height: 100vh;
  transition: grid-template-columns .35s ease;
}
.layout.collapsed { grid-template-columns: minmax(0, 1fr) 56px; }

.feed { padding: 48px clamp(16px, 5vw, 64px) 80px; max-width: 980px; width: 100%; margin: 0 auto; }

/* ---------- шапка ---------- */
.brand {
  display: inline-block;
  padding: 7px 11px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--white);
  font: 600 12px/1 Benzin, Unbounded, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.hero h1 {
  font: 700 clamp(34px, 6vw, 56px)/1.05 Unbounded, sans-serif;
  margin: 18px 0 14px;
  letter-spacing: -.01em;
}
/* большой переключатель: «Что смотрим?» и под ним «Когда смотрим?» */
.switch {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  margin: 18px 0 14px;
  /* Размер зависит только от ширины окна, поэтому на обеих вкладках он одинаковый
     и заголовок всегда помещается в одну строку (даже рядом с панелью результатов). */
  font: 700 clamp(26px, 8.1vw, 52px)/1.1 Unbounded, sans-serif;
  white-space: nowrap;
  letter-spacing: -.01em;
}
@media (min-width: 901px) {
  .switch { font-size: clamp(28px, calc(8.1vw - 34px), 52px); }
}
.switch a {
  position: relative;
  color: rgba(255, 255, 255, .26);
  text-decoration: none;
  padding-bottom: 8px;
  transition: color .2s;
}
.switch a:hover { color: rgba(255, 255, 255, .6); }
.switch a[aria-current="page"] { color: var(--white); }
/* Вкладки на одной странице: показываем только содержимое открытой. */
html:not(.tab-when) [data-pane="when"],
html.tab-when [data-pane="what"] { display: none; }
html.tab-when .layout { grid-template-columns: minmax(0, 1fr) 0; }
html.tab-switching .layout { transition: none; } /* панель не «уезжает» при смене вкладки */
html.tab-when .panel { display: none; }
/* Левый край как у ленты фильмов (шапка не сдвигается), а вправо календарь занимает и место панели. */
.layout { --pw: var(--panel-w); }
.layout.collapsed { --pw: 56px; }
html.tab-when .feed {
  max-width: none; width: auto;
  margin-left: max(0px, calc((100% - var(--pw) - 980px) / 2));
  margin-right: max(0px, calc((100% - var(--pw) - 980px) / 2));
}

/* Плавный переход между «Что смотрим?» и «Когда смотрим?»: браузер не моргает,
   а растворяет одну страницу в другую, заголовки и плашка переезжают на место. */
@view-transition { navigation: auto; }
.brand { view-transition-name: brand; }
.switch a:nth-child(1) { view-transition-name: tab-what; }
.switch a:nth-child(2) { view-transition-name: tab-when; }
::view-transition-group(*) { animation-duration: .4s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(root) { animation: vt-out .25s ease both; }
::view-transition-new(root) { animation: vt-in .4s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
.switch a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 4px; border-radius: 2px; background: var(--accent);
}

.theme { margin: 0 0 14px; font-size: 17px; font-weight: 500; }
.lead { color: var(--muted); max-width: 60ch; margin: 0; }
.mode-note {
  margin-top: 18px;
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
}
.mode-note b { color: var(--text); font-weight: 600; }

/* ---------- карточки фильмов ---------- */
.films { display: flex; flex-direction: column; gap: 22px; margin-top: 44px; }

.film {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 28px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  scroll-margin-top: 24px;
  transition: border-color .25s, box-shadow .25s;
}
.film.voted { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.film.flash { box-shadow: 0 0 0 3px var(--accent); }

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
.poster img { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .ph {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 16px; text-align: center;
  font: 500 14px/1.3 Unbounded, sans-serif; color: var(--muted);
}
.poster .num {
  position: absolute; top: 8px; left: 8px;
  min-width: 28px; height: 28px; padding: 0 8px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(6px);
  font: 600 13px/1 Inter, sans-serif;
}

.info { display: flex; flex-direction: column; min-width: 0; }
.info h2 { font: 700 clamp(20px, 2.6vw, 26px)/1.2 Unbounded, sans-serif; margin: 2px 0 6px; }
.sub { color: var(--muted); font-size: 14px; }
.sub .dot { margin: 0 7px; opacity: .5; }
.about { margin: 14px 0 0; color: rgba(255, 255, 255, .85); }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.rates { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.rate {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 11px 6px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-decoration: none;
  font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
a.rate:hover { border-color: var(--white); }
.rate .tag {
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  padding: 2px 7px; border-radius: 999px;
  background: var(--white); color: var(--black);
}

.vote-row { display: flex; align-items: center; gap: 14px; margin-top: auto; padding-top: 22px; flex-wrap: wrap; }
.vote {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--white);
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.vote:hover { background: rgba(137, 12, 12, .35); }
.vote:active { transform: scale(.97); }
.vote[aria-pressed="true"], .vote.solid { background: var(--accent); }
.vote:disabled { opacity: .4; cursor: not-allowed; }
.vote-count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.link-btn {
  border: 0; background: none; padding: 4px 2px;
  color: var(--muted); font-size: 14px;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--white); }
.del { margin-left: auto; }

/* ---------- добавить фильм ---------- */
.add { margin-top: 22px; }
.add-cta {
  width: 100%;
  text-align: left;
  border-style: dashed;
  cursor: pointer;
}
.add-cta:hover { border-color: var(--accent); background: rgba(137, 12, 12, .12); }
.add-poster, .drop {
  display: grid; place-items: center;
  border: 1.5px dashed var(--line);
  background: transparent;
}
.add-cta .info { justify-content: center; gap: 10px; }
.add-title { font: 700 clamp(20px, 2.6vw, 26px)/1.2 Unbounded, sans-serif; }
.plus {
  display: grid; place-items: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--white);
  font: 400 34px/1 Inter, sans-serif;
}

.add-form { border-color: var(--accent); }
.drop { cursor: pointer; transition: border-color .2s, background .2s; }
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(137, 12, 12, .12); }
.drop.has-img { border-style: solid; }
.drop img { position: absolute; inset: 0; }
.drop-hint { display: grid; justify-items: center; gap: 8px; text-align: center; font-weight: 600; }
.drop-hint small { color: var(--muted); font-weight: 400; font-size: 12px; line-height: 1.4; }
.drop .plus { width: 44px; height: 44px; font-size: 28px; }

.add-form input:not([type="file"]), .add-form textarea {
  width: 100%; min-width: 0;
  padding: 6px 0;
  border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  outline: none;
  transition: border-color .2s;
}
.add-form input:focus, .add-form textarea:focus { border-bottom-color: var(--accent); }
.add-form ::placeholder { color: rgba(255, 255, 255, .35); }
.add-form .f-title { font: 700 clamp(20px, 2.6vw, 26px)/1.2 Unbounded, sans-serif; padding-bottom: 8px; }
.f-row { display: flex; gap: 14px; margin-top: 10px; font-size: 14px; }
.f-row .f-short { flex: 0 0 64px; }
.add-form textarea { margin-top: 14px; resize: vertical; }
.add-form .facts { align-items: center; }
.add-form .facts input { padding: 3px 0; }
.add-form .rate { padding-right: 12px; }
.add-form .rate input { width: 3.2em; padding: 0; border-bottom: 0; text-align: center; }
.form-msg { color: var(--muted); font-size: 13px; }

.foot { margin-top: 56px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- панель результатов ---------- */
.panel {
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--black);
  border-left: 1px solid var(--line);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  border: 0; border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.panel-title { font: 600 14px/1 Unbounded, sans-serif; letter-spacing: .02em; }
.panel-summary { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.chev { display: grid; place-items: center; color: var(--muted); transition: transform .3s; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.live-dot.on { background: var(--accent); animation: pulse 2s infinite; }
.live-dot.demo { background: var(--white); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(137, 12, 12, .9); }
  70% { box-shadow: 0 0 0 8px rgba(137, 12, 12, 0); }
  100% { box-shadow: 0 0 0 0 rgba(137, 12, 12, 0); }
}

.panel-body { flex: 1; overflow-y: auto; padding: 14px 12px 18px; }

.board { position: relative; }
.row {
  position: absolute; left: 0; right: 0; top: 0;
  height: calc(var(--row-h) - 6px);
  display: grid;
  grid-template-columns: 22px 34px minmax(0, 1fr) auto;
  align-items: center; gap: 10px;
  padding: 0 10px 0 6px;
  border-radius: 10px;
  border: 0; background: transparent;
  cursor: pointer; text-align: left;
  transition: transform .55s cubic-bezier(.2,.8,.2,1), background .2s;
}
.row:hover { background: var(--surface-2); }
.row .rank {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.row .thumb { width: 34px; height: 46px; border-radius: 5px; object-fit: cover; background: var(--surface-2); }
.row .mid { min-width: 0; }
.row .name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .bar { height: 5px; margin-top: 7px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.row .fill { height: 100%; width: 0; border-radius: 3px; background: rgba(255, 255, 255, .4); transition: width .55s cubic-bezier(.2,.8,.2,1); }
.row .n { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.row.mine .name::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.row.lead .fill { background: var(--accent); }
.row.lead .rank { background: var(--accent); color: var(--white); }
.row.bump .n { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.35); } }

.panel-stats { margin-top: 14px; padding: 12px 8px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.panel-stats b { color: var(--text); font-weight: 600; }

/* свёрнутая панель на десктопе */
.layout.collapsed .panel-head { flex-direction: column; height: 100%; padding: 20px 0; border-bottom: 0; gap: 14px; }
.layout.collapsed .panel-title,
.layout.collapsed .panel-summary { writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; overflow: visible; }
.layout.collapsed .panel-summary { flex: 0 1 auto; max-height: 60vh; text-overflow: ellipsis; overflow: hidden; }
.layout.collapsed .chev { order: -1; transform: rotate(180deg); }
.layout.collapsed .panel-body { display: none; }

/* ---------- телефоны и узкие окна: панель снизу ---------- */
@media (max-width: 900px) {
  .layout, .layout.collapsed { display: block; }
  .feed { padding-top: 32px; padding-bottom: 120px; }
  .film { grid-template-columns: 112px minmax(0, 1fr); gap: 16px; padding: 14px; }
  .about { font-size: 14px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dt { margin-top: 6px; font-size: 12px; }
  .vote { padding: 10px 18px; }
  .f-row { flex-wrap: wrap; }
  .f-row input:first-child { flex: 1 1 100%; }
  .plus { width: 44px; height: 44px; font-size: 28px; }

  .panel {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0;
    height: auto; max-height: 72vh;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .8);
    z-index: 10;
  }
  .panel-head { padding: 16px 18px; }
  .chev { transform: rotate(-90deg); }
  .layout.collapsed .panel-head { flex-direction: row; height: auto; padding: 16px 18px; gap: 10px; }
  .layout.collapsed .panel-title,
  .layout.collapsed .panel-summary { writing-mode: horizontal-tb; transform: none; text-align: right; }
  .layout.collapsed .panel-title { text-align: left; }
  .layout.collapsed .chev { order: 0; transform: rotate(90deg); }
}

@media (max-width: 520px) {
  .film { grid-template-columns: 1fr; }
  .poster { width: 150px; }
  .info h2 { margin-top: 0; }
  .add-cta { grid-template-columns: 72px 1fr; }
  .add-cta .poster { width: auto; }
}

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