/* Our promises: nine promises, one stroke.
   Paula Scher, the Public Theater season poster (1995-96): one colossal word runs down the sheet at ninety degrees, justified blocks
   lock beside it, one figure bursts through. Here the figure is our stroke: a promise is a line you don't break, so the pen never lifts.
   Persimmon from the cover to the footer. Ink only. No Paper, no rules, no second colour.

   THE FIT. Every line is set so its INK (not its box) runs from the column's left edge to its right edge. Each line carries three
   numbers measured once from the real font (Newsreader 500, opsz 72, -.012em): --e the ink width in em, --x where the ink starts
   from the text origin in em, --d how far the ink falls below the baseline in em. Then it is only arithmetic:
       font-size = column width / --e        margin-left = -(--x) em
   The column is a size container, so the arithmetic is done by the browser at every width and needs no script.
   Where a promise would fall under 34px it breaks into two lines, each fitted on its own (the @container blocks below).

   THE STROKE. promises.js draws one SVG path across the stack: off the first full stop, back under the line, under every
   promise in turn (boustrophedon), round the margin at each end, and into the full stop of "Let's talk." Without script the
   same bars stand under each promise as plain rules. Geometry is read from the layout, never guessed. */

/* ------------------------------------------------------------------ the page's own tokens */
.p-promises{
  --mx:clamp(24px,5.2vw,64px);
  --sw:clamp(4px,.625vw,12px);              /* the pen: 8px at 1280, 4px on a phone */
  --o:clamp(11px,1.75vw,36px);              /* how far the pen swings out past the column when it turns */
  --r:clamp(12px,2vw,32px);                 /* the corner of a turn */
  --dl:.2333;                               /* the descender line, in em: every bar runs along it, so the pen keeps one rhythm under every promise */
  --gp:max(.075em,8px);                     /* the deepest ink to the stroke: the nearest the pen comes to a letter */
  --sg:14px;                                /* stroke to its sentence (the line box; the type itself sits about 18px under) */
  --gap:clamp(24px,2.8vw,48px);             /* a sentence to the next promise */
  --sf:clamp(18px,calc(11.6px + .5vw),26px);
  background:var(--persimmon);
  color:var(--ink);
}
@media (min-width:1440px){ .p-promises{ --mx:max(64px,calc((100vw - 1680px) / 2)) } }
.p-promises main{background:var(--persimmon)}
.p-promises .stop{color:inherit}
.p-promises ::selection{background:var(--ink);color:var(--persimmon)}

/* ------------------------------------------------------------------ the sheet */
.pw{container-type:inline-size}
.poster{position:relative;padding:calc(56px + clamp(12px,1.5vw,30px)) var(--mx) clamp(72px,9vw,136px)}
.stack,.pback{container-type:inline-size;min-width:0}

/* every fitted line: one face, one setting, never wraps */
.ph,.lead,.pr__h,.pr__h .u,.bk{
  font-family:var(--serif);font-weight:500;line-height:1;letter-spacing:-.012em;white-space:nowrap;
  font-variation-settings:"opsz" 72;font-kerning:normal;text-rendering:geometricPrecision;
}

/* the title: narrow it lies flat across the top, wide it stands up the left edge and runs the height of the promises */
.ph{
  margin:0 0 clamp(14px,2.4vw,24px) calc(-.0458em);
  font-size:calc((100cqw - 2 * var(--mx)) / 6.1875);
}

/* the standfirst */
.lead{
  margin:0 0 clamp(20px,3vw,34px);max-width:24em;
  font:italic 400 clamp(21px,5.6vw,30px)/1.22 var(--serif);letter-spacing:0;white-space:normal;text-wrap:balance;
  font-variation-settings:"opsz" 36;text-rendering:optimizeLegibility;
}

