/* ==========================================================================
   Luteya - a portfolio printed on newsprint

   Shape:   square corners everywhere. The only curves are holes punched
            through the paper: the notches at the ends of a tear line.
   Colour:  paper, ink and one spot ink (--accent). Nothing else.
   Paper:   the sheet is one length off a roll. Sections are joined by tear
            lines, and the foot of the page is where it was torn off.
   Layers:  page content 0-3, sticky bar 40, paper grain 60, skip link 70.
   Motion:  everything animated is gated behind html.motion, which is only
            set when the visitor has not asked for reduced motion.
   ========================================================================== */

/* ---------- Fonts (self-hosted, latin subsets) ---------- */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin-opsz-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin-wght-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("../fonts/archivo-latin-wdth-normal.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}

/* Twelve chess glyphs cut from Noto Sans Symbols 2 (SIL Open Font License). */
@font-face {
  font-family: "Chess Figurines";
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url("../fonts/chess-figurines.woff2") format("woff2");
  unicode-range: U+2654-265F;
}

/* ---------- Tokens ---------- */

/* One edition only: the page stays on light paper even when the visitor's
   system is in dark mode. */
:root {
  color-scheme: only light;

  --paper: #e8e7e1;
  --paper-2: #dcdad2;
  --print: #f4f3ee;
  --desk: #c8c6bd;
  --ink: #0d1c20;
  --ink-2: #3b494c;
  --hair: rgba(13, 28, 32, 0.26);
  --accent: #bd2d16;
  --on-accent: #fff6f1;

  /* Tear lines: the ink of the slits, the radius of the notch at each end and
     the desk seen through it, which lies in the shadow of the paper. */
  --perf: rgba(13, 28, 32, 0.55);
  --notch: clamp(0.5rem, 1.1vw, 0.75rem);
  --pit: #b3b1a8;
  /* The strip of desk left showing below the torn foot of the sheet. */
  --strip: clamp(2.25rem, 5vw, 4rem);

  /* How the halftone layer and the grain sit on the paper. */
  --tone-blend: multiply;
  --tone-alpha: 0.92;
  --grain-blend: multiply;
  --grain-alpha: 0.2;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bar-h: 3.5rem;
  --gutter: clamp(1rem, 3.2vw, 2.75rem);
  --col-gap: clamp(1.25rem, 2.6vw, 2.75rem);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--bar-h) + 1.25rem);
}

