/* thescottrocca.com articles: the reading page.
   Built by Bright Presence Digital, https://brightpresencedigital.com

   Everything an article needs to read well, in one file. Colour, faces and topic accents come
   from tokens.css and are only used here, never redefined.

   How the page is put together:
   1. One body size (--fs) grows gently with the window, and every other size and every gap is a
      multiple of it or of one line of body text (--line). That is what keeps the spacing even.
   2. Narrow windows get one centred column. From 1100px up the page is a deliberate two part
      composition: a margin on the left for the depth gauge, then the "stage". Text sits on the
      left of the stage at a comfortable measure, and pictures, the headline and pull quotes are
      allowed to run the full width of the stage. The whole composition is centred in the window,
      so a very wide window gets bigger type and bigger pictures, not a thin strip.
   3. Nothing animates in. The words are there when the page is. */

/* ------------------------------------------------------------------------------------------
   Layout values. The depth gauge reads these same names, so the two files cannot drift apart.
   ------------------------------------------------------------------------------------------ */
:root{
  /* Body size: 18px on a phone, 19px on a tablet, 21px on a wide desktop. */
  --fs:clamp(18px,17.2px + .22vw,21px);
  --line:calc(var(--fs) * 1.7);

  /* The reading column. The shared measure is counted in the width of a zero, and this face has
     wide figures, so on its own it lets a line run to about ninety letters. Capping it in ems
     holds a line of body text near seventy, which is where long reading stays easy. */
  --col:min(var(--measure),calc(var(--fs) * 34));

  /* Space between the window edge and anything on the page. */
  --page-pad:clamp(20px,5vw,64px);

  /* Narrow layout: the gauge is a strip across the top and the page starts below it. */
  --gauge-strip:44px;

  /* Wide layout (1100px and up): the gauge column, the gap between it and the stage, the widest
     the stage may grow, and where the left edge of the gauge column sits. */
  --gauge-w:clamp(200px,16vw,260px);
  --gauge-gap:clamp(40px,4vw,88px);
  --stage-max:calc(var(--fs) * 56);
  --frame-max:calc(var(--gauge-w) + var(--gauge-gap) + var(--stage-max));
  --gauge-left:max(var(--page-pad),calc((100vw - var(--frame-max)) / 2));
  --stage-left:calc(var(--gauge-left) + var(--gauge-w) + var(--gauge-gap));

  /* One face for the few places that show something typed: a command, a domain name. */
  --mono:ui-monospace,SFMono-Regular,Menlo,Consolas,'Liberation Mono',monospace;
}
@media (min-width:1100px){
  :root{--gauge-strip:0px}
}

/* ------------------------------------------------------------------------------------------
   Page furniture
   ------------------------------------------------------------------------------------------ */
