/* ============================================================================
   SN games — app shell: топбар, левая навигация, правая колонка, мобильная
   нижняя навигация, центр уведомлений и глобальный поиск.
   Разметку рендерит /js/shell.js; страницы кладут контент в .shell-main.
   ========================================================================== */

body.app-page{
  padding-top:var(--topbar-h);
  background:var(--bg);
}

/* Меню появляется первым. Основной контент проявляется на следующем кадре;
   fallback не оставит страницу скрытой, если JavaScript был заблокирован. */
body.app-page:not(.sn-shell-ready) .shell-main{
  opacity:0;
  visibility:hidden;
  transform:translateY(6px);
  animation:sn-shell-content-fallback .01s 2s forwards;
}
body.app-page.sn-shell-ready .shell-main{
  opacity:1;
  visibility:visible;
  transform:none;
  transition:opacity .18s var(--ease-out),transform .18s var(--ease-out);
}
@keyframes sn-shell-content-fallback{
  to{opacity:1;visibility:visible;transform:none}
}

@media (prefers-reduced-motion:reduce){
  body.app-page.sn-shell-ready .shell-main{transition:none}
}

/* ------------------------------- топбар ---------------------------------- */
.topbar{
  position:fixed;top:0;left:0;right:0;height:var(--topbar-h);
  z-index:var(--z-topbar);
  background:color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line-soft);
}
.topbar-in{
  max-width:var(--shell-max);height:100%;margin:0 auto;padding:0 16px;
  display:flex;align-items:center;gap:12px;
}

.brand{
  display:inline-flex;align-items:center;gap:8px;
  color:var(--text-strong);font-weight:800;font-size:17px;letter-spacing:.2px;
  flex:0 0 auto;
}
.brand:hover{color:var(--text-strong)}
.brand-mark{
  width:32px;height:32px;border-radius:9px;
  display:inline-flex;align-items:center;justify-content:center;
  background:var(--card-soft);border:1px solid var(--line);
  color:var(--accent);font-size:13.5px;font-weight:900;font-style:italic;
}
.brand span:not(.brand-mark){display:inline}

/* глобальный поиск */
.topbar-search{position:relative;flex:1 1 auto;max-width:420px;margin:0 auto}
.topbar-search .input-search{height:36px;border-radius:var(--radius-full);background:var(--card-soft);border-color:transparent}
.topbar-search .input-search:focus{background:var(--bg);border-color:var(--accent)}
.search-drop{
  position:absolute;top:calc(100% + 8px);left:0;right:0;
  max-height:min(70dvh,540px);overflow-y:auto;
  background:var(--bg-elev);border:1px solid var(--line);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-pop);z-index:var(--z-dropdown);padding:6px;
}
.search-drop-note{padding:10px 12px;color:var(--muted);font-size:13px}
.search-sec{padding:8px 12px 4px;color:var(--muted-2);font-size:11.5px;font-weight:800;text-transform:uppercase;letter-spacing:.06em}
.search-row{
  display:flex;align-items:center;gap:10px;width:100%;
  padding:8px 10px;border:0;border-radius:var(--radius-sm);
  background:none;color:var(--text);text-align:left;cursor:pointer;font-size:14px;
}
.search-row:hover{background:var(--card-soft)}
.search-row .u-grow b{font-weight:var(--site-font-strong)}
.search-row .sub{display:block;font-size:12.5px;color:var(--muted);margin-top:1px}
.search-row .game-tile{width:32px;height:32px;font-size:12px}

.topbar-actions{display:flex;align-items:center;gap:6px;flex:0 0 auto;margin-left:auto}
.topbar-btn{
  position:relative;width:38px;height:38px;border:0;border-radius:var(--radius-md);
  display:inline-flex;align-items:center;justify-content:center;
  background:none;color:var(--muted);cursor:pointer;
  transition:background var(--dur-fast) var(--ease-out),color var(--dur-fast) var(--ease-out);
}
.topbar-btn:hover{background:var(--card-soft);color:var(--text)}
.topbar-btn.is-active{color:var(--accent);background:var(--accent-soft)}
.topbar-btn .icon{width:21px;height:21px}
.topbar-avatar{padding:0;border:0;background:none;cursor:pointer;border-radius:50%}
.topbar-avatar .avatar{width:34px;height:34px}
.topbar-avatar:hover{opacity:.85}

