/* shared by every page: tokens, type, boxes, the header, the email line, tags and pictures.
   the hand-drawn effects are in css/sketch.css, the observer in css/observer.css, and each
   page's own arrangement in its file (home, post, feeds, blogroll).

   breakpoints, three and only three (test/css.test.js keeps it so):
     phone   max-width: 700px    one column: a post stacks, the index compacts, the reader centres
     narrow  701px to 1000px     the index's tighter columns
     wide    min-width: 1280px   a post's sources scatter (js/post/sources.js asks the same), the
                                 reader's next moves beside its card
   the wall's masonry counts its columns by card size instead, in js/home/masonry.js: one to 500,
   two to 900, three to 1250, four to 1600, then five */

@font-face {
  font-family: 'Kiya Handwrite';
  src: url('/fonts/kiya-handwrite.woff2') format('woff2');
  font-display: swap;
}

:root {
  /* greys, darkest first */
  --ink: #111;
  --text: #333;
  /* the lightest grey that still reads at 4.5:1 on white */
  --dim: #767676;
  /* the same on the grey page, which needs it a touch darker */
  --dim-page: #707070;
  --pale: #a9a9a9;
  --rule: #c2c2c2;
  --faint: #cbcbcb;
  --line: #e8e8e8;
  --wash: #f7f7f7;
  --bg: #f5f5f5;
  --paper: #fff;

  --edge: 1px dashed var(--rule);

  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --hand: "Kiya Handwrite", var(--sans);

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* type sizes: the hand, then the words */
  --h-xl: 30px;
  --h-l: 24px;
  --h-m: 20px;
  --h-s: 17px;
  --h-xs: 15px;
  --size: 15px;
  --small: 14px;
  --note: 12px;
  --tiny: 11px;

  /* links pointed at */
  --glow: 0 0 0.25rem gold;

  /* tag ladder: the old purple, the only colour on the page */
  --t-passing: rgb(251, 251, 255);
  --t-highlights: rgb(233, 233, 255);
  --t-braindump: rgb(206, 206, 255);
  --t-draft: rgb(162, 162, 252);
  --t-iterating: rgb(144, 144, 225);
  --t-published: rgb(103, 103, 160);
  --t-recommendation: rgb(255, 215, 122);
  --t-newsletter: rgb(255, 172, 172);
  --t-edge: rgb(78, 78, 121);
  /* words as they arrive in a replay, before they fade into the text */
  --arriving: var(--t-draft);
}

/* reset */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--sans);
  font-size: var(--size);
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  padding: var(--s5) var(--s4) 80px;
}

/* phones: the same 16px all round; the look picker floats over the last card as over the rest */
@media (max-width: 700px) {
  body { padding: var(--s4); }
}

h1, h2, h3 { font-weight: 400; text-wrap: balance; }

p, li, dd { text-wrap: pretty; }

/* a phrase that wraps whole, like a title's "by ..." (utils.js titleHtml) */
.phrase { display: inline-block; }

a {
  color: inherit;
  text-decoration: none;
}

::selection { background: var(--line); }

button, input {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button { cursor: pointer; }

input:focus { outline: none; }

time {
  font-family: var(--hand);
  font-size: 1.25em;
  color: var(--dim);
  text-transform: lowercase;
}

/* boxes: paper on the grey page, with a dashed edge drawn by an <i class="edge"> inside, so
   css/sketch.css can boil it without touching the words */

.edge {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: var(--edge);
}

/* the header: the observer standing on the wordmark, the links in a row under it, all centred.
   it and the email line under it read as one box: the header drops its bottom edge and the
   email box its top, so the seam disappears */

.top {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3);
  background: var(--paper);
}

.top .edge { border-bottom: none; }

.top .left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s1);
}

/* the vw cap keeps the wordmark on one line at phone width */
.wordmark {
  font-family: var(--hand);
  font-size: min(var(--h-xl), 7vw);
  line-height: 1;
}

.top .right {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: var(--s1) var(--s5);
  font-family: var(--hand);
  font-size: var(--h-s);
  line-height: 1.2;
  color: var(--dim);
}