body {
  margin: 0;
  padding-bottom: var(--strip);
  min-height: 100dvh;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.5;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

p,
h1,
h2,
h3,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

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

::selection {
  background: var(--ink);
  color: var(--paper);
}

[hidden] {
  display: none !important;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.skip {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 70;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font: 700 0.875rem/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

.icon {
  flex: none;
  width: 1.1em;
  height: 1.1em;
  fill: currentColor;
}

/* Paper grain. Fixed and inert so it never repaints with the scroll. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: var(--grain-alpha);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* The sheet of paper everything is printed on. */
.sheet {
  position: relative;
  max-width: 92rem;
  margin-inline: auto;
  background: var(--paper);
  box-shadow: 0 2rem 6rem -2rem rgba(0, 0, 0, 0.4);
  /* Pictures that tilt and drift with the scroll must never widen the page. */
  overflow-x: clip;
}

/* The foot of the sheet was torn off the roll against a serrated bar. The
   teeth are an image, so their colours are written out: --paper and --hair. */
.sheet::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  height: 0.5rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='8' viewBox='0 0 16 8'%3E%3Cpath d='M0 0h16L8 7.5z' fill='%23e8e7e1'/%3E%3Cpath d='M0 0 8 7.5 16 0' fill='none' stroke='%230d1c20' stroke-opacity='.26'/%3E%3C/svg%3E") 0 0 / 1rem 100% round;
  filter: drop-shadow(0 0.35rem 0.3rem rgba(0, 0, 0, 0.16));
  pointer-events: none;
}

/* On a screen wider than the sheet its long edges show, and the hairline that
   marks them is drawn inside the sheet so a notch can cut through it. */
@media (min-width: 92.0625rem) {
  .sheet,
  .bar {
    --edge: inset 1px 0 0 var(--hair), inset -1px 0 0 var(--hair);
  }

  .sheet {
    box-shadow: var(--edge), 0 2rem 6rem -2rem rgba(0, 0, 0, 0.4);
  }

  .bar {
    box-shadow: var(--edge);
  }
}

/* ---------- Tear lines ----------
   Where one section ends and the next begins the sheet is perforated: a row
   of slits from edge to edge and a notch punched out of each edge, showing the
   desk. It is a single pseudo-element so the script can still run the slits
   across the page (--rule goes from 0 to 1). */

.story,
.about,
.contact,
.foot {
  position: relative;
}

.story + .story::before,
.about::before,
.contact::before,
.foot::before {
  --hole: var(--pit) calc(100% - 1.5px), var(--hair) calc(100% - 1px), var(--hair) calc(100% - 0.5px), transparent;
  --inset: calc(var(--notch) + 0.5rem);
  content: "";
  position: absolute;
  top: calc(var(--notch) * -1);
  right: calc(var(--gutter) * -1);
  left: calc(var(--gutter) * -1);
  height: calc(var(--notch) * 2);
  background:
    radial-gradient(circle var(--notch) at 0 50%, var(--hole)),
    radial-gradient(circle var(--notch) at 100% 50%, var(--hole)),
    repeating-linear-gradient(90deg, var(--perf) 0 0.5rem, transparent 0.5rem 0.875rem) var(--inset) 50% / calc((100% - var(--inset) * 2) * var(--rule, 1)) 2px no-repeat;
  pointer-events: none;
}

.foot::before {
  right: 0;
  left: 0;
}

/* ---------- Buttons and links ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.95rem 1.3rem;
  border: 1px solid var(--ink);
  /* The spot ink floods up from the bottom edge on hover. */
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / 100% 0 var(--ink);
  color: var(--paper);
  font: 700 0.875rem/1 var(--sans);
  font-stretch: 82%;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-size 0.4s var(--ease), border-color 0.3s, color 0.3s, transform 0.12s;
}

.btn:hover,
.btn:focus-visible {
  background-size: 100% 100%;
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn .icon,
.link .icon {
  transition: transform 0.4s var(--ease);
}

/* Icons answer the hover: the jump arrow dips, the others lift. */
.btn:hover .icon {
  transform: scale(1.18) rotate(-8deg);
}

.btn[href^="#"]:hover .icon {
  transform: translateY(0.22em);
}

.link:hover .icon {
  transform: translate(0.14em, -0.14em);
}

.btn--small {
  padding: 0.6rem 0.85rem;
  font-size: 0.75rem;
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: 400 0.9375rem/1.2 var(--mono);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.28em;
  transition: color 0.2s;
}

.link:hover {
  color: var(--accent);
}

.link--button {
  padding: 0.35rem 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.6rem;
}

.actions--stack {
  flex-direction: column;
  align-items: flex-start;
}

/* ---------- Top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--hair);
}

.bar__inner {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  height: var(--bar-h);
  padding-inline: var(--gutter);
}

.bar__left {
  display: flex;
  flex: 1;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.75rem);
  min-width: 0;
}

.bar__mark {
  flex: none;
  width: 8.75rem;
  color: var(--ink);
}

.bar__mark svg {
  width: 100%;
  height: auto;
  fill: currentColor;
}

/* On load the wordmark is sketched in spot ink, then flooded with black. */
.wordmark path {
  stroke: var(--accent);
  stroke-width: 0.75;
  stroke-opacity: 0;
  vector-effect: non-scaling-stroke;
}

.bar__date {
  overflow: hidden;
  color: var(--ink-2);
  font: 400 0.8125rem/1 var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar__nav {
  display: flex;
  gap: clamp(0.9rem, 2.2vw, 2rem);
}

.bar__nav a {
  position: relative;
  padding: 0.7rem 0;
  font: 700 0.8125rem/1 var(--sans);
  font-stretch: 82%;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
}

.bar__nav a::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0.35rem;
  left: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}

.bar__nav a:hover::after,
.bar__nav a:focus-visible::after,
.bar__nav a[aria-current]::after {
  transform: scaleX(1);
}

/* The sound switch: a speaker, struck out when sound is off. */
.bar__sound {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-right: -0.55rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: color 0.2s;
}

.bar__sound:hover {
  color: var(--accent);
}

.bar__sound .icon {
  width: 1.2rem;
  height: 1.2rem;
}

.bar__sound[aria-pressed="true"] .icon--off,
.bar__sound[aria-pressed="false"] .icon--on {
  display: none;
}

/* ---------- Front page ---------- */

.front {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - var(--bar-h) - 2.75rem);
  padding: clamp(2rem, 6vh, 4.5rem) var(--gutter) clamp(2rem, 6vh, 4rem);
  overflow-x: clip;
}

/* The headline is the masthead: a banner across the full sheet. */
.front h1 {
  font: 600 clamp(2.6rem, 7.4vw, 6.75rem) / 0.94 var(--serif);
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.lead {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  align-items: center;
  margin-top: clamp(1.75rem, 5.5vh, 3.75rem);
}

.lead__copy {
  grid-column: 1 / span 5;
}

.deck {
  max-width: 30ch;
  color: var(--ink-2);
  font: italic 400 clamp(1.25rem, 1.9vw, 1.7rem) / 1.32 var(--serif);
}

.lead .actions {
  margin-top: clamp(1.4rem, 3.4vh, 2.25rem);
}

/* Three prints laid across the page, one per app. */
.lead__stack {
  position: relative;
  grid-column: 7 / -1;
  justify-self: end;
  width: min(100%, 36dvh * 2.3);
  aspect-ratio: 2.3 / 1;
}

.print {
  position: absolute;
  width: 37%;
}

.print--1 {
  top: 10%;
  left: 0;
  rotate: -5deg;
}

.print--2 {
  top: 0;
  left: 31.5%;
  z-index: 2;
  rotate: 3deg;
}

.print--3 {
  top: 14%;
  right: 0;
  z-index: 1;
  rotate: 7deg;
}

.print .plate {
  aspect-ratio: 1;
  border: 0.4rem solid var(--print);
  box-shadow: 0 0 0 1px var(--hair), 0 1.4rem 1.9rem -1.2rem rgba(0, 0, 0, 0.55);
  transition: transform 0.6s var(--ease), box-shadow 0.6s var(--ease);
}

.print:hover,
.print:focus-within {
  z-index: 3;
}

.print .plate:hover,
.print .plate:focus-visible {
  transform: translateY(-0.5rem) scale(1.04);
  box-shadow: 0 0 0 1px var(--hair), 0 2.2rem 2.4rem -1.4rem rgba(0, 0, 0, 0.6);
}

/* ---------- Halftone plates ----------
   Two copies of the same image. The lower one is pushed through a contrast
   threshold with a dot screen on top, which turns grey values into dots of
   different sizes, the way a newspaper prints a photograph. The upper one is
   the clean colour image, wiped in when the plate scrolls into view. */

.plate {
  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
}

.plate__tone {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #fff;
  filter: contrast(18);
  mix-blend-mode: var(--tone-blend);
  opacity: var(--tone-alpha);
}

.plate__tone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) brightness(0.86) contrast(1.15) blur(1px);
  transform: scale(1.03);
}

