/* modules/accelerate.css */
/* Accelerate: top-bar dock (toggle, bloom stage, pulse, burst-power chevron),
   Throw confirmation, fork chips, handshake-key review, context loading, and
   the layout-size hints applied to Studio panels. Colour language follows the
   colony launcher: cyan for the zooid, amber for the warning tier. */

.accelerate-dock-mount { display: inline-flex; align-items: center; }
.accelerate-dock-mount[hidden] { display: none; }

.accelerate-dock {
  --acc-zooid: #22d3ee;
  --acc-warn: #f59e0b;
  --acc-line: var(--panel-border, #d1d5db);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.accelerate-toggle[aria-pressed="true"] {
  color: var(--acc-zooid);
  border-color: var(--acc-zooid);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--acc-zooid) 25%, transparent);
}
.accelerate-toggle svg { width: 18px; height: 18px; }

.accelerate-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 2px;
  border: 1px solid var(--acc-line);
  border-radius: 999px;
  background: var(--bg-3, #f3f4f6);
}
.accelerate-controls[hidden] { display: none; }

/* Mini colony stage + bloom ring. */
.accelerate-bloom {
  --bloom-intensity: 0.2;
  --bloom-ms: 1200ms;
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle, #0b1320 55%, #05080f 100%);
  flex: none;
}
.accelerate-bloom canvas { width: 100% !important; height: 100% !important; }
.accelerate-bloom::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color 0.25s;
}
.accelerate-bloom[data-cycle="handshake"]::after,
.accelerate-bloom[data-cycle="charging"]::after {
  border-color: var(--acc-zooid);
  border-top-color: transparent;
  animation: accelerate-spin 0.8s linear infinite;
}
.accelerate-bloom[data-cycle="settled"]::after { border-color: color-mix(in srgb, var(--acc-zooid) 50%, transparent); }
.accelerate-bloom[data-cycle="error"]::after { border-color: var(--error, #ef4444); }
.accelerate-bloom.is-blooming::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--acc-zooid) 80%, transparent) 0%, transparent 70%);
  animation: accelerate-bloom var(--bloom-ms) ease-out forwards;
  pointer-events: none;
}
.accelerate-bloom[data-tier="5"].is-blooming::before {
  background: radial-gradient(circle, color-mix(in srgb, var(--acc-warn) 85%, transparent) 0%, transparent 70%);
}
.accelerate-bloom-static { background: radial-gradient(circle, var(--acc-zooid) 0 18%, #0b1320 22% 100%); }

@keyframes accelerate-bloom {
  0% { opacity: calc(0.5 + var(--bloom-intensity) * 0.5); transform: scale(0.4); }
  100% { opacity: 0; transform: scale(calc(1.2 + var(--bloom-intensity) * 1.6)); }
}
@keyframes accelerate-spin { to { transform: rotate(360deg); } }

.accelerate-pulse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: var(--acc-zooid);
  color: #04202a;
  /* Longhands: `font: 600 13px/1 inherit` is invalid (a CSS-wide keyword
     can't sit inside the shorthand), so the whole line was dropped. */
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.accelerate-pulse:disabled { opacity: 0.6; cursor: progress; }
.accelerate-pulse.is-warn { background: var(--acc-warn); color: #2a1600; }

.accelerate-chevron {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text, inherit);
  cursor: pointer;
}
.accelerate-chevron[aria-expanded="true"] { background: var(--bg-2, #e5e7eb); }

.accelerate-status {
  max-width: 180px;
  font-size: 11px;
  color: var(--text-secondary, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.accelerate-dock[data-error] .accelerate-status { color: var(--error, #ef4444); white-space: normal; }

.accelerate-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1200;
  width: 300px;
  max-height: min(70vh, 540px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--acc-line);
  border-radius: 12px;
  background: var(--panel, #fff);
  color: var(--text, #111827);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.accelerate-menu[hidden] { display: none; }
.accelerate-menu-title {
  margin: 8px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary, #6b7280);
}
.accelerate-menu-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.accelerate-menu-item:hover, .accelerate-menu-item:focus-visible { background: var(--bg-2, #f3f4f6); outline: none; }
.accelerate-menu-item[aria-checked="true"] { box-shadow: inset 3px 0 0 var(--acc-zooid); font-weight: 600; }
.accelerate-menu-item.is-warn .accelerate-menu-label { color: var(--acc-warn); }
.accelerate-menu-label { white-space: nowrap; }
.accelerate-menu-detail { font-size: 12px; color: var(--text-secondary, #6b7280); text-align: right; }
.accelerate-menu-foot { margin-top: 6px; padding: 6px 8px 2px; border-top: 1px solid var(--acc-line); }
.accelerate-menu-link {
  border: 0;
  background: none;
  color: var(--acc-zooid);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

/* Throw confirmation */
.accelerate-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--overlay-tint, rgba(0, 0, 0, 0.45));
}
.accelerate-confirm-card {
  width: min(420px, 100%);
  padding: 20px;
  border-radius: 14px;
  border-top: 4px solid #f59e0b;
  background: var(--panel, #fff);
  color: var(--text, #111827);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.3);
}
.accelerate-confirm-card h2 { margin: 0 0 8px; font-size: 17px; }
.accelerate-confirm-card p { margin: 0 0 16px; color: var(--text-secondary, #4b5563); font-size: 14px; }
.accelerate-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.accelerate-confirm-actions button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--panel-border, #d1d5db);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.accelerate-confirm-go { background: #f59e0b !important; border-color: #f59e0b !important; color: #2a1600 !important; font-weight: 600 !important; }
.accelerate-confirm-go:disabled { opacity: 0.45; cursor: not-allowed; }

/* Fork chips under a steered reply */
.accelerate-forks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.accelerate-forks-label { font-size: 12px; color: var(--text-secondary, #6b7280); }
.accelerate-fork-chip {
  padding: 4px 10px;
  border: 1px solid #22d3ee;
  border-radius: 999px;
  background: color-mix(in srgb, #22d3ee 10%, transparent);
  color: inherit;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.accelerate-fork-chip:hover, .accelerate-fork-chip:focus-visible { background: color-mix(in srgb, #22d3ee 22%, transparent); }
.accelerate-fork-chip:disabled { opacity: 0.6; cursor: progress; }
.accelerate-fork-chip.is-done { opacity: 0.7; cursor: default; }

.accelerate-colony-receipt {
  margin-top: 10px;
  padding: 8px 12px;
  border-left: 3px solid #22d3ee;
  border-radius: 6px;
  background: color-mix(in srgb, #22d3ee 8%, transparent);
  font-size: 13px;
}
.accelerate-colony-receipt.is-sending { opacity: 0.8; }
.accelerate-colony-headline { margin: 0; font-weight: 600; }
.accelerate-colony-steers { margin: 6px 0 0; padding-left: 18px; }
.accelerate-colony-steers li { margin: 2px 0; overflow-wrap: anywhere; }
.accelerate-colony-receipt.is-unreachable { border-left-color: #f59e0b; background: color-mix(in srgb, #f59e0b 10%, transparent); }
.accelerate-colony-subhead { margin: 8px 0 0; font-weight: 600; }
.accelerate-colony-where { margin: 6px 0 0; font-size: 12px; color: var(--text-secondary, #6b7280); }

/* Context streaming visibly into the chat input */
.accelerate-context-loading {
  box-shadow: 0 0 0 2px color-mix(in srgb, #22d3ee 55%, transparent) !important;
  transition: box-shadow 0.2s;
}

/* Handshake-key review (companion console → Advanced) */
.accelerate-key-review { padding: 6px 2px 2px; max-height: 240px; overflow-y: auto; }
.accelerate-key-review[hidden] { display: none; }
.accelerate-key-empty { margin: 0; font-size: 12px; color: var(--text-secondary, #6b7280); }
.accelerate-key-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.accelerate-key-entry { padding: 6px 8px; border: 1px solid var(--panel-border, #d1d5db); border-radius: 8px; font-size: 11px; }
.accelerate-key-entry.is-rejected { border-color: var(--error, #ef4444); }
.accelerate-key-head { display: flex; justify-content: space-between; margin-bottom: 4px; font-weight: 600; text-transform: capitalize; }
.accelerate-key-row { display: flex; justify-content: space-between; gap: 8px; }
.accelerate-key-row code { font-size: 11px; }

/* Layout-size hints applied to Studio panels while Accelerate is on */
.accelerate-size-compact { max-height: 38vh; overflow: auto; }
.accelerate-focus-flash { animation: accelerate-focus 900ms ease-out; }
@keyframes accelerate-focus {
  0% { box-shadow: 0 0 0 3px color-mix(in srgb, #22d3ee 70%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@media (max-width: 640px) {
  .accelerate-status { display: none; }
  .accelerate-menu { position: fixed; top: 56px; left: 16px; right: 16px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .accelerate-bloom.is-blooming::before,
  .accelerate-bloom[data-cycle="handshake"]::after,
  .accelerate-bloom[data-cycle="charging"]::after,
  .accelerate-focus-flash { animation: none; }
}
