/* project-rail.css — DW3-13: the project's own left rail (project-rail.js).
 * body.in-project (set by showView) swaps the company nav for the
 * project's rail inside the same white sidebar, and the project page
 * drops its stacked chrome: no "← Projects" button, no tab bar, and
 * the title block only on Summary. Every other section carries one
 * heading — its own name.
 *
 * wave581 (2026-11-10, Micheal's ruling: "no collapse inside the
 * project for the side bar"): the audit found three width behaviours
 * touching this sidebar, and the rulings settle each:
 *   · the MAIN rail's fold (waves 548–559) never reaches it — every
 *     rail-min rule in styles.css is scoped :not(.in-project) and the
 *     toggle itself is display:none in a project. Untouched: the
 *     main rail outside projects keeps its ruled collapse.
 *   · the tablet band (dw3-chrome.css, wave362) steps the sidebar
 *     236px → 204px at 901–1240px. Exempted below for in-project:
 *     inside a project the sidebar holds the full 236px.
 *   · the ≤900px block this file used to carry folded the rail into
 *     a horizontal strip — head, section labels, icons and the Back
 *     label all hidden. REMOVED: the rail keeps its full column
 *     form; the shell's top bar grows to hold it (it already
 *     scrolls) and the content starts below it.
 * wave585-prcollapse (2026-11-10, the owner's reversal the same
 * night — "Add a collapse inside projects too"): the project rail
 * now carries its OWN collapse control (project-rail.js renders it
 * under the project head, in the main toggle's language). The fold
 * is a user choice only — body.proj-rail-min, the device's
 * localStorage rkProjRailMin, stamped pre-paint by index-inline.js
 * — narrow­ing #topbar to the same 64px icon rail the main rail
 * folds to, content widening to meet it; rail-toggle.js's #rail-tip
 * names the folded items on hover. What wave581 settled SURVIVES:
 * the expanded rail is still 236px at every width above 900px
 * (the tablet exemption below now scopes to :not(.proj-rail-min)),
 * and at ≤900px nothing here applies — wave584's ☰ drawer is the
 * way in and the in-bar strip stays hidden in-project. */

#proj-rail { display: none; }
body.in-project #topbar > nav,
body.in-project #topbar .brand-product { display: none; }
body.in-project #proj-rail { display: flex; flex-direction: column; gap: 2px; width: 100%; margin-top: 2px; }

/* the stacked headers go */
body.in-project #view-project > .back,
body.in-project #project-modules { display: none !important; }
body.in-project:not([data-pmod="summary"]) #view-project > .page-head,
body.in-project:not([data-pmod="summary"]) #project-ref-slot,
body.in-project:not([data-pmod="summary"]) #app #project-status-slot { display: none; }
/* Summary keeps the title block; its edit/archive/delete doors sit
 * top-right where the back button used to sit beside them */
body.in-project[data-pmod="summary"] #view-project > .page-head { margin-top: 2px; }

/* ---- back ---- */
.pr-back {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; cursor: pointer;
  color: var(--ds-muted); font: inherit; font-size: var(--ds-fs-sm); font-weight: 600;
  padding: 7px 10px; margin: 0 0 6px; border-radius: var(--ds-r-sm); text-align: left;
}
.pr-back:hover { background: var(--ds-bg); color: var(--ds-navy); }
.pr-back:focus-visible { outline: none; box-shadow: var(--ds-focus); }
.pr-back span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- the project's identity + switcher ---- */
.pr-head {
  --pr-tint: var(--ds-gold);
  border: 1px solid var(--ds-line); border-radius: var(--ds-r);
  background: var(--ds-card); padding: 4px; margin: 0 0 10px;
  box-shadow: inset 3px 0 0 var(--pr-tint);
}
.pr-switch {
  display: flex; align-items: flex-start; gap: 9px; width: 100%;
  background: none; border: 0; cursor: pointer; text-align: left; font: inherit;
  padding: 8px 8px 6px 10px; border-radius: var(--ds-r-sm); color: var(--ds-navy);
}
.pr-switch:hover { background: var(--ds-tint); }
.pr-switch:focus-visible { outline: none; box-shadow: var(--ds-focus); }
.pr-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pr-tint); flex: none; margin-top: 5px; }
.pr-switch-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.pr-name { font-weight: 700; font-size: var(--ds-fs); line-height: 1.3; }
.pr-sub { color: var(--ds-muted); font-size: var(--ds-fs-xs); line-height: 1.35; }
.pr-caret { color: var(--ds-muted); margin-top: 4px; flex: none; }
.pr-stage {
  display: inline-block; margin: 0 0 6px 28px; padding: 2px 9px; border-radius: var(--ds-r-pill);
  background: var(--ds-neutral-bg); color: var(--ds-neutral-ink); font-size: 11.5px; font-weight: 600;
}
.pr-stage[data-stage="in_construction"] { background: var(--ds-info-bg); color: var(--ds-info-ink); }
.pr-stage[data-stage="quote_sent"] { background: var(--ds-orange-bg); color: var(--ds-orange-ink); }
.pr-stage[data-stage="quote_signed"] { background: var(--ds-ok-bg); color: var(--ds-ok-ink); }
.pr-stage[data-stage="completed"] { background: var(--ds-neutral-bg); color: var(--ds-neutral-ink); } /* DW3-ADD-1: a finished job, read neutral */
.pr-stage[data-stage="to_bid"] { background: var(--ds-bad-bg); color: var(--ds-bad-ink); }

