/* "Under the bonnet", the page about the workshop. Loads after site.css and service.css.
   The opening view is a job card: what the driver tells us, what we find and what we do about it, with one fault
   signal running through all three, over the tools of the trade faded into the black. */

/* ---------- Opening view: the heading's row, then the card ---------- */
.bon-top {
  --pad-top: clamp(16px, 4vh, 48px);
  --pad-x: max(var(--edge), calc((100vw - 1600px) / 2));
  position: relative; isolation: isolate; overflow-x: clip;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; row-gap: clamp(28px, 5vh, 56px);
  min-height: calc(100vh - var(--head));
  padding: var(--pad-top) var(--pad-x) clamp(20px, 4vh, 40px);
}
/* The svh height sits in @supports: beside var(), a browser that doesn't know svh would drop it rather than fall back. */
@supports (height: 1svh) { .bon-top { min-height: calc(100svh - var(--head)); } }
/* The tool drawer fills the heading's row only, from the header down to just above the card. It fades in from the
   left and out towards the bottom, so the words and the whole card sit on black. */
.bon-top__art {
  grid-area: 1 / 1; z-index: -1; position: relative; justify-self: end; align-self: stretch;
  width: min(80vw, 1500px); margin: calc(-1 * var(--pad-top)) calc(-1 * var(--pad-x)) 0 0;
  pointer-events: none; user-select: none;
}
.bon-top__art img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 70% 30%; opacity: 0.6;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 45%), linear-gradient(#000 35%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 45%), linear-gradient(#000 35%, transparent);
  mask-composite: intersect;
}
.bon-hero { grid-area: 1 / 1; align-self: center; max-width: 42rem; padding-bottom: 2vh; }
.bon-title {
  margin: 0 0 20px; font-size: clamp(2.5rem, 1.1rem + 4.6vw, 5.5rem); font-weight: 800;
  line-height: 1; letter-spacing: -0.03em; text-wrap: balance;
}
.bon-lede {
  margin: 0 0 30px; max-width: 30rem; color: var(--soft); font-size: clamp(1.08rem, 1rem + 0.4vw, 1.32rem);
  line-height: 1.5; text-wrap: pretty; text-shadow: 0 0 18px #000, 0 0 3px #000;
}
.bon-actions { margin: 0; }

