@font-face {
  font-display: swap;
  font-family: "Geologica";
  font-weight: 700;
  src: url("fonts/geologica/geologica-v5-latin_latin-ext-700.woff2");
}

@font-face {
  font-display: swap;
  font-family: "Geologica";
  font-weight: 800;
  src: url("fonts/geologica/geologica-v5-latin_latin-ext-800.woff2");
}

@font-face {
  font-display: swap;
  font-family: "SN Pro";
  font-weight: 400;
  src: url("fonts/sn-pro/sn-pro-v1-latin_latin-ext-regular.woff2");
}

@font-face {
  font-display: swap;
  font-family: "SN Pro";
  font-style: italic;
  font-weight: 400;
  src: url("fonts/sn-pro/sn-pro-v1-latin_latin-ext-italic.woff2");
}

@font-face {
  font-display: swap;
  font-family: "SN Pro";
  font-weight: 500;
  src: url("fonts/sn-pro/sn-pro-v1-latin_latin-ext-500.woff2");
}

:root {
  color-scheme: light dark;

  --color-background: light-dark(#fbfbfb, #061826);
  --color-text: light-dark(#333, #d6d6d6);
  --color-rule: color-mix(in srgb, currentColor 25%, transparent);
  --color-tag: #f3de8a;
  --color-tag-text: #444;

  /*
    A severe ramp, because the screen has room to breathe.

    On narrow screens, h1 and h2 shrink with the column so their words don't
    break.
  */
  --text-root: 115%;
  --text-s: 0.85rem;
  --text-l: 1.1rem;
  --text-h3: 1.5rem;
  --text-h2: clamp(1.5rem, 13cqi, 2.5rem);
  --text-h1: clamp(2rem, 19cqi, 4rem);

  --line-height: 1.4;

  /* Scales every space. */
  --density: 1;

  --space-xs: calc(0.25rem * var(--density));
  --space-s: calc(0.5rem * var(--density));
  --space-m: calc(1rem * var(--density));
  --space-l: calc(2rem * var(--density));
  --space-xl: calc(5rem * var(--density));
}

* {
  box-sizing: border-box;
  margin: 0;
}

:root {
  -webkit-font-smoothing: antialiased;

  background: var(--color-background);
  color: var(--color-text);
  font-family: "SN Pro", sans-serif;
  font-size: var(--text-root);
  font-synthesis: none;
  line-height: var(--line-height);
  overflow-wrap: break-word;
  text-wrap: pretty;
}

h1,
h2,
h3 {
  font-family: "Geologica", sans-serif;
  font-weight: 800;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-h1);
  margin-bottom: var(--space-m);
}

h2 {
  font-size: var(--text-h2);
  margin-block: var(--space-l) var(--space-m);
}

h3 {
  font-size: var(--text-h3);
  font-weight: 700;
}

p,
ul {
  margin-bottom: var(--space-m);
}

a {
  text-underline-offset: 0.2em;
}

.contact {
  list-style: none;
  padding: 0;
}

.introduction {
  font-size: var(--text-l);
}

/* A job or a qualification: its dates, then its detail. */
section {
  margin-bottom: var(--space-l);
}

.dates {
  font-size: var(--text-s);
  font-weight: 500;
  margin-bottom: 0;
}

.detail > :last-child {
  margin-bottom: 0;
}

.organisation {
  font-weight: 500;

  /* A rule between the organisation and whatever follows it. */
  &:not(:last-child) {
    border-bottom: 1px solid var(--color-rule);
    padding-bottom: var(--space-s);
  }
}

.highlights {
  padding-left: 1.2rem;

  li + li {
    margin-top: var(--space-s);
  }
}

/*
  Screen: all the layout lives here, because print is one column in normal flow.
*/

@media screen {
  body {
    margin: var(--space-xl) auto;
    width: min(74ch, 100% - 2 * var(--space-m));
  }

  /* The heading sizes measure this column. */
  main {
    container-type: inline-size;
  }

  h1,
  h2,
  h3 {
    letter-spacing: -0.05rem;
  }

  .print-only,
  .sep {
    display: none;
  }

  .contact {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-m);

    /* Lets a long address wrap rather than overflow. */
    li {
      min-width: 0;
    }

    a {
      align-items: center;
      display: inline-flex;
      gap: var(--space-xs);
    }

    svg {
      flex-shrink: 0;
      height: 1lh;
      width: 1lh;
    }
  }

  /* The location takes the first row to itself. */
  .location {
    flex-basis: 100%;
  }

  /* The dates sit beside the detail, or above it when the column is narrow. */
  section {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s) var(--space-m);
  }

  .dates {
    flex: 0 0 22ch;
  }

  .detail {
    flex: 1 1 48ch;
  }

  .tags {
    display: flex;
    flex-wrap: wrap;
    font-size: var(--text-s);
    gap: var(--space-s);
    text-transform: lowercase;
  }

  .tag {
    background: var(--color-tag);
    border-radius: var(--space-xs);
    color: var(--color-tag-text);
    font-weight: 500;
    padding-inline: var(--space-s);
  }
}

/*
  Print: reads like a plain-text CV, for applicant tracking systems.
  scripts/check-pdf.cjs lists the only things these styles may do to the text.
*/

@page {
  margin: 1cm 1.2cm 0.5cm;
  size: A4;
}

@media print {
  :root {
    color-scheme: light;

    background: none;
    font-variant-ligatures: none;

    /*
      Two text sizes, because space is at a premium.
      Headings stand out by weight alone.
    */
    --text-root: 102%;
    --text-l: 1rem;
    --text-h3: 1rem;
    --text-h2: 1rem;
    --text-h1: 1rem;

    --line-height: 1.3;
    --density: 0.5;
  }

  a {
    color: inherit;
  }

  h2 {
    text-transform: uppercase;
  }

  .contact svg,
  .pdf,
  .screen-only {
    display: none;
  }

  .contact {
    font-size: var(--text-s);
  }

  .contact li,
  .dates,
  .tag {
    white-space: nowrap;
  }

  h1,
  h2,
  h3,
  .dates,
  .organisation {
    break-after: avoid;
  }

  p,
  li {
    break-inside: avoid;
  }

  .tags {
    break-before: avoid;
    text-wrap: balance;
  }
}
