/* Besides — itsbesides.com
 *
 * One stylesheet for every page. The look is the app's paper look carried to the
 * web: a page with no hue of its own, SF Pro (the system font), hairlines, square
 * cards in five very faint tints with stronger edges, and the mark.
 *
 * Every colour here is computed from the app's tokens by make/colors.py, which
 * also measures the contrast of each pair. Change a token there, run it, paste the
 * hex here. Nothing is picked by eye.
 */

/* --- tokens ------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* PageLook.board, light */
  --paper: #ffffff;
  --ink: #111111;
  --secondary: #6b6b6b;
  --hairline: #dcdcdc;
  /* Tint fills: oklch(0.986 0.007 hue). Edges: oklch(0.525 0.083 hue). */
  --tint-yellow: #fbfbf5; --edge-yellow: #766b2e;
  --tint-mint:   #f6fcf9; --edge-mint:   #34795e;
  --tint-rose:   #fff9f9; --edge-rose:   #94565b;
  --tint-sky:    #f6fbff; --edge-sky:    #337293;
  --tint-sage:   #f9fbf7; --edge-sage:   #5a743f;
  /* The dotted paper's strength at its densest. */
  --dots: 0.34;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Type: five sizes, in rem so the reader's own text size still applies. */
  --fs-small: 0.875rem;   /* 14 */
  --fs-body: 1.0625rem;   /* 17, the app's body */
  --fs-lede: 1.25rem;     /* 20 */
  --fs-h2: 1.25rem;       /* 20 */
  --fs-h1: 1.75rem;       /* 28 */

  /* Space: one step is 8px. The app's page margin and card padding are 16. */
  --margin: 16px;
  --card-pad: 16px;
  --measure: 36rem;       /* about 70 characters of body text */

  --mark-w: 96px;         /* the dashed box's width; the name is 0.22 of it */
}

@media (prefers-color-scheme: dark) {
  :root {
    /* PageLook.board, dark: true greys */
    --paper: #171717;
    --ink: #ebebeb;
    --secondary: #858585;
    --hairline: #333333;
    /* Fills: oklch(0.197 0.007 hue). Edges: oklch(0.600 0.036 hue). */
    --tint-yellow: #161512; --edge-yellow: #858169;
    --tint-mint:   #131615; --edge-mint:   #6d877b;
    --tint-rose:   #181414; --edge-rose:   #957879;
    --tint-sky:    #121618; --edge-sky:    #6c8493;
    --tint-sage:   #141613; --edge-sage:   #79856e;
    --dots: 0.3;
  }
}

/* --- base --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* A link to #signup or to a heading never lands flush against the top edge. */
  scroll-padding-block-start: 24px;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  overflow-wrap: break-word;
}

h1, h2, h3, p, dl, dd, ul, ol { margin: 0; }

h1, h2, h3 {
  font-weight: 600;
  text-wrap: balance;
}
h1 { font-size: var(--fs-h1); line-height: 1.15; letter-spacing: -0.015em; }
h2 { font-size: var(--fs-h2); line-height: 1.25; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-body); line-height: 1.35; }

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

/* Links: ink, never a hue. A dotted underline in the secondary grey, as in the
 * app's prose; it turns solid ink under a pointer that can hover. */
a {
  color: inherit;
  text-decoration: underline dotted var(--secondary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  touch-action: manipulation;
}
a:active { color: var(--secondary); }

@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration-style: solid; text-decoration-color: currentColor; }
}

/* One focus ring everywhere: ink on paper, 15:1 or better in both themes. */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: 2;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus { transform: none; outline-color: var(--paper); outline-offset: -4px; }

/* --- the mark ------------------------------------------------------------ */

/* "besides" in a dashed box of 50 dashes, measured from the app icon: the box is
 * 821 by 293, the name's size 0.22 of the box's width. The dashes are drawn in
 * the SVG in the order the app draws them, clockwise from the top left. */
.mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--mark-w);
  aspect-ratio: 821 / 293;
  color: var(--ink);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.mark__box {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.mark__name {
  font-size: calc(var(--mark-w) * 0.22);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
}
/* The ring hugs the box, not the text inside it. */
.mark:focus-visible { outline-offset: 6px; }
.mark:active { color: var(--secondary); }
/* The small mark's target reaches 44px high without growing the mark. */
.mark::after { content: ""; position: absolute; inset: -6px; }

/* The splash: each dash appears in turn, with no fade and no movement, 0.8 s in
 * all (SplashLook.board.length). js/site.js adds .is-drawing on hover, on keyboard
 * focus, and once at load on a touch screen. Without the class, without scripts,
 * or under reduced motion the mark is whole. */
@keyframes dash-on { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: no-preference) {
  .mark.is-drawing .mark__box > * {
    animation: dash-on 1ms linear both;
    animation-delay: calc(50ms + var(--i) * 15ms);
  }
}

/* --- cards --------------------------------------------------------------- */

/* A tinted card: square, a 1px edge in the tint's own stronger colour. */
.card {
  --tint: var(--tint-yellow);
  --edge: var(--edge-yellow);
  padding: var(--card-pad);
  background: var(--tint);
  border: 1px solid var(--edge);
}
.card--sky  { --tint: var(--tint-sky);  --edge: var(--edge-sky); }
.card--sage { --tint: var(--tint-sage); --edge: var(--edge-sage); }
.card--rose { --tint: var(--tint-rose); --edge: var(--edge-rose); }
.card--mint { --tint: var(--tint-mint); --edge: var(--edge-mint); }

.card > h2 { font-size: var(--fs-body); line-height: 1.35; letter-spacing: 0; }
.card > h2 + p { margin-block-start: 4px; }

.secondary { color: var(--secondary); }
.nowrap { white-space: nowrap; }
.small { font-size: var(--fs-small); line-height: 1.45; }

/* --- the signup form ----------------------------------------------------- */

.signup { margin-block-start: 16px; }

.signup__label {
  display: block;
  font-size: var(--fs-small);
  line-height: 1.45;
  color: var(--secondary);
  margin-block-end: 6px;
}

.signup__row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.signup__input {
  /* Beside the button the field takes the spare room; on a narrow screen the
   * button wraps under it and fills the row. */
  flex: 999 1 12rem;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  /* 16px or more, so iOS Safari does not zoom the page on focus. */
  font: inherit;
  font-size: max(16px, 1rem);
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
.signup__input::placeholder { color: var(--secondary); opacity: 1; }
.signup__input:focus-visible { outline-offset: 2px; }
.signup__input[aria-invalid="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.button {
  flex: 1 0 auto;
  min-height: 44px;
  min-width: 7.5rem;
  padding: 8px 20px;
  font: inherit;
  font-weight: 600;
  line-height: 1.4;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition-property: scale, opacity;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.button[aria-disabled="true"] { opacity: 0.55; cursor: default; }
.button:not([aria-disabled="true"]):active { opacity: 0.8; }
@media (prefers-reduced-motion: no-preference) {
  .button:not([aria-disabled="true"]):active { scale: 0.96; }
}

/* Room is held for one line of message, so nothing below jumps when it arrives.
 * A problem is bold with a mark before it; good news has a tick. Neither leans
 * on colour. */
.signup__message {
  min-height: 1.45em;
  margin-block: 8px 0;
  font-size: var(--fs-small);
  line-height: 1.45;
}
.signup__message[data-tone="problem"] { font-weight: 600; }
.signup__message[data-tone="problem"]::before { content: "! "; }
.signup__message[data-tone="done"]::before { content: "\2713\00a0"; }

.signup__note { margin-block-start: 0; }

/* With scripts off the form can't send: a <noscript> rule in each page's head
 * hides .needs-js, and this line says so. */
.noscript-note { margin-block-start: 12px; }

/* --- home ---------------------------------------------------------------- */

/* A document, like the app's own pages and like are.na's front page: one
 * column, everything on its left edge, the mark small where a title would be. */
.home main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--margin));
  margin-inline: auto;
  padding-block: 56px 64px;
  /* Physical sides on purpose: the safe-area insets are physical. */
  padding-left: max(var(--margin), env(safe-area-inset-left));
  padding-right: max(var(--margin), env(safe-area-inset-right));
}

