.documents-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.documents-all-link {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-bottom: 42px;
  padding: 0 20px;
  border: 1px solid var(--line);
  color: var(--paper);
  font-weight: 900;
}

.documents-all-link:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.document-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.document-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(118px, 0.4fr) minmax(0, 1fr);
  min-height: 210px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(28, 21, 16, 0.88);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  opacity: 0;
  animation: document-in 0.45s ease forwards;
  animation-delay: var(--document-delay, 0ms);
}

@keyframes document-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.document-card-preview {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #dfd4c4;
}

.document-card-preview::after {
  content: '';
  position: absolute;
  inset: 0;
  border-right: 1px solid var(--line);
  box-shadow: inset -24px 0 40px rgba(10, 7, 5, 0.14);
  pointer-events: none;
}

.document-card-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.35s ease, filter 0.35s ease;
  user-select: none;
}

.document-card-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(18px, 2.2vw, 28px);
}

.document-card-meta > span {
  margin-bottom: 16px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.document-card-meta strong {
  color: var(--paper);
  font-family: Oswald, Inter, Arial, sans-serif;
  font-size: clamp(20px, 1.7vw, 27px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.document-card-meta small {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.document-card:hover,
.document-card:focus-visible {
  outline: none;
  border-color: rgba(240, 107, 31, 0.72);
  background: rgba(38, 27, 20, 0.96);
}

.document-card:hover img,
.document-card:focus-visible img {
  transform: scale(1.035);
  filter: contrast(1.04);
}

.documents-empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 28px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.documents-empty[hidden] {
  display: none;
}

.documents-page .header {
  position: relative;
  inset: auto;
  width: auto;
  margin: 18px clamp(16px, 4vw, 58px) 0;
}

.documents-main {
  min-height: calc(100vh - 180px);
  padding-top: clamp(72px, 8vw, 116px);
}

.documents-intro,
.documents-catalog {
  padding-left: clamp(18px, 6vw, 86px);
  padding-right: clamp(18px, 6vw, 86px);
}

.documents-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.55fr);
  gap: clamp(28px, 6vw, 90px);
  align-items: end;
  padding-bottom: clamp(48px, 6vw, 82px);
  border-bottom: 1px solid var(--line);
}

.documents-intro .tag {
  grid-column: 1 / -1;
  margin-bottom: -12px;
}

.documents-intro h1 {
  max-width: 1120px;
  margin: 0;
  font-size: clamp(58px, 8vw, 128px);
  line-height: 0.88;
}

.documents-intro > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 1.4vw, 20px);
  line-height: 1.6;
}

.documents-catalog {
  padding-top: clamp(42px, 5vw, 72px);
  padding-bottom: clamp(74px, 8vw, 120px);
}

.document-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.document-filters[hidden] {
  display: none;
}

.document-filters button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: rgba(18, 13, 10, 0.64);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.document-filters button:hover,
.document-filters button.is-active {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
}

.document-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: rgba(7, 5, 4, 0.97);
  color: var(--paper);
  user-select: none;
}

.document-viewer[hidden] {
  display: none;
}

.is-viewing-document {
  overflow: hidden;
}

.document-viewer-bar,
.document-viewer-footer {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 40px);
  border-color: var(--line);
  background: rgba(18, 13, 10, 0.94);
}

.document-viewer-bar {
  border-bottom: 1px solid var(--line);
}

.document-viewer-bar > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.document-viewer-category {
  color: var(--orange);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.document-viewer-title {
  overflow: hidden;
  color: var(--paper);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-viewer-close,
.document-viewer-arrow {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(28, 21, 16, 0.9);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}

.document-viewer-close {
  width: 46px;
  height: 46px;
  font-size: 30px;
  line-height: 1;
}

.document-viewer-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 60px;
  gap: clamp(8px, 2vw, 24px);
  align-items: center;
  padding: clamp(12px, 2vw, 24px);
  overflow: hidden;
}

.document-viewer-paper {
  min-width: 0;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.document-viewer-paper img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.54);
  user-select: none;
  -webkit-user-drag: none;
}

.document-viewer-arrow {
  width: 56px;
  height: 56px;
  font-size: 25px;
}

.document-viewer button:hover:not(:disabled),
.document-viewer button:focus-visible {
  outline: none;
  border-color: var(--orange);
  color: var(--orange);
}

.document-viewer button:disabled {
  opacity: 0.22;
  cursor: default;
}

.document-viewer-footer {
  border-top: 1px solid var(--line);
}

.document-viewer-footer button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.document-viewer-counter {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1380px) {
  .documents-page .header {
    grid-template-columns: auto auto;
    justify-content: start;
    gap: 12px;
  }

  .documents-page .menu-toggle {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0;
    border: 1px solid var(--line);
    background: rgba(8, 6, 4, 0.46);
    color: var(--paper);
    cursor: pointer;
  }

  .documents-page .menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    margin: 0;
    background: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }

  .documents-page .header.is-menu-open .menu-toggle span:first-child {
    transform: translateY(4px) rotate(45deg);
  }

  .documents-page .header.is-menu-open .menu-toggle span:last-child {
    transform: translateY(-4px) rotate(-45deg);
  }

  .documents-page .nav {
    grid-column: 1 / -1;
    justify-self: start;
    width: 100%;
    display: none;
    grid-template-columns: 1fr;
    gap: 10px;
    padding-top: 8px;
  }

  .documents-page .header.is-menu-open .nav {
    display: grid;
  }

  .documents-page .nav a,
  .documents-page .nav-user {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    background: rgba(8, 6, 4, 0.38);
    white-space: normal;
  }

  .documents-page .call {
    grid-column: 1 / -1;
    display: none;
    justify-self: start;
    width: 100%;
    text-align: center;
  }

  .documents-page .header.is-menu-open .call {
    display: flex;
    justify-content: center;
  }

  .documents-page .header {
    position: relative;
    inset: auto;
    width: auto;
    margin: 18px;
  }

  .document-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .documents-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .documents-all-link {
    width: 100%;
    margin: -18px 0 28px;
  }

  .document-gallery {
    grid-template-columns: 1fr;
  }

  .document-card {
    grid-template-columns: 112px minmax(0, 1fr);
    min-height: 168px;
  }

  .documents-main {
    padding-top: 48px;
  }

  .documents-intro {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .documents-intro .tag {
    margin-bottom: 0;
  }

  .documents-intro h1 {
    font-size: 46px;
    line-height: 0.92;
    overflow-wrap: normal;
    word-break: normal;
  }

  .document-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-filters button {
    width: 100%;
    padding: 0 8px;
  }

  .document-viewer-stage {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 6px;
    padding: 8px 4px;
  }

  .document-viewer-arrow {
    width: 40px;
    height: 48px;
  }

  .document-viewer-bar,
  .document-viewer-footer {
    padding: 10px 12px;
  }

  .document-viewer-footer button {
    width: 32%;
    min-height: 44px;
    padding: 0 6px;
    line-height: 1.15;
  }
}

@media (prefers-reduced-motion: reduce) {
  .document-card {
    animation: none;
    opacity: 1;
  }
}
