/* ============================================================================
   Sidebar auto-hide overlay for MOHIT AI (mohitai.cmll.in)
   Collapsed icon-rail by default; opens on hover; pin to lock open; mobile drawer.
   Additive — every rule is gated on body.sah-on (set by sidebar-autohide.js only
   after setup succeeds). If the JS never runs, nothing here applies and the
   sidebar behaves exactly as before. Rollback = remove the <link> + <script>.

   Design note: all RAIL (collapsed) rules are scoped to
     .side:not(:hover):not(:focus-within)
   so hovering/focusing the sidebar simply STOPS these rules from applying and
   the app's own native rendering (group accordion, section chips) returns —
   we never have to fight or re-implement the app's nav logic.
   ============================================================================ */

/* pin button (in sidebar) + mobile hamburger (in ticker) + mobile backdrop */
.sah-pin{display:none;align-items:center;justify-content:center;gap:6px;width:100%;
  margin:2px 0 12px;padding:6px 8px;border:1px solid rgba(255,255,255,.28);border-radius:6px;
  background:rgba(255,255,255,.12);color:#fff;font-size:11px;font-weight:700;letter-spacing:.4px;
  cursor:pointer;line-height:1;white-space:nowrap}
.sah-pin:hover{background:rgba(255,255,255,.22)}
body.sah-on .sah-pin{display:flex}
/* 19-Oct-2026: the pin lives on the brand row, small, pushed to the right of MOHIT AI */
.side .brand{align-items:center}
.side .brand .sah-pin{width:auto;margin:0 0 0 auto;padding:4px 8px;font-size:10px;border-radius:999px;flex:none}
/* the Customise menu button sits at the very bottom of the sidebar */
.side .nav-customise{margin-top:auto}
.sah-burger{display:none;align-items:center;justify-content:center;width:34px;height:30px;
  margin-right:12px;border:1px solid var(--line,rgba(120,90,160,.35));border-radius:6px;
  background:rgba(120,80,160,.08);color:var(--purple,#522E90);font-size:17px;line-height:1;
  cursor:pointer;flex:none}
.sah-backdrop{display:none}

@media (min-width:901px){
  body.sah-on .side{transition:width .18s ease, box-shadow .18s ease}

  /* keep the grid track slim while in auto mode (even on hover) so the floated
     panel overlays the content instead of pushing it */
  body.sah-on:not(.sah-pinned) #app{grid-template-columns:62px minmax(0,1fr)}

  /* ---------- RAIL: collapsed + not hovered/focused ---------- */
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within){
    width:62px;overflow:visible;padding-left:10px;padding-right:10px}
  /* brand -> monogram */
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .brand{justify-content:center;margin:0 0 12px}
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .brand small{display:none}
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .brand h1{font-size:0}
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .brand h1::before{
    content:'M';font-size:20px;color:#fff;font-family:var(--d-serif,'DM Serif Display',serif)}
  /* group headers -> centred icon, no chevron, no text */
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .nav-group{
    font-size:0;letter-spacing:0;text-align:center;padding:9px 0}
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .nav-group::after{display:none}
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .nav-group[data-sah-icon]::before{
    content:attr(data-sah-icon);font-size:18px;line-height:1;display:block}
  /* hide items + section chips entirely while railed */
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .nav-item,
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .nav-sections,
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .nav-section{display:none!important}
  /* pin -> small centred icon while railed */
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .sah-pin{padding:6px 0}
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .brand .sah-pin,
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .nav-customise{display:none}
  body.sah-on:not(.sah-pinned) .side:not(:hover):not(:focus-within) .sah-pin .sah-pin-txt{display:none}

  /* ---------- FLOAT OPEN on hover / keyboard focus (auto mode) ---------- */
  body.sah-on:not(.sah-pinned) .side:hover,
  body.sah-on:not(.sah-pinned) .side:focus-within{
    width:232px;overflow:auto;z-index:60;box-shadow:16px 0 44px rgba(18,10,38,.30)}

  /* ---------- PINNED OPEN: original full sidebar ---------- */
  body.sah-on.sah-pinned #app{grid-template-columns:232px minmax(0,1fr)}
}

/* ---------- MOBILE (<=900px): off-canvas slide-in drawer ---------- */
@media (max-width:900px){
  body.sah-on .side{position:fixed;top:0;left:0;bottom:0;width:min(82vw,270px);height:100vh;
    transform:translateX(-101%);transition:transform .22s ease;z-index:70;overflow:auto;
    flex-direction:column;flex-wrap:nowrap;align-items:stretch;border-right:1px solid var(--line);
    box-shadow:6px 0 40px rgba(18,10,38,.4)}
  body.sah-on.sah-drawer-open .side{transform:none}
  body.sah-on #app{grid-template-columns:1fr}
  body.sah-on .sah-burger{display:inline-flex}
  /* iPhone, installed app (viewport-fit=cover, translucent status bar): the page runs under the status bar and the rounded
     corner, where a tap goes to the phone, not the page (owner 27-Oct-2026: "the top left where I can search or select the
     tab is not getting touched"). The header and the drawer start below the safe area, and the menu button sits a little
     in from the edge with a finger-sized target. In a browser tab the insets are 0 and nothing moves. */
  body.sah-on .top{padding-top:calc(10px + env(safe-area-inset-top,0px));padding-left:calc(14px + env(safe-area-inset-left,0px))}
  body.sah-on .sah-burger{margin-left:10px;width:44px;height:40px;font-size:20px}
  body.sah-on .side{padding-top:calc(12px + env(safe-area-inset-top,0px))}
  body.sah-on.sah-drawer-open .sah-backdrop{display:block;position:fixed;inset:0;
    background:rgba(10,6,24,.45);z-index:65}
  body.sah-on .sah-pin{display:none}
}

@media (prefers-reduced-motion:reduce){
  body.sah-on .side{transition:none!important}
}
