/*
  Marketing site styles (#261, restyled in #568 to the Mail map design in the Slate palette).
  The look follows docs/design/portal-design-mail-map.md: a cool grey page, white panels with a
  1px border and no shadow, cobalt for actions and links, Archivo for text and JetBrains Mono for
  domains and records. Red and green are used only the way the portal uses them (a failing line,
  a passing line), never as decoration.

  The shared tokens file (@emailsecurity/ui) still holds the Signal values, which the operator
  console uses, so the Slate values are set here for the marketing site only. This is the same
  list as apps/portal/src/client/slate.css. Slate has no dark theme designed yet, so the site stays
  light even when the device asks for dark; the selector list below matches every rule in the
  shared file that would otherwise switch the palette.

  The security policy (public/_headers) allows no inline styles, so values that vary
  per element (meter segment widths) are classes, not style="".
*/
@import "/ui/styles/tokens.css";

:root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
  color-scheme: light;
  --mt-canvas: #EEF1F3;
  --mt-surface: #FFFFFF;
  --mt-raised: #F4F6F8;
  --mt-text: #15202B;
  --mt-text-secondary: #3A4652;
  --mt-text-muted: #586574;
  --mt-border: #DCE1E6;
  --mt-control-border: #7A8694;
  --mt-action: #1F45D6;
  --mt-action-text: #FFFFFF;
  --mt-selected: #E6ECFF;
  --mt-pass: #127A4B;
  --mt-fail: #D92D20;
  --mt-fail-text: #B42318;
  --mt-fail-tint: #FFF4F3;
  /* The Signal names that the shared file defines, pointed at Slate values. */
  --mt-rail: var(--mt-raised);
  --mt-brand: #15202B;
  --mt-brand-text: #FFFFFF;
  --mt-alert: var(--mt-fail);
  --mt-alert-text: var(--mt-fail-text);
  --mt-alert-surface: var(--mt-fail-tint);
  --mt-working: var(--mt-pass);
  --mt-accent: #6F86DE;
  --mt-font-body: "Archivo", ui-sans-serif, system-ui, "Segoe UI", Arial, sans-serif;
  --mt-font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --mt-radius-control: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--mt-canvas);
  color: var(--mt-text);
  font-family: var(--mt-font-body);
  font-size: 1rem;
  line-height: 1.55;
}

a { color: var(--mt-action); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--mt-action); outline-offset: 2px; }

code, kbd, samp, pre { font-family: var(--mt-font-mono); font-size: .875em; }

/* Headings are semibold and modest in size, as in the portal; page titles use its slightly narrow width. */
h1, h2, h3 { line-height: 1.2; font-weight: 600; margin: 0; }
h1 { font-size: clamp(1.75rem, 3.6vw, 2.5rem); font-stretch: 90%; letter-spacing: -.01em; }
h2 { font-size: clamp(1.375rem, 2.4vw, 1.75rem); }
h3 { font-size: 1.0625rem; }
p, figure { margin: 0; }

.wrap { width: min(72rem, 100% - 2rem); margin-inline: auto; }
.muted { color: var(--mt-text-muted); }
.small { font-size: .875rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: var(--mt-space-4); top: var(--mt-space-4); z-index: 10; background: var(--mt-surface); padding: var(--mt-space-2) var(--mt-space-3); }

/* Header: a white bar like the portal's side menu. The wrapper is only a grouping element now. */
.site-header { background: var(--mt-surface); border-bottom: 1px solid var(--mt-border); }
.site-header .wrap { display: flex; align-items: center; gap: var(--mt-space-5); min-height: 3.5rem; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: var(--mt-space-2); color: var(--mt-text); text-decoration: none; font-weight: 700; font-size: 1.0625rem; }
/* The shipped mark is white for dark headers; invert it for the white bar, as the portal menu does. */
.brand img { width: 1.75rem; height: 1.75rem; filter: invert(1); }
.site-nav { display: flex; gap: var(--mt-space-2); margin-left: auto; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--mt-text); text-decoration: none; padding: var(--mt-space-1) var(--mt-space-3); border-radius: var(--mt-radius-control); font-weight: 500; }
.site-nav a:hover { background: var(--mt-raised); }
/* The current page gets the portal's selected-item tint. */
.site-nav a[aria-current="page"] { background: var(--mt-selected); color: var(--mt-action); }
.site-nav .nav-cta { border: 1px solid var(--mt-action); color: var(--mt-action); font-weight: 600; }

/* Buttons: primary is cobalt, as in the portal. */
.button { display: inline-block; border-radius: var(--mt-radius-control); padding: .625rem 1.125rem; text-decoration: none; border: 1px solid var(--mt-action); line-height: 1.3; font: inherit; font-weight: 600; cursor: pointer; }
.button-primary { background: var(--mt-action); color: var(--mt-action-text); }

