/* ============================================================
   Site sidebar — expandable navigation rail
   (interaction modeled after dribbble.com/shots/26211061)

   Self-contained and theme-agnostic: every color reads from the site's
   existing CSS variables (with fallbacks), so it re-skins itself with
   the white/terminal/vscode toggle automatically. Include on every page
   alongside assets/styles.css.
   ============================================================ */

:root {
  --sb-w-collapsed: 76px;
  --sb-w-expanded: 264px;
  --sb-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Reserve room for the fixed rail. The sidebar itself is position:fixed
   so it doesn't participate in normal flow — this padding is what
   actually pushes the navbar/main/footer over. */
body {
  padding-left: 0;
  transition: none;
}
body.sb-expanded {
  padding-left: 0;
}
/* first paint: skip the transition so it doesn't animate in on load */
body.sb-no-anim {
  transition: none;
}

.site-sidebar {
  display: none !important;
  --sb-bg: var(--nav-bg, var(--surface, #121212));
  --sb-border: var(--border, rgba(255, 255, 255, 0.08));
  --sb-fg: var(--fg, #e8e8e8);
  --sb-fg-dim: var(--fg-dim, #9a9a9a);
  --sb-accent: var(--accent, #a84304);
  --sb-accent-dim: var(--accent-dim, rgba(168, 67, 4, 0.35));
  --sb-radius: var(--radius, 10px);

  position: fixed;
  top: 0;
  left: 0;
  z-index: 500;
  width: var(--sb-w-collapsed);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  box-shadow:
    inset -1px 0 0 0 rgba(255, 255, 255, 0.04),
    6px 0 24px -14px rgba(0, 0, 0, 0.5);
  transition: width 0.38s var(--sb-ease);
  overflow: visible;
}
body.sb-expanded .site-sidebar {
  width: var(--sb-w-expanded);
}
body.sb-no-anim .site-sidebar {
  transition: none;
}

/* ---------- Header: logo + collapse toggle ---------- */
.site-sidebar .sb-header {
  position: relative;
  display: flex;
  align-items: center;
  height: 64px;
  flex: 0 0 auto;
  padding: 0 22px;
}
.site-sidebar .sb-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--sb-fg);
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  white-space: nowrap;
  overflow: hidden;
}
.site-sidebar .sb-logo .bracket { color: var(--sb-accent); }
.site-sidebar .sb-logo-badge {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex: 0 0 auto;
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.site-sidebar .sb-logo-text {
  opacity: 1;
  transition: opacity 0.2s ease 0.12s;
}
body:not(.sb-expanded) .site-sidebar .sb-logo-text {
  opacity: 0;
  transition: opacity 0.1s ease;
  pointer-events: none;
}

.site-sidebar .sb-toggle {
  position: absolute;
  top: 22px;
  right: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sb-bg);
  color: var(--sb-fg-dim);
  border: 1px solid var(--sb-border);
  cursor: pointer;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
  transition: color 0.2s ease, transform 0.38s var(--sb-ease), border-color 0.2s ease;
  z-index: 2;
}
.site-sidebar .sb-toggle:hover {
  color: var(--sb-fg);
  border-color: var(--sb-accent-dim);
}
.site-sidebar .sb-toggle svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.38s var(--sb-ease);
}
body.sb-expanded .site-sidebar .sb-toggle svg {
  transform: rotate(180deg);
}

/* ---------- Scroll area ---------- */
.site-sidebar .sb-scroll {
  flex: 1 1 auto;
  /* Deliberately NOT scrollable (no overflow-y:auto): per the CSS
     Overflow spec, setting overflow-y to anything but visible forces
     overflow-x to compute as auto too, which would clip the
     collapsed-state flyouts positioned outside the rail's bounds.
     The nav list is short enough that this isn't a practical problem;
     each row still clips its own label text (see .sb-row). */
  overflow: visible;
  padding: 4px 12px 12px;
}

.site-sidebar .sb-section-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sb-fg-dim);
  padding: 14px 10px 6px;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s ease 0.1s;
}
body:not(.sb-expanded) .site-sidebar .sb-section-label {
  opacity: 0;
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  transition: opacity 0.1s ease;
}

/* ---------- Flat items + group triggers share this look ---------- */
.site-sidebar .sb-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--sb-radius);
  color: var(--sb-fg-dim);
  text-decoration: none;
  background: none;
  border: none;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.18s ease, color 0.18s ease;
}
.site-sidebar .sb-row:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--sb-fg);
}
.site-sidebar .sb-row.active {
  background: rgba(255, 255, 255, 0.07);
  color: var(--sb-fg);
}
.site-sidebar .sb-row.active .sb-icon { color: var(--sb-accent); }

