/* Д-2170: экран «Пригласи друга», вход друга, корзина. Закрытый модуль referal*.js. Цвета ТОЛЬКО токены tokens.css
   (макет `docs/mockups/d2170-bayapass/`, вариант А). Движение - только transform и opacity; «Уменьшение движения» выключает всё. */

.rf { --tw: 150px; padding: 2px 0 16px; color: var(--text); }
.rf-title { display: flex; align-items: center; gap: 10px; margin: 6px 4px 10px; }
.rf-title h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 800; }
.rf-later { margin-left: auto; padding: 2px 10px; border: 1px solid var(--warn); border-radius: 999px; color: var(--warn-text); font-size: 12px; font-weight: 600; }
.rf-score { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 8px; margin: 0 4px; }
.rf-score b { font-size: 40px; line-height: 1.05; font-weight: 800; font-variant-numeric: tabular-nums; }
.rf-score .of { font-size: 18px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.rf-score .lb { font-size: 15px; color: var(--muted); }
.rf-hint { display: flex; align-items: center; gap: 8px; margin: 6px 4px 12px; font-size: 15px; font-weight: 600; color: var(--ok-text); line-height: 1.3; }
.rf-hint.mute { color: var(--muted); }
.rf-hint .rf-ico { flex: 0 0 20px; width: 20px; height: 20px; }

/* значки: линия, цвет от текста */
.rf-ico { display: inline-flex; flex: none; width: 16px; height: 16px; }
.rf-ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* рисунки призов: схема без текста, настоящие картинки придут по prompts.md макета */
.rf-art, .rf-ic { display: block; width: 100%; height: 100%; color: var(--text); }
.rf-ic * { stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.rf-ic .f { fill: var(--panel-2); }
.rf-ic .a { fill: var(--accent); fill-opacity: .9; stroke: none; }
.rf-ic .w { fill: var(--text); stroke: none; }
.rf-ic .s { fill: none; opacity: .7; }
.rf-ic .k { stroke: var(--on-solid); stroke-width: 1.8; }
.rf-ic .kd { fill: var(--on-solid); stroke: none; }
.rf-img { position: relative; aspect-ratio: 1; border-radius: 12px; background: radial-gradient(circle at 30% 18%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 62%), var(--panel-2); display: grid; place-items: center; overflow: hidden; }
.rf-img .rf-art { width: 78%; height: 78%; }
.rf-art .rf-foto { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 10px; }

/* статусы: слово и значок, не только цвет */
.rf-st { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center; font-family: inherit; }
.rf-st span { min-width: 0; overflow-wrap: anywhere; }
.rf-st.ok { color: var(--ok-text); }
.rf-st.on { background: var(--main); color: var(--on-ok); padding: 4px 8px; border: 0; border-radius: 999px; max-width: 100%; box-sizing: border-box; min-width: 0; min-height: 28px; }
.rf-st.off { color: var(--muted); }
.rf-st.cur { color: var(--ok-text); font-size: 15px; }
.rf-sub { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
button.rf-st.on { min-height: 44px; cursor: pointer; }

/* лента-шкала: прокрутка вправо, ближайшая ступень по центру, следующая выглядывает с края */
.rf-strip { overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -12px; padding: 4px calc(50vw - var(--tw) / 2) 12px; scrollbar-width: none; overscroll-behavior-x: contain; }
.rf-strip::-webkit-scrollbar { display: none; }
.rf-track { position: relative; display: flex; gap: 10px; width: max-content; padding-top: 34px; }
.rf-rail, .rf-fill { position: absolute; top: 10px; left: calc(var(--tw) / 2); right: calc(var(--tw) / 2); height: 4px; border-radius: 2px; }
.rf-rail { background: var(--line); }
.rf-fill { background: var(--accent); transform-origin: left center; transform: scaleX(var(--to)); }
.rf-fill.play { animation: rf-fillx 1.1s cubic-bezier(.2, .7, .2, 1) .25s both; }
.rf-tile { position: relative; flex: 0 0 var(--tw); width: var(--tw); scroll-snap-align: center; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; box-sizing: border-box; }
.rf-tile.cur { border-color: transparent; }
.rf-tile.got { border-color: var(--ok-edge); }
.rf-tile.now { background: linear-gradient(var(--ok-wash), var(--ok-wash)), var(--panel); }
.rf-tile.ready { border-color: transparent; }
.rf-in { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.rf-tile.cur .rf-in, .rf-tile.ready .rf-in { background: var(--ok-wash); margin: -10px; padding: 10px; border-radius: 13px; }
.rf-node { position: absolute; top: -34px; left: 50%; margin-left: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--panel); border: 3px solid var(--line); box-sizing: border-box; display: grid; place-items: center; z-index: 2; }
.rf-node .rf-ico { width: 12px; height: 12px; color: var(--on-ok); }
.rf-node .rf-ico svg { stroke-width: 3.4; }
.rf-tile.got .rf-node { background: var(--accent); border-color: var(--accent); }
.rf-tile.cur .rf-node { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ok-edge-soft); }
.rf-node.pop { animation: rf-pop .6s cubic-bezier(.2, .7, .2, 1) 1.1s both; }
.rf-num { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.rf-num b { font-size: 28px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.rf-num span { font-size: 13px; color: var(--muted); }
.rf-tile.closed .rf-img { opacity: .78; }
.rf-name { font-size: 14px; font-weight: 700; line-height: 1.2; text-align: center; min-height: 3.6em; overflow-wrap: anywhere; display: flex; align-items: center; justify-content: center; }
.rf-foot { margin-top: auto; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* бегунок по рамке текущей ступени: один виток света, только transform */
.rf-run { position: absolute; inset: -1px; border-radius: 15px; overflow: hidden; pointer-events: none; z-index: 0; }
.rf-run::before { content: ""; position: absolute; left: 50%; top: 50%; width: 300%; aspect-ratio: 1; margin: -150% 0 0 -150%; background: conic-gradient(from 0deg, transparent 0 62%, var(--accent) 88%, transparent 100%); animation: rf-spin 3.4s linear infinite; }
.rf-run::after { content: ""; position: absolute; inset: 2px; border-radius: 13px; background: var(--panel); }
@keyframes rf-spin { to { transform: rotate(360deg); } }
@keyframes rf-fillx { from { transform: scaleX(var(--from)); } to { transform: scaleX(var(--to)); } }
@keyframes rf-pop { 0% { transform: scale(.55); opacity: 0; } 60% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* ссылка, «Пригласить», QR, условия */
.rf-share { margin: 14px 0 0; }
.rf-for { margin: 0 4px 8px; font-size: 14px; color: var(--muted); line-height: 1.35; }
.rf-for b { color: var(--ok-text); font-weight: 700; }
.rf-link { display: flex; align-items: stretch; gap: 8px; margin: 0 0 10px; }
.rf-url { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font: 600 15px/1.2 ui-monospace, Menlo, monospace; color: var(--text); overflow: hidden; white-space: nowrap; }
/* адрес сжимается с конца хозяина, а `/?ref=<код>` не обрезается никогда: по нему ссылку узнают */
.rf-url-h { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rf-url-t { flex: none; }
.rf-copy { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 14px; border: 1px solid var(--ok-edge); border-radius: 12px; background: var(--panel); color: var(--ok-text); font: inherit; font-size: 15px; font-weight: 700; }
.rf-copy .rf-ico { width: 20px; height: 20px; }
.rf-link.done .rf-url { border-color: var(--ok-edge); }
.rf-link.done .rf-copy { background: var(--ok-wash); }
.rf-tekst { margin: 0 4px 10px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; user-select: all; }
.rf-tekst[hidden] { display: none; }
.rf-inv { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border: 0; border-radius: 12px; background: var(--main); color: var(--on-ok); font: inherit; font-size: 17px; font-weight: 800; }
.rf-inv .rf-ico { width: 22px; height: 22px; }
.rf-qr-btn { display: block; width: 100%; min-height: 44px; margin-top: 2px; border: 0; background: none; color: var(--ok-text); font: inherit; font-size: 14px; font-weight: 700; }
.rf-copy:focus-visible, .rf-inv:focus-visible, .rf-qr-btn:focus-visible, .rf-st.on:focus-visible, .rf-prize-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rf-cond { margin: 2px 4px 0; font-size: 13px; color: var(--muted); }
.rf-cond summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; cursor: pointer; list-style: none; }
.rf-cond summary::-webkit-details-marker { display: none; }
.rf-cond summary::after { content: "\203A"; font-size: 20px; margin-left: 6px; transform: rotate(90deg); }
.rf-cond[open] { padding: 0 0 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin: 6px 0 0; }
.rf-cond[open] summary { padding: 0 14px; }
.rf-cond[open] summary::after { transform: rotate(-90deg); }
.rf-cl { margin: 0; padding: 0 14px 6px; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.rf-cl li { line-height: 1.4; color: var(--muted); }
.rf-cl b { color: var(--text); font-weight: 700; }
.rf-hidden-copy { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* серое «позже» (D-284): лента без чисел, ссылки нет */
.rf-dim { opacity: .45; pointer-events: none; }

/* окно QR и окно сюрприза: узлы в body, вне перерисовываемого тела */
.rf-back, .rf-shade { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: var(--gde-skrim); }
.rf-qr { box-sizing: border-box; width: min(86vw, 360px); padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); display: flex; flex-direction: column; gap: 14px; }
.rf-qr-img { width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; }
.rf-sur-win { box-sizing: border-box; width: min(calc(100vw - 32px), 420px); padding: 18px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; background: var(--panel); border: 1px solid var(--ok-edge); border-radius: 18px; box-shadow: 0 0 0 4px var(--ok-edge-soft); animation: rf-sur-in .45s cubic-bezier(.2, .7, .2, 1) both; }
.rf-sur-img { width: min(52vw, 176px); aspect-ratio: 1; border-radius: 14px; background: radial-gradient(circle at 30% 18%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 62%), var(--panel-2); display: grid; place-items: center; }
.rf-sur-img .rf-art { width: 78%; height: 78%; }
.rf-sur-joke { font-size: 22px; line-height: 1.2; font-weight: 800; overflow-wrap: anywhere; }
.rf-sur-gift { font-size: 16px; color: var(--ok-text); font-weight: 700; }
@keyframes rf-sur-in { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }

/* Основатель: тот же вид, цвет даёт уровень гостя (moyo-cvet.js), здесь только лёгкие прожилки */
.rf.gold { position: relative; }
.rf.gold::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .4; z-index: 0; background: repeating-linear-gradient(115deg, transparent 0 46px, color-mix(in srgb, var(--accent) 8%, transparent) 47px 48px, transparent 49px 93px); animation: rf-vein 7s ease-in-out infinite; }
.rf.gold > * { position: relative; z-index: 1; }
@keyframes rf-vein { 0%, 100% { opacity: .25; } 50% { opacity: .7; } }

/* строка в «Моё»: серая и мёртвая, пока облако молчит (D-284) */
.mo-ref.mo-ref-later { opacity: .6; border-style: dashed; box-shadow: none; background-image: none; cursor: default; }
.mo-ref.mo-ref-later .mo-ref-ic { background: var(--panel-2); color: var(--muted); }

/* вход друга: плашка над формой входа */
.rf-invite { box-sizing: border-box; margin: 0 0 16px; padding: 18px 16px; border: 1px solid var(--accent); border-radius: var(--radius-lg); background: var(--accent-wash); color: var(--text); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rf-invite-lead { font-size: 19px; line-height: 1.25; }
.rf-invite-big { font-size: 64px; line-height: 1; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.rf-invite-set { font-size: 22px; line-height: 1.2; font-weight: 800; overflow-wrap: anywhere; }
.rf-invite-what { margin: 4px 0 0; font-size: 17px; line-height: 1.35; }
.rf-invite-fix { margin: 0; font-size: 15px; line-height: 1.35; color: var(--muted); }
.rf-invite-hall { margin-top: 4px; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); font-size: 15px; font-weight: 700; }
.rf-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); font-size: 15px; }
.rf-note-x { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 24px; }

/* корзина: скидка другу, метка у позиции, приз */
.rf-cart { margin: 6px 0; padding: 10px 12px; border: 1px solid var(--accent); border-radius: var(--radius-lg); background: var(--accent-wash); }
.rf-cart-top { display: flex; justify-content: space-between; gap: 10px; font-size: 16px; }
.rf-cart-set { margin-top: 4px; font-size: 13px; line-height: 1.35; color: var(--muted); overflow-wrap: anywhere; }
.rf-cart-lost { margin: 2px 0 6px; font-size: 13px; color: var(--muted); }
.rf-cart-tag { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 0; padding: 4px 12px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); font-size: 15px; font-weight: 700; }
.rf-cart-tag .mo-ic, .rf-cart-tag .mo-ic svg { width: 18px; height: 18px; }
.rf-prize { margin: 8px 0; padding: 12px; border: 1px solid var(--ok-edge); border-radius: var(--radius-lg); background: var(--ok-wash); display: flex; flex-direction: column; gap: 8px; }
.rf-prize.mute { border-color: var(--line); background: var(--panel); }
.rf-prize-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.rf-prize-head .mo-ic, .rf-prize-head .mo-ic svg { width: 22px; height: 22px; }
.rf-prize-row, .rf-prize-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rf-prize-name { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.rf-prize-note { font-size: 13px; color: var(--muted); line-height: 1.35; }
.rf-prize-btn { flex: none; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--main); color: var(--on-ok); font: inherit; font-size: 15px; font-weight: 800; }
.rf-prize-btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 700; }
.rf-prize-btn[disabled] { opacity: .55; }

@media (max-width: 380px) {
  .rf { --tw: 136px; }
  .rf-score b { font-size: 34px; }
  .rf-title h1 { font-size: 20px; }
  .rf-name { font-size: 13px; }
  .rf-st.on .rf-ico { display: none; }
  .rf-st.on { font-size: 12px; }
  .rf-invite-big { font-size: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .rf-run::before, .rf-fill.play, .rf-node.pop, .rf.gold::before, .rf-sur-win { animation: none !important; }
  .rf-run::before { display: none; }
  .rf-run { border: 2px solid var(--ok-edge); }
  .rf-run::after { display: none; }
}