/* ------------------------------------------------------------------ a promise */
.pr{margin-top:var(--gap)}
.lead + .pr{margin-top:0}
.pr__h{
  margin:0 0 var(--sg) calc(var(--x) * -1em);
  font-size:calc(100cqw / var(--e));
}
/* the stroke's own bar, in layout: with script it is drawn by the pen and this one is clear */
.pr__h::after,.bk1::after{
  content:"";display:block;height:var(--sw);background:var(--ink);
  margin:calc((var(--dl) - .2667) * 1em + var(--gp)) 0 0 calc(var(--x) * 1em);
}
.js .pr__h::after,.js .bk1::after{background:transparent}
.pr__h .u{display:inline}
.pr__p{
  max-width:36em;margin:0;
  font:500 var(--sf)/1.4 var(--sans);text-wrap:pretty;
}

/* where one line would fall under 34px, the promise breaks in two and each line is fitted by itself.
   34px x --e of the whole line is the container width below which that happens. */
@container (width < 331px){
  .pr--2 .pr__h{margin-left:0}
  .pr--2 .pr__h::after{display:none}
  .pr--2 .u{display:block;font-size:calc(100cqw / var(--e));margin-left:calc(var(--x) * -1em)}
  .pr--2 .u2::after{content:"";display:block;height:var(--sw);background:var(--ink);margin:calc((var(--dl) - .2667) * 1em + var(--gp)) 0 0 calc(var(--x) * 1em)}
  .js .pr--2 .u2::after{background:transparent}
}
@container (width < 388px){
  .pr--3 .pr__h{margin-left:0}
  .pr--3 .pr__h::after{display:none}
  .pr--3 .u{display:block;font-size:calc(100cqw / var(--e));margin-left:calc(var(--x) * -1em)}
  .pr--3 .u2::after{content:"";display:block;height:var(--sw);background:var(--ink);margin:calc((var(--dl) - .2667) * 1em + var(--gp)) 0 0 calc(var(--x) * 1em)}
  .js .pr--3 .u2::after{background:transparent}
}
@container (width < 409px){
  .pr--6 .pr__h{margin-left:0}
  .pr--6 .pr__h::after{display:none}
  .pr--6 .u{display:block;font-size:calc(100cqw / var(--e));margin-left:calc(var(--x) * -1em)}
  .pr--6 .u2::after{content:"";display:block;height:var(--sw);background:var(--ink);margin:calc((var(--dl) - .2667) * 1em + var(--gp)) 0 0 calc(var(--x) * 1em)}
  .js .pr--6 .u2::after{background:transparent}
}
@container (width < 455px){
  .pr--7 .pr__h{margin-left:0}
  .pr--7 .pr__h::after{display:none}
  .pr--7 .u{display:block;font-size:calc(100cqw / var(--e));margin-left:calc(var(--x) * -1em)}
  .pr--7 .u2::after{content:"";display:block;height:var(--sw);background:var(--ink);margin:calc((var(--dl) - .2667) * 1em + var(--gp)) 0 0 calc(var(--x) * 1em)}
  .js .pr--7 .u2::after{background:transparent}
}
@container (width < 381px){
  .pr--8 .pr__h{margin-left:0}
  .pr--8 .pr__h::after{display:none}
  .pr--8 .u{display:block;font-size:calc(100cqw / var(--e));margin-left:calc(var(--x) * -1em)}
  .pr--8 .u2::after{content:"";display:block;height:var(--sw);background:var(--ink);margin:calc((var(--dl) - .2667) * 1em + var(--gp)) 0 0 calc(var(--x) * 1em)}
  .js .pr--8 .u2::after{background:transparent}
}
@container (width < 286px){
  .pr--9 .pr__h{margin-left:0}
  .pr--9 .pr__h::after{display:none}
  .pr--9 .u{display:block;font-size:calc(100cqw / var(--e));margin-left:calc(var(--x) * -1em)}
  .pr--9 .u2::after{content:"";display:block;height:var(--sw);background:var(--ink);margin:calc((var(--dl) - .2667) * 1em + var(--gp)) 0 0 calc(var(--x) * 1em)}
  .js .pr--9 .u2::after{background:transparent}
}

