/* ============================================================
   ВИДЕОСАЛОН — кассетный прокат 70-80х
   Палитра: крем, охра, терракота, тёмно-коричневый, фирменный зелёный
   ============================================================ */

:root {
  --cream: #f2e8d5;
  --cream-2: #e9dcc3;
  --paper: #f7efdf;
  --ink: #2b2118;
  --ink-soft: #4a3a2c;
  --brown: #6b4f3a;
  --terra: #c1543c;
  --orange: #d98e32;
  --gold: #c9a227;
  --green: #4a6b4f;
  --teal: #3e6e6e;
  --plum: #7a4e6d;
  --shadow: rgba(43, 33, 24, .18);
  --stamp: #a3392e;
  --radius: 4px;
  --font-display: 'Bebas Neue', 'Arial Narrow', sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  font-family: var(--font-mono);
  color: var(--ink);
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, #f7eeda 0%, var(--cream) 55%, var(--cream-2) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------- Оверлеи ретро-экрана ---------- */
.grain {
  position: fixed; inset: -50%;
  pointer-events: none; z-index: 90;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 1.2s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0,0); }
  25% { transform: translate(-2%,1%); }
  50% { transform: translate(1%,-2%); }
  75% { transform: translate(-1%,2%); }
  100% { transform: translate(0,0); }
}
.scanlines {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 91;
  background: repeating-linear-gradient(
    to bottom, transparent 0 2px, rgba(43,33,24,.022) 2px 3px
  );
  mix-blend-mode: multiply;
}

/* ---------- Экран входа ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 50% 30%, #f7eeda, var(--cream-2));
  padding: 1.5rem;
}
.gate-box {
  width: min(420px, 100%);
  text-align: center;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 2rem 1.75rem 1.5rem;
  box-shadow: 8px 8px 0 var(--shadow), inset 0 0 0 6px var(--paper), inset 0 0 0 7px rgba(43,33,24,.25);
  position: relative;
}
.gate-cat { margin-top: -70px; margin-bottom: .25rem; }
.gate-cat img { filter: drop-shadow(3px 3px 0 var(--shadow)); }
.gate-title {
  font-family: var(--font-display);
  font-size: 3rem; letter-spacing: .12em;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--orange), 4px 4px 0 var(--shadow);
}
.gate-sub {
  font-family: var(--font-display);
  letter-spacing: .4em; font-size: .95rem;
  color: var(--terra);
  margin: .15rem 0 1.25rem;
}
.gate-hint { font-size: .85rem; color: var(--ink-soft); margin-bottom: 1rem; }
.gate-form { display: flex; gap: .5rem; justify-content: center; }
.gate-form input {
  font-family: var(--font-mono);
  font-size: 1.1rem; letter-spacing: .3em;
  padding: .55rem .8rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fffdf6;
  width: 55%;
  text-align: center;
  outline: none;
}
.gate-form input:focus { border-color: var(--terra); box-shadow: 3px 3px 0 var(--shadow); }
.gate-error { color: var(--stamp); font-size: .8rem; margin-top: .75rem; font-weight: 600; }
.gate-foot { margin-top: 1.5rem; font-size: .72rem; color: var(--ink-soft); opacity: .75; font-style: italic; }

/* ---------- Кнопки ---------- */
.btn {
  font-family: var(--font-display);
  font-size: 1.05rem; letter-spacing: .12em;
  padding: .55rem 1.2rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, background .15s;
  text-transform: uppercase;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.btn-primary { background: var(--orange); color: var(--ink); }
.btn-stamp { background: var(--green); color: var(--paper); }

/* ---------- Шапка ---------- */
#app { display: flex; flex-direction: column; min-height: 100vh; }
.masthead {
  border-bottom: 3px solid var(--ink);
  background:
    linear-gradient(to bottom, rgba(247,239,223,.5), rgba(247,239,223,0)),
    repeating-linear-gradient(90deg, transparent 0 26px, rgba(43,33,24,.03) 26px 27px);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(3px);
}
.masthead-inner {
  max-width: 1280px; margin: 0 auto;
  padding: .9rem 1.25rem;
  display: flex; flex-wrap: wrap; gap: .9rem;
  align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: .9rem; }
.logo {
  background: none; border: none; cursor: pointer;
  transition: transform .15s ease;
}
.logo:hover { transform: rotate(-6deg) scale(1.06); }
.brand-title {
  font-family: var(--font-display);
  font-size: 2.4rem; line-height: .95;
  letter-spacing: .1em;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--orange), 3px 3px 0 var(--shadow);
}
.brand-tag { font-size: .75rem; color: var(--ink-soft); letter-spacing: .04em; }
.masthead-actions { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.whoami { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--ink-soft); }
.whoami select {
  font-family: var(--font-mono); font-size: .85rem;
  padding: .35rem .5rem;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  outline: none; cursor: pointer;
}
.masthead-strip {
  border-top: 2px dashed rgba(43,33,24,.3);
  padding: .3rem 1rem;
  display: flex; gap: 2.2rem; justify-content: center;
  font-family: var(--font-display); font-size: .8rem; letter-spacing: .3em;
  color: var(--terra);
  overflow: hidden; white-space: nowrap;
}

