/* App shell: left sidebar + main column. Loaded on every page after style.css. */

.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.app-main {
  min-width: 0;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  padding: 18px 14px 14px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}

.sidebar-brand {
  padding: 2px 8px 4px;
}

.side-search {
  position: relative;
}

.side-search .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.side-search input {
  width: 100%;
  padding: 11px 12px 11px 38px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.side-search input:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--ring);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.side-nav a,
.side-foot a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.side-nav a:hover,
.side-foot a:hover,
.side-nav a:focus-visible,
.side-foot a:focus-visible {
  background: var(--panel);
  color: var(--text);
}

.side-nav a[aria-current="page"],
.side-foot a[aria-current="page"] {
  background: var(--accent);
  color: var(--on-accent);
}

.side-nav .icon,
.side-foot .icon {
  flex: none;
  width: 19px;
  height: 19px;
  color: var(--accent-text);
}

.side-nav a[aria-current="page"] .icon,
.side-foot a[aria-current="page"] .icon {
  color: var(--on-accent);
}

.side-nav em {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 650;
}

.side-nav a[aria-current="page"] em {
  color: var(--on-accent);
}

.side-label {
  margin: 14px 12px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.side-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.side-foot a.side-sponsor {
  margin-bottom: 6px;
  justify-content: center;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.side-foot a.side-sponsor:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.side-foot a.side-sponsor:hover .icon {
  color: var(--on-accent);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-height: 56px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
}

.topbar-brand {
  display: none;
}

.topbar-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--ok-line);
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok-text);
  font-size: 13px;
  font-weight: 700;
}

.topbar-note .icon {
  width: 16px;
  height: 16px;
}

.sidebar-backdrop {
  display: none;
}

.app-main .site-footer {
  margin-top: 24px;
}

/* ---------- Small screens: sidebar becomes a drawer ---------- */

@media (max-width: 900px) {
  .app {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .js .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: min(300px, 86vw);
    height: auto;
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
    box-shadow: var(--shadow-md);
  }

  .js .app.is-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform .22s ease;
  }

  .js .app.is-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(2, 6, 23, .5);
  }

  .js .app.is-open .sidebar-backdrop[hidden] {
    display: none;
  }

  .topbar {
    justify-content: space-between;
    padding: 8px 14px;
  }

  .topbar-brand {
    display: inline-block;
    margin-right: auto;
    font-size: 20px;
  }

  .js .topbar .nav-toggle:not([hidden]) {
    display: inline-flex;
  }

  .app.is-open .nav-toggle .icon-open {
    display: none;
  }

  .app.is-open .nav-toggle .icon-close {
    display: block;
  }

  .topbar-note {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .sidebar {
    transition: none;
  }
}
