/* shell.css — the PRECISION app shell (docs/PRECISION.md §4): the persistent
   left rail (brand, nav groups, journey, profile foot) and the workspace it
   frames. The rail's group markup is painted by app/infrastructure/pipeline.js
   into #phaseNav; this sheet owns how all of it looks. */

.app-shell {
  display: flex;
  height: 100vh;
  background: var(--bg);
}

/* ---- Rail ---------------------------------------------------------------- */

.rail {
  width: var(--rail-w);
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px;
  overflow-y: auto;
}

/* Brand: the original wordmark trio (mark | divider | shimmer "Goldmine"),
   preserved verbatim in treatment (.goldmine-word lives in base.css), sized
   for the rail. */
.rail-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 12px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  border-radius: var(--r);
}
.rail-brand-mark {
  height: 28px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.rail-brand-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
}
.rail-brand-word {
  font-size: 18px;
  white-space: nowrap;
}

.rail-groups { flex: 1; min-height: 0; }

.rail-group { padding: 10px 0 2px; }
.rail-group > .group-label { display: block; padding: 0 10px 5px; }

/* Plain nav item (Home, Supplements, Activities, coach queue rows) */
.rail-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--sub);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.rail-item:hover { background: var(--soft); color: var(--ink); }
.rail-item.on { background: var(--soft); color: var(--ink); font-weight: 600; }
.rail-item .rail-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
}

/* Journey step (the stepper, vertical). pipeline.js renders:
   .rail-step.status-{done|active|pending|revision|ready|locked}[.current] >
     .step-dot + .step-text(.step-label + .step-note) */
.rail-step {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--sub);
  font-size: 13px;
  font-weight: 500;
  cursor: default;
}
.rail-step.navigable { cursor: pointer; }
.rail-step.navigable:hover { background: var(--soft); color: var(--ink); }
.rail-step.current { background: var(--soft); color: var(--ink); font-weight: 600; }

.step-dot {
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.step-dot .pp-ico { width: 10px; height: 10px; display: block; }

.rail-step.status-done .step-dot { background: var(--gold); border-color: var(--gold); }
.rail-step.status-active .step-dot { border-color: var(--gold); background: var(--gold); }
.rail-step.status-active .step-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: var(--bg);
  border-radius: 50%;
}
.rail-step.status-pending .step-dot { border-color: var(--gold); }
.rail-step.status-revision .step-dot {
  border-color: var(--warn);
  color: var(--warn);
  font-size: 10px;
  font-weight: 700;
}
.rail-step.status-ready .step-dot { border-color: var(--sub); }
.rail-step.status-locked { color: var(--faint); }
.rail-step.status-locked .step-dot { border-color: var(--line); }

.step-text { min-width: 0; }
.step-label { display: block; }
.step-note {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--faint);
  margin-top: 1px;
}
.rail-step.status-revision .step-note { color: var(--warn); }

/* ---- Rail foot: utilities + profile ------------------------------------- */

.rail-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rail-foot-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 5px 10px;
  border: 0;
  border-radius: var(--r);
  background: none;
  color: var(--sub);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.rail-foot-btn:hover { background: var(--soft); color: var(--ink); }

.rail-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 2px;
  font-size: 12px;
  color: var(--sub);
}
.rail-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.rail-who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#signOutBtn {
  border: 0;
  background: none;
  color: var(--sub);
  font-size: 12px;
  padding: 3px 6px;
  border-radius: var(--r);
  cursor: pointer;
  flex-shrink: 0;
}
#signOutBtn:hover { background: var(--soft); color: var(--ink); }

/* ---- Workspace ----------------------------------------------------------- */

.workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.workspace main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: block;
  padding: 0;
}

/* Workspace header: every view's first row (PRECISION.md §4). */
.whead {
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 18px;
  background: var(--bg);
}
.whead h1, .whead h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.whead .tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

/* 2px progress hairline under a .whead */
.whead-progress { height: 2px; background: var(--soft); }
.whead-progress .fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Small screens: rail collapses behind a topbar ----------------------- */

.shell-topbar {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.shell-topbar .rail-brand { padding: 4px 0; }
.shell-menu-btn {
  border: 1px solid var(--line);
  background: none;
  border-radius: var(--r);
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sub);
  cursor: pointer;
}
.shell-menu-btn:hover { color: var(--ink); background: var(--soft); }
.rail-scrim { display: none; }

@media (max-width: 900px) {
  .shell-topbar { display: flex; }
  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(280px, 82vw);
    z-index: 60;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }
  body.rail-open .rail { transform: none; }
  body.rail-open .rail-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(14, 21, 38, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail { transition: none; }
  .whead-progress .fill { transition: none; }
}
