/*
 * STAGE33R — application shell layout (design system v5).
 * Desktop: command bar + context bar, full-width content, no sidebar.
 * Mobile (<= 860px): compact top bar, bottom tab bar, bottom sheet,
 * full-screen search palette. Tokens come from stage33r.css.
 */

.s-skip {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  padding: 10px 14px; border-radius: var(--s-radius);
  background: var(--s-cyan); color: var(--s-ink-inv); font-weight: 600;
}
.s-skip:focus { top: 12px; }

/* ---------------------------------------------------------- command bar */
.s-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 9, 13, 0.9);
  backdrop-filter: blur(10px) saturate(130%);
  -webkit-backdrop-filter: blur(10px) saturate(130%);
  border-bottom: 1px solid var(--s-line);
}
.s-bar__inner {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  height: var(--s-bar-h);
  max-width: var(--s-max);
  margin: 0 auto;
  padding-inline: var(--s-gutter);
}

.s-brand { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; color: var(--s-ink); }
:where(.s-body) a.s-brand:hover { text-decoration: none; }
.s-mark { width: 26px; height: 26px; color: var(--s-cyan); flex-shrink: 0; }
.s-mark--sm { width: 18px; height: 18px; }
.s-brand__word {
  font-family: var(--s-f-display);
  font-stretch: 122%;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--s-ink);
}
.s-brand__word span { color: var(--s-cyan); }

/* Primary navigation */
.s-nav { flex: 1 1 auto; min-width: 0; height: 100%; }
.s-nav__list { display: flex; align-items: stretch; height: 100%; gap: 2px; margin: 0; padding: 0; list-style: none; }
.s-nav__list > li { display: flex; position: relative; }
.s-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--s-ink-2);
  font-family: var(--s-f-text);
  font-size: var(--s-t-14);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
:where(.s-body) a.s-nav__link { color: var(--s-ink-2); }
:where(.s-body) a.s-nav__link:hover, .s-nav__link:hover { color: var(--s-ink); text-decoration: none; }
.s-nav__link[aria-current="page"], .s-nav__link[data-current="true"] { color: var(--s-ink); }
.s-nav__link[aria-current="page"]::after, .s-nav__link[data-current="true"]::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--s-cyan);
}
.s-nav__link:focus-visible { box-shadow: inset var(--s-focus); }
.s-nav__chev { width: 14px; height: 14px; transition: transform 160ms var(--s-ease); }
.s-nav__trigger[aria-expanded="true"] .s-nav__chev { transform: rotate(180deg); }
.s-nav__tag { height: 18px; font-size: 11px; padding: 0 5px; }

/* Intelligence menu */
.s-menu {
  position: absolute;
  top: calc(100% + 1px);
  left: -12px;
  width: min(680px, calc(100vw - 48px));
  padding: var(--s-4);
  background: var(--s-panel);
  border: 1px solid var(--s-line-2);
  border-radius: 0 0 var(--s-radius-lg) var(--s-radius-lg);
  box-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.8);
  z-index: 120;
}
.s-menu__head { display: flex; flex-direction: column; gap: 4px; padding: 0 var(--s-2) var(--s-3); border-bottom: 1px solid var(--s-line); margin-bottom: var(--s-2); }
.s-menu__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; margin: 0; padding: 0; list-style: none; }
.s-menu__item { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); padding: 10px var(--s-2); border-radius: var(--s-radius); color: var(--s-ink); }
:where(.s-body) a.s-menu__item:hover { background: var(--s-panel-2); text-decoration: none; }
.s-menu__icon { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border: 1px dashed rgba(169, 145, 255, 0.5); border-radius: var(--s-radius); color: var(--s-violet); }
.s-menu__icon svg { width: 15px; height: 15px; }
.s-menu__text { display: flex; flex-direction: column; min-width: 0; }
.s-menu__title { font-size: var(--s-t-13); font-weight: 600; }
.s-menu__desc { font-size: var(--s-t-12); color: var(--s-ink-3); line-height: 1.35; }