/* Opening: the claim on the left, an optional checker on the right, then the Map page across the width. */
.hero { display: grid; gap: var(--mt-space-6); padding-block: var(--mt-space-7) var(--mt-space-6); align-items: end; }
@media (min-width: 60rem) { .hero { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--mt-space-7); } }
.hero-sub { font-size: 1.125rem; color: var(--mt-text-secondary); margin-top: var(--mt-space-4); max-width: 38rem; }
.hero-cta { margin-top: var(--mt-space-5); display: flex; flex-wrap: wrap; align-items: center; gap: var(--mt-space-3) var(--mt-space-4); }
.hero-cta span { color: var(--mt-text-muted); }
.hero-check { display: grid; gap: var(--mt-space-2); background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-radius-panel); padding: var(--mt-space-5); }
.hero-check label { font-weight: 600; }
.hero-check p { font-size: .875rem; color: var(--mt-text-muted); }

/* Form fields */
.field { display: grid; gap: var(--mt-space-2); max-width: 36rem; }
.field label { font-weight: 600; }
.field-row { display: flex; gap: var(--mt-space-2); flex-wrap: wrap; }
.field-row input { flex: 1 1 12rem; font: inherit; font-family: var(--mt-font-mono); padding: .625rem .75rem; border: 1px solid var(--mt-control-border); border-radius: var(--mt-radius-control); background: var(--mt-surface); color: var(--mt-text); min-width: 0; }
.field-row input[type="number"] { flex: 0 0 7rem; }

/* Sections of the argument. Space separates them; there are no rules or bands. */
.beat { padding-block: calc(var(--mt-space-7) * 1.5) 0; }
.beat-lede { font-size: 1.125rem; color: var(--mt-text-secondary); margin-top: var(--mt-space-3); max-width: 42rem; }
.beat h2 + p { margin-top: var(--mt-space-3); }
/* The steps inside the SPF feature sit closer to its heading than separate features do. */
.beat-step { padding-top: calc(var(--mt-space-7) * 1.1); }
.beat h3 { font-size: 1.25rem; }
.beat > p { max-width: 46rem; }
.beat > p + p { margin-top: var(--mt-space-3); }

/* Problem: the ten-lookup budget, drawn like the portal's lookup meter. Each service is a pale blue block;
   the one that goes past the limit is drawn the way the portal draws a failing sender. */
.meter-figure { margin-top: calc(var(--mt-space-7) + var(--mt-space-4)); }
.meter { --gap: 4px; position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
.seg { grid-column: span var(--n); background: var(--mt-selected); color: var(--mt-text); border: 1px solid var(--mt-action); min-height: 5rem; padding: var(--mt-space-2); display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; font-size: .8125rem; font-weight: 600; line-height: 1.2; overflow: hidden; border-radius: var(--mt-radius-control); }
.seg b { display: block; font-family: var(--mt-font-mono); font-size: 1.25rem; line-height: 1; margin-bottom: var(--mt-space-1); color: var(--mt-action); }
/* How many of the twelve columns (or, on a phone, rows) a service covers: one per lookup.
   The grid is the ten-lookup limit plus two, and src/_data/examples.js checks the data fits. */
.span-1 { --n: 1; } .span-2 { --n: 2; } .span-3 { --n: 3; } .span-4 { --n: 4; } .span-5 { --n: 5; }
.span-6 { --n: 6; } .span-7 { --n: 7; } .span-8 { --n: 8; } .span-9 { --n: 9; } .span-10 { --n: 10; }
.seg-over { background: var(--mt-fail-tint); color: var(--mt-fail-text); border: 1px dashed var(--mt-fail); }
.seg-over b { color: var(--mt-fail-text); }
/* The limit line sits after the tenth of twelve columns. */
.limit { position: absolute; top: -1.75rem; bottom: -.5rem; left: calc((100% - 11 * var(--gap)) * 10 / 12 + 9.5 * var(--gap)); border-left: 2px solid var(--mt-text); padding-left: var(--mt-space-2); font-size: .8125rem; font-weight: 700; white-space: nowrap; }
.meter-figure figcaption { margin-top: var(--mt-space-4); max-width: 42rem; }
/* On a phone the budget runs downwards: one row per lookup, so every name fits. */
@media (max-width: 40rem) {
  .meter { --row: 1.75rem; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(12, var(--row)); }
  .seg { grid-column: auto; grid-row: span var(--n); min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; gap: var(--mt-space-2); padding-block: 0; }
  .seg b { font-size: 1rem; margin: 0; }
  /* The line sits after the tenth row; its label drops into the empty twelfth row so it never covers a service. */
  .limit { top: calc(10 * var(--row) + 9.5 * var(--gap)); bottom: auto; left: 0; right: 0; border-left: 0; border-top: 2px solid var(--mt-text); padding: calc(var(--row) + 2 * var(--gap)) 0 0; text-align: right; }
  .limit::before { content: "↑ "; }
}
figcaption { font-size: .875rem; color: var(--mt-text-muted); margin-top: var(--mt-space-3); }

/* Fix: the explanation beside the record swap, then a real screen across the page. */
.fix { display: grid; gap: var(--mt-space-6); }
@media (min-width: 60rem) {
  .fix { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--mt-space-6) var(--mt-space-7); align-items: start; }
  .fix-screen { grid-column: 1 / -1; }
}
.fix-text > * + * { margin-top: var(--mt-space-4); }
.fix-text h3 + p { margin-top: var(--mt-space-4); }

