/* ClearMile, the case study (work/clearmile.html only). The record on the brief, the process drawn as pieces that the
   flick joins into one line, and the portal drawn from its design, labelled as drawn. The type is the site's own
   (Tiempos, National, Söhne Mono); ClearMile's cyan appears only where things join. */

/* ---------- the record: cm-record.css styles it; here it holds still, in the design's last state, on the brief ----------
   The title no longer dives into it (Adam, 5 Nov 2026): the title is a screen of its own, its letters on plain white as
   they always read, and the brief slides up over it with the record on it */
/* the card, its send bar and the note stand in one column (on the homepage cm-record.js places them one by one) */
/* centred with translate, not transform: translate applies after the scale cm-story.js may give it, so it stays centred */
#the-brief .cm-col { position: absolute; left: 50%; top: calc(50% - 1svh); width: min(44vw, 480px); translate: -50% -50%;
  display: grid; gap: 14px; }
#the-brief .cmrec .cm-card, #the-brief .cmrec .cm-send { position: relative; left: auto; top: auto; width: auto; }
#the-brief .cm-note { margin: 2px 0 0; text-align: center; color: var(--chalk-2); }
/* the record's own type (Inter, Space Grotesk) is in before a word of it shows (cm-story.js) */
#the-brief .cmrec:not(.fonts-in) .cm-card > *, #the-brief .cmrec:not(.fonts-in) .cm-send { visibility: hidden; }
/* beat 1's line sits on the navy under the record: its shade stays low, so it never greys the card */
#the-brief .grade-b { background: linear-gradient(to top, rgba(14, 13, 12, .9) 0, rgba(14, 13, 12, .62) 12%, rgba(14, 13, 12, 0) 26%); }
/* a phone, or any short screen: the record rises clear of beat 1's line (cm-story.js scales it down if it must) */
@media (max-aspect-ratio: 1/1), (max-height: 560px) {
  #the-brief .cm-col { top: calc(var(--mast) + 2svh); width: min(90vw, 440px); translate: -50% 0; transform-origin: 50% 0; }
}
/* a wide screen: the record stands in the right half at its full size, beside the brief, as the other case studies'
   pictures do (Adam, 5 Nov 2026: "the brief screen on desktop for clear mile the image is tiny looks broken": held in
   the middle, clear of the brief's two paragraphs, it had shrunk to its smallest and still ran into them) */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) { #the-brief .cm-col { left: 75%; width: min(40vw, 480px); } }

/* ---------- beats 3 to 5: the pieces join ----------
   One drawing for three shots, driven by the scene's shot position (--s, from film.js), so it follows the thumb
   and rests composed at each stop. --A (shots 0 to 1) lines the pieces up; --B (shots 1 to 2) closes the gaps and
   draws the line through them. Both are smoothstepped, so each stop is a rest, not a pause mid move. Between the
   stops the drawing takes the whole frame (--m), centred while it has no words, and makes room for them again. */
#story {
  --a: clamp(0, var(--s, 0), 1); --b: clamp(0, var(--s, 0) - 1, 1);
  --A: calc(var(--a) * var(--a) * (3 - 2 * var(--a))); --B: calc(var(--b) * var(--b) * (3 - 2 * var(--b)));
  --m: min(var(--A), 1 - var(--B));
  --u: calc((var(--B) - .1) / .85 * 4); /* how far the line has travelled: 0 at the first piece, 4 at the last */
}
.pc { background: var(--night); }
.pc-field { position: absolute; left: var(--pad); right: var(--pad); top: calc(var(--mast) + 12px);
  height: calc((42svh - 22px + 8svh * var(--B)) * (1 - var(--m)) + (100svh - var(--mast) - var(--foot) - 36px) * var(--m)); }
.pc-p { --ph: clamp(40px, 7.2svh, 48px); --gap: 12px; --w0: 168px; --cw: min(100%, 320px); --r: calc(10px * (1 - var(--B)));
  position: absolute; box-sizing: border-box; height: var(--ph); display: flex; align-items: center; gap: 13px; padding: 0 16px;
  width: calc(var(--w0) * (1 - var(--A)) + var(--cw) * var(--A));
  left: calc(var(--x0) * (1 - var(--A)) + 50% * var(--A));
  top: calc(var(--y0) * (1 - var(--A)) + (50% + (var(--n) - 2) * (var(--ph) + var(--gap) * (1 - var(--B)) - 1px * var(--B))) * var(--A));
  transform: translate(-50%, -50%) rotate(calc(var(--r0) * (1 - var(--A))));
  background: var(--night-2); border: 1px solid rgba(243, 239, 231, .2); border-radius: var(--r);
  font-family: var(--font-text); font-weight: 400; font-size: 1.0625rem; line-height: 1.2; color: var(--chalk); white-space: nowrap; }
