/* =========================================================================
   Ben Lilley
   Implementation of artboard 2A, "Studio, polished", from the design canvas.
   Every value below is taken from that artboard rather than invented.

   Type:   Source Serif 4 for prose, Space Grotesk for furniture.
   Colour: warm paper, near-black ink, vermilion accent.
   ========================================================================= */

@font-face {
  font-family: "Source Serif 4";
  src: url(/fonts/source-serif-4-latin.woff2) format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url(/fonts/source-serif-4-latin-italic.woff2) format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url(/fonts/space-grotesk-latin.woff2) format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --paper: #f8f7f4;
  --ink: #15171a;
  --ink-body: #22262a;
  --ink-muted: #494f52;
  --ink-soft: #5c6063;
  --ink-faint: #6f6e66;   /* 4.78:1 on paper. Was #8a8981 at 3.28:1. */
  --ink-tagline: #6b6f72;

  --rule: #e4e3db;
  --rule-soft: #e2e1d8;
  --rule-link: #dbdad1;

  --accent: #1f2ecc;      /* 8.45:1 on paper */
  --accent-idle: #6f6e66;  /* was #b4b2a9 at 1.98:1 */
  --accent-wash: rgba(31, 46, 204, 0.16);
  --accent-line: rgba(31, 46, 204, 0.32);

  --surface-active: #edece7;
  --surface-hover: #efeee9;
  --surface-row: #f2f1ec;

  --sidebar-w: 236px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* --- Reset --------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Page lengths vary a lot, so without this the scrollbar appears and
     disappears between pages and shifts the layout sideways. */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19.5px;
  line-height: 1.66;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p, ul, ol, dl, figure, blockquote, hr { margin: 0; }
ul, ol { padding: 0; }
img, svg, video { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
::selection { background: var(--accent-wash); }

/* --- Shell --------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.main { padding: 60px 64px 48px; }

/* --- Sidebar ------------------------------------------------------------- */

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 52px 30px 34px;
  border-right: 1px solid var(--rule);
  font-family: var(--sans);
}

.sidebar__name {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  color: var(--ink);
}

/* The mark. The only piece of pure identity on the page, so it stays at
   every breakpoint. */
.sidebar__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.sidebar__tagline {
  margin: 6px 0 40px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-tagline);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  list-style: none;
  font-size: 13.5px;
}

.nav a {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  padding: 8px 10px;
  border-radius: 5px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav a:hover { background: var(--surface-hover); color: var(--ink); }

.nav a[aria-current="page"] {
  background: var(--surface-active);
  color: var(--ink);
}

.nav__num {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--accent-idle);
  font-variant-numeric: tabular-nums;
  transition: color 0.18s ease;
}

.nav a[aria-current="page"] .nav__num { color: var(--accent); }

.sidebar__foot {
  font-size: 13px;
  line-height: 1.8;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
}

/* --- Eyebrow ------------------------------------------------------------- */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow::after {
  content: "";
  flex: 1;
  max-width: 120px;
  height: 1px;
  background: var(--rule-soft);
}

/* --- Prose --------------------------------------------------------------- */

h1 {
  margin-bottom: 36px;
  font-size: 58px;
  line-height: 1.04;
  font-weight: 400;
  letter-spacing: -0.024em;
  max-width: 15ch;
  text-wrap: balance;
}

/* Longer headings need the wider measure and a smaller size. */
h1.is-long { font-size: 46px; line-height: 1.08; letter-spacing: -0.022em; max-width: 22ch; margin-bottom: 18px; }

h2 { font-size: 30px; line-height: 1.15; font-weight: 400; letter-spacing: -0.02em; }
h3 { font-size: 23px; line-height: 1.25; font-weight: 600; letter-spacing: -0.012em; }

.prose { max-width: 33em; color: var(--ink-body); }
.prose > * + * { margin-top: 1.1em; }
.prose h2, .prose h3 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.1em; }
.prose li + li { margin-top: 0.3em; }
.prose li::marker { color: var(--accent); }

.prose blockquote {
  padding-left: 1em;
  border-left: 2px solid var(--accent);
  font-style: italic;
  color: var(--ink-muted);
}

.lead {
  max-width: 32em;
  margin-bottom: 46px;
  font-size: 18.5px;
  line-height: 1.6;
  color: var(--ink-muted);
}

/* The highlighter mark, sitting behind the last 38% of the line. */
.highlight {
  font-style: italic;
  background-image: linear-gradient(
    transparent 54%,
    var(--accent-wash) 54%,
    var(--accent-wash) 91%,
    transparent 91%
  );
  /* Without this the band breaks apart across a wrapped line. */
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-inline: 0.12em;
}

