/* Article pages. The tokens, top bar and footer mirror /home.css: keep the two in step.
   Everything here works without /article.js, which only hides the bar on scroll, fills the
   progress line and lifts the footer letters. */

:root {
  --paper: #EEEDE9;
  --ink: #0A0A0A;
  --bone: #F2F1ED;
  --accent: #FF5A1F;          /* on ink */
  --accent-big: #E2470F;      /* large type on paper, 3.5:1 */
  --muted-p: #5E5D59;         /* body on paper, 5.6:1 */
  --muted-i: #A3A29D;         /* body on ink */
  --dim-i: #7A7A75;           /* small labels on ink, 4.6:1 */
  --line: rgba(10, 10, 10, .16);
  --display: "Archivo", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --text: "Archivo", "Helvetica Neue", Arial, sans-serif;   /* reading type: no Arial Black fallback */
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --gutter: clamp(20px, 3vw, 48px);
  --wide: 108%;               /* display width: expanded, but readable on a laptop */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 96px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--text); font-stretch: 100%; -webkit-font-smoothing: antialiased; }
::selection { background: var(--accent); color: var(--ink); }
a { color: inherit; }
:where(a, button):focus-visible { outline: 2px solid var(--accent-big); outline-offset: 3px; }

.skip { position: absolute; left: -9999px; z-index: 70; padding: .6rem 1rem; background: var(--ink); color: var(--bone); }
.skip:focus { left: 1rem; top: 1rem; }

/* ---------------- progress bar ---------------- */