.plate__tone::after {
  content: "";
  position: absolute;
  inset: -30%;
  opacity: 0.5;
  background-image: radial-gradient(circle at center, #000 0%, #fff 74%);
  background-size: 5px 5px;
  transform: rotate(24deg);
}

.plate__ink {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.motion .plate__ink {
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.15s cubic-bezier(0.7, 0, 0.2, 1);
}

.motion .plate:not(.is-live) .plate__ink {
  clip-path: inset(0 0 100% 0);
}

.plate.is-live .plate__tone {
  visibility: hidden;
  transition: visibility 0s 1.3s;
}

/* ---------- Wire ---------- */

.wire {
  overflow: hidden;
  border-block: 1px solid var(--ink);
}

.wire:not(.is-rolling) {
  overflow-x: auto;
}

.wire__track {
  display: flex;
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
}

.wire__track li {
  display: flex;
  align-items: center;
  padding-block: 0.85rem;
  font: 700 0.8125rem/1 var(--sans);
  font-stretch: 82%;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* The separator borrows the stripes of the logo. */
.wire__track li::before {
  content: "";
  width: 0.875rem;
  height: 0.75rem;
  margin-inline: 1.6rem;
  background: repeating-linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 4px);
}

.wire a {
  text-decoration: none;
  transition: color 0.2s;
}

.wire a:hover {
  color: var(--accent);
}

/* ---------- Stories ---------- */

.work {
  padding-inline: var(--gutter);
}

.story {
  padding-block: clamp(3.5rem, 8vw, 7.5rem);
}

.headline {
  font: 600 clamp(3rem, 9.4vw, 8rem) / 0.92 var(--serif);
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.headline--md {
  font-size: clamp(2.5rem, 5.6vw, 4.75rem);
  line-height: 0.96;
  letter-spacing: -0.032em;
}

/* SplitText line masks: leave room for descenders while a line is clipped. */
.ln-mask {
  padding-bottom: 0.16em;
  margin-bottom: -0.16em;
}

.story__deck {
  margin-top: 0.9rem;
  font: italic 400 clamp(1.3rem, 2.1vw, 1.85rem) / 1.45 var(--serif);
}

/* Highlighter: each story is marked up in its app's own colour. The swipe
   width is animated when the story scrolls into view. */
.hl {
  --hl: #ffe500;
  margin-inline: -0.2em;
  padding: 0.06em 0.2em 0.1em;
  background: linear-gradient(var(--hl), var(--hl)) no-repeat 0 55% / var(--swipe, 100%) 84%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.hl--chess {
  --hl: #f2c45a;
}

.hl--js {
  --hl: #ffe500;
}

.hl--jam {
  --hl: #35c8ea;
}

.story__meta {
  display: flex;
  margin-top: 1.1rem;
  color: var(--ink-2);
  font: 400 0.8125rem/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.story__meta span + span {
  margin-left: 0.9rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--hair);
}

.story__copy {
  max-width: 46ch;
  margin-top: 1.5rem;
}

/* Column rules that draw themselves in from the top. */
.cols > * {
  position: relative;
}

.cols > * + *::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--col-gap) / -2);
  width: 1px;
  background: var(--hair);
  transform: scaleY(var(--draw, 1));
  transform-origin: top;
}

/* Lead story: Chess System */

.story--chess .story__head {
  margin-bottom: clamp(2rem, 4.5vw, 3.75rem);
}

.story--chess .story__grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 5fr) minmax(0, 4fr);
  column-gap: var(--col-gap);
}