.top .right a:hover {
  text-shadow: var(--glow);
}

/* the email line: the field shrinks to its words so the arrow follows them */

.subscribe {
  margin-bottom: var(--s4);
  padding: 0 var(--s4) var(--s4);
  background: var(--paper);
  border: var(--edge);
  border-top: none;
}

/* what's left once you've subscribed */
.subscribe p {
  font-family: var(--hand);
  font-size: var(--h-s);
  color: var(--dim);
  text-align: center;
}

#subscribeForm {
  display: flex;
  flex-direction: column;
}

#subscribeForm[hidden] { display: none; }

/* waiting on them to confirm: a way back to the form */
.subscribe .subscribe-again {
  margin-top: var(--s1);
  font-family: var(--sans);
  font-size: var(--note);
}

.subscribe-again a { color: var(--dim); text-decoration: underline dashed; text-underline-offset: 3px; }

.subscribe-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--s2);
  align-self: center;
  width: fit-content;
  max-width: 100%;
}

.subscribe input {
  field-sizing: content;
  max-width: 100%;
  font-family: var(--hand);
  font-size: var(--h-s);
  text-align: center;
}

/* the lightest grey that still reads, so the invitation sits back */
.subscribe input::placeholder,
.subscribe button { color: var(--dim); }
.subscribe button:hover { text-shadow: var(--glow); }

/* what you'd get, surfacing out of a blur while the box is pointed at or typed in */
.subscribe-note {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease, margin-top 0.35s ease;
}

.subscribe-note > span {
  overflow: hidden;
  font-size: var(--note);
  color: var(--dim);
  text-align: center;
  opacity: 0;
  filter: blur(4px);
  transform: translateY(-3px);
  transition: opacity 0.45s ease, filter 0.45s ease, transform 0.45s ease;
}

.subscribe:hover .subscribe-note,
.subscribe:focus-within .subscribe-note,
.subscribe-note.checking {
  grid-template-rows: 1fr;
  margin-top: var(--s2);
}

.subscribe:hover .subscribe-note > span,
.subscribe:focus-within .subscribe-note > span {
  opacity: 1;
  filter: none;
  transform: none;
  transition-delay: 0.1s;
}

/* pressing → before the bot check is done says what's happening while it comes up */
.subscribe-note.checking > span { opacity: 1; filter: none; transform: none; }

/* the bot check, opening under the centred address */
.turnstile-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s ease;
}

.turnstile-wrapper.visible {
  grid-template-rows: 1fr;
  margin-top: var(--s2);
}

.turnstile-inner {
  display: flex;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

#turnstile-target { max-width: 24rem; }

/* phones: the header and the email line take less of the first screen */
@media (max-width: 700px) {
  .top { gap: var(--s2); padding-top: var(--s3); }
  .subscribe { padding-bottom: var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
  .subscribe-note,
  .subscribe-note > span { transition: none; }
}

/* tags: a square per stage a post is at */

.blocks {
  display: flex;
  gap: var(--s1);
}

.block {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--t-edge);
  background: var(--paper);
}

.block.passing        { background: var(--t-passing); }
.block.highlights     { background: var(--t-highlights); }
.block.braindump      { background: var(--t-braindump); }
.block.draft          { background: var(--t-draft); }
.block.iterating      { background: var(--t-iterating); }
.block.published      { background: var(--t-published); }
.block.recommendation { background: var(--t-recommendation); }
.block.newsletter     { background: var(--t-newsletter); }

/* pictures wear the same edge as the box they sit in */
.card img,
.stream img,
.source img,
.cover {
  border: var(--edge);
}

/* when something a visitor came for didn't load */
.empty-note {
  position: relative;
  padding: var(--s4);
  background: var(--paper);
  font-family: var(--hand);
  font-size: var(--h-s);
  color: var(--dim);
}

.empty-note a { color: var(--ink); }

/* the caret that types and backspaces words in a replay (the wall's, a post's history) */
.caret {
  display: inline-block;
  width: 1px;
  height: 1.1em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--ink);
}
