/* Top bar, Arc-style (2026-10-28).
 *
 * Loaded after every other top-bar rule (responsive, controls, desk,
 * oceanus, topbar_frost, flat). It keeps Cairn's layout and the labels
 * that grow out of the icon buttons, and changes how they look and move:
 *
 * - Controls: 32px, 9px radius, secondary ink at rest. Hover is a quiet
 *   filled tint and full ink in 180ms; the drawn outline is gone.
 * - Press: buttons that act scale to .97; buttons that open a panel
 *   (Ask, Helm, search) answer with colour only, so the panel anchors
 *   against a steady box.
 * - Grow labels open on a smooth width reveal with a short slide, and
 *   close faster than they open.
 * - Search: on wide screens the palette launcher is a bordered field with
 *   its shortcut, always visible.
 * - Page title: 14px, full ink, rising in on load.
 */

html body .top-bar {
  --tb-hover: color-mix(in srgb, var(--text-primary) 6%, transparent);
  --tb-press: color-mix(in srgb, var(--text-primary) 10%, transparent);
  --tb-ease: cubic-bezier(.22, 1, .36, 1);
  --tb-enter: cubic-bezier(.16, 1, .3, 1);
  --tb-exit: cubic-bezier(.7, 0, .84, 0);
}

/* ---- Every control in the bar ---------------------------------------- */
html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn, .sidebar-mobile-trigger, .top-bar-tools-toggle,
  .oc-cmdp-trigger, .ask-oceanus-btn, .helm-launch, .tb-desk-btn, .tb-fs-btn) {
  min-width: 32px;
  height: 32px;
  border-radius: 9px !important;
  border: 1px solid transparent !important;
  background: transparent;
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 180ms var(--tb-ease),
    color 180ms var(--tb-ease),
    border-color 180ms var(--tb-ease),
    transform 160ms var(--tb-ease) !important;
}
html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn) {
  width: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}
html body .top-bar .top-bar-hist { gap: 2px; }
html body .top-bar .top-bar-hist-btn:disabled { opacity: .35; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn:not(:disabled), .sidebar-mobile-trigger, .top-bar-tools-toggle,
    .oc-cmdp-trigger, .ask-oceanus-btn, .helm-launch, .tb-desk-btn, .tb-fs-btn):hover {
    background: var(--tb-hover);
    color: var(--text-primary);
    border-color: transparent !important;
  }
}
html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn, .sidebar-mobile-trigger, .top-bar-tools-toggle,
  .oc-cmdp-trigger, .ask-oceanus-btn, .helm-launch, .tb-desk-btn, .tb-fs-btn):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 1px;
  background: var(--tb-hover);
  color: var(--text-primary);
  border-color: transparent !important;
}
/* Acting buttons press down; panel anchors answer with colour. */
html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn:not(:disabled), .tb-desk-btn, .tb-fs-btn):active {
  transform: scale(.97);
  background: var(--tb-press);
}
html body .top-bar :is(.oc-cmdp-trigger, .ask-oceanus-btn, .helm-launch, .sidebar-mobile-trigger, .top-bar-tools-toggle):active {
  transform: none;
  background: var(--tb-press);
}
/* Current and open states keep their meaning. */
html body.page-desk .top-bar .tb-desk-btn,
html body .top-bar .tb-desk-btn.active { color: var(--accent); background: var(--tb-hover); }
html body .top-bar .helm-launch[aria-expanded="true"] {
  border-color: var(--oc-action) !important;
  background: var(--oc-action);
  color: var(--text-inverse);
}

/* ---- Grow labels: smooth reveal, faster close ------------------------- */
@media (min-width: 821px) {
  html body .top-bar :is(.ask-oceanus-btn, .helm-launch, .tb-desk-btn, .tb-fs-btn) { padding: 0 8px; }
  html body .top-bar .tb-grow {
    font-weight: 500;
    letter-spacing: -0.005em;
    transform: translateX(-4px);
    transition:
      max-width 180ms var(--tb-exit),
      margin-left 180ms var(--tb-exit),
      opacity 120ms var(--tb-exit),
      transform 180ms var(--tb-exit) !important;
  }
  html body .top-bar :is(.oc-cmdp-trigger, .ask-oceanus-btn, .helm-launch, .tb-desk-btn, .tb-fs-btn):is(:hover, :focus-visible) .tb-grow,
  html body .top-bar .helm-launch[aria-expanded="true"] .tb-grow {
    transform: none;
    max-width: var(--tb-grow-w, 14rem) !important;
    transition:
      max-width 360ms var(--tb-enter),
      margin-left 360ms var(--tb-enter),
      opacity 220ms var(--tb-ease) 60ms,
      transform 360ms var(--tb-enter) !important;
  }
}

/* ---- Search launcher -------------------------------------------------- */
@media (min-width: 1100px) {
  html body .top-bar .oc-cmdp-trigger {
    width: auto;
    min-width: 150px;
    height: 32px;
    padding: 0 8px 0 10px;
    gap: 8px;
    justify-content: flex-start;
    border: 1px solid color-mix(in srgb, var(--text-primary) 13%, transparent) !important;
    border-radius: 10px !important;
    background: color-mix(in srgb, var(--bg-elevated, var(--bg-base)) 70%, transparent);
    color: var(--text-secondary);
    margin-right: 4px;
  }
  html body .top-bar .oc-cmdp-trigger .tb-grow {
    display: block;
    max-width: none !important;
    margin-left: 0 !important;
    opacity: 1 !important;
    transform: none !important;
    font-size: calc(12px * var(--ui-font-scale, 1));
    font-weight: 400;
    color: inherit;
  }
  html body .top-bar .oc-cmdp-trigger .oc-cmdp-trigger__kbd {
    display: inline-block !important;
    margin-left: auto;
    padding-left: 12px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: calc(10px * var(--ui-font-scale, 1));
    letter-spacing: .02em;
  }
  @media (hover: hover) and (pointer: fine) {
    html body .top-bar .oc-cmdp-trigger:hover {
      border-color: color-mix(in srgb, var(--text-primary) 24%, transparent) !important;
      background: var(--tb-hover);
      color: var(--text-primary);
    }
  }
}

/* ---- Page title -------------------------------------------------------- */
html body .top-bar .top-bar-title {
  font-size: calc(14px * var(--ui-font-scale, 1));
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  animation: tb-title-rise 280ms var(--tb-enter) both;
}
@keyframes tb-title-rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---- Touch: keep the 44px targets -------------------------------------- */
@media (hover: none) and (pointer: coarse) {
  html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn, .sidebar-mobile-trigger, .top-bar-tools-toggle,
    .oc-cmdp-trigger, .ask-oceanus-btn, .helm-launch, .tb-desk-btn, .tb-fs-btn) { min-width: 40px; height: 40px; }
}

/* ---- Reduced motion ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn, .sidebar-mobile-trigger, .top-bar-tools-toggle,
    .oc-cmdp-trigger, .ask-oceanus-btn, .helm-launch, .tb-desk-btn, .tb-fs-btn),
  html body .top-bar .tb-grow { transition: none !important; }
  html body .top-bar :is(.sidebar-toggle, .top-bar-hist-btn, .tb-desk-btn, .tb-fs-btn):active { transform: none; }
  html body .top-bar .top-bar-title { animation: none; }
}
