/* Type, colour and proportion follow the IKII brand guide v1.0: p46, p54, p56, in the
   Warm mono direction: colour as ground (deck p47, option A, the listening paper, a
   little brighter here), with Redaction 20 for display, two steps finer than the
   guide's Redaction 50: at headline sizes the coarser grades read as pixels.

   The type has four voices, as on the programme posters:
   - Redaction 20 for display.
   - Geist for anything read as a sentence: the intro, the reading pages, the field.
   - Geist Mono, small, upper case and tracked, for labels and data.
   - Geist, small and softer, for the fine print. */

@font-face {
  font-family: "Redaction 20";
  src: url("/fonts/redaction-20-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Redaction 20";
  src: url("/fonts/redaction-20-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --paper: #f5f0e6;
  --ink: #1d1a16;
  --signal: #0078bf;
  /* Fine print and placeholders. 66% ink keeps a little over 5:1 on the paper. */
  --ink-soft: color-mix(in srgb, var(--ink) 66%, var(--paper));

  /* x is a quarter of the full mark's height at this size, kept as the page's
     unit where the icon stands in for the mark. Margins and clear space are 1x.
     It follows the screen's height as well as its width, so that on a laptop the
     whole page, address included, fits without scrolling. */
  --mark-height: clamp(96px, min(14vw, 19svh), 184px);
  --x: calc(var(--mark-height) / 4);
  --icon: max(56px, var(--mark-height) * 0.42);
  --column: 34rem;
  --tap: 52px;

  /* The gutter between columns. The body is a size container, so 100cqi is the
     width inside the margins wherever it is needed. */
  --gutter: clamp(16px, 1.6vw, 28px);

  /* Vertical rhythm. The wide gap gives way a little on short screens. */
  --gap-tight: 12px;
  --gap: 32px;
  --gap-wide: clamp(28px, 5svh, 72px);

  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Redaction 20", Georgia, "Times New Roman", serif;

  /* The intro's size, the same as the reading pages' text. */
  --lede: 16px;
}

/* Colour-coded by month: js/month.js sets data-month from the date in Berlin, and each
   month has its own accent, a Riso-style ink for the typed word and focus rings. The
   paper stays the one warm off-white. Every accent keeps at least 3:1 against it, as
   large text needs; test/month.test.mjs checks that. Without JavaScript the default
   blue stays. */
:root[data-month="1"]  { --signal: #3d5588; } /* January: federal blue */
:root[data-month="2"]  { --signal: #0078bf; } /* February: Riso blue */
:root[data-month="3"]  { --signal: #00838a; } /* March: teal */
:root[data-month="4"]  { --signal: #148a55; } /* April: green */
:root[data-month="5"]  { --signal: #765ba7; } /* May: purple */
:root[data-month="6"]  { --signal: #dc3f4e; } /* June: red */
:root[data-month="7"]  { --signal: #d0522a; } /* July: orange */
:root[data-month="8"]  { --signal: #a0742a; } /* August: gold */
:root[data-month="9"]  { --signal: #68724d; } /* September: moss */
:root[data-month="10"] { --signal: #b4674a; } /* October: clay */
:root[data-month="11"] { --signal: #914e72; } /* November: burgundy */
:root[data-month="12"] { --signal: #96283a; } /* December: burgundy crimson */

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

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

/* Twelve columns between margins of 1x. Only the reading pages set text on them:
   the other pages are one column down the left, and the shapes have the rest. */
body {
  position: relative;
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: auto 1fr auto;
  column-gap: var(--gutter);
  min-height: 100svh;
  margin: 0;
  padding: var(--x);
  overflow-x: clip;
  background: var(--paper);
  font: 400 16px/1.6 var(--sans);
}

/* Everything readable sits above the shapes. */
/* Paper and print: grain and a sheet's unevenness over the whole page, as on the posts.
   Three see-through pictures from assets/textures, made by scripts/textures.mjs: dark
   specks for the paper's grain, light ones for the ink, and slow clouds. They are laid
   on without blend modes, so they cost the page nothing to draw, and they stay put
   while the page scrolls. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  /* Lighter than on a post: here it lies over small text that has to be read */
  opacity: 0.6;
  background:
    url("/assets/textures/tooth.png") 0 0 / 256px,
    url("/assets/textures/salt.png") 110px 70px / 256px,
    url("/assets/textures/mottle.png") 0 0 / 100% 100%;
}
body > :not(.field) {
  position: relative;
  z-index: 1;
}

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover {
  text-decoration-thickness: 2px;
}

h1,
h2,
p,
ul {
  margin: 0;
}

/* The guide's type scale, p54 */

.display {
  max-width: var(--column);
  font: 400 clamp(38px, 11vw, 56px) / 1.05 var(--display); /* The guide's floor is 28pt, about 37px. */
  letter-spacing: -0.02em;
  text-wrap: balance;
}
/* Read as a sentence, a size up from the body: the intro, and the short pages' text. */
.lede {
  font: 400 var(--lede) / 1.42 var(--sans);
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
/* Labels and data: headings over a block, the info line, address and links. */
.subhead,
.data {
  font: 400 12px/1.5 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* Fine print */
.caption {
  font: 400 12px/1.55 var(--sans);
  color: var(--ink-soft);
}
.caption a {
  color: var(--ink);
}
.display em {
  font-style: italic;
  color: var(--signal);
}
.signal {
  color: var(--signal);
}
.nowrap {
  white-space: nowrap;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The icon, once, with 1x of clear space, and the poster's info line opposite */

.masthead {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: var(--x);
}
.masthead__info {
  max-width: 20rem;
  text-align: right;
}
/* The name over what IKII is, the name in bold. */
.masthead__info strong {
  font-weight: 700;
}
.icon {
  display: block;
  width: auto;
  height: var(--icon);
}

/* One column, left aligned, anchored to the bottom of the page. Everything in it
   shares its left edge and its width, but for the headline, which may run wider. */

main {
  grid-column: 1 / -1;
  grid-row: 2;
  align-self: end;
  padding-top: clamp(12px, 2svh, 48px);
}
main > :not(.display--hero),
.info {
  max-width: var(--column);
}
main > .intro,
main:not(.reading) > .prose {
  margin-top: var(--gap);
}
main > .signup {
  margin-top: var(--gap-wide);
}

.display--hero {
  /* As wide as the column, or as half the page where that is wider, for a line of
     5.4em. On wide screens it also takes no more than the height the rest of the page
     leaves, so everything down to the links fits without scrolling. --hero-room is
     that rest, measured (the gaps in it grow with the screen's height, hence the
     12svh): recheck it if the masthead, intro, signup or footer change. */
  --hero-room: calc(3 * var(--x) + var(--icon) + 342px + 12svh);
  --hero-w: calc(max(50cqi, min(100cqi, var(--column))) / 5.4);
  --hero-h: calc((100svh - var(--hero-room)) / var(--hero-lines));
  --hero-lines: 1.84; /* two lines of 0.92em */
  width: fit-content;
  max-width: 100%;
  font-size: clamp(32px, min(var(--hero-w), var(--hero-h)), 160px);
  line-height: 0.92;
  letter-spacing: -0.03em;
}
/* The home page's headline: a typed word over "Social Club". The typed word is set
   bigger than "Social Club", by --word. The words run up to 4.57em wide ("Connection")
   but for the last, "The in-between", at 6.18em: so the headline is sized for the
   others to fill the column, the last runs wider, and it never runs off the screen.
   "Social Club" is 4.57em at its own size, inside the others' width. */
.display--hero:has(.words) {
  --word: 1.3;
  --hero-w: min(100cqi / (6.2 * var(--word)), max(50cqi, min(100cqi, var(--column))) / (4.6 * var(--word)));
  --hero-lines: calc(0.92 * (1 + var(--word)));
}
.words {
  font-size: calc(var(--word) * 1em);
}
/* The headline's first word, typed through a list by js/words.js, on a line of its own.
   Every word sits in the same grid cell, hidden but for the one being typed, so the
   headline keeps the width of the longest and nothing around it moves. */
.words {
  position: relative;
  display: grid;
  justify-items: start;
}
.words__now,
.words__size {
  grid-area: 1 / 1;
  white-space: nowrap;
}
.words__size {
  visibility: hidden;
}
/* The typed word, in the month's accent. */
.display--hero .words {
  color: var(--signal);
}
/* A pen scribble under the typed word, in the accent like the word: one of IKII's own,
   from assets/scribbles, cut out of the colour. js/words.js picks one to fit each word
   and shows it letter by letter with the word, cutting --pen-cut off its right end;
   without it, this one stays whole under "Hi-Fi". A scribble is 60 units high and its
   line runs through the middle; --pen-unit is one unit, so the longest scribble, 400
   units, is as wide as the headline's column. It lies over the gap between the two
   lines and takes no room of its own. */
.words__pen {
  --pen: url("/assets/scribbles/170-back.svg");
  --pen-length: 170;
  --pen-unit: 0.0115em;
  --pen-cut: 0%;
  position: absolute;
  left: 0.03em;
  top: calc(0.87em - 30 * var(--pen-unit));
  width: calc(var(--pen-length) * var(--pen-unit));
  height: calc(60 * var(--pen-unit));
  background: var(--signal);
  -webkit-mask: var(--pen) center / 100% 100% no-repeat;
  mask: var(--pen) center / 100% 100% no-repeat;
  clip-path: inset(-10% var(--pen-cut) -10% 0);
  pointer-events: none;
}

/* Signup */

/* What you sign up for, as a label over the field: mono, so it reads as part of the
   form and not as more of the intro, and a weight up, as the one label that leads
   to the page's action. */
.signup__label {
  display: block;
  margin-bottom: 10px;
  font-weight: 500;
}
/* The field and the button as one bar, the fine print under it. */
.signup__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}
.signup__input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-right: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 400 16px/1.3 var(--sans); /* 16px, or iOS zooms in on focus */
  appearance: none;
}
.signup__input::placeholder {
  color: var(--ink-soft);
  opacity: 1;
}
.signup__input[aria-invalid="true"] {
  box-shadow: inset 0 0 0 1px var(--ink);
}
.signup__consent {
  margin-top: 12px;
}
.signup__button {
  min-height: var(--tap);
  padding: 0 24px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  font: 400 12px/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
}
.signup__button:hover {
  background: var(--paper);
  color: var(--ink);
}
.signup__button[aria-busy="true"] {
  background: var(--paper);
  color: var(--ink);
  cursor: progress;
}
.signup__trap {
  position: absolute;
  left: -9999px;
}

/* Shown by the browser after a redirect without JavaScript, or by signup.js */
.signup__message {
  display: none;
  margin-top: 10px;
  font: 400 14px/1.45 var(--sans);
  scroll-margin-top: 40svh;
}
.signup__message:target,
.signup__message.is-shown {
  display: block;
}

/* Address, hours and links, side by side under the one hairline */

.info {
  grid-column: 1 / -1;
  grid-row: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: var(--gutter);
  align-items: start;
  margin-top: var(--gap-wide);
  padding-top: 14px;
  border-top: 1px solid var(--ink);
}
.info__visit {
  display: contents;
}
.info__links {
  padding-left: 0;
  list-style: none;
}
/* The three columns keep the same close rows of 18px. A link reaches 3px past its
   row above and below, so it is still 24px tall to click. */
.info__links a {
  display: inline-block;
  margin-block: -3px;
  padding-block: 3px;
}

/* Reading pages: the headline across the top, then each heading on columns 1 to 3
   with its text on 4 to 8, both under a hairline. The footer sits under the text. */

.prose p + p {
  margin-top: 14px;
}
/* The short pages (thanks, confirmed, 404) read at the intro's size. */
main:not(.reading) > .prose {
  font: 400 var(--lede) / 1.42 var(--sans);
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
body:has(> main.reading) {
  grid-template-rows: auto auto 1fr;
}
main.reading {
  display: grid;
  grid-template-columns: subgrid;
  align-items: start;
  align-self: start;
  padding-top: var(--x);
  padding-bottom: var(--gap-wide);
}
main.reading > * {
  max-width: none;
}
.reading .display {
  grid-column: 1 / -1;
  margin-bottom: 24px;
}
.reading .prose,
.reading .prose section {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: start;
}
.reading .prose > :not(section),
.reading .prose section > * {
  grid-column: 4 / 9;
}
.reading .prose .subhead {
  grid-column: 1 / 4;
}
.reading .prose .subhead,
.reading .prose .subhead + * {
  margin-top: 40px;
  padding-top: 10px;
  border-top: 1px solid var(--ink);
}
.reading .prose section + section {
  margin-top: 80px;
}
.reading + .info {
  grid-column: 4 / 9;
  align-self: end;
  max-width: none;
}

/* Details still missing. The launch check refuses to deploy while any of these remain. */
.todo {
  padding: 0 0.3em;
  border: 1px dashed var(--ink);
  background: none;
  color: inherit;
  font: 400 0.82em/1.5 var(--mono);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.todo--block {
  display: block;
  margin-bottom: 24px;
  padding: 10px 12px;
}

/* The floating shapes never catch input and never widen the page */

.field {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.shape {
  position: absolute;
  top: 0;
  left: 0;
  mix-blend-mode: multiply;
  opacity: 0;
  transition: opacity 0.9s ease-out;
  will-change: transform;
}
.shape.is-in {
  opacity: 1;
}

/* Below 1100px the columns are too narrow for the longest headings, so the reading
   pages are one column too: each heading over its text. */
@media (max-width: 1099px) {
  .reading .prose,
  .reading .prose section {
    display: block;
  }
  .reading .prose {
    max-width: var(--column);
  }
  .reading .prose .subhead + * {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
  .reading .prose .subhead {
    margin-bottom: var(--gap-tight);
  }
  .reading + .info {
    grid-column: 1 / -1;
    max-width: var(--column);
  }
}

/* Phones: the address and hours as one block with the links beside it, each link
   tall enough to tap. The shapes get the band under the mark and one more past the
   footer. */
@media (max-width: 759px) {
  :root {
    --gap: 20px;
    --gap-wide: clamp(34px, 5.5svh, 60px);
  }
  main {
    padding-top: clamp(40px, 7svh, 180px);
  }
  .display--hero {
    --hero-h: 160px;
  }
  .masthead__info {
    display: none;
  }
  .info {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .info__visit {
    display: block;
  }
  .info__visit p + p {
    margin-top: 10px;
  }
  .info__links {
    margin-top: -8px;
  }
  .info__links a {
    margin-block: 0;
    padding-block: 8px;
  }
  .field ~ .info {
    margin-bottom: 128px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shape {
    transition: none;
    will-change: auto;
  }
}
