/* ==========================================================================
   CSTV — мобильная и ПК-надстройка (подключается ПОСЛЕ остальных CSS)
   ========================================================================== */

/* ---------- Общее: вырез экрана (safe-area) ---------- */
.topbar{padding-top:env(safe-area-inset-top,0px)}
body{padding-bottom:env(safe-area-inset-bottom,0px)}
.toast{margin-bottom:env(safe-area-inset-bottom,0px)}
.modal-actions{padding-bottom:max(0px,env(safe-area-inset-bottom,0px))}

/* ---------- Бегущая строка: пауза на касание/наведение ---------- */
.ticker-wrap.tk-paused .ticker-track{animation-play-state:paused!important}
.ticker-track .tk-item{-webkit-tap-highlight-color:rgba(255,255,255,.12)}
.ticker-wrap{touch-action:pan-y}
@media (hover:hover){.ticker-wrap:hover .ticker-track{animation-play-state:paused}}

/* ---------- Сворачивающаяся шапка ---------- */
.topbar{transition:transform .25s ease}
html.hdr-hidden .topbar{transform:translateY(-110%)}
#cstvSearchFab{display:none;position:fixed;right:12px;top:calc(env(safe-area-inset-top,0px) + 10px);z-index:1100;
  width:44px;height:44px;border-radius:50%;border:1px solid var(--border);background:var(--bg-elev-2);color:var(--text,#fff);
  align-items:center;justify-content:center;box-shadow:0 4px 14px rgba(0,0,0,.4);cursor:pointer;padding:0}
