/* The transcription engine card on Settings -> Transcripts.
 *
 * Inline rather than a design-system component: the design system has no
 * status card, and this one is a status surface first and a form second.
 * Numbers are from the handoff's build spec.
 */

.engine-card {
  border: 1px solid var(--c-neutral-1200);
  border-radius: 12px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  row-gap: 18px;
}

/* The failure state swaps the border and nothing else. */
.engine-card.engine-broken {
  border-color: var(--c-red-dark);
}

.engine-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.engine-head h2 {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}

.engine-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.dot-live { background: var(--c-green); }
.dot-idle { background: var(--c-neutral-6); }
.dot-broken { background: var(--c-red); }

.badge-idle { background: var(--c-neutral-2); color: var(--c-neutral-11); }
.badge-broken { background: rgba(255, 73, 76, 0.12); color: var(--c-red); }

/* Pushed right, and the last thing read rather than the first. */
.engine-age {
  margin-left: auto;
  font-size: 12px;
  color: var(--c-neutral-9);
}

.engine-explainer,
.engine-note {
  border: 1px solid var(--c-neutral-3);
  border-radius: 8px;
  padding: 16px 18px;
}

.engine-explainer h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 500;
}

.engine-explainer p,
.engine-note p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--c-neutral-10);
}

.engine-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  max-width: 760px;
}

.engine-note-glyph {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--c-neutral-6);
  color: var(--c-neutral-6);
  font-size: 11px;
  line-height: 14px;
  text-align: center;
}

/* The consequence, before any diagnostics. */
.engine-alarm {
  border: 1px solid var(--c-red-dark);
  border-radius: 8px;
  padding: 16px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.engine-alarm-glyph {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--c-red);
  color: var(--c-red);
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

.engine-alarm-title {
  margin: 0 0 6px;
  font-weight: 500;
  color: var(--c-white);
}

.engine-alarm p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--c-neutral-10);
}

.engine-facts {
  display: grid;
  grid-template-columns: 150px 1fr;
  row-gap: 12px;
  column-gap: 16px;
  margin: 0;
}

.engine-facts > div {
  display: contents;
}

.engine-facts dt {
  font-size: 12px;
  color: var(--c-neutral-9);
}

.engine-facts dd {
  margin: 0;
  font-size: 13px;
  color: var(--c-white);
}

/* Addresses and error text are machine words and are set as such. */
.engine-facts .engine-machine {
  font: var(--t-code-400);
  color: var(--c-neutral-12);
  word-break: break-all;
}

/* Between the read-only facts and the fields that change them. */
.engine-fields {
  border-top: 1px dashed transparent;
  background-image: repeating-linear-gradient(
    to right,
    var(--c-neutral-3) 0 4px,
    transparent 4px 8px
  );
  background-size: 100% 1px;
  background-repeat: no-repeat;
  padding-top: 18px;
  display: flex;
  flex-direction: column;
  row-gap: 18px;
}

.engine-result {
  font-size: 12px;
  color: var(--c-neutral-9);
  align-self: center;
}

.engine-result-good { color: var(--c-green); }
.engine-result-bad { color: var(--c-red); }

/* The same ring as the Google credential check. */
[data-engine-check][data-busy="yes"]::before,
[data-engine-save][data-busy="yes"]::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -3px;
  border: 2px solid var(--c-neutral-3);
  border-top-color: var(--c-blue);
  border-radius: 50%;
  animation: dgspin 900ms linear infinite;
}

@keyframes dgspin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  [data-engine-check][data-busy="yes"]::before,
  [data-engine-save][data-busy="yes"]::before {
    animation: none;
  }
}

@media (max-width: 900px) {
  .engine-fields .grid-two {
    grid-template-columns: 1fr;
  }
  .engine-facts {
    grid-template-columns: 130px 1fr;
  }
}

/* At 390 the card collapses: the address gets its own line and every action
 * is thumb-sized. */
@media (max-width: 480px) {
  /* The title wraps before the badge does, and the age gets its own line -
     squeezed into a column beside the title it reads as a second heading. */
  .engine-head {
    flex-wrap: wrap;
  }

  .engine-head h2 {
    flex: 1 1 auto;
  }

  .engine-age {
    flex: 1 0 100%;
    margin-left: 18px;
  }

  .engine-facts {
    grid-template-columns: 1fr;
    row-gap: 4px;
  }
  .engine-facts > div {
    display: block;
    margin-bottom: 8px;
  }
  .engine-card .section-actions .button {
    min-height: 44px;
  }
}
