/* MY GENIE — Responsive layer (v1)
 * Loaded last; adapts the desktop mock to tablet + phone without touching
 * the canonical styles. Breakpoints: 1180 (grids stack, icon rail forced),
 * 880 (sidebar → off-canvas drawer + hamburger), 640 (compact header,
 * hero + panel sizing).
 */

/* =========== ≤ 1180 · tablet: stack grids, force the icon rail ========= */
@media (max-width: 1180px) {
  /* Every multi-column grid becomes a single column (Home, project
     workspace, files, decisions — all share .grid). */
  .grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Force the collapsed 72px icon rail regardless of the toggle state. */
  .shell,
  .shell[data-sidebar="expanded"] {
    --shell-nav-w: 72px;
  }
  .side .side-label,
  .side .ws-meta { display: none !important; }
  .side-ws,
  .side-user { justify-content: center; padding-left: 8px !important; padding-right: 8px !important; }

  /* Momentum: the two chart blocks stack. */
  .momentum-body { grid-template-columns: minmax(0, 1fr) !important; gap: 18px !important; }

  /* Work rows: drop the avatar stack + chevron, keep name/status/progress. */
  .work-row .col-avatars,
  .work-row .col-chev { display: none; }
  .work-row .col-progress { flex: 1 1 150px; min-width: 150px; }
}

/* =========== ≤ 880 · phone/tablet: off-canvas sidebar drawer =========== */

/* The hamburger hides on desktop tiers. */
.nav-burger { display: none !important; }

@media (max-width: 880px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  /* .side.side-v2 carries (0,2,0) base rules (sticky, width var, overflow
     hidden) — match that specificity so the drawer wins the cascade.
     The dark ink background + light labels from phase26-ink.css stay
     untouched — no background override here. */
  .side,
  .side.side-v2 {
    position: fixed;
    left: 0;
    top: 0;
    width: 264px;
    height: 100dvh;
    z-index: 95;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
    transform: translateX(-104%);
    transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
  }
  body.nav-open .side,
  body.nav-open .side.side-v2 { transform: none; }

  /* Labels come back inside the drawer — there is room now. */
  .side .side-label { display: inline-block !important; }
  .side .ws-meta { display: block !important; }
  .side-ws,
  .side-user { justify-content: flex-start; padding-left: 10px !important; padding-right: 10px !important; }

  /* Scrim behind the drawer (visual only; taps fall through to body —
     the shell-level click handler closes the drawer). */
  body.nav-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 14, 0.46);
    z-index: 90;
    backdrop-filter: blur(2px);
  }

  /* Hamburger shows only on this tier. */
  .nav-burger { display: inline-flex !important; }
  .main { padding: 10px 12px 28px; }

  /* Geni panel goes near-fullscreen on phones/tablets. */
  .geni-panel {
    width: calc(100vw - 20px) !important;
    max-width: 420px;
    right: 10px !important;
    max-height: calc(100dvh - 110px);
  }
}

/* =========== ≤ 640 · phone: compact header, hero, rows ================= */
@media (max-width: 640px) {
  .header { gap: 8px; padding: 10px 12px; }
  .header-search { display: none; }
  .btn-create span { display: none; }        /* Create = icon only */
  .crumb span:first-child { display: none; } /* keep current page only */
  .page-header-row { flex-wrap: wrap; }

  .hero { border-radius: 18px; }
  .mg-home-hero-editorial { min-height: 380px; }
  .mg-home-hero-editorial .mg-home-hero-copy { padding: 30px 22px 28px; max-width: none; }
  .mg-home-hero-editorial .mg-home-hero-greet { font-size: clamp(32px, 9vw, 44px) !important; }
  .mg-home-hero-editorial .mg-home-hero-sub { font-size: 14.5px !important; }
  .mg-home-hero-editorial .mg-home-hero-stats {
    flex-wrap: wrap;
    row-gap: 12px;
    padding-top: 14px;
  }
  .mg-home-hero-editorial .mg-hh-stat { padding: 2px 12px; }
  .mg-home-hero-editorial .mg-hh-stat:first-child { padding-left: 0; }

  /* Cards breathe less on phones. */
  .card { border-radius: 16px; }

  /* Work rows fully stack their meta line. */
  .work-row { gap: 10px; padding: 12px 10px; }
  .work-row .col-status { order: 2; }
  .work-row .col-progress { order: 3; flex-basis: 100%; min-width: 0; }

  /* Geni AI orb + panel margins. */
  .geni-orb { right: 14px !important; bottom: 14px !important; }
  .geni-panel { right: 8px !important; width: calc(100vw - 16px) !important; max-height: calc(100dvh - 84px); }

  /* Voice stage paddings on small screens. */
  .geni-voice-stage { padding: 20px 14px 16px; }
  .geni-voice-orb { width: 190px !important; height: 190px !important; }
}

/* Very narrow phones: keep the stat strip from overflowing the video. */
@media (max-width: 380px) {
  .mg-home-hero-editorial .mg-hh-stat { padding: 2px 9px; }
  .mg-home-hero-editorial .mg-hh-stat .v { font-size: 21px; }
}

/* =========== Header: burger centering (all tiers) + stronger mobile ===== */
.nav-burger {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.nav-burger svg { display: block; }

@media (max-width: 640px) {
  .header {
    height: 58px;
    padding: 0 10px;
    gap: 8px;
  }
  .header > * { flex-shrink: 0; }

  /* The crumb becomes a solid chip and may truncate. */
  .header .crumb {
    flex: 1 1 auto;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface, #fff);
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: var(--shadow-widget, 0 1px 2px rgba(15, 15, 18, 0.06));
    font-weight: 600;
  }
  .header .crumb .now {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Uniform 40px control pills. */
  .header .btn,
  .header .icon-btn {
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .header .btn { padding: 0 12px; }
  .header .btn-white span { display: none; } /* Inbox collapses to icon + badge */
}
