@font-face {
  font-family: "Oswald";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Enamel-sign navy, kerb grey, sign white, and five route-line colours */
  --navy: #1c2757;
  --kerb: #e9ece6;
  --sign: #fbfcfa;
  --ink: #1c2757;
  --ink-soft: #424a6b;
  --on-navy-soft: #c6cce2;

  --culture: #9b4dca;
  --food: #e09a00;
  --movement: #1e88e5;
  --people: #e0457b;
  --places: #2fa36b;

  --display: "Oswald", "Arial Narrow", "Helvetica Neue", sans-serif;
  --text: "Literata", Georgia, "Times New Roman", serif;

  --pad: clamp(20px, 4.5vw, 64px);
  --rail: 8px;
}

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

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

body {
  margin: 0;
  background: var(--kerb);
  color: var(--ink);
  font-family: var(--text);
  font-size: 18px;
  line-height: 1.6;
  font-optical-sizing: auto;
}

body.reading { overflow: hidden; }

h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 500; }
p { margin: 0; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

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

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

.skip {
  position: absolute;
  left: 12px; top: -60px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--sign);
  color: var(--navy);
  font-family: var(--display);
  font-size: 17px;
  text-decoration: none;
}
.skip:focus { top: 12px; outline-color: var(--food); }

/* Masthead: an enamel route sign */

.masthead {
  background: var(--navy);
  color: var(--sign);
  padding: clamp(28px, 5vw, 56px) var(--pad) clamp(28px, 4vw, 44px);
  overflow: hidden;
}

.masthead-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 36ch);
  align-items: end;
  gap: 24px 56px;
}

.title {
  font-weight: 600;
  font-size: clamp(60px, 10.5vw, 152px);
  line-height: 0.88;
  letter-spacing: -0.012em;
}

.intro {
  font-size: 19px;
  line-height: 1.55;
  color: var(--on-navy-soft);
  padding-bottom: 0.4em;
}

.lines {
  display: block;
  width: calc(100% + 2 * var(--pad));
  height: clamp(64px, 9vw, 128px);
  margin: clamp(24px, 3.5vw, 40px) calc(-1 * var(--pad)) clamp(20px, 3vw, 32px);
}

.ln {
  stroke: var(--c);
  stroke-width: 9px;
  vector-effect: non-scaling-stroke;
}

/* The one load-time moment: the five lines run out across the sign */
@media (prefers-reduced-motion: no-preference) {
  .ln { animation: draw 1.2s cubic-bezier(.6, 0, .2, 1) both; }
  .ln:nth-child(2) { animation-delay: .08s; }
  .ln:nth-child(3) { animation-delay: .16s; }
  .ln:nth-child(4) { animation-delay: .24s; }
  .ln:nth-child(5) { animation-delay: .32s; }
}
@keyframes draw {
  from { clip-path: inset(-20px 100% -20px -20px); }
  to { clip-path: inset(-20px -20px -20px -20px); }
}

.key {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px 28px;
}

.key li {
  border-top: 6px solid var(--c);
  padding-top: 10px;
  display: grid;
  gap: 2px;
}

.key-name {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 500;
  line-height: 1.2;
}

.key-note {
  font-size: 15px;
  line-height: 1.45;
  color: var(--on-navy-soft);
}

/* Browsing layout */

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(32px, 5vw, 64px) var(--pad) 40px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 72px;
}

.finder {
  position: sticky;
  top: 28px;
  align-self: start;
  display: grid;
  gap: 20px;
}

.finder-heading { font-size: 28px; line-height: 1.15; }

.field label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 500;
}

.field input,
.field select {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border: 2px solid var(--navy);
  border-radius: 6px;
  background: var(--sign);
  font-size: 17px;
}

