/* rail-shell.css — universal left-rail chrome.
   Two-state width animation (60px → 240px on hover).
   Blur backdrop on expand. Brand-mark + wordmark slot on top,
   nav slot in middle (scrolls), user slot on bottom.
   Slot content is consumer-defined; this shell only owns chrome.

   Migrated 2026-05-02 from platform/_shared/_rail.css and
   admin/app/shell.css (which had two parallel copies).
   ADR 0017 documents the absorption.
*/

aly-rail-shell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: var(--rail-width);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--surface-2);
  border-right: 1px solid transparent;
  padding: 0 var(--space-1) var(--space-2);
  transition: width var(--dur-card) var(--ease),
              background var(--dur-card) var(--ease),
              border-right-color var(--dur-card) var(--ease);
  overflow: hidden;
  z-index: 10;
}

aly-rail-shell:hover,
aly-rail-shell[data-expanded="true"] {
  width: var(--rail-expanded);
  background: var(--surface);
  border-right-color: var(--border-3);
}

body[data-route="landing"] aly-rail-shell {
  background: var(--shell);
  border-right-color: transparent;
}

body[data-route="landing"] aly-rail-shell:hover,
body[data-route="landing"] aly-rail-shell[data-expanded="true"] {
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border-right-color: var(--border-3);
}

aly-rail-shell[data-popover-open="true"] {
  overflow: visible;
  z-index: 1000;
}

/* ── Brand-mark slot (top) ───────────────────────────── */

aly-rail-shell .logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--chrome-header-h);
  box-sizing: border-box;
  padding: 0 var(--space-2);
  margin-bottom: var(--space-2);
  border-bottom: var(--chrome-hairline-w) solid transparent;
  transition: border-color var(--dur-card) var(--ease);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  flex: 0 0 auto;
}

aly-rail-shell:hover .logo,
aly-rail-shell[data-expanded="true"] .logo {
  border-color: var(--chrome-hairline-color);
}

aly-rail-shell .logo .mark {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

aly-rail-shell .logo .mark[data-brand-mark="myfs"] {
  width: 30px;
}

aly-rail-shell .logo .mark img,
aly-rail-shell .logo .mark svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  color: var(--ink);
  transition: color var(--dur-card) var(--ease);
}

aly-rail-shell:hover .logo .mark svg,
aly-rail-shell[data-expanded="true"] .logo .mark svg {
  color: var(--brand);
}

/* Two-image logo state — grey at rest, brand-green when expanded.
   Both images stack via absolute positioning so the swap is instant
   (no layout shift, no glyph reflow). */
aly-rail-shell .logo .mark {
  position: relative;
}
aly-rail-shell .logo .mark .m-rest,
aly-rail-shell .logo .mark .m-rest-dark,
aly-rail-shell .logo .mark .m-active {
  position: absolute;
  inset: 0;
  transition: opacity var(--dur-card) var(--ease);
}
aly-rail-shell .logo .mark .m-active,
aly-rail-shell .logo .mark .m-rest-dark {
  opacity: 0;
}
aly-rail-shell:hover .logo .mark .m-rest,
aly-rail-shell[data-expanded="true"] .logo .mark .m-rest {
  opacity: 0;
}
aly-rail-shell:hover .logo .mark .m-active,
aly-rail-shell[data-expanded="true"] .logo .mark .m-active {
  opacity: 1;
}

/* iter-14 polish (2026-05-20, per user feedback): in dark mode the rest-
   state grey mark blends into the dark page bg. Swap to the white
   variant for the rest state; the green active variant still works on
   dark since the iter-13 brand-lift gives sufficient contrast. */
[data-theme="dark"] aly-rail-shell .logo .mark .m-rest {
  opacity: 0;
}
[data-theme="dark"] aly-rail-shell .logo .mark .m-rest-dark {
  opacity: 1;
}
[data-theme="dark"] aly-rail-shell:hover .logo .mark .m-rest-dark,
[data-theme="dark"] aly-rail-shell[data-expanded="true"] .logo .mark .m-rest-dark {
  opacity: 0;
}

aly-rail-shell .logo .wm {
  font-size: var(--type-headline-sm);
  font-weight: var(--fw-bolder);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity var(--dur-hover) var(--ease),
              transform var(--dur-card) var(--ease);
  white-space: nowrap;
}

aly-rail-shell:hover .logo .wm,
aly-rail-shell[data-expanded="true"] .logo .wm {
  opacity: 1;
  transform: translateX(0);
}

/* ── Nav slot (middle, scrolls) ──────────────────────── */

aly-rail-shell .rail-nav,
aly-rail-shell > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
  width: 100%;
}

aly-rail-shell li {
  width: 100%;
  margin: 0;
  padding: 0;
}

/* ── Section eyebrow — hairline collapsed, label expanded ───── */

aly-rail-shell .rail-section {
  font-size: var(--type-eyebrow);
  font-weight: var(--fw-bolder);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  height: 9px;
  padding: var(--space-1) var(--space-2);
  position: relative;
  transition: height var(--dur-card) var(--ease),
              padding var(--dur-card) var(--ease);
}

aly-rail-shell .rail-section::before {
  content: "";
  position: absolute;
  left: var(--space-2);
  width: 18px;
  top: 50%;
  height: 1px;
  background: var(--border-3);
  opacity: 1;
  transition: opacity var(--dur-hover) var(--ease);
}

/* Selector list supports both <h3> (canonical, component-friendly,
   per framework-portability-auditor iter-862) and the transitional
   <span role="heading" aria-level="3"> from the 60th-lap a11y pass.
   The reset block below neutralizes <h3> browser defaults so the
   visual rendering matches the previous <span>-based pattern. */
aly-rail-shell .rail-section > h3,
aly-rail-shell .rail-section > span {
  display: inline-block;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--dur-hover) var(--ease),
              transform var(--dur-card) var(--ease);
}

/* h3 specific reset — neutralize browser defaults so h3 inherits
   the eyebrow typography from .rail-section parent. Explicit
   property names (not `font: inherit` shorthand) because the
   shorthand inconsistently picks up CSS custom properties. */
aly-rail-shell .rail-section > h3 {
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  font-style: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: inherit;
  margin: 0;
}

aly-rail-shell:hover .rail-section,
aly-rail-shell[data-expanded="true"] .rail-section {
  height: 26px;
  padding: var(--space-3) var(--space-2) var(--space-1);
}

aly-rail-shell:hover .rail-section::before,
aly-rail-shell[data-expanded="true"] .rail-section::before {
  opacity: 0;
  /* iter-17 (2026-05-20): 120ms → var(--dur-dismiss). Exact-match token. */
  transition-duration: var(--dur-dismiss);
}

aly-rail-shell:hover .rail-section > h3,
aly-rail-shell:hover .rail-section > span,
aly-rail-shell[data-expanded="true"] .rail-section > h3,
aly-rail-shell[data-expanded="true"] .rail-section > span {
  opacity: 1;
  transform: translateX(0);
}

/* ── Spacer (between nav scroll and user card) ───────── */

aly-rail-shell .rail-spacer {
  flex: 1 1 auto;
}

/* ── Auto-revealed elements (labels next to icons) ───── */

aly-rail-shell .reveal-on-expand {
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity var(--dur-hover) var(--ease),
              transform var(--dur-card) var(--ease);
  white-space: nowrap;
  pointer-events: none;
}

aly-rail-shell:hover .reveal-on-expand,
aly-rail-shell[data-expanded="true"] .reveal-on-expand {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
