/* Backbilt demo: one made-up dossier from intake to the last invoice, as a click-through.
   CSS only: the site's CSP has no script-src. Builds on ../assets/site.css (tokens, header, pills,
   the app frame, chat bubbles, instalment bar).

   How it works without a script:
   - one empty anchor per step at the top of <body>; the step whose anchor is :target is shown, so
     every step has its own link (/demo/#werf) and the back button walks the steps;
   - each step's "Bevestig" is the label of a hidden checkbox; :checked swaps the step from the
     proposal to the confirmed state (.off-ok / .on-ok) and counts it (counter "confirmed");
   - a hidden step keeps its checkbox rendered (visibility, not display) so the count stays right,
     while its content is display:none, so its animations restart each time it is shown. */

:root {
  --warn: #A3480B;
  --warn-bg: #FDF1E7;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --warn: #F5A65B;
    --warn-bg: rgba(245, 166, 91, .12);
  }
}
:root[data-theme="dark"] {
  --warn: #F5A65B;
  --warn-bg: rgba(245, 166, 91, .12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .rf-head { fill: #101A2E; stroke: #2ED3BF; stroke-width: 1.2; }
}
:root[data-theme="dark"] .rf-head { fill: #101A2E; stroke: #2ED3BF; stroke-width: 1.2; }

.anchor { position: absolute; top: 0; left: 0; width: 1px; height: 1px; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

body { counter-reset: confirmed; }

.tour {
  padding: 40px max(var(--gutter), calc((100% - var(--max)) / 2)) 96px;
  min-height: calc(100vh - 160px);
}

/* One step at a time. */
.stage { position: relative; }
.step { position: absolute; top: 0; left: 0; visibility: hidden; }
.step-grid { display: var(--shown, none); }

.s-start,
#start:target ~ main .s-start,
#intake:target ~ main .s-intake,
#offerte:target ~ main .s-offerte,
#prijzen:target ~ main .s-prijzen,
#bestellingen:target ~ main .s-bestellingen,
#werf:target ~ main .s-werf,
#levering:target ~ main .s-levering,
#meerwerk:target ~ main .s-meerwerk,
#factuur:target ~ main .s-factuur,
#einde:target ~ main .s-einde {
  position: static;
  visibility: visible;
  --shown: grid;
}
.anchor:target ~ main .s-start {
  position: absolute;
  visibility: hidden;
  --shown: none;
}

/* Proposal and confirmed state. */
.ok {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.ok:checked { counter-increment: confirmed; }
.ok:not(:checked) ~ .step-grid .on-ok { display: none; }
.ok:checked ~ .step-grid .off-ok { display: none; }
.tally::before { content: counter(confirmed); }

/* Step layout: the story left, the app right; on a phone the app comes between story and buttons. */
.step-grid {
  grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "story app" "nav app";
  gap: 32px clamp(32px, 6vw, 88px);
  align-items: start;
}
.story { grid-area: story; display: grid; gap: 16px; max-width: 46ch; }
.step-grid > .app, .route, .recap { grid-area: app; }
.step-nav { grid-area: nav; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.step-nav .pill { gap: 8px; }

.kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--grey);
  font-size: 14px;
  font-weight: 500;
}
.story h1 {
  font-size: clamp(34px, 4.6vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.story h2 { font-size: clamp(28px, 3.2vw, 42px); line-height: 1.08; }
.story p { font-size: 17px; }
.story .lede { font-size: 18px; }
.story .lede strong { color: var(--title); font-weight: 500; }
.story .ai { color: var(--link); font-weight: 500; font-size: 16px; }
.rule {
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--panel);
}
.story .rule { font-size: 16px; }
.rule strong { color: var(--title); font-weight: 500; }
.fine { width: 100%; color: var(--grey); font-size: 14px; }

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font: 500 12px/1.4 var(--body);
  letter-spacing: .02em;
  white-space: nowrap;
}
.tag-admin { background: var(--title); color: var(--bg); }
.tag-site { background: var(--accent); color: var(--marine); }

.back {
  color: var(--grey);
  font-weight: 500;
  text-decoration: none;
  padding: 12px 0;
}
.back:hover { color: var(--title); }
.pill.next { border-color: currentColor; color: var(--title); }
.pill.next:hover { background: var(--panel); }
.ok:checked ~ .step-grid .pill.next {
  background: var(--accent);
  border-color: transparent;
  color: var(--marine);
}

/* Progress: the eight steps as vertebrae, marine for administration, turquoise for the site. */
.progress { display: none; margin-bottom: 40px; }
.anchor:target ~ main .progress { display: block; }
#start:target ~ main .progress { display: none; }
.progress ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.progress li { flex: 1 1 0; min-width: 0; --pc: var(--title); }
.progress .p-site { --pc: var(--accent); }
.progress a {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink, var(--grey));
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}
.progress a::before {
  content: "";
  display: block;
  height: 8px;
  margin-bottom: 8px;
  border-radius: 4px;
  background: var(--bar, var(--line));
  opacity: var(--dim, 1);
}
.progress a:hover { color: var(--title); }
.progress b { font-weight: 500; margin-right: 6px; }

#offerte:target ~ main .progress li:nth-child(-n+1),
#prijzen:target ~ main .progress li:nth-child(-n+2),
#bestellingen:target ~ main .progress li:nth-child(-n+3),
#werf:target ~ main .progress li:nth-child(-n+4),
#levering:target ~ main .progress li:nth-child(-n+5),
#meerwerk:target ~ main .progress li:nth-child(-n+6),
#factuur:target ~ main .progress li:nth-child(-n+7),
#einde:target ~ main .progress li { --bar: var(--pc); --dim: .35; }

#intake:target ~ main .progress li:nth-child(1),
#offerte:target ~ main .progress li:nth-child(2),
#prijzen:target ~ main .progress li:nth-child(3),
#bestellingen:target ~ main .progress li:nth-child(4),
#werf:target ~ main .progress li:nth-child(5),
#levering:target ~ main .progress li:nth-child(6),
#meerwerk:target ~ main .progress li:nth-child(7),
#factuur:target ~ main .progress li:nth-child(8) { --bar: var(--pc); --dim: 1; --ink: var(--title); }

/* A tick on each confirmed step (where :has is supported; without it the demo works the same). */
.tour:has(#ok-intake:checked) .progress li:nth-child(1) b::after,
.tour:has(#ok-offerte:checked) .progress li:nth-child(2) b::after,
.tour:has(#ok-prijzen:checked) .progress li:nth-child(3) b::after,
.tour:has(#ok-bestellingen:checked) .progress li:nth-child(4) b::after,
.tour:has(#ok-werf:checked) .progress li:nth-child(5) b::after,
.tour:has(#ok-levering:checked) .progress li:nth-child(6) b::after,
.tour:has(#ok-meerwerk:checked) .progress li:nth-child(7) b::after,
.tour:has(#ok-factuur:checked) .progress li:nth-child(8) b::after {
  content: "✓";
  margin-left: 3px;
  color: var(--link);
}

/* The app frame (site.css .app) and what goes in it. */
.step-grid > .app { font-size: 15px; }
.app-body { gap: 20px; }
.muted { color: var(--grey); }
.new { color: var(--link); font-weight: 500; }
.app-quote .new th, .app-quote .new td { color: var(--link); }

.facts { margin: 0; }
.facts div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.facts dt { color: var(--grey); }
.facts dd { margin: 0; color: var(--title); }

/* Remus's proposal card. */
.remus-card {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
  border: 1.5px solid var(--accent);
  border-radius: 14px;
  background: var(--panel);
}
.rc-head { display: flex; align-items: center; gap: 8px; color: var(--grey); font-size: 14px; }
.rc-head strong { font: 700 16px/1 var(--display); color: var(--title); }
.rc-face { width: 26px; height: 26px; flex: none; }
.rf-head { fill: #16233B; }
.rc-main { position: relative; display: grid; gap: 10px; }
.rc-title { color: var(--title); font-weight: 500; }
.rc-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.rc-calc, .rc-why { color: var(--grey); font-size: 14px; }
.rc-calc strong { color: var(--title); font-weight: 500; }
.rc-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.rc-table th { text-align: left; font-weight: 400; }
.rc-table td { text-align: right; white-space: nowrap; padding-left: 12px; }
.rc-table th, .rc-table td { padding-top: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.rc-table tfoot th, .rc-table tfoot td { border-bottom: 0; color: var(--title); font-weight: 500; }
.rc-table tfoot .sub th, .rc-table tfoot .sub td { color: var(--grey); font-weight: 400; }

.rc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 4px; }
.confirm {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--marine);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color .15s ease;
}
.confirm:hover { background: #2ED3BF; }
.ok:focus-visible ~ .step-grid .confirm { outline: 2px solid var(--title); outline-offset: 3px; }
.ok:checked ~ .step-grid .confirm {
  background: transparent;
  color: var(--link);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.rc-note { color: var(--grey); font-size: 14px; }
.ok:checked ~ .step-grid .rc-note { color: var(--title); font-weight: 500; }
.approved { color: var(--link); font-size: 14px; font-weight: 500; }

/* "Remus is reading": covers the proposal for a moment when the step opens (motion only). */
.thinking {
  position: absolute;
  inset: -2px;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-top: 2px;
  background: var(--panel);
  color: var(--grey);
  font-size: 14px;
  visibility: hidden;
  opacity: 0;
}
.dots { display: inline-flex; gap: 4px; padding-top: 9px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* Price requests: bars against the largest price. */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
.bars li::after {
  content: "";
  grid-column: 1 / -1;
  grid-row: 2;
  width: calc(var(--w) * 1%);
  height: 10px;
  border-radius: 5px;
  background: var(--line);
  transform-origin: left center;
}
.bars .w67 { --w: 67; }
.bars .w71 { --w: 71; }
.bars .w79 { --w: 79; }
.bars .w100 { --w: 100; }
.b-name { color: var(--title); font-weight: 500; }
.b-val { color: var(--title); text-align: right; font-variant-numeric: tabular-nums; }
.b-note { grid-column: 1 / -1; grid-row: 3; color: var(--grey); font-size: 13px; }
.bars .own::after { background: transparent; box-shadow: inset 0 0 0 1.5px var(--grey); }
.bars .best::after { background: var(--accent); }
.bars .flag::after { background: var(--warn); opacity: .55; }
.bars .flag .b-note { color: var(--warn); }
.won {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--marine);
  font-size: 12px;
}

/* Orders in rounds. */
.o-round { padding: 14px 0 4px; color: var(--grey); font-size: 13px; }
.o-round:first-child { padding-top: 0; }
.o-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 4px 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.o-line strong { color: var(--title); font-weight: 500; }
.o-line .muted { font-size: 13px; }
.o-amt { color: var(--title); font-variant-numeric: tabular-nums; }
.state {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.s-ok { background: var(--panel); color: var(--link); box-shadow: inset 0 0 0 1px var(--accent); }
.s-warn { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }

/* The day plan. */
.day { list-style: none; margin: 0; padding: 0; }
.day li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.day time { font: 700 16px/1.5 var(--display); color: var(--title); }
.day strong { color: var(--title); font-weight: 500; }
.day .muted { font-size: 14px; }
.keybox { padding: 10px 14px; border-radius: 10px; background: var(--bubble); color: var(--title); font-size: 14px; }

/* The late delivery: a two-week plan whose bars slide when the proposal is confirmed. */
.alert {
  padding: 12px 16px;
  border-left: 4px solid var(--warn);
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--title);
  font-size: 14px;
}
.alert strong { display: block; color: var(--warn); font-weight: 500; }
.gantt { --lab: 128px; display: grid; gap: 6px; font-size: 12px; }
.g-days {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  margin-left: var(--lab);
  color: var(--grey);
  font-size: 11px;
}
.g-days span { text-align: center; white-space: nowrap; }
.g-days i { font-style: normal; }
.g-row { display: grid; grid-template-columns: var(--lab) minmax(0, 1fr); align-items: center; }
.g-who { padding-right: 8px; color: var(--title); font-size: 13px; }
.g-track {
  position: relative;
  height: 28px;
  border-radius: 4px;
  background:
    linear-gradient(to right, transparent calc(50% - 1px), var(--grey) calc(50% - 1px) 50%, transparent 50%) 0 0 / 100% 100% no-repeat,
    repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px 10%);
}
.g-bar, .g-drop { position: absolute; transition: left .8s cubic-bezier(.4, 0, .2, 1); }
.g-bar {
  top: 3px;
  bottom: 3px;
  left: calc(var(--s) * 10% + 2px);
  width: calc(var(--d) * 10% - 4px);
  display: flex;
  align-items: center;
  padding: 0 6px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--title);
  color: var(--bg);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.g-moves { background: var(--accent); color: var(--marine); }
.ok:not(:checked) ~ .step-grid .g-conflict {
  background: repeating-linear-gradient(-45deg, var(--warn) 0 6px, transparent 6px 10px), var(--warn-bg);
  color: var(--title);
  box-shadow: inset 0 0 0 1.5px var(--warn);
}
.g-drop {
  top: 50%;
  left: calc(var(--s) * 10% + 5% - 6px);
  width: 12px;
  height: 12px;
  margin-top: -6px;
  background: var(--warn);
  transform: rotate(45deg);
}
.g-drop.g-was { background: transparent; box-shadow: inset 0 0 0 1.5px var(--grey); }
.at0 { --s: 0; } .at1 { --s: 1; } .at2 { --s: 2; } .at3 { --s: 3; } .at4 { --s: 4; }
.at5 { --s: 5; } .at8 { --s: 8; }
.len1 { --d: 1; } .len2 { --d: 2; } .len3 { --d: 3; }
.ok:checked ~ .step-grid .to2 { --s: 2; }
.ok:checked ~ .step-grid .to5 { --s: 5; }

/* A message from site. */
.site-msg { display: grid; gap: 6px; }
.site-msg .who { margin-top: 0; }
.site-msg .bubble { justify-self: start; border-bottom-right-radius: 16px; border-bottom-left-radius: 4px; }

/* Instalments: the last one turns "sent" when confirmed. */
.pay .off-ok, .pay .on-ok { color: var(--grey); }
.ok:checked ~ .step-grid .pay .last::before { background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }

/* Start: the route as a spine with three groups. */
.route { position: relative; display: grid; gap: 14px; padding-left: 28px; }
.route::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  border-radius: 4px;
  background: var(--accent);
}
.route-pillar {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.route-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.route-sub { color: var(--link); font-size: 14px; font-weight: 500; }
.route ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.route a { display: flex; gap: 12px; color: var(--title); text-decoration: none; }
.route a:hover { color: var(--link); }
.route b { min-width: 1ch; font: 700 15px/1.6 var(--display); color: var(--grey); }

/* End: what Remus proposed, ticked where you confirmed (where :has is supported). */
.recap { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.recap li {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 12px 0 12px 36px;
  border-bottom: 1px solid var(--line);
  color: var(--title);
}
.recap li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-top: -12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-size: 13px;
  font-weight: 500;
}
.tour:has(#ok-intake:checked) .r-intake::before,
.tour:has(#ok-offerte:checked) .r-offerte::before,
.tour:has(#ok-prijzen:checked) .r-prijzen::before,
.tour:has(#ok-bestellingen:checked) .r-bestellingen::before,
.tour:has(#ok-werf:checked) .r-werf::before,
.tour:has(#ok-levering:checked) .r-levering::before,
.tour:has(#ok-meerwerk:checked) .r-meerwerk::before,
.tour:has(#ok-factuur:checked) .r-factuur::before {
  content: "✓";
  background: var(--accent);
  color: var(--marine);
  box-shadow: none;
}

.demo-page .foot p:first-child { max-width: 72ch; }

/* Motion: the step comes in, Remus reads for a moment, then proposes; confirmed changes pop in. */
@media (prefers-reduced-motion: no-preference) {
  .step-grid { animation: step-in .45s ease both; }
  .thinking { animation: thinking 1.5s ease both; }
  .ok:checked ~ .step-grid .thinking { animation: none; }
  .dots i { animation: blink 1s ease-in-out infinite; }
  .dots i:nth-child(2) { animation-delay: .15s; }
  .dots i:nth-child(3) { animation-delay: .3s; }
  .ok:not(:checked) ~ .step-grid .confirm { animation: nudge 1.6s ease 1.8s 2; }
  .ok:checked ~ .step-grid .on-ok { animation: pop .45s ease both; }
  .ok:checked ~ .step-grid .approved { animation: pop .45s ease 1.6s both; }
  .bars li::after { animation: grow .8s cubic-bezier(.4, 0, .2, 1) .2s both; }
  .route-pillar { animation: step-in .5s ease both; }
  .route-pillar:nth-child(2) { animation-delay: .12s; }
  .route-pillar:nth-child(3) { animation-delay: .24s; }
}
@media (prefers-reduced-motion: reduce) {
  .g-bar, .g-drop { transition: none; }
}
@keyframes step-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes thinking {
  0%, 75% { opacity: 1; visibility: visible; }
  100% { opacity: 0; visibility: hidden; }
}
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes nudge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(19, 181, 164, 0); }
  40% { box-shadow: 0 0 0 8px rgba(19, 181, 164, .25); }
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
@keyframes grow { from { transform: scaleX(0); } }

/* Tablet and phone. */
@media (max-width: 960px) {
  .step-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "story" "app" "nav";
  }
  .s-start .step-grid, .s-einde .step-grid { grid-template-areas: "story" "nav" "app"; }
  .story { max-width: 60ch; }
}
@media (max-width: 720px) {
  .tour { padding-top: 24px; padding-bottom: 64px; }
  .progress { margin-bottom: 28px; }
  .progress ol { gap: 4px; }
  .progress a { text-align: center; }
  .progress span { display: none; }
  .progress b { margin-right: 0; }
  .step-grid { gap: 24px; }
  .story { gap: 12px; }
  .story p { font-size: 16px; }
  .story .lede { font-size: 17px; }
  .remus-card { padding: 14px; }
  .facts div { grid-template-columns: 76px minmax(0, 1fr); gap: 12px; }
  .route { padding-left: 20px; }
  .route::before { width: 6px; }
  .route-pillar { padding: 14px 16px; }
  .gantt { --lab: 0px; gap: 4px; }
  .g-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .g-row + .g-row { margin-top: 4px; }
  .g-who { font-size: 12px; }
  .g-days i { display: none; }
  .g-bar { padding: 0 4px; font-size: 10px; }
  .g-bar.len1 { color: transparent; }
  .day li { grid-template-columns: 48px minmax(0, 1fr); }
  .day .state { grid-column: 2; justify-self: start; }
  .o-line { grid-template-columns: minmax(0, 1fr) auto; }
  .o-line .state { grid-column: 2; justify-self: end; }
}
@media (max-width: 480px) {
  .demo-page .top .login { display: none; }
  .demo-page .top .pill-small { margin-left: auto; }
}

/* The note that the dossier is made up, above the footer. */
.demo-fictive {
  padding: 24px max(var(--gutter), calc((100% - var(--max)) / 2)) 0;
  color: var(--grey);
  font-size: 14px;
}