.prose a {
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  padding-bottom: 1px;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
}

.prose a:hover { color: var(--accent); border-bottom-color: var(--accent); }

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

/* --- Page foot links ----------------------------------------------------- */

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  margin-top: 50px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 13px;
}

.page-links a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule-link);
  padding-bottom: 2px;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.page-links a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.page-links a.is-primary { color: var(--accent); border-bottom-color: var(--accent-line); }
.page-links a.is-primary:hover { border-bottom-color: var(--accent); }

/* --- Row list -----------------------------------------------------------
   The design's CV row grammar: a fixed date column, then the content. Used
   for the writing index too, so the two pages read as one system. */

.rows { list-style: none; }

.rows > li > a,
.rows > li > .row {
  display: grid;
  grid-template-columns: 9em 1fr;
  gap: 30px;
  padding: 24px 4px;
  border-top: 1px solid var(--rule);
  align-items: baseline;
  text-decoration: none;
  transition: background 0.18s ease;
}

.rows > li > a:hover { background: var(--surface-row); }

.row__date {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.row__title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.012em;
  transition: color 0.18s var(--ease);
}

.rows > li > a:hover .row__title { color: var(--accent); }

.row__note {
  margin-top: 7px;
  font-size: 17.5px;
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 38em;
}

/* --- Article ------------------------------------------------------------- */

.article-meta {
  margin: -22px 0 36px;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

/* --- Post note ----------------------------------------------------------
   Shown on anything ten years or older. Quiet enough to skip, present
   enough to change how the piece below it reads. */

.post-note {
  position: relative;
  /* Same measure as the prose below it, so its right edge lines up rather
     than running the full width of the column. */
  max-width: 33em;
  margin: 0 0 42px;
  padding: 16px 0 18px 24px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  /* Space Grotesk reads smaller than Source Serif at the same size, so this
     sits above the 13px floor to hold its own next to 19.5px body. */
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-muted);
}

/* The mark from the wordmark, hanging in the gutter. Enough to say this is
   an aside without putting a box around it. */
.post-note::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.back-link { display: inline-flex; align-items: baseline; gap: 0.5em; }

.back-link__arrow { transition: transform 0.18s var(--ease); }
.back-link:hover .back-link__arrow { transform: translateX(-3px); }

/* --- Skip link ----------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: 16px;
  top: -4rem;
  z-index: 10;
  padding: 0.6em 1em;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 13px;
  text-decoration: none;
  border-radius: 4px;
  transition: top 0.2s var(--ease);
}

.skip-link:focus { top: 16px; }

/* =========================================================================
   CV
   The design's CV artboard is a four-row placeholder; the real CV is far
   denser. Its structure is kept and the design's type, colour and row
   grammar applied to it.
   ========================================================================= */

.cv { font-size: 17.5px; line-height: 1.6; }

.cv-masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px 26px;
}

.cv-name { font-size: 46px; line-height: 1.08; font-weight: 400; letter-spacing: -0.022em; max-width: none; margin: 0; }
.cv-role { margin-top: 4px; font-family: var(--sans); font-size: 14px; color: var(--ink-soft); }

.cv a.cv-download {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.5em 0.95em;
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.cv a.cv-download:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.cv-download-icon {
  width: 0.85em; height: 0.85em;
  fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

.cv-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2em 22px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  list-style: none;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-faint);
}

.cv-contact a { text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.18s var(--ease), color 0.18s var(--ease); }
.cv-contact a:hover { color: var(--accent); border-bottom-color: var(--accent); }

.cv-section { margin-top: 54px; }

.cv-section-title {
  margin-bottom: 4px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

.cv-section > p { max-width: 38em; margin-top: 18px; color: var(--ink-muted); }
.cv-section > p + p { margin-top: 0.9em; }

.cv-entry {
  padding: 24px 4px;
  border-top: 1px solid var(--rule);
  transition: background 0.18s ease;
}

.cv-entry:hover { background: var(--surface-row); }

.cv-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 20px;
}

.cv-entry-title { font-size: 22px; font-weight: 600; letter-spacing: -0.012em; }

