/* FUNCTION AT SCALE, v4 layer. Loads after styles.css. Header fix, wider layouts, new components. */

/* Header: solid paper, same as the page. Grain sits above everything so header and page share one surface. */
.site-head,
.site-head.scrolled {
  background: var(--paper);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
body::before { z-index: 90; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); margin-right: 10px; vertical-align: 2px;
  box-shadow: 0 0 0 0 rgba(226, 35, 26, .45);
  animation: livepulse 2.4s var(--ease) infinite;
}
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(226,35,26,.45); } 70% { box-shadow: 0 0 0 9px rgba(226,35,26,0); } 100% { box-shadow: 0 0 0 0 rgba(226,35,26,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Hero */
.hero h1 { max-width: none; font-size: clamp(2.9rem, 5.4vw, 6.25rem); }
.h1-line { display: block; }
.hero .lede { color: var(--ink); }
.hero .lede-sm { color: var(--ink-70); }

.stats {
  margin: clamp(56px, 7vw, 104px) 0 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--ink);
}
.stat { padding: 22px 24px 26px 0; border-right: 1px solid var(--rule); }
.stat + .stat { padding-left: 24px; }
.stat:last-child { border-right: 0; }
.stat-n { font-size: clamp(2.2rem, 3.6vw, 3.4rem); line-height: 1; letter-spacing: -0.02em; }
.stat-n span { font-size: .45em; margin-left: 6px; letter-spacing: 0; color: var(--ink-70); }
.stat dd { margin: 12px 0 0; font-size: 1.02rem; line-height: 1.4; color: var(--ink-70); max-width: 26ch; }

.creds { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.cred-row { display: grid; grid-template-columns: 220px 1fr; gap: var(--gap); align-items: baseline; padding: 16px 0; }
.cred-row + .cred-row { border-top: 1px solid var(--rule); }
.cred-label { color: var(--ink-70); }
.cred-list { display: flex; flex-wrap: wrap; gap: 8px 0; }
.cred-list li { font-family: var(--mono); font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; }
.cred-list li + li::before { content: "/"; margin: 0 14px; color: var(--ink-35); }

@media (max-width: 899px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(3) { padding-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .cred-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .stat, .stat + .stat { padding-left: 0; border-right: 0; }
  .stat + .stat { border-top: 1px solid var(--rule); }
}

.section { padding-block: clamp(88px, 10vw, 160px); }
.fit { --chip: var(--red); }
.models { --chip: var(--yellow); }

/* 01 Sound familiar */
.fit-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap); align-items: start; }
.fit-copy { grid-column: 1 / span 5; position: sticky; top: 100px; }
.fit-copy h2 { max-width: 14ch; }
.fit-copy .lede { margin-top: 24px; }
.dx { grid-column: 7 / span 6; }
.dx-opts { border-top: 1px solid var(--ink); }
.dx-opt {
  width: 100%; display: grid; grid-template-columns: 36px 1fr 26px; gap: 16px; align-items: center;
  text-align: left; padding: 18px 4px; border-bottom: 1px solid var(--rule);
  font-size: clamp(1.15rem, 1.5vw, 1.35rem); line-height: 1.3;
  transition: background-color var(--t-fast) var(--ease), padding var(--t-fast) var(--ease);
}
.dx-opt:hover { background: rgba(17,17,17,.035); padding-left: 10px; }
.dx-box { width: 22px; height: 22px; border: 1px solid var(--ink); position: relative; justify-self: end; }
.dx-opt[aria-pressed="true"] .dx-t { font-weight: 500; }
.dx-opt[aria-pressed="true"] .dx-box { background: var(--ink); }
.dx-opt[aria-pressed="true"] .dx-box::after {
  content: ""; position: absolute; right: -1px; top: -1px; border-style: solid;
  border-width: 0 9px 9px 0; border-color: transparent var(--red) transparent transparent;
}
.dx-opt[aria-pressed="true"] .idx { color: var(--red); }
.dx-result {
  margin-top: 28px; background: var(--dark); color: var(--paper); padding: clamp(24px, 3vw, 36px);
  position: relative; min-height: 210px;
}
.dx-result::before { content: ""; position: absolute; right: 0; top: 0; border-style: solid; border-width: 0 18px 18px 0; border-color: transparent var(--red) transparent transparent; }
.dx-kicker { color: var(--paper-70); }
.dx-name { margin-top: 10px; font-size: clamp(1.7rem, 2.6vw, 2.3rem); line-height: 1.1; }
.dx-line { margin-top: 10px; color: var(--paper-70); max-width: 46ch; }
.dx-steps { margin-top: 18px; border-top: 1px solid var(--paper-rule); }
.dx-steps li { display: grid; grid-template-columns: 90px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--paper-rule); font-size: 1.05rem; }
.dx-steps .mono { color: var(--paper-70); padding-top: 4px; }
.dx-cta { margin-top: 22px; }
.dx-result.flash { animation: dxflash .5s var(--ease); }
@keyframes dxflash { from { transform: translateY(6px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (max-width: 899px) {
  .fit-copy, .dx { grid-column: 1 / -1; }
  .fit-copy { position: static; margin-bottom: 28px; }
}

/* 02 What I do */
.work h2 { max-width: 20ch; }
.svc-grid { margin-top: clamp(36px, 5vw, 64px); display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--ink); }
.svc-card { padding: 28px clamp(18px, 2.2vw, 32px) 32px; border-right: 1px solid var(--rule); display: flex; flex-direction: column; }
.svc-card:first-child { padding-left: 0; }
.svc-card:last-child { border-right: 0; padding-right: 0; }
.svc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.svc-ico { width: 56px; height: 56px; }
.svc-ico .rail { stroke: var(--ink); stroke-width: 1; }
.svc-ico .red { fill: var(--red); } .svc-ico .blue { fill: var(--blue); } .svc-ico .yellow { fill: var(--yellow); }
.svc-card h3 { font-size: clamp(1.7rem, 2.3vw, 2.2rem); }
.svc-card .svc-sub { margin-top: 6px; font-style: italic; color: var(--ink-70); }
.svc-card > p:not(.svc-sub) { margin-top: 16px; text-wrap: pretty; }
.tick-list { margin-top: auto; padding-top: 22px; }
.tick-list li { font-family: var(--mono); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; padding: 9px 0 9px 22px; border-top: 1px solid var(--rule); position: relative; }
.tick-list li::before { content: ""; position: absolute; left: 0; top: 13px; width: 10px; height: 10px; border: 1px solid var(--ink); }
@media (max-width: 899px) {
  .svc-grid { grid-template-columns: 1fr; }
  .svc-card, .svc-card:first-child, .svc-card:last-child { padding: 28px 0 32px; border-right: 0; border-bottom: 1px solid var(--rule); }
}

/* 03 How it works */
.how-head { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap); align-items: end; }
.how-head h2 { grid-column: 1 / span 7; max-width: 16ch; }
.how-head .lede { grid-column: 8 / span 5; }
.timeline { margin-top: clamp(40px, 6vw, 80px); display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); position: relative; }
.timeline::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 1px; background: var(--ink); transform-origin: left; transform: scaleX(0); transition: transform 1200ms var(--ease); }
.timeline.in-view::before, html:not(.js) .timeline::before { transform: none; }
.tl-step { position: relative; padding-top: 34px; padding-right: 12px; }
.tl-dot { position: absolute; top: 0; left: 0; width: 15px; height: 15px; border-radius: 50%; }
.blue-dot { background: var(--blue); } .yellow-dot { background: var(--yellow); } .red-dot { background: var(--red); } .ink-dot { background: var(--ink); }
.tl-when { color: var(--ink-70); }
.tl-step h3 { margin-top: 8px; }
.tl-step p:not(.mono) { margin-top: 10px; color: var(--ink-70); text-wrap: pretty; }
@media (max-width: 899px) {
  .how-head h2, .how-head .lede { grid-column: 1 / -1; }
  .timeline { grid-template-columns: 1fr 1fr; row-gap: 40px; }
  .timeline::before { display: none; }
}
@media (max-width: 520px) { .timeline { grid-template-columns: 1fr; } }

