/* Scroll To Run It: two scenes on the home page (index.html #flow and #change)
   that build as you scroll, like the job drawing at the top of the page.
   Every rule here draws a scene's END state. The start state only applies
   while /next/scrub.js has armed a scene (.sc-armed) and set --k on each part
   from the scroll position, so with JavaScript off, with Reduce Motion on or
   on a very short window the scenes read as finished drawings.
   Only transform and opacity move. */

.sc-head { display: grid; gap: 14px; max-width: 46em; margin-bottom: clamp(24px, 3.4vw, 40px); }
.sc-lead { font-size: clamp(17px, 1.3vw, 19px); line-height: 1.45; color: var(--ink2); }
.sc-lead .tier { vertical-align: 2px; margin-left: 4px; }
.sc-note { margin-top: 14px; font-size: 14px; color: var(--mute); }

/* the part of the scroll a scene plays over, and the sheet that stays put while it does */
.sc-armed .sc-track { height: 330vh; }
.sc-armed .sc-stick { position: sticky; top: 0; min-height: 100vh; display: grid; align-content: center; padding: 18px 0; }

/* the moves. Each part reads --k (0 to 1) for its own stretch of the scroll. */
.sc-armed .k-set { opacity: var(--k, 1); transform: translateY(calc((1 - var(--k, 1)) * 10px)); }
.sc-armed .k-fade { opacity: var(--k, 1); }
.sc-armed .k-grow { transform: scaleX(var(--k, 1)); }
.sc-armed .k-rise { transform: scaleY(var(--k, 1)); }
.sc-armed .k-stamp { opacity: min(1, calc(var(--k, 1) * 4)); transform: rotate(-3deg) scale(calc(1.5 - .5 * var(--k, 1))); }
.sc-armed .k-wipe { transform: scaleX(calc(1 - var(--k, 1))); }
.k-grow, .k-wipe { transform-origin: left center; }
.k-rise { transform-origin: center bottom; }
.k-stamp { transform: rotate(-3deg); }

/* ---------- the sheet both scenes are drawn on ---------- */
.sx { border: 1px solid var(--ink); background: var(--sheet); }
.sx-tabs { display: grid; grid-template-columns: repeat(var(--tabs, 3), minmax(0, 1fr)); border-bottom: 1px solid var(--ink); }
.sx-tabs span { position: relative; display: flex; align-items: baseline; gap: 10px; min-height: 48px; padding: 14px 16px 11px; border-right: 1px solid var(--hair); color: var(--mute); font: 600 15px/1.1 var(--disp); letter-spacing: .1em; text-transform: uppercase; overflow: hidden; }
.sx-tabs span:last-child { border-right: 0; }
.sx-tabs b { font-size: 12px; letter-spacing: .14em; color: var(--ink2); }
.sx-tabs .on { color: var(--ink); background: var(--paper); }
.sx-tabs .on b { color: var(--green); }
.sx-tabs i { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--green); }
.sx-head { display: flex; justify-content: space-between; gap: 12px; padding: 12px clamp(14px, 2vw, 24px) 10px; border-bottom: 1px solid var(--hair); font: 600 12px/1.2 var(--disp); letter-spacing: .12em; text-transform: uppercase; }
.sx-head .ex { color: var(--mute); white-space: nowrap; }
.sx-illus { padding: 9px clamp(14px, 2vw, 24px); border-top: 1px solid var(--hair); font: 600 11px/1.2 var(--disp); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }

/* figures along the foot of a sheet */
.sx-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--ink); }
.sx-figs > div { position: relative; padding: 12px clamp(14px, 2vw, 24px) 14px; border-right: 1px solid var(--hair); min-width: 0; }
.sx-figs > div:last-child { border-right: 0; }
.sx-figs dt { font-size: 11.5px; color: var(--mute); }
.sx-figs dd { margin: 6px 0 0; font: 700 clamp(24px, 2.3vw, 34px)/1 var(--disp); font-variant-numeric: tabular-nums; letter-spacing: .01em; white-space: nowrap; }
.sx-figs dd small { font: 500 13px/1 var(--body); color: var(--mute); margin-left: 6px; letter-spacing: 0; }
.sx-figs .now dd { color: var(--green); }
.stamp { position: absolute; display: inline-block; padding: 5px 9px 4px; border: 2px solid currentColor; border-radius: 3px; font: 700 14px/1 var(--disp); letter-spacing: .14em; text-transform: uppercase; color: var(--teal); background: var(--sheet); }
.sx-figs .stamp { right: 14px; top: 10px; }

