/* ----------------------------------------------------------------------------
   responsive.css — Viewport breakpoints and the reduced-motion block. Deliberately late in
   the cascade: these override the component sheets above.
   Slice 14 of 16 (see css/tokens.css for the full load order).
   ------------------------------------------------------------------------- */
/* ------------------------------------------------------------ responsive */
/* Any element that overflows the viewport width forces a horizontal scroll on
   the whole page — which on mobile also stretches the fixed .starfield canvas
   past the visible area, so the field looks shifted or absent. Belt-and-braces:
   the layout below fits everything, and this guarantees the field stays put. */
html,
body {
  overflow-x: hidden;
}

/* The short touch-oriented library intro — shown only on small screens, where
   the desktop copy's shift-click/hover/drag instructions are meaningless. */
.lib-hint-mobile {
  display: none;
}

/* Kill the mobile double-tap-zoom delay on every control (no-op for mouse). */
button,
a,
label,
input {
  touch-action: manipulation;
}

@media (max-width: 979px) {

  /* iOS Safari auto-zooms the page when a focused input's font-size is under
     16px — the single biggest "the layout jumped around" complaint on phones. */
  input:not([type='checkbox']) {
    font-size: 16px;
  }

  /* keep the composer clear of the iPhone home indicator; the page's own
     top padding goes — the pills row carries its 8px gap itself, so the row
     sits snug under the header instead of floating a paragraph below it.
     Double class: the 720px block's `.page { padding: … }` shorthand comes
     later in the file and would otherwise silently win the cascade. */
  .page.chat-page {
    padding-top: 0;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .page {
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 720px) {
  .user-email {
    display: none;
  }

  .app-header {
    gap: 10px;
    padding: 0 12px;
  }

  .lib-hint-desktop {
    display: none;
  }

  .lib-hint-mobile {
    display: block;
  }

  /* Library rows: on desktop a file row is one flex line — name, type and
     token chips side by side plus a status badge and three action buttons.
     At phone width that squeezed the NAME (the one thing that matters) to
     nothing. Grid instead: the name block owns all remaining width
     (minmax(0,1fr) lets it ellipsise), actions keep fixed slots, and the
     secondary chips (status badge, folder token cost) bow out. */
  .tree-file {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto auto;
    align-items: center;
  }

  .tree-file .badge {
    display: none;
  }

  .folder-tokens {
    display: none;
  }

  /* tighter chrome so the filename keeps as much width as possible */
  .folder-header,
  .tree-file {
    gap: 6px;
  }

  .folder-header .icon-btn,
  .tree-file .icon-btn {
    width: 28px;
    height: 28px;
  }

  /* upload zone: drag isn't how phones upload — tighten it up */
  .upload-zone {
    padding: 18px 14px;
  }

  .upload-zone .uz-icon {
    display: none;
  }

  .app-header nav {
    gap: 6px;
  }

  .app-header nav a {
    padding: 7px 14px;
  }

  .page {
    padding: 22px 16px 30px;
  }

  .page-head h1 {
    font-size: 21px;
  }

  .msg,
  .msg.assistant {
    max-width: 100%;
    width: 100%;
  }

  .msg.assistant {
    padding-left: 28px;
  }
}

/* Below this the top bar can't hold the "Sign out" text pill alongside the nav
   and the three toggles, so it collapses to an icon-only button and the nav
   pills tighten up. This is the width at which the buttons used to overlap. */
@media (max-width: 560px) {
  .brand-sub {
    display: none;
  }

  .brand img {
    height: 24px;
  }

  .app-header {
    gap: 8px;
    padding: 0 10px;
  }

  .app-header nav a {
    padding: 6px 12px;
    font-size: 13px;
  }

  .header-actions {
    gap: 8px;
  }

  /* The help "?" is the most expendable header control — the same guide is
     one tap away via the Get started pill on an empty chat. */
  #help-btn {
    display: none;
  }

  /* Sign out → icon-only circular button, matching the other header controls. */
  #sign-out-btn.labelled {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
  }

  #sign-out-btn .signout-label {
    display: none;
  }

  #sign-out-btn .signout-ic {
    display: block;
  }

  .suggestion {
    max-width: 100%;
  }
}

/* Very small phones: keep the composer and Clear-chat pill clear of the edges. */
@media (max-width: 400px) {
  .app-header {
    gap: 6px;
    padding: 0 8px;
  }

  .app-header nav a {
    padding: 6px 11px;
  }

  .chat-messages {
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* respect users who opt out of motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}

