/* shell.css: owned by P9b. The app shell: the sidebar foot, the phone top bar and drawer, the pulse bell,
   and the sign-in / no-access / offline pages on phones. The base shell comes from style.css (P0). */

/* ---------- desktop: the .me block sits at the foot of the nav (so the phone drawer can carry it) ---------- */
.nav { min-height: 0; overflow-y: auto; }
.nav > .me { margin-top: auto; gap: 6px; padding-left: 2px; padding-right: 2px; }
.nav > .me img { width: 32px; height: 32px; }
.nav > .me .icon-btn { padding: 4px; }
.brand-text { min-width: 0; }
.topbar-title, .nav-toggle, .nav-backdrop { display: none; }

/* pulse bell: on = lit, with a small green dot */
.me .alerts-btn { position: relative; }
.me .alerts-btn.on { color: var(--text); }
.me .alerts-btn.on::after { content: ''; position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--panel); }

/* top-bar title: the new label rises in while a copy of the old one fades out above it */
@keyframes p9-title-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes p9-title-out { to { opacity: 0; transform: translateY(-6px); } }
.topbar-cur { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
.topbar-cur.p9-title-in { animation: p9-title-in var(--dur-2) var(--ease-out) both; }
.topbar-ghost { position: absolute; left: 10px; top: 0; white-space: nowrap; pointer-events: none; }
.topbar-ghost.p9-title-out { animation: p9-title-out var(--dur-2) var(--ease-out) forwards; }

/* ---------- phones and small tablets: sticky top bar + off-canvas drawer ---------- */
@media (max-width: 860px) {
  .shell { grid-template-rows: auto 1fr; align-content: start; }
  .shell > .sidebar {
    position: sticky; top: 0; z-index: 40;
    display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 10px;
    height: calc(56px + env(safe-area-inset-top, 0px)); min-height: 0;
    padding: env(safe-area-inset-top, 0px) max(10px, env(safe-area-inset-right, 0px)) 0 max(14px, env(safe-area-inset-left, 0px));
    border-right: 0; border-bottom: 1px solid var(--border);
    background: var(--panel);
    transition: box-shadow var(--dur-2) var(--ease-out);
  }
  .shell > .sidebar.scrolled { box-shadow: 0 6px 18px rgba(0,0,0,.35); }

  /* brand: logo + name only */
  .shell > .sidebar > .brand { flex: 0 1 auto; min-width: 0; gap: 8px; border: 0; padding: 0; margin: 0; }
  .shell > .sidebar > .brand img { width: 28px; height: 28px; border-radius: 7px; }
  .shell > .sidebar .brand-name { font-size: 16px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44vw; }
  .shell > .sidebar .brand-sub { display: none; }

  /* the current view */
  .shell > .sidebar .topbar-title { display: block; position: relative; flex: 1 1 auto; min-width: 0; padding-left: 10px; border-left: 1px solid var(--border); font: 600 15px/1.25 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .shell > .sidebar .topbar-title:empty { display: none; }

  /* menu button, with the open-ticket dot */
  .shell > .sidebar .nav-toggle { display: inline-flex; position: relative; flex: 0 0 auto; width: 40px; height: 40px; min-width: 40px; margin-left: auto; margin-right: -4px; color: var(--text); }
  .shell > .sidebar .nav-toggle::after { content: ''; position: absolute; top: 7px; right: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--panel); transform: scale(0); transition: transform var(--dur-2) var(--ease-spring); }
  .shell > .sidebar .nav-toggle.has-alert::after { transform: scale(1); }
  .shell > .sidebar.open .nav-toggle::after { transform: scale(0); }

  /* the drawer */
  .shell > .sidebar .nav {
    position: fixed; z-index: 2; top: calc(56px + env(safe-area-inset-top, 0px)); bottom: 0; left: 0; width: min(300px, 85vw);
    display: flex; flex-direction: column; flex-wrap: nowrap; gap: 1px; order: 0; flex-basis: auto;
    overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: 8px 12px 0; background: var(--panel); border-right: 1px solid var(--border); box-shadow: 0 24px 60px rgba(0,0,0,.5);
    transform: translateX(-100%); /* main.js makes the closed drawer inert, so it is out of the tab order too */
    transition: transform var(--dur-3) var(--ease-out);
  }
  .shell > .sidebar.open .nav { transform: none; }
  .shell > .sidebar .nav-group { display: block; padding: 14px 12px 6px; }
  .shell > .sidebar .nav-group:first-child { padding-top: 6px; }
  .shell > .sidebar .nav-item { width: 100%; white-space: normal; border-left: 3px solid transparent; border-bottom: 0; border-radius: 8px; padding: 11px 12px; font-size: 15px; }
  .shell > .sidebar .nav-item::before { left: -3px; right: auto; top: 8px; bottom: 8px; width: 3px; height: auto; border-radius: 0 3px 3px 0; transform: scaleY(0); }
  .shell > .sidebar .nav-item.active::before { transform: scaleY(1); }

  /* drawer footer: who is signed in, alerts, sign out. It stays in view when the list scrolls. */
  .shell > .sidebar .nav > .me { display: flex; margin: auto -12px 0; border: 0; border-top: 1px solid var(--border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); position: sticky; bottom: 0; background: var(--panel); }
  .shell > .sidebar .nav > .me .me-role { display: block; }

  /* backdrop */
  .shell > .sidebar .nav-backdrop { display: block; position: fixed; z-index: 1; left: 0; right: 0; bottom: 0; top: calc(56px + env(safe-area-inset-top, 0px)); background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity var(--dur-2) var(--ease-out); }
  .shell > .sidebar.open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  /* the banners stick under the top bar instead of behind it */
  .shell > .main > .banners { top: calc(64px + env(safe-area-inset-top, 0px)); }
}

/* ---------- sign-in, no-access and offline pages ---------- */
.gate { min-height: 100dvh; }
.gate-card { animation: rise-in var(--dur-3) var(--ease-out) both; }
.gate-card .gate-mark { animation: scale-in var(--dur-3) var(--ease-out) both; animation-delay: 80ms; }
.gate-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.gate-status { min-height: 1.5em; margin: 0 0 16px !important; }
@media (max-width: 640px) {
  .gate { padding: 16px; }
  .gate-card { max-width: none; padding: 28px 20px 24px; border-radius: 14px; }
  .gate-card h1 { font-size: 28px; }
  .gate-mark { font-size: 40px; }
  .gate-actions > .btn { flex: 1 1 0; min-height: 44px; }
  .gate-card .btn-discord { width: 100%; min-height: 48px; }
}