/* Tools */
.s-bar__tools { display: flex; align-items: center; gap: var(--s-3); flex-shrink: 0; margin-left: auto; }

.s-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 260px;
  height: 36px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--s-line-2);
  border-radius: var(--s-radius);
  background: var(--s-bg-2);
  color: var(--s-ink-3);
}
.s-search:focus-within { border-color: var(--s-cyan); box-shadow: 0 0 0 3px rgba(63, 213, 242, 0.12); }
.s-search__icon { width: 15px; height: 15px; flex-shrink: 0; }
.s-search__input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: none; color: var(--s-ink); font: 400 var(--s-t-13) var(--s-f-text); }
.s-search__input::placeholder { color: var(--s-ink-3); opacity: 1; }
.s-search__kbd { font-family: var(--s-f-mono); font-size: 11px; padding: 1px 6px; border: 1px solid var(--s-line-2); border-radius: 2px; color: var(--s-ink-3); }

.s-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border: 1px solid var(--s-line-2); border-radius: var(--s-radius);
  background: var(--s-bg-2); color: var(--s-ink-2); cursor: pointer;
}
.s-iconbtn:hover { color: var(--s-ink); border-color: var(--s-ink-3); }
.s-iconbtn svg { width: 16px; height: 16px; }
.s-search-open { display: none; }

/* Source indicator */
.s-srcind { display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border: 1px solid var(--s-line); border-radius: var(--s-radius); white-space: nowrap; }
:where(.s-body) a.s-srcind { color: var(--s-ink-2); }
:where(.s-body) a.s-srcind:hover { color: var(--s-ink); border-color: var(--s-line-2); text-decoration: none; }
.s-srcind__lights { display: inline-flex; gap: 3px; }
.s-srcind__lights i { width: 6px; height: 14px; border-radius: 1px; background: var(--s-panel-3); }
.s-srcind__lights i[data-h="operational"] { background: var(--s-ok); }
.s-srcind__lights i[data-h="degraded"] { background: var(--s-warn); }
.s-srcind__lights i[data-h="failed"] { background: var(--s-fail); }
/* No signal reads as dashes (the same "—" used for unavailable figures), not as empty boxes. */
.s-srcind__lights { align-items: center; height: 14px; }
.s-srcind__lights i[data-h="unknown"] { height: 2px; background: var(--s-ink-3); }
.s-srcind__lights i[data-h="not-configured"] { background: transparent; box-shadow: inset 0 0 0 1px var(--s-line-2); }
.s-srcind__label { font-size: var(--s-t-12); }
.s-srcind__k { font-family: var(--s-f-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--s-ink-3); }

/* Account */
.s-acct { position: relative; }
.s-acct__btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border: 1px solid var(--s-line-2); border-radius: var(--s-radius); background: var(--s-bg-2); color: var(--s-ink); font-size: var(--s-t-13); font-weight: 600; cursor: pointer; white-space: nowrap; }
.s-acct__btn:hover { border-color: var(--s-ink-3); }
.s-acct__avatar { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 2px; background: var(--s-panel-3); color: var(--s-cyan); }
.s-acct__avatar svg { width: 14px; height: 14px; }
.s-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 120;
  min-width: 280px; padding: 6px;
  background: var(--s-panel); border: 1px solid var(--s-line-2); border-radius: var(--s-radius-lg);
  box-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.8);
}
.s-pop__item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--s-radius); font-size: var(--s-t-13); color: var(--s-ink); }
.s-pop__item svg { width: 15px; height: 15px; color: var(--s-ink-3); flex-shrink: 0; }
:where(.s-body) a.s-pop__item { color: var(--s-ink); }
:where(.s-body) a.s-pop__item:hover { background: var(--s-panel-2); text-decoration: none; }
.s-pop__item--off { color: var(--s-ink-3); justify-content: flex-start; }
.s-pop__item--off .s-tag { margin-left: auto; }

