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

:root {
  --bg: #323534;
  --text: #f2f2f2;
  --muted: #a9adab;
  --line: #e8e8e8;
  --pad-x: clamp(16px, 4vw, 48px);
  --blue: #4a90d9;
  --red: #e0483f;
  --mono: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono',
          Consolas, 'Courier New', monospace;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Header: logo + menu ---------- */
.site-header {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  column-gap: 24px;
  padding: clamp(12px, 3vw, 32px) var(--pad-x) 0;
}

/* Line under the header, inset from edges */
.site-header::after {
  content: "";
  position: absolute;
  left: var(--pad-x);
  right: var(--pad-x);
  bottom: 0;
  height: 1px;
  background: var(--line);
}

.logo {
  display: inline-block;
  padding: 4px 0 10px;
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--text);
  text-decoration: none;
  line-height: 1.1;
}

.nav {
  display: flex;
  gap: clamp(0px, 2vw, 28px);
  margin-right: -10px;
}

.nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 10px;
  font-size: clamp(.95rem, 2.4vw, 1.1rem);
  letter-spacing: .08em;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--red));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .2s ease;
  z-index: 1;
}

/* aria-current="page" — сам раздел, "true" — страница внутри раздела */
.nav a:hover,
.nav a:focus-visible,
.nav a[aria-current] {
  color: var(--text);
}

.nav a:hover::after,
.nav a:focus-visible::after,
.nav a[aria-current]::after {
  transform: scaleX(1);
}

.nav a:focus-visible,
.logo:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -2px;
}