.figures {
  margin-block: 1.75rem 2rem;
}

.figures div {
  padding-block: 0.8rem;
}

.figures div + div {
  border-top: 1px solid var(--hair);
}

.figures dt {
  font: 600 2.5rem/1 var(--serif);
  letter-spacing: -0.03em;
  /* Tabular figures keep the number steady while it counts up. */
  font-variant-numeric: lining-nums tabular-nums;
}

.figures dd {
  margin-top: 0.2rem;
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.3;
}

.problem__task {
  font: italic 500 1.35rem/1.25 var(--serif);
}

.board-wrap {
  max-width: 31rem;
  margin-top: 1.1rem;
}

.board {
  position: relative;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  background: var(--paper);
  container-type: inline-size;
  touch-action: manipulation;
  user-select: none;
}

.board__sqs {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(8, 1fr) / repeat(8, 1fr);
}

.sq {
  position: relative;
}

/* Dark squares are hatched, as in a printed diagram. */
.sq--dark {
  background: repeating-linear-gradient(135deg, var(--ink) 0 1px, transparent 1px 5px);
}

.sq.is-from::after,
.sq.is-mate::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
}

.sq.is-mate::after {
  background: var(--accent);
  opacity: 0.28;
}

.pc {
  position: absolute;
  top: calc(var(--r) * 12.5%);
  left: calc(var(--f) * 12.5%);
  display: grid;
  place-items: center;
  width: 12.5%;
  height: 12.5%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: "Chess Figurines", "Noto Sans Symbols 2", "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", sans-serif;
  font-size: 2.4rem;
  font-size: 10.6cqw;
  line-height: 1;
}

