# DEI Realty — the HTML shell
# Instructions for an agent composing an email.
#
# Self-contained on purpose. Everything needed to produce a correct branded
# email is in this file; you do not need the repository.
#
#   The Well is the blank template — see /email/client-well.html. A truly empty
#   shell is chrome around a void; The Well marks the region so the blank shows
#   its own structure. House convention across every Opscend property.
#
#   Fetch:  https://deirealty.op-site.net/email/client.html
#           https://deirealty.op-site.net/email/team.html
#           https://deirealty.op-site.net/email/agent.txt   (this file)

## 0 · Before anything — one blocker and two standing facts

THE POSTAL ADDRESS IS SET.
CAN-SPAM requires a physical postal address in every commercial email.
DEI Realty's is:

    1500 McConnor Pkwy, 3rd Floor, Schaumburg, IL 60173

Confirmed 2026-09-01. It is set once as POSTAL_ADDRESS in
scripts/email-shell.mjs and defaults into every client email, so you do not
pass it and it cannot drift between templates. Passing an explicitly empty one
still throws.

It is the same building as Diamond Equity Investments Chicago. That is a fact
about an office, not a systems intersection — nothing is shared between the two.

⚠️ DEI REALTY HAS NO EMAIL SENDING ADDRESS YET.
Notion's "Live Data — Realty" records the email as "not yet set". Confirm the
from-address with the operator before any send.

⚠️ THE PHONE NUMBER IS WITHHELD, AND THE OBVIOUS ONE IS WRONG.
(630) 333-9073 appears in DEI Realty's live site footer AND in Notion's
"Live Data — Realty" as the dedicated SMS number. Marcel confirmed on
2026-09-01 that IT IS NOT REALTY'S NUMBER. Both sources are wrong at source.

No phone appears in any shell or template. Do NOT put one in, and do NOT copy
333-9073 from the site or from Notion. When the real number is known it goes in
the shell footer via the `phone` slot, once, and nowhere else.

## 1 · Pick the shell

CLIENT — external. Buyers, sellers, leads.
  Full lockup, the ink footer with DEI's registered tagline, the phone,
  Equal Housing Opportunity, and the unsubscribe. Identical for every agent:
  a client should not care which system wrote to them. The address, the Equal
  Housing line and the opt-out are required, not decorative.

TEAM — internal. DEI Realty staff: agents, transaction coordinators, brokers.
  Agent output, handoffs, ops reporting. Compact header that names the sending
  agent. NO tagline, NO postal address, NO Equal Housing line, NO unsubscribe —
  internal mail is not commercial email, and an opt-out link on staff mail
  implies a staff member can opt out of being told a closing moved.

ROUTING: decide by RECIPIENT, not by inspecting the body.
  Going to a client, lead or member of the public  -> client
  Going to someone who works at DEI Realty          -> team

  Note for anyone who knows the Chicago shell: that one derives its routing
  from the stored templates, because Chicago's template table has 77 rows with
  a recognisable manager-facing subset. DEI REALTY'S TABLE HAS NO EMAIL BODIES
  AT ALL — its six rows are SMS only. There is no data here to derive a rule
  from, so do not invent one. Use the recipient.

## 2 · Normalize the body BEFORE putting it in the shell

DEI Realty has not written its email templates yet, so today most bodies will
be text you compose. Normalize anyway — the moment templates are authored, the
same hazard that bit Chicago applies here, and the step is cheap.

  1. STRIP ANY OPT-OUT THE BODY BROUGHT WITH IT. Remove a trailing <p>
     containing {optOutLink}, or "want to receive future emails", or
     "unsubscribe anytime", or a bare <a> whose href is {optOutLink}. The shell
     owns the opt-out; a body carrying its own gives the reader two.

  2. IF THE BODY ALREADY CONTAINS A BLOCK TAG — <p>, <div>, <table>, <h1>-<h6>,
     <ul>, <ol>, <li>, <blockquote>, <pre>, <figure> — it is real HTML. Do not
     wrap it, do not escape it, do not second-guess it.

  3. IN THAT HTML, CONVERT NEWLINES THAT SIT BETWEEN TEXT into <br>. A
     signature or a details block written as three lines will otherwise arrive
     as one, because HTML collapses newlines to spaces. Convert only a newline
     with text on its left; leave newlines between tags alone.

  4. OTHERWISE IT IS PLAIN TEXT. Escape & < > , split on blank lines into
     paragraphs, turn remaining single newlines into <br>, wrap each paragraph
     in <p>...</p>.