/* ---------- 1. one estimate runs the job ---------- */
.fx { --days: 50; --px: clamp(14px, 2vw, 24px); --cols: minmax(150px, 1.2fr) 112px minmax(0, 3fr) 124px; position: relative; padding: 0 var(--px); }
.fx-row { display: grid; grid-template-columns: var(--cols); align-items: center; gap: 0 14px; min-height: 34px; border-bottom: 1px solid var(--hair); }
.fx-row.fx-cols { min-height: 30px; border-bottom: 1px solid var(--ink); font: 600 11px/1 var(--disp); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.fx-nm { font-size: 14.5px; line-height: 1.2; color: var(--ink2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-amt { font: 500 14.5px/1 var(--body); font-variant-numeric: tabular-nums; text-align: right; }
.fx-tr { position: relative; height: 34px; background-image: linear-gradient(to right, var(--hair) 1px, transparent 1px); background-size: calc(100% / 5) 100%; }
.fx-cols .fx-tr { height: 30px; background: none; }
.fx-cols .fx-tr span { position: absolute; top: 10px; left: calc((var(--a) - 1) * 100% / var(--days)); padding-left: 4px; border-left: 1px solid var(--hair2); white-space: nowrap; }
.fx-bar { position: absolute; top: 10px; height: 14px; left: calc((var(--a) - 1) * 100% / var(--days)); width: calc(var(--d) * 100% / var(--days)); border: 1.5px solid var(--ink); background: var(--sheet); overflow: hidden; }
.fx-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--done, 0) * 100%); background: var(--teal); }
.fx-bl { display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: center; gap: 8px; }
.fx-bl s { position: relative; display: block; height: 8px; background: var(--paper); border: 1px solid var(--hair2); text-decoration: none; overflow: hidden; }
.fx-bl s i { position: absolute; inset: 0; right: auto; width: var(--b); background: var(--green); }
.fx-bl b { font: 600 13px/1 var(--body); font-variant-numeric: tabular-nums; text-align: right; color: var(--ink2); }
.fx-bl.zero b { color: var(--hair2); }
/* the two vertical lines on the chart, today and the finish, on a copy of the row grid laid over the rows */
.fx-marks { position: absolute; top: 0; bottom: 20px; left: var(--px); right: var(--px); display: grid; grid-template-columns: var(--cols); gap: 0 14px; pointer-events: none; }
.fx-mk { position: relative; grid-column: 3; }
.fx-mk i { position: absolute; top: 4px; bottom: 0; width: 0; left: calc((var(--a) - 1) * 100% / var(--days)); border-left: 1.5px solid var(--green); }
.fx-mk i.fin { border-left: 1.5px dashed var(--ink); left: calc(var(--a) * 100% / var(--days)); }
.fx-mk i span { position: absolute; bottom: 0; left: 4px; transform: translateY(100%); padding-top: 4px; font: 600 10.5px/1 var(--disp); letter-spacing: .1em; text-transform: uppercase; color: var(--green); white-space: nowrap; }
.fx-mk i.fin span { color: var(--ink); left: auto; right: 4px; }
.fx-pad { height: 20px; }

/* ---------- 2. one change, signed and billed ---------- */
.cx { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(220px, .75fr) minmax(0, 1fr); }
.cx > section { position: relative; padding: clamp(14px, 2vw, 24px); border-right: 1px solid var(--hair); min-width: 0; }
.cx > section:last-child { border-right: 0; }
.cx h3 { font-size: clamp(20px, 1.7vw, 24px); margin: 6px 0 4px; }
.cx-tag { font: 600 12px/1 var(--disp); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.cx-tag b { color: var(--green); margin-right: 6px; }
.cx-why { font-size: 14px; color: var(--mute); margin-bottom: 12px; }
.cx-lines li, .cx-reg li { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--hair); font-size: 14.5px; line-height: 1.3; }
.cx-lines { border-top: 1px solid var(--ink); }
.cx-lines li span, .cx-reg li span { color: var(--ink2); min-width: 0; }
.cx-lines li b, .cx-reg li b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cx-tot { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 0 0; }
.cx-tot dt { font-size: 12px; color: var(--mute); }
.cx-tot dd { margin: 0; font: 700 clamp(26px, 2.3vw, 32px)/1 var(--disp); font-variant-numeric: tabular-nums; }
.cx-imp { display: flex; justify-content: space-between; padding-top: 10px; font-size: 14px; color: var(--ink2); }
.cx-imp b { font-weight: 600; }

