/* ---------------------------------------------------------------------------
   email.css — the composed email and, above all, where it actually went.
   ---------------------------------------------------------------------------
   The routing block is the most important thing in this file. Two lines that
   must never be confusable with each other:

       Extracted:    what we scraped off the lead's website
       Rerouted to:  where the message really went

   Amber when it was rerouted to the test inbox. RED when it was not, because
   "we emailed a real stranger" must not look like "we emailed ourselves".
--------------------------------------------------------------------------- */

.email {
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  background: var(--c-surface);
  overflow: hidden;
}

.email__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: var(--s-3);
  border-bottom: 1px solid var(--c-border);
}
.email__title {
  font-size: var(--t-xs);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-fg-muted);
}

/* ---- routing ------------------------------------------------------------- */
.email__routing {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--c-border);
}
.email__route {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: var(--s-2);
  align-items: baseline;
  padding: var(--s-2) var(--s-3);
  background: var(--c-surface);
  font-size: var(--t-sm);
}
.email__routekey {
  font-weight: var(--fw-semi);
  color: var(--c-fg-muted);
}
.email__routeval { color: var(--c-fg); }

.email__route--rerouted {
  background: var(--c-warn-soft);
  box-shadow: inset 3px 0 0 var(--c-warn);
}
.email__route--rerouted .email__routekey,
.email__route--rerouted .email__routeval { color: var(--c-warn-ink); }
.email__route--rerouted .email__routeval { font-weight: var(--fw-semi); }

/* No reroute means this went to the real scraped addresses. */
.email__route--live {
  background: var(--c-danger-soft);
  box-shadow: inset 3px 0 0 var(--c-danger);
}
.email__route--live .email__routekey,
.email__route--live .email__routeval { color: var(--c-danger-ink); }
.email__route--live .email__routeval { font-weight: var(--fw-bold); }

.email__route--none .email__routeval { color: var(--c-fg-faint); }

/* ---- fields -------------------------------------------------------------- */
.email__fields {
  display: grid;
  gap: var(--s-1);
  padding: var(--s-3);
  border-bottom: 1px solid var(--c-border);
}
.email__field {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: var(--s-2);
  font-size: var(--t-sm);
}
.email__field[hidden] { display: none; }
.email__fieldkey {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--c-fg-faint);
  padding-top: 2px;
}
.email__fieldval { color: var(--c-fg-muted); min-width: 0; }
.email__field--subject .email__fieldval { color: var(--c-fg); font-weight: var(--fw-medium); }
.email__fieldval--bad { color: var(--c-danger-ink); }

/* ---- preview ------------------------------------------------------------- */
.email__preview { display: flex; flex-direction: column; }
.email__preview[hidden] { display: none; }

.email__previewbar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--c-surface-2);
}
.email__previewlabel {
  font-size: var(--t-xs);
  font-weight: var(--fw-semi);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-fg-muted);
}
.email__previewnote { font-size: var(--t-xs); }
.email__expand { margin-left: auto; }

/* sandbox="" plus a CSP inside the frame: the email's CSS cannot leak out, the
   page's cannot leak in, and the preview cannot make a network request. */
.email__frame {
  display: block;
  width: 100%;
  height: 300px;
  border: 0;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  transition: height var(--m-base) var(--m-ease);
}
.email--expanded .email__frame { height: 70vh; }

@media (max-width: 640px) {
  .email__route,
  .email__field { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .email__previewnote { display: none; }
  .email__frame { height: 240px; }
  .email--expanded .email__frame { height: 62vh; }
}