.field input::placeholder { color: #6b7290; }

.select-wrap { position: relative; }
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  font-family: var(--display);
  font-size: 18px;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 18px; top: 50%;
  width: 10px; height: 10px;
  border-right: 2.5px solid var(--navy);
  border-bottom: 2.5px solid var(--navy);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.mark {
  width: 15px; height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
[aria-pressed="true"] .mark { fill: currentColor; }

.saved-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  padding: 0 8px 0 20px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: transparent;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 500;
  text-align: left;
}
.saved-toggle:hover { background: var(--sign); }
.saved-toggle[aria-pressed="true"] { background: var(--navy); color: var(--sign); }

.saved-count {
  margin-left: auto;
  min-width: 34px; height: 34px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--navy);
  color: var(--sign);
  font-size: 16px;
}
.saved-toggle[aria-pressed="true"] .saved-count { background: var(--sign); color: var(--navy); }

.status { font-size: 15px; color: var(--ink-soft); }

/* The route: stories as stops on a line, newest first */

.stories:focus { outline: none; }

.route {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 860px;
}

.stop {
  --line: var(--navy);
  display: grid;
  grid-template-columns: 64px 32px minmax(0, 1fr);
  column-gap: 24px;
  padding-bottom: 52px;
}

.stop[data-topic="Culture"]  { --line: var(--culture); }
.stop[data-topic="Food"]     { --line: var(--food); }
.stop[data-topic="Movement"] { --line: var(--movement); }
.stop[data-topic="People"]   { --line: var(--people); }
.stop[data-topic="Places"]   { --line: var(--places); }

.stop-date {
  font-family: var(--display);
  text-align: right;
  line-height: 1;
  padding-top: 2px;
}
.stop-date time { display: block; }
.stop-day { display: block; font-size: 34px; font-weight: 600; }
.stop-month { display: block; margin-top: 4px; font-size: 16px; color: var(--ink-soft); }

.stop-rail { position: relative; }
.stop-rail::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: -52px;
  width: var(--rail);
  margin-left: calc(var(--rail) / -2);
  background: var(--navy);
}
.stop:first-child .stop-rail::before { top: 16px; }
.stop:last-child .stop-rail::before { bottom: auto; height: 16px; }
.stop:only-child .stop-rail::before { display: none; }

.stop-rail::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 30px; height: 30px;
  margin-left: -15px;
  border-radius: 50%;
  background: var(--sign);
  border: 8px solid var(--line);
  box-shadow: 0 0 0 3px var(--kerb);
}

.stop-body {
  position: relative;
  display: grid;
  gap: 10px;
  max-width: 62ch;
}

.topic {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
}
.topic::before {
  content: "";
  width: 22px; height: 6px;
  border-radius: 3px;
  background: var(--line);
}

.stop h3 {
  font-size: clamp(27px, 2.5vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.005em;
}
.stop:first-child h3 { font-size: clamp(34px, 3.6vw, 52px); line-height: 1.02; }

.open {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font-weight: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
}
.open::after { content: ""; position: absolute; inset: -10px -12px; }
.open:hover { text-decoration-color: var(--line); }

.summary { font-size: 18px; line-height: 1.6; color: var(--ink-soft); }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-family: var(--display);
  font-size: 16px;
  color: var(--ink-soft);
}

.saved-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 500;
}
.saved-flag .mark { width: 12px; height: 15px; fill: currentColor; }

/* Empty state */

.empty {
  max-width: 560px;
  padding: 36px 0 0 120px;
  display: grid;
  justify-items: start;
  gap: 12px;
}
.empty[hidden] { display: none; }
.empty-title { font-family: var(--display); font-size: 32px; font-weight: 500; line-height: 1.15; }
.empty-text { color: var(--ink-soft); }
.empty .btn { margin-top: 8px; }

.load-error { padding: 24px 0; font-size: 18px; }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 2px solid var(--navy);
  border-radius: 999px;
  background: transparent;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.2;
  text-align: left;
}
.btn:hover { background: var(--kerb); }
.btn svg:not(.mark) { width: 20px; height: 20px; flex: none; }

.btn-quiet { border-color: transparent; padding-left: 10px; }

.save[aria-pressed="true"] { background: var(--navy); color: var(--sign); }

.colophon {
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px var(--pad) 56px;
  display: grid;
  gap: 4px;
  font-size: 15px;
  color: var(--ink-soft);
}
.colophon strong { font-family: var(--display); font-weight: 500; color: var(--ink); font-size: 17px; }

/* Reader: a sheet that slides in from the right */