.pc > span {
  grid-area: 1 / 1;
}

.pc--w {
  cursor: pointer;
}

/* White pieces: a paper-coloured silhouette under the outline glyph, so the
   hatching of a dark square does not show through the piece. */
.pc__fill {
  color: var(--paper);
}

.pc--b {
  text-shadow: 0 0 0 var(--ink), 0.03em 0 0 var(--paper), -0.03em 0 0 var(--paper), 0 0.03em 0 var(--paper), 0 -0.03em 0 var(--paper);
}

.pc:focus-visible {
  outline-offset: -3px;
}

/* A white piece lifts off its square when it is picked up. */
.pc--w > span {
  transition: transform 0.3s var(--ease);
}

.pc--w:focus-visible > span,
.pc--w[aria-pressed="true"] > span {
  transform: translateY(-10%);
}

@media (hover: hover) {
  .board:not(.is-solved) .pc--w:hover > span {
    transform: translateY(-10%);
  }
}

.board__stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  padding: 0.5em 0.7em 0.42em;
  border: 3px solid var(--accent);
  background: var(--paper);
  color: var(--accent);
  font: 800 2rem/1 var(--sans);
  font-size: 8.4cqw;
  font-stretch: 70%;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-7deg);
  opacity: 0;
  pointer-events: none;
}

.board.is-solved .board__stamp {
  opacity: 1;
}

.problem__status {
  min-height: 2.9em;
  margin-top: 1rem;
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.4;
}

.problem__actions {
  margin-top: 0.25rem;
}

.story__plates--pair {
  display: grid;
  grid-template: 1fr / repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.story__plates--pair .plate {
  border: 1px solid var(--ink);
}

.story__plates--pair .plate + .plate {
  align-self: end;
  margin-top: 2.75rem;
}

/* Second story: JavaScript Baby Steps */

.story--js {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: var(--col-gap);
  align-items: center;
}

.story__plates--fan {
  position: relative;
  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
  aspect-ratio: 1 / 1.16;
}

.story__plates--fan .plate {
  position: absolute;
  width: 56%;
  border: 0.4rem solid var(--print);
  box-shadow: 0 0 0 1px var(--hair), 0 1.6rem 2rem -1.3rem rgba(0, 0, 0, 0.55);
}

.story__plates--fan .plate:first-child {
  top: 0;
  left: 0;
  rotate: -5deg;
}

.story__plates--fan .plate:last-child {
  right: 0;
  bottom: 0;
  rotate: 4deg;
}

/* The sandbox wears the app's own colours: yellow bar, dark editor, coloured
   syntax. */
.sandbox {
  --js-yellow: #ffe500;
  --js-black: #0b0b0c;
  --code-bg: #14161b;
  --code-bg-2: #1c1f26;
  --code-ink: #ecebe4;
  --code-dim: #8d96a6;
  --code-keyword: #ff9d5c;
  --code-string: #a8e06c;
  --code-number: #ffd866;
  --code-call: #7cc5ff;
  --code-builtin: #5fe0d0;
  --code-error: #ff8078;
  max-width: 38rem;
  margin-block: 1.9rem;
  border: 1px solid var(--ink);
  background: var(--code-bg);
}

.sandbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  background: var(--js-yellow);
  color: var(--js-black);
}