html{scroll-padding-top:calc(var(--gauge-strip) + var(--line))}
body{
  font-family:var(--text);font-size:var(--fs);line-height:1.7;
  padding-top:var(--gauge-strip);
  font-kerning:normal;font-variant-ligatures:common-ligatures;
  font-optical-sizing:auto;
}
::selection{background:var(--accent);color:#fff}

a{color:inherit}
:focus-visible{outline:2px solid var(--accent-ink);outline-offset:3px;border-radius:2px}

/* Keyboard users get a way past the masthead. It stays off screen until it has focus. */
.skip{
  position:absolute;left:var(--page-pad);top:0;z-index:20;transform:translateY(-120%);
  padding:.55em 1em;background:var(--ink);color:var(--bg);
  font-family:var(--ui);font-size:.84em;font-weight:600;text-decoration:none;border-radius:0 0 3px 3px;
}
.skip:focus{transform:none;outline-offset:2px}

/* The masthead: who wrote this, and the way back to the list. Two quiet links, not pinned. */
.masthead{
  display:flex;flex-wrap:wrap;justify-content:space-between;align-items:baseline;
  gap:.4em 2em;
  margin:0 var(--page-pad);padding:calc(var(--line) * .9) 0 0;
  font-family:var(--ui);font-size:.84em;line-height:1.4;
}
.masthead a{color:var(--ink-quiet);text-decoration:none;padding:.35em 0;transition:color .2s}
.masthead a:hover{color:var(--ink)}
.masthead-home{font-family:var(--text);font-size:1.16em;font-weight:600;color:var(--ink-soft) !important}
.masthead-home:hover{color:var(--ink) !important}
.masthead-index{text-decoration:underline !important;text-decoration-color:var(--rule-strong) !important;
  text-decoration-thickness:1px !important;text-underline-offset:.3em}
.masthead-index:hover{text-decoration-color:var(--accent-ink) !important}

/* ------------------------------------------------------------------------------------------
   The page and the stage
   ------------------------------------------------------------------------------------------ */
.page{
  padding:0 var(--page-pad);
}
.story,.onward{max-width:var(--stage-max);margin-inline:auto}

/* ------------------------------------------------------------------------------------------
   The story header
   ------------------------------------------------------------------------------------------ */
.story-head{
  max-width:var(--col);margin-inline:auto;
  padding-top:calc(var(--line) * 2.5);
}

.story-topics{
  display:flex;flex-wrap:wrap;gap:.3em 1.6em;margin:0;
  font-family:var(--ui);font-size:.84em;font-weight:600;line-height:1.4;
}
.topic{
  display:inline-flex;align-items:center;gap:.6em;padding:.3em 0;
  color:var(--accent-ink);text-decoration:none;
}
/* A short rule in the topic's own colour stands in for a label or a badge. */
.topic::before{content:'';width:1.4em;height:2px;background:var(--accent);flex:none}
.topic:hover{text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:.3em}

.story-title{
  margin:calc(var(--line) * .75) 0 0;
  font-family:var(--display);font-weight:400;color:var(--ink);
  font-size:clamp(36px,20px + 4.2vw,56px);line-height:1.08;letter-spacing:-.005em;
  text-wrap:balance;overflow-wrap:break-word;
}
.story-dek{
  margin:calc(var(--line) * .9) 0 0;
  font-size:1.22em;line-height:1.5;font-style:italic;color:var(--ink-soft);
  text-wrap:pretty;
}
.story-meta{
  display:flex;flex-wrap:wrap;align-items:center;gap:.2em 0;
  margin:var(--line) 0 0;
  font-family:var(--ui);font-size:.84em;line-height:1.4;color:var(--ink-quiet);
  font-variant-numeric:lining-nums;
}
/* The date and the reading time are kept apart by a hairline, not by punctuation. */
.story-mins{margin-left:.9em;padding-left:.9em;border-left:1px solid var(--rule-strong)}
/* A note that the article was added to later. It takes a row of its own under the date at every
   width, so it never runs into the reading time and never wraps by accident. */
.story-updated{flex:0 0 100%;margin-top:.15em}
.story-updated::first-letter{text-transform:uppercase}

/* ------------------------------------------------------------------------------------------
   Pictures. One at a time, and wider than the text when there is room.
   ------------------------------------------------------------------------------------------ */
.hero-fig,.art-band{margin:0}
.hero-fig,.story > .hero-shot{margin-top:calc(var(--line) * 2)}

.hero-shot{
  display:block;position:relative;overflow:hidden;
  border:1px solid var(--rule-strong);border-radius:3px;
  background:var(--surface);
  transition:border-color .25s;
}
.hero-shot img,.art-band img{display:block;width:100%;height:auto}
.art-band img{border:1px solid var(--rule-strong);border-radius:3px;background:var(--surface)}

/* When the picture is a link, say where it goes. The words come from the link's own label so
   this one rule serves every article. */
a.hero-shot:hover,a.hero-shot:focus-visible{border-color:var(--accent-ink)}
a.hero-shot[aria-label]::after{
  content:attr(aria-label);
  position:absolute;left:0;bottom:0;max-width:100%;
  padding:.5em .9em;background:var(--bg);color:var(--ink);
  border-top:1px solid var(--accent-ink);border-right:1px solid var(--accent-ink);border-top-right-radius:3px;
  font-family:var(--ui);font-size:.8em;font-weight:600;line-height:1.3;
  opacity:0;transition:opacity .25s;
}
a.hero-shot:hover::after,a.hero-shot:focus-visible::after{opacity:1}

/* A caption lines up with the text column, not with the edge of the wider picture. */
figcaption{
  max-width:calc(var(--fs) * 34);margin:calc(var(--line) * .5) auto 0;padding-right:12%;
  font-family:var(--ui);font-size:.84em;line-height:1.5;color:var(--ink-quiet);
  text-wrap:pretty;
}

/* ------------------------------------------------------------------------------------------
   The body of the article
   The body is a three track grid: a spare track, the text measure, a spare track. Text always
   sits in the middle track. Anything that should run wide spans all three.
   ------------------------------------------------------------------------------------------ */
.article-content{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,var(--col)) minmax(0,1fr);
  margin-top:calc(var(--line) * 2);
  font-size:var(--fs);line-height:1.7;color:var(--ink-soft);
  hanging-punctuation:first allow-end last;
  font-variant-numeric:oldstyle-nums proportional-nums;
}
.article-content > *{grid-column:2;min-width:0;margin:var(--line) 0 0}
.article-content > :first-child{margin-top:0}

