/* The app shell's top bar (prototype/home-v2.html, .topbar; decision 75): the date on the left, the client
   search in the centre and the reading banner on the right. It sits at the top of the main panel on every
   page; the page under it starts a little higher so the bar doesn't push content down. */
/* Liquid Glass: a floating chrome bar at the top of the transparent main area; pages scroll under it. The
   banner inside it is a panel (near-solid, never blurred): glass never nests in glass. */
.topbar {
  --tb-ease: cubic-bezier(.22, 1, .36, 1);
  --tb-swap: 0.25s;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
  min-height: 56px; padding: 8px 10px 8px 20px;
  font-size: 13.5px; line-height: 20px; color: var(--muted);
  position: sticky; top: 0; z-index: 20;
  background: var(--glass-bg-strong); border: 1px solid var(--glass-edge); border-radius: var(--radius-card); box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: var(--glass-filter); backdrop-filter: var(--glass-filter);
}
.topbar .tb-side { min-width: 0; display: flex; align-items: center; }
.topbar .tb-left { justify-content: flex-start; }
/* The banner shrinks with the room it has (the mark and "3 of 45" last), so it never runs under the search. */
.topbar .tb-right { justify-content: flex-end; container-type: inline-size; }
.topbar .tb-centre { display: flex; justify-content: center; min-width: 0; }
.topbar .tb-centre .gs { width: clamp(240px, 30vw, 380px); }
/* The suggestions open centred under the search. */
.topbar .tb-centre .hs-pop { left: 50%; right: auto; margin-left: calc(max(100%, 420px) / -2); }
.topbar .tb-date { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .tb-status { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .tb-status-text { overflow: hidden; text-overflow: ellipsis; }
.main-panel > .topbar ~ .page { padding-top: 32px; }
.main-panel > .topbar + .closing-banner { margin: 16px 0 0; }

/* The reading banner: a rounded notification pill. The mark on the left, the stage ("Reading", "Preparing
   workpapers", "Needs you") and the document it's on now, "3 of 45" under it, and a thin progress line
   along the bottom edge. It's a button: it opens the drawer (src/components/reading/drawer.tsx). */
.tb-banner {
  position: relative; display: inline-flex; align-items: center; gap: 10px; max-width: min(100%, 340px); min-width: 0;
  height: 40px; padding: 0 16px 0 6px; border-radius: var(--radius-pill); overflow: hidden;
  background: var(--panel-bg); box-shadow: var(--shadow-panel); color: var(--ink); text-decoration: none;
  border: 0; font: inherit; text-align: left; cursor: pointer;
  transition: box-shadow 0.15s, background-color 0.15s;
}
.tb-banner[aria-expanded="true"] { background: var(--surface-solid); box-shadow: var(--shadow-panel), 0 0 0 1px var(--line-strong); }
.tb-banner:hover { background: var(--surface-solid); box-shadow: var(--shadow-panel), 0 0 0 1px var(--line-strong); }
.tb-banner:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.tb-bn-ic {
  width: 28px; height: 28px; border-radius: var(--radius-pill); flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--on-primary);
}
.tb-banner[data-state="waiting"] .tb-bn-ic { background: var(--dot-review); }
.tb-banner[data-state="preparing"] .tb-bn-ic { background: var(--dot-preparing); }
.tb-bn-body { display: flex; flex-direction: column; min-width: 0; line-height: 16px; }
.tb-bn-line { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-size: 13px; white-space: nowrap; }
.tb-bn-title { font-weight: 600; flex-shrink: 0; }
/* The two names (leaving and entering) share one cell, so the swap never changes the pill's size. */
.tb-bn-names { display: inline-grid; min-width: 0; overflow: hidden; }
.tb-bn-name { grid-area: 1 / 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.tb-bn-sub { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-bn-meter { position: absolute; left: 44px; right: 16px; bottom: 3px; height: 2px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--ink) 8%, transparent); overflow: hidden; }
.tb-bn-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--dot-preparing); }

/* Not much room: the mark and "3 of 45" only (the link's label still says it all). */
@container (max-width: 230px) {
  .tb-banner .tb-bn-line { display: none; }
  .tb-banner { padding-right: 12px; gap: 8px; }
  .tb-banner .tb-bn-sub { font-size: 12.5px; color: var(--ink); }
  .tb-bn-meter { left: 40px; right: 12px; }
}
@container (max-width: 150px) {
  .topbar .tb-status-text { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .topbar .dot.pulse { animation: tb-pulse 1.6s ease-in-out infinite; }
  .tb-banner { animation: tb-bn-in 0.3s var(--tb-ease) both; }
  .tb-banner.is-folding { animation: tb-bn-out var(--tb-swap) ease-in forwards; pointer-events: none; }
  .tb-bn-name.is-leaving { animation: tb-name-out var(--tb-swap) var(--tb-ease) forwards; }
  .tb-bn-name.is-entering { animation: tb-name-in var(--tb-swap) var(--tb-ease) both; }
  .tb-bn-meter > span { transition: width 0.5s var(--tb-ease); }
  .tb-bn-ic.is-live svg { animation: tb-pulse 1.6s ease-in-out infinite; }
  .topbar .tb-status { animation: tb-fade 0.25s ease-out both; }
}
/* Reduced motion: no slide and no fade; the old name simply goes. */
@media (prefers-reduced-motion: reduce) {
  .tb-bn-name.is-leaving { display: none; }
  .tb-banner.is-folding { opacity: 0; }
}
@keyframes tb-pulse { 50% { opacity: 0.35; } }
@keyframes tb-fade { from { opacity: 0; } }
@keyframes tb-bn-in { from { opacity: 0; transform: translateY(-6px) scale(0.94); } }
@keyframes tb-bn-out { to { opacity: 0; transform: translateY(-6px) scale(0.94); } }
@keyframes tb-name-out { to { opacity: 0; transform: translateY(-80%); } }
@keyframes tb-name-in { from { opacity: 0; transform: translateY(80%); } }

@media (max-width: 1000px) {
  .topbar { padding: 8px 10px 8px 16px; gap: 12px; }
  .main-panel > .topbar + .closing-banner { margin: 12px 0 0; }
}
/* A phone: the date, then the search button and the banner on one row; the open search takes its own row. */
@media (max-width: 700px) {
  .topbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px; position: relative; }
  /* The right side is a size container, so it takes its width from the row, never from the banner. */
  .topbar .tb-left { flex: 1 1 0; order: 1; }
  .topbar .tb-centre { order: 2; flex: 0 0 auto; }
  .topbar .tb-right { order: 3; flex: 1 1 0; }
  .topbar .tb-centre .gs { width: auto; }
  .topbar .tb-centre:has(.gs.open) { order: 5; flex-basis: 100%; }
  .topbar .tb-centre .hs-pop { left: 0; margin-left: 0; }
  .main-panel > .topbar ~ .page { padding-top: 20px; }
}

/* A file dropped outside Home (src/components/app-drop-guard.tsx): a short note at the bottom, as the
   prototype's status toast. */
.app-drop-note { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; width: min(560px, calc(100% - 32px)); display: flex; justify-content: center; pointer-events: none; }
.app-drop-note > span { background: var(--ink); color: var(--on-primary); border-radius: 12px; padding: 11px 16px; font-size: 13.5px; line-height: 19px; box-shadow: var(--shadow-primary); }
@media (prefers-reduced-motion: no-preference) {
  .app-drop-note > span { animation: tb-rise 0.2s ease-out both; }
}
@keyframes tb-rise { from { opacity: 0; transform: translateY(6px); } }