.artifacts { margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.art { border: 1px solid var(--rule); padding: 20px; background: rgba(255,255,255,.28); transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.art:hover { border-color: var(--ink); transform: translateY(-2px); }
.art h4 { margin: 18px 0 0; font-size: 1.35rem; font-weight: 500; line-height: 1.2; }
.art p { margin-top: 6px; color: var(--ink-70); font-size: 1.05rem; line-height: 1.4; }
.doc { height: 128px; border: 1px solid var(--ink); background: var(--paper); padding: 12px 14px; position: relative; overflow: hidden; }
.doc::after { content: ""; position: absolute; right: -1px; top: -1px; border-style: solid; border-width: 0 12px 12px 0; border-color: transparent var(--red) transparent transparent; }
.doc-h { height: 6px; width: 40%; background: var(--ink); margin-bottom: 12px; }
.cal { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cal i { height: 34px; border: 1px solid var(--rule-strong); }
.cal i.on { background: var(--blue); border-color: var(--blue); }
.rows span { display: flex; align-items: center; gap: 8px; height: 18px; margin-bottom: 6px; }
.rows span::before { content: ""; width: 10px; height: 10px; border: 1px solid var(--ink); flex: none; }
.rows span:first-child::before { background: var(--yellow); border-color: var(--yellow); }
.rows b { height: 5px; width: var(--w); background: var(--ink-35); }
.rows span:first-child b { background: var(--ink); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 88px; border-bottom: 1px solid var(--ink); }
.bars i { flex: 1; height: var(--h); background: var(--ink-35); }
.bars i.hi { background: var(--blue); }
.log span { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--rule); }
.log em { width: 26px; height: 5px; background: var(--red); flex: none; }
.log span:nth-child(even) em { background: var(--ink); }
.log b { height: 5px; width: var(--w); background: var(--ink-35); }
.memo b { display: block; height: 5px; width: var(--w); background: var(--ink-35); margin-bottom: 8px; }
.memo .kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.memo .kpis i { height: 34px; border: 1px solid var(--ink); }
.memo .kpis i:first-child { background: var(--yellow); border-color: var(--yellow); }
.org { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 4px; }
.org i { width: 46px; height: 22px; background: var(--ink); display: block; }
.org span { display: flex; gap: 14px; }
.org i.open { background: transparent; border: 1px dashed var(--red); }
@media (max-width: 899px) { .artifacts { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .artifacts { grid-template-columns: 1fr; } }

/* 04 Built to scale: give the controls room so they never run under the figure */
.scale-copy { grid-column: 1 / span 5; }
.stage-figure { grid-column: 6 / span 7; }
@media (max-width: 1199px) { .segmented button { padding: 10px 12px; font-size: 1rem; } }
@media (max-width: 899px) { .scale-copy, .stage-figure { grid-column: 1 / -1; position: static; } .stage-figure { margin-top: 32px; } }

/* 05 Models */
.models h2 { max-width: 20ch; }
.specs { margin-top: clamp(36px, 5vw, 64px); border-top: 1px solid var(--ink); }
.spec-row { display: grid; grid-template-columns: 1.1fr 2fr 2fr 2fr; border-bottom: 1px solid var(--rule); }
.spec-row > span { padding: 16px 20px; font-size: 1.1rem; line-height: 1.4; }
.spec-row > span:first-child { padding-left: 0; color: var(--ink-70); padding-top: 21px; }
.spec-row > span.mono { font-size: var(--fs-mono); }
.spec-headrow > span { padding-top: 22px; padding-bottom: 18px; }
.spec-name { display: block; font-size: clamp(1.7rem, 2.4vw, 2.3rem); line-height: 1; }
.spec-headrow .mono { display: block; margin-top: 8px; color: var(--ink-70); }
.spec-feat { background: var(--dark); color: var(--paper); }
.spec-headrow .spec-feat .mono { color: var(--yellow); }
@media (max-width: 899px) {
  .specs { overflow-x: auto; }
  .spec-row { grid-template-columns: 110px repeat(3, minmax(170px, 1fr)); min-width: 640px; }
}

/* 06 About */
.now { margin-top: 32px; padding: 20px 22px; border: 1px solid var(--ink); }
.now ul { margin-top: 10px; }
.now li { padding: 8px 0; border-top: 1px solid var(--rule); font-size: 1.1rem; }
.cv { margin: 24px 0 0; border-top: 1px solid var(--ink); }
.cv > div { display: grid; grid-template-columns: 112px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.cv dt { color: var(--ink-70); padding-top: 4px; }
.cv dd { margin: 0; font-size: 1.02rem; line-height: 1.4; }

/* 08 Questions */
.q-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap); align-items: start; }
.q-grid > h2 { grid-column: 1 / span 4; position: sticky; top: 100px; }
.q-grid > .faq-list { grid-column: 6 / span 7; margin-top: 0; }
@media (max-width: 899px) { .q-grid > h2, .q-grid > .faq-list { grid-column: 1 / -1; position: static; } .q-grid > .faq-list { margin-top: 28px; } }

/* 09 Contact */
.contact-v4 { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap); align-items: start; }
.contact-v4 .contact-copy { grid-column: 1 / span 5; }
.contact-v4 .lede { margin-top: 22px; color: var(--paper-70); }
.mini-steps { margin-top: 28px; border-top: 1px solid var(--paper-rule); }
.mini-steps li { padding: 12px 0; border-bottom: 1px solid var(--paper-rule); font-size: 1.15rem; }
.mini-steps .mono { color: var(--paper-70); margin-right: 14px; }
.contact-v4 .contact-email { display: inline-block; margin-top: 28px; }
.brief { grid-column: 7 / span 6; border: 1px solid var(--paper-rule); padding: clamp(22px, 3vw, 36px); position: relative; }
.brief::before { content: ""; position: absolute; right: -1px; top: -1px; border-style: solid; border-width: 0 16px 16px 0; border-color: transparent var(--red) transparent transparent; }
.brief-note { color: var(--paper-70); margin-bottom: 18px; }
.brief-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bfield { margin-top: 16px; }
.bfield label, .blabel { display: block; font-size: 1.02rem; margin-bottom: 8px; color: var(--paper); }
.bfield .opt { color: var(--paper-70); }
.bfield input, .bfield textarea {
  width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--paper-35);
  color: var(--paper); padding: 8px 0; font-size: 1.15rem; border-radius: 0;
}
.bfield textarea { border: 1px solid var(--paper-35); padding: 10px 12px; resize: vertical; }
.bfield input:focus, .bfield textarea:focus { outline: none; border-color: var(--paper); }
.bfield textarea::placeholder { color: var(--paper-35); }
.bfield.invalid input { border-color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--paper-35); padding: 8px 12px; font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--paper-70); transition: all var(--t-fast) var(--ease); }
.chips button:hover { color: var(--paper); border-color: var(--paper); }
.chips button[aria-checked="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.brief-actions { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.brief-status { color: var(--paper-70); max-width: 40ch; }
@media (max-width: 899px) {
  .contact-v4 .contact-copy, .brief { grid-column: 1 / -1; }
  .brief { margin-top: 32px; }
  .brief-row { grid-template-columns: 1fr; gap: 0; }
}
