/* TRON Wiki — Layout */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-5) 0 var(--space-8);
  scrollbar-width: thin;
  scrollbar-color: var(--color-line) transparent;
}

.sidebar__scroll::-webkit-scrollbar { width: 6px; }
.sidebar__scroll::-webkit-scrollbar-thumb {
  background: var(--color-line);
  border-radius: var(--radius-full);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.sidebar__brand-text { flex: 1; min-width: 0; }

.sidebar__logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: none;
  color: var(--color-accent);
}

.sidebar__logo svg { width: 18px; height: 18px; }

.sidebar__logo-img {
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 4px;
}

[data-theme="dark"] .sidebar__logo {
  color: var(--text);
  background: var(--bg-surface);
  border-color: var(--border);
}

.footer-brand__icon.sidebar__logo svg {
  width: 20px;
  height: 20px;
}

.sidebar__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  line-height: 1.25;
}

.sidebar__subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-normal);
}

.sidebar__nav { padding: 0 var(--space-3); }

.sidebar__group { margin-bottom: var(--space-5); }

.sidebar__label {
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  font-size: 0.6875rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-muted);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.sidebar__link:hover {
  background: rgba(9, 9, 11, 0.04);
  color: var(--text);
  text-decoration: none;
}

.sidebar__link.is-active {
  background: var(--color-accent-soft);
  color: var(--color-accent-ink);
  font-weight: var(--weight-semibold);
}

.sidebar__link svg {
  width: 16px;
  height: 16px;
  opacity: 0.5;
  flex-shrink: 0;
}

.sidebar__link.is-active svg { opacity: 0.85; }

.sidebar__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Donate block (sidebar + footer) ── */
.sidebar-donate {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-donate__title {
  font-size: 0.65rem;
  font-weight: var(--weight-semibold);
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  opacity: 0.7;
  margin-bottom: var(--space-2);
}

.sidebar-donate__line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-donate__addr {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  word-break: break-all;
  opacity: 0.95;
}

.sidebar-donate__addr:hover {
  text-decoration: underline;
  color: var(--text);
}

.sidebar-donate__copy {
  flex-shrink: 0;
  height: 28px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  opacity: 0.7;
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), opacity var(--duration-fast);
}

.sidebar-donate__copy:hover {
  opacity: 1;
  background: var(--bg-sidebar);
  border-color: var(--color-muted-light);
  color: var(--text);
}

/* ── Main column ── */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
}

/* ── Topbar ── */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-8);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.topbar__menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  color: var(--text-secondary);
}

.topbar__search {
  position: relative;
  flex: 0 1 380px;
}

.topbar__search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.topbar__search input {
  width: 100%;
  height: 38px;
  padding: 0 var(--space-10) 0 var(--space-10);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-sidebar);
  font-size: var(--text-sm);
  color: var(--text);
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast),
    background var(--duration-fast);
}

.topbar__search input::placeholder { color: var(--text-muted); }

.topbar__search input:hover {
  border-color: var(--color-muted-light);
}

.topbar__search input:focus {
  outline: none;
  background: var(--bg-surface);
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

.topbar__kbd {
  flex-shrink: 0;
  margin-left: auto;
  pointer-events: none;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* sidebar brand link (clickable logo) */
.sidebar__brand-link {
  display: grid;
  place-items: center;
  text-decoration: none;
  border-radius: var(--radius-md);
  position: relative;
}

.topbar__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.topbar__link:hover {
  background: var(--color-line-subtle);
  color: var(--text);
  text-decoration: none;
}

.topbar__link svg { width: 16px; height: 16px; }

/* ── Page content areas ── */

.page {
  flex: 1;
  width: 100%;
  max-width: none;
  padding: var(--space-10) var(--page-gutter) var(--space-16);
}

.page--wide {
  max-width: none;
  width: 100%;
}

.page-header {
  margin-bottom: var(--space-10);
  max-width: var(--content-max);
}

.page-header h1 { margin-bottom: var(--space-3); }

/* Article layout: content + right TOC */

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-width);
  gap: var(--space-12);
  align-items: start;
  width: 100%;
}

.article-layout__content {
  min-width: 0;
  /* Keep article content (and prev/next) aligned to a single readable column */
  max-width: var(--content-max);
  width: 100%;
  margin-inline: auto;
}

.article-layout__toc {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-6));
}

/* ── Breadcrumb ── */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-muted);
  transition: color var(--duration-fast);
}

.breadcrumb a:hover { color: var(--text); text-decoration: none; }

.breadcrumb__sep {
  color: var(--color-muted-light);
  user-select: none;
}

/* ── Footer ── */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-8);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--bg-sidebar);
}

.site-footer a {
  color: var(--text-muted);
}

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

/* ── Mobile overlay ── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-sidebar) - 1);
  background: rgba(9, 9, 11, 0.4);
  backdrop-filter: blur(2px);
}

/* ── Responsive ── */

@media (max-width: 1100px) {
  .article-layout {
    grid-template-columns: 1fr;
  }
  .article-layout__toc { display: none; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease-out);
    z-index: var(--z-overlay);
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-overlay.is-visible { display: block; }

  .topbar__menu-btn { display: inline-flex; }

  .page { padding: var(--space-8) var(--space-5) var(--space-12); }

  .topbar { padding: 0 var(--space-4); gap: var(--space-2); }

  .topbar__search {
    flex: 0 0 auto;
    max-width: none;
  }

  .topbar__search-trigger {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
  }

  .topbar__search-text,
  .topbar__search-trigger .topbar__kbd {
    display: none;
  }

  .topbar__link span { display: none; }
}