.sandbox__bar label {
  font: 800 0.8125rem/1 var(--sans);
  font-stretch: 82%;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sandbox__bar .btn {
  border-color: var(--js-black);
  background: var(--js-black);
  color: var(--js-yellow);
}

.sandbox__bar .btn:hover {
  border-color: var(--js-black);
  background: var(--js-black);
  color: #fff;
}

.sandbox__bar .btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.sandbox__bar :focus-visible {
  outline-color: var(--js-black);
}

.sandbox__editor {
  position: relative;
}

.sandbox__paint,
.sandbox textarea {
  margin: 0;
  padding: 1rem;
  border: 0;
  font: 400 0.9375rem/1.6 var(--mono);
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.sandbox__paint {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: var(--code-ink);
  pointer-events: none;
}

.sandbox__paint code {
  font: inherit;
}

.sandbox textarea {
  position: relative;
  display: block;
  width: 100%;
  min-height: 9.5rem;
  border-radius: 0;
  background: transparent;
  color: var(--code-ink);
  caret-color: var(--js-yellow);
  resize: none;
  overflow: hidden;
}

/* Once the script paints the highlighted copy underneath, the textarea keeps
   only its caret and selection. */
.sandbox__editor.is-painted textarea {
  color: transparent;
}

/* Selected code is set solid, black on yellow, over the painted copy: a
   translucent highlight left the grey comments too faint to read. */
.sandbox textarea::selection {
  background: var(--js-yellow);
  color: var(--js-black);
}

.sandbox textarea:focus-visible {
  outline-color: var(--js-yellow);
  outline-offset: -2px;
}

.t-comment {
  color: var(--code-dim);
  font-style: italic;
}

.t-keyword {
  color: var(--code-keyword);
}

.t-string {
  color: var(--code-string);
}

.t-number {
  color: var(--code-number);
}

.t-call {
  color: var(--code-call);
}

.t-builtin {
  color: var(--code-builtin);
}

/* The caret that follows the lesson while it types itself in. */
.t-caret {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  margin-left: 1px;
  background: var(--js-yellow);
  vertical-align: text-bottom;
  animation: caret-blink 0.8s steps(1) infinite;
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

.sandbox__out {
  display: block;
  min-height: 3.2rem;
  padding: 0.85rem 1rem 0.85rem 0.85rem;
  border-left: 0.3rem solid var(--code-dim);
  background: var(--code-bg-2);
  color: var(--code-ink);
  font: 400 0.9375rem/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: border-color 0.3s;
}

.sandbox__out.is-ok {
  border-left-color: var(--code-string);
}

.sandbox__out.is-error {
  border-left-color: var(--code-error);
}

/* Each logged line is its own block, so the script can print them in turn. */
.sandbox__line {
  display: block;
}

.sandbox__line:empty::before {
  content: "\200b";
}

.sandbox__hint {
  color: var(--code-dim);
}

.sandbox__error {
  display: block;
  color: var(--code-error);
}

.sandbox__help {
  padding: 0.6rem 1rem;
  background: var(--paper);
  color: var(--ink-2);
  font: 400 0.75rem/1.4 var(--mono);
}

/* Late news: Invasion Jam. The box is a ticket for a game that is not out
   yet: the picture is the stub, and a tear line runs between the two with a
   notch clipped out of the frame at each end. */

.story--jam {
  perspective: 1800px;
}

.jam {
  --notch: clamp(0.7rem, 1.5vw, 1rem);
  --hole: var(--paper) calc(100% - 3.5px), var(--ink) calc(100% - 3px), var(--ink) calc(100% - 0.5px), transparent;
  --inset: calc(var(--notch) + 0.5rem);
  /* Which way the tear line runs: down the ticket, or across it when stacked. */
  --run: 180deg;
  --slits: repeating-linear-gradient(var(--run), var(--ink) 0 0.5rem, transparent 0.5rem 0.875rem);
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  transform-origin: 50% 0;
}

/* The two halves are framed separately, so the script can tug the stub away
   from the tear line. Each carries its own quarter of the two notches. */
.jam__copy,
.jam__stub {
  position: relative;
  border: 3px solid var(--ink);
  background: var(--print);
}

.jam__copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(1.5rem, 4.5vw, 4.5rem);
  border-right: 0;
}

/* The picture stops short of the tear line, leaving the notches clear. */
.jam__stub {
  display: grid;
  padding-left: calc(var(--notch) + 0.375rem);
  border-left: 0;
  transform-origin: 0 0;
}

.jam__copy::after,
.jam__stub::before {
  content: "";
  position: absolute;
  top: -3px;
  bottom: -3px;
  z-index: 2;
  width: var(--notch);
  pointer-events: none;
}

.jam__copy::after {
  right: 0;
  background:
    radial-gradient(circle var(--notch) at 100% 0, var(--hole)),
    radial-gradient(circle var(--notch) at 100% 100%, var(--hole)),
    var(--slits) 100% var(--inset) / 2px calc(100% - var(--inset) * 2) no-repeat;
}

.jam__stub::before {
  left: 0;
  background:
    radial-gradient(circle var(--notch) at 0 0, var(--hole)),
    radial-gradient(circle var(--notch) at 0 100%, var(--hole));
}

.jam__art {
  aspect-ratio: 4 / 5;
}

.jam__art img {
  object-position: 50% 28%;
}

.stamp {
  display: inline-block;
  /* In the ticket's column the stamp keeps its own width. */
  align-self: flex-start;
  margin-bottom: 1.6rem;
  padding: 0.55rem 0.75rem 0.45rem;
  border: 2px solid var(--accent);
  color: var(--accent);
  font: 800 1.0625rem/1 var(--sans);
  font-stretch: 72%;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  rotate: -4deg;
}

/* ---------- About ---------- */

.about {
  margin-inline: var(--gutter);
  padding-block: clamp(3.5rem, 8vw, 7.5rem);
}

.about__grid {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
  column-gap: var(--col-gap);
  align-items: start;
  margin-top: clamp(1.75rem, 3.5vw, 3rem);
}

.about__text {
  columns: 2;
  column-gap: var(--col-gap);
  column-rule: 1px solid var(--hair);
}

.about__text p + p {
  margin-top: 1em;
}

.about__text p {
  orphans: 2;
  widows: 2;
}

.about__text p:first-child::first-letter {
  float: left;
  padding: 0.07em 0.1em 0 0;
  color: var(--accent);
  font: 600 4.5em/0.74 var(--serif);
}

.pull {
  padding-block: 1.4rem 1.5rem;
  border-block: 1px solid var(--ink);
  font: italic 500 clamp(1.75rem, 3.1vw, 2.75rem) / 1.14 var(--serif);
  letter-spacing: -0.015em;
}

/* ---------- Contact ---------- */

.contact {
  margin-inline: var(--gutter);
  padding-block: clamp(4.5rem, 11vw, 10rem);
  text-align: center;
}

.contact .headline {
  font-size: clamp(2.6rem, 7.4vw, 6.5rem);
}

.contact__mail {
  margin-top: clamp(1.5rem, 3vw, 2.5rem);
  font: italic 400 clamp(1.75rem, 5.2vw, 4.25rem) / 1.2 var(--serif);
  letter-spacing: -0.02em;
}

.contact__mail a {
  display: inline-block;
  padding-bottom: 0.08em;
  background: linear-gradient(var(--accent), var(--accent)) no-repeat 0 100% / var(--underline, 100%) 3px;
  text-decoration: none;
  transition: color 0.25s;
}

.contact__mail a:hover {
  color: var(--accent);
}

.contact__phone {
  margin-top: 1.75rem;
}

/* ---------- Footer ---------- */

/* The last length on the roll: a stub below the final tear line. */
.foot {
  padding: 2rem var(--gutter) 2.25rem;
}

.foot__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  color: var(--ink-2);
  font: 400 0.8125rem/1.5 var(--mono);
}

.foot__mark {
  width: 9.5rem;
  color: var(--ink);
}

.foot__mark svg {
  width: 100%;
  height: auto;
  fill: currentColor;
}

.foot__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  align-items: center;
}

