/* Responsive layout: which elements belong to which width class.
   ONE copy, served from public/ so `expo start` (dev) and the exported build
   read the same file. It used to be duplicated here and inline in
   web/index.html, which is a fact stored twice and therefore a fact that drifts.

   CSS media queries are evaluated by the browser layout engine, so they are
   right on first paint. JS width detection is not — `useIsMobile()` reads
   `screen.width` at mount and refreshes only on resize, and every phone-layout
   bug this app has had traced back to that difference. Prefer these classes.

   `.desktop-only` / `.mobile-only` say what they do. Their predecessors were
   `.admin-sidebar` / `.admin-hamburger` / `.admin-mobile-header`, named after
   the one place they were first used, which is not a detail: an author asking
   "how do I hide this on a phone?" does not search for `.admin-sidebar`, so the
   chat history column shipped with no width handling at all and the web app
   rendered as a squished desktop on Android for six weeks (AMB-698). */
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
}
@media (min-width: 768px) {
  .desktop-only { display: flex !important; }
  .mobile-only { display: none !important; }
}

/* The collection action row (CollectionToolbar) is ONE row on a phone — that is
   the whole point of moving Add and Search onto FABs. It must therefore SHRINK
   its sort control rather than wrap, which is what iOS does ("Recently added" →
   "Re…"). Measured on a 393px phone the row wants ~7px more than it has, so
   without this it wraps and the chrome doubles in height for the sake of a few
   pixels. `min-width: 0` on the children is what actually permits the shrink —
   a flex item's default `min-width: auto` refuses to go below its content. */
@media (max-width: 767px) {
  .collection-chrome-row { flex-wrap: nowrap !important; }
  .collection-chrome-row > * { min-width: 0; }
}

/* Card grids (lib/cardGrid.ts). The ideal card width is a width-class decision,
   so it lives here rather than in a JS `isMobile` branch: on a phone two ~160px
   columns, on a desktop the per-surface default the call site passes in.
   `min-width: 0` stops an item outgrowing the track it was placed in — without
   it a long unbroken title pushes its column wide and the page with it. */
@media (max-width: 767px) {
  :root { --card-min: 160px; --tile-min: 100%; --card-gap: 8px; }
}
.card-grid > * { min-width: 0; }

/* Image Studio (AMB-2198). On a desktop the composer is a fixed column with the
   results beside it; on a phone the page stacks and the composer takes the
   width the shell leaves it. Fixed at 380px inside the shell's padding, it ran
   the prompt box and the Generate button off a 393px screen. */
@media (max-width: 767px) {
  .studio-page { flex-direction: column !important; padding: 0 !important; }
  /* flex-basis too: the results' 320px basis is a WIDTH beside the composer,
     and in a column it would become a 320px-tall scroll box. */
  .studio-page > * { width: 100% !important; flex-basis: auto !important; }
}

/* The chat's Conversations column eases in when shown (AMB-3110), so a person
   sees what the toggle did. It unmounts on hide, so only the way in animates.
   A short fade and nudge, not a width sweep: animating the width clipped the
   column's leading edge mid-way, so the toggle was not under the pointer.
   Desktop only: below 768px the column is display:none and the phone drawer
   is used instead. */
@keyframes history-column-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}
@media (min-width: 768px) and (prefers-reduced-motion: no-preference) {
  .history-column-enter { animation: history-column-in 160ms ease-out; }
}

/* Chat welcome tiles (apps/web/app/(app)/chat.tsx). Two across where there is
   room, one on a phone. The tile's ✕ waits for hover or keyboard focus where
   there is a mouse, so four tiles do not carry four close buttons at rest; on
   touch it is always visible, because a finger cannot hover.
   768px is DESKTOP_MIN_WIDTH (components/chat/ConversationsControls.tsx).
   chat.tsx centres the empty state at that same line in JS, because it
   changes React Native inline styles a stylesheet cannot override. */
.welcome-tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 16px;
}
@media (min-width: 768px) {
  .welcome-tile-grid { grid-template-columns: 1fr 1fr; }
}
.welcome-tile > div { transition: border-color 120ms ease, box-shadow 120ms ease; }
.welcome-tile:hover > div {
  border-color: #00B4D8 !important;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
}
@media (hover: hover) {
  .welcome-tile-dismiss { opacity: 0; transition: opacity 120ms ease; }
  .welcome-tile:hover .welcome-tile-dismiss,
  .welcome-tile:focus-within .welcome-tile-dismiss { opacity: 1; }
}
