/* ═════ Sentos · Карточка человека и группы: кнопки, меню, разделы вложений ═════
   Перенесено из прототипа newfront/chats.css.
   Палитра и общие примитивы — в base.css и app.css. */

/* ─────────────────────── Профиль ─────────────────────── */

.profile {
  grid-area: profile;
  /* Точка отсчёта: уходящий вид на время перехода вынимается из потока. */
  position: relative;
  display: none;
}

.messenger.profile-open .profile { display: flex; }

.profile-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: calc(10px + env(safe-area-inset-top)) 10px 8px 18px;
}

.profile-head .screen-title { flex: 1; font-size: 17px; }

.profile-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 20px;
}

.profile-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0 16px;
  text-align: center;
}

.profile-top strong {
  font-family: "SF Pro Display", "SF Pro Text", sans-serif;
  font-size: 17px;
  font-weight: 600;
}

.profile-top span {
  color: var(--muted);
  font-size: 13px;
}

.profile-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-bottom: 16px;
}

.profile-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 11px;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.profile-action.is-pressed { transform: scale(0.94); }

/* Кнопки действий круглые, как и всё остальное в проекте: квадратики со
   скруглением выбивались из общей геометрии. */
.profile-action-icon {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  max-width: 54px;
  border-radius: 50%;
  background: var(--field);
  color: var(--text);
  transition: background-color 160ms ease;
}

.profile-action-icon .icon { width: 22px; height: 22px; fill: currentColor; }

@media (hover: hover) {
  .profile-action:hover .profile-action-icon { background: var(--field-strong); }
}

.profile-details {
  padding: 4px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 16px;
  border-radius: 24px;
  background: var(--field);
}

.detail-label {
  color: var(--muted);
  font-size: 12px;
}

.detail-value {
  font-size: 15px;
  line-height: 1.4;
}

/* Код безопасности закрыт размытием: карточку показывают с экрана и
   снимают на общих скриншотах, а шестьдесят цифр читаются с одного
   взгляда. Открывается нажатием — заодно уходит в буфер, — и
   закрывается, как только нажали мимо. */
.safety-number {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  /* Размытый текст всё ещё выделяется и копируется мышью — до нажатия
     этого быть не должно. */
  user-select: none;
  -webkit-user-select: none;
}

/* Размытие живёт на цифрах, а не на самой кнопке: нажатие красит кнопки
   через тот же filter (brightness в base.css), и два правила спорили бы
   за одно свойство. */
.safety-digits {
  display: block;
  filter: blur(7px);
  transition: filter 200ms ease;
}

.safety-number.is-open {
  user-select: text;
  -webkit-user-select: text;
}

.safety-number.is-open .safety-digits { filter: none; }

@media (prefers-reduced-motion: reduce) {
  .safety-digits { transition: none; }
}

/* Полоса разделов длиннее карточки, поэтому её правый край накрыт
   тенью в цвет панели: пилюли уходят под неё, а не обрываются. */
.profile-tabs-wrap {
  position: relative;
}

/* Тень стоит с той стороны, где список продолжается: пока полоса в
   начале, затемнён только правый край; сдвинули — проступает левый, а на
   конце правый пропадает, потому что дальше ничего нет. Прозрачность
   обеим теням выставляет profile-shared.js по положению прокрутки. */
.tabs-fade {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 10px;
  width: 44px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.tabs-fade-left {
  left: 0;
  background: linear-gradient(to left, transparent, var(--panel-bg) 78%);
}

.tabs-fade-right {
  right: 0;
  background: linear-gradient(to right, transparent, var(--panel-bg) 78%);
}

.profile-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
  /* На компьютере полосу можно тащить мышью, поэтому и курсор
     соответствующий. */
  cursor: grab;
}

.profile-tabs.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

.profile-tabs::-webkit-scrollbar { display: none; }

