/* ============ TOKENS & BASE ============
   Upstorey brand v1.0 — Poppins + IBM Plex Mono.
   Grounds: Paper / Stone. Red is an accent only (max 10% of a surface).
   No large black fields: the single dark surface is warm Clay.
   ======================================== */
:root {
  --bg: #f5f2ed;          /* Paper */
  --surface: #ffffff;
  --stone: #eae5de;       /* Stone */
  --stone-2: #dfd8ce;
  --ink: #201d1b;
  --muted: #5e574f;
  --faint: #8c8781;
  --red: #d63536;
  --red-dark: #b5322f;
  --line: #e4ded4;
  --line-2: #efeae2;
  --clay: #3e3833;        /* warm dark, footer only */
  --sans: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
  --pad: clamp(20px, 4vw, 32px);
  --nav-h: 76px;
  --shadow: 0 1px 2px rgba(62, 56, 51, .04), 0 18px 40px -24px rgba(62, 56, 51, .30);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  font-weight: 300;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.62;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; border-radius: 2px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 var(--pad); }

.skip { position: absolute; left: -9999px; background: var(--red); color: #fff; padding: 12px 20px; z-index: 100; }
.skip:focus { left: 12px; top: 12px; }

/* ============ TYPE ============ */
.display {
  font-weight: 500;
  font-size: clamp(2.1rem, 4.6vw, 3.7rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
  text-wrap: balance;
  overflow-wrap: break-word;
}
.display em { font-style: normal; color: var(--red); }

.display-alt {
  font-weight: 500;
  font-size: clamp(1.75rem, 3.2vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.eyebrow {
  font-family: var(--mono);
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* the brand device: a 45° arrow-cut square */
.eyebrow::before {
  content: "";
  width: 9px; height: 9px; flex: none;
  background: var(--red);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.lede { color: var(--muted); font-size: 1.05rem; max-width: 48ch; text-wrap: pretty; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 500;
  font-size: 0.94rem;
  padding: 14px 26px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: background .2s, border-color .2s, color .2s, transform .18s, box-shadow .2s;
}
.btn-red { background: var(--red); color: #fff; box-shadow: 0 10px 22px -14px rgba(214, 53, 54, .9); }
.btn-red:hover { background: var(--red-dark); transform: translateY(-2px); }
.btn-ghost { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn-ghost:hover { border-color: var(--ink); transform: translateY(-2px); }
.btn-lg { padding: 17px 32px; font-size: 1rem; }
.arrow { transition: transform .2s; }
.btn:hover .arrow, .text-link:hover .arrow { transform: translate(3px, -3px); }

.text-link {
  color: var(--red);
  font-weight: 500;
  font-size: 0.94rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ============ NAV ============ */
.nav-wrap {
  position: sticky; top: 0; z-index: 50;
  /* blended into the page at rest; only picks up a surface once you scroll */
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background .25s, border-color .25s, backdrop-filter .25s;
}
.nav-wrap.scrolled {
  background: rgba(245, 242, 237, .9);
  backdrop-filter: blur(14px);
  border-color: var(--line);
}
.nav { display: flex; align-items: center; gap: clamp(16px, 3vw, 40px); height: var(--nav-h); }
.brand img { height: 34px; width: auto; }
.nav-links { display: flex; gap: clamp(16px, 2.4vw, 32px); margin-left: auto; }
.nav-links a {
  font-size: 0.92rem; font-weight: 400; color: var(--ink);
  position: relative; padding-block: 6px;
}
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 1.5px; width: 100%;
  background: var(--red); transform: scaleX(0); transform-origin: left; transition: transform .22s;
}
.nav-links a:hover::after { transform: scaleX(1); }
.nav-cta { padding: 11px 20px; font-size: .88rem; }
.nav-toggle { display: none; }

/* ============ HERO ============ */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .95fr);
  gap: 56px;
  align-items: center;
}
.hero-copy {
  align-self: center;
  padding-block: clamp(32px, 5vw, 64px) clamp(56px, 7vw, 92px);
}
.hero-copy .display { margin-bottom: 24px; }
.hero-copy .lede { margin-bottom: 34px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

/* the photo starts at the very top of the page, running under the nav,
   and bleeds off the right edge of the viewport */
/* starts at the top of the page, under the nav; right edge lines up with the container */
.hero-visual {
  position: relative;
  align-self: start;
  margin-top: calc(-1 * var(--nav-h));
}
/* natural aspect ratio: the photo is never cropped or zoomed */
.hero-img {
  width: 100%; height: auto;
  /* 45° corner crop, the brand device */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 64px 100%, 0 calc(100% - 64px));
}
.mini-chart { width: 100%; height: 34px; margin-top: 8px; }

/* ============ SERVICES ============ */
.platform { background: var(--stone); padding: clamp(64px, 8vw, 100px) 0; }
.platform-grid { display: grid; grid-template-columns: .82fr 1.6fr; gap: clamp(36px, 5vw, 64px); align-items: start; }
.platform-copy { position: sticky; top: 108px; }
.platform-copy p { color: var(--muted); margin: 20px 0 24px; font-size: .98rem; max-width: 40ch; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feature-card {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 26px 22px 28px;
  position: relative;
  transition: transform .22s, box-shadow .22s;
}
.feature-card::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--red);
  transition: width .35s cubic-bezier(.22, 1, .36, 1);
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.feature-card:hover::after { width: 40%; }
.f-icon { width: 28px; height: 28px; color: var(--red); margin-bottom: 36px; }
.feature-card h3 { font-size: 1rem; font-weight: 500; letter-spacing: -.02em; margin-bottom: 9px; }
.feature-card p { color: var(--muted); font-size: .86rem; line-height: 1.6; }

/* ============ RESULTS ============ */
.results { padding-block: clamp(64px, 8vw, 100px); }
.stats-band {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: clamp(30px, 4vw, 44px) 24px;
}
.stat { text-align: center; padding: 6px 18px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat-big {
  font-size: clamp(2rem, 3.4vw, 2.9rem);
  font-weight: 500; letter-spacing: -.04em; line-height: 1.1; margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: .84rem; color: var(--muted); }

/* ============ WORKFLOW ============ */
.workflow { padding-bottom: clamp(70px, 9vw, 110px); }
.workflow-head { max-width: 760px; margin-bottom: clamp(44px, 6vw, 72px); }
.workflow-head .display { margin-bottom: 18px; }

/* one continuous dotted spine; the icons sit on top of it */
.steps { display: flex; flex-direction: column; position: relative; }
.steps::before {
  content: ""; position: absolute; left: 30.5px; top: 40px; bottom: 40px;
  border-left: 2px dotted var(--stone-2);
}
.step {
  display: grid; grid-template-columns: 62px 1fr 380px; gap: clamp(20px, 3vw, 40px);
  align-items: center; position: relative; padding: 32px 0;
}
.step-marker { position: relative; z-index: 1; }
.step-icon {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 24px -14px rgba(62, 56, 51, .3);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
  transition: color .2s, border-color .2s, transform .2s;
}
.step:hover .step-icon { color: var(--red); border-color: var(--red); transform: translateY(-2px); }
.step-icon svg { width: 24px; height: 24px; }

.step-num { font-family: var(--mono); color: var(--red); font-size: .78rem; letter-spacing: .12em; margin-bottom: 4px; }
.step-title { font-size: 1.4rem; font-weight: 500; letter-spacing: -.03em; margin-bottom: 12px; }
.step-list li { font-size: .89rem; color: var(--muted); padding-left: 18px; position: relative; margin-bottom: 5px; }
.step-list li::before {
  content: ""; position: absolute; left: 2px; top: .68em; width: 7px; height: 7px;
  background: var(--red); clip-path: polygon(0 0, 100% 0, 100% 100%);
}

/* --- mini preview cards --- */
.mini-card {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.mini-title { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 16px; }

.mini-research { display: flex; align-items: center; gap: 20px; }
.mini-research svg { width: 80px; height: 80px; flex: none; }
.mini-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.mini-lines span { height: 8px; border-radius: 4px; background: var(--stone); display: block; }

.mini-tree { display: flex; flex-direction: column; gap: 12px; }
.tree-row { display: flex; gap: 10px; justify-content: center; }
.tree-box { flex: 1; height: 26px; border-radius: 4px; background: var(--stone); }
.tree-box.wide { flex: 0 0 46%; }
.tree-box.red { background: var(--red); }

.mini-seq { display: flex; flex-direction: column; gap: 13px; }
.seq-row { display: flex; align-items: center; gap: 12px; }
.seq-ico { width: 18px; height: 18px; border-radius: 4px; border: 1.5px solid var(--stone-2); flex: none; }
.seq-bar { height: 7px; border-radius: 4px; background: var(--stone); }
.seq-dot { width: 8px; height: 8px; background: var(--red); clip-path: polygon(0 0, 100% 0, 100% 100%); margin-left: auto; flex: none; }

.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px 8px; justify-items: center; }
.mini-cal span { width: 14px; height: 14px; border-radius: 3px; background: var(--stone); }
.mini-cal span.on { background: var(--red); }

.mini-pipe { display: flex; gap: 8px; }
.pipe-col { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.pipe-tag {
  width: 100%; text-align: center;
  font-family: var(--mono); font-size: .52rem; letter-spacing: .04em;
  color: var(--muted); background: var(--stone); border-radius: 3px; padding: 4px 2px;
}
.pipe-tag.won { background: var(--red); color: #fff; }
.pipe-val { font-size: .9rem; font-weight: 500; font-variant-numeric: tabular-nums; }

.mini-perf { display: flex; gap: 8px; margin-bottom: 14px; }
.perf-tile { flex: 1; border: 1px solid var(--line-2); border-radius: 6px; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.perf-k { font-family: var(--mono); font-size: .56rem; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.perf-v { font-size: 1rem; font-weight: 500; letter-spacing: -.02em; }
.perf-d { font-family: var(--mono); font-size: .58rem; color: var(--red); }

/* ============ BAND ============ */
.band {
  background: var(--stone);
  max-width: 1180px; margin: 0 auto clamp(70px, 9vw, 110px);
  border-radius: 14px;
  padding: clamp(48px, 6vw, 72px) 0 clamp(44px, 5vw, 64px);
}
.band .container { padding: 0 clamp(24px, 4vw, 56px); }
.band-sub { color: var(--muted); margin: 14px 0 clamp(36px, 5vw, 52px); font-size: .98rem; }
.band-items { display: grid; grid-template-columns: repeat(6, 1fr); gap: 24px; position: relative; }
.band-items::before {
  content: ""; position: absolute; top: 26px; left: 8%; right: 8%;
  border-top: 2px dotted var(--stone-2);
}
.band-items li { text-align: center; position: relative; }
.band-icon {
  width: 54px; height: 54px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line-2);
  color: var(--red);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  transition: transform .2s;
}
.band-items li:hover .band-icon { transform: translateY(-3px); }
.band-icon svg { width: 24px; height: 24px; }
.band-items p { font-size: .82rem; font-weight: 400; }

/* ============ CONTACT ============ */
.contact {
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 5vw, 72px);
  align-items: start;
  padding-block: clamp(64px, 8vw, 96px) clamp(56px, 7vw, 88px);
}
.contact-copy .display { margin-bottom: 18px; }
.contact-alt { margin-top: 22px; font-size: .94rem; color: var(--muted); }
.contact-alt a { color: var(--red); }
.contact-alt a:hover { text-decoration: underline; }

.form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: clamp(24px, 3vw, 34px);
  display: grid; gap: 16px;
  box-shadow: var(--shadow);
}
.field { display: grid; gap: 7px; }
.field > span {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint);
}
.field input, .field textarea {
  font: inherit; font-size: .95rem; color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 14px;
  width: 100%;
  transition: border-color .18s, background .18s;
}
.field textarea { resize: vertical; min-height: 96px; }
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--red); background: var(--surface);
}
.form .btn { margin-top: 6px; }
.form .btn:disabled { opacity: .6; cursor: progress; transform: none; }
.form-note { font-size: .78rem; color: var(--faint); text-align: center; }
.form-status:empty { display: none; }
.form-status {
  font-size: .86rem; line-height: 1.5;
  padding: 12px 14px; border-radius: 4px;
  border-left: 3px solid currentColor;
}
.form-status.ok { color: var(--ink); background: var(--stone); border-color: var(--red); }
.form-status.err { color: var(--red-dark); background: rgba(214, 53, 54, .07); border-color: var(--red); }
.hp { position: absolute; left: -9999px; opacity: 0; }

/* ============ FOOTER ============ */

.footer { background: var(--clay); color: var(--stone-2); padding-top: clamp(44px, 5vw, 64px); }
.footer .brand img { height: 26px; }
.footer-bottom {
  display: flex; align-items: center; gap: 32px; flex-wrap: wrap;
  padding-bottom: 36px;
}
.footer-links { display: flex; gap: 26px; margin-left: auto; flex-wrap: wrap; }
.footer-links a { font-size: .88rem; color: rgba(234, 229, 222, .72); }
.footer-links a:hover { color: #fff; }
.copyright { font-size: .78rem; color: rgba(234, 229, 222, .45); width: 100%; border-top: 1px solid rgba(234, 229, 222, .15); padding-top: 22px; }

/* ============ MOTION ============ */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity .7s cubic-bezier(.22, 1, .36, 1), transform .7s cubic-bezier(.22, 1, .36, 1); }
.reveal.in { opacity: 1; transform: none; }
.feature-grid .reveal:nth-child(2), .steps .reveal:nth-child(2) { transition-delay: .07s; }
.feature-grid .reveal:nth-child(3) { transition-delay: .14s; }
.feature-grid .reveal:nth-child(4) { transition-delay: .21s; }
.feature-grid .reveal:nth-child(5) { transition-delay: .28s; }
.feature-grid .reveal:nth-child(6) { transition-delay: .35s; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .platform-grid { grid-template-columns: 1fr; gap: 40px; }
  .platform-copy { position: static; }
  .step { grid-template-columns: 56px 1fr; }
  .step-icon { width: 56px; height: 56px; }
  .steps::before { left: 27.5px; }
  .step-visual { grid-column: 2; max-width: 420px; }
  .band-items { grid-template-columns: repeat(3, 1fr); gap: 36px 24px; }
  .band-items::before { display: none; }
}

@media (max-width: 860px) {
  .nav-links, .nav-cta { display: none; }
  .nav-toggle {
    display: flex; flex-direction: column; gap: 5px; margin-left: auto;
    background: none; border: 0; cursor: pointer; padding: 10px;
  }
  .nav-toggle span { width: 22px; height: 1.5px; background: var(--ink); display: block; transition: transform .25s, opacity .2s; }
  body.menu-open .nav-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  body.menu-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.menu-open .nav-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
  body.menu-open .nav-links {
    display: flex; position: absolute; top: 76px; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    padding: 8px var(--pad) 22px;
    box-shadow: var(--shadow);
  }
  body.menu-open .nav-links a { display: block; padding: 13px 0; font-size: 1rem; border-bottom: 1px solid var(--line-2); }
  body.menu-open .nav-links a::after { display: none; }

  .hero { grid-template-columns: 1fr; gap: 0; min-height: 0; }
  .hero-copy { padding-block: clamp(28px, 5vw, 48px) clamp(32px, 5vw, 48px); order: 2; }
  .hero-visual { order: 1; margin-top: calc(-1 * var(--nav-h)); }
  .contact { grid-template-columns: 1fr; gap: 36px; }
  .stats-band { grid-template-columns: repeat(2, 1fr); gap: 24px 0; }
  .stat:nth-child(3) { border-left: 0; }
}

@media (max-width: 560px) {
  .hero-img { clip-path: polygon(0 0, 100% 0, 100% 100%, 40px 100%, 0 calc(100% - 40px)); }
  .step { gap: 18px; }
  .step-visual { grid-column: 1 / -1; max-width: none; }
  .stats-band { grid-template-columns: 1fr; }
  .stat + .stat { border-left: 0; border-top: 1px solid var(--line); padding-top: 22px; margin-top: 18px; }
  .band { border-radius: 0; }
  .band-items { grid-template-columns: repeat(2, 1fr); }
  .btn { width: 100%; }
  .hero-actions { width: 100%; }
  .footer-links { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
