/* static/css/left_rail.css — left-rail nav shell (Layout Vision Rev 2.1 §14a.1-R)
 *
 * Linked from base.html.j2 <head> (unconditionally — the rail renders on every page).
 * Pure BEM (.left-rail*) so nothing here depends on a Tailwind utility that could be
 * silently purged from the compiled tailwind.css (BL-AX). All colors are design-system
 * tokens (var(--*)) — NEVER raw hex/rgb. Sharp corners (<=2px) and Linear-grade chrome
 * density per Design System §5.2 — Claude-inspired STRUCTURE only, never Claude styling.
 */

.left-rail {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 14rem;
  height: 100vh;
  background-color: var(--canvas-1);
  border-right: 1px solid var(--line-0);
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.875rem;
  color: var(--ink-1);
  transition: width 0.12s ease;
}

/* Collapsed: thin icon strip. Labels and grouped destinations hide; the icon items
 * (search, upload a deal, saved models, privacy, watchlist, account) remain. */
.left-rail--collapsed {
  width: 3rem;
}
.left-rail--collapsed .left-rail__label {
  display: none;
}
.left-rail--collapsed .left-rail__group {
  display: none;
}
/* RAIL S1: Upload a deal sits under the Buying a business header; its icon stays on
 * the collapsed strip (the header text hides with every label). */
.left-rail--collapsed .left-rail__buying {
  display: block;
  border-bottom: 0;
}
.left-rail--collapsed .left-rail__item {
  justify-content: center;
}

/* Head: logo + collapse chevron */
.left-rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--line-0);
}
.left-rail__logo {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 600;
  color: var(--ink-0);
  text-decoration: none;
}
.left-rail__logo:hover {
  color: var(--accent-0);
}
/* Collapsed: hide the logo and center the head so the collapse button is the sole,
 * fully-visible, clickable control on the 3rem strip — clicking it re-expands.
 * (Without this the logo + button at space-between overflow the 3rem strip and the
 * button is clipped by overflow-x:hidden, trapping the rail collapsed.) */
.left-rail--collapsed .left-rail__logo {
  display: none;
}
.left-rail--collapsed .left-rail__head {
  justify-content: center;
}
.left-rail__collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.125rem;
  background: transparent;
  border: 0;
  border-radius: 2px;
  color: var(--ink-2);
  cursor: pointer;
}
.left-rail__collapse-btn:hover {
  color: var(--ink-0);
}
.left-rail--collapsed .left-rail__collapse-btn svg {
  transform: rotate(180deg);
}

/* Generic rail item (links and buttons; RAIL sec 3.2: no disabled controls) */
.left-rail__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.25rem 0.75rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink-1);
  font-size: 0.875rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.left-rail__item:hover {
  color: var(--ink-0);
  background-color: var(--canvas-2);
}

.left-rail__icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Search trigger — keyboard hint pinned right */
.left-rail__search-hint {
  margin-left: auto;
  padding: 0 0.25rem;
  font-size: 0.6875rem;
  color: var(--ink-2);
  border: 1px solid var(--line-0);
  border-radius: 2px;
}

/* Grouped sections (Buying a business / Selling a business) */
.left-rail__group {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--line-1);
}
.left-rail__group-head {
  padding: 0.1875rem 0.75rem;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-2);
}

/* RAIL S1 sec 1.3: the Buying a business header is the <summary> of a native
 * <details open>; it expands and collapses its list and keeps the group-head look. */
.left-rail__group-toggle {
  display: block;
  cursor: pointer;
  list-style: none;
}
.left-rail__group-toggle::-webkit-details-marker {
  display: none;
}
.left-rail__group-toggle::after {
  content: " \25BE";
}
.left-rail__buying:not([open]) > .left-rail__group-toggle::after {
  content: " \25B8";
}
.left-rail__group-toggle:hover {
  color: var(--ink-0);
}

/* RAIL S1 sec 1.4 / 4.2: the one declared "Coming soon" line, in the rail's quiet
 * type -- not a badge, not a tag, not a control. */
.left-rail__soon {
  margin: 0;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-2);
}

/* Watchlist active-count badge — token colors, sharp corner */
.left-rail__badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  font-size: 0.6875rem;
  background-color: var(--accent-0);
  color: var(--canvas-0);
  border-radius: 2px;
}

/* User menu — pinned to the bottom */
.left-rail__user {
  position: relative;
  margin-top: auto;
  border-top: 1px solid var(--line-0);
}
.left-rail__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  font-size: 0.6875rem;
  background-color: var(--canvas-2);
  border: 1px solid var(--line-0);
  border-radius: 2px;
  color: var(--ink-1);
}
.left-rail__menu {
  position: absolute;
  left: 0.5rem;
  bottom: 100%;
  min-width: 11rem;
  margin-bottom: 0.25rem;
  padding: 0.25rem 0;
  background-color: var(--canvas-2);
  border: 1px solid var(--line-0);
  border-radius: 2px;
}
.left-rail__menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.375rem 0.75rem;
  background: transparent;
  border: 0;
  color: var(--ink-1);
  font-size: 0.8125rem;
  text-align: left;
  cursor: pointer;
}
.left-rail__menu-item:hover {
  color: var(--ink-0);
  background-color: var(--canvas-3);
}
/* 4de: Sign out, where the page carries the CSRF token, is a one-button form. */
.left-rail__menu-form {
  margin: 0;
}

/* T-7.01 -- <md off-canvas drawer + hamburger + scrim (FRONTEND UI spec 13.1/13.2).
 * md+ (>=768px) is UNCHANGED: the rail stays a static flex sibling at its current
 * width, and the hamburger + scrim are display:none. Below md the rail becomes a
 * fixed off-canvas drawer toggled by $store.nav.mobileOpen (.left-rail--mobile-open).
 * Pure BEM + @media (no Tailwind utility, BL-AX); colors are design-system tokens. */

/* Desktop default: trigger + scrim hidden. */
.left-rail__hamburger {
  display: none;
}
.left-rail__scrim {
  display: none;
}

@media (max-width: 767px) {
  /* Rail -> fixed off-canvas drawer, slid off-screen until opened. */
  .left-rail {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }
  .left-rail.left-rail--mobile-open {
    transform: translateX(0);
  }

  /* Hamburger trigger -- fixed top-left, above page content. */
  .left-rail__hamburger {
    display: flex;
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 45;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background-color: var(--canvas-1);
    border: 1px solid var(--line-0);
    color: var(--ink-1);
    cursor: pointer;
  }
  .left-rail__hamburger:hover {
    color: var(--ink-0);
  }

  /* Scrim -- token-backed translucent layer (mirrors the command-palette backdrop:
   * var(--canvas-0) at opacity, never raw rgba). The 2-class selector outspecifies
   * the base .left-rail__scrim display:none, so it shows only when open AND <md. */
  .left-rail__scrim.left-rail--mobile-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background-color: var(--canvas-0);
    opacity: 0.8;
  }
}