.reader {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  width: min(800px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  border: 0;
  background: var(--sign);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.reader::backdrop { background: rgb(28 39 87 / 0.6); }

@media (prefers-reduced-motion: no-preference) {
  .reader[open] { animation: sheet-in .32s cubic-bezier(.2, .7, .2, 1); }
  .reader[open]::backdrop { animation: fade-in .32s ease-out; }
}
@keyframes sheet-in { from { transform: translateX(48px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

.sheet { --line: var(--navy); min-height: 100%; border-top: 12px solid var(--line); }
.sheet[data-topic="Culture"]  { --line: var(--culture); }
.sheet[data-topic="Food"]     { --line: var(--food); }
.sheet[data-topic="Movement"] { --line: var(--movement); }
.sheet[data-topic="People"]   { --line: var(--people); }
.sheet[data-topic="Places"]   { --line: var(--places); }

.sheet-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(16px, 5vw, 56px);
  background: var(--sign);
  border-bottom: 2px solid var(--kerb);
}

.sheet-body { padding: clamp(28px, 5vw, 48px) clamp(20px, 7vw, 80px) 72px; }

.sheet-head { display: grid; gap: 16px; max-width: 64ch; }

.sheet-title {
  font-size: clamp(38px, 5.4vw, 62px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.01em;
}
.sheet-title:focus { outline: none; }

.standfirst { font-size: 22px; line-height: 1.5; font-style: italic; color: var(--ink-soft); font-variation-settings: "opsz" 24; }

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  padding-top: 4px;
  font-family: var(--display);
  font-size: 17px;
}
.byline span:not(:first-child) { color: var(--ink-soft); }

.sheet-figure { margin: 32px 0 0; }
.sheet-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--kerb);
}
.sheet-figure figcaption { margin-top: 8px; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }

.article-text { margin-top: 36px; max-width: 64ch; }
.article-text p { font-size: 19px; line-height: 1.75; }
.article-text p + p { margin-top: 1.1em; }

.next {
  margin-top: 56px;
  padding-top: 24px;
  border-top: var(--rail) solid var(--navy);
  display: grid;
  gap: 10px;
  justify-items: start;
  max-width: 64ch;
}
.next-label { font-family: var(--display); font-size: 17px; color: var(--ink-soft); }
.next .btn { font-size: 20px; min-height: 52px; white-space: normal; padding-block: 8px; }

/* Narrow screens */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); gap: 44px; }
  .key { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body { font-size: 17px; }
  .masthead-top { grid-template-columns: 1fr; }
  .intro { font-size: 17px; }
  .ln { stroke-width: 6px; }
  .key { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
  .key-name { font-size: 19px; }
  .key-note { font-size: 14px; }

  .layout { grid-template-columns: 1fr; gap: 32px; padding-top: 28px; }
  .finder { position: static; gap: 16px; }
  .finder-heading { font-size: 24px; }

  .stop {
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 16px;
    padding-bottom: 40px;
  }
  .stop-rail { grid-column: 1; grid-row: 1 / span 2; }
  .stop-rail::before { bottom: -40px; }
  .stop-rail::after { width: 26px; height: 26px; margin-left: -13px; border-width: 7px; top: 0; }
  .stop:first-child .stop-rail::before { top: 13px; }
  .stop:last-child .stop-rail::before { height: 13px; }
  .stop-date { grid-column: 2; grid-row: 1; text-align: left; padding: 2px 0 8px; }
  .stop-date time { display: flex; align-items: baseline; gap: 6px; }
  .stop-day { font-size: 22px; }
  .stop-month { margin: 0; font-size: 17px; }
  .stop-body { grid-column: 2; grid-row: 2; }
  .stop h3 { font-size: 27px; }
  .stop:first-child h3 { font-size: 34px; }
  .summary { font-size: 17px; }

  .empty { padding-left: 0; }
  .empty-title { font-size: 27px; }

  .sheet-bar .btn { font-size: 16px; padding: 0 14px; }
  .sheet-bar .btn-quiet { padding-left: 4px; }
  .standfirst { font-size: 19px; }
  .article-text p { font-size: 18px; line-height: 1.72; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
