/*
 * chrisnewland.com
 * Cool slate paper, grotesk for structure, serif for reading.
 * Each kind of work has its own colour, used in the code-cache strip and the key.
 */

:root {
  color-scheme: light dark;

  --paper: #f2f4f6;
  --surface: #e7ebef;
  --ink: #1c2530;
  --muted: #586574;
  --rule: #cdd4dc;
  --link: #1f5fa6;
  --focus: #1f5fa6;

  --article: #2f6db5;
  --book: #9c3d54;
  --talk: #b98315;
  --video: #6b4fa8;
  --tool: #2b8a6b;

  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 42rem;
  --wide: 64rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121820;
    --surface: #1a222c;
    --ink: #e4e9ee;
    --muted: #9aa6b3;
    --rule: #2a3542;
    --link: #8db8ec;
    --focus: #8db8ec;

    --article: #5b93d6;
    --book: #c76a80;
    --talk: #d9a43c;
    --video: #9479cf;
    --tool: #4fb08f;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
}

a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3, nav, .entry-date, .entry-venue, .facts, .cache-key, .more, .actions .aside, .site-footer, .skip {
  font-family: var(--sans);
}

h1, h2, h3 { line-height: 1.15; margin: 0 0 0.6em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; font-weight: 600; }
h2 a { color: inherit; text-decoration: none; }
h2 a:hover { text-decoration: underline; }

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

.skip { position: absolute; left: 1rem; top: -3rem; background: var(--ink); color: var(--paper); padding: 0.5rem 0.8rem; z-index: 10; }
.skip:focus { top: 1rem; }

/* ---------------------------------------------------------------- frame */

.masthead, main, .site-footer {
  max-width: var(--wide);
  margin: 0 auto;
  padding-left: clamp(1.1rem, 4vw, 2.5rem);
  padding-right: clamp(1.1rem, 4vw, 2.5rem);
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark { font-family: var(--sans); font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; }

nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.4rem; font-size: 1rem; }
nav a { color: var(--muted); text-decoration: none; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

main { padding-top: 2.5rem; padding-bottom: 4rem; }

.site-footer {
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.site-footer p { max-width: var(--measure); margin: 0; }

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

.intro { max-width: var(--measure); margin-bottom: 3rem; }
.intro h1 { font-size: clamp(2.8rem, 8vw, 5rem); margin-bottom: 0.3em; }
.lede { font-size: 1.3rem; line-height: 1.55; margin: 0; }

/* The code-cache strip: one block per work, oldest first, coloured by kind. */
.cache { margin-bottom: 3.5rem; }
.cache h2 { margin-bottom: 0.3rem; }
.cache-note { color: var(--muted); max-width: var(--measure); margin: 0 0 1.6rem; font-size: 1rem; }

.cache-strip {
  list-style: none;
  margin: 0;
  padding: 1.5rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(1.6rem, 1fr));
  gap: 1.7rem 4px;
}

.cache-slot { position: relative; }

.cache-slot--year::before {
  content: attr(data-year);
  position: absolute;
  bottom: calc(100% + 0.3rem);
  left: 0;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.cache-slot--year .block { box-shadow: inset 3px 0 0 var(--ink); }

.block {
  display: block;
  height: 3.2rem;
  border-radius: 2px;
  background: var(--article);
  transition: transform 120ms ease-out;
}
.block:hover, .block:focus-visible { transform: translateY(-4px); }

.block--article { background: var(--article); }
.block--book, .block--interview { background: var(--book); }
.block--talk { background: var(--talk); }
.block--video { background: var(--video); }
.block--tool { background: var(--tool); }

/* On load the blocks fill in left to right, like a code cache filling up. */
@media (prefers-reduced-motion: no-preference) {
  .cache-strip .block {
    animation: compile 360ms ease-out backwards; /* backwards, so hover can still move it afterwards */
    transform-origin: bottom;
    animation-delay: calc(var(--i, 0) * 28ms);
  }
  @keyframes compile {
    from { opacity: 0; transform: scaleY(0.2); }
    to { opacity: 1; transform: none; }
  }
}

.cache-key {
  list-style: none;
  margin: 1.4rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  font-size: 0.92rem;
  color: var(--muted);
}
.cache-key li { display: flex; align-items: center; gap: 0.45rem; }

.swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; vertical-align: -0.05em; margin-right: 0.45rem; }
.cache-key .swatch { margin-right: 0; }

.home-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr));
  gap: 2.5rem 3.5rem;
  margin-bottom: 3.5rem;
}

.more { margin: 0.8rem 0 0; font-size: 0.95rem; }

/* --------------------------------------------------------------- lists */

.entries { list-style: none; margin: 0; padding: 0; }

.entry {
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  gap: 0 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
}
.entry:last-child { border-bottom: 1px solid var(--rule); }

.entry-date { color: var(--muted); font-size: 0.88rem; padding-top: 0.2rem; font-variant-numeric: tabular-nums; }
.entry-body { display: flex; flex-direction: column; gap: 0.1rem; }
.entry-title { font-weight: 600; text-decoration: none; color: var(--ink); line-height: 1.35; }
.entry-title:hover { color: var(--link); text-decoration: underline; }
.entry-venue { color: var(--muted); font-size: 0.9rem; }

.home-lists .entry { grid-template-columns: 6.2rem 1fr; }

@media (max-width: 34rem) {
  .entry, .home-lists .entry { grid-template-columns: 1fr; }
  .entry-date { padding-top: 0; }
}

.page-head { max-width: var(--measure); margin-bottom: 2.2rem; }
.page-head p { color: var(--muted); margin: 0; }

.year-group { max-width: 48rem; margin-bottom: 2.4rem; }
.year { font-size: 1.05rem; color: var(--muted); margin-bottom: 0.5rem; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- tools */

.tool-list { margin: 0; display: grid; gap: 1.4rem 3rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.tool dt { font-family: var(--sans); font-weight: 600; font-size: 1.1rem; }
.tool dt a { color: var(--ink); text-decoration-color: var(--tool); text-decoration-thickness: 2px; }
.tool dd { margin: 0.2rem 0 0; color: var(--muted); }
.tool-list--full { max-width: 52rem; grid-template-columns: 1fr; }
.out { display: inline-block; margin-left: 0.3rem; font-family: var(--sans); font-size: 0.92rem; }

/* ---------------------------------------------------------- single work */

.work { max-width: var(--measure); }

.facts { display: flex; flex-wrap: wrap; gap: 0.6rem 2.2rem; margin: 1.2rem 0 0; font-size: 0.95rem; }
.facts dt { color: var(--muted); font-size: 0.82rem; }
.facts dd { margin: 0; }

.summary { font-size: 1.2rem; }

.player { position: relative; aspect-ratio: 16 / 9; margin: 2rem 0; background: var(--surface); }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.actions { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 0.6rem; }
.actions a { font-family: var(--sans); font-weight: 600; }
.actions .aside { display: block; color: var(--muted); font-size: 0.88rem; }
.no-link { color: var(--muted); font-size: 1rem; }