.article-content p{text-wrap:pretty;hyphens:manual}
.article-content strong,.article-content b{font-weight:600;color:var(--ink)}
.article-content em{font-style:italic}

/* The opening: a three line initial in the topic's ink. It is only switched on where the browser
   can place a raised initial on the baseline by itself, so it can never sit crooked. Everywhere
   else the article simply begins. */
@supports (initial-letter:3) or (-webkit-initial-letter:3){
  .article-content > p:first-child::first-letter{
    -webkit-initial-letter:3;initial-letter:3;
    margin-right:.14em;
    font-weight:500;color:var(--accent-ink);
  }
}

.article-content h2{
  margin-top:calc(var(--line) * 2.5);
  font-family:var(--text);font-weight:600;color:var(--ink);
  font-size:1.5em;line-height:1.22;letter-spacing:-.008em;
  text-wrap:balance;font-variant-numeric:lining-nums;
}
.article-content h2 + *{margin-top:calc(var(--line) * .75)}
.article-content h3{
  margin-top:calc(var(--line) * 2);
  font-family:var(--text);font-weight:600;font-style:italic;color:var(--ink);
  font-size:1.18em;line-height:1.35;text-wrap:balance;
}
.article-content h3 + *{margin-top:calc(var(--line) * .5)}

/* Links: the words stay in the reading colour, the underline carries the topic. */
.article-content a,.onward-all,.author-bio a{
  color:var(--ink);
  text-decoration:underline;text-decoration-color:var(--accent-ink);
  text-decoration-thickness:.07em;text-underline-offset:.2em;text-decoration-skip-ink:auto;
  transition:color .2s,text-decoration-color .2s;
}
.article-content a:hover,.onward-all:hover,.author-bio a:hover{color:var(--accent-ink);text-decoration-thickness:.12em}

.article-content code,.article-content kbd{
  font-family:var(--mono);font-size:.86em;color:var(--ink);
  padding:.12em .4em;border-radius:3px;
  background:rgba(255,255,255,.07);border:1px solid var(--rule);
  font-variant-numeric:lining-nums;overflow-wrap:anywhere;
}
.article-content pre{
  grid-column:1 / -1;overflow-x:auto;padding:var(--line);
  font-family:var(--mono);font-size:.84em;line-height:1.6;color:var(--ink);
  background:rgba(255,255,255,.05);border:1px solid var(--rule);border-radius:3px;
}
.article-content pre code{padding:0;border:0;background:none;font-size:1em}

/* Lists hang their markers in the topic's ink and keep a little air between items. */
.article-content ul,.article-content ol{padding-left:1.35em}
.article-content li{padding-left:.25em;text-wrap:pretty}
.article-content li + li{margin-top:calc(var(--line) * .4)}
.article-content li::marker{color:var(--accent-ink);font-family:var(--ui);font-weight:600;font-variant-numeric:lining-nums}
.article-content ul > li::marker{content:'\2013\2002'}
.article-content li > ul,.article-content li > ol{margin-top:calc(var(--line) * .4)}

.article-content blockquote{
  padding-left:1.2em;border-left:2px solid var(--accent);
  font-style:italic;color:var(--ink);
}
.article-content blockquote p{margin:0}
.article-content blockquote p + p{margin-top:calc(var(--line) * .5)}

