/* Upstream Dynamics landing page. No web fonts, no images except our own
   inline SVG. Colours are tokens, redefined for dark mode below. The strict
   Content Security Policy blocks style attributes, so every SVG shape is
   styled from here through its class. */

:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-alt: #eaf1f5;
  --text: #13232f;
  --heading: #0a3a52;
  --muted: #4a5b68;
  --line: #d3dde4;
  --border: #758592; /* 3.7:1 on --surface: input edges stay visible (WCAG 1.4.11) */
  --brand: #0b4f6c;
  --brand-strong: #083c53;
  --brand-text: #ffffff;
  --brand-soft: #d7e8f0;
  --accent: #e0951f;
  --focus: #b35f00; /* 4:1 on --surface */
  --error: #b42318;
  --error-bg: #fdecea;
  --success: #1d6b3a;
  --success-bg: #e7f5ec;
  --shadow: 0 1px 2px rgb(10 40 60 / 0.06), 0 12px 32px rgb(10 40 60 / 0.10);

  /* Illustration */
  --art-sky-1: #dcecf4;
  --art-sky-2: #f6fafc;
  --art-sun: #f6c46a;
  --art-sun-halo: #f6c46a;
  --art-bar-out: #c9d5dd;
  --art-bar-in: #a9cadb;
  --art-curve: #0b4f6c;
  --art-curve-area: #0b4f6c;
  --art-sea-1: #2f7896;
  --art-sea-2: #123f55;
  --art-seabed: #0d3144;
  --art-wave: #8fc3d8;
  --art-land: #9fb08a;
  --art-frame: #22343f;
  --art-deck: #34495a;
  --art-module: #e9eef1;
  --art-module-alt: #e0951f;
  --art-window: #7a8d99;
  --art-pipe: #e0951f;
  --art-flame: #f08a24;
  --art-tank: #e9eef1;
  --art-tank-top: #c3ced5;
  --contour: #b9cfdb;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b131a;
    --surface: #121e27;
    --surface-alt: #10202a;
    --text: #e3eaef;
    --heading: #f2f6f9;
    --muted: #a3b3bf;
    --line: #253540;
    --border: #6c7d8a; /* 3.9:1 on --surface */
    --brand: #5bbde3;
    --brand-strong: #8ad0ec;
    --brand-text: #05202c;
    --brand-soft: #16384a;
    --accent: #f2a531;
    --focus: #ffb35c;
    --error: #ff8a80;
    --error-bg: #3a1714;
    --success: #7fd69b;
    --success-bg: #12301d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 12px 32px rgb(0 0 0 / 0.35);

    --art-sky-1: #0f2533;
    --art-sky-2: #18394b;
    --art-sun: #f2c26b;
    --art-sun-halo: #f2a531;
    --art-bar-out: #2a3c48;
    --art-bar-in: #22506a;
    --art-curve: #6fd0f2;
    --art-curve-area: #6fd0f2;
    --art-sea-1: #11475f;
    --art-sea-2: #071d29;
    --art-seabed: #04121a;
    --art-wave: #3f8eae;
    --art-land: #4d5e45;
    --art-frame: #c8d6df;
    --art-deck: #9fb2bf;
    --art-module: #2c4250;
    --art-module-alt: #d48a1a;
    --art-window: #8fb3c6;
    --art-pipe: #f2a531;
    --art-flame: #ffad42;
    --art-tank: #2c4250;
    --art-tank-top: #4a6272;
    --contour: #1e3a4a;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
}

@media (min-width: 40rem) {
  .wrap {
    padding: 0 1.5rem;
  }
}

a {
  color: var(--brand);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--brand-strong);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  color: var(--heading);
  line-height: 1.2;
  text-wrap: balance;
}

/* Header */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.6rem 0;
  color: var(--heading);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

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

.brand img {
  display: block;
}

/* Hero */

.hero {
  padding: 1.5rem 0 2.5rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}

.hero-grid {
  display: grid;
  gap: 2rem;
  align-items: center;
}

.hero-text {
  min-width: 0;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--heading);
  font-size: 0.85rem;
  font-weight: 600;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.85rem, 5.2vw, 3rem);
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 1.125rem;
  max-width: 36rem;
}

.hero-art {
  min-width: 0;
}

