/* Экран «Профиль» (frontend/js/ui/profile.js), префикс .prf-. Шапка держит свои цвета сцены (--prf-ink,
   --prf-ink-soft, --prf-sky приходят из SCENE_THEMES.profile), лист ниже — переменные темы оболочки.
   Плоский вид: никаких теней. */

.prf {
  --prf-ink: #2f3a24;
  --prf-ink-soft: #5d6a4f;
  --prf-sky: #dfe8cf;
  --prf-hero-h: 300px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

/* Экран во всю ширину: шапка — до краёв, без боковых отступов .screen. */
.screen.prf,
.prf {
  padding: 0 0 var(--nav-h, 96px);
}

.prf [hidden] {
  display: none !important;
}

/* ---------- Шапка ---------- */

.prf-hero {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: var(--prf-hero-h);
  margin: 0 auto;
  overflow: hidden;
  background: var(--prf-sky);
  color: var(--prf-ink);
  flex: none;
}

.prf-scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.prf-scene > svg {
  display: block;
  width: 100%;
  height: 100%;
}

.prf-title {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  margin: 0;
  text-align: center;
  font-size: 19px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--prf-ink);
}

.prf-id {
  position: absolute;
  top: 50px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

.prf-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 650;
  color: var(--prf-ink);
}

.prf-handle {
  flex: none;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--prf-ink-soft);
  font-weight: 500;
}

.prf-avatar {
  position: absolute;
  top: 90px;
  left: 50%;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  display: grid;
  place-items: center;
}

.prf-avatar > * {
  grid-area: 1 / 1;
}

.prf-avatar .avatar {
  border-radius: 50%;
}

.prf-ring {
  display: block;
}

.prf-ring-track {
  stroke: var(--prf-ink);
  stroke-opacity: 0.14;
}

.prf-ring-bar {
  stroke: var(--prf-ink);
  transition: stroke-dasharray 0.5s ease;
}

.prf-avatar.is-zero .prf-ring-bar {
  display: none;
}

.prf-skel-face {
  width: 96px;
  height: 96px;
}

/* Полоса: место (шестиугольник) — профит | друзья */
.prf-strip {
  position: absolute;
  top: 222px;
  left: 50%;
  width: min(320px, calc(100% - 32px));
  transform: translateX(-50%);
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.prf-hero.is-skel .prf-strip .skel-line {
  width: 200px;
}

.prf-hex {
  position: relative;
  flex: none;
  width: 48px;
  height: 54px;
  display: grid;
  place-items: center;
}

.prf-hex > * {
  grid-area: 1 / 1;
}

.prf-hex-shape {
  display: block;
}

.prf-hex-fill {
  fill: #e8a43a;
  stroke: #ffffff;
  stroke-width: 3;
}

.prf-hex.is-none .prf-hex-fill {
  fill: var(--prf-ink-soft);
}

.prf-hex-num {
  position: relative;
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.prf-fig {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.prf-fig-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 18px;
  line-height: 22px;
  font-weight: 800;
  color: var(--prf-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prf-fig-value.tone-good {
  color: var(--prf-ink);
}

.prf-fig-value.tone-bad {
  color: #c93b3b;
}

.prf-fig-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--prf-ink-soft);
  white-space: nowrap;
}

.prf-divider {
  flex: none;
  width: 1px;
  height: 34px;
  background: var(--prf-ink);
  opacity: 0.2;
}

.prf-gram {
  flex: none;
  border-radius: 50%;
  object-fit: cover;
}

/* ---------- Лист со строками ---------- */

.prf-sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: -24px auto 0;
  padding: 8px 20px 12px;
  box-sizing: border-box;
  background: var(--surface);
  border-radius: 28px 28px 0 0;
  min-height: 200px;
}

.prf-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 10px 0;
  margin: 0;
  box-sizing: border-box;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.prf-row[data-row="invite"] {
  border-bottom-color: transparent;
}

.prf-row.is-tap {
  cursor: pointer;
}

.prf-row.is-tap:active {
  opacity: 0.6;
}

.prf-row-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
}

.prf-row-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 600;
}

.prf-row-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prf-row-value > *,
.prf-gram-amount > * {
  flex: none;
}

.prf-row-chev svg,
.prf-row-icon svg {
  display: block;
}

.prf-row-chev {
  display: inline-flex;
  margin-right: -4px;
  color: var(--ink-soft);
  transition: transform 0.2s ease;
}

.prf-row.is-open .prf-row-chev {
  transform: rotate(90deg);
}

.prf-gram-amount {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.prf-ref-count {
  min-width: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  text-align: center;
}

/* Раскрытая реферальная ссылка */
.prf-ref {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 0 16px;
}

.prf-ref-text {
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-soft);
}

.prf-ref-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font: 500 13px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
  text-overflow: ellipsis;
}

.prf-ref-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.prf-ref-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

.prf-ref-btn.is-primary {
  background: var(--ink);
  color: var(--surface);
}

.prf-ref-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.prf-ref-btn:active:not(:disabled) {
  opacity: 0.7;
}

/* ---------- Ошибка (компактно) ---------- */

.prf-state {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px 14px;
  align-items: center;
  padding: 16px 0;
}

.prf-state-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--ink-soft);
}

.prf-state-title {
  font-size: 15px;
  color: var(--ink);
}

.prf-retry {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--surface);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

.prf-sheet.is-skel .prf-row .skel-line {
  width: 60%;
}

@media (prefers-reduced-motion: reduce) {
  .prf-ring-bar,
  .prf-row-chev {
    transition: none;
  }
}

/* Прокрутка. Корень профиля — сама вкладка (.screen: position absolute, inset 0, overflow-y auto). Правило .prf
   выше ставило ей position: relative, из-за чего вкладка растягивалась по содержимому, обрезалась родителем и
   не прокручивалась. Возвращаем позиционирование вкладки; блоки не сжимаются. */
.screen.prf {
  position: absolute;
  display: block;
}

.prf > * {
  flex: 0 0 auto;
}

/* Единственная цифра сцены — общий профит — стоит по центру под аватаром. */
.prf-strip .prf-fig {
  align-items: center;
  text-align: center;
}
