/* Recursive, monospace axis pinned (MONO 1). Weight axis: 300-1000. */
@font-face {
  font-family: "Recursive";
  font-style: normal;
  font-weight: 300 1000;
  font-display: swap;
  src: url("fonts/recursive-latin-mono-normal.woff2") format("woff2-variations");
}

:root {
  --bg:     #fcfcfb;
  --ink:    #1b1c1a;
  --muted:  #6d6f6a;
  --line:   #c3c7c2;
  --accent: #3f4a52;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #121311;
    --ink:    #e8e8e4;
    --muted:  #90928c;
    --line:   #44473f;
    --accent: #a9b4bb;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Recursive", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  min-height: 100dvh;
  max-width: 1180px;
  margin-inline: auto;
  padding: clamp(1.25rem, 3.5vw, 3rem);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  column-gap: clamp(1rem, 3vw, 2.5rem);
}

/* ---- the graph ------------------------------------------------------ */

/* The third term keeps the drawing and the text together on one screen:
   the text block needs about 340 px of the remaining height. */
.plot {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  width: min(58vw, 620px, calc(123vh - 340px));
}

.graph {
  display: block;
  width: 100%;
  height: auto;
}

.curve {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}

/* ---- the links on the curve ----------------------------------------- */

/* Each link sits at its own point of the curve. The drawing scales, the
   labels do not, so they stay readable at every window size. */
.node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-6px, -6px);
  padding: 1rem 0.9rem 0.8rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 450;
  line-height: 1;
  white-space: nowrap;
  text-align: left;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms linear;

  /* The email node is a button. These four lines give it the anchor look. */
  appearance: none;
  background: none;
  border: 0;
  font-family: inherit;
}

.node::before {
  content: "";
  position: absolute;
  left: 0.5px;
  top: 0.5px;
  width: 11px;
  height: 11px;
  border: 1.4px solid var(--muted);
  border-radius: 50%;
  background: var(--bg);
  transition: background-color 120ms linear, border-color 120ms linear;
}

.node:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.node:hover::before {
  background: var(--accent);
  border-color: var(--accent);
}

.node:focus-visible {
  outline: 1.5px dashed var(--accent);
  outline-offset: -2px;
  border-radius: 4px;
  color: var(--ink);
}

/* ---- the text ------------------------------------------------------- */

.intro {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  justify-self: start;
  max-width: 32ch;
}

h1 {
  margin: 0 0 0.6em;
  font-size: clamp(1.4rem, 3.4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.role {
  margin: 0 0 1.6em;
  font-size: clamp(0.95rem, 1.9vw, 1.1rem);
  font-weight: 400;
}

.meta {
  margin: 0 0 0.75em;
  font-size: 0.9rem;
  font-weight: 350;
  color: var(--muted);
}

.intro a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.22em;
  transition: color 120ms linear, text-decoration-color 120ms linear;
}

.intro a:hover,
.intro a:focus-visible { color: var(--ink); text-decoration-color: currentColor; }

/* ---- the email node ------------------------------------------------- */

/* The node copies the address. It does not open a mail client. */

.node--copy { padding-right: 1.95rem; }

/* The icon keeps its space at all times, so the label never moves. The mask
   takes the colour of the label, and therefore follows the theme. */
.node--copy::after {
  content: "";
  position: absolute;
  top: 1.09rem;
  right: 0.78rem;
  width: 0.78em;
  height: 0.78em;
  background-color: currentColor;
  opacity: 0;
  transition: opacity 120ms linear;
  -webkit-mask: var(--icon-copy) center / contain no-repeat;
  mask: var(--icon-copy) center / contain no-repeat;
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='12' height='12' rx='2.5'/%3E%3Cpath d='M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1'/%3E%3C/svg%3E");
}

.node--copy:hover::after,
.node--copy:focus-visible::after { opacity: 0.85; }

/* ---- the message beside the pointer --------------------------------- */

.copy-toast {
  position: fixed;
  z-index: 20;
  transform-origin: top left;
  padding: 0.45em 0.6em;
  font-size: 0.76rem;
  font-weight: 450;
  line-height: 1;
  white-space: nowrap;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  pointer-events: none;
  animation:
    toast-life 1700ms ease-out forwards,
    toast-ring 620ms ease-out;
}

@keyframes toast-life {
  0%   { opacity: 0; transform: scale(0.94); }
  7%   { opacity: 1; transform: scale(1); }
  80%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.98); }
}

/* One ring leaves the border of the message. */
@keyframes toast-ring {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 38%, transparent); }
  100% { box-shadow: 0 0 0 12px rgb(0 0 0 / 0); }
}

/* The script gives each spark a start point and an end point on an ellipse
   around the message. */
.spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: spark-fly 560ms ease-out forwards;
}

@keyframes spark-fly {
  0%   { opacity: 0.7; transform: translate(var(--sx), var(--sy)) scale(1); }
  70%  { opacity: 0.35; }
  100% { opacity: 0; transform: translate(var(--ex), var(--ey)) scale(0.5); }
}

@media (prefers-reduced-motion: reduce) {
  .copy-toast { animation: toast-plain 1700ms linear forwards; }
  .spark { display: none; }
}

@keyframes toast-plain {
  0%, 85% { opacity: 1; }
  100%    { opacity: 0; }
}

/* The screen reader gets the same message. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- narrow screens ------------------------------------------------- */

@media (max-width: 760px) {
  main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    row-gap: clamp(1.5rem, 6vw, 3rem);
    align-content: center;
  }

  .plot { grid-column: 1; grid-row: 1; width: min(100%, 78vh); }

  .intro { grid-column: 1; grid-row: 2; }
}