.home__title { font: inherit; letter-spacing: 0; line-height: 0; }

.home__is { margin-block-start: 32px; }

/* The senses: a. b. c. d. The letters sit in the column on a phone and hang in
 * the margin once there is a margin to hang in, so the words keep one edge. */
.senses {
  --letter: 1.75rem;
  margin-block-start: 12px;
  padding: 0;
  list-style: none;
  counter-reset: sense;
}
.senses li {
  counter-increment: sense;
  position: relative;
  padding-inline-start: var(--letter);
}
.senses li + li { margin-block-start: 6px; }
.senses li::before {
  content: counter(sense, lower-alpha) ".";
  position: absolute;
  inset-inline-start: 0;
  color: var(--secondary);
}
@media (min-width: 44rem) {
  .senses { margin-inline-start: calc(-1 * var(--letter)); }
}

.home__about { margin-block-start: 24px; }

.home__go {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-block-start: 24px;
  font-size: var(--fs-small);
  line-height: 1.45;
}

/* The small rectangle: a link that reads as a button. Square, ink on paper. */
.chip {
  position: relative;
  display: inline-block;
  padding: 5px 10px;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition-property: scale, opacity;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
/* Its target reaches 44px high. */
.chip::after { content: ""; position: absolute; inset: -8px 0; }
.chip:active { color: var(--paper); opacity: 0.8; }
@media (prefers-reduced-motion: no-preference) {
  .chip:active { scale: 0.96; }
}
@media (hover: hover) and (pointer: fine) {
  .chip:hover { opacity: 0.85; }
}

.home__trail {
  margin-block-start: 56px;
  padding-block-start: 32px;
  border-block-start: 1px solid var(--hairline);
}
.home__trail > h2 { font-size: var(--fs-body); line-height: 1.35; letter-spacing: 0; }

/* The rail. Sizes are the app's: a 1px line, a dot a third of the body size.
 * As it stands in the HTML every stop is ink, so it reads whole with scripts
 * off. js/site.js adds .trail--live and from then on a stop is ink once the
 * reading line (PageLook.railRead, 0.4 of the window's height) has passed it,
 * and the ink line follows the scroll. */
.trail {
  --dot: 0.33em;
  --gutter: 1.5rem;
  --fill: 1;
  position: relative;
  margin-block-start: 20px;
  padding: 0;
  list-style: none;
}
.trail li {
  position: relative;
  padding-inline-start: var(--gutter);
}
.trail li + li { margin-block-start: 20px; }
.trail h3 { font-weight: 600; }
.trail p { margin-block-start: 2px; color: var(--secondary); }

/* The line: grey all the way down, ink over it as far as you have read. Both
 * stop at the last stop's dot (the script measures where that is). */
.trail::before, .trail::after {
  content: "";
  position: absolute;
  inset-block: 0.68em var(--tail, 2.4em);
  inset-inline-start: calc(var(--dot) / 2 - 0.5px);
  width: 1px;
  background: var(--hairline);
}
.trail::after {
  background: var(--ink);
  transform-origin: top;
  transform: scaleY(var(--fill));
}
.trail li::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset-block-start: calc(0.68em - var(--dot) / 2);
  inset-inline-start: 0;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--ink);
  /* A ring of paper, so the line stops short of the dot instead of running into it. */
  box-shadow: 0 0 0 3px var(--paper);
}

