/* ==========================================================================
   Dr Andrew Rochford — drandrewrochford.com
   Design system and base styles.

   Aesthetic: a serious academic monograph crossed with a law firm that bills
   a lot. Near-white warm paper, generous white space, near-zero ornament,
   one restrained navy ink accent, one serif typeface throughout.

   No external dependencies. No CDN. Fonts are self-hosted (see /assets/fonts).
   Light only by design: a mediocre dark mode would cheapen the monograph feel.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Self-hosted typeface — Source Serif 4 (SIL OFL 1.1)
   Only the three weights actually used are loaded: regular, regular italic,
   and semibold. font-display: swap keeps text visible immediately, falling
   back to Georgia until (or if) the woff2 files are present. The site is
   fully legible with no font files at all.
   -------------------------------------------------------------------------- */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local("Source Serif 4"), local("SourceSerif4-Regular"),
       url("../assets/fonts/source-serif-4-regular.woff2") format("woff2");
}

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

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: local("Source Serif 4 Semibold"), local("SourceSerif4-Semibold"),
       url("../assets/fonts/source-serif-4-semibold.woff2") format("woff2");
}

/* --------------------------------------------------------------------------
   2. Design tokens
   -------------------------------------------------------------------------- */

:root {
  /* Colour */
  --paper:        #FBFAF7; /* near-white warm background */
  --ink:          #1A1A1A; /* near-black body text */
  --ink-soft:     #4A4A48; /* secondary text, captions */
  --accent:       #1F3A5F; /* single restrained deep navy ink */
  --hairline:     #E2DED6; /* thin divider lines */
  --paper-raised: #FFFFFF; /* raised blocks, used minimally */

  /* Typeface — single-typeface monograph look */
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body:    "Source Serif 4", Georgia, "Times New Roman", serif;

  /* Type scale and rhythm */
  --size-base:    1.1875rem;  /* 19px on a 16px root */
  --line-body:    1.6;
  --measure:      40rem;      /* ~70 character reading measure */

  /* Spacing scale (vertical rhythm) */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.75rem;
  --space-lg:  3rem;
  --space-xl:  5rem;
  --space-xxl: 7rem;

  /* Layout */
  --content-max: 52rem;   /* 832px editorial frame: number rail + reading column */
  --rail:        3.5rem;   /* left margin rail carrying the section numbers */
  --gutter:      1.5rem;   /* side padding, never below 20px on mobile */
}

/* --------------------------------------------------------------------------
   3. Reset and box model
   -------------------------------------------------------------------------- */

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

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

body,
h1, h2, h3, h4, p, ul, ol, li, figure, blockquote {
  margin: 0;
  padding: 0;
}

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

ul, ol {
  list-style: none;
}

/* --------------------------------------------------------------------------
   4. Base typography
   -------------------------------------------------------------------------- */

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--size-base);
  line-height: var(--line-body);
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
}

p {
  max-width: var(--measure);
  margin-bottom: var(--space-md);
}

p:last-child {
  margin-bottom: 0;
}

/* Display headings — generous space above, tight, monograph */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}

h1 {
  font-size: 2.5rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.6rem;
  letter-spacing: -0.005em;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

h3 {
  font-size: 1.2rem;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

em, i {
  font-style: italic;
}

strong, b {
  font-weight: 600;
}

small,
.caption {
  font-size: 0.875rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   5. Links — accent used sparingly
   -------------------------------------------------------------------------- */

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  text-decoration-color: var(--hairline);
  transition: text-decoration-color 0.15s ease;
}

a:hover {
  text-decoration-color: var(--accent);
}

/* --------------------------------------------------------------------------
   6. Focus states — visible and clear on every interactive element
   -------------------------------------------------------------------------- */

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper-raised);
  color: var(--accent);
  padding: var(--space-xs) var(--space-sm);
  z-index: 10;
}

.skip-link:focus {
  left: var(--gutter);
  top: var(--gutter);
}

/* --------------------------------------------------------------------------
   7. Layout — single centred column on full-bleed paper
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main > section {
  padding-block: var(--space-xl);
}

/* --------------------------------------------------------------------------
   8. Hairline rules — sparing section dividers
   -------------------------------------------------------------------------- */

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

/* --------------------------------------------------------------------------
   8b. Masthead — the opening composition. The name, then the identity line
   set large as the masthead statement, the portrait, and the links row,
   closed by a navy rule. Mobile-first single column; a two-column lockup
   on wider screens. Visual order on narrow screens is name, portrait, lede,
   links; the DOM order is unchanged, so assistive technology reads name,
   lede, the portrait's alt text, then links.
   -------------------------------------------------------------------------- */