.foot__links .link {
  font-size: 0.8125rem;
}

/* ---------- Retired page (404) ---------- */

/* A single slip that fills the screen, torn foot and desk included. The page
   has no script, so the slip is fed onto the desk by CSS alone. */
.sheet--slip {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--strip));
  animation: feed 0.9s var(--ease) backwards;
}

@keyframes feed {
  from {
    transform: translateY(calc(-100% - 1rem));
  }
}

.gone {
  display: grid;
  flex: 1;
  place-items: center;
  padding: clamp(3rem, 10vw, 8rem) var(--gutter);
  text-align: center;
}

.gone .headline {
  font-size: clamp(2.6rem, 7.4vw, 6rem);
}

.gone .deck {
  max-width: 40ch;
  margin: 1.25rem auto 0;
}

.gone .actions {
  justify-content: center;
  margin-top: 2rem;
}

/* ---------- Intro: hold the front page until the press starts ---------- */

.intro .wordmark path {
  fill-opacity: 0;
}

.intro .front [data-enter] {
  visibility: hidden;
}

/* ---------- Smaller screens ---------- */

@media (max-width: 64rem) {
  .story--chess .story__grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    row-gap: 3rem;
  }

  .story--chess .story__plates {
    grid-column: 1 / -1;
    max-width: 30rem;
  }

  .story--chess .story__plates::before {
    display: none;
  }
}