/* -------------------------------- каркас ---------------------------------- */
.shell{
  max-width:var(--shell-max);margin:0 auto;
  padding:var(--shell-gap) 16px calc(var(--shell-gap) + 40px);
  display:grid;grid-template-columns:var(--sidebar-w) minmax(0,1fr) var(--rail-w);
  gap:var(--shell-gap);
  align-items:start;
}
body.app-page:not([data-shell-rail="1"]) .shell{
  grid-template-columns:var(--sidebar-w) minmax(0,1fr);
}
.shell.no-rail{grid-template-columns:var(--sidebar-w) minmax(0,1fr)}

/* ------------------------------ левое меню -------------------------------- */
.shell-nav{
  grid-column:1;
  grid-row:1;
  position:sticky;top:calc(var(--topbar-h) + var(--shell-gap));
  display:flex;flex-direction:column;gap:2px;
  max-height:calc(100dvh - var(--topbar-h) - var(--shell-gap)*2);
  overflow-y:auto;overscroll-behavior:contain;
}
.nav-item{
  display:flex;align-items:center;gap:12px;
  height:40px;padding:0 12px;border-radius:var(--radius-md);
  color:var(--muted);font-size:14.5px;font-weight:var(--site-font-strong);
  transition:background var(--dur-fast) var(--ease-out),color var(--dur-fast) var(--ease-out);
}
.shell-nav .nav-item[hidden]{display:none}
.nav-item:hover{background:var(--card-soft);color:var(--text)}
.nav-item.active{background:var(--accent-soft);color:var(--text-strong);font-weight:var(--site-font-strong)}
.nav-item .icon{width:21px;height:21px;flex:0 0 auto}
.nav-item .nav-count{
  margin-left:auto;min-width:20px;height:20px;padding:0 6px;border-radius:var(--radius-full);
  background:var(--accent);color:var(--on-accent);font-size:11.5px;font-weight:800;line-height:20px;text-align:center;
}
.shell-nav button.nav-item{
  width:100%;border:0;background:transparent;font:inherit;text-align:left;cursor:pointer;
}
.shell-nav button.nav-item:hover{background:var(--card-soft);color:var(--text)}
.shell-nav .nav-action{color:var(--text)}
.shell-nav .nav-action .icon{color:var(--muted)}
.nav-sep{height:1px;margin:8px 12px;background:var(--line-soft)}
.nav-foot{padding:10px 12px;color:var(--muted-2);font-size:11.5px;line-height:1.6}
.nav-foot a{display:inline-flex;align-items:center;min-height:30px;color:var(--muted-2)}
.nav-foot a:hover{color:var(--muted)}

/* --------------------------------- main ----------------------------------- */
.shell-main{grid-column:2;grid-row:1;min-width:0;display:grid;grid-template-columns:minmax(0,1fr);gap:var(--shell-gap);align-content:start}
.shell-main > *{min-width:0;max-width:100%}

.page-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.page-head h1{font-size:20px}
.page-head .sub{color:var(--muted);font-size:13.5px;margin-top:2px}

/* ------------------------------ правая колонка ----------------------------- */
.shell-rail{
  grid-column:3;
  grid-row:1;
  position:relative;
  display:grid;gap:calc(var(--shell-gap) + 2px);align-content:start;
  min-width:0;
  overflow:visible;
  scrollbar-width:none;
}
.shell-rail::-webkit-scrollbar{display:none}

.rail-profile-slot:empty{display:none}
.rail-profile-slot,.rail-data{min-width:0}
.rail-data{display:grid;gap:calc(var(--shell-gap) + 2px)}

.rail-card{padding:6px 0 10px}
.rail-card .card-head{padding:12px 16px 8px;border-bottom:0}
.rail-card .card-head h3{font-size:13.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}
.rail-list{display:grid;gap:4px;padding:0 8px 4px}
.rail-row{
  display:flex;align-items:center;gap:10px;
  padding:8px;min-width:0;color:var(--text);border-radius:var(--radius-sm);
  transition:background var(--dur-fast) var(--ease-out);
}
a.rail-row:hover,button.rail-row:hover{background:var(--card-soft);color:var(--text)}
button.rail-row{width:100%;border:0;background:none;font:inherit;text-align:left;cursor:pointer}
.rail-row .name{font-size:13.5px;font-weight:var(--site-font-strong);color:var(--text)}
.rail-row .sub{font-size:12px;color:var(--muted)}
.rail-row .btn{margin-left:auto}
.rail-empty{padding:9px 8px 10px;font-size:13px;color:var(--muted-2)}