/* the client's phone, drawn in ink */
.cx-mid { display: grid; justify-items: center; align-content: start; gap: 10px; background: var(--paper); }
.cx-phone { position: relative; width: min(100%, 210px); aspect-ratio: 9 / 14; border: 2px solid var(--ink); border-radius: 26px; background: var(--sheet); padding: 30px 14px 16px; display: grid; align-content: start; gap: 8px; }
.cx-phone::before { content: ""; position: absolute; top: 10px; left: 50%; width: 46px; height: 6px; margin-left: -23px; border-radius: 4px; background: var(--ink); }
.cx-pt { font: 600 10.5px/1.2 var(--disp); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.cx-ph { font: 700 19px/1.05 var(--disp); text-transform: uppercase; letter-spacing: .02em; }
.cx-pamt { font: 700 26px/1 var(--disp); font-variant-numeric: tabular-nums; }
.cx-pr { height: 1px; background: var(--hair); }
.cx-sig { position: relative; height: 62px; border-bottom: 1.5px solid var(--ink); }
.cx-sig svg { position: absolute; left: 0; right: 0; bottom: 4px; width: 100%; height: 54px; overflow: visible; }
.cx-sig path { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cx-sig .k-wipe { position: absolute; inset: 0 0 2px; background: var(--sheet); transform: scaleX(0); }
.sc-armed .cx-sig .k-wipe { transform: scaleX(calc(1 - var(--k, 1))); }
.cx-sn { font-size: 12px; color: var(--mute); }
.cx-phone .stamp { position: static; justify-self: end; margin-top: 2px; }
.cx-cap { font-size: 13px; color: var(--mute); text-align: center; max-width: 20em; }
.cx-reg { border-top: 1px solid var(--ink); }
.cx-reg li.new b { color: var(--green); }
.cx-reg li.sum { border-bottom: 0; padding-top: 12px; }
.cx-reg li.sum span { font: 600 12px/1 var(--disp); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.cx-reg li.sum b { font: 700 clamp(26px, 2.3vw, 32px)/1 var(--disp); }
.cx-next { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--green); background: var(--green-t); font-size: 14px; line-height: 1.35; }
.cx-next b { display: block; font: 600 11.5px/1.2 var(--disp); letter-spacing: .12em; text-transform: uppercase; color: var(--green); margin-bottom: 4px; }

/* ---------- phones and narrow windows ---------- */
/* tablets (iPad in either direction, small laptops): the laptop layout, packed tighter */
@media (min-width: 700px) and (max-width: 1099px) {
  .fx { --cols: minmax(128px, 1fr) 96px minmax(0, 2fr) 104px; }
  .fx-row { gap: 0 10px; } .fx-marks { gap: 0 10px; }
  .fx-nm, .fx-amt { font-size: 13.5px; }
  .fx-bl { grid-template-columns: minmax(0, 1fr) 36px; gap: 6px; }
  .cx { grid-template-columns: minmax(0, 1fr) 190px minmax(0, 1fr); }
  .cx-phone { padding: 28px 12px 14px; }
  .cx h3 { font-size: 19px; }
  .cx-lines li, .cx-reg li { font-size: 13.5px; }
  .sx-figs dd { font-size: 26px; }
  .fx-mk i:not(.fin) span { display: none; }
}
@media (max-width: 699px) {
  .sx-tabs span { flex-direction: column; gap: 3px; padding: 10px 10px 9px; font-size: 13px; min-height: 0; }
  .sx-figs dd { font-size: 22px; }
  .sx-figs > div { padding: 10px 10px 12px; }
  .sx-figs dd small { display: block; margin: 4px 0 0; }
  .sx-figs .stamp { position: static; display: inline-block; margin-top: 6px; font-size: 11px; }
  .fx-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "nm amt" "tr tr" "bl bl"; gap: 2px 10px; padding: 6px 0; }
  .fx-nm { grid-area: nm; } .fx-amt { grid-area: amt; } .fx-tr { grid-area: tr; height: 22px; } .fx-bl { grid-area: bl; }
  .fx-bar { top: 5px; height: 12px; }
  .fx-row.fx-cols { grid-template-areas: "tr tr"; padding: 0; }
  .fx-cols .fx-nm, .fx-cols .fx-amt, .fx-cols .fx-bl { display: none; }
  .fx-cols .fx-tr span:nth-child(3), .fx-cols .fx-tr span:nth-child(5) { display: none; }
  .cx { grid-template-columns: 1fr; }
  .cx > section { border-right: 0; border-bottom: 1px solid var(--hair); }
  .cx > section:last-child { border-bottom: 0; }
  .cx-mid { grid-template-columns: 150px minmax(0, 1fr); justify-items: start; align-items: center; }
  .cx-phone { width: 150px; padding: 24px 10px 12px; border-radius: 20px; gap: 6px; }
  .cx-ph { font-size: 15px; } .cx-pamt { font-size: 20px; } .cx-sig { height: 44px; } .cx-sig svg { height: 38px; }
  .cx-phone .stamp { font-size: 11px; }
  .cx-cap { text-align: left; }

  /* armed on a phone: one row line at a time, and the three parts of the change share one place */
  .sc-armed .fx-row { grid-template-columns: var(--cols); grid-template-areas: "nm x"; padding: 0; min-height: 30px; }
  .sc-armed .fx-row.fx-cols { grid-template-areas: "nm x"; min-height: 26px; }
  .sc-armed .fx-cols .fx-nm, .sc-armed .fx-cols .fx-amt, .sc-armed .fx-cols .fx-bl { display: block; }
  .sc-armed .fx-nm { font-size: 13.5px; }
  .sc-armed .fx-amt, .sc-armed .fx-tr, .sc-armed .fx-bl { grid-area: x; }
  .sc-armed .fx-tr { height: 30px; }
  .sc-armed .fx-bar { top: 9px; height: 11px; }
  .sc-armed .fx-cols .fx-tr span { display: none; }
  .sc-armed .fx-amt { opacity: clamp(0, calc((.37 - var(--p, 1)) * 30), 1); }
  .sc-armed .fx-tr { opacity: clamp(0, calc(min(var(--p, 1) - .35, .7 - var(--p, 1)) * 30), 1); }
  .sc-armed .fx-bl { opacity: clamp(0, calc((var(--p, 1) - .68) * 30), 1); grid-template-columns: minmax(0, 1fr) 34px; gap: 5px; }
  .fx-marks { display: none; }
  .sc-armed .fx { --cols: minmax(0, 1fr) 132px; }
  .sc-armed .fx-marks { display: grid; gap: 0 10px; opacity: clamp(0, calc(min(var(--p, 1) - .35, .7 - var(--p, 1)) * 30), 1); }
  .sc-armed .fx-mk { grid-column: 2; }
  .sc-armed .fx-mk span { display: none; }
  .sc-armed .cx { grid-template-areas: "one"; }
  .sc-armed .cx > section { grid-area: one; border: 0; }
  .sc-armed .cx-doc { opacity: clamp(0, calc((.4 - var(--p, 1)) * 25), 1); }
  .sc-armed .cx-mid { opacity: clamp(0, calc(min(var(--p, 1) - .38, .7 - var(--p, 1)) * 25), 1); background: transparent; grid-template-columns: 1fr; justify-items: center; }
  .sc-armed .cx-mid .cx-phone { width: 190px; padding: 28px 12px 14px; }
  .sc-armed .cx-reg-wrap { opacity: clamp(0, calc((var(--p, 1) - .68) * 25), 1); }
}
@media (max-width: 699px) and (max-height: 700px) {
  .sc-armed .fx-row { min-height: 26px; } .sc-armed .fx-tr { height: 26px; } .sc-armed .fx-bar { top: 8px; height: 10px; }
  .sc-armed .sx-head, .sc-armed .sx-illus { padding-top: 7px; padding-bottom: 6px; }
}

@media print { .sc-track { height: auto !important; } .sc-stick { position: static !important; } }