/* ---------- Доска тиров ---------- */
.board { flex: 1; max-width: 1280px; margin: 0 auto; width: 100%; padding: 1.5rem 1.25rem 3rem; }
.tiers { display: flex; flex-direction: column; gap: 1.4rem; }

.tier {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--shadow);
  overflow: hidden;
}
.tier-head {
  display: flex; align-items: center; gap: .8rem;
  padding: .55rem 1rem;
  border-bottom: 3px solid var(--ink);
  background: var(--cream-2);
}
.tier-badge {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--paper);
  background: var(--tier-color, var(--brown));
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 2px 2px 0 var(--ink);
}
.tier-name {
  font-family: var(--font-display);
  font-size: 1.5rem; letter-spacing: .14em;
  color: var(--ink);
}
.tier-count {
  margin-left: auto;
  font-size: .75rem; color: var(--ink-soft);
  border: 1.5px dashed var(--ink-soft);
  padding: .15rem .5rem; border-radius: 999px;
}

/* Полка — флекс-ряд кассет */
.tier-shelf {
  display: flex; flex-wrap: wrap; gap: .9rem;
  padding: 1rem;
  min-height: 86px;
  background:
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(43,33,24,.025) 34px 35px);
}
.tier-empty {
  font-size: .78rem; color: var(--ink-soft); font-style: italic;
  opacity: .6; align-self: center; padding-left: .5rem;
}