.profile-tab {
  flex: none;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.profile-tab span { opacity: 0.75; }
.profile-tab.active { background: var(--field-strong); color: var(--text); }
.profile-tab.is-pressed { transform: scale(0.96); }

.shared-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.shared-media-item {
  display: block;
  aspect-ratio: 1;
  /* Плитка — кнопка, а у кнопки свой отступ от браузера (1px 6px).
     Из-за него снимок не доходил до краёв, и по бокам оставались
     серые поля подложки. */
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--field);
}

.shared-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}

/* ───────────── Общие материалы в профиле ─────────────

   Медиа, файлы, ссылки и голосовые — не отдельные экраны, а виды одной
   карточки. Переключаются сменой кадра: уходящий гаснет за 90 мс, за
   следующие 110 мс проявляется приходящий, друг на друга они не
   накладываются — так же, как разделы настроек. */

#profileSharedContent {
  position: relative;
}

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

/* Свой display перебивает hidden, поэтому скрытие возвращаем явно. */
.shared-list[hidden] { display: none; }

.shared-list .shared-media-grid { gap: 4px; }

.pane-in { animation: pane-fade-in 110ms ease 90ms both; }

.pane-out {
  pointer-events: none;
  position: absolute;
  inset: 0;
  animation: pane-fade-out 90ms ease both;
}

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

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

/* Строка файла: что прислали, когда и сколько весит. */
.shared-file-item,
.shared-link-item,
.shared-voice-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 18px;
  background: var(--field);
  transition:
    background-color 160ms ease,
    opacity 200ms ease,
    transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) {
  .shared-file-item:hover,
  .shared-link-item:hover,
  .shared-voice-item:hover { background: var(--field-strong); }
}

.shared-file-icon,
.shared-link-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.shared-file-icon .icon,
.shared-link-icon .icon {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.shared-file-body,
.shared-link-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.shared-file-body strong,
.shared-link-body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
}

.shared-file-body span,
.shared-link-date {
  color: var(--muted);
  font-size: 12px;
}

.shared-link-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent);
  font-size: 12px;
}

/* Голосовые в профиле — те же записи, что и в переписке, только без
   пузыря: дорожка, длительность и дата. */
.shared-voice-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.shared-voice-meta {
  color: var(--muted);
  font-size: 12px;
}

.shared-voice-item .voice-play {
  width: 34px;
  height: 34px;
}

.shared-voice-item .voice-wave { height: 16px; }

/* Удаление вложения: строка гаснет и сжимается, а не пропадает рывком. */
.shared-file-item.is-removing,
.shared-link-item.is-removing,
.shared-voice-item.is-removing,
.shared-media-item.is-removing {
  opacity: 0;
  transform: scale(0.92);
}

/* Долгое нажатие по вложению не должно выделять текст или открывать
   системное меню картинки. */