.progress { position: fixed; inset: 0 0 auto 0; z-index: 50; height: 2px; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

/* ---------------- top bar (as /home.css) ---------------- */
/* Difference blending keeps the bar readable over paper and over the ink code blocks. It hides on scroll down. */

.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 16px var(--gutter);
  color: #fff; mix-blend-mode: difference;
  transition: transform .6s var(--ease-out);
}
.bar.is-hidden { transform: translateY(-110%); }
.bar:focus-within { transform: none; }
.bar a { color: #fff; text-decoration: none; }
.bar-mark { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-stretch: var(--wide); font-size: 14px; letter-spacing: -.01em; text-transform: uppercase; }
.bar-mark svg { transition: transform .6s var(--ease-out); }
.bar-mark:hover svg { transform: rotate(180deg); }
.bar-nav { display: flex; gap: 26px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.bar-nav a { position: relative; padding: 12px 0; }
.bar-nav a::after { content: ""; position: absolute; left: 0; right: 100%; bottom: 8px; height: 1px; background: #fff; transition: right .45s var(--ease-out); }
.bar-nav a:hover::after { right: 0; }
.bar-cta { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border: 1px solid #fff; border-radius: 999px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; transition: background-color .3s, color .3s; }
.bar-cta:hover { background: #fff; color: #000 !important; }

/* ---------------- article ---------------- */
/* One reading column of about 68 characters at 18px. The headline runs wider on the same
   left edge. Both grids keep an 18px font so the ch-based column lines up between them. */

/* registered, so 68ch is fixed at the grid's 18px and inherited as a length */
@property --measure { syntax: "<length>"; inherits: true; initial-value: 700px; }
.article, #sources {
  --measure: 68ch;
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [text-start] min(var(--measure), 100% - 2 * var(--gutter))
    [text-end] minmax(0, 16rem)
    [wide-end] minmax(var(--gutter), 1fr) [full-end];
  font-size: 18px; line-height: 1.65;
}
.article > *, #sources > * { grid-column: text; min-width: 0; }
.article { padding-top: clamp(120px, 13vw, 176px); }

/* small labels in parentheses, as on the homepage; the brackets are decoration, not text */
.meta { margin: 0 0 28px; font-family: var(--mono); font-size: 12.5px; line-height: 1.4; letter-spacing: .06em; text-transform: uppercase; }
.meta::before, #sources h2::before { content: "( "; content: "( " / ""; }
.meta::after, #sources h2::after { content: " )"; content: " )" / ""; }

.article h1 {
  grid-column: text-start / wide-end;
  margin: 0 0 36px;
  font-family: var(--display); font-size: clamp(34px, 4vw, 56px); font-weight: 800; font-stretch: var(--wide);
  line-height: 1.02; letter-spacing: -.04em; text-wrap: balance;
}
.article h1 code { font-size: .84em; font-weight: 600; letter-spacing: -.05em; }

.lede { margin: 0 0 56px; padding-bottom: 44px; border-bottom: 2px solid var(--ink); font-size: clamp(19px, 1.5vw, 22px); font-weight: 500; line-height: 1.45; letter-spacing: -.015em; }

.article h2 {
  margin: 64px 0 18px; padding-top: 20px; border-top: 1px solid var(--line);
  font-family: var(--display); font-size: clamp(24px, 2.2vw, 31px); font-weight: 650;
  line-height: 1.15; letter-spacing: -.03em; text-wrap: balance;
}
.lede + h2 { margin-top: 0; padding-top: 0; border-top: 0; }

.article p { margin: 0 0 1.15em; overflow-wrap: break-word; }
.article strong { font-weight: 700; }
.article ul, .article ol, #sources ul { margin: 0 0 1.4em; padding-left: 1.75em; }
.article ul, #sources ul { list-style: "—\2002"; }
.article ol { list-style: decimal-leading-zero; }
.article ol > li::marker { font-family: var(--mono); font-size: .78em; color: var(--muted-p); }
.article li { margin-bottom: .55em; padding-left: .25em; overflow-wrap: break-word; }

/* links: a quiet underline that the ink draws across on hover */
.article a, #sources a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(rgba(10, 10, 10, .38), rgba(10, 10, 10, .38));
  background-size: 0 1px, 100% 1px; background-position: 0 100%, 0 100%; background-repeat: no-repeat;
  transition: background-size .45s var(--ease-out);
}
.article a:hover, #sources a:hover { background-size: 100% 1px, 100% 1px; }

code { font-family: var(--mono); }
.article :not(pre, h1) > code, #sources code { font-size: .84em; padding: .08em .32em; border-radius: 4px; background: rgba(10, 10, 10, .065); }

/* code keeps the text width, and a block with long lines grows into the wide column rather than scrolling */
.article pre {
  grid-column: text-start / wide-end; justify-self: start;
  width: fit-content; min-width: min(100%, var(--measure)); max-width: 100%;
  margin: 8px 0 32px; padding: 22px 24px; overflow-x: auto;
  border-radius: 6px; background: var(--ink); color: var(--bone);
  font-size: 14.5px; line-height: 1.65; tab-size: 4;
  scrollbar-color: var(--dim-i) transparent;
}
.article pre code { font-size: inherit; }

/* counts called out in the text; at this size and weight they are large text, so the accent passes */
.num { font-family: var(--display); font-size: 1.15em; font-weight: 800; font-stretch: var(--wide); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.num.bad { color: var(--accent-big); }

.callout { margin: 40px 0; padding: 22px 0 4px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--line); }
.callout::before { content: "( Note )"; content: "( Note )" / ""; display: block; margin-bottom: 12px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-p); }
.callout p { font-size: 17px; line-height: 1.6; }
/* the callout that asks for an email becomes an ink panel, like the homepage's close */
.callout:has(a[href^="mailto:"]) { padding: 26px 28px 8px; border: 0; border-radius: 6px; background: var(--ink); color: var(--bone); }
.callout:has(a[href^="mailto:"])::before { content: "( Get in touch )"; content: "( Get in touch )" / ""; color: var(--dim-i); }
.callout:has(a[href^="mailto:"]) a { color: var(--accent); background-image: linear-gradient(currentColor, currentColor), linear-gradient(rgba(255, 90, 31, .45), rgba(255, 90, 31, .45)); }
.callout:has(a[href^="mailto:"]) :focus-visible { outline-color: var(--accent); }

#sources { margin-top: 24px; padding-bottom: clamp(80px, 9vw, 128px); }
#sources > * { font-size: 15px; line-height: 1.6; color: var(--muted-p); }
#sources h2 { margin: 0 0 14px; padding-top: 18px; border-top: 2px solid var(--ink); font-family: var(--mono); font-size: 12.5px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); }
#sources p { margin: 0 0 12px; }
#sources li { margin-bottom: 6px; }
#sources a { color: var(--ink); overflow-wrap: anywhere; }

/* the headline settles in on load; it is never hidden */
@media (prefers-reduced-motion: no-preference) {
  .article h1 { animation: settle 1.1s var(--ease-out) backwards; }
}
@keyframes settle { from { transform: translateY(.18em); } to { transform: none; } }

/* ---------------- footer (as /home.css) ---------------- */

.ink { --muted: var(--muted-i); background: var(--ink); color: var(--bone); }
.mini { font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-i); }
.foot { padding: 72px var(--gutter) 28px; container-type: inline-size; font-family: var(--display); }
.foot :focus-visible { outline-color: var(--accent); }
.foot-in { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 40px; }
.foot-col { display: flex; flex-direction: column; gap: 10px; }
.foot-col p { margin: 0; max-width: 320px; font-size: 15px; line-height: 1.5; color: var(--muted-i); }
.foot-col a { width: fit-content; font-size: 15px; color: var(--bone); text-decoration: none; transition: color .3s, transform .45s var(--ease-out); }
.foot-col a:hover, .foot-col a[aria-current="page"] { color: var(--accent); }
.foot-col a:hover { transform: translateX(4px); }
.foot-col .mini { margin-bottom: 6px; color: var(--dim-i); }
.foot-brand { color: var(--bone) !important; font-size: 22px !important; font-weight: 900; font-stretch: var(--wide); letter-spacing: -.03em; text-transform: uppercase; }
/* a big closing wordmark; each letter lifts under the pointer */
.foot-wm { margin: 72px 0 0; font-weight: 900; font-stretch: var(--wide); text-transform: uppercase; line-height: .8; letter-spacing: -.04em; white-space: nowrap; color: #1C1C1B; font-size: calc((100vw - 2 * var(--gutter)) / 11.6); font-size: calc(100cqw / 11.6); user-select: none; }
.foot-wm span { display: inline-block; transition: transform .5s var(--ease-out), color .3s; }
.foot-wm span:hover { transform: translateY(-14%); color: var(--accent); }
/* the letters rise one after another; /article.js writes --fw, and without it they sit in place */
.foot-wm span { translate: 0 calc((1 - clamp(0, var(--fw, 1) * 1.5 - var(--li, 0) * .04, 1)) * 75%); }
.foot-base { max-width: 1280px; margin: 28px auto 0; display: flex; justify-content: space-between; gap: 16px; padding-top: 20px; border-top: 1px solid rgba(255, 255, 255, .12); font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--dim-i); }

/* ---------------- responsive ---------------- */

@media (max-width: 1020px) {
  .bar-nav { display: none; }
  .foot-in { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .bar-mark span { display: none; }
  .article { padding-top: 112px; }
  .article, #sources { font-size: 17px; }
  .article pre { justify-self: stretch; width: auto; min-width: 0; max-width: none; margin-inline: calc(-1 * var(--gutter)); padding: 18px var(--gutter); border-radius: 0; font-size: 13.5px; }
  .callout:has(a[href^="mailto:"]) { padding: 22px 20px 6px; }
  .foot-in { grid-template-columns: minmax(0, 1fr); }
  .foot-base { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

@media print {
  .skip, .progress, .bar, .foot { display: none; }
  body { background: #fff; }
  .article { padding-top: 0; }
  .article pre { white-space: pre-wrap; }
  .callout:has(a[href^="mailto:"]) { background: none; color: inherit; border: 2px solid var(--ink); }
}
