/*
 * acodeit.com: a well-kept ledger.
 * One blue margin rule runs down the page, as on ledger paper: dates sit to its
 * left, entries to its right. Everything else stays quiet.
 * Serif (Newsreader) for anything you read, mono (IBM Plex Mono) for data.
 */

@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-latin-opsz-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f8f7f3;
  --ink: #14181f;
  --grey: #636973;
  --hairline: #dcd9d1;
  --accent: #1e3a8a;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* The ledger's geometry: a date column, a gutter the margin rule runs through, the entries. */
  --date: 8.5rem;
  --gutter: 2.5rem;
  --indent: calc(var(--date) + var(--gutter));
  --aside: 17rem;
}

/* Dark applies when the system asks for it, unless Light is picked in the
   header switch, or always when Dark is picked. The switch is three radio
   buttons read with :has(), so it works without JavaScript. theme.js only
   remembers the choice: it sets data-theme on <html> from localStorage. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(:has(#t-light:checked)) {
    --paper: #12151b;
    --ink: #e9e6df;
    --grey: #9aa1ab;
    --hairline: #2a2f38;
    --accent: #9db4f0;
  }
}
:root[data-theme="dark"],
:root:has(#t-dark:checked) {
  --paper: #12151b;
  --ink: #e9e6df;
  --grey: #9aa1ab;
  --hairline: #2a2f38;
  --accent: #9db4f0;
  color-scheme: dark;
}
:root[data-theme="light"],
:root:has(#t-light:checked) {
  color-scheme: light;
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.5;
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
  font-weight: 400;
}

a {
  color: inherit;
  text-decoration: none;
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

.page {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 6vw, 3.5rem);
}

/* Small mono text: dates, labels, sectors, registration numbers. */
.top,
.label,
.years,
.role,
.about,
.foot {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ---------- Header ---------- */

.top {
  display: grid;
  grid-template-columns: var(--indent) 1fr auto;
  align-items: baseline;
  padding: 2rem 0;
  color: var(--grey);
}
.mark {
  color: var(--ink);
  font-weight: 500;
}
.top nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.75rem;
}
.top nav a:hover {
  color: var(--accent);
}

/* Theme switch: plain words, the current one in ink with a rule under it. */
.theme {
  display: flex;
  gap: 1rem;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.theme legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.theme input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.theme label {
  cursor: pointer;
  padding-bottom: 1px;
  border-bottom: 1px solid transparent;
}
.theme label:hover {
  color: var(--accent);
}
.theme label:has(:checked) {
  color: var(--ink);
  border-bottom-color: var(--ink);
}
.theme label:has(:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
@supports not selector(:has(*)) {
  .theme {
    display: none;
  }
}

/* ---------- The margin rule ---------- */

main {
  position: relative;
  padding-bottom: 4rem;
}
main::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--date) + var(--gutter) / 2);
  width: 1px;
  background: var(--accent);
  opacity: 0.55;
}

/* ---------- Statement ---------- */

