/* ==========================================================================
   Адаптация клона Trust Wallet под телефоны.

   Разметку разделов даёт их собственный CSS: заголовки, отступы и сетки
   карточек на узком экране перестраиваются сами. Здесь только шапка,
   мобильное меню и мелкие поправки для самых узких экранов.

   Про сетку шапки. Она из двух колонок: знак и блок действий. В блоке
   действий лежат язык, кнопка загрузки и «бургер» — поэтому он остаётся
   одним элементом сетки. Если вынести «бургер» наружу, элементов станет три
   на две колонки, браузер создаст вторую строку и действия уедут под панель.
   ========================================================================== */

.tw-burger {
  display: none;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--v2-text-primary);
  cursor: pointer;
  transition: background .18s var(--tw-ease);
}
.tw-burger:hover { background: var(--v2-bg-secondary); }
.tw-burger svg { width: 20px; height: 20px; }

/* ------------------------------------------------------- телефон: до 743px */

@media (max-width: 743px) {
  .tw-header { padding: 8px 10px; }

  .tw-header__inner {
    height: 54px;
    padding: 0 8px 0 12px;
    gap: 6px;
    border-radius: 17px;
    /* Две колонки и ровно одна строка: `minmax(0, …)` не даёт знаку
       растянуть колонку и вытолкнуть действия. */
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
    align-items: center;
  }

  .tw-brand {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    min-width: 0;
    /* Знак остаётся 22px, но область нажатия — не меньше 44px: по логотипу
       тоже нажимают, и попасть в полоску высотой 22px пальцем нельзя. */
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-right: 4px;
  }
  .tw-brand img { height: 22px; width: auto; }

  /* Разделы каталога уходят в шторку: на 360px рядом со знаком и действиями
     для них нет места, а сжатый шрифт читать нельзя. */
  .tw-nav { display: none; }

  /* «Служба поддержки» — обычная ссылка; её место занимает кнопка загрузки. */
  .tw-support { display: none; }

  .tw-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
  }

  .tw-cta {
    height: 44px;
    padding: 0 15px;
    font-size: 13px;
    white-space: nowrap;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    border-radius: 22px;
  }
  .tw-globe { width: 44px; height: 44px; flex: 0 0 auto; }
  .tw-burger { display: grid; width: 44px; height: 44px; }

  /* Список языков прижимаем к краю окна, а не кнопки: панель шириной 300px
     при якоре справа от кнопки уезжает за левый край на 360px. */
  .tw-lang__menu {
    position: fixed;
    top: 64px;
    right: 10px;
    left: auto;
    width: min(272px, calc(100vw - 20px));
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 10px;
    border-radius: 14px;
  }
  .tw-lang__item { padding: 10px 8px; font-size: 13px; min-height: 44px; display: flex; align-items: center; justify-content: center; }

  /* Футер: пять колонок на телефоне не читаются. */
  .tw-footer__nav { grid-template-columns: 1fr 1fr; gap: 24px 16px; }
  .tw-footer__bottom { grid-template-columns: 1fr; gap: 24px; }
  .tw-footer__inner { padding: 44px 18px 32px; }
}

/* --------------------------------------------------- узкие: 380px и меньше */

@media (max-width: 380px) {
  .tw-header__inner { padding: 0 6px 0 10px; gap: 4px; }
  .tw-brand img { height: 20px; }
  /* Высота остаётся 44px — это область нажатия, а не украшение. Уже только
     внутренние отступы. */
  .tw-cta { padding: 0 11px; font-size: 12.5px; }
  .tw-globe, .tw-burger { width: 42px; height: 44px; }
  .tw-burger svg { width: 18px; height: 18px; }
}

/* ------------------------------------------- очень узкие: 330px и меньше */

@media (max-width: 330px) {
  .tw-header { padding: 7px 6px; }
  .tw-header__inner { height: 50px; }
  .tw-brand img { height: 18px; }
  /* Кнопку загрузки оставляем: это главное действие страницы, а глобус
     доступен из шторки. */
  .tw-globe { display: none; }
  .tw-cta { padding: 0 10px; font-size: 12px; }
}

/* --------------------------------------------------------------- шторка */

.tw-drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #0b0e1166;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: tw-fade .2s ease both;
}
.tw-drawer[hidden] { display: none; }

@keyframes tw-fade { from { opacity: 0; } to { opacity: 1; } }

.tw-drawer__sheet {
  max-height: 86vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  background: var(--v2-bg-surface);
  box-shadow: 0 -8px 40px #090d2126;
  animation: tw-rise .3s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes tw-rise {
  from { transform: translateY(22px); opacity: .6; }
  to   { transform: none; opacity: 1; }
}

.tw-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--v2-divider);
}
.tw-drawer__title {
  font-family: var(--font-wix-madefor-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--v2-text-heading);
}
.tw-drawer__x {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--v2-bg-secondary);
  color: var(--v2-text-secondary);
  cursor: pointer;
}

.tw-drawer__group { margin-top: 14px; }
.tw-drawer__label {
  margin: 0 0 6px 4px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--v2-text-tertiary);
}

.tw-drawer__list { display: flex; flex-direction: column; gap: 2px; }

.tw-drawer__item {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--v2-text-primary);
  transition: background .16s var(--tw-ease);
}
.tw-drawer__item:active { background: var(--v2-bg-secondary); }
.tw-drawer__item img { width: 22px; height: 22px; flex: 0 0 auto; opacity: .8; }

/* TrustSend — первым и цветом бренда, как в меню на компьютере. */
.tw-drawer__item--trustsend { font-weight: 700; }
.tw-drawer__item--trustsend span { color: var(--v2-brand); }
.tw-drawer__item--trustsend img { opacity: 1; }

/* ------------------------------------------------------------ планшет */

@media (min-width: 744px) and (max-width: 1079px) {
  /* Пять колонок футера на планшете теснятся — оставляем три. */
  .tw-footer__nav { grid-template-columns: repeat(3, 1fr); gap: 28px 24px; }
}

/* ------------------------------------------------- телефон боком */

@media (max-height: 520px) and (orientation: landscape) {
  .tw-header { padding: 6px 10px; }
  .tw-header__inner { height: 46px; }
  .tw-drawer__sheet { max-height: 92vh; }
  .tw-lang__menu { top: 54px; max-height: 74vh; overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .tw-drawer, .tw-drawer__sheet { animation: none !important; }
}
