/* mobile-drawer.css — slide-in sidebar drawer for mobile.
 *
 * Mirrors the Claude mobile pattern: a hamburger in the top-left of
 * the stage opens the sidebar from the left edge over a dimmed
 * backdrop. Tapping outside, picking a session, or pressing Escape
 * closes it. On ≥541px screens this file is inert and the sidebar
 * sits inline as on desktop.
 */

@media (min-width: 541px) {
  .drawer-toggle,
  .drawer-backdrop { display: none !important; }
}

@media (max-width: 540px) {
  :root { --sidebar-drawer-width: min(82vw, 320px); }

  .drawer-toggle {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(env(safe-area-inset-left, 0px) + 12px);
    z-index: 70;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(18px) url(#liquid-glass) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border: 0;
    /* Dark glyph by default so it reads against the cream surfaces
     * (category-feed, read, writing). The welcome screen overrides
     * to white because the indigo corner-flag sits behind it. */
    color: var(--color-foreground);
    box-shadow: none;
    transition: background 0.2s ease, opacity 0.18s ease;
  }
  .drawer-toggle:hover { background: rgba(255, 255, 255, 0.16); }
  .drawer-toggle:active { transform: scale(0.96); }

  /* Welcome screen has an indigo corner-flag (see styles.css
   * .stage > .welcome.feed[data-active]::before) directly under
   * the hamburger — flip the glyph to white there for contrast. */
  body:has(.stage > .welcome.feed[data-active]) .drawer-toggle {
    color: #fff;
  }

  body[data-drawer-open] .drawer-toggle {
    opacity: 0;
    pointer-events: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-drawer-width);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    box-shadow: 0 0 0 transparent;
    border-right: 1px solid var(--color-border);
  }
  body[data-drawer-open] .sidebar {
    transform: translateX(0);
    box-shadow: 0 0 24px rgba(26, 26, 26, 0.18);
  }

  /* Restore the labels/text the rail mode hides — inside the drawer
   * we want the full desktop-style sidebar. */
  .sidebar__name,
  .sidebar__footer,
  .sidebar__account { display: revert; }
  .sidebar__top { padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px; }

  /* Backdrop stays in the DOM only to catch clicks-outside-the-drawer
     and dismiss it. Transparent on purpose — the user asked for no
     darkening when the chrome pops out. */
  .drawer-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    pointer-events: none;
    z-index: 50;
  }
  body[data-drawer-open] .drawer-backdrop { pointer-events: auto; }

  .stage { width: 100%; }
  /* Push the active surfaces below the floating drawer-toggle so the
   * hamburger doesn't overlap content. The toggle is 44px tall + 12px
   * top inset; we add another 24px of breathing room before content. */
  .feed { padding: calc(env(safe-area-inset-top, 0px) + 80px) 14px 56px; }
  .writing__top {
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    padding-right: calc(env(safe-area-inset-right, 0px) + 16px);
    padding-left: 64px;
    /* Reserve enough vertical room that body content always starts below
     * the 48px+12px-top hamburger, even if the row's content collapses. */
    min-height: calc(env(safe-area-inset-top, 0px) + 60px);
    box-sizing: border-box;
  }
  .read__body { padding-top: calc(env(safe-area-inset-top, 0px) + 80px); }
  .category-feed__head { padding-top: calc(env(safe-area-inset-top, 0px) + 80px); }
  /* Post-publish "You just published" crumb and the LinkedIn fits
   * review both sit at the very top of the stage with no in-view
   * close button — without this clearance the floating hamburger
   * overlaps the crumb/headline on phones. */
  .writing-fit__inner { padding-top: calc(env(safe-area-inset-top, 0px) + 80px); }
  .linkedin-fit__inner { padding-top: calc(env(safe-area-inset-top, 0px) + 80px); }
}
