/* ==========================================================================
   trimbitas.co.uk

   Direction: a cold Suffolk morning at the kitchen table, laptop open, a route
   north planned that will not be taken. The ground is grey-green daylight, not
   warm paper. The primary accent is the petrol blue of a map and a screen at
   six in the morning. There is exactly one warm colour on this site - the burnt
   orange of the Opel Rekord from chapter 03 - and it is spent on the marker for
   that chapter and on the moments where the reader's hand touches the page.

   Signature: the route rail. On the index, the book is a walked line with
   numbered waypoints, and the standalone essays sit deliberately off it. On a
   post, the rail returns in the margin with the essay's own section headings as
   waypoints, filling as you read. Reading the piece is walking the route.
   ========================================================================== */

:root {
  --ground:      #E8EAE7;
  --ground-lift: #F1F3F0;
  --ink:         #14181A;
  --soft:        #545C60;
  --faint:       #7C8489;
  --rule:        #C9CDC8;
  --rule-hard:   #AAB0AC;
  --north:       #2E5266;
  --rekord:      #C24A14;
  --selection:   rgba(46, 82, 102, .18);

  --measure: 34rem;
  --wrap:    46rem;

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #14181A;
    --ground-lift: #1B2023;
    --ink:         #E2E6E3;
    --soft:        #A2AAAD;
    --faint:       #7C8489;
    --rule:        #2C3438;
    --rule-hard:   #414A4F;
    --north:       #86AFC4;
    --rekord:      #E0703C;
    --selection:   rgba(134, 175, 196, .22);
  }
}

:root[data-theme="dark"] {
  --ground:      #14181A;
  --ground-lift: #1B2023;
  --ink:         #E2E6E3;
  --soft:        #A2AAAD;
  --faint:       #7C8489;
  --rule:        #2C3438;
  --rule-hard:   #414A4F;
  --north:       #86AFC4;
  --rekord:      #E0703C;
  --selection:   rgba(134, 175, 196, .22);
}

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

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
  font-variation-settings: "opsz" 16;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: inherit; }

img { max-width: 100%; height: auto; }

:focus-visible {
  outline: 2px solid var(--rekord);
  outline-offset: 3px;
  border-radius: 1px;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.5rem; }

/* Reading pages: the measure sets the width of everything, masthead included. */
.wrap.narrow { max-width: 37rem; }
.wrap.narrow .post-head,
.wrap.narrow .post-meta,
.wrap.narrow .prose,
.wrap.narrow .post-foot,
.wrap.narrow .page-head,
.wrap.narrow .lost { max-width: none; }

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--ground);
  padding: .6rem 1rem; font-family: var(--mono); font-size: .8125rem;
}
.skip:focus { left: 1rem; top: 1rem; z-index: 50; }

/* --- shared utility type ------------------------------------------------- */

.label {
  font-family: var(--mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

/* --- masthead ------------------------------------------------------------ */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 2.25rem 0 1.5rem;
}

.wordmark {
  font-family: var(--sans);
  font-variation-settings: "wdth" 118;
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
}
.wordmark:hover { color: var(--rekord); }

.masthead nav { display: flex; gap: 1.5rem; }

.masthead nav a {
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--soft);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}
.masthead nav a:hover,
.masthead nav a[aria-current] { color: var(--ink); border-bottom-color: var(--rekord); }

/* --- opening statement --------------------------------------------------- */

.opening { padding: 3.5rem 0 4rem; max-width: 32rem; }

.opening .statement {
  font-size: clamp(1.5rem, 4.4vw, 2.1875rem);
  line-height: 1.24;
  font-variation-settings: "opsz" 40;
  font-weight: 400;
  margin: 0 0 1.75rem;
  text-wrap: balance;
}

.opening .who {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--soft);
  margin: 0;
  max-width: 28rem;
}

.opening .who strong { font-weight: 600; color: var(--ink); }

/* --- section heads ------------------------------------------------------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: .875rem;
  border-bottom: 1px solid var(--rule-hard);
  margin: 0 0 .5rem;
}

.section-head h2 {
  font-family: var(--mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0;
}

.section-head .note {
  font-family: var(--serif);
  font-size: .875rem;
  font-style: italic;
  color: var(--faint);
}

/* --- the route rail (index) ---------------------------------------------- */

.route { padding-bottom: 4rem; }

.rail {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

/* the line itself, running through the waypoints */
.rail::before {
  content: "";
  position: absolute;
  left: 4.0625rem;
  top: 1.8125rem;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom,
              var(--rule-hard) calc(100% - 2.75rem), transparent);
}

.rail li { margin: 0; }

.rail a {
  display: grid;
  grid-template-columns: 2.25rem 2.125rem 1fr auto;
  align-items: baseline;
  gap: 0 .75rem;
  padding: 1.0625rem 0;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: background-color .18s ease;
}
.rail li:last-child a { border-bottom: 0; }