.site-sidebar .sb-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sb-fg-dim);
}
.site-sidebar .sb-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-sidebar .sb-label {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 0.2s ease 0.12s;
}
body:not(.sb-expanded) .site-sidebar .sb-label {
  opacity: 0;
  transition: opacity 0.1s ease;
}

.site-sidebar .sb-caret {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--sb-fg-dim);
  transition: transform 0.3s var(--sb-ease), opacity 0.2s ease 0.12s;
}
.site-sidebar .sb-caret svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-group.open > .sb-row .sb-caret { transform: rotate(180deg); }
body:not(.sb-expanded) .site-sidebar .sb-caret {
  opacity: 0;
  transition: opacity 0.1s ease;
}

/* ---------- Expandable groups: accordion sub-list ---------- */
.site-sidebar .sb-group { position: relative; margin: 1px 0; }

.site-sidebar .sb-subwrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.38s var(--sb-ease);
  margin-left: 20px;
  border-left: 1px solid var(--sb-border);
}
.site-sidebar .sb-group.open > .sb-subwrap {
  grid-template-rows: 1fr;
}
.site-sidebar .sb-sublist {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-left: 6px;
}
.site-sidebar .sb-sublink {
  position: relative;
  display: block;
  padding: 7px 10px;
  margin: 1px 0;
  border-radius: calc(var(--sb-radius) - 4px);
  color: var(--sb-fg-dim);
  text-decoration: none;
  font-size: 12.5px;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-4px);
  transition: background 0.15s ease, color 0.15s ease, opacity 0.28s ease, transform 0.28s ease;
  transition-delay: 0s;
}
.site-sidebar .sb-group.open .sb-sublink {
  opacity: 1;
  transform: translateX(0);
  transition-delay: calc(var(--i, 0) * 35ms);
}
.site-sidebar .sb-sublink:hover,
.site-sidebar .sb-sublink:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sb-fg);
}
.site-sidebar .sb-sublink.active { color: var(--sb-accent); }

/* When the rail is collapsed, hide the accordion state entirely and
   show a hover flyout with the same items instead. */
body:not(.sb-expanded) .site-sidebar .sb-subwrap {
  display: none;
}

.site-sidebar .sb-flyout {
  position: absolute;
  left: calc(100% + 12px);
  top: 0;
  min-width: 190px;
  padding: 8px;
  background: var(--sb-bg);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.6), 0 4px 10px -4px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-6px);
  transition: opacity 0.18s ease, transform 0.18s var(--sb-ease), visibility 0.18s;
  z-index: 600;
}
.site-sidebar .sb-flyout::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 0;
  width: 12px;
  height: 100%;
}
.site-sidebar .sb-flyout-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sb-fg-dim);
  padding: 4px 8px 6px;
}
/* Flyout re-uses the .sb-sublink look but must stay visible regardless
   of the accordion's own open/closed (opacity-driven) state. */
.site-sidebar .sb-flyout .sb-sublink {
  opacity: 1;
  transform: none;
  transition: background 0.15s ease, color 0.15s ease;
}
body:not(.sb-expanded) .site-sidebar .sb-group:hover .sb-flyout,
body:not(.sb-expanded) .site-sidebar .sb-group:focus-within .sb-flyout {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}

/* ---------- Bottom profile card ---------- */
.site-sidebar .sb-footer {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--sb-border);
}
.site-sidebar .sb-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--sb-radius);
  color: var(--sb-fg);
  text-decoration: none;
  border: 1px solid transparent;
  overflow: hidden;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.site-sidebar .sb-profile-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--sb-border);
}
.site-sidebar .sb-profile-avatar {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: var(--sb-fg-dim);
  border: 1px solid var(--sb-border);
}
.site-sidebar .sb-profile-avatar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.site-sidebar .sb-profile-text {
  flex: 1 1 auto;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.2s ease 0.12s;
}
body:not(.sb-expanded) .site-sidebar .sb-profile-text {
  opacity: 0;
  transition: opacity 0.1s ease;
}
.site-sidebar .sb-profile-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-sidebar .sb-profile-sub {
  font-size: 11px;
  color: var(--sb-fg-dim);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .site-sidebar { display: none; } /* the top navbar remains the primary nav on small screens */
  body { padding-left: 0 !important; transition: none !important; }
}

/* ============================================================
   Small circular "your profile" quick-access button, added to the
   existing top navbar's empty spacer area (kept separate from the
   navbar's own markup/styles, which are otherwise untouched).
   ============================================================ */
.nav-profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--fg-dim, #9a9a9a);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  text-decoration: none;
  margin: 0 6px;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.nav-profile-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-profile-btn:hover,
.nav-profile-btn:focus-visible {
  color: var(--fg, #e8e8e8);
  border-color: var(--accent-dim, rgba(168, 67, 4, 0.4));
  transform: translateY(-1px);
}
.nav-profile-btn.active {
  color: var(--accent, #a84304);
  border-color: var(--accent, #a84304);
}