.trail--live li:not(.is-reached) h3 { color: var(--secondary); }
.trail--live li:not(.is-reached)::before { background: var(--secondary); }
.trail--live li.is-reached p { color: var(--ink); }
.trail--live h3, .trail--live p { transition: color 200ms ease-out; }
.trail--live li::before { transition: background-color 200ms ease-out; }

.home .card { margin-block-start: 56px; }

/* --- documents: privacy, support, 404 ------------------------------------ */

.doc__head, .doc main, .foot {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--margin));
  margin-inline: auto;
  /* Physical sides on purpose: the safe-area insets are physical. */
  padding-left: max(var(--margin), env(safe-area-inset-left));
  padding-right: max(var(--margin), env(safe-area-inset-right));
}

.doc__head { padding-block: 24px 0; }

.doc main { flex: 1; padding-block: 40px 64px; }

.doc h1 + .doc__dated { margin-block-start: 8px; color: var(--secondary); }
.doc__intro { margin-block-start: 24px; font-size: var(--fs-lede); line-height: 1.4; }

.doc section { margin-block-start: 48px; }
.doc section > h2 {
  padding-block-end: 8px;
  border-block-end: 1px solid var(--hairline);
}
.doc section > * + * { margin-block-start: 16px; }
.doc section > h3 { margin-block-start: 24px; }
.doc section > h3 + * { margin-block-start: 4px; }

.doc ul { padding-inline-start: 1.2em; }
.doc li + li { margin-block-start: 6px; }
.doc li::marker { color: var(--secondary); }

/* Rows like the app's Settings: a grey label, the value beside it, a hairline
 * under each. Under 34rem the label sits above its value. */
.rows { border-block-start: 0; }
.rows > div {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  column-gap: 16px;
  padding-block: 12px;
  border-block-end: 1px solid var(--hairline);
}
.rows dt { color: var(--secondary); }
.rows dd > * + * { margin-block-start: 6px; }
.doc section > h2 + .rows { margin-block-start: 0; }

@media (max-width: 34rem) {
  .rows > div { grid-template-columns: minmax(0, 1fr); row-gap: 2px; }
  .rows dt { font-size: var(--fs-small); line-height: 1.45; }
}

.doc .card { margin-block-start: 24px; }
.doc .card > * + * { margin-block-start: 8px; }

.lost { text-align: start; }
.lost p { margin-block-start: 16px; }

/* --- foot ---------------------------------------------------------------- */

.foot {
  padding-block: 20px 20px;
  font-size: var(--fs-small);
  line-height: 1.45;
  color: var(--secondary);
}
.foot ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  padding: 0;
  list-style: none;
}
.foot li + li::before { content: "·"; margin-inline: 0.5em; }
/* The links' targets reach 44px high without moving the line. */
.foot a { position: relative; }
.foot a::after { content: ""; position: absolute; inset: -14px -4px; }

.doc .foot, .home .foot { border-block-start: 1px solid var(--hairline); max-width: none; }
.doc .foot ul, .home .foot ul { max-width: var(--measure); margin-inline: auto; }

/* The dotted paper: a band of dots that thickens toward the page's foot, the
 * app's dithered print used as a texture. assets/dots.png is a 1-bit ordered
 * dither (Bayer 8 by 8), used as a mask so the dots take the page's ink in
 * either theme. Each cell is one CSS pixel. Decoration only. */
.dots {
  flex: none;
  height: 96px;
  padding-block-end: env(safe-area-inset-bottom);
  box-sizing: content-box;
  background: var(--ink);
  opacity: var(--dots);
  -webkit-mask: url("/assets/dots.png?v=1") repeat-x 0 0 / 8px 96px;
  mask: url("/assets/dots.png?v=1") repeat-x 0 0 / 8px 96px;
  image-rendering: pixelated;
}

/* Windows High Contrast and friends: keep the card's edge and the button's. */
@media (forced-colors: active) {
  .dots { display: none; }
  .mark__box { fill: CanvasText; }
  .button { border-color: ButtonText; }
}

@media print {
  .dots, .skip { display: none; }
}