## 3 · Fill the shell

CLIENT — four slots:
  {{preheader}}      one line, ~90 characters. The grey text after the subject
                     in the inbox list. Leave it empty and the client scrapes
                     the first words of the body instead, which is usually
                     worse.
  {{emailBody}}      the normalized body from step 2. Triple brace in the file —
                     raw HTML, not escaped.
  {{contactId}}      the contact's Notion page id. It becomes
                     /email-unsubscribe?id=<that>.
  {{postalAddress}}  defaults to the registered address; you rarely pass it.
  {{phone}}          OPTIONAL and currently withheld — see section 0. Supply
                     nothing and the whole region is removed rather than left
                     as a blank line.

TEAM — three slots:
  {{agent}}          the sending agent's code: CSA, SMA, LGA, LA or PUA.
  {{preheader}}
  {{emailBody}}

Replace EVERY occurrence of each token, not just the first. Each shell
documents its own tokens in the comment at its top, so the first occurrence of
{{preheader}} is that documentation — a single-occurrence replace substitutes
the comment and leaves the real token sitting in the markup.

The SUBJECT LINE is an email header, not markup. It is not in either file.

## 4 · Merge tokens do not collide

  {singleBrace}    DEI's own — {sellerName}, {firstName}, {propertyAddress},
                   {reviewLink}, {agentFirstName} ...
  {{doubleBrace}}  the shell's slots — {{preheader}}, {{agent}}, {{contactId}},
                   {{postalAddress}}

Leave DEI's single-brace tokens exactly as they are. They are substituted
downstream, after the shell is filled.

## 5 · The opt-out

  https://deirealty.op-site.net/email-unsubscribe?id=<notion page id>

This is DEI REALTY'S OWN opt-out, on DEI Realty's own site. It shares a link
SHAPE with the Diamond Equity corporate page and nothing else — different
business, different list. Never point a DEI Realty email at the Diamond Equity
opt-out, or at any other host.

`/unsubscribe` and `/email-opt-out` are permanent aliases and render the same
page, because links already sent must never break.

## 6 · Check your work before sending

  · No "{{" remains anywhere outside an HTML comment.
  · A CLIENT email shows exactly ONE visible Unsubscribe link. Note the href
    itself contains "email-unsubscribe", so a case-insensitive count of the
    word finds two in a CORRECT email — count the anchor text.
  · A CLIENT email carries the Equal Housing Opportunity line and the postal
    address (1500 McConnor Pkwy). No phone.
  · A TEAM email shows NO unsubscribe, NO postal address and NO Equal Housing
    line.
  · No "{optOutLink}" survives anywhere.
  · The body sits inside the well — you have added no header, footer, logo or
    signature of your own. The frame is already built.

## 7 · What you must not change

  · Colour. Three values in the shells deliberately differ from the live site
    at the same size because the site's values fail WCAG AA, and an email has
    no zoom affordance and a legally required line to read:
      - small text and links use logo-red #C43C3C (4.75:1 on bone), not
        brass #DF3A3A (4.03:1). White on #C43C3C is 5.30:1; white on #DF3A3A
        is 4.46:1 and misses.
      - meta text on bone uses stone #4A4A46 (7.38:1), not the v3
        stylesheet's #8A857B (3.28:1).
      - in the ink footer, small labels are bone rather than red; red on ink
        is 4.12:1 and fails.
    All three replacements are DEI Realty brand tokens. Do not "restore" the
    site values here.
  · One red moment per view. Red means action or series in this brand.
  · No capsule or pill tags, no blurred text, no glow text, no gradient blobs.
  · Do not edit the shells to suit one email. If a send needs something the
    shell cannot express, say so rather than modifying the frame.

## 8 · Provenance

Canonical source is the private repo melockhart/dei-realty →
public/email/ and scripts/email-shell.mjs. This host is a published copy.
Never edit here.

⚠️ This is DEI Series LLC. It shares no code, tokens, components or content
with the Diamond Equity Investments repo. That shell looks nothing like this
one on purpose — different business, different brand, and red is DEI Realty's
action colour where Diamond Equity removed it. Do not carry anything across.