header.container {
  padding-block: var(--space-xl) var(--space-lg);
  margin-bottom: var(--space-md);
  border-bottom: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

header > h1              { order: 1; }
header > picture         { order: 2; }
header > .identity       { order: 3; }
header > .identity-links { order: 4; }

h1 {
  font-size: clamp(2rem, 5.5vw, 3.1rem);
  line-height: 1.05;
}

/* The lede: the identity line, raised to a masthead statement. */
.identity {
  font-size: clamp(1.25rem, 3.2vw, 1.65rem);
  line-height: 1.4;
  font-weight: 400;
  color: var(--ink);
  max-width: 34rem;
  margin-top: var(--space-md);
  text-wrap: balance;
}

header > picture {
  display: block;
  width: 100%;
  max-width: 230px;
  margin-block: var(--space-md);
}

header picture img {
  width: 100%;
  height: auto;
}

/* Links row: small-caps, navy, quiet, each a comfortable >=44px touch target. */
.identity-links {
  margin-top: var(--space-sm);
}

.identity-links ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-lg);
}

.identity-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--accent);
}

.identity-links a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.25em;
}

/* --------------------------------------------------------------------------
   8c. Sections — editorial layout. A left rail carries the section number
   in navy; the heading and body sit in the reading column. The numbers are
   generated with a CSS counter, so no numbering lives in the markup.
   -------------------------------------------------------------------------- */

main {
  counter-reset: section;
}

main > section {
  counter-increment: section;
  border-top: 1px solid var(--accent);
  display: grid;
  grid-template-columns: 1fr;
  column-gap: var(--space-lg);
}

/* The section number — above the heading on narrow screens, in the rail wide. */
main > section::before {
  content: counter(section, decimal-leading-zero);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: lining-nums tabular-nums;
  margin-bottom: var(--space-sm);
}

main > section > * {
  max-width: var(--measure);
}

main > section > h2 {
  margin-top: 0;
}

/* Lead paragraph of each section, set a touch larger to open the section. */
main > section > p:first-of-type {
  font-size: 1.1rem;
}

/* --------------------------------------------------------------------------
   8d. Navy thesis band — the concluding sentence of the argument, lifted
   into a navy panel as the page's single strongest focal point.
   -------------------------------------------------------------------------- */

#argument > p:last-of-type {
  max-width: none;
  margin-top: var(--space-lg);
  margin-bottom: 0;
  padding: var(--space-lg);
  background: var(--accent);
  color: var(--paper);
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
  line-height: 1.45;
  text-wrap: balance;
}

/* --------------------------------------------------------------------------
   8e. "Read the paper" — a quiet call to action, never a loud button.
   -------------------------------------------------------------------------- */

.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  min-height: 44px;
  font-weight: 600;
  text-decoration-color: var(--accent);
}

.cta::after {
  content: "\2192"; /* a small trailing arrow */
  transition: transform 0.15s ease;
}

.cta:hover::after {
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   8f. Footer — small and quiet, set apart by a navy rule.
   -------------------------------------------------------------------------- */

footer.container {
  margin-top: var(--space-lg);
  padding-block: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--accent);
  color: var(--ink-soft);
  font-size: 0.95rem;
}

footer p {
  max-width: none;
  margin-bottom: var(--space-xs);
}

footer p:last-child {
  margin-bottom: 0;
}

footer a {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   8g. Wider screens — two-column masthead, and the section number rail.
   -------------------------------------------------------------------------- */

@media (min-width: 46rem) {
  header.container {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name     portrait"
      "lede     portrait"
      "links    portrait";
    column-gap: var(--space-xl);
    align-items: start;
  }

  header > h1              { grid-area: name; }
  header > .identity       { grid-area: lede; }
  header > .identity-links { grid-area: links; }
  header > picture {
    grid-area: portrait;
    max-width: 230px;
    margin: 0;
    align-self: start;
  }

  /* The number moves into a left rail beside the heading. */
  main > section {
    grid-template-columns: var(--rail) minmax(0, 1fr);
  }

  main > section::before {
    grid-column: 1;
    align-self: start;
    justify-self: start;
    margin-bottom: 0;
  }

  main > section > * {
    grid-column: 2;
  }

  /* The navy band spans the full frame, rail included. */
  #argument > p:last-of-type {
    grid-column: 1 / -1;
  }
}

/* --------------------------------------------------------------------------
   9. Accessibility helpers
   -------------------------------------------------------------------------- */

/* Visually hidden but available to assistive technology */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   10. Responsive — mobile-first; the single column simply narrows
   -------------------------------------------------------------------------- */

@media (max-width: 30rem) {
  :root {
    --gutter: 1.25rem; /* 20px minimum side gutters */
    --size-base: 1.125rem; /* 18px on small screens */
  }

  h2 { font-size: 1.35rem; }

  header > picture { max-width: 200px; }

  main > section {
    padding-block: var(--space-lg);
  }

  #argument > p:last-of-type {
    padding: var(--space-md);
  }
}

/* --------------------------------------------------------------------------
   11. Motion — respect user preference
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   12. Print — clean, ink-light
   -------------------------------------------------------------------------- */

@media print {
  body {
    background: #fff;
    color: #000;
  }
  a {
    color: #000;
    text-decoration: underline;
  }
  .skip-link {
    display: none;
  }
}