.article-content table{
  grid-column:1 / -1;width:100%;border-collapse:collapse;
  font-family:var(--ui);font-size:.9em;line-height:1.45;font-variant-numeric:lining-nums tabular-nums;
}
.article-content th,.article-content td{padding:.6em 1em .6em 0;text-align:left;vertical-align:top;border-bottom:1px solid var(--rule)}
.article-content th{font-weight:600;color:var(--ink);border-bottom-color:var(--rule-strong)}

.article-content img{max-width:100%;height:auto}
.article-content hr{width:100%;height:0;border:0;border-top:1px solid var(--rule-strong)}

/* The pull quote. No box, no marks: the sentence itself, set large, is the picture. */
.pull-quote{
  grid-column:1 / -1 !important;
  max-width:26em;
  margin-top:calc(var(--line) * 2) !important;
  padding-top:calc(var(--line) * .9);
  font-family:var(--text);font-style:italic;font-weight:500;color:var(--ink);
  font-size:clamp(1.4em,.95em + 1.6vw,1.95em);line-height:1.3;letter-spacing:-.006em;
  text-wrap:balance;
  position:relative;
}
.pull-quote::before{content:'';position:absolute;left:0;top:0;width:3em;height:2px;background:var(--accent)}
.pull-quote + *{margin-top:calc(var(--line) * 2) !important}
.pull-quote cite{display:block;margin-top:.8em;font-family:var(--ui);font-size:.5em;font-style:normal;font-weight:400;color:var(--ink-quiet)}

/* A pause between two parts of an article. */
.content-divider{
  width:3em;height:2px;background:var(--accent);
  margin-top:calc(var(--line) * 2.5) !important;
}
.content-divider + *{margin-top:calc(var(--line) * 2) !important}
.content-divider + h2{margin-top:calc(var(--line) * 2) !important}

.art-band{grid-column:1 / -1 !important;margin-top:calc(var(--line) * 2) !important}
.art-band + *{margin-top:calc(var(--line) * 2) !important}

/* A dated addition to an article that was already published. */
.update-stamp{
  display:block;
  font-family:var(--ui);font-size:.84em;font-weight:600;line-height:1.4;color:var(--accent-ink);
  font-variant-numeric:lining-nums;
}
.update-stamp + h2{margin-top:calc(var(--line) * .4) !important}

/* A specimen: something quoted exactly as it arrived, so a reader can search for the same
   string. The red rule marks it as the thing being warned about, whatever the topic colour is. */
.specimen{
  padding:.1em 0 .1em 1.2em;border-left:2px solid #d0503f;
  margin-top:calc(var(--line) * 1.25) !important;
}
.specimen + :not(.specimen){margin-top:calc(var(--line) * 1.5) !important}
.specimen .dom{
  display:block;
  font-family:var(--mono);font-size:.95em;font-weight:700;line-height:1.4;color:#f08a7c;
  font-variant-numeric:lining-nums;overflow-wrap:anywhere;
}
.specimen .det{
  margin:calc(var(--line) * .35) 0 0;
  font-family:var(--ui);font-size:.92em;line-height:1.6;color:var(--ink-soft);
  font-variant-numeric:lining-nums;text-wrap:pretty;
}
.specimen .det b{font-weight:600;color:var(--ink)}

/* ------------------------------------------------------------------------------------------
   The foot of the story: share, and who wrote it
   ------------------------------------------------------------------------------------------ */
.story-foot{
  max-width:var(--col);margin:calc(var(--line) * 3) auto 0;
  padding-top:var(--line);border-top:1px solid var(--rule-strong);
}

.article-share{
  display:flex;flex-wrap:wrap;align-items:center;gap:.5em 1.4em;
  font-family:var(--ui);font-size:.9em;line-height:1.4;
}
.article-share-btn{
  display:inline-flex;align-items:center;gap:.55em;
  margin:0;padding:.55em 1.1em;min-height:44px;
  font:inherit;font-weight:600;color:var(--ink);
  background:transparent;border:1px solid var(--rule-strong);border-radius:3px;cursor:pointer;
  transition:border-color .2s,color .2s;
}
.article-share-btn:hover{border-color:var(--accent-ink);color:var(--accent-ink)}
.article-share-btn svg{width:1.05em;height:1.05em;flex:none}
.article-share-links{display:flex;flex-wrap:wrap;gap:.3em 1.4em}
/* The script marks the button as closed when it starts up. Until someone opens it, the two
   links stay out of the way. Without the script there is no mark, so the links simply show. */
