/* ==========================================================================
   links.niallsampson.com
   One hand-written stylesheet. Flat, sharp, 2px max radius, no shadows,
   no gradients. Signal orange is decoration only, never text.
   build.php appends ?v=<hash> to the font URLs below for cache-busting.
   ========================================================================== */

/* --- Fonts (self-hosted, subsetted, OFL) ---------------------------------- */

@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/space-grotesk-500.woff2?v=801ed9a836") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/space-grotesk-700.woff2?v=65510b950c") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400.woff2?v=d57f168355") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-500.woff2?v=0628a211e9") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

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

:root {
  /* Brand palette */
  --ink: #1C1D21;
  --paper: #F4EFE6;
  --signal: #E5662C;
  --deep-blue: #2C5778;

  /* Roles, light mode (default). Contrast on Paper in brackets. */
  --bg: var(--paper);
  --fg: var(--ink);           /* 14.70:1 */
  --label: var(--deep-blue);  /*  6.69:1 */
  --muted: #4D4E54;           /*  7.24:1 */
  --line: #D3CABB;            /* decorative hairline */
  --line-strong: var(--ink);  /* hover/focus border, 14.70:1 */

  --font-sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 2px;
  --marker: 0.5rem;           /* the Signal square used as a link marker */
  --ease: 160ms cubic-bezier(0.2, 0, 0, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Contrast on Ink in brackets. */
    --bg: var(--ink);
    --fg: var(--paper);         /* 14.70:1 */
    --label: #A9C0D4;           /*  8.96:1, Paper-tinted Deep blue */
    --muted: #BDB8AF;           /*  8.53:1 */
    --line: #3A3B40;            /* decorative hairline */
    --line-strong: var(--paper);
  }
}

/* --- Base ----------------------------------------------------------------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 500 1rem/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
}

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

a {
  color: inherit;
}

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

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

/* --- Page column ---------------------------------------------------------- */

.page {
  width: 100%;
  max-width: 30rem;            /* 480px */
  margin: 0 auto;
  padding: clamp(2.5rem, 10vw, 5.5rem) 1.25rem 2rem;
}

/* --- Masthead ------------------------------------------------------------- */

.masthead {
  margin-bottom: 3rem;
}

.monogram {
  --w: 4.5rem;
  width: var(--w);
  /* The SVG's viewBox pads the artwork by 138 of its 1669 units on the left;
     pull it back so the N lines up with the text column. */
  margin: 0 0 2.25rem calc(var(--w) * -138 / 1669);
}

.name {
  margin: 0;
  font-weight: 700;
  font-size: clamp(2.25rem, 10vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

/* The signature full stop. Sized and seated like the one in the wordmark:
   0.147em, sitting on the baseline. Always square. */
.sq {
  display: inline-block;
  width: 0.147em;
  height: 0.147em;
  margin-left: 0.05em;
  background: var(--signal);
  vertical-align: baseline;
}

.tagline {
  margin: 0.875rem 0 0;
  color: var(--label);
  font: 500 0.8125rem/1.4 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.bio {
  max-width: 32ch;
  margin: 1.75rem 0 0;
  font-size: 1.125rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font: 400 0.75rem/1.5 var(--font-mono);
  letter-spacing: 0.04em;
}

.meta__coords::before {
  content: "/";
  margin-right: 0.75rem;
  color: var(--line-strong);
  opacity: 0.35;
}

/* --- Section labels ------------------------------------------------------- */

.group + .group {
  margin-top: 2.5rem;
}

.label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  color: var(--label);
  font: 500 0.75rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.label__idx {
  font-variant-numeric: tabular-nums;
}

/* Hairline running to the right edge, like a spec-sheet section rule. */
.label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* --- Link rows ------------------------------------------------------------ */

.links {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color var(--ease);
}


.link__body {
  flex: 1;
  min-width: 0;
  /* Reserve the distance the text slides on hover so it never meets the arrow. */
  padding-right: calc(var(--marker) + 0.75rem);
  transition: transform var(--ease);
}

.link__title {
  position: relative;
  display: block;
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.3;
}

/* The Signal square. Hidden at rest; scales in on hover/focus (scale keeps it
   square at every frame, so it is never a rectangle mid-transition). Sits
   level with the title's first line and travels in with the text. */
.link__title::before,
.tile__marker {
  content: "";
  position: absolute;
  width: var(--marker);
  height: var(--marker);
  background: var(--signal);
  transform: scale(0);
  transition: transform var(--ease);
}

.link__title::before {
  top: 0.65em;
  left: calc((var(--marker) + 0.75rem) * -1);
  margin-top: calc(var(--marker) / -2);
}

.link__desc {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font: 400 0.8125rem/1.45 var(--font-mono);
}

.link__arrow {
  flex: none;
  font: 400 1.125rem/1 var(--font-mono);
  transition: transform var(--ease);
}

.link:hover,
.link:focus-visible {
  border-color: var(--line-strong);
}

/* Sharp focus ring: an offset outline would otherwise round to radius + offset. */
.link:focus-visible,
.tile:focus-visible {
  border-radius: 0;
}

.link:hover .link__title::before,
.link:focus-visible .link__title::before {
  transform: scale(1);
}

/* Make room for the marker by sliding the text, not by resizing the row. */
.link:hover .link__body,
.link:focus-visible .link__body {
  transform: translateX(calc(var(--marker) + 0.75rem));
}

.link:hover .link__arrow,
.link:focus-visible .link__arrow {
  transform: translateX(0.2rem);
}

/* --- Contact tiles -------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  height: 100%;
  min-height: 5rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color var(--ease);
}

.tile__proto {
  color: var(--label);
  font: 500 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tile__title {
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.2;
}

.tile__marker {
  top: 0.875rem;
  right: 1rem;
}

.tile:hover,
.tile:focus-visible {
  border-color: var(--line-strong);
}

.tile:hover .tile__marker,
.tile:focus-visible .tile__marker {
  transform: scale(1);
}

.contact-plain {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font: 400 0.8125rem/1.5 var(--font-mono);
}

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

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 400 0.75rem/1.5 var(--font-mono);
  letter-spacing: 0.04em;
}

.foot p {
  margin: 0;
}

.foot a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

.foot a:hover {
  color: var(--fg);
  text-decoration-color: var(--signal);
}

/* --- 404 ------------------------------------------------------------------ */

.notfound .tagline {
  margin: 0 0 1rem;
}

.notfound .bio {
  margin-bottom: 2.5rem;
}

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

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

/* --- Larger screens ------------------------------------------------------- */

@media (min-width: 48em) {
  .page {
    padding-bottom: 4rem;
  }

  .monogram {
    --w: 5rem;
  }
}