.statement {
  padding: 5.5rem 0 6.5rem var(--indent);
}
.statement h1 {
  font-size: clamp(2.25rem, 5.2vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.017em;
  max-width: 13em;
  text-wrap: balance;
}
.statement p {
  margin-top: 1.5rem;
  color: var(--grey);
  max-width: 34em;
  text-wrap: pretty;
}

/* ---------- Groups and rows ---------- */

.group {
  margin-bottom: 3.5rem;
}
.label {
  font-weight: 500;
  color: var(--ink);
  padding: 0 0 0.75rem var(--indent);
  border-bottom: 1px solid var(--ink);
}

.row {
  display: grid;
  grid-template-columns: var(--date) 1fr var(--aside);
  column-gap: var(--gutter);
  align-items: baseline;
  padding-block: 1.25rem 1.375rem;
  border-bottom: 1px solid var(--hairline);
}
.years {
  color: var(--grey);
  white-space: nowrap;
}
.role {
  color: var(--grey);
  text-align: right;
}
.name {
  font-size: 1.4375rem;
  line-height: 1.25;
  letter-spacing: -0.006em;
}
.line {
  margin-top: 0.375rem;
  color: var(--grey);
  max-width: 34em;
  text-wrap: pretty;
}

/* How long the row has run, shown under the dates when you point at it. */
.years[data-duration]::after {
  content: attr(data-duration);
  display: block;
  color: var(--accent);
  opacity: 0;
  transition: opacity 160ms ease;
}
.years[data-duration] {
  position: relative;
}
.years[data-duration]::after {
  position: absolute;
  top: 100%;
  left: 0;
}
.row:hover .years::after,
.row:focus-within .years::after {
  opacity: 1;
}

.arrow {
  display: inline-block;
  margin-left: 0.4em;
  font-family: var(--mono);
  font-size: 0.7em;
  color: var(--grey);
  transition:
    transform 160ms ease,
    color 160ms ease;
}
.name a:hover,
.name a:focus-visible {
  color: var(--accent);
}
.row.linked:hover .arrow,
.row.linked:focus-within .arrow {
  transform: translateX(4px);
  color: var(--accent);
}

/* Client rows: one line each, lighter than the work above. Too short for a
   second line under the dates, so the duration sits beside them. */
.row.client .years[data-duration]::after {
  position: static;
  display: inline;
  margin-left: 0.75em;
}

.row.client {
  padding-block: 0.75rem 0.8125rem;
}
.row.client .name {
  font-size: 1.0625rem;
  line-height: 1.5;
  letter-spacing: 0;
}
.row.client .line {
  margin: 0;
  max-width: none;
}

/* ---------- Company ---------- */

.about {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem var(--gutter);
  padding: 2.5rem 0 0 var(--indent);
  color: var(--ink);
  line-height: 1.75;
}
.about .label {
  padding: 0 0 0.5rem;
  border: 0;
  color: var(--grey);
  font-weight: 400;
}
.about .dim {
  display: block;
  color: var(--grey);
}
.about .person + .person {
  margin-top: 0.5rem;
}
.about a {
  border-bottom: 1px solid var(--hairline);
}
.about a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- Footer ---------- */

.foot {
  padding: 2rem 0 3rem var(--indent);
  border-top: 1px solid var(--hairline);
  color: var(--grey);
}
.foot p {
  max-width: 44em;
}
.foot p + p {
  margin-top: 0.75rem;
}
.foot .cookie {
  color: var(--ink);
}

/* ---------- Narrow screens ----------
   The margin rule moves to the left edge of the column. Each row becomes:
   dates on the left and role on the right of one mono line, then the entry. */

@media screen and (max-width: 56rem) {
  :root {
    --date: 0rem;
    --gutter: 1.125rem;
  }
  .top {
    grid-template-columns: 1fr auto;
    padding: 1rem 0 1rem var(--indent);
  }
  /* Comfortable to hit with a thumb. */
  .theme {
    gap: 0;
    margin-right: -0.5rem;
  }
  .theme label {
    padding: 0.625rem 0.5rem;
    border-bottom: 0;
  }
  .theme label:has(:checked) {
    text-decoration: underline;
    text-underline-offset: 0.35em;
  }
  .mark {
    padding-block: 0.625rem;
  }
  .name a {
    display: inline-block;
    padding-block: 0.125rem;
  }
  /* One page, a thumb's scroll long: the section links earn no space here. */
  .top nav {
    display: none;
  }
  main::before {
    left: 0;
  }
  .statement {
    padding-top: 3rem;
    padding-bottom: 3.5rem;
  }
  .group {
    margin-bottom: 2.75rem;
  }
  .row {
    grid-template-columns: auto 1fr;
    column-gap: 1rem;
    row-gap: 0.5rem;
    padding-left: var(--indent);
  }
  .row .years {
    grid-column: 1;
    grid-row: 1;
  }
  .row .role {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }
  .row .what {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  /* Work rows: only the countries share the date line; the kind of work
     closes the entry. Client rows are short enough to keep both on one line. */
  .row:not(.client) .role {
    display: contents;
  }
  .row:not(.client) .where {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }
  .row:not(.client) .kind {
    grid-column: 1 / -1;
    grid-row: 3;
    text-align: left;
  }
  .row:not(.client) .sep {
    display: none;
  }
  .row.client {
    row-gap: 0.125rem;
  }
  /* No hover on touch screens, and the dates now share their line. */
  .years[data-duration]::after,
  .row.client .years[data-duration]::after {
    display: none;
  }
  .about {
    grid-template-columns: 1fr 1fr;
    gap: 1.75rem var(--gutter);
    padding-top: 0.75rem;
  }
  .foot {
    padding-top: 1.5rem;
  }
}

@media screen and (max-width: 30rem) {
  .statement h1 {
    font-size: 2.125rem;
  }
  .about {
    grid-template-columns: 1fr;
  }
}

/* ---------- Preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .arrow,
  .years[data-duration]::after {
    transition: none;
  }
  .row.linked:hover .arrow,
  .row.linked:focus-within .arrow {
    transform: none;
  }
}

/* ---------- Print: a one-page company sheet ---------- */

@media print {
  @page {
    size: A4;
    margin: 15mm 16mm;
  }
  :root,
  :root[data-theme],
  :root:has(#t-dark:checked),
  :root:not([data-theme="light"]):not(:has(#t-light:checked)) {
    --paper: #fff;
    --ink: #000;
    --grey: #444;
    --hairline: #bbb;
    --accent: #000;
    --date: 25mm;
    --gutter: 8mm;
    --aside: 44mm;
  }
  body {
    font-size: 9.5pt;
    line-height: 1.4;
  }
  .page {
    max-width: none;
    padding: 0;
  }
  .top,
  .label,
  .years,
  .role,
  .about,
  .foot {
    font-size: 7pt;
  }
  .top nav,
  .theme,
  .cookie,
  .privacy,
  .arrow,
  .years[data-duration]::after {
    display: none;
  }
  .top {
    padding: 0 0 3mm;
  }
  main {
    padding-bottom: 3mm;
  }
  main::before {
    opacity: 1;
  }
  .statement {
    padding-top: 5mm;
    padding-bottom: 7mm;
  }
  .statement h1 {
    font-size: 22pt;
  }
  .statement p {
    margin-top: 3mm;
  }
  .group {
    margin-bottom: 5mm;
    break-inside: avoid;
  }
  .label {
    padding-bottom: 1.5mm;
  }
  .row {
    padding-block: 1.8mm;
    break-inside: avoid;
  }
  .row.client {
    padding-block: 1mm;
  }
  .name {
    font-size: 12pt;
  }
  .row.client .name {
    font-size: 9.5pt;
  }
  .line {
    margin-top: 0.5mm;
    max-width: none;
  }
  .about {
    padding-top: 4mm;
    line-height: 1.55;
  }
  .foot {
    padding: 4mm 0 0 var(--indent);
  }
}