.article-share-btn[aria-expanded="false"] + .article-share-links{display:none}
.article-share-links a{
  padding:.55em 0;color:var(--ink-soft);
  text-decoration:underline;text-decoration-color:var(--rule-strong);
  text-decoration-thickness:1px;text-underline-offset:.3em;
  transition:color .2s,text-decoration-color .2s;
}
.article-share-links a:hover{color:var(--ink);text-decoration-color:var(--accent-ink)}

/* The author: a portrait, a name, one line. No panel around it. */
.author-card{
  display:flex;align-items:center;gap:1.2em;
  margin-top:calc(var(--line) * 1.5);
}
.author-photo{
  flex:none;width:calc(var(--line) * 2.5);height:calc(var(--line) * 2.5);border-radius:50%;
  background:var(--surface) url('/scott-tilly.jpg') center 18%/cover;
  border:1px solid var(--rule-strong);
}
.author-info{flex:1;min-width:0}
.author-name{font-family:var(--text);font-weight:600;font-size:1.05em;line-height:1.3;color:var(--ink)}
.author-bio{margin-top:.25em;font-family:var(--ui);font-size:.9em;line-height:1.5;color:var(--ink-soft);text-wrap:pretty}

/* ------------------------------------------------------------------------------------------
   Onward: three more things to read, set as type. Each carries a rule in its own topic colour.
   ------------------------------------------------------------------------------------------ */
.onward{
  margin-top:calc(var(--line) * 4);
  display:grid;grid-template-columns:minmax(0,1fr);gap:0 calc(var(--line) * 1.5);
}
.onward-label{
  grid-column:1 / -1;margin:0 0 calc(var(--line) * .75);
  font-family:var(--ui);font-size:.84em;font-weight:600;line-height:1.4;color:var(--ink-quiet);
}
.onward-link{
  display:flex;flex-direction:column;gap:.5em;
  padding:calc(var(--line) * .8) 0 calc(var(--line) * 1.1);
  border-top:2px solid var(--accent);
  text-decoration:none;color:var(--ink);
}
.onward-title{
  font-family:var(--text);font-weight:600;font-size:1.45em;line-height:1.22;letter-spacing:-.008em;
  text-wrap:balance;
  text-decoration:underline;text-decoration-color:transparent;
  text-decoration-thickness:.06em;text-underline-offset:.18em;
  transition:text-decoration-color .2s;
}
.onward-link:hover .onward-title{text-decoration-color:var(--accent-ink)}
.onward-meta{font-family:var(--ui);font-size:.84em;line-height:1.4;color:var(--accent-ink)}
.onward-all{
  grid-column:1 / -1;justify-self:start;
  margin-top:calc(var(--line) * .5);padding:.4em 0;
  font-family:var(--ui);font-size:.95em;font-weight:600;
}
/* Three across once there is honest room for three, never two and an orphan. */
@media (min-width:1400px){
  .onward{grid-template-columns:repeat(3,minmax(0,1fr))}
  .onward-link{padding-bottom:calc(var(--line) * .5)}
  .onward-all{margin-top:var(--line)}
  /* Four links make two even rows of two, so the fourth is never left alone under three. */
  .onward:has(.onward-link:nth-child(5)){grid-template-columns:repeat(2,minmax(0,1fr))}
  .onward:has(.onward-link:nth-child(5)) .onward-link{padding-bottom:var(--line)}
}
/* One centred column: the pull quote and the onward list keep to the text's own left edge, so
   nothing hangs out to one side of the writing. Only pictures run wider, evenly on both sides. */
@media (max-width:1099.98px){
  .pull-quote{grid-column:2 !important}
  .onward{max-width:var(--col)}
}