.art {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

@media (min-width: 56rem) {
  .hero {
    padding: 3.5rem 0 4rem;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: 3.5rem;
  }

  .lead {
    font-size: 1.2rem;
  }
}

/* Illustration shapes */

.sky-top { stop-color: var(--art-sky-1); }
.sky-bottom { stop-color: var(--art-sky-2); }
.sea-top { stop-color: var(--art-sea-1); }
.sea-bottom { stop-color: var(--art-sea-2); }

.sun { fill: var(--art-sun); opacity: 0.85; }
.sun-halo { fill: var(--art-sun-halo); opacity: 0.18; }
.bar-out { fill: var(--art-bar-out); }
.bar-in { fill: var(--art-bar-in); }
.curve-area { fill: var(--art-curve-area); opacity: 0.1; }

.curve {
  fill: none;
  stroke: var(--art-curve);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-curve 1.2s ease-out 0.2s backwards;
}

@keyframes draw-curve {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .curve {
    animation: none;
  }
}

.land { fill: var(--art-land); }
.seabed { fill: var(--art-seabed); opacity: 0.55; }
.veil { fill: var(--art-sea-2); opacity: 0.3; }
.wave,
.waterline {
  fill: none;
  stroke: var(--art-wave);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.7;
}
.waterline { opacity: 0.9; }

.pipe {
  fill: none;
  stroke: var(--art-pipe);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.frame path {
  fill: none;
  stroke: var(--art-frame);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crown,
.deck { fill: var(--art-deck); }
.module { fill: var(--art-module); stroke: var(--art-frame); stroke-width: 1.5; }
.module-alt { fill: var(--art-module-alt); }
.window { fill: none; stroke: var(--art-window); stroke-width: 2; stroke-dasharray: 5 4; }
.flame { fill: var(--art-flame); }
.tank { fill: var(--art-tank); stroke: var(--art-frame); stroke-width: 1.5; }
.tank-top { fill: var(--art-tank-top); stroke: var(--art-frame); stroke-width: 1.5; }

/* Sign-up card */

.signup-card {
  max-width: 34rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (min-width: 40rem) {
  .signup-card {
    padding: 1.5rem;
  }
}

.field {
  margin: 0 0 1rem;
}

label {
  display: block;
  font-weight: 600;
}

.hint {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input[type="email"],
input[type="text"] {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input[type="email"]:focus-visible,
input[type="text"]:focus-visible {
  border-color: var(--brand);
}

input[aria-invalid="true"] {
  border-color: var(--error);
  border-width: 2px;
}

.more {
  margin: 0 0 1rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.more summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 0;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.more summary::-webkit-details-marker {
  display: none;
}

.more summary::before {
  content: "";
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.more[open] summary::before {
  transform: rotate(45deg);
}

.more-body {
  padding: 0.25rem 0 0.25rem;
}

.more-body > .hint {
  margin-bottom: 0.9rem;
}

fieldset {
  margin: 0 0 1rem;
  padding: 0.6rem 1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

fieldset:has(input[aria-invalid="true"]) {
  border-color: var(--error);
}

legend {
  padding: 0 0.35rem;
  font-weight: 600;
}

label.check {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  font-weight: 400;
  cursor: pointer;
}

label.check input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  flex: none;
  accent-color: var(--brand);
}

/* The spam check runs invisibly: its container takes no space. */
.spam-check {
  margin: 0;
  padding: 0;
  border: 0;
}

.error {
  margin: 0.35rem 0 0;
  color: var(--error);
  font-weight: 600;
  font-size: 0.95rem;
}

.summary {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--error);
  border-radius: 0.5rem;
  background: var(--error-bg);
  color: var(--text);
}

.summary p,
.summary ul {
  margin: 0;
}

.summary ul {
  padding-left: 1.25rem;
}

button {
  min-height: 48px;
  min-width: 44px;
  padding: 0.65rem 1.5rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--brand);
  color: var(--brand-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

button:hover {
  background: var(--brand-strong);
}

button:disabled {
  opacity: 0.75;
  cursor: progress;
}

#signup-form button {
  width: 100%;
}

@media (min-width: 40rem) {
  #signup-form button {
    width: auto;
  }
}

.fine-print {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.status:empty {
  display: none;
}

.status {
  padding: 0.9rem 1rem;
  border-radius: 0.5rem;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 600;
}

.status p {
  margin: 0;
}

.status p + p {
  margin-top: 0.5rem;
  font-weight: 400;
}

.status a {
  color: inherit;
}

.unavailable {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface-alt);
}

/* What it does */

.features {
  padding: 3rem 0;
}

h2 {
  margin: 0 0 1.5rem;
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  letter-spacing: -0.01em;
}

.cards {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 64rem) {
  .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}

.card h3 {
  margin: 0.85rem 0 0.4rem;
  font-size: 1.1rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.975rem;
}

.icon {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0.55rem;
  border-radius: 0.75rem;
  background: var(--brand-soft);
  color: var(--brand);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Who it is for */

.audience {
  position: relative;
  overflow: hidden;
  padding: 3.5rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}

.contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--contour);
  stroke-width: 1.5;
}

.contours path {
  vector-effect: non-scaling-stroke;
}

.audience-inner {
  position: relative;
  max-width: 48rem;
  text-align: center;
}

.audience h2 {
  margin-bottom: 0.75rem;
}

.audience-text {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.trust {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-style: italic;
}

.trust::before,
.trust::after {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 2px;
  margin: 0 0.6rem 0.3rem;
  background: var(--accent);
  vertical-align: middle;
}

.cta-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 1.25rem;
  border: 2px solid var(--brand);
  border-radius: 0.5rem;
  font-weight: 700;
  text-decoration: none;
}

.cta-link:hover {
  background: var(--brand);
  color: var(--brand-text);
}

/* Footer */

.site-footer {
  padding: 2rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0.35rem 0;
}

.footer-grid {
  display: grid;
  gap: 1rem 3rem;
}

@media (min-width: 48rem) {
  .footer-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }
}

.privacy {
  max-width: 44rem;
}

.privacy strong {
  color: var(--text);
}

/* Pages the Worker renders (confirm, outbox) and the 404 page */

.server-page {
  max-width: 40rem;
  margin: 2.5rem auto;
  padding-top: 2rem;
  padding-bottom: 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

@media (max-width: 40rem) {
  .server-page {
    margin: 1.25rem 1rem;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
  }
}

.server-page h1 {
  font-size: clamp(1.5rem, 5vw, 2rem);
}

.server-page form {
  margin: 1.5rem 0 0.5rem;
}

.server-page .page-art {
  display: block;
  width: 6rem;
  height: auto;
  margin: 0 0 1rem;
}

.outbox-message {
  margin: 1.25rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--line);
}

.outbox-message h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.outbox-message pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--surface-alt);
  font-size: 0.875rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