#cstvSearchFab svg{pointer-events:none}
@media (max-width:820px){html.hdr-hidden #cstvSearchFab{display:flex}}

/* ---------- Оффлайн-плашка ---------- */
#cstvOffline{display:none;position:fixed;left:0;right:0;bottom:0;z-index:2000;text-align:center;font-size:12.5px;font-weight:600;
  padding:7px 12px calc(7px + env(safe-area-inset-bottom,0px));background:#b8741a;color:#fff}
#cstvOffline.show{display:block}

/* ---------- Телефон: цели касания >= 44px ---------- */
@media (pointer:coarse){
  .btn,button.nav-item,.nav-item,.modal-close,.cmt-btn,.tabs button,.pill,select,
  input[type=text],input[type=email],input[type=password],input[type=search],input[type=number]{min-height:44px}
  .btn-sm{min-height:40px;padding-left:12px;padding-right:12px}
  .modal-close{min-width:44px}
  #commentsList .cmt-btn{min-height:36px;padding:4px 12px}
  .tk-item{padding-top:10px;padding-bottom:10px}
}

/* ---------- Телефон: чат на весь экран ---------- */
@media (max-width:820px){
  .msg-shell.thread-open{position:fixed;inset:0;z-index:1500;margin:0;border-radius:0;border:0;display:flex;flex-direction:column;
    height:100vh;height:100dvh;background:var(--bg);
    padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
  .msg-shell.thread-open .msg-list-col{display:none}
  .msg-shell.thread-open .msg-thread-col{display:flex;flex-direction:column;flex:1 1 auto;min-height:0;width:100%;max-width:none}
  .msg-shell.thread-open .msg-thread-col [class*="msg-scroll"],
  .msg-shell.thread-open .msg-thread-col [class*="msg-messages"],
  .msg-shell.thread-open .msg-thread-col [class*="msg-body"],
  .msg-shell.thread-open .msg-thread-col [class*="msg-log"]{flex:1 1 auto;min-height:0;max-height:none!important;height:auto!important;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
  .msg-shell.thread-open .msg-thread-col textarea,
  .msg-shell.thread-open .msg-thread-col input[type=text]{font-size:16px} /* iOS не зумит поле */
  html:has(.msg-shell.thread-open) .topbar,
  html:has(.msg-shell.thread-open) #cstvSearchFab{display:none!important}
  html:has(.msg-shell.thread-open){overflow:hidden}
}

/* ---------- ПК: таблицы — липкая шапка и сортировка ---------- */
@media (min-width:1024px){
  .rs-table thead th,.players-table thead th,.hltv-stats-table thead th,.sp-table thead th{
    position:sticky;top:var(--cstv-sticky-top,0px);z-index:3;background:var(--bg-elev-2)}
}
th[data-sortable]{cursor:pointer;user-select:none;white-space:nowrap}
th[data-sortable]:hover{filter:brightness(1.25)}
th[data-sortable]::after{content:"";display:inline-block;margin-left:5px;opacity:.35;font-size:9px;vertical-align:1px}
th[data-sortable][data-sort="asc"]::after{content:"\25B2";opacity:1}
th[data-sortable][data-sort="desc"]::after{content:"\25BC";opacity:1}

/* ---------- ПК: комментарии рядом с контентом (док справа) ---------- */
@media (min-width:1100px){
  .shell{transition:padding-right .25s ease}
  body.cm-docked .shell{padding-right:404px}
  #overlayComments.open{display:block!important;background:transparent!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important;pointer-events:none}
  #overlayComments.open .modal{pointer-events:auto;position:fixed;right:12px;top:12px;bottom:12px;left:auto;margin:0;
    width:380px;max-width:380px;height:auto;max-height:none;display:flex;flex-direction:column;
    box-shadow:0 8px 30px rgba(0,0,0,.45);overflow:hidden}
  #overlayComments.open #commentsList{flex:1 1 auto;max-height:none!important;min-height:0}
}

/* ---------- Палитра команд (Ctrl+K) ---------- */
#cstvPalette{display:none;position:fixed;inset:0;z-index:5000;background:rgba(0,0,0,.55);align-items:flex-start;justify-content:center;padding:12vh 12px 0}
#cstvPalette.open{display:flex}
#cstvPalette .cp-box{width:100%;max-width:620px;background:var(--bg-elev);border:1px solid var(--border);border-radius:10px;overflow:hidden;box-shadow:0 20px 60px rgba(0,0,0,.6)}
#cstvPalette .cp-input{width:100%;box-sizing:border-box;border:0;border-bottom:1px solid var(--border);background:transparent;color:inherit;font-size:16px;padding:14px 16px;outline:none}
#cstvPalette .cp-list{max-height:56vh;overflow-y:auto}
#cstvPalette .cp-group{padding:8px 16px 4px;font-size:11px;letter-spacing:.06em;text-transform:uppercase;opacity:.6}
#cstvPalette .cp-item{display:flex;justify-content:space-between;gap:10px;align-items:center;padding:9px 16px;cursor:pointer;font-size:14px}
#cstvPalette .cp-item.sel,#cstvPalette .cp-item:hover{background:var(--bg-elev-2)}
#cstvPalette .cp-sub{opacity:.6;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:45%}
#cstvPalette .cp-empty{padding:18px 16px;opacity:.7;font-size:14px}
#cstvPalette .cp-foot{display:flex;gap:14px;padding:8px 16px;border-top:1px solid var(--border);font-size:11px;opacity:.65}
kbd.cp-k{border:1px solid var(--border);border-bottom-width:2px;border-radius:4px;padding:0 5px;font:inherit;font-size:11px}

/* справка по горячим клавишам */
#cstvHelp{display:none;position:fixed;inset:0;z-index:5000;background:rgba(0,0,0,.55);align-items:center;justify-content:center;padding:12px}
#cstvHelp.open{display:flex}
#cstvHelp .ch-box{background:var(--bg-elev);border:1px solid var(--border);border-radius:10px;padding:18px 22px;max-width:460px;width:100%}
#cstvHelp h3{margin:0 0 10px}
#cstvHelp .ch-row{display:flex;justify-content:space-between;gap:12px;padding:4px 0;font-size:13.5px}

/* ---------- Скелетоны ---------- */
.cstv-sk{padding:6px 0}
.cstv-sk .sk{border-radius:8px;background:linear-gradient(90deg,var(--bg-elev) 25%,var(--bg-elev-2) 37%,var(--bg-elev) 63%);
  background-size:400% 100%;animation:cstvSk 1.3s ease infinite}
.cstv-sk .sk-title{height:26px;width:40%;margin-bottom:16px}
.cstv-sk .sk-row{height:46px;margin-bottom:10px}
.cstv-sk .sk-row:nth-child(3n){width:92%}
@keyframes cstvSk{0%{background-position:100% 50%}100%{background-position:0 50%}}
@media (prefers-reduced-motion:reduce){.cstv-sk .sk{animation:none}}

/* ---------- Мини-плеер музыки: компактная карточка в углу ---------- */
.csm-bar .csm-min{background:transparent;border:0;color:#fff;opacity:.6;cursor:pointer;font-size:16px;padding:6px 8px;border-radius:8px}
.csm-bar .csm-min:hover{opacity:1;background:rgba(255,255,255,.08)}
@media (pointer:coarse){.csm-bar .csm-min,.csm-bar .csm-x{min-width:40px;min-height:40px}}
.csm-bar.csm-mini{left:auto;right:12px;bottom:calc(12px + env(safe-area-inset-bottom,0px));
  width:min(360px,calc(100vw - 16px));box-sizing:border-box;padding:8px 10px;flex-wrap:wrap;gap:4px 6px;
  border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 10px 30px rgba(0,0,0,.55)}
.csm-bar.csm-mini .csm-now{width:auto;flex:1 1 0;min-width:0}
.csm-bar.csm-mini .csm-ctrl{flex:none}
.csm-bar.csm-mini .csm-ctrl #csmShuf,.csm-bar.csm-mini .csm-ctrl #csmRep{display:none}
.csm-bar.csm-mini .csm-vol{display:none}
.csm-bar.csm-mini .csm-prog{order:5;flex:1 1 100%}
body.csm-has-bar.csm-mini-on{padding-bottom:0}
body.csm-mini-on #csmSP{bottom:calc(130px + env(safe-area-inset-bottom,0px));right:12px}
@media (max-width:760px){.csm-bar.csm-mini{right:8px}body.csm-mini-on #csmSP{right:8px}}
/* плашка «нет сети» не должна перекрывать полноразмерный плеер */
body.csm-has-bar:not(.csm-mini-on) #cstvOffline{bottom:76px}
@media (max-width:760px){body.csm-has-bar:not(.csm-mini-on) #cstvOffline{bottom:128px}}