/* Record panels are the portal's code boxes: a raised fill with the record in monospace. */
.console { background: var(--mt-raised); color: var(--mt-text); border: 1px solid var(--mt-border); border-radius: var(--mt-radius-panel); overflow: hidden; }
.console-bar { padding: var(--mt-space-2) var(--mt-space-4); border-bottom: 1px solid var(--mt-border); background: var(--mt-surface); font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--mt-text-muted); }
.console pre { margin: 0; padding: var(--mt-space-4); line-height: 1.65; font-size: .8125rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.console .dim { color: var(--mt-text-muted); }
.console .bad { color: var(--mt-fail-text); }
.console .good { color: var(--mt-pass); }

/* Portal screenshots, captured by scripts/capture-screens.mjs. src/_data/screens.json gives their
   sizes, so the page reserves their space before they load. */
.screen-shot { display: block; width: 100%; height: auto; border: 1px solid var(--mt-border); border-radius: var(--mt-radius-panel); background: var(--mt-surface); }
.hero-screen { padding-bottom: 0; }

/* Why: the comparison across the page, then a note on version history. */
.why-grid { margin-top: var(--mt-space-6); }
.why-evidence { margin-top: var(--mt-space-6); max-width: 46rem; }
.price-compare { margin-top: calc(var(--mt-space-7) * 1.25); font-size: 1.25rem; line-height: 1.45; max-width: 46rem; }

/* Tables: uppercase captions, 1px row lines, as in the portal. */
.table-wrap { overflow-x: auto; border: 1px solid var(--mt-border); border-radius: var(--mt-radius-panel); background: var(--mt-surface); }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; }
th, td { text-align: left; padding: var(--mt-space-3) var(--mt-space-4); border-bottom: 1px solid var(--mt-border); vertical-align: top; }
thead th { font-weight: 600; background: var(--mt-raised); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--mt-text-muted); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.compare tbody th { width: 34%; }
.compare td { color: var(--mt-text-muted); }
.compare td:last-child { color: var(--mt-text); font-weight: 600; }
.compare thead th:last-child { color: var(--mt-action); }
.plans thead th { font-size: .875rem; }
.plans tbody th { width: 22%; color: var(--mt-text-muted); font-weight: 600; }
.plans td.price { font-size: 1.25rem; font-weight: 600; }
/* Approximate dollar and euro amounts under a pound price: information only, never the charge. */
.fx { display: block; font-size: .875rem; font-weight: 400; color: var(--mt-text-muted); }
.close-fx { font-weight: 600; }

/* Closing: one white panel. */
.close-band { margin-top: calc(var(--mt-space-7) * 1.5); }
.close { display: grid; gap: var(--mt-space-5); padding: var(--mt-space-6); align-items: end; background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-radius-panel); }
@media (min-width: 60rem) { .close { grid-template-columns: minmax(0, 2fr) auto; gap: var(--mt-space-7); } }
.close p { margin-top: var(--mt-space-3); max-width: 40rem; color: var(--mt-text-secondary); }
.close-actions { display: flex; flex-wrap: wrap; gap: var(--mt-space-3) var(--mt-space-5); align-items: center; }
.close .close-fx { color: var(--mt-text); }

/* Inner pages: the title sits straight on the page. */
.page-head { padding-block: var(--mt-space-6) var(--mt-space-2); }
.page-head p { margin-top: var(--mt-space-3); max-width: 40rem; font-size: 1.0625rem; color: var(--mt-text-secondary); }
.page-head .hero-check p { font-size: .875rem; margin-top: 0; }
.page-body { padding-block: var(--mt-space-6) var(--mt-space-7); display: grid; gap: var(--mt-space-6); }
.page-body h2 { font-size: 1.25rem; }
.two-col { display: grid; gap: var(--mt-space-6); }
@media (min-width: 60rem) { .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--mt-space-7); } }
.two-col > div > * + * { margin-top: var(--mt-space-3); }