.pc-p:nth-of-type(1) { border-radius: 10px 10px var(--r) var(--r); }
.pc-p:last-of-type { border-radius: var(--r) var(--r) 10px 10px; }
.pc-p > span { opacity: calc(.72 + .28 * var(--A)); }
/* the knot on each piece: a ring while the tools are apart, ClearMile's cyan once the line reaches it */
.pc-k { position: relative; z-index: 1; flex: none; width: 11px; height: 11px; border-radius: 50%; box-sizing: border-box;
  border: 1.5px solid var(--chalk-2); background: var(--night-2); }
.pc-k::after { content: ""; position: absolute; inset: -1.5px; border-radius: 50%; background: var(--cm-cyan);
  opacity: clamp(0, (var(--u) - var(--n)) / .25 + 1, 1); }
/* the line, drawn in halves inside each piece so it passes under the knots, and bridging the closing gaps */
.pc-p::before, .pc-p::after { content: ""; position: absolute; left: 20.5px; width: 2px; background: var(--cm-cyan); }
.pc-p::before { top: calc(-1px - (var(--gap) * (1 - var(--B)) - 1px * var(--B)) / 2); bottom: 50%; transform-origin: 50% 0;
  transform: scaleY(clamp(0, (var(--u) - var(--n)) * 2 + 1, 1)); }
.pc-p::after { top: 50%; bottom: calc(-1px - (var(--gap) * (1 - var(--B)) - 1px * var(--B)) / 2); transform-origin: 50% 0;
  transform: scaleY(clamp(0, (var(--u) - var(--n)) * 2, 1)); }
.pc-p:nth-of-type(1)::before, .pc-p:last-of-type::after { display: none; }
/* how it moved before: by email, by hand (gone as soon as the pieces start to line up) */
.pc-by { position: absolute; left: var(--x0); top: var(--y0); display: flex; align-items: center; gap: 8px; color: var(--chalk-2); white-space: nowrap;
  opacity: clamp(0, 1 - var(--A) * 2.5, 1); }
.pc-by::before { content: ""; width: 22px; border-top: 1px dashed var(--chalk-2); }

/* ---------- the reading screens on this page ---------- */
/* a phone: the longest beats (3 and 8) give their words more of the screen, so they never reach the foot */
.read-pic.long { height: 42svh; }
.read.long { top: calc(var(--mast) + 42svh + 18px); }

/* type alone on night: a whole sentence, set as a title card at a size it can hold */
.card-fig.words.long { font-size: clamp(1.75rem, 1.5vw + 1.25rem, 3.25rem); line-height: 1.12; letter-spacing: -.02em; max-width: 17em; }

/* the dates: set large, joined by the line of the build between them */
.cm-dates .card-fig.words { line-height: 1; }
.cm-span { display: block; width: 2px; height: clamp(36px, 6svh, 64px); margin: 16px 0; background: var(--cm-cyan); transform-origin: 50% 0;
  transform: scaleY(var(--e, 1)); }
.cm-say { margin-top: 30px; font-family: var(--font-display); font-weight: 500; font-size: var(--t-lede); line-height: 1.28; letter-spacing: -.008em;
  color: var(--chalk); max-width: 19em; }

/* ---------- the portal, drawn from its design (beats 7 and 8): never a screenshot, and labelled so ---------- */
.read-pic.dg { display: grid; place-items: center; box-sizing: border-box; padding: 10px var(--pad) 4px; }
.dg figure { width: 100%; max-width: 360px; margin: 0; }
.dg-cap { margin-top: 12px; text-align: center; color: var(--chalk-2); }
.dg-panel { background: var(--night-2); border: 1px solid var(--rule-dark); border-radius: 12px; overflow: hidden; }
.dg-h { padding: 12px 18px 11px; color: var(--chalk-2); border-bottom: 1px solid var(--rule-dark); }
.dg-list li { position: relative; padding: 10px 18px 10px 42px; font-size: 1.0625rem; line-height: 1.3; }
.dg-list li + li { border-top: 1px solid rgba(243, 239, 231, .08); }
.dg-list li::before { content: ""; position: absolute; left: 18px; top: calc(10px + .66em); width: 12px; height: 1px; background: var(--chalk-2); }
.dg-sub { display: grid; gap: 3px; margin-top: 5px; }
.dg-sub span { position: relative; padding-left: 16px; font-size: 1rem; color: var(--chalk-2); }
.dg-sub span::before { content: ""; position: absolute; left: 1px; top: .62em; width: 5px; height: 5px; border-radius: 50%; border: 1px solid var(--chalk-2); }
/* the flow: one line that forks; held is dashed (it waits), cleared takes the cyan (it goes out on its own) */
.cmf { display: grid; justify-items: center; }
.cmf > li { position: relative; width: 100%; display: grid; justify-items: center; }
.cmf > li + li { margin-top: 24px; }
.cmf > li + li::before { content: ""; position: absolute; left: 50%; top: -24px; height: 24px; width: 1px; background: var(--chalk-2); }
.cmf-n { display: grid; justify-items: center; text-align: center; box-sizing: border-box; min-width: 62%; padding: 9px 14px 10px;
  background: var(--night-2); border: 1px solid var(--rule-dark); border-radius: 10px; font-size: 1.0625rem; line-height: 1.25; }
