/* Alignment Integration
   Look: a measured engineering sheet. Cool paper, ink slate type, spruce green
   marks, hairline tick rules, monospace coordinates in the margin.
   Token record and editing rules live in design.md. */

/* ---------- tokens ---------- */

:root {
  /* colour. Contrast ratios against --paper are noted in design.md. */
  --paper:        #edefee;
  --panel:        #f6f7f7;
  --panel-deep:   #e3e7e7;
  --ink:          #101d26;
  --ink-muted:    #4a5a66;
  --mark:         #0b5a44;
  --mark-deep:    #08402f;
  --second:       #2f4e7a;
  --line:         #c3ccd1;
  --line-strong:  #75838c;

  /* type */
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --t-micro: 0.75rem;
  --t-label: 0.8125rem;
  --t-small: 0.9375rem;
  --t-body:  1.0625rem;
  --t-lead:  clamp(1.125rem, 0.98rem + 0.55vw, 1.3125rem);
  --t-h3:    clamp(1.125rem, 1.02rem + 0.4vw, 1.3125rem);
  --t-h2:    clamp(1.5rem, 1.24rem + 1.05vw, 2rem);
  --t-h1:    clamp(1.9375rem, 1.28rem + 2.9vw, 3.375rem);

  /* space, 4px base */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4rem;
  --s9: 6rem;

  --radius: 2px;
  --radius-pill: 999px;
  --hair: 1px;

  --gutter: clamp(1.25rem, 4vw, 3rem);
  --measure: 1100px;

  --fast: 140ms;
  --base: 240ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
  /* clip, not hidden. Hidden on html or body makes a scroll container and the
     sticky masthead stops sticking. */
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.65;
  font-weight: 400;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

/* the attribute wins over any display value set below */
[hidden] { display: none !important; }

img, svg { max-width: 100%; }

a { color: var(--mark); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--mark-deep); }

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

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: var(--s4);
  top: var(--s4);
  z-index: 20;
  padding: var(--s2) var(--s4);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--t-small);
  text-decoration: none;
  translate: 0 -400%;
  transition: translate var(--fast) var(--ease);
}
.skip:focus { translate: 0 0; }

/* ---------- masthead ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, white);
  border-bottom: var(--hair) solid var(--line);
  backdrop-filter: blur(6px);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3) var(--s5);
  padding-block: var(--s3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  color: var(--ink);
  text-decoration: none;
}

.brand-name {
  font-size: var(--t-small);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.mono-ink { stroke: var(--ink); }
.mono-mark { stroke: var(--mark); }

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s5);
  font-family: var(--mono);
  font-size: var(--t-label);
}

.nav a {
  position: relative;
  padding-block: var(--s1);
  color: var(--ink-muted);
  text-decoration: none;
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--mark);
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}

.nav a:hover { color: var(--ink); }
.nav a:hover::after,
.nav a[aria-current="true"]::after { opacity: 1; }
.nav a[aria-current="true"] { color: var(--ink); }

.nav-cta {
  padding-inline: var(--s3);
  border: var(--hair) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink) !important;
}
.nav-cta::after { display: none; }
.nav-cta:hover { background: var(--panel); }

/* ---------- section frame: the tick rule and the margin index ---------- */

.section {
  padding-block: clamp(2.5rem, 6vw, var(--s9));
  /* clears the sticky masthead, which is two rows tall on narrow screens */
  scroll-margin-top: 7.5rem;
}

.section + .section { position: relative; }

.section + .section::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 7px;
  background:
    linear-gradient(to bottom, var(--line) 0 var(--hair), transparent var(--hair)),
    repeating-linear-gradient(to right, var(--line-strong) 0 1px, transparent 1px 9px);
  background-repeat: no-repeat, no-repeat;
  background-size: 100% var(--hair), 100% 100%;
  background-position: 0 0, 0 2px;
  opacity: 0.75;
}

.index {
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 500;
  color: var(--mark);
  letter-spacing: 0.14em;
}

