/* ================================================================
   OUR WORLD — Minecraft Native Sidebar
   Dark: Deepslate · Light: Oak planks
   Collapsible panel with edge arrow, full-width on all screens
   ================================================================ */

/* 桌面：固定侧栏宽度 + body 偏移 */
body { padding-left: 248px; transition: padding-left 0.25s ease; }
body.sidebar-collapsed { padding-left: 0; }

/* ---------- Sidebar base ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  width: 248px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 10px;
  background: var(--panel);
  border-right: 2px solid var(--border);
  box-shadow: 4px 0 24px rgba(0,0,0,0.35);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* 折叠态 */
.sidebar:not(.open) {
  transform: translateX(-100%);
  box-shadow: none;
}
/* body 偏移联动 */
.sidebar:not(.open) ~ * { /* 仅作 marker */ }

/* ---------- 折叠箭头（暗灰小色块嵌在侧栏边缘） ---------- */
.sidebar-toggle {
  position: fixed; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 44px;
  background: #555;
  border: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer; z-index: 201;
  padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  transition: left .25s ease, opacity .25s, background .25s;
  opacity: 0.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.sidebar-toggle:hover { opacity: 0.85; }
.sidebar-toggle .toggle-icon {
  font-size: 0.75rem; color: #ccc;
  transition: transform .25s; display: inline-block;
  line-height: 1;
}

/* 展开态：色块贴在侧栏右边缘 */
.sidebar.open ~ .sidebar-toggle {
  left: calc(248px - 2px);
  border-radius: 0 6px 6px 0;
}

/* 折叠态：色块靠在屏幕最左边 */
.sidebar:not(.open) ~ .sidebar-toggle {
  left: 0;
  border-radius: 0 6px 6px 0;
  opacity: 0.55;
}
.sidebar:not(.open) ~ .sidebar-toggle:hover { opacity: 0.9; }

/* ---------- Brand ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  padding: 4px 2px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.brand-mark {
  width: 40px; height: 40px; min-width: 40px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.72rem;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 2px solid var(--btn-primary-shadow);
  box-shadow:
    inset -2px -3px 0 0 var(--btn-primary-shadow),
    inset 2px 2px 0 0 rgba(255,255,255,0.2);
  transition: box-shadow 0.1s linear, filter 0.1s linear;
  letter-spacing: 0.04em;
}
.brand-mark:hover { filter: brightness(1.1); }

.brand-text {
  white-space: nowrap;
  opacity: 1;
  overflow: hidden;
}
.brand-name, .brand-tag { margin: 0; }
.brand-name { font-weight: 400; font-size: 0.82rem; letter-spacing: 0.08em; color: var(--text); }
.brand-tag { color: var(--text-muted); font-size: 0.62rem; letter-spacing: 0.04em; margin-top: 2px; }

/* ---------- Navigation ---------- */
.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav a {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 11px;
  border: 1px solid transparent;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.78rem;
  transition: all 0.12s ease;
  position: relative;
  border-radius: 0;
  letter-spacing: 0.02em;
}
.nav a::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 2px; height: 70%;
  background: var(--accent);
  transition: transform 0.15s ease;
}
.nav a:hover,
.nav a.active {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel-hover);
}
.nav a:hover::before,
.nav a.active::before { transform: translateY(-50%) scaleY(1); }
.nav a.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: inset 0 0 0 1px rgba(78,200,110,0.08);
}

.nav-icon {
  width: 22px; min-width: 22px;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1;
  transition: color 0.12s ease;
}
.nav a.active .nav-icon { color: var(--accent); }

.nav-label {
  opacity: 1;
}

/* ---------- Footer area ---------- */
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Admin link */
.admin-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 11px;
  width: 100%;
  color: var(--text-muted);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.12s ease;
  position: relative;
}
.admin-link:hover { color: var(--text); border-color: var(--border); background: var(--panel-hover); }
.admin-link .nav-label {
  opacity: 1;
}

/* ---------- Theme button in sidebar ---------- */
.theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: all 0.12s ease;
  letter-spacing: 0.02em;
}
.theme-btn:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--border-light);
}
.theme-icon-dark { display: inline; }
.theme-icon-light { display: none; }
body[data-theme="light"] .theme-icon-dark { display: none; }
body[data-theme="light"] .theme-icon-light { display: inline; }

/* ---------- Sidebar tooltip (icon-only state) ---------- */
.nav a[title]:hover::after,
.admin-link[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.72rem;
  padding: 4px 10px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ---------- 遮罩（移动端侧栏滑出时显示） ---------- */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,0.35);
}
.sidebar-backdrop.show { display: block; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  body { padding-left: 0; }
  body.sidebar-collapsed { padding-left: 0; }

  /* 窄屏：侧栏覆盖模式，默认折叠 */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  /* 箭头固定屏幕左边 */
  .sidebar-toggle { left: 6px; opacity: 0.55 !important; }
  .sidebar.open ~ .sidebar-toggle { left: 254px; }
}