/* ------------------------------------------------------------------ the back cover: the question, the bar, the answer */
.pback{margin-top:var(--gap)}
.pback__h{margin:0}
.bk{display:block;margin-left:calc(var(--x) * -1em);font-size:calc(100cqw / var(--e))}
.bk1::after{margin-bottom:0}
.bk2{margin-top:clamp(18px,2.2vw,34px)}
.pback .back__act{margin-top:clamp(30px,3.4vw,56px)}
.pback .btn--ink{color:var(--persimmon)}
.pback .btn--ink:hover{background:transparent;color:var(--ink)}
.pback .btn--copy:hover{background:var(--ink);color:var(--persimmon)}
.pback .back__status{margin-top:clamp(22px,2.4vw,34px)}

/* ------------------------------------------------------------------ the pen */
.pen{position:absolute;left:0;top:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:3}
.pen__path{fill:none;stroke:var(--ink);stroke-width:var(--sw);stroke-linecap:round;stroke-linejoin:round}
.is-still .pen__path{stroke-dasharray:none !important}

/* ------------------------------------------------------------------ wide: the title stands up the left edge */
@media (min-width:700px){
  .lead{
    max-width:none;margin:0 0 clamp(20px,2.4vw,32px) .02em;
    font:italic 400 1em/1 var(--serif);font-size:calc(100cqw / 21.7167);letter-spacing:-.012em;white-space:nowrap;text-wrap:nowrap;
    font-variation-settings:"opsz" 72;text-rendering:geometricPrecision;
  }
}
@media (min-width:1000px){
  .poster{
    /* the title's size on first paint (and with no script): a straight line through the sizes the script settles on, 1000 to 2560 wide, never more than 3px off */
    --hfs:clamp(150px,calc(68.5px + .1903 * (100cqw - 2 * var(--mx))),400px);
    --t:calc(var(--hfs) * .9583);           /* the title's ink is .9583em thick */
    --g:calc(var(--o) * 2.1);               /* room for the pen to turn between the title and the promises */
    display:grid;grid-template-columns:var(--t) minmax(0,1fr);column-gap:var(--g);align-items:start;
  }
  .ph{
    grid-column:1;grid-row:1;height:0;
    writing-mode:vertical-rl;font-size:var(--hfs);
    margin:calc(-.0458em) 0 0 calc(-.0075em);
  }
  .stack{grid-column:2;grid-row:1}
  .pback{grid-column:2;grid-row:2}
}

/* ------------------------------------------------------------------ browsers without container units: one calm column */
@supports not (width:1cqw){
  .poster{display:block !important}
  .ph{writing-mode:horizontal-tb;height:auto;font-size:calc((100vw - 2 * var(--mx)) / 6.3)}
  .pr__h{font-size:calc((100vw - 2 * var(--mx)) / var(--e) * .95)}
  .bk{font-size:calc((100vw - 2 * var(--mx)) / var(--e) * .95)}
  .lead{font-size:clamp(21px,5.6vw,30px);white-space:normal}
}

/* ------------------------------------------------------------------ forced colours, print */
@media (forced-colors:active){
  .pen__path{stroke:CanvasText}
  .pr__h::after,.bk1::after,.pr__h .u2::after{background:CanvasText}
  .js .pr__h::after,.js .bk1::after,.js .pr__h .u2::after{background:transparent}
}
@media print{
  .p-promises,.p-promises main{background:none}
  .pen{display:none}
  .poster{display:block;padding:0}
  .ph,.lead,.pr__h,.pr__h .u,.bk{white-space:normal;margin:0;font-size:22pt !important;line-height:1.1;text-wrap:balance}
  .ph{writing-mode:horizontal-tb;height:auto;font-size:34pt !important;margin-bottom:8pt}
  .lead{font-size:13pt !important;font-style:italic;margin-bottom:10pt}
  .pr{margin-top:12pt;break-inside:avoid}
  .pr__h .u{display:inline}
  .pr__h::after,.pr__h .u2::after,.bk1::after{display:block !important;content:"";height:1.2pt;background:#000 !important;margin:3pt 0 5pt}
  .pr__h .u2::after{display:none !important}
  .pr__p{font-size:10.5pt;max-width:none}
  .pback{margin-top:16pt;break-inside:avoid}
  .pback .btn--ink{color:#000}
}