/* мини-профиль текущего пользователя (верх правого рейла) */
.shell-rail .rail-profile{padding:14px 16px;display:grid;gap:12px}
.rail-profile-main{display:flex;align-items:center;gap:11px;min-width:0;color:var(--text)}
.rail-profile-main:hover{color:var(--text)}
.rail-profile-main .avatar{width:48px;height:48px}
.rail-profile-txt{min-width:0;display:grid}
.rail-profile-txt .name{font-size:14.5px;font-weight:var(--site-font-strong);color:var(--text-strong);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rail-profile-txt .sub{font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rail-profile-acts{display:flex;gap:8px}
.rail-profile-acts .btn{flex:1 1 auto;justify-content:center}
.rail-message-link{position:relative;min-width:0}
.rail-message-count{
  min-width:19px;height:19px;padding:0 5px;margin-left:auto;border-radius:999px;
  display:inline-flex;align-items:center;justify-content:center;
  background:var(--accent);color:var(--on-accent);font-size:10.5px;line-height:1;font-weight:800;
}

/* плитка игры (обложек нет — генерим градиент по названию) */
.game-tile{
  width:40px;height:40px;border-radius:var(--radius-md);flex:0 0 auto;
  display:inline-flex;align-items:center;justify-content:center;
  color:var(--gt-fg,var(--muted));font-size:14px;font-weight:900;letter-spacing:.5px;
  background:var(--gt-bg,var(--card-soft));border:1px solid var(--gt-line,var(--line-soft));
  text-transform:uppercase;
}
.game-tile-lg{width:64px;height:64px;border-radius:var(--radius-lg);font-size:20px}

/* --------------------------- мобильная навигация --------------------------- */
.bottnav{
  position:fixed;left:0;right:0;bottom:0;z-index:var(--z-topbar);
  display:none;
  background:color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
  border-top:1px solid var(--line-soft);
  padding-bottom:env(safe-area-inset-bottom,0);
}
.bottnav-in{display:grid;grid-template-columns:repeat(5,1fr);height:var(--bottnav-h)}
.bottnav a,.bottnav button{
  position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  border:0;background:none;color:var(--muted);cursor:pointer;font-size:10px;font-weight:var(--site-font-strong);
}
.bottnav .icon{width:23px;height:23px}
.bottnav a.active,.bottnav button.is-active{color:var(--text-strong)}
.bottnav .pill-count{top:4px;right:calc(50% - 20px)}
.bottnav .bn-plus{
  width:44px;height:30px;border-radius:var(--radius-full);
  display:flex;align-items:center;justify-content:center;
  background:var(--accent);color:var(--on-accent);
}
.bottnav .bn-plus .icon{width:20px;height:20px}

/* --------------------------- центр уведомлений ----------------------------- */
.notif-panel{
  position:fixed;top:calc(var(--topbar-h) + 8px);right:max(16px,calc((100vw - var(--shell-max))/2 + 16px));
  width:min(400px,calc(100vw - 24px));max-height:min(72dvh,620px);
  display:flex;flex-direction:column;
  background:var(--bg-elev);border:1px solid var(--line);border-radius:var(--radius-xl);
  box-shadow:var(--shadow-pop);z-index:var(--z-dropdown);
  animation:modal-pop var(--dur-mid) var(--ease-emph);
}
.notif-head{
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:13px 16px;border-bottom:1px solid var(--line-soft);flex:0 0 auto;
}
.notif-head h3{font-size:15px}
.notif-head .btn-icon{width:32px;height:32px;padding:0;flex:0 0 auto}
.notif-confirm{
  margin:10px 12px 6px;padding:12px;display:flex;align-items:center;justify-content:space-between;gap:12px;
  border:1px solid color-mix(in srgb,var(--danger) 28%,var(--line));border-radius:var(--radius-md);
  background:color-mix(in srgb,var(--danger) 6%,var(--card));
}
.notif-confirm.hidden{display:none}
.notif-confirm b{display:block;color:var(--text-strong);font-size:13px}
.notif-confirm p{margin:3px 0 0;color:var(--muted);font-size:11.5px;line-height:1.35}
.notif-confirm-actions{display:flex;gap:6px;flex:0 0 auto}
.notif-list{overflow-y:auto;min-height:0;padding:4px 0}
.notif-row{
  display:flex;align-items:flex-start;gap:11px;width:100%;
  padding:10px 16px;border:0;background:none;text-align:left;cursor:pointer;
  color:var(--text);transition:background var(--dur-fast) var(--ease-out);
}
.notif-row:hover{background:var(--card-soft)}
.notif-row.unread{background:var(--accent-soft)}
.notif-row.unread:hover{background:var(--accent-soft-2)}
.notif-row .txt{flex:1 1 auto;min-width:0;font-size:13.5px;line-height:1.42}
.notif-row .txt b{font-weight:var(--site-font-strong)}
.notif-row .txt .quote{color:var(--muted);display:block;margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.notif-row .when{font-size:11.5px;color:var(--muted-2);margin-top:3px;display:block}
.notif-row .dot{flex:0 0 auto;width:8px;height:8px;border-radius:50%;background:var(--accent);margin-top:6px;opacity:0}
.notif-row.unread .dot{opacity:1}
.notif-row .n-act{flex:0 0 auto}
.notif-more{
  width:calc(100% - 24px);height:38px;margin:6px 12px 12px;border:1px solid var(--line);
  border-radius:var(--radius-md);background:var(--card-soft);color:var(--text);
  font:700 12.5px var(--site-font);cursor:pointer;
}
.notif-more:hover{background:var(--card-hover);color:var(--text-strong)}

@media (max-width:640px){
  .notif-panel{
    top:var(--topbar-h);left:0;right:0;bottom:0;width:auto;max-height:none;
    border-radius:0;border-left:0;border-right:0;
  }
  .notif-head{padding-inline:12px}
  .notif-head .u-flex{gap:4px}
  .notif-head #sn_notif_readall{padding-inline:10px}
  .notif-confirm{align-items:stretch;flex-direction:column}
  .notif-confirm-actions{justify-content:flex-end}
}

/* ------------------------- меню профиля в топбаре -------------------------- */
.user-menu{top:calc(var(--topbar-h) + 6px);right:max(16px,calc((100vw - var(--shell-max))/2 + 16px));position:fixed}
.user-menu .menu-user{display:flex;align-items:center;gap:10px;padding:10px;border-bottom:1px solid var(--line-soft);margin-bottom:5px}
.user-menu .menu-user .u-grow{min-width:0;display:grid;gap:2px}
.user-menu .menu-user .name{font-weight:var(--site-font-strong);color:var(--text-strong);font-size:14px}
.user-menu .menu-user .sub{font-size:12px;line-height:1.35;color:var(--muted);white-space:normal;overflow-wrap:anywhere}

/* ------------------------------- адаптив ----------------------------------- */
@media (max-width:1120px){
  .shell,.shell.no-rail{grid-template-columns:var(--sidebar-w) minmax(0,1fr)}
  .shell-rail{display:none}
}

@media (max-width:900px){
  body.app-page{padding-bottom:calc(var(--bottnav-h) + env(safe-area-inset-bottom,0px))}
  .shell,.shell.no-rail{grid-template-columns:minmax(0,1fr);padding:14px 10px calc(var(--bottnav-h) + 40px)}
  body.app-page:not([data-shell-rail="1"]) .shell{grid-template-columns:minmax(0,1fr)}
  .shell-main{grid-column:1}
  .shell-nav{display:none}
  .bottnav{display:block}
  .topbar-search{display:none}
  .topbar-in{gap:8px}
  .topbar-btn.only-mobile-search{display:inline-flex}
}

@media (min-width:901px){
  .topbar-btn.only-mobile-search{display:none}
}

/* декоративное свечение сверху — очень сдержанное */
body.app-page::before{
  content:"";position:fixed;top:0;left:50%;transform:translateX(-50%);
  width:min(920px,calc(100vw - 32px));height:1px;pointer-events:none;z-index:0;
  background:var(--line-soft);
  opacity:.72;
}