/* ---------------------------------------------------------- context bar */
.s-ctx { border-bottom: 1px solid var(--s-line); background: var(--s-bg); }
.s-ctx__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: var(--s-ctx-h); max-width: var(--s-max); margin: 0 auto; padding-inline: var(--s-gutter); }
.s-crumbs ol { display: flex; align-items: center; flex-wrap: wrap; gap: 0; margin: 0; padding: 0; list-style: none; font-family: var(--s-f-mono); font-size: var(--s-t-11); letter-spacing: 0.06em; text-transform: uppercase; }
.s-crumbs li { display: inline-flex; align-items: center; color: var(--s-ink-3); }
.s-crumbs li + li::before { content: '/'; margin: 0 10px; color: var(--s-line-2); }
.s-crumbs a { color: var(--s-ink-3); }
.s-crumbs a:hover { color: var(--s-ink); }
.s-crumbs [aria-current="page"] { color: var(--s-ink); }
.s-ctx__meta { display: flex; align-items: center; gap: var(--s-3); font-family: var(--s-f-mono); font-size: var(--s-t-11); color: var(--s-ink-3); white-space: nowrap; }
.s-ctx__meta .s-live { display: inline-flex; align-items: center; gap: 6px; color: var(--s-ink-2); }
.s-ctx__meta .s-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--s-ok); }
.s-ctx__meta .s-live[data-state="unavailable"]::before { background: var(--s-amber); }

/* ---------------------------------------------------------- main + footer */
.s-main { display: block; min-width: 0; padding-bottom: var(--s-12); }
html { scroll-padding-top: calc(var(--s-bar-h, 60px) + 12px); }
.s-main:focus { outline: none; }
.s-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3) var(--s-6);
  margin-top: var(--s-16); padding: var(--s-5) 0; border-top: 1px solid var(--s-line);
  font-size: var(--s-t-12); color: var(--s-ink-3);
}
.s-foot__brand { display: inline-flex; align-items: center; gap: 10px; }
.s-foot__brand .s-mark { color: var(--s-ink-3); }
.s-foot nav { display: flex; gap: var(--s-5); flex-wrap: wrap; }
.s-foot a { color: var(--s-ink-2); }

/* ---------------------------------------------------------- mobile model */
.s-tabbar { display: none; }
.s-scrim { position: fixed; inset: 0; z-index: 300; background: rgba(2, 4, 8, 0.66); }
.s-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 310;
  max-height: 82vh; overflow-y: auto;
  background: var(--s-panel); border-top: 1px solid var(--s-line-2);
  border-radius: 12px 12px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -24px 48px rgba(0, 0, 0, 0.6);
}
.s-sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--s-line-2); margin: 10px auto 2px; }
.s-sheet__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-4) var(--s-3); border-bottom: 1px solid var(--s-line); }
.s-sheet__body { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
.s-sheet__list { margin: 0 0 var(--s-2); padding: 0; list-style: none; }
.s-sheet__list a { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); min-height: 48px; padding: 0 var(--s-2); border-bottom: 1px solid var(--s-line); color: var(--s-ink); font-size: var(--s-t-14); }
:where(.s-body) .s-sheet__list a:hover { text-decoration: none; background: var(--s-panel-2); }
.s-sheet__list svg { width: 18px; height: 18px; color: var(--s-ink-3); }