/* ---------- Карточка-кассета ---------- */
.card {
  width: 168px;
  background: linear-gradient(180deg, #3a2e24 0%, #2e241c 100%);
  border: 2.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 var(--shadow);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  color: var(--cream);
  display: flex; flex-direction: column;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px) rotate(-.6deg);
  box-shadow: 6px 8px 0 var(--shadow);
  outline: none;
}
/* Этикетка-корешок */
.card-tape {
  height: 14px;
  background: var(--tier-color, var(--brown));
  border-bottom: 2px solid var(--ink);
  position: relative;
}
.card-tape::after {
  content: '';
  position: absolute; inset: 3px 8px;
  background: repeating-linear-gradient(90deg, rgba(0,0,0,.22) 0 4px, transparent 4px 10px);
  border-radius: 1px;
}
.card-poster {
  aspect-ratio: 2/3;
  background: #1d1712;
  position: relative;
  overflow: hidden;
}
.card-poster img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(.92) contrast(1.02);
}
.card-stamp {
  position: absolute; top: 10px; left: -6px;
  font-family: var(--font-display);
  font-size: .75rem; letter-spacing: .18em;
  color: var(--paper);
  background: var(--stamp);
  padding: .2rem .55rem;
  border: 1.5px solid var(--paper);
  transform: rotate(-7deg);
  box-shadow: 2px 2px 0 rgba(0,0,0,.4);
  pointer-events: none;
}
.card-meta { padding: .5rem .55rem .45rem; flex: 1; }
.card-title {
  font-family: var(--font-display);
  font-size: 1.02rem; letter-spacing: .04em; line-height: 1.05;
  color: var(--cream);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-sub {
  font-size: .62rem; color: #c9b99e; margin-top: .2rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-ratings { display: flex; gap: .45rem; margin-top: .4rem; flex-wrap: wrap; }
.rating-chip {
  font-size: .62rem; font-weight: 600;
  padding: .1rem .35rem;
  border-radius: 2px;
  border: 1px solid rgba(242,232,213,.35);
}
.rating-chip.kp { color: #ff9c66; }
.rating-chip.imdb { color: #f5c542; }
.rating-chip.wiki { color: #9ec5ff; }
.card-actions {
  display: flex; gap: .3rem;
  padding: .4rem .5rem .5rem;
  border-top: 1.5px dashed rgba(242,232,213,.2);
}
.card-tier-move {
  flex: 1;
  font-family: var(--font-mono); font-size: .68rem;
  background: #241c15; color: var(--cream);
  border: 1.5px solid rgba(242,232,213,.35);
  border-radius: 2px; padding: .2rem;
  cursor: pointer; outline: none;
}
.card-watch, .card-del {
  width: 28px; height: 24px;
  font-size: .8rem;
  background: #241c15; color: var(--cream);
  border: 1.5px solid rgba(242,232,213,.35);
  border-radius: 2px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.card-watch:hover { background: var(--green); color: #fff; }
.card-watch.watched { background: var(--green); color: #fff; }
.card-del:hover { background: var(--stamp); color: #fff; }

/* ---------- Пустое состояние ---------- */
.empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--ink-soft);
}
.empty p { margin-top: 1rem; font-style: italic; }

/* ---------- Футер ---------- */
.colophon {
  border-top: 3px solid var(--ink);
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--ink-soft);
  font-size: .8rem;
}
.colophon img { margin-bottom: .5rem; }
.colophon-tiny { font-size: .68rem; opacity: .6; margin-top: .5rem; }

/* ---------- Модалки ---------- */
.modal {
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 10px 10px 0 var(--shadow);
  padding: 0;
  width: min(560px, 94vw);
  max-height: 88vh;
  color: var(--ink);
}
.modal::backdrop { background: rgba(43,33,24,.55); backdrop-filter: blur(2px); }
.modal-wide { width: min(760px, 94vw); }
.modal-close-form { position: absolute; top: 0; right: 0; margin: 0; }
.modal-close {
  position: absolute; top: 8px; right: 10px;
  background: var(--stamp); color: var(--paper);
  border: 2px solid var(--ink);
  width: 34px; height: 34px;
  font-size: 1.2rem; font-weight: 700;
  cursor: pointer;
  border-radius: var(--radius);
  box-shadow: 2px 2px 0 var(--ink);
  line-height: 1;
  z-index: 2;
}
.modal-body { padding: 1.5rem 1.5rem 1.75rem; }
.modal-title {
  font-family: var(--font-display);
  font-size: 2rem; letter-spacing: .1em;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--orange);
  margin-bottom: .25rem;
}
.modal-hint { font-size: .78rem; color: var(--ink-soft); margin-bottom: 1.1rem; }

.search-row { display: flex; gap: .5rem; }
.search-row input {
  flex: 1;
  font-family: var(--font-mono); font-size: .95rem;
  padding: .6rem .8rem;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: #fffdf6; outline: none;
}
.search-row input:focus { border-color: var(--terra); box-shadow: 3px 3px 0 var(--shadow); }
.search-status { margin-top: .8rem; font-size: .8rem; color: var(--ink-soft); font-style: italic; }

.search-results { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; max-height: 46vh; overflow-y: auto; }
.result-item {
  display: flex; gap: .8rem; align-items: center;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: #fffdf6; padding: .5rem;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  text-align: left;
}
.result-item:hover, .result-item.picked {
  transform: translate(-2px,-2px);
  box-shadow: 4px 4px 0 var(--shadow);
  border-color: var(--terra);
}
.result-poster { width: 52px; height: 76px; object-fit: cover; border: 1.5px solid var(--ink); border-radius: 2px; background: #1d1712; flex-shrink: 0; }
.result-info { flex: 1; min-width: 0; }
.result-title { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .04em; line-height: 1; }
.result-sub { font-size: .7rem; color: var(--ink-soft); margin-top: .2rem; }
.result-ratings { display: flex; gap: .4rem; margin-top: .35rem; flex-wrap: wrap; }
.result-ratings .rating-chip { border-color: var(--ink-soft); }
.result-ratings .rating-chip.kp { color: var(--terra); }
.result-ratings .rating-chip.imdb { color: #9a7a10; }

.pick-panel { margin-top: 1.2rem; border-top: 2px dashed var(--ink-soft); padding-top: 1rem; }
.pick-title { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: .1em; margin-bottom: .6rem; }
.tier-pick { display: flex; gap: .5rem; flex-wrap: wrap; }
.tier-pick button {
  font-family: var(--font-display); font-size: 1.1rem;
  width: 46px; height: 42px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.tier-pick button:hover { transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.tier-pick button.picked {
  background: var(--tier-color, var(--brown));
  color: var(--paper);
  transform: translate(2px,2px);
  box-shadow: 0 0 0 var(--ink);
}
.pick-actions { margin-top: 1rem; display: flex; justify-content: flex-end; }

/* ---------- Детальная карточка ---------- */
.detail { display: grid; grid-template-columns: 220px 1fr; gap: 1.3rem; }
.detail-poster { position: relative; }
.detail-poster img {
  width: 100%; border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: 5px 5px 0 var(--shadow);
  display: block;
}
.detail-stamp {
  position: absolute; top: 14px; left: -8px;
  font-family: var(--font-display); font-size: 1rem; letter-spacing: .18em;
  color: var(--paper); background: var(--stamp);
  padding: .25rem .7rem; border: 2px solid var(--paper);
  transform: rotate(-7deg); box-shadow: 2px 2px 0 rgba(0,0,0,.35);
}
.detail-info h2 {
  font-family: var(--font-display);
  font-size: 2.1rem; letter-spacing: .05em; line-height: .95;
  color: var(--ink);
  text-shadow: 2px 2px 0 var(--orange);
}
.detail-original { font-size: .78rem; color: var(--ink-soft); font-style: italic; margin-top: .2rem; }
.detail-facts { display: flex; flex-wrap: wrap; gap: .4rem; margin: .7rem 0; }
.fact-chip {
  font-size: .68rem;
  border: 1.5px solid var(--ink); border-radius: 999px;
  padding: .15rem .6rem;
  background: var(--cream);
}
.detail-ratings { display: flex; gap: .6rem; margin: .7rem 0; flex-wrap: wrap; }
.detail-ratings .rating-chip {
  font-size: .8rem; padding: .25rem .55rem;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: #fffdf6;
  color: var(--ink);
}
.detail-ratings .rating-chip.kp { border-left: 8px solid var(--terra); }
.detail-ratings .rating-chip.imdb { border-left: 8px solid var(--gold); }
.detail-desc {
  font-size: .85rem; line-height: 1.55; color: var(--ink-soft);
  border-left: 3px solid var(--orange);
  padding-left: .8rem; margin-top: .8rem;
}
.detail-src { font-size: .65rem; color: var(--ink-soft); opacity: .7; margin-top: .4rem; font-style: italic; }
.detail-actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.detail-actions select {
  font-family: var(--font-mono); font-size: .8rem;
  padding: .45rem .5rem;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); cursor: pointer; outline: none;
}

/* Комментарии */
.comments { margin-top: 1.5rem; border-top: 2px dashed var(--ink-soft); padding-top: 1rem; }
.comments-title {
  font-family: var(--font-display); font-size: 1.3rem; letter-spacing: .12em;
  margin-bottom: .8rem;
  display: flex; align-items: center; gap: .5rem;
}
.comments-list { display: flex; flex-direction: column; gap: .6rem; max-height: 240px; overflow-y: auto; }
.comment {
  background: #fffdf6;
  border: 2px solid var(--ink); border-radius: var(--radius);
  padding: .55rem .75rem;
  box-shadow: 3px 3px 0 var(--shadow);
}
.comment-head { display: flex; justify-content: space-between; font-size: .7rem; color: var(--ink-soft); margin-bottom: .25rem; }
.comment-author { font-weight: 600; color: var(--terra); }
.comment-text { font-size: .83rem; line-height: 1.45; }
.comment-empty { font-size: .78rem; color: var(--ink-soft); font-style: italic; padding: .5rem 0; }
.comment-form { display: flex; gap: .5rem; margin-top: .8rem; }
.comment-form input {
  flex: 1;
  font-family: var(--font-mono); font-size: .85rem;
  padding: .55rem .7rem;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: #fffdf6; outline: none;
}
.comment-form input:focus { border-color: var(--terra); }

/* ---------- Пасхалка ---------- */
.easter {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 6px 6px 0 var(--shadow);
  padding: .6rem;
  text-align: center;
  animation: easter-in .35s cubic-bezier(.2,1.4,.4,1);
}
.easter img { max-width: 220px; max-height: 180px; display: block; border: 2px solid var(--ink); }
.easter p { font-size: .68rem; color: var(--ink-soft); font-style: italic; margin-top: .35rem; }
@keyframes easter-in {
  from { transform: translateY(40px) rotate(4deg) scale(.8); opacity: 0; }
  to { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
}

/* ---------- Тосты ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--cream);
  font-family: var(--font-mono); font-size: .82rem;
  padding: .6rem 1.1rem;
  border-radius: var(--radius);
  border: 2px solid var(--cream);
  box-shadow: 4px 4px 0 var(--shadow);
  z-index: 300;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Адаптив ---------- */
@media (max-width: 760px) {
  .brand-title { font-size: 1.8rem; }
  .masthead-strip { gap: 1.2rem; font-size: .7rem; }
  .detail { grid-template-columns: 1fr; }
  .detail-poster { max-width: 240px; }
  .card { width: calc(50% - .45rem); }
  .masthead-actions { width: 100%; justify-content: space-between; }
}
@media (max-width: 420px) {
  .card { width: 100%; }
  .gate-form { flex-direction: column; align-items: center; }
  .gate-form input { width: 100%; }
}

/* Уменьшенное движение */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