[data-shared-item] {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* «Перейти к сообщению»: лента подводится к нужному пузырю, и он коротко
   отмечается — без этого непонятно, куда именно перешли. */
.message-row.is-highlight > .message {
  animation: goto-flash 1.2s ease;
}

@keyframes goto-flash {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  25% { box-shadow: 0 0 0 4px var(--accent-soft); }
  100% { box-shadow: 0 0 0 0 var(--accent-soft); }
}

/* ───────────── Меню кнопок профиля ─────────────

   Колокольчик и «Ещё» открывают меню под своей кнопкой. Сроки отключения
   не открывают второе окно поверх первого: то же меню перелистывается на
   следующий шаг и плавно меняет высоту под новый список. */

.profile-menu {
  min-width: 216px;
  overflow: hidden;
  transition: height 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.profile-menu .menu-page {
  display: flex;
  flex-direction: column;
}

.profile-menu .menu-page[hidden] { display: none; }

.menu-page.page-in { animation: pane-fade-in 110ms ease 90ms both; }

.menu-page.page-out {
  position: absolute;
  inset: 5px 5px auto;
  pointer-events: none;
  animation: pane-fade-out 90ms ease both;
}

/* Стрелка «дальше» и галочка состояния прижаты к правому краю пункта. */
.menu-arrow,
.menu-check {
  margin-left: auto;
  color: var(--muted);
}

.menu-check {
  opacity: 0;
  transition: opacity 160ms ease;
}

.message-menu-item[aria-pressed="true"] .menu-check {
  opacity: 1;
  color: var(--accent);
}

.menu-back .icon { color: var(--muted); }

.menu-back {
  color: var(--muted);
  font-size: 12px;
}

/* Колокольчик переключается сменой иконок, как микрофон в звонке. */
.notify-icons {
  width: 22px;
  height: 22px;
}

.notify-icons .icon-off {
  opacity: 0;
  transform: scale(0.5);
}

.profile-action.is-muted .notify-icons .icon-on {
  opacity: 0;
  transform: scale(0.5);
}

.profile-action.is-muted .notify-icons .icon-off {
  opacity: 1;
  transform: none;
}

/* Меню и затемнение уходят так же плавно, как приходят: раньше они
   появлялись с анимацией, а исчезали щелчком. */
.message-menu.is-closing {
  pointer-events: none;
  animation: menu-out 140ms ease both;
}

.message-dim.is-closing {
  pointer-events: none;
  animation: dim-out 140ms ease both;
}

@keyframes menu-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: scale(0.96); }
}

@keyframes dim-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ───────────── Вид раздела вложений ─────────────

   Раздел — не отдельный экран, а второй вид той же карточки: сведения о
   человеке уходят, список приходит. Переход тот же, что везде в проекте:
   90 мс на уход, 110 мс на приход, без наложения. */

/* Оба вида лежат в своей обёртке: уходящий на время перехода
   вынимается из потока и ложится ровно на место приходящего, не
   накрывая шапку карточки. */
.profile-views {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.view-in { animation: pane-fade-in 110ms ease 90ms both; }

/* Список вложений при смене раздела уходит тем же движением, что и
   целые виды: гаснет за 90 мс, а приходящий проявляется за 110. Шапка
   и полоса пилюль при этом стоят на месте — уходит только список. */
/* Свежая карточка: списку не за кем занимать очередь, поэтому он
   проявляется сразу — заодно с самой панелью, а не после неё. */
#profileSharedContent.view-in.is-first { animation-delay: 0s; }

#profileSharedContent.is-fading {
  animation: pane-fade-out 90ms ease both;
  pointer-events: none;
}

.view-out {
  pointer-events: none;
  position: absolute;
  inset: 0;
  animation: pane-fade-out 90ms ease both;
}

.profile-scroll[hidden] { display: none; }

/* Пустой раздел — карточкой того же вида, что «Логин» и «Код
   безопасности»: значок раздела и подпись по центру. Раньше подпись
   жила в пилюле кнопки «Показать ещё» и прилипала к её левому краю. */
.shared-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 20px;
  border-radius: 24px;
  background: var(--field);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.shared-empty strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.shared-empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--field-strong);
  color: var(--text-soft);
}

.shared-empty-icon .icon {
  width: 22px;
  height: 22px;
}

/* «Показать ещё»: её наполняет рабочий код. */
.shared-load-more {
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
  border: 0;
  border-radius: 19px;
  background: var(--field);
  color: var(--text-soft);
  font: inherit;
  font-size: 13px;
  transition:
    background-color 160ms ease,
    transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.shared-load-more.is-pressed { transform: scale(0.97); }

/* В виде раздела полоса пилюль прилипает к верху: список длинный, а
   переключаться между разделами удобно на месте. */
#profileSharedView .profile-tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 3;
  padding-top: 4px;
  background: var(--panel-bg);
}

/* Рабочий код раскрывает меню классом open — на случай, если атрибут
   hidden при этом останется, показываем меню и по классу. */
.message-menu.open[hidden],
.compose-menu.open[hidden] { display: block; }