.s-palette { position: fixed; inset: 0; z-index: 320; display: flex; justify-content: center; align-items: flex-start; padding: 12vh var(--s-4) var(--s-4); background: rgba(2, 4, 8, 0.72); backdrop-filter: blur(3px); }
.s-palette[hidden] { display: none; }
.s-palette__box { width: min(640px, 100%); background: var(--s-panel); border: 1px solid var(--s-line-2); border-radius: var(--s-radius-lg); box-shadow: 0 32px 64px -20px rgba(0, 0, 0, 0.9); overflow: hidden; }
.s-palette__form { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-bottom: 1px solid var(--s-line); color: var(--s-ink-3); }
.s-palette__form > svg { width: 18px; height: 18px; flex-shrink: 0; }
.s-palette__input { flex: 1; min-width: 0; height: 40px; border: 0; outline: none; background: none; color: var(--s-ink); font: 400 var(--s-t-16) var(--s-f-text); }
.s-palette__input::placeholder { color: var(--s-ink-3); opacity: 1; }
.s-palette__scopes { display: flex; flex-wrap: wrap; gap: 6px; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--s-line); }
.s-palette__quick { display: flex; flex-direction: column; padding: var(--s-3) var(--s-2) var(--s-2); }
.s-palette__quick .s-index { padding: 0 var(--s-2) var(--s-2); }
.s-palette__quick a { display: flex; align-items: center; gap: var(--s-3); min-height: 40px; padding: 0 var(--s-2); border-radius: var(--s-radius); color: var(--s-ink); font-size: var(--s-t-13); }
.s-palette__quick a svg { width: 15px; height: 15px; color: var(--s-ink-3); }
:where(.s-body) .s-palette__quick a:hover { background: var(--s-panel-2); text-decoration: none; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .s-search { display: none; }
  .s-search-open { display: inline-flex; }
  .s-bar__inner { gap: var(--s-4); }
}
@media (max-width: 1100px) {
  .s-srcind__k, .s-nav__tag { display: none; }
  .s-nav__link { padding: 0 9px; font-size: var(--s-t-13); }
  .s-nav__link[aria-current="page"]::after, .s-nav__link[data-current="true"]::after { left: 9px; right: 9px; }
}
@media (max-width: 960px) {
  .s-srcind__label { display: none; }
  .s-acct__name { display: none; }
  .s-acct__btn { padding: 0 4px; }
}

@media (max-width: 860px) {
  :root { --s-bar-h: 52px; }
  .s-nav { display: none; }
  .s-bar__inner { gap: var(--s-3); }
  .s-srcind { padding: 0 9px; }
  .s-ctx__inner { min-height: 34px; }
  .s-ctx__meta { display: none; }
  /* Fixed tab bar: content, anchor jumps and keyboard focus always land
     above it (and below the sticky command bar). */
  html {
    scroll-padding-top: calc(var(--s-bar-h) + 8px);
    scroll-padding-bottom: calc(var(--s-tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  }
  .s-main { padding-bottom: calc(var(--s-tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--s-6)); }
  /* While typing, the on-screen keyboard owns the bottom edge: tuck the bar away. */
  .s-tabbar { transition: transform 160ms var(--s-ease); }
  .s-body:has(:is(input:not([type="checkbox"]):not([type="radio"]), textarea, select):focus) .s-tabbar { transform: translateY(110%); }
  .s-foot { margin-top: var(--s-10); }

  .s-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--s-tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(10, 14, 20, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--s-line-2);
  }
  .s-tabbar__item {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    border: 0; background: none; cursor: pointer;
    font-family: var(--s-f-text); font-size: 11px; font-weight: 500;
  }
  :where(.s-body) .s-tabbar__item, .s-tabbar__item { color: var(--s-ink-3); }
  :where(.s-body) a.s-tabbar__item:hover { text-decoration: none; color: var(--s-ink); }
  .s-tabbar__item svg { width: 20px; height: 20px; }
  .s-tabbar__item[aria-current="page"], .s-tabbar__item[data-current="true"] { color: var(--s-cyan); }
  .s-tabbar__item[aria-current="page"]::before, .s-tabbar__item[data-current="true"]::before { content: ''; position: absolute; top: -1px; left: 26%; right: 26%; height: 2px; background: var(--s-cyan); }

  .s-palette { padding: 0; align-items: stretch; }
  .s-palette__box { width: 100%; border-radius: 0; border: 0; }
}

@media (max-width: 420px) {
  .s-brand__word { font-size: 13.5px; letter-spacing: 0.11em; }
  .s-bar__tools { gap: 8px; }
}