/* Billing period switch on the pricing page: the portal's segmented control. */
.toggle { display: inline-flex; border: 1px solid var(--mt-control-border); border-radius: var(--mt-radius-control); overflow: hidden; }
.toggle button { font: inherit; border: 0; background: var(--mt-surface); color: var(--mt-text); padding: var(--mt-space-2) var(--mt-space-4); cursor: pointer; }
.toggle button[aria-pressed="true"] { background: var(--mt-text); color: var(--mt-surface); font-weight: 600; }

/* Checker results (home page, below the band, and the checker page). */
.result { display: grid; gap: var(--mt-space-4); padding-top: var(--mt-space-6); }
.result:empty { display: none; }
.result h3 { margin-top: var(--mt-space-2); }
.verdict { border-left: 4px solid var(--mt-working); padding: var(--mt-space-2) var(--mt-space-4); max-width: 46rem; }
.verdict-bad { border-left-color: var(--mt-alert); }
.verdict-bad strong { color: var(--mt-alert-text); }
.tree { list-style: none; margin: 0; padding: 0; font-family: var(--mt-font-mono); font-size: .8125rem; }
.tree ul { list-style: none; margin: 0 0 0 .375rem; padding-left: 1.25rem; border-left: 1px solid var(--mt-border); }
.tree li { padding-block: .1875rem; }
.tree .cost { color: var(--mt-text-muted); }
.tree .warn { color: var(--mt-alert-text); }

/* Footer: one line of links on a white bar. */
.site-footer { margin-top: var(--mt-space-7); padding-block: var(--mt-space-5); font-size: .875rem; color: var(--mt-text-muted); background: var(--mt-surface); border-top: 1px solid var(--mt-border); }
.footer-line { display: flex; flex-wrap: wrap; gap: var(--mt-space-2) var(--mt-space-5); }
.footer-line span { font-weight: 700; color: var(--mt-text); }
.footer-legal { margin-top: var(--mt-space-3); font-size: .8125rem; }

@media (max-width: 40rem) {
  .site-nav { gap: var(--mt-space-1); margin-left: 0; width: 100%; padding-bottom: var(--mt-space-3); font-size: .9375rem; }
  .close { padding: var(--mt-space-5); }
  th, td { padding: var(--mt-space-2) var(--mt-space-3); }
}

/* Pricing page spacing (the prototype used inline styles, which the security policy blocks). */
.plans-wrap { margin-top: var(--mt-space-3); }
.currency-note { margin-top: var(--mt-space-3); max-width: 52rem; }
.two-col p + p { margin-top: var(--mt-space-3); }

/* SPF checker page (#262). */
.checker-form { margin-top: var(--mt-space-5); max-width: 36rem; }
.result-heading { font-size: 1.25rem; }
.checker-cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--mt-space-3); max-width: 46rem; }

/* Help articles, contact and security pages (#263). */
.crumb { margin: 0 0 var(--mt-space-2); font-size: .875rem; }
.help-layout { display: grid; gap: var(--mt-space-6); }
@media (min-width: 60rem) { .help-layout { grid-template-columns: minmax(0, 44rem) minmax(0, 16rem); justify-content: space-between; gap: var(--mt-space-7); } }
.help-nav h2 { font-size: 1rem; margin-bottom: var(--mt-space-3); }
.help-nav ul { list-style: none; margin: 0 0 var(--mt-space-5); padding: 0; display: grid; gap: var(--mt-space-2); }
.help-nav a[aria-current="page"] { font-weight: 600; color: var(--mt-text); text-decoration: none; }
.help-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--mt-space-5); max-width: 46rem; }
.help-list h2 { font-size: 1.125rem; }
.help-list p { margin-top: var(--mt-space-1); color: var(--mt-text-muted); }

/* Long-form text from Markdown. */
.prose > * + * { margin-top: var(--mt-space-4); }
.prose h2 { font-size: 1.25rem; margin-top: var(--mt-space-6); }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: var(--mt-space-2); }
.prose pre { background: var(--mt-raised); border: 1px solid var(--mt-border); border-radius: var(--mt-radius-control); padding: var(--mt-space-3); white-space: pre-wrap; overflow-wrap: anywhere; }
.prose code { font-size: .875em; }
.prose :not(pre) > code { background: var(--mt-raised); border-radius: var(--mt-radius-control); padding: 0 .25em; }

.contact-address { font-size: 1.25rem; font-weight: 600; }
.plain { padding-left: 1.25rem; display: grid; gap: var(--mt-space-2); }
.two-col h2 + p { margin-top: var(--mt-space-3); }
