/* Overview of the state e-mails: a list on the left, the envelope, the compiled preview and the
   MJML source on the right. Only for the template, the e-mails themselves live in emails/. */
.emails-header__row {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: 32px;
}

.emails-header__brand {
  display: flex;
  gap: 20px;
  align-items: center;
  min-width: 0;
}

.emails-header__title {
  display: grid;
  gap: 2px;
  padding-left: 20px;
  border-left: 1px solid var(--color-line-on-ink);
}

.emails-header__title strong {
  font-size: var(--text-title);
  font-weight: 600;
}

.emails-header__title span {
  color: var(--color-on-ink-muted);
  font-family: var(--font-mono);
  font-size: var(--text-mono-xs);
}

.emails {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.emails__aside {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.emails__group {
  margin: 20px 0 8px;
  color: var(--color-fg-muted);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: var(--text-label--letter-spacing);
  text-transform: uppercase;
}

.emails__nav > .emails__group:first-child {
  margin-top: 0;
}

.emails__list {
  display: grid;
  gap: 2px;
}

/* A link of the list has no border and no fill of its own: the hover changes only the colour.
   The open e-mail is a state, not a hover, so it gets the surface and the red edge. */
.emails__link {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--color-fg);
  text-decoration: none;
  transition: var(--transition-state);
}

.emails__link:hover {
  color: var(--color-brand);
}

.emails__link[aria-current="page"] {
  background: var(--color-surface);
  box-shadow:
    inset 2px 0 var(--color-brand),
    inset 0 0 0 1px var(--color-line);
}

.emails__link-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-ink);
  color: var(--color-on-ink);
}

.emails__link-icon[data-tone="success"] {
  background: var(--color-success);
}

.emails__link-icon[data-tone="danger"] {
  background: var(--color-brand);
}

.emails__link-icon[data-tone="neutral"] {
  background: var(--color-fg-hint);
}

.emails__link-icon .icon {
  width: 16px;
  height: 16px;
}

.emails__link-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.emails__link-text strong {
  font-size: var(--text-ui);
  font-weight: 600;
  line-height: 1.3;
}

.emails__link-text span {
  color: var(--color-fg-muted);
  font-family: var(--font-mono);
  font-size: var(--text-mono-xs);
  line-height: 1.4;
}

.emails__rules {
  padding: 16px 18px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.emails__rules .emails__group {
  margin-top: 0;
}

.emails__rules ul {
  display: grid;
  gap: 8px;
  color: var(--color-fg-muted);
  font-size: var(--text-ui-sm);
  font-weight: 400;
  line-height: 1.45;
}

.emails__rules code,
.emails__tags code {
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--color-canvas);
  color: var(--color-fg);
  font-family: var(--font-mono);
  font-size: var(--text-mono-xs);
}

.emails__stage {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.emails__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.emails__toolbar .icon {
  width: 16px;
  height: 16px;
}

/* The width only means something for the preview, the source keeps it but dims it. */
.emails__widths {
  transition: opacity 0.16s ease;
}

.emails[data-view="source"] .emails__widths {
  opacity: 0.4;
  pointer-events: none;
}

.emails__mail {
  display: grid;
  gap: 16px;
  animation: emails-in 0.2s ease;
}

.emails__mail[hidden] {
  display: none;
}

/* An e-mail of an order or a claim comes for a person and for a company, the switch shows one.
   A sign-in e-mail has one form only and stays on view with both. */
.emails__variant {
  display: grid;
  gap: 16px;
  animation: emails-in 0.2s ease;
}

.emails[data-kind="person"] [data-variant="company"],
.emails[data-kind="company"] [data-variant="person"] {
  display: none;
}

@keyframes emails-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.emails__envelope {
  padding: 20px 24px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.emails__envelope-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.emails__subject {
  font-size: var(--text-heading-md);
  font-weight: var(--text-heading-md--font-weight);
  line-height: 1.2;
}

.emails__files {
  display: flex;
  flex: none;
  gap: 4px;
}

.emails__meta {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-line-soft);
}

.emails__meta > div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

.emails__meta dt {
  color: var(--color-fg-muted);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: var(--text-label--letter-spacing);
  text-transform: uppercase;
}

.emails__meta dd {
  color: var(--color-fg);
  font-size: var(--text-ui-sm);
  font-weight: 400;
  line-height: 1.45;
}

/* The preview sits on white so the grey canvas of the e-mail shows where it ends. On a phone
   width it gets the edge of a device. */
.emails__preview {
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  animation: emails-in 0.2s ease;
}

.emails__frame {
  display: block;
  width: 100%;
  max-width: 680px;
  height: 900px;
  border: 0 solid var(--color-ink);
  border-radius: 0;
  background: var(--color-canvas);
  transition:
    max-width 0.28s ease,
    height 0.2s ease,
    border-width 0.28s ease,
    border-radius 0.28s ease;
}

.emails[data-width="mobile"] .emails__frame {
  max-width: 395px;
  border-width: 10px;
  border-radius: 28px;
}

.emails[data-view="source"] .emails__preview,
.emails[data-view="preview"] .emails__source {
  display: none;
}

.emails__source {
  position: relative;
  min-width: 0;
  animation: emails-in 0.2s ease;
}

.emails__copy {
  position: absolute;
  top: 12px;
  right: 12px;
}

.emails__code {
  max-height: 75vh;
  margin: 0;
  padding: 20px 24px;
  overflow: auto;
  border-radius: var(--radius-md);
  background: var(--color-ink);
  color: var(--color-on-ink-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  tab-size: 2;
}

.emails__code .mj-tag {
  color: var(--color-brand-tint);
}

.emails__code .mj-attr {
  color: var(--color-on-ink);
}

.emails__code .mj-value {
  color: var(--color-highlight);
}

.emails__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.emails__tags-title {
  color: var(--color-fg-muted);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  font-weight: 400;
  letter-spacing: var(--text-label--letter-spacing);
  text-transform: uppercase;
}

.emails__tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emails__tags code {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--color-line);
  background: var(--color-surface);
}

@media (max-width: 960px) {
  .emails {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The list stays above the preview, the rules move under it. */
  .emails__aside {
    display: contents;
  }

  .emails__rules {
    order: 1;
  }

  .emails__list {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 640px) {
  .emails-header__row {
    padding-inline: 16px;
  }

  .emails-header__title span {
    display: none;
  }

  .emails {
    padding: 20px 16px 40px;
  }

  .emails__envelope {
    padding: 16px;
  }

  .emails__envelope-head {
    flex-direction: column;
  }

  .emails__preview {
    padding: 16px 0;
  }
}