/* ---------- Main content ---------- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: clamp(28px, 6vh, 72px) var(--pad-x) clamp(48px, 8vh, 96px);
}

h1 {
  font-size: clamp(1.3rem, 3.6vw, 2.2rem);
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.55;
  max-width: 20ch;
}

/* ---------- Buttons ---------- */
.buttons {
  margin-top: clamp(32px, 7vh, 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(24px, 6vh, 64px);
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  min-width: 176px;
  min-height: 44px;
  padding: .85em 2.4em;
  border: 1px solid transparent;
  border-radius: 10px;
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(180deg, var(--blue), var(--red)) border-box;
  color: var(--text);
  font-family: inherit;
  font-size: clamp(1rem, 2vw, 1.15rem);
  letter-spacing: .08em;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.btn .arrow {
  transition: transform .2s ease;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(74, 144, 217, .28),
    0 6px 20px rgba(224, 72, 63, .28);
}

.btn:hover .arrow,
.btn:focus-visible .arrow {
  transform: translateX(4px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* Disabled: no link set yet */
.btn[aria-disabled="true"] {
  background:
    linear-gradient(var(--bg), var(--bg)) padding-box,
    linear-gradient(180deg, #5b5f5d, #5b5f5d) border-box;
  color: #7d817f;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@media (max-width: 380px) {
  .btn {
    width: 100%;
    max-width: 280px;
  }
}

/* ---------- Posters showcase ---------- */
.posters {
  list-style: none;
  margin-top: clamp(24px, 5vh, 56px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(20px, 3vw, 40px) clamp(12px, 3vw, 32px);
}

@media (min-width: 720px) {
  .posters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .posters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 339px) {
  .posters { grid-template-columns: minmax(0, 1fr); }
}

.poster {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.poster-img {
  display: block;
  aspect-ratio: 3579 / 5033;
  border-radius: 6px;
  overflow: hidden;
  background: #2a2c2b;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
  cursor: zoom-in;
  transition: transform .2s ease, box-shadow .2s ease;
}

.poster-img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-img:hover,
.poster-img:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
}

.poster-img:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.poster-title {
  font-size: clamp(.8rem, 2.9vw, 1rem);
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.poster-title a {
  color: inherit;
  text-decoration: none;
}

.poster-title a:hover,
.poster-title a:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-underline-offset: .2em;
}

.poster-title a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.poster-desc {
  margin-top: -4px;
  color: var(--muted);
  font-size: clamp(.75rem, 2.6vw, .9rem);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.poster-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poster-actions .btn {
  min-width: 0;
  width: 100%;
  max-width: none;
  padding: .6em .5em;
  font-size: clamp(.8rem, 2.8vw, 1rem);
  letter-spacing: .06em;
}

@media (min-width: 720px) {
  .poster-actions { flex-direction: row; }
  .poster-actions .btn { flex: 1; }
}

/* ---------- Poster description (page and lightbox) ---------- */
.poster-text {
  font-size: clamp(.9rem, 2.4vw, 1rem);
  line-height: 1.6;
}

.poster-text > * {
  margin-top: 1em;
}

.poster-text h2 {
  margin-top: 2em;
  font-size: .9em;
  letter-spacing: .08em;
  line-height: 1.45;
}

.poster-text ul {
  padding-left: 1.4em;
}

.poster-text li + li {
  margin-top: .5em;
}

.poster-text li::marker {
  color: var(--blue);
}

/* ---------- Poster page ---------- */
.back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin: -12px 0 4px;
  color: var(--muted);
  font-size: clamp(.85rem, 2.4vw, 1rem);
  letter-spacing: .04em;
  text-decoration: none;
  transition: color .2s ease;
}

.back:hover,
.back:focus-visible {
  color: var(--text);
}

.back:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.poster-page {
  margin-top: clamp(20px, 4vh, 40px);
  display: grid;
  gap: clamp(24px, 4vw, 56px);
}

.poster-page .poster-img {
  width: 100%;
  max-width: 560px;
}

.poster-info {
  max-width: 68ch;
  overflow-wrap: break-word;
}

.poster-lead {
  font-size: clamp(1rem, 2.6vw, 1.15rem);
  line-height: 1.5;
}

.poster-page .poster-actions {
  margin-top: 20px;
  flex-direction: row;
  max-width: 420px;
}

.poster-page .poster-actions .btn {
  flex: 1;
}

.poster-page .poster-text {
  margin-top: clamp(16px, 3vh, 32px);
}

/* Широкий экран: постер слева и не уезжает, текст справа */
@media (min-width: 900px) {
  .poster-page {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: start;
  }

  .poster-page .poster-img {
    position: sticky;
    top: 24px;
    width: min(100%, calc((100vh - 48px) * 32 / 45));
    width: min(100%, calc((100dvh - 48px) * 32 / 45));
  }
}

.poster-more {
  margin-top: clamp(48px, 8vh, 96px);
}

.poster-more h2 {
  font-size: clamp(1rem, 2.6vw, 1.3rem);
  letter-spacing: .08em;
}

.posters-mini {
  list-style: none;
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 20px 16px;
}

@media (min-width: 720px) {
  .posters-mini { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

.posters-mini a {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: clamp(.75rem, 2.4vw, .9rem);
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: color .2s ease;
}

.posters-mini img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 32 / 45;
  border-radius: 6px;
  background: #2a2c2b;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
  transition: transform .2s ease;
}

.posters-mini a:hover,
.posters-mini a:focus-visible {
  color: var(--text);
  outline: none;
}

.posters-mini a:hover img,
.posters-mini a:focus-visible img {
  transform: translateY(-3px);
}

.posters-mini a:focus-visible img {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(20, 22, 21, .97);
  color: var(--text);
  overflow: auto;
  overscroll-behavior: contain;
}

.lightbox:not([open]) {
  display: none;
}

.lightbox-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 56px 12px 24px;
  cursor: zoom-out;
}

.lightbox img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 80px);
  max-height: calc(100dvh - 80px);
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .6);
}

/* С описанием (список постеров): постер чуть ниже экрана,
   чтобы под ним было видно начало текста */
.lightbox.has-text .lightbox-inner {
  padding-bottom: 48px;
}

.lightbox.has-text img {
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
}

.lightbox-text {
  width: 100%;
  max-width: 68ch;
  padding: 0 4px;
  cursor: auto;
  overflow-wrap: break-word;
}

.lightbox-title {
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  letter-spacing: .04em;
  line-height: 1.3;
}

/* Градиентная черта под названием — как под шапкой и в меню */
.lightbox-title::after {
  content: "";
  display: block;
  width: 64px;
  height: 2px;
  margin-top: 12px;
  background: linear-gradient(90deg, var(--blue), var(--red));
}

/* Название ведёт на страницу постера */
.lightbox-title a {
  color: inherit;
  text-decoration: none;
}

.lightbox-title a::after {
  content: " \2192";
  color: var(--muted);
}

.lightbox-title a:hover,
.lightbox-title a:focus-visible {
  text-decoration: underline;
  text-decoration-color: var(--blue);
  text-underline-offset: .2em;
  outline: none;
}

/* Широкий экран: постер слева и не уезжает, текст прокручивается справа */
@media (min-width: 640px) and (min-aspect-ratio: 1/1) {
  .lightbox.has-text .lightbox-inner {
    flex-direction: row;
    align-items: flex-start;
    gap: 48px;
    padding: 40px 64px;
  }

  .lightbox.has-text img {
    position: sticky;
    top: 40px;
    flex: none;
    width: min(50%, calc((100vh - 80px) * 32 / 45));
    width: min(50%, calc((100dvh - 80px) * 32 / 45));
    max-height: none;
  }

  .lightbox-text {
    flex: 0 1 64ch;
    min-width: 0;
    padding: 0;
  }
}

.lightbox-close {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid #5b5f5d;
  border-radius: 50%;
  background: rgba(50, 53, 52, .9);
  color: var(--text);
  font: 1.4rem/1 var(--mono);
  cursor: pointer;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  border-color: var(--text);
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
