@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/copy-button/copy-button.css';
@layer cinder.components {
  /* ========================================
 * RESTART STATE
 * A chromeless modal: the dialog is the scrim, and the card is centred in it. Nothing in it
 * dismisses it, so the card has no close button and no header rule.
 * ======================================== */

  .cinder-restart-state__layout {
    display: grid;
    grid-template-columns: minmax(0, 28rem);
    justify-content: center;
    align-content: center;
    box-sizing: border-box;
    min-block-size: 100%;
    padding: var(--cinder-space-4);
  }

  .cinder-restart-state__card {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-3);
    box-sizing: border-box;
    inline-size: 100%;
    padding: var(--cinder-space-5);
    background: var(--cinder-surface-raised);
    border: var(--cinder-border-width) solid var(--cinder-border);
    border-radius: var(--cinder-radius-lg);
    box-shadow: var(--cinder-shadow-lg);
    color: var(--cinder-text-default);
    font-size: var(--cinder-text-sm);
    line-height: var(--cinder-leading-normal);
  }

  /* A failure is red on the whole card: the rule and the heading. */
  .cinder-restart-state__card[data-cinder-phase='failed'] {
    border-color: var(--cinder-status-danger-border);
  }

  .cinder-restart-state__title {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    margin: 0;
    font-size: var(--cinder-text-base);
    font-weight: var(--cinder-font-semibold);
    line-height: var(--cinder-leading-snug);
  }

  .cinder-restart-state__card[data-cinder-phase='failed'] .cinder-restart-state__title {
    color: var(--cinder-status-danger-text);
  }

  .cinder-restart-state__icon {
    display: inline-flex;
    flex: none;
    color: var(--cinder-accent-text);
  }

  .cinder-restart-state__card[data-cinder-phase='reconnecting'] .cinder-restart-state__icon {
    color: var(--cinder-status-warning-text);
  }

  .cinder-restart-state__card[data-cinder-phase='failed'] .cinder-restart-state__icon {
    color: var(--cinder-status-danger-text);
  }

  .cinder-restart-state__card[data-cinder-phase='restarting'] .cinder-restart-state__icon svg {
    animation: cinder-restart-state-spin 1.2s linear infinite;
  }

  @keyframes cinder-restart-state-spin {
    to {
      transform: rotate(360deg);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    :root:not([data-cinder-reduced-motion='false']):not([data-reduced-motion='off'])
      .cinder-restart-state__icon
      svg {
      animation: none;
    }
  }

  .cinder-restart-state__description {
    margin: 0;
    color: var(--cinder-text-muted);
  }

  /* ----------------------------------------
 * Reconnecting: the attempts, one segment each
 * ---------------------------------------- */

  .cinder-restart-state__attempts {
    display: flex;
    gap: var(--cinder-space-1-5);
  }

  .cinder-restart-state__segment {
    flex: 1 1 0;
    block-size: 0.25rem;
    border-radius: var(--cinder-radius-full);
    /* A track a step above the card, so unreached attempts stay visible on the raised surface. */
    background: color-mix(in oklch, var(--cinder-text-subtle) 28%, transparent);
  }

  .cinder-restart-state__segment[data-cinder-filled] {
    background: var(--cinder-accent-solid);
  }

  /* ----------------------------------------
 * Failed: what to check, the details, the command
 * ---------------------------------------- */

  /* What to check is a heading and a sentence on the card itself, not a box inside the card. */
  .cinder-restart-state__check {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-0-5);
  }

  .cinder-restart-state__check-title {
    margin: 0;
    font-weight: var(--cinder-font-semibold);
  }

  .cinder-restart-state__check-text {
    margin: 0;
    color: var(--cinder-text-muted);
  }

  .cinder-restart-state__details-summary {
    display: inline-flex;
    align-items: center;
    min-block-size: 1.5rem;
    cursor: pointer;
    inline-size: fit-content;
    color: var(--cinder-accent-text);
  }

  .cinder-restart-state__details-body {
    margin-block-start: var(--cinder-space-2);
    overflow-wrap: anywhere;
  }

  /* The label, then one flat row: the command in the code face, and the copy icon at the row's
     inline end. No chip or box around the command. */
  .cinder-restart-state__command {
    display: flex;
    flex-direction: column;
    gap: var(--cinder-space-1);
  }

  .cinder-restart-state__command-row {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
  }

  .cinder-restart-state__command-text {
    flex: 1 1 auto;
    min-inline-size: 0;
    font-family: var(--cinder-font-mono);
    font-size: var(--cinder-text-sm);
    font-weight: var(--cinder-font-medium);
    color: var(--cinder-text-default);
    overflow-wrap: anywhere;
  }

  .cinder-restart-state__copy {
    flex: none;
  }

  .cinder-restart-state__actions {
    display: flex;
    justify-content: flex-end;
  }

  /* On a coarse pointer the summary keeps its painted box; a pseudo-element, which takes no layout
     space, reaches 44 by 44. The action is a Button, which draws its own 44px hit area. */
  @media (any-pointer: coarse) {
    .cinder-restart-state__details-summary {
      position: relative;
    }

    .cinder-restart-state__details-summary::after {
      content: '';
      position: absolute;
      inset-block: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
      inset-inline: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
    }
  }

  @media (forced-colors: active) {
    .cinder-restart-state__card {
      border-color: CanvasText;
    }

    .cinder-restart-state__segment {
      background: GrayText;
    }

    .cinder-restart-state__segment[data-cinder-filled] {
      background: Highlight;
    }
  }
}
