/* ==========================================================================
   SysAdmin Wiki — layout: topbar, shell, sidebar frame, footer
   ========================================================================== */

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: rgba(8, 8, 15, 0.76);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}

[data-theme="light"] .topbar {
  background: rgba(250, 250, 255, 0.82);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: var(--container);
  height: 100%;
  margin: 0 auto;
  padding: 0 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  border-radius: 12px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(167, 139, 250, 0.32);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(167, 139, 250, 0.22), rgba(96, 165, 250, 0.1));
  color: var(--violet-bright);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 6px 20px rgba(76, 29, 149, 0.22);
}

.brand__mark--sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.brand__mark--sm .icon {
  width: 18px;
  height: 18px;
}

.brand__text {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand__text strong {
  font-weight: 800;
}

.brand__text span {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 10px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.topnav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.topnav a.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--violet-bright);
  font-size: 0.66rem;
  font-weight: 800;
}

.search-trigger {
  display: flex;
  flex: 0 1 306px;
  align-items: center;
  gap: 9px;
  height: 40px;
  margin-left: auto;
  padding: 0 9px 0 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--muted);
  text-align: left;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.search-trigger:hover {
  border-color: var(--accent-line);
  background: var(--surface-solid);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-trigger .icon {
  width: 17px;
  height: 17px;
}

.search-trigger__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.topbar__actions .icon-btn {
  width: 38px;
  height: 38px;
}

.topbar__menu {
  display: none;
  width: 38px;
  height: 38px;
}

[data-theme="dark"] .icon--moon {
  display: none;
}

[data-theme="light"] .icon--sun {
  display: none;
}

/* ---------- shell ---------- */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  width: 100%;
  max-width: var(--container);
  min-height: 100vh;
  margin: 0 auto;
  padding-top: var(--topbar-h);
}

.main {
  min-width: 0;
  outline: none;
}

.app {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 36px 44px 88px;
  animation: pageIn 0.45s var(--ease) both;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- sidebar frame ---------- */

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.sidebar__inner {
  height: 100%;
  padding: 22px 16px 34px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(3, 3, 8, 0.68);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* ---------- reading progress ---------- */

.reading-progress {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  z-index: 101;
  height: 2px;
  background: transparent;
  pointer-events: none;
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gradient);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.8);
  transition: width 0.08s linear;
}

/* ---------- footer ---------- */

.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, rgba(12, 12, 22, 0.7));
}

[data-theme="light"] .footer {
  background: linear-gradient(180deg, transparent, rgba(235, 235, 248, 0.72));
}

.footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto;
  gap: 22px 40px;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 30px 24px;
}

.footer__brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 520px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.footer__brand strong {
  color: var(--text-soft);
}

.footer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
}

.footer__links a {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  transition: color 0.2s ease;
}

.footer__links a:hover {
  color: var(--text);
}

.footer__meta {
  grid-column: 1 / -1;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .topnav {
    display: none;
  }

  .topbar__menu {
    display: inline-flex;
  }

  .search-trigger {
    flex: 1 1 auto;
    max-width: 340px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 95;
    width: min(330px, 88vw);
    height: 100vh;
    padding-top: var(--topbar-h);
    border-right: 1px solid var(--border-strong);
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    transform: translateX(-103%);
    transition: transform 0.32s var(--ease);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__inner {
    padding: 18px 16px 34px;
  }
}

@media (max-width: 760px) {
  .app {
    padding: 26px 20px 68px;
  }

  .footer__inner {
    grid-template-columns: 1fr;
  }

  .footer__meta {
    grid-column: auto;
  }

  .topbar__inner {
    padding: 0 16px;
    gap: 10px;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 22px 15px 60px;
  }

  .search-trigger {
    flex: 0 0 38px;
    width: 38px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
  }

  .search-trigger__text,
  .search-trigger .kbd {
    display: none;
  }

  .topbar__github {
    display: none;
  }

  .brand__text {
    font-size: 0.96rem;
  }

  .brand__mark {
    width: 35px;
    height: 35px;
  }
}
