/* An automation, on its own page and in the workspace's list. */
.automation__name {
    color: inherit;
    font-weight: var(--font-weight-medium);
    text-decoration: none;
}

.automation__name:hover {
    text-decoration: underline;
}


/* What starts it: its source's icon and the trigger in a sentence. */
.automation__statement {
    display: grid;
    grid-template-columns: 1.5rem minmax(0, 1fr) auto;
    column-gap: var(--spacing-md);
    row-gap: var(--spacing-sm);
    align-items: center;
}

.automation__statement-icon {
    display: grid;
    place-items: center;
}

.automation__clause {
    margin: 0;
    line-height: 2;
}

/* The line under what it does: where it posts, and with whose accounts. */
.automation__clause--footer {
    padding-top: var(--spacing-md);
    border-top: var(--border-width) solid var(--color-divider-subtle);
    color: var(--color-on-surface-muted);
}

.automation__action {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.automation__chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    vertical-align: middle;
    padding: 0.125rem 0.5rem;
    border-radius: 0.5rem;
    color: var(--color-on-surface);
    background-color: var(--color-surface-highlighted);
    font-weight: var(--font-weight-medium);
    line-height: 1.5;
    text-decoration: none;
}

.automation__chip-icon {
    width: 0.875rem;
    height: 0.875rem;
    flex-shrink: 0;
    color: var(--color-on-surface-muted);
}

.automation__chip--link:hover {
    background-color: var(--color-secondary);
}

.automation__note {
    margin: 0;
    color: var(--color-on-surface-muted);
    font-size: var(--font-size-sm);
}

/* What happened each time it ran, newest first: when, why, and how it went. */
.automation__entries {
    margin: 0;
    padding: 0;
    list-style: none;
}

.automation__entry {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr) auto;
    gap: var(--spacing-md);
    align-items: baseline;
    padding-block: var(--spacing-sm);
    border-bottom: var(--border-width) solid var(--color-divider-subtle);
    font-size: var(--font-size-sm);
}

.automation__entry:first-child {
    padding-top: 0;
}

.automation__entry:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.automation__entry-time {
    color: var(--color-on-surface-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.automation__entry-summary {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.automation__problem {
    margin: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-sm);
    color: var(--color-on-error);
    background-color: var(--color-error);
    font-size: var(--font-size-sm);
}


/* In the workspace's list: a row per automation, its source in a tile, what it is in the middle, its last run at the end. */
.automation__count {
    color: var(--color-on-surface-faint);
    font-weight: var(--font-weight-regular);
}

.automation__row {
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) auto;
    gap: var(--spacing-md);
    align-items: center;
    padding-block: var(--spacing-md);
    border-bottom: var(--border-width) solid var(--color-divider-subtle);
}

.automation__row:first-child {
    padding-top: 0;
}

.automation__row:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.automation__tile {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--radius-sm);
    background-color: var(--color-surface-highlighted);
}

.automation__icon {
    width: 1.125rem;
    height: 1.125rem;
    object-fit: contain;
    color: var(--color-on-surface-muted);
}

/* Paused: still listed, quietly. */
.automation__name--paused,
.automation__tile--paused {
    opacity: 0.55;
}

.automation__summary {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.automation__meta {
    color: var(--color-on-surface-muted);
    font-size: var(--font-size-sm);
}

.automation__link {
    color: inherit;
}

/* A problem in the list: one line of red, without the box it has on its own page. */
.automation__problem--inline {
    padding: 0;
    background-color: transparent;
}

.automation__run {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--color-on-surface-muted);
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.automation__run-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: var(--radius-full);
    background-color: var(--color-on-surface-faint);
}

.automation__run--running .automation__run-dot,
.automation__run--waiting .automation__run-dot {
    background-color: var(--color-on-surface);
}

.automation__run--waiting {
    color: var(--color-on-surface);
}

.automation__run--failed {
    color: var(--color-on-error);
}

.automation__run--failed .automation__run-dot {
    background-color: var(--color-on-error);
}

/* On a phone the last run drops under what the automation is. */
@media (max-width: 40rem) {
    .automation__entry {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--spacing-xs);
    }

    .automation__row {
        grid-template-columns: 2.25rem minmax(0, 1fr);
    }

    .automation__run {
        grid-column: 2;
    }
}