@media (max-width: 56rem) {
  .lead {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 2.75rem;
  }

  .lead__copy,
  .lead__stack {
    grid-column: 1 / -1;
  }

  /* On narrow screens the prints sit in a pile instead of a row. */
  .lead__stack {
    justify-self: center;
    width: min(100%, 26rem);
    aspect-ratio: 1 / 0.84;
  }

  .print {
    width: 48%;
  }

  .print--1 {
    top: 4%;
    left: 2%;
    rotate: -6deg;
  }

  .print--2 {
    top: 36%;
    left: 27%;
  }

  .print--3 {
    top: 0;
    right: 1%;
    width: 42%;
  }

  .story--js {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 3rem;
  }

  /* Name the story before showing its pictures. */
  .story--js .story__body {
    order: -1;
  }

  .story__plates--fan {
    max-width: 24rem;
  }

  /* Stacked, the ticket tears across instead of down. */
  .jam {
    --run: 90deg;
    grid-template-columns: minmax(0, 1fr);
  }

  .jam__copy {
    border-right: 3px solid var(--ink);
    border-bottom: 0;
  }

  .jam__stub {
    padding: calc(var(--notch) + 0.375rem) 0 0;
    border-top: 0;
    border-left: 3px solid var(--ink);
  }

  .jam__art {
    aspect-ratio: 5 / 4;
  }

  .jam__copy::after,
  .jam__stub::before {
    top: auto;
    right: -3px;
    bottom: auto;
    left: -3px;
    width: auto;
    height: var(--notch);
  }

  .jam__copy::after {
    bottom: 0;
    background:
      radial-gradient(circle var(--notch) at 0 100%, var(--hole)),
      radial-gradient(circle var(--notch) at 100% 100%, var(--hole)),
      var(--slits) var(--inset) 100% / calc(100% - var(--inset) * 2) 2px no-repeat;
  }

  .jam__stub::before {
    top: 0;
    background:
      radial-gradient(circle var(--notch) at 0 0, var(--hole)),
      radial-gradient(circle var(--notch) at 100% 0, var(--hole));
  }

  .about__grid {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 2.5rem;
  }
}

@media (max-width: 40rem) {
  body {
    font-size: 1.0625rem;
  }

  .bar__date {
    display: none;
  }

  .bar__mark {
    width: 6.75rem;
  }

  .bar__nav a {
    font-size: 0.75rem;
  }

  .story--chess .story__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cols > * + *::before {
    display: none;
  }

  .about__text {
    columns: 1;
  }

  .foot__inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Forced colours drop background images, so a tear line becomes a border. */
@media (forced-colors: active) {
  .story + .story::before,
  .about::before,
  .contact::before,
  .foot::before {
    top: 0;
    height: 0;
    border-top: 2px dashed CanvasText;
  }

  .jam__copy {
    border-right: 2px dashed CanvasText;
  }
}

@media (forced-colors: active) and (max-width: 56rem) {
  .jam__copy {
    border-right: 3px solid CanvasText;
    border-bottom: 2px dashed CanvasText;
  }
}

/* The narrowest phones: the top bar tightens so the logo, the three links and
   the sound switch still sit on one line. */
@media (max-width: 23.5rem) {
  .bar__mark {
    width: 5rem;
  }

  .bar__nav {
    gap: 0.6rem;
  }

  .bar__nav a {
    font-size: 0.6875rem;
  }

  .bar__sound {
    width: 1.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