/* ------------------------------------------------------------------------------------------
   The site footer
   ------------------------------------------------------------------------------------------ */
.site-foot{
  margin:calc(var(--line) * 4) var(--page-pad) 0;padding:calc(var(--line) * 1.25) 0 0;
  border-top:1px solid var(--rule);
  text-align:center;
}
.site-foot > p{margin:0;font-family:var(--ui);font-size:.84em;line-height:1.5;color:var(--ink-quiet)}

/* ------------------------------------------------------------------------------------------
   Wide windows: the two part composition
   ------------------------------------------------------------------------------------------ */
@media (min-width:1100px){
  .masthead{
    margin-left:var(--gauge-left);
    max-width:var(--frame-max);
    padding-top:calc(var(--line) * 1.25);
  }
  .page{padding-left:var(--stage-left)}
  .story,.onward{margin-inline:0}

  .story-head{max-width:none;margin-inline:0;padding-top:calc(var(--line) * 3)}
  .story-title{
    max-width:17em;
    font-size:clamp(56px,31px + 2.5vw,88px);line-height:1.04;
  }
  .story-dek{max-width:var(--col)}

  .article-content{grid-template-columns:0 minmax(0,var(--col)) minmax(0,1fr);margin-top:calc(var(--line) * 2.5)}
  .hero-fig,.story > .hero-shot{margin-top:calc(var(--line) * 2.5)}
  .story-foot{margin-inline:0}
  figcaption{margin-inline:0}

  .site-foot{margin-left:var(--stage-left);max-width:var(--stage-max)}
}

/* ------------------------------------------------------------------------------------------
   Small phones: keep the portrait from squeezing the line beside it
   ------------------------------------------------------------------------------------------ */
@media (max-width:420px){
  .author-photo{width:calc(var(--line) * 2);height:calc(var(--line) * 2)}
  .author-card{gap:1em}
}

/* ------------------------------------------------------------------------------------------
   Paper: black on white, one column, and every link's address written out
   ------------------------------------------------------------------------------------------ */
@media print{
  @page{margin:20mm 18mm}
  :root{
    --fs:11pt;--page-pad:0px;--gauge-strip:0px;
    --ink:#000;--ink-soft:#000;--ink-quiet:#333;--accent:#000;--accent-ink:#000;
    --rule:#bbb;--rule-strong:#888;--surface:#fff;--bg:#fff;
  }
  [data-topic]{--accent:#000;--accent-ink:#000}
  html,body{background:#fff !important;color:#000}
  body{padding-top:0}
  #world,.skip,.gauge,.masthead-index,.article-share,.onward,.bpd-sig-wrap{display:none !important}
  .masthead{margin:0;padding:0;max-width:none}
  .page{padding:0}
  .story,.story-head,.story-foot,.site-foot{max-width:none;margin-inline:0}
  .story-head{padding-top:12pt}
  figcaption{max-width:none;margin-inline:0;padding-right:0}
  .story-title{font-size:26pt;max-width:none}
  .article-content{display:block;font-size:11pt}
  .article-content > * + *{margin-top:var(--line)}
  .pull-quote{font-size:15pt;max-width:none}
  .hero-shot,.art-band img{border-color:#888}
  .hero-shot::after{display:none}
  .hero-fig,.art-band,.pull-quote,.specimen,.author-card{break-inside:avoid}
  .article-content h2,.article-content h3{break-after:avoid}
  .article-content p{orphans:3;widows:3}
  .article-content code{background:none;border-color:#bbb}
  .specimen,.specimen .dom{border-color:#000;color:#000}
  .article-content a[href^="http"]::after,.author-bio a[href^="http"]::after,.hero-fig a[href^="http"] + figcaption::after{
    font-family:var(--ui);font-size:.85em;overflow-wrap:anywhere;
  }
  .article-content a[href^="http"]::after,.author-bio a[href^="http"]::after{content:' (' attr(href) ')'}
  .article-content a[href^="/"]::after{content:' (thescottrocca.com' attr(href) ')';font-family:var(--ui);font-size:.85em;overflow-wrap:anywhere}
  .article-content a[href^="mailto:"]::after{content:''}
  .site-foot{margin:24pt 0 0}
}