.rail a:hover { background: var(--ground-lift); }

.rail .wp-num {
  grid-column: 1;
  grid-row: 1;
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.rail a:hover .wp-num { color: var(--north); }

/* the waypoint marker: a ring on the line, filled on hover */
.rail .wp-dot {
  position: relative;
  justify-self: center;
  align-self: center;
  grid-column: 2;
  grid-row: 1;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 1px solid var(--rule-hard);
  background: var(--ground);
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.rail a:hover .wp-dot { background: var(--north); border-color: var(--north); transform: scale(1.3); }

/* chapter 03 is the orange Opel Rekord. It is the one warm thing on the route. */
.rail a[data-rekord] .wp-dot { background: var(--rekord); border-color: var(--rekord); }
.rail a[data-rekord]:hover .wp-dot { background: var(--rekord); border-color: var(--rekord); }
.rail a[data-rekord]:hover .wp-num { color: var(--rekord); }

.rail .wp-title {
  grid-column: 3;
  grid-row: 1;
  font-size: 1.125rem;
  line-height: 1.32;
  font-weight: 500;
  font-variation-settings: "opsz" 24;
  color: var(--ink);
  text-wrap: balance;
}
.rail a:hover .wp-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.rail .wp-date {
  grid-column: 4;
  grid-row: 1;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .06em;
  color: var(--faint);
  white-space: nowrap;
}

.rail .wp-dek {
  grid-column: 3 / span 2;
  grid-row: 2;
  font-size: .9375rem;
  line-height: 1.55;
  color: var(--soft);
  margin-top: .3125rem;
  max-width: 32rem;
}

/* --- off the route (standalone essays) ----------------------------------- */
/* Deliberately unrailed: these are not part of the book. */

.off { padding-bottom: 4rem; }

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

.loose a {
  display: block;
  padding: 1.0625rem 0 1.0625rem 5.875rem;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: background-color .18s ease;
}
.loose li:last-child a { border-bottom: 0; }
.loose a:hover { background: var(--ground-lift); }

.loose .wp-title { font-size: 1.125rem; line-height: 1.32; font-weight: 500; display: block; }
.loose a:hover .wp-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.loose .wp-dek { font-size: .9375rem; line-height: 1.55; color: var(--soft); margin-top: .3125rem; max-width: 32rem; }
.loose .wp-date { font-family: var(--mono); font-size: .6875rem; letter-spacing: .06em; color: var(--faint); display: block; margin-bottom: .25rem; }

/* --- post ---------------------------------------------------------------- */

.post-head { padding: 2.5rem 0 0; max-width: var(--measure); }

.post-head .kicker {
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 1.25rem;
  display: flex;
  gap: .625rem;
  align-items: center;
  flex-wrap: wrap;
}
.post-head .kicker a { color: var(--north); text-decoration: none; border-bottom: 1px solid var(--rule-hard); }
.post-head .kicker a:hover { color: var(--rekord); border-bottom-color: var(--rekord); }
.post-head .kicker .sep { color: var(--rule-hard); }

.post-head h1 {
  font-family: var(--sans);
  font-variation-settings: "wdth" 108;
  font-weight: 700;
  font-size: clamp(1.875rem, 5.6vw, 3rem);
  line-height: 1.04;
  letter-spacing: -.018em;
  margin: 0;
  text-wrap: balance;
}

.post-head .dek {
  font-size: clamp(1.125rem, 2.6vw, 1.3125rem);
  line-height: 1.45;
  font-variation-settings: "opsz" 28;
  color: var(--soft);
  margin: 1.125rem 0 0;
  text-wrap: pretty;
}

.post-meta {
  display: flex;
  gap: .625rem;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 1.75rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  max-width: var(--measure);
}
.post-meta .sep { color: var(--rule-hard); }

/* prose */

.prose { max-width: var(--measure); padding: 2.5rem 0 0; }

.prose > * { margin: 0 0 1.5rem; }
.prose > *:last-child { margin-bottom: 0; }

.prose p { text-wrap: pretty; }

.prose h2 {
  font-family: var(--sans);
  font-variation-settings: "wdth" 100;
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.28;
  letter-spacing: -.005em;
  margin: 3.25rem 0 1.125rem;
  scroll-margin-top: 2rem;
}

.prose h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.3;
  margin: 2.5rem 0 .875rem;
  scroll-margin-top: 2rem;
}

.prose a {
  color: var(--north);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
  text-decoration-color: var(--rule-hard);
}
.prose a:hover { color: var(--rekord); text-decoration-color: var(--rekord); }

.prose blockquote {
  margin: 2.25rem 0;
  padding: 0 0 0 1.5rem;
  border-left: 2px solid var(--rekord);
  font-size: 1.1875rem;
  line-height: 1.5;
  font-style: italic;
  font-variation-settings: "opsz" 28;
  color: var(--ink);
}
.prose blockquote p { margin: 0 0 .75rem; }
.prose blockquote p:last-child { margin: 0; }

.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li { margin: 0 0 .5rem; }

.prose hr {
  border: 0;
  height: 1px;
  background: var(--rule-hard);
  margin: 3rem auto;
  width: 4rem;
}

.prose code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--ground-lift);
  padding: .1em .35em;
  border: 1px solid var(--rule);
}