.cmf-n .lab { margin-top: 3px; color: var(--chalk-2); line-height: 1.35; }
.cmf-fork { --fg: 12px; grid-template-columns: 1fr 1fr; gap: var(--fg); padding-top: 14px; }
.cmf > li.cmf-fork::before { height: 38px; top: -24px; }
.cmf-fork::after { content: ""; position: absolute; top: 14px; left: calc(25% - var(--fg) / 4); right: calc(25% - var(--fg) / 4); height: 1px; background: var(--chalk-2); }
.cmf-fork .cmf-n { min-width: 0; width: 100%; position: relative; margin-top: 14px; }
.cmf-fork .cmf-n::before { content: ""; position: absolute; left: 50%; top: -15px; height: 14px; width: 1px; background: var(--chalk-2); }
.cmf-held { border-style: dashed; border-color: rgba(243, 239, 231, .34); }
.cmf-ok { border-color: rgba(58, 172, 217, .7); }
.cmf-fork .cmf-ok::before { background: var(--cm-cyan); }

/* a short phone: the drawings close up a little before cm-story.js has to make them smaller */
@media (max-aspect-ratio: 1/1) and (max-height: 640px) {
  .dg-h { padding-block: 9px 8px; }
  .dg-list li { padding-block: 7px; }
  .dg-list li::before { top: calc(7px + .66em); }
  .cmf > li + li { margin-top: 16px; }
  .cmf > li + li::before { top: -16px; height: 16px; }
  .cmf > li.cmf-fork::before { top: -16px; height: 26px; }
  .cmf-fork { padding-top: 10px; }
  .cmf-fork::after { top: 10px; }
  .cmf-fork .cmf-n { margin-top: 10px; }
  .cmf-fork .cmf-n::before { top: -11px; height: 10px; }
  .cmf-n { padding-block: 6px 7px; }
  .dg-cap { margin-top: 9px; }
}

/* ---------- the prototypes: real captures, desktop ones, shown whole on a phone too (never cut) ---------- */
.read-pic.shot { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; box-sizing: border-box; padding: 10px var(--pad) 6px; }
#story .read-pic.shot > img { position: static; inset: auto; width: auto; height: auto; max-width: 100%; max-height: calc(100% - 32px);
  object-fit: contain; border-radius: 6px; box-shadow: 0 0 0 1px rgba(243, 239, 231, .12); }
.shot-cap { color: var(--chalk-2); text-align: center; }

/* ---------- a wide screen: the same beats, laid out for it ---------- */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .pc-field { left: 5vw; top: calc(var(--mast) + 5vh); bottom: 5vh; height: auto; right: calc(50% * (1 - var(--m)) + 5vw * var(--m)); }
  .pc-p { --ph: 64px; --gap: 16px; --w0: 240px; --cw: min(100%, 460px); gap: 16px; padding: 0 24px; font-size: 1.25rem; }
  .pc-p::before, .pc-p::after { left: 28.5px; }
  .read-pic.long { height: auto; }
  .read.long { top: var(--mast); }
  .read-pic.dg { padding: 0 3vw; }
  .dg figure { max-width: 480px; }
  .dg-h { padding: 16px 26px 15px; }
  .dg-list li { padding: 15px 26px 15px 54px; font-size: 1.25rem; }
  .dg-list li::before { left: 26px; top: calc(15px + .66em); }
  .dg-sub span { font-size: 1.125rem; }
  .cmf > li + li { margin-top: 34px; }
  .cmf > li + li::before { top: -34px; height: 34px; }
  .cmf > li.cmf-fork::before { top: -34px; height: 48px; }
  .cmf-n { padding: 14px 22px 15px; font-size: 1.25rem; }
  .cmf-fork { --fg: 18px; }
  .read-pic.shot { padding: 0; gap: 16px; }
}

/* reduced motion: the film cuts from rest to rest (film.js rounds --s), so nothing here moves: the pieces rest at
   each stop; the dates' line is simply there */
html.reduced .cm-span { transform: none; }
