/* === Нормализация === */
*,
*::before,
*::after { box-sizing: border-box; }

:root{
  --header-h: 0px;  /* ставится скриптом по фактической высоте header */
  --footer-h: 0px;  /* если будет фикс-футер — укажи реальную высоту */
}

html, body {
  height: auto;
  overflow-y: auto; /* скролл только у body */
}

body {
  font-family: 'Arial', sans-serif;
  margin: 0;
  background-color: #121212;
  color: #ffffff;
  min-width: 360px;
}

/* === Header === */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background-color: #000000;
  padding: 10px 0;
  border-bottom: 2px solid #f44336;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  transform: translateY(0);
  transition: transform 0.4s ease;
  overflow: visible;  /* важно: header не должен иметь свой скролл */
}

header.hidden { transform: translateY(-100%); }

header h1 {
  margin: 0 auto 5px auto;
  font-size: 2em;
  color: #f0f0f0;
  text-align: center;
  display: block;
}

.nav-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px 40px;
  padding: 5px 0;
}

.nav-buttons button {
  padding: 5px 40px;
  flex: 0 1 auto;
  min-width: 20px;
  font-size: 16px;
  font-weight: bold;
  background-color: transparent;
  color: #ffffff;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
  white-space: nowrap;
}
.nav-buttons button:hover {
  background-color: #e63946;
  color: #ffffff;
  transform: scale(1.05);
}

/* === Контент === */
.content-wrapper {
  /* убрали внутренний скролл и фикс-высоту */
  margin-top: var(--header-h); /* отступ ровно под реальную высоту шапки */
  min-height: calc(100dvh - var(--header-h) - var(--footer-h));
  padding-top: 0;
  border-top: 1px solid transparent;
}

main { padding-bottom: var(--footer-h); }

/* === Панель управления === */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 15px;
  margin: 20px auto 15px auto;
  padding: 0 10px;
  max-width: 1200px;
}

.controls select,
.controls input[type="text"] {
  padding: 8px 12px;
  margin: 0 5px;
  font-size: 14px;
  border: 2px solid #000000;
  background-color: #1e1e1e;
  color: #fff;
  transition: border-color 0.3s ease;
}
.controls select:focus,
.controls input[type="text"]:focus {
  outline: none;
  border-color: #000000;
}

/* === Сетка фильмов === */
.movie-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  max-width: 100%;
  margin: 20px auto;
  padding: 0 20px;
}

.movie {
  background: transparent;
  border: 3px solid #000000;
  border-radius: 0;
  padding: 2px;
  width: 300px;
  max-width: 300px;
  height: 430px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  cursor: pointer;
  perspective: 1000px;
}

.movie .flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}
.movie:hover .flip-inner {
  transform: rotateY(20deg);
  box-shadow: 0 20px 20px rgba(50, 50, 50, 0.2);
}
.movie.flipped .flip-inner { transform: rotateY(180deg); }

.flip-front,
.flip-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #1e1e1e;
  color: #fff;
}
.flip-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.flip-back {
  background-color: #222;
  transform: rotateY(180deg);
  padding: 10px;
  overflow-y: auto; /* локальный скролл внутри карточки — ок */
}
.flip-back h2 {
  font-size: 1.5em;
  margin: 10px 10px 5px 10px;
}

/* === About === */
.about-us {
  text-align: center;
  padding: 20px;
  margin: 200px auto 0 auto;
  max-width: 600px;
}
.about-us p {
  margin: 10px 0;
  text-align: center;
  font-size: 18px;
  line-height: 1.6;
}

/* === Адаптив === */
@media (max-width: 480px){
  .movie{
    width: 45vw;
    max-width: 220px;
    height: auto;
    aspect-ratio: 2 / 3;
  }
  .movie .flip-inner,
  .flip-front,
  .flip-back { height: 100%; }
}