/* ---------- The job card ---------- */
.card { grid-area: 2 / 1; position: relative; }
.card__head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 32px;
  padding: 13px 0; border-top: 1px solid var(--rule);
}
.card__title { margin: 0; font-size: clamp(1.15rem, 1rem + 0.5vw, 1.45rem); font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }
.card__vehicle { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.card__key { color: var(--muted); font-size: 0.9rem; }
.ticks { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; padding: 0; list-style: none; }
.ticks li { display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; font-weight: 700; line-height: 1.2; }
/* Ticked by hand: the stroke runs past the box, as a pen does. */
.tick { flex: none; width: 18px; height: 18px; overflow: visible; }
.tick rect { fill: none; stroke: var(--muted); stroke-width: 1.25; }
.tick path { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.card__fields {
  --pad: clamp(16px, 1.8vw, 28px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) minmax(0, 1fr);
  margin: 0; padding: 0; list-style: none;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.field { position: relative; padding: 16px var(--pad) 28px; min-height: clamp(200px, 28vh, 290px); }
.field + .field { border-left: 1px solid var(--rule); }
.field__label { margin: 0; font-size: clamp(1.05rem, 0.95rem + 0.35vw, 1.3rem); font-weight: 800; line-height: 1.2; letter-spacing: -0.01em; }

/* The fault signal: each field draws its own stretch of it, edge to edge, so the three join across the rules. */
.trace { position: relative; height: clamp(52px, 7.5vh, 84px); margin: 12px calc(-1 * var(--pad)) 16px; }
.trace svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trace path { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.trace .trace__noise { stroke: var(--muted); }
.trace .trace__spike { stroke: var(--accent); stroke-width: 2; }
.trace .trace__clean { stroke: var(--ink); }
/* The one spike that is the fault, marked the way the service pages mark a part. */
.found { position: absolute; left: 50.5%; top: 4%; width: 0; height: 0; pointer-events: none; }
.found__dot {
  position: absolute; left: -4.5px; top: -4.5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 1.5px #fff, 0 1px 6px 2px rgba(0, 0, 0, 0.6);
}
.found__line { position: absolute; left: 9px; top: -0.75px; width: 26px; height: 1.5px; background: var(--accent); transform-origin: 0 50%; }
.found__text {
  position: absolute; left: 42px; top: 0; translate: 0 -50%; white-space: nowrap;
  font-size: 0.875rem; font-weight: 700; line-height: 1.25; letter-spacing: 0.01em; text-shadow: 0 1px 10px #000, 0 0 2px #000;
}

.field__value {
  position: relative; margin: 0; max-width: 26ch; color: var(--soft); font-size: 1.0625rem; line-height: 1.55;
  text-wrap: pretty; text-shadow: 0 0 14px #000, 0 0 3px #000;
}
.field--cause .field__value { max-width: 30ch; }
/* Each field's tool sits to the right of its words and runs on down past the card's bottom rule, fading out on
   every side, so no cell edge cuts it. The rules and the words are drawn over it. */
.field__tool {
  position: absolute; z-index: -1; height: auto; opacity: 0.3; pointer-events: none; user-select: none;
  -webkit-mask-image: radial-gradient(70% 70% at 50% 50%, #000 50%, transparent);
  mask-image: radial-gradient(70% 70% at 50% 50%, #000 50%, transparent);
}
.field--complaint .field__tool { right: -2%; bottom: -36%; width: 64%; }
.field--cause .field__tool { right: 2%; bottom: -40%; width: 46%; }
.field--correction .field__tool { right: -4%; bottom: -44%; width: 70%; }

/* ---------- Who's under the bonnet: a short piece on the workshop and the engine shop behind it. It takes the place
   of the booking form (the page's Book links go to the contact page's). It sits on the job card's frame and columns:
   the heading under "Job card" at the left edge, the words starting where the Cause field's do, and the card's bottom
   rule as the one line between them. The meter is faded in behind the heading's column on wide screens. ---------- */
.bon-story {
  --pad-x: max(var(--edge), calc((100vw - 1600px) / 2)); /* as .bon-top */
  position: relative; isolation: isolate; overflow-x: clip;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.35fr); row-gap: 16px; /* the card's 1 : 1.35 + 1 */
  margin: clamp(48px, 8vh, 88px) 0 0; padding: 0 var(--pad-x) clamp(72px, 12vh, 128px);
}
.bon-story h2 { margin: 0; font-size: clamp(1.45rem, 1.2rem + 0.9vw, 1.9rem); font-weight: 800; line-height: 1.15; letter-spacing: -0.015em; text-wrap: balance; }
.bon-story__text { padding-left: clamp(16px, 1.8vw, 28px); } /* the card's field padding */
.bon-story__text p { margin: 0 0 1em; max-width: 62ch; color: var(--soft); font-size: 1.0625rem; line-height: 1.7; text-wrap: pretty; }
.bon-story__text p:last-child { margin-bottom: 0; }
.bon-story__text .bon-story__lead { max-width: 46ch; color: var(--ink); font-size: clamp(1.15rem, 1.05rem + 0.4vw, 1.35rem); line-height: 1.5; } /* ends at or before the paragraph under it */
.bon-story__tool {
  position: absolute; z-index: -1; left: max(0px, calc(var(--pad-x) - 56px)); top: 40px; width: min(20vw, 260px); height: auto;
  opacity: 0.26; pointer-events: none; user-select: none;
  -webkit-mask-image: radial-gradient(70% 70% at 50% 50%, #000 50%, transparent);
  mask-image: radial-gradient(70% 70% at 50% 50%, #000 50%, transparent);
}

/* ---------- Motion: the drawer fades up, the boxes are ticked, then the signal sweeps across once ---------- */
@media (prefers-reduced-motion: no-preference) {
  .bon-top__art img { animation: bon-img-in 1.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
}
@media (prefers-reduced-motion: no-preference) and (min-width: 960px) {
  .tick path { stroke-dasharray: 1; animation: bon-tick 0.34s cubic-bezier(0.4, 0, 0.2, 1) both; animation-delay: calc(0.35s + var(--i) * 0.09s); }
  /* One sweep at one speed: each field's share of the time matches its share of the width (1 : 1.35 : 1). */
  .field--complaint { --dur: 0.54s; --at: 0.8s; }
  .field--cause { --dur: 0.73s; --at: 1.34s; }
  .field--correction { --dur: 0.54s; --at: 2.07s; }
  .trace svg { animation: bon-sweep var(--dur) linear both; animation-delay: var(--at); }
  .found__dot { animation: bon-pop 0.42s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: 1.72s; }
  .found__line { animation: bon-grow 0.3s cubic-bezier(0.4, 0, 0.2, 1) both; animation-delay: 1.86s; }
  .found__text { animation: bon-fade 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: 1.98s; }
}
/* On phones the card is further down, so each stretch of the signal draws as it rises through the lower part of
   the screen, and is whole by the time it is read. Where the browser can't tie motion to scrolling, the signal is
   simply there. */
@media (prefers-reduced-motion: no-preference) and (max-width: 959px) {
  @supports (animation-timeline: view()) {
    .trace { view-timeline-name: --trace; }
    .trace svg { animation: bon-sweep linear both; animation-timeline: --trace; animation-range: entry 100% cover 30%; }
    .found__dot { animation: bon-pop linear both; animation-timeline: --trace; animation-range: cover 18% cover 21%; }
    .found__line { animation: bon-grow linear both; animation-timeline: --trace; animation-range: cover 20% cover 23%; }
    .found__text { animation: bon-fade linear both; animation-timeline: --trace; animation-range: cover 22% cover 27%; }
  }
}
@keyframes bon-img-in { from { opacity: 0; } }
@keyframes bon-tick { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes bon-sweep { from { clip-path: inset(-40% 100% -40% 0); } to { clip-path: inset(-40% 0 -40% 0); } }
@keyframes bon-pop { from { scale: 0; opacity: 0; } }
@keyframes bon-grow { from { scale: 0 1; } }
@keyframes bon-fade { from { opacity: 0; } }

/* Short laptop screens: a smaller heading and a lower card, so the card stays in the first screen. */
@media (min-width: 960px) and (max-height: 700px) {
  .bon-title { font-size: clamp(2.5rem, 0.8rem + 4vw, 4.4rem); margin-bottom: 14px; }
  .bon-lede { margin-bottom: 22px; }
  .trace { height: 52px; margin-top: 8px; margin-bottom: 12px; }
  .field { min-height: 0; padding-top: 12px; padding-bottom: 20px; }
}

/* ---------- Phones: the words first, then the card with its fields stacked. The signal wraps with them, a
   stretch per field like a printed strip chart, and runs to both edges of the screen. ---------- */
@media (max-width: 959px) {
  .bon-top { --pad-top: 26px; grid-template-rows: auto auto; row-gap: clamp(36px, 7vh, 56px); min-height: 0; padding-bottom: 8px; }
  .bon-top__art { justify-self: stretch; width: auto; margin: calc(-1 * var(--pad-top)) calc(-1 * var(--edge)) 0; }
  .bon-top__art img {
    opacity: 0.5; object-position: 72% 35%;
    -webkit-mask-image: linear-gradient(to right, transparent 10%, #000 55%), linear-gradient(#000 30%, transparent);
    mask-image: linear-gradient(to right, transparent 10%, #000 55%), linear-gradient(#000 30%, transparent);
  }
  .bon-hero { align-self: start; max-width: 36rem; padding-bottom: 0; }
  .bon-title { margin-bottom: 14px; }
  .bon-lede { margin-bottom: 22px; }
  .card__head { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 0 16px; }
  .card__fields { --pad: 0px; grid-template-columns: minmax(0, 1fr); }
  .field { min-height: 0; padding: 18px 0 26px; }
  .field + .field { border-left: 0; border-top: 1px solid var(--rule); }
  .trace { height: 64px; margin-inline: calc(-1 * var(--edge)); }
  .field__value, .field--cause .field__value { max-width: 28ch; }
  .field--complaint .field__tool, .field--cause .field__tool, .field--correction .field__tool {
    right: calc(-1 * var(--edge)); bottom: -24%; width: min(46%, 220px);
  }
  .field--cause .field__tool { width: min(38%, 180px); }
  /* One column; the meter stays off, since here it could only sit behind the words. */
  .bon-story { grid-template-columns: minmax(0, 1fr); margin-top: clamp(40px, 7vh, 56px); }
  .bon-story__text { padding-left: 0; }
  .bon-story__tool { display: none; }
}

/* Phones: the vehicle label stays on the line with its boxes, which sit three and two. */
@media (max-width: 559px) {
  .card__vehicle { flex-wrap: nowrap; align-items: baseline; gap: 14px; }
  .ticks { display: grid; grid-template-columns: repeat(3, max-content); gap: 10px 16px; }
}
/* The narrowest phones: the boxes go under the label, still three and two. */
@media (max-width: 359px) {
  .card__vehicle { flex-wrap: wrap; }
}

/* Short phones: a smaller heading, so the heading, the line and the button land in the first screen. */
@media (max-width: 959px) and (orientation: portrait) and (max-height: 600px) {
  .bon-top { --pad-top: 16px; }
  .bon-title { font-size: clamp(2rem, 1.3rem + 3.5vw, 2.4rem); margin-bottom: 10px; }
  .bon-lede { font-size: 1rem; line-height: 1.45; margin-bottom: 16px; }
}

/* Phones on their side: the same order, tighter, with the drawer behind the right-hand side of the heading. */
@media (max-width: 959px) and (orientation: landscape) and (max-height: 520px) {
  .bon-top { --pad-top: 14px; }
  .bon-top__art { justify-self: end; width: 72%; margin-left: 0; }
  .bon-hero { max-width: 64%; }
  .bon-title { font-size: clamp(1.9rem, 1rem + 3vw, 2.5rem); margin-bottom: 10px; }
  .bon-lede { font-size: 1rem; line-height: 1.45; margin-bottom: 16px; }
}