.eyebrow {
  margin-top: var(--s1);
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.section-head {
  display: grid;
  gap: var(--s2) var(--s5);
  margin-bottom: var(--s6);
}

.section-head h2 { font-size: var(--t-h2); }

.section-intro {
  margin-top: var(--s3);
  max-width: 62ch;
  color: var(--ink-muted);
  font-size: var(--t-small);
}

.h-quiet {
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

/* ---------- 01 hero ---------- */

.section-hero { padding-top: clamp(2rem, 5vw, var(--s8)); }

.hero {
  display: grid;
  gap: var(--s6);
  align-items: center;
}

.lede {
  margin-top: var(--s4);
  font-size: var(--t-h1);
  letter-spacing: -0.022em;
  max-width: 22ch;
}

.claim {
  margin-top: var(--s5);
  max-width: 54ch;
  font-size: var(--t-lead);
  color: var(--ink-muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-top: var(--s6);
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.15rem;
  border: var(--hair) solid transparent;
  border-radius: var(--radius);
  font-size: var(--t-small);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--sans);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), translate var(--fast) var(--ease);
}

.btn-primary {
  background: var(--mark);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--mark-deep);
  color: #ffffff;
  translate: 0 -1px;
}

.btn-quiet {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-quiet:hover {
  background: var(--panel);
  color: var(--ink);
  translate: 0 -1px;
}

/* the one data-texture element on the page */

.plot {
  margin: 0;
  padding: var(--s4);
  background: var(--panel);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius);
}

.plot svg { display: block; width: 100%; height: auto; }

.grid-line { stroke: var(--line); stroke-width: 1; opacity: 0.7; }
.plot-frame { stroke: var(--line-strong); stroke-width: 1; opacity: 0.5; }

.trace-raw {
  stroke: var(--second);
  stroke-width: 1.6;
  stroke-linejoin: round;
  opacity: 0.85;
}

.plot-split {
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.trace-clean {
  stroke: var(--mark);
  stroke-width: 2.4;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.nodes rect { fill: var(--mark); }

.plot-label,
.plot-caption {
  font-family: var(--mono);
  font-size: 11px;
  fill: var(--ink-muted);
  letter-spacing: 0.06em;
}
.plot-caption { fill: var(--line-strong); }

/* ---------- 01 steps and audience ---------- */

.steps {
  display: grid;
  gap: var(--s5);
  margin-top: clamp(2.5rem, 6vw, var(--s8));
  border-top: var(--hair) solid var(--line);
  padding-top: var(--s6);
}

.step-no {
  font-family: var(--mono);
  font-size: var(--t-label);
  color: var(--mark);
  letter-spacing: 0.08em;
}

.step h3 {
  margin-top: var(--s2);
  font-size: var(--t-h3);
}

.step p:last-child {
  margin-top: var(--s3);
  color: var(--ink-muted);
  font-size: var(--t-small);
  max-width: 46ch;
}

.audience {
  margin-top: var(--s7);
  padding-top: var(--s5);
  border-top: var(--hair) solid var(--line);
}

.audience p {
  margin-top: var(--s3);
  max-width: 68ch;
  font-size: var(--t-small);
  color: var(--ink-muted);
}

/* ---------- 02 demo tiles ---------- */

.tiles {
  display: grid;
  gap: var(--s4);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--s5) var(--s5) var(--s4);
  background: var(--panel);
  border: var(--hair) solid var(--line-strong);
  border-radius: var(--radius);
}

/* the in development band: hatched, so the state does not rely on colour */
.tile::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 8px;
  background: repeating-linear-gradient(45deg, var(--line-strong) 0 1.5px, transparent 1.5px 7px);
  opacity: 0.8;
}

.tile-market {
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.tile-name {
  margin-top: var(--s2);
  font-size: var(--t-h3);
}

.tile-body {
  margin-top: var(--s3);
  font-size: var(--t-small);
  color: var(--ink-muted);
}

.tile-state {
  margin-top: var(--s5);
  padding-top: var(--s3);
  border-top: var(--hair) solid var(--line);
  font-family: var(--mono);
  font-size: var(--t-label);
  color: var(--ink-muted);
}

.tile-engine { background: var(--panel-deep); }
.tile-engine .tile-market { color: var(--mark); }

/* live state, applied by main.js when a demo URL exists */

.tile-live {
  padding: 0;
  border-color: var(--line-strong);
  transition: border-color var(--fast) var(--ease), translate var(--fast) var(--ease);
}

.tile-live::before {
  background: var(--mark);
  opacity: 1;
  height: 3px;
}

.tile-live > a.tile-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--s5) var(--s5) var(--s4);
  color: inherit;
  text-decoration: none;
}