/* ---- the sections ---- */
.pr-nav { display: flex; flex-direction: column; gap: 2px; }
.pr-sec {
  font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--ds-faint); font-weight: 600; padding: 14px 12px 5px;
}
.pr-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; cursor: pointer; font: inherit;
  color: #3d4856; font-size: var(--ds-fs); font-weight: 500;
  border-radius: var(--ds-r-sm); min-height: 36px; padding: 7px 12px;
}
.pr-ico { width: 20px; display: inline-flex; justify-content: center; color: #6b7685; flex: none; }
.pr-item:hover { background: var(--ds-bg); color: var(--ds-navy); }
.pr-item.active { background: var(--ds-nav-active); color: var(--ds-navy); font-weight: 700; }
.pr-item.active .pr-ico { color: var(--ds-navy); }
.pr-item:focus-visible { outline: none; box-shadow: var(--ds-focus); }

/* ---- the main area's one heading ---- */
.proj-section-head { display: none; }
body.in-project:not([data-pmod="summary"]) .proj-section-head { display: block; margin: 0 0 20px; }
.pr-kicker { margin: 0 0 4px; color: var(--ds-muted); font-size: var(--ds-fs-sm); font-weight: 600; }
.pr-title { margin: 0; font-size: var(--ds-fs-page); line-height: 1.2; font-weight: 700; letter-spacing: -.015em; color: var(--ds-navy); }

/* ---- the switcher popover ---- */
.pr-switcher {
  position: fixed; z-index: 400; background: var(--ds-card);
  border: 1px solid var(--ds-line); border-radius: var(--ds-r); box-shadow: var(--ds-shadow-pop);
  padding: 8px; max-height: min(420px, 70vh); display: flex; flex-direction: column; gap: 6px;
}
.pr-switch-q {
  height: var(--ds-ctl-sm); border: 1px solid var(--ds-line); border-radius: var(--ds-r-sm);
  padding: 0 10px; font: inherit; font-size: var(--ds-fs-sm); background: var(--ds-fill);
}
.pr-switch-q:focus { outline: none; box-shadow: var(--ds-focus); border-color: var(--ds-gold); }
.pr-switch-list { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.pr-switch-row {
  display: flex; flex-direction: column; gap: 1px; align-items: flex-start; text-align: left;
  background: none; border: 0; cursor: pointer; font: inherit; padding: 8px 10px; border-radius: var(--ds-r-sm);
}
.pr-switch-row:hover, .pr-switch-row:focus-visible { background: var(--ds-tint); outline: none; }
.pr-switch-row.on { background: var(--ds-nav-active); }
.pr-switch-row-name { color: var(--ds-navy); font-weight: 600; font-size: var(--ds-fs-sm); }
.pr-switch-row-sub { color: var(--ds-muted); font-size: var(--ds-fs-xs); }
.pr-switch-none { padding: 10px; }

/* ---- the rail's own collapse control (wave585) ----
 * The main toggle's language (styles.css .rail-toggle): a quiet
 * full-width row under the project head — chevrons + the word,
 * fading in on hover — so it reads as the same control. In the
 * folded rail it centres to just the chevrons, which flip to say
 * "pointing out = expand", exactly like the main rail's. */
.pr-collapse {
  display: flex; align-items: center; gap: 10px;
  width: 100%; margin: 0 0 6px; padding: 7px 12px;
  background: none; border: 0; border-radius: 8px;
  color: inherit; font: inherit; font-size: 13px;
  cursor: pointer; text-align: left; opacity: .75;
}
.pr-collapse:hover { opacity: 1; background: rgba(127, 147, 179, .14); }
.pr-collapse:focus-visible { outline: none; box-shadow: var(--ds-focus); }
.pr-collapse .pr-collapse-ico { display: inline-flex; flex: none; }
.pr-collapse .pr-collapse-ico svg { transition: transform .18s ease; }
@media (max-width: 900px) {
  .pr-collapse { display: none; }
}

/* the logo is the Home door */
#topbar .brand[data-home] { cursor: pointer; border-radius: var(--ds-r-sm); }
#topbar .brand[data-home]:focus-visible { outline: none; box-shadow: var(--ds-focus); }

/* ---- narrow screens (wave581): no VIEWPORT fold in a project.
 * The old ≤900px strip (row layout, project head / section labels /
 * icons / Back label hidden) is gone: the rail keeps its full column
 * — head, sections, icons and words. The shell's top bar grows to
 * hold it (it already scrolls vertically) and the content area
 * adapts below it. The tablet band's 204px step-back (dw3-chrome.css,
 * wave362) is likewise exempted in a project: the EXPANDED sidebar
 * holds the full 236px, and #app's margin follows it — wave585
 * scopes the exemption to the expanded state, because a folded
 * rail is 64px at every band. */
@media (max-width: 900px) {
  body.in-project #topbar { height: auto; }
}
@media (min-width: 901px) and (max-width: 1240px) {
  body.in-project:not(.proj-rail-min) #topbar { width: var(--rail-w); }
  body.in-project:not(.proj-rail-min):has(#topbar:not(.hidden)) #app { margin-left: var(--rail-w); }
}

/* ---- the folded project rail (wave585): a user choice, never a
 * viewport accident. Mirrors the main rail's fold geometry
 * (styles.css wave548): #topbar is position:fixed at 236px with its
 * padding, #app offset by margin-left — narrowing the bar to 64px
 * with the rail-min padding and moving #app's margin to 64px lets
 * the content take the freed width. NOT scoped :not() against the
 * main rail's state: the two folds are independent (rkRailMin /
 * rkProjRailMin); this block wins on #topbar's width in-project
 * because it loads after styles.css and out-specifies both the
 * base rule and the tablet band. Folded, the head keeps only what
 * a 64px column can hold: the project dot (the collapsed switcher —
 * clicking it still opens the switcher), Back as its arrow alone,
 * the collapse chevrons, and the sections as named icons. */
@media (min-width: 901px) {
  body.in-project.proj-rail-min #topbar { width: var(--rail-w); padding: 18px 8px 14px; }
  body.in-project.proj-rail-min:has(#topbar:not(.hidden)) #app { margin-left: var(--rail-w); }
  body.in-project #topbar, body.in-project #app { transition: width .18s ease, margin-left .18s ease; }
  body.in-project.proj-rail-min #topbar .brand { align-items: center; padding: 2px 0 10px; }
  body.in-project.proj-rail-min #topbar .brand .brand-lockup-img,
  body.in-project.proj-rail-min #topbar .brand .topbar-logo { display: none; }
  body.in-project.proj-rail-min #topbar .gc-row {
    flex-direction: column; justify-content: center; gap: 6px;
    width: 100%; margin: 0 0 8px; padding: 0;
  }
  body.in-project.proj-rail-min #topbar .gs-trigger {
    flex: none; width: 40px; height: 40px; padding: 0; justify-content: center;
  }
  body.in-project.proj-rail-min #topbar .gs-trigger .gs-trigger-t,
  body.in-project.proj-rail-min #topbar .gs-trigger .gs-kbd { display: none; }
  body.in-project.proj-rail-min #topbar .nb-wrap { justify-content: center; }
  body.in-project.proj-rail-min #topbar .nb-bell { width: 40px; height: 40px; }
  body.in-project.proj-rail-min #topbar .userbox { align-items: center; padding: 14px 0 2px; }
  body.in-project.proj-rail-min #topbar .userbox #user-email,
  body.in-project.proj-rail-min #topbar .userbox #btn-logout,
  body.in-project.proj-rail-min #topbar .userbox .userbox-caret { display: none; }
  body.in-project.proj-rail-min .pr-back { justify-content: center; padding-left: 0; padding-right: 0; }
  body.in-project.proj-rail-min .pr-back span { display: none; }
  body.in-project.proj-rail-min .pr-head { padding: 4px; box-shadow: none; }
  body.in-project.proj-rail-min .pr-switch { justify-content: center; padding: 8px 0 6px; }
  body.in-project.proj-rail-min .pr-switch-main,
  body.in-project.proj-rail-min .pr-caret,
  body.in-project.proj-rail-min .pr-stage { display: none; }
  body.in-project.proj-rail-min .pr-dot { margin-top: 0; }
  body.in-project.proj-rail-min .pr-collapse { justify-content: center; padding-left: 0; padding-right: 0; }
  body.in-project.proj-rail-min .pr-collapse .pr-collapse-tx { display: none; }
  body.in-project.proj-rail-min .pr-collapse .pr-collapse-ico svg { transform: rotate(180deg); }
  body.in-project.proj-rail-min .pr-sec { display: none; }
  body.in-project.proj-rail-min .pr-item { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; font-size: 0; }
}
