/*
  Connections page styling.

  Its own stylesheet, like tomo-visibility.css and tomo-settings.css. The section carries
  .tomo-face, so every token (and the dark palette under prefers-color-scheme) comes from
  tomo-face.css, and so do .tomo-btn / .tomo-badge / .tomo-card__eyebrow. Nothing here invents
  a colour.

  Before P12 the section did not carry .tomo-face, so none of those tokens were defined inside
  it: .tomo-btn--primary's background and text colour resolved to nothing and the Connect and
  Disconnect buttons rendered as bare bold text, in light and dark alike.

  Each connection is a TomoCollapsibleRow (Ro, 26 Oct 2026, the collapsible row in
  tomo/mocks/connector-detail/ZenAI-Connector-Detail_Ro.html): the row owns the head, the pill,
  the motion and the on-mock strip. This sheet styles only what the open body holds: flat fact
  rows with hairlines, notes, the link editor and the actions, keyed off the row list's own width
  (a container query at 560px), so it behaves the same in a phone, a tablet or a side pane.

  Hosts include both (the row itself is styled in tomo-face.css):
    <link rel="stylesheet" href="_content/Tomo.Face/tomo-face.css" />
    <link rel="stylesheet" href="_content/Tomo.Face/tomo-connections.css" />
*/

.tomo-connections.tomo-face {
  box-sizing: border-box;
  width: 100%;
  height: auto;
  gap: var(--tomo-space-4);
  max-width: calc(740px + 2 * var(--tomo-space-4));
  margin: 0 auto;
  padding: 28px var(--tomo-space-4) 40px;
  background: transparent;
}

.tomo-connections *,
.tomo-connections *::before,
.tomo-connections *::after { box-sizing: border-box; }

.tomo-connections svg { flex: none; }

@media (max-width: 600px) {
  .tomo-connections.tomo-face { padding: 18px var(--tomo-space-3) 28px; }
}

/* The mock's page eyebrow is the accent, not the kit's muted card eyebrow. */
.tomo-connections__header .tomo-card__eyebrow {
  color: var(--tomo-accent);
}

.tomo-connections__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.tomo-connections__title {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.tomo-connections__lede {
  margin: 0;
  max-width: 62ch;
  color: var(--tomo-text-secondary);
  font-size: 14.5px;
  line-height: 1.5;
}

.tomo-connections__muted {
  margin: 0;
  color: var(--tomo-text-secondary);
  font-size: 13.5px;
}

/* Said once, for the page, not on every card. */
.tomo-connections__privacy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid var(--tomo-border-subtle);
  border-bottom: 1px solid var(--tomo-border-subtle);
  color: var(--tomo-text-secondary);
  font-size: 13.5px;
  line-height: 1.5;
}

.tomo-connections__privacy-icon { display: inline-flex; color: var(--tomo-ok); }
.tomo-connections__privacy-icon svg { width: 16px; height: 16px; margin-top: 2px; }

.tomo-connections__list { gap: 12px; }

.tomo-connection__purpose {
  margin: 0;
  max-width: 62ch;
  color: var(--tomo-text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

/* ---- Notes: what just happened, why it needs a reconnect ---- */

.tomo-connection__note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--tomo-radius-md);
  color: var(--tomo-text-primary);
  font-size: 13.5px;
  line-height: 1.5;
}

.tomo-connection__note > svg { width: 16px; height: 16px; margin-top: 2px; }
.tomo-connection__note-text { flex: 1; min-width: 0; }
.tomo-connection__note-text b { display: block; font-weight: 650; }

.tomo-connection__note--ok { background: var(--tomo-ok-bg); }
.tomo-connection__note--ok > svg { color: var(--tomo-ok); }
.tomo-connection__note--err { background: var(--tomo-danger-bg); box-shadow: inset 0 0 0 1px var(--tomo-danger-line); }
.tomo-connection__note--err > svg { color: var(--tomo-danger-ink); }
.tomo-connection__note--info { background: var(--tomo-surface-sunken); }
.tomo-connection__note--info > svg { color: var(--tomo-text-secondary); }
.tomo-connection__note--warn { background: var(--tomo-warn-bg); }
.tomo-connection__note--warn > svg { color: var(--tomo-warn-ink); }

/* The x keeps a 44px hit area while its glyph stays small. */
.tomo-connection__dismiss {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--tomo-touch);
  height: var(--tomo-touch);
  margin: -12px -12px -12px 0;
  border: 0;
  border-radius: var(--tomo-radius-md);
  background: transparent;
  color: var(--tomo-text-secondary);
  cursor: pointer;
}

.tomo-connection__dismiss:hover { background: color-mix(in srgb, var(--tomo-text-primary) 7%, transparent); }
.tomo-connection__dismiss svg { width: 14px; height: 14px; }

/* ---- Facts: flat rows, hairlines, no boxes ---- */

.tomo-connection__facts {
  margin: 0;
  border-top: 1px solid var(--tomo-border-subtle);
}

.tomo-connection__facts:empty { display: none; }

.tomo-connection__row {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 2px 16px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--tomo-border-subtle);
}

.tomo-connection__row dt {
  color: var(--tomo-text-muted);
  font-size: 13px;
}