.tile-live:hover { border-color: var(--ink); translate: 0 -2px; }
.tile-live:hover .tile-name { color: var(--mark-deep); }
.tile-live .tile-state { color: var(--mark); }
.tile-live:focus-within { border-color: var(--ink); }

/* ---------- 03 the three ideas ---------- */

.ideas {
  display: grid;
  gap: 0;
  border-top: var(--hair) solid var(--line);
}

.idea {
  display: grid;
  gap: var(--s2) var(--s5);
  padding-block: var(--s5);
  border-bottom: var(--hair) solid var(--line);
}

.idea-no {
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.14em;
  color: var(--mark);
}

.idea h3 { font-size: var(--t-h3); }

.idea p {
  margin-top: var(--s3);
  max-width: 64ch;
  font-size: var(--t-small);
  color: var(--ink-muted);
}

/* ---------- 04 what is built ---------- */

.facts {
  display: grid;
  gap: var(--s4);
  max-width: 68ch;
}

.facts li {
  position: relative;
  padding-left: var(--s5);
  font-size: var(--t-small);
  color: var(--ink-muted);
}

.facts li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 10px;
  height: 1px;
  background: var(--mark);
}

/* ---------- 05 contact ---------- */

.form-shell {
  padding: clamp(1.25rem, 3vw, var(--s6));
  background: var(--panel);
  border: var(--hair) solid var(--line);
  border-radius: var(--radius);
}

.form {
  display: grid;
  gap: var(--s5);
  grid-template-columns: 1fr;
}

.field { display: grid; gap: var(--s2); }

.field label {
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: 0.06em;
  color: var(--ink);
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--paper);
  border: var(--hair) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.5;
}

.field textarea { resize: vertical; min-height: 7rem; }

.field input:hover,
.field textarea:hover { border-color: var(--ink-muted); }

.field input:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  border-color: var(--ink);
}

.hint {
  font-size: var(--t-micro);
  color: var(--ink-muted);
}

.field-submit {
  gap: var(--s3);
  justify-items: start;
}

.form-error {
  font-family: var(--mono);
  font-size: var(--t-label);
  color: var(--second);
}

.offscreen-field input { width: 1px; }

.offscreen-field {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.confirm {
  display: grid;
  gap: var(--s2);
  padding: var(--s5);
  background: var(--paper);
  border: var(--hair) solid var(--mark);
  border-left-width: 3px;
  border-radius: var(--radius);
}

.confirm-mark { line-height: 0; }
.confirm-mark svg { stroke: var(--mark); }
.confirm h3 { font-size: var(--t-h3); }
.confirm p { font-size: var(--t-small); color: var(--ink-muted); }

/* ---------- footer ---------- */

.footer {
  border-top: var(--hair) solid var(--line-strong);
  padding-block: var(--s6);
  background: var(--panel);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3) var(--s5);
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  font-size: var(--t-small);
  font-weight: 600;
}

.footer-meta,
.footer-top {
  font-family: var(--mono);
  font-size: var(--t-label);
  color: var(--ink-muted);
}

.footer-top a { color: var(--ink-muted); }
.footer-top a:hover { color: var(--mark-deep); }

/* ---------- wider viewports ---------- */

@media (min-width: 40rem) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: var(--s5); }
  .form { grid-template-columns: 1fr 1fr; column-gap: var(--s5); }
  .field-wide, .field-submit { grid-column: 1 / -1; }
}

@media (min-width: 48rem) {
  .section-head { grid-template-columns: 4rem 1fr; }
  .idea { grid-template-columns: 4rem 1fr; }
  .steps { padding-top: var(--s7); }
}

@media (min-width: 60rem) {
  .hero {
    grid-template-columns: 1.08fr 0.92fr;
    gap: var(--s7);
  }
  .section { scroll-margin-top: 5.5rem; }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  .plot-ready .trace-raw,
  .plot-ready .trace-clean {
    stroke-dasharray: var(--len, 1200);
    stroke-dashoffset: var(--len, 1200);
    animation: draw 900ms var(--ease) forwards;
  }

  .plot-ready .trace-clean { animation-delay: 220ms; }

  .plot-ready .nodes rect {
    opacity: 0;
    animation: appear var(--base) var(--ease) forwards;
    animation-delay: 900ms;
  }

  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes appear { to { opacity: 1; } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@media print {
  .masthead, .nav, .skip, .footer-top { display: none; }
  body { background: #ffffff; }
  .plot, .form-shell, .tile { background: #ffffff; }
}