.cv-entry-dates {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cv-entry-org {
  margin-top: 5px;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.cv-entry-meta { color: var(--ink-faint); }

.cv-entry > p:not(.cv-entry-org) {
  margin-top: 10px;
  font-size: 17.5px;
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 38em;
}

.cv-bullets {
  margin-top: 10px;
  padding-left: 1.1em;
  font-size: 17.5px;
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: 38em;
}

.cv-bullets li + li { margin-top: 6px; }
.cv-bullets li::marker { color: var(--accent); }

.cv-skill-group {
  display: grid;
  grid-template-columns: 9em 1fr;
  gap: 30px;
  padding: 14px 4px;
  border-top: 1px solid var(--rule);
}

.cv-skills dt {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.cv-skills dd { margin: 0; font-size: 17.5px; line-height: 1.55; color: var(--ink-muted); max-width: 38em; }

/* --- Responsive ---------------------------------------------------------
   The tablet and mobile artboards drop the sidebar for a top bar and keep
   the numbered section label, which is the piece that carries the identity. */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; min-height: 0; }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px 26px;
    padding: 26px 28px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .sidebar__tagline, .sidebar__foot { display: none; }
  .sidebar > div:first-child { display: contents; }

  .nav { flex-direction: row; flex-wrap: wrap; gap: 16px; font-size: 13px; }
  .nav a { display: block; padding: 0 0 2px; border-radius: 0; border-bottom: 1.5px solid transparent; }
  .nav a:hover { background: none; }
  .nav a[aria-current="page"] { background: none; border-bottom-color: var(--accent); }
  .nav__num { display: none; }

  .main { padding: 34px 28px 40px; }
  body { font-size: 17px; }
  h1 { font-size: 34px; margin-bottom: 22px; max-width: 18ch; }
  h1.is-long, .cv-name { font-size: 30px; }
  .eyebrow { margin-bottom: 22px; font-size: 13px; }
  .rows > li > a, .rows > li > .row, .cv-skill-group { grid-template-columns: 1fr; gap: 6px; }
  .row__note, .cv-bullets, .cv-entry > p:not(.cv-entry-org) { font-size: 16px; }
}

@media (max-width: 460px) {
  .main { padding: 26px 20px 36px; }
  h1 { font-size: 26px; line-height: 1.08; }
  body { font-size: 15.5px; }
}

/* --- Motion -------------------------------------------------------------- */

@view-transition { navigation: auto; }

/* Only <main> changes between pages, so only <main> animates. Naming the two
   regions gives each its own snapshot: without this the transition captures
   the whole page as one group, and the sidebar and masthead move with it. */
.sidebar { view-transition-name: sidebar; }
.main { view-transition-name: page; }

/* Identical on every page, so it holds still rather than cross fading. */
::view-transition-old(sidebar),
::view-transition-new(sidebar) { animation: none; mix-blend-mode: normal; }

/* The page background does not change either. */
::view-transition-old(root),
::view-transition-new(root) { animation: none; }

::view-transition-old(page) { animation: fade-out 0.14s var(--ease) both; }
::view-transition-new(page) { animation: fade-in 0.22s var(--ease) both; }

@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  ::view-transition-old(page), ::view-transition-new(page) { animation: none; }
}

/* --- Print --------------------------------------------------------------- */

@page { size: A4; margin: 14mm 15mm; }

@media print {
  .sidebar, .skip-link, .cv-download, .eyebrow { display: none !important; }
  .layout { display: block; }
  .main { padding: 0; }
  body { background: #fff; }

  /* Every CV size is set on its own class, so setting body alone does nothing
     here - .cv wins and the PDF prints at screen size. Each one is restated. */
  .cv { font-size: 9.5pt; line-height: 1.45; color: #000; }
  .cv-name { font-size: 22pt; }
  .cv-role { font-size: 9pt; }
  .cv-contact { font-size: 8.5pt; margin-top: 14px; padding-top: 10px; }
  .cv-section { margin-top: 22px; }
  .cv-section-title { font-size: 8.5pt; letter-spacing: 0.2em; }
  .cv-section > p { margin-top: 10px; }
  .cv-entry { padding: 12px 0; }
  .cv-entry-title { font-size: 12pt; }
  .cv-entry-dates, .cv-entry-org { font-size: 8.5pt; }
  .cv-entry > p:not(.cv-entry-org), .cv-bullets { font-size: 9.5pt; line-height: 1.4; margin-top: 6px; }
  .cv-bullets li + li { margin-top: 3px; }
  .cv-skill-group { padding: 8px 0; }
  .cv-skills dt { font-size: 8.5pt; }
  .cv-skills dd { font-size: 9.5pt; line-height: 1.4; }

  /* The 38em screen measure is much narrower than A4 at 9.5pt, which left a
     third of the page empty. Widened so the column fills the print area. */
  .cv-section > p,
  .cv-entry > p:not(.cv-entry-org),
  .cv-bullets,
  .cv-skills dd { max-width: 46em; }

  .cv-entry:hover { background: none; }
  .cv-entry, .cv-skill-group { break-inside: avoid; }
  .cv-section-title { break-after: avoid; }
}