.tomo-connection__row dt small {
  display: block;
  margin-top: 1px;
  font-size: 11.5px;
  line-height: 1.35;
}

.tomo-connection__row dd {
  min-width: 0;
  margin: 0;
  font-size: 14px;
}

.tomo-connection__dim { color: var(--tomo-text-muted); }

/* A long address truncates; the full one is in the title tooltip. */
.tomo-connection__trunc {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tomo-connection__inline {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
}

.tomo-connection__inline-icon { display: inline-flex; align-self: center; color: var(--tomo-text-muted); }
.tomo-connection__inline-icon svg { width: 14px; height: 14px; }

.tomo-connection__health {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.tomo-connection__health i { display: block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tomo-connection__health--ok { color: var(--tomo-ok); }
.tomo-connection__health--needsreconnect { color: var(--tomo-warn-ink); }

.tomo-connection__perms {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tomo-connection__perms li { display: flex; align-items: flex-start; gap: 8px; }
.tomo-connection__perms svg { width: 14px; height: 14px; margin-top: 4px; color: var(--tomo-text-muted); }

/* ---- Connecting ---- */

.tomo-connection__steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tomo-connection__steps li { display: flex; align-items: center; gap: 10px; font-size: 14px; }

.tomo-connection__spin {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--tomo-border-strong);
  border-top-color: var(--tomo-accent);
  border-radius: 50%;
  animation: tomo-connection-spin 0.9s linear infinite;
}

.tomo-btn .tomo-connection__spin {
  border-color: color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
}

@keyframes tomo-connection-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .tomo-connection__spin { animation: none; }
}

/* ---- Manage link editor ---- */

.tomo-connection__linkedit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border-radius: var(--tomo-radius-md);
  background: var(--tomo-surface-sunken);
}

.tomo-connection__linkedit label { font-size: 13px; font-weight: 600; }

.tomo-connection__linkedit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tomo-connection__input {
  width: 160px;
  min-width: 0;
  height: var(--tomo-touch);
  padding: 0 12px;
  border: 1px solid var(--tomo-border-strong);
  border-radius: var(--tomo-radius-md);
  background: var(--tomo-surface);
  color: var(--tomo-text-primary);
  font: inherit;
}

.tomo-connection__hint { margin: 0; color: var(--tomo-text-muted); font-size: 12.5px; }

/* ---- Actions: one primary at most, Disconnect apart on the right ---- */

.tomo-connection__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.tomo-connection__push { margin-left: auto; }

.tomo-connection__aside {
  margin: 0;
  color: var(--tomo-text-muted);
  font-size: 12.5px;
}

.tomo-connections .tomo-crow__content .tomo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tomo-touch);
  padding: 0 18px;
  border-radius: var(--tomo-radius-md);
  font-size: 14px;
  white-space: nowrap;
}

.tomo-btn--secondary {
  border: 1px solid var(--tomo-border-strong);
  background: var(--tomo-surface);
  color: var(--tomo-text-primary);
}

.tomo-btn--secondary:hover:not(:disabled) { background: var(--tomo-surface-sunken); }

.tomo-btn--quiet-danger {
  border: 1px solid transparent;
  background: transparent;
  color: var(--tomo-danger-ink);
}

.tomo-btn--quiet-danger:hover:not(:disabled) { background: var(--tomo-danger-bg); }

/* Destructive, and it reads that way: disconnecting revokes the grant upstream and purges every
   stored copy, so it should not look like an ordinary button. */
.tomo-btn--danger {
  border: 1px solid transparent;
  background: var(--tomo-danger-ink);
  color: var(--tomo-on-danger);
}

.tomo-btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--tomo-danger-ink) 85%, black);
}

.tomo-btn[aria-busy="true"] { cursor: progress; }

/* Disconnect confirm: replaces the action row, physically apart from Reconnect. */
.tomo-connection__confirm {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--tomo-radius-md);
  background: var(--tomo-danger-bg);
  box-shadow: inset 0 0 0 1px var(--tomo-danger-line);
}

.tomo-connection__confirm b { font-size: 14.5px; }

.tomo-connection__confirm p {
  margin: 0;
  color: var(--tomo-text-secondary);
  font-size: 13.5px;
}

.tomo-connection__confirm .tomo-connection__actions { justify-content: flex-end; }

.tomo-connections .tomo-crow__content .tomo-btn:focus-visible,
.tomo-connection__dismiss:focus-visible,
.tomo-connection__input:focus-visible {
  outline: 2px solid var(--tomo-accent);
  outline-offset: 2px;
}

/* Phone, or any row under 560px: fact rows stack, buttons go full width and Disconnect comes
   last with a gap. The row's own head folds in tomo-face.css. */
@container (max-width: 559px) {
  .tomo-connection__row { grid-template-columns: minmax(0, 1fr); padding: 9px 0; }
  .tomo-connection__actions { flex-direction: column; align-items: stretch; }
  .tomo-connection__actions .tomo-btn { width: 100%; }
  .tomo-connection__push { margin-top: 4px; margin-left: 0; }
  .tomo-connection__confirm .tomo-connection__actions { flex-direction: column-reverse; }
  .tomo-connection__linkedit-row { flex-direction: column; align-items: stretch; }
  .tomo-connection__input { width: 100%; }
}