.prose pre {
  font-family: var(--mono);
  font-size: .8125rem;
  line-height: 1.6;
  background: var(--ground-lift);
  border: 1px solid var(--rule);
  padding: 1rem 1.125rem;
  overflow-x: auto;
}
.prose pre code { background: none; border: 0; padding: 0; }

.prose .footnote { font-size: .9375rem; color: var(--soft); }
.prose .footnote hr { display: none; }

/* --- the reading rail (post) --------------------------------------------- */
/* The route returns in the margin. Each of the essay's own section headings is
   a waypoint; the line fills as you walk it. Wide screens only - below that it
   would crowd the text, and the essay reads fine without it. */

.reading-rail {
  position: fixed;
  top: 22vh;
  height: 56vh;
  width: 1px;
  background: var(--rule);
  display: none;
  z-index: 5;
}

.reading-rail .fill {
  position: absolute;
  top: 0; left: 0;
  width: 1px;
  height: 0;
  background: var(--rekord);
  transition: height .1s linear;
}

.reading-rail .stop {
  position: absolute;
  left: -3px;
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px solid var(--rule-hard);
  background: var(--ground);
  padding: 0;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.reading-rail .stop:hover,
.reading-rail .stop.is-past { background: var(--rekord); border-color: var(--rekord); }
.reading-rail .stop:hover { transform: scale(1.45); }

.reading-rail .stop .name {
  position: absolute;
  left: 1.125rem;
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .04em;
  color: var(--soft);
  background: var(--ground);
  padding: .25rem .5rem;
  border: 1px solid var(--rule);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.reading-rail .stop:hover .name,
.reading-rail .stop:focus-visible .name { opacity: 1; }

@media (min-width: 1180px) {
  .reading-rail { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .reading-rail .fill { transition: none; }
  * { scroll-behavior: auto !important; }
}

/* --- post footer / neighbours -------------------------------------------- */

.post-foot { max-width: var(--measure); padding: 4rem 0 0; }

.neighbours {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  border-top: 1px solid var(--rule-hard);
  padding-top: 1.5rem;
}

.neighbours a {
  text-decoration: none;
  display: block;
}
.neighbours .dir {
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  display: block;
  margin-bottom: .375rem;
}
.neighbours .t { font-size: 1rem; line-height: 1.35; font-weight: 500; }
.neighbours a:hover .t { color: var(--rekord); }
.neighbours .next { text-align: right; }
.neighbours .empty { opacity: 0; pointer-events: none; }

/* --- footer -------------------------------------------------------------- */

.foot {
  margin-top: 5rem;
  border-top: 1px solid var(--rule);
  padding: 1.75rem 0 3rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}
.foot a { color: var(--soft); text-decoration: none; border-bottom: 1px solid var(--rule); }
.foot a:hover { color: var(--rekord); border-bottom-color: var(--rekord); }
.foot .set { display: flex; gap: 1.25rem; flex-wrap: wrap; }

/* --- page (about) -------------------------------------------------------- */

.page-head { padding: 2.5rem 0 0; max-width: var(--measure); }
.page-head h1 {
  font-family: var(--sans);
  font-variation-settings: "wdth" 108;
  font-weight: 700;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  line-height: 1.06;
  letter-spacing: -.015em;
  margin: 0;
}

/* --- 404 ----------------------------------------------------------------- */

.lost { padding: 5rem 0; max-width: var(--measure); }
.lost h1 {
  font-family: var(--sans);
  font-variation-settings: "wdth" 112;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 1.04;
  margin: 0 0 1rem;
}
.lost p { color: var(--soft); margin: 0 0 1.5rem; }

/* --- narrow screens ------------------------------------------------------ */

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

  .rail::before { left: 2.875rem; }

  .rail a {
    grid-template-columns: 1.375rem 1.75rem 1fr;
    gap: 0 .625rem;
    padding: .9375rem 0;
  }
  .rail .wp-num { grid-column: 1; font-size: .6875rem; }
  .rail .wp-date { grid-column: 3; grid-row: 3; margin-top: .375rem; }
  .rail .wp-dek { grid-column: 3; }

  .loose a { padding-left: 0; }
  .wrap.narrow { max-width: var(--wrap); }

  .opening { padding: 2.5rem 0 3rem; }
  .masthead { padding: 1.75rem 0 1.25rem; }
  .neighbours { grid-template-columns: 1fr; }
  .neighbours .next { text-align: left; }
}
