:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --line: #e2e8f0;
  --bar: #0c4a6e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.bar {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: var(--bar);
}

.bar__brand {
  color: #fff;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.top__brand {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  min-width: 0;
}

.top__title {
  margin: 0;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.top__lead,
.top__rest {
  display: inline;
}

.top__note {
  flex: 1 0 100%;
  margin: -8px 0 0;
  font-size: 15px;
  font-weight: 450;
  line-height: 1.4;
  color: #334155;
}

.top__more {
  display: none;
}

.top__contacts {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: #f97316;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 0 0 4px color-mix(in srgb, #f97316 32%, transparent);
}

.top__contacts:hover {
  background: #ea580c;
}

.contacts--marked {
  background: color-mix(in srgb, #f97316 16%, #fff);
  border-color: #f97316;
  box-shadow: 0 0 0 4px color-mix(in srgb, #f97316 32%, transparent);
}

.contacts {
  margin-top: 16px;
  padding: 18px 20px;
  background: color-mix(in srgb, #f97316 8%, #fff);
  border: 2px solid #f97316;
  border-radius: 12px;
}

.contacts__title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 650;
}

.contacts__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.contacts__list a {
  color: #0c4a6e;
  font-size: 14px;
  text-decoration: none;
}

.contacts__list a:hover {
  text-decoration: underline;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.modules {
  position: relative;
}

.modules__fade,
.modules__more,
.modules__arrow {
  display: none;
}

.tile {
  display: flex;
  flex-direction: column;
  min-height: 180px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.tile {
  cursor: pointer;
}

.tile:hover,
.tile.is-active {
  border-color: #0369a1;
}

.module-card {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

body.has-open-module .tile:not(.is-active) {
  opacity: 0.42;
  filter: saturate(0.35);
}

body.has-open-module .tile.is-active {
  opacity: 1;
  filter: none;
  border-color: #0c4a6e;
  box-shadow: 0 0 0 2px #0c4a6e;
}

body.has-open-module .stack,
body.has-open-module .contacts {
  opacity: 0.45;
}

.module-exit-stack {
  position: sticky;
  top: 120px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  width: fit-content;
  margin: 116px 16px -176px auto;
  padding: 3px;
  border: 3px solid #fff;
  border-radius: 12px;
  background: #f97316;
  box-shadow: 0 0 0 4px rgb(249 115 22 / 45%), 0 8px 20px rgb(15 23 42 / 35%);
}

.module-exit-stack[hidden] { display: none; }

.module-exit-dismiss {
  position: absolute;
  top: -10px;
  right: -10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ea580c;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgb(15 23 42 / 28%);
}

.module-exit-dismiss:hover { background: #c2410c; }

.module-exit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  text-align: left;
}

.module-exit svg { flex: none; }

.module-exit[hidden] { display: none; }

.module-exit:hover { background: rgb(255 255 255 / 18%); color: #fff; }

body.has-open-module .module-card {
  margin-top: 20px;
  border-color: #0c4a6e;
  box-shadow: 0 16px 40px rgb(15 23 42 / 16%);
}

body.has-open-module .module-card__frame {
  height: min(84vh, 920px);
}

.module-card.is-chrome-in-frame .module-card__bar { display: none; }

.module-card__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.module-card__title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.module-card__open {
  font-size: 13px;
  font-weight: 600;
  color: #0c4a6e;
  text-decoration: none;
}

.module-card__close {
  border: 0;
  background: transparent;
  color: #0c4a6e;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.module-card__frame {
  display: block;
  width: 100%;
  height: min(72vh, 760px);
  border: 0;
  background: #fff;
}

.module-card__empty {
  margin: 0;
  padding: 28px 16px;
  color: var(--muted, #64748b);
}

.tile__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 14px;
}

.tile__links {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  flex: none;
}

.tile__module,
.tile__full {
  font-size: 13px;
  font-weight: 600;
  color: #0c4a6e;
  text-decoration: none;
}

.tile__full:hover {
  text-decoration: underline;
}

.player {
  display: none;
}

.player.is-open {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.player__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgb(15 23 42 / 72%);
  cursor: pointer;
}

.player__frame {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player__frame video {
  width: 100%;
  max-height: calc(100vh - 96px);
  background: #000;
}

.player__close {
  align-self: flex-end;
  border: 0;
  background: #fff;
  color: #0f172a;
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tile__preview {
  display: block;
  height: 220px;
  background: #e8eef5 center / cover no-repeat;
}

.tile__preview.is-fitted {
  position: relative;
  height: auto;
  overflow: hidden;
}

.tile__preview.is-fitted img,
.tile__preview.is-fitted video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  object-fit: unset;
}

.tile__preview.is-landscape video {
  width: 360%;
  left: 50%;
  transform: translateX(-50%);
}

.tile__preview.is-landscape img {
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  transform: none;
  object-fit: contain;
  object-position: center;
  background: #e8eef5;
}

.tile__preview img,
.tile__preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #0f172a;
  pointer-events: none;
}

.tile__name {
  font-size: 15px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.tile__name-small {
  font-size: 12px;
  font-weight: 500;
}

.tile__name--split {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.tile__name-en {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
}

.tile__name-ru {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.stack {
  margin: 16px 0 8px;
  padding: 18px 20px 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stack__title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 650;
}

.stack__list {
  margin: 0;
}

.stack__list div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.stack__list div:first-child {
  border-top: 0;
}

.stack__list dt,
.stack__list dd {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.stack__list dt {
  font-weight: 650;
  color: #0c4a6e;
}

.stack__lines span + span::before {
  content: " ";
}

.scroll-affordance {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.scroll-affordance.is-visible {
  opacity: 1;
}

.scroll-affordance__fade {
  height: 88px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--bg) 45%, transparent) 50%,
    color-mix(in srgb, var(--bg) 94%, transparent) 100%
  );
}

.scroll-affordance__chevron {
  position: absolute;
  bottom: 14px;
  left: 50%;
  width: 64px;
  height: 64px;
  transform: translateX(-50%);
  color: #0c4a6e;
  filter: drop-shadow(0 1px 2px color-mix(in srgb, #fff 80%, transparent));
  animation: scroll-affordance-bounce 2.4s ease-in-out infinite;
}

@keyframes scroll-affordance-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.55; }
  50% { transform: translateX(-50%) translateY(4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-affordance__chevron { animation: none; opacity: 0.75; }
}

@media (min-width: 721px) {
  .grid {
    grid-template-columns: 274px 1fr 1fr;
    align-items: start;
  }

  .tile:first-child {
    grid-row: span 2;
    align-self: stretch;
  }

  .tile:first-child .tile__preview {
    flex: 1;
    min-height: 0;
    height: auto !important;
    aspect-ratio: auto !important;
  }

  .tile:first-child .tile__preview img,
  .tile:first-child .tile__preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
  }

  .tile:not(:first-child) .tile__preview {
    position: relative;
    aspect-ratio: 16 / 9 !important;
    height: auto !important;
    overflow: hidden;
  }

  .tile:not(:first-child) .tile__preview img,
  .tile:not(:first-child) .tile__preview video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
    object-fit: cover;
    object-position: center top;
    background: #e8eef5;
  }

  .tile__name {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.25;
    color: #c2410c;
  }

  .tile__name-en {
    font-size: 16px;
    font-weight: 700;
    color: #c2410c;
  }

  .tile__name-ru {
    font-size: 13px;
    font-weight: 600;
    color: #c2410c;
  }

  .tile__name-small {
    font-size: 14px;
    font-weight: 600;
    color: #c2410c;
  }
}

@media (max-width: 720px) {
  main {
    padding: 16px;
  }

  .top {
    gap: 10px;
    align-items: center;
  }

  .top__brand {
    flex: 1;
    min-width: 0;
  }

  .top__title {
    font-size: 17px;
    line-height: 1.2;
    white-space: normal;
    letter-spacing: -0.02em;
  }

  .top__lead {
    display: block;
  }

  .top__note {
    font-size: 14px;
  }

  .top__note:not(.is-open) {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  .top__more {
    display: inline;
    flex: 1 0 100%;
    align-self: flex-start;
    margin-top: -6px;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    text-align: left;
    color: #0c4a6e;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
  }

  .top__contacts {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    box-shadow: 0 0 0 3px color-mix(in srgb, #f97316 28%, transparent);
  }

  .top__contacts svg {
    width: 16px;
    height: 16px;
  }

  .tile__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 12px 8px;
  }

  .tile__name {
    line-height: 1.2;
  }

  .tile__name--one {
    white-space: nowrap;
  }

  .tile__links {
    margin-left: 0;
    gap: 14px;
  }

  .stack__list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .stack__lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .stack__lines span + span::before {
    content: none;
  }

  .modules__row {
    position: relative;
  }

  .modules:not(.is-open) .grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .modules:not(.is-open) .grid::-webkit-scrollbar {
    display: none;
  }

  .modules:not(.is-open) .tile {
    flex: 0 0 85%;
    min-width: 0;
    scroll-snap-align: start;
  }

  .modules:not(.is-open) .modules__fade {
    display: block;
    position: absolute;
    inset: 0 0 0 auto;
    width: 28px;
    background: linear-gradient(90deg, transparent, var(--bg));
    pointer-events: none;
  }

  .modules:not(.is-open) .modules__more {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    justify-content: flex-start;
    gap: 14px;
    width: 100%;
    margin-top: 10px;
  }

  .modules__count {
    margin: 0;
    font-size: 14px;
    font-weight: 650;
    color: var(--ink);
  }

  .modules__show {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-size: 14px;
    font-weight: 650;
    color: #0c4a6e;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
  }
}
