:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e1e6ee;
  --text: #16202c;
  --muted: #5b6878;

  /* The blueprint band at the top of the page, and the logo's tile. */
  --bp: #1c66c9;
  --bp-2: #2a7fe2;
  --bp-grid: rgb(255 255 255 / .13);
  --bp-ink: #ffffff;
  --bp-ink-2: rgb(255 255 255 / .78);
  --bp-glass: rgb(255 255 255 / .14);
  --bp-edge: rgb(255 255 255 / .32);
  --bp-up: #6ee7a8;
  --bp-down: #ffb4a8;
  --tile: #1f7ae0;
  --tile-ink: #ffffff;
  --tile-shadow: 0 18px 36px -14px rgb(20 70 140 / .45);

  --mail: #0961bb;
  --stego: #6d4fd8;
  --airplanes: #1f7ae0;
  --arcade: #d7860b;
  --learngrid: #1e9b61;
  --irc: #0f8a8c;
  --dcrypt: #2b45c9;
  --norbit: #d9481a;
  --send: #c2410c;
  --agents: #be185d;
  --kofi: #e0463f;
  --up: #1b8a4f;
  --down: #c7372f;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 8px 24px -12px rgb(16 24 40 / .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131a;
    --surface: #151c25;
    --border: #243040;
    --text: #e7edf4;
    --muted: #93a1b2;
    --bp: #0f2c52;
    --bp-2: #163d6e;
    --bp-grid: rgb(140 190 255 / .12);
    --bp-ink: #e8f1ff;
    --bp-ink-2: rgb(232 241 255 / .72);
    --tile-shadow: 0 18px 36px -14px rgb(0 0 0 / .7);
    --mail: #70b1ff;
    --stego: #a18cf5;
    --airplanes: #5ea8f5;
    --arcade: #f2a93b;
    --learngrid: #4fcb8e;
    --irc: #45c4c6;
    --dcrypt: #8194f5;
    --norbit: #ff8a5c;
    --send: #fb9256;
    --agents: #f472b6;
    --kofi: #ff7a73;
    --up: #4fcb8e;
    --down: #ff7a73;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 28px -14px rgb(0 0 0 / .6);
  }
}

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

/* Holds the logo's drawing for <use>; takes no room. */
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ------------------------------------------------------- blueprint band */

/* The blue holds behind the logo and text, then eases out slowly behind the
   first row of cards, which `main` pulls up into the band. */
.sky {
  position: relative;
  overflow: hidden;
  padding: 0 20px;
  background: linear-gradient(180deg,
    var(--bp) 0%, var(--bp-2) 42%,
    color-mix(in srgb, var(--bp-2) 88%, var(--bg)) 52%,
    color-mix(in srgb, var(--bp-2) 70%, var(--bg)) 62%,
    color-mix(in srgb, var(--bp-2) 48%, var(--bg)) 72%,
    color-mix(in srgb, var(--bp-2) 27%, var(--bg)) 82%,
    color-mix(in srgb, var(--bp-2) 10%, var(--bg)) 91%,
    var(--bg) 100%);
}

/* Blueprint paper: a fine grid that fades out before the blue does. */
.sky::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--bp-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bp-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center top;
  -webkit-mask-image: linear-gradient(180deg, #000 40%, transparent 85%);
  mask-image: linear-gradient(180deg, #000 40%, transparent 85%);
}

/* Clouds drawn like the logo, drifting slowly. Faint, so the text over
   them stays easy to read. */
.drift {
  position: absolute;
  height: auto;
  color: var(--bp-ink);
  opacity: .2;
  pointer-events: none;
  animation: drift linear infinite alternate;
}
.d1 { width: 220px; top: 26px; left: 4%; animation-duration: 38s; }
.d2 { width: 140px; top: 120px; right: 8%; opacity: .14; animation-duration: 30s; animation-direction: alternate-reverse; }
.d3 { width: 300px; top: 210px; left: 62%; animation-duration: 46s; }
.d4 { width: 110px; top: 250px; left: 14%; opacity: .14; animation-duration: 34s; animation-direction: alternate-reverse; }

@keyframes drift {
  from { transform: translateX(-30px); }
  to { transform: translateX(30px); }
}

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 64px 0 330px;
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.logo {
  width: 120px;
  height: auto;
  border-radius: 26px;
  color: var(--tile-ink);
  box-shadow: 0 0 0 1px var(--bp-edge), var(--tile-shadow);
}

.logo .tile { fill: var(--tile); }

/* The name: one weight for both halves, only the colour splits it, and a
   little air before "make" so the r and the m don't collide. */
h1 {
  margin: 0;
  color: var(--bp-ink);
  font-size: clamp(2.8rem, 8vw, 4.4rem);
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.05;
}

h1 span { margin-left: .03em; color: var(--bp-ink-2); }

.tagline {
  max-width: 40rem;
  margin: 0;
  color: var(--bp-ink-2);
  font-size: 1.08rem;
  text-wrap: balance;
}

/* "All online", "1 app offline": set by status.js from the same check as
   the cards. Hidden until there is something true to say. */
.summary {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 4px 14px;
  border: 1px solid var(--bp-edge);
  border-radius: 999px;
  background: var(--bp-glass);
  color: var(--bp-ink);
  font-size: .85rem;
  font-weight: 600;
}

.summary[data-state] { display: inline-flex; }

.summary .dot { color: var(--bp-up); }
.summary[data-state="down"] .dot { color: var(--bp-down); }
.summary[data-state="checking"] .dot { color: var(--bp-ink-2); animation: status-pulse 1.2s ease-in-out infinite; }

/* -------------------------------------------------------------- projects */

main {
  position: relative;
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: -290px auto 0;
  padding: 0 20px 56px;
}

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

/* Two wide cards, so ten projects fill every row of three (and of two).
   After adding or removing a project, move or drop a `wide` class so no
   card sits alone in the last row. */
.projects .wide { grid-column: span 2; }

/* Three across on wide screens, two in between, one on phones. */
@media (max-width: 1000px) {
  .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .projects { grid-template-columns: minmax(0, 1fr); }
  .projects .wide { grid-column: auto; }
}

.mail      { --accent: var(--mail); }
.stego     { --accent: var(--stego); }
.airplanes { --accent: var(--airplanes); }
.arcade    { --accent: var(--arcade); }
.learngrid { --accent: var(--learngrid); }
.irc       { --accent: var(--irc); }
.dcrypt    { --accent: var(--dcrypt); }
.norbit    { --accent: var(--norbit); }
.send      { --accent: var(--send); }
.agents    { --accent: var(--agents); }

.card {
  height: 100%;
  display: flex;
  gap: 16px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
}

.card[href]:hover { transform: translateY(-2px); border-color: var(--accent); }

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

.icon {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}

.icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Mail's icon is its own logo: a filled envelope, its flap cut out in the
   card's colour. */
.icon .solid { fill: currentColor; stroke: none; }
.icon .cut { stroke: var(--surface); }

.body { display: flex; flex-direction: column; min-width: 0; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }

.name { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }

.host {
  color: var(--accent);
  font: 500 .85rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.card[href]:hover .host { text-decoration: underline; text-underline-offset: 3px; }

.desc { margin-top: 8px; color: var(--muted); font-size: .95rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

.tags span {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: .78rem;
}

/* ---------------------------------------------------------------- status */

/* Set by status.js; without it (no JavaScript) the badge stays hidden. */
.status {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 1px 9px 1px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.card[data-state] .status { display: inline-flex; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.card[data-state="checking"] .dot { animation: status-pulse 1.2s ease-in-out infinite; }

.card[data-state="up"] .status { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }

.card[data-state="down"] .status { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }

/* Offline: still there to read, but plainly not something to click. */
.card[data-state="down"] {
  cursor: default;
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
  box-shadow: none;
}

.card[data-state="down"] .icon { filter: grayscale(1); opacity: .55; }
.card[data-state="down"] .name { color: var(--muted); }
.card[data-state="down"] .host { color: var(--muted); }

@keyframes status-pulse {
  50% { opacity: .3; }
}

/* ---------------------------------------------------------------- footer */

footer.smallprint {
  /* Same width as the cards, so the rule lines up with them. */
  width: calc(100% - 40px);
  max-width: 1140px;
  margin: 0 auto;
  padding: 22px 0 32px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .85rem;
}

.credits { margin: 0; }

.credits a {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color .15s ease;
}

.credits a:hover { text-decoration-color: currentColor; }

footer.smallprint a:focus-visible { outline: 2px solid var(--airplanes); outline-offset: 3px; border-radius: 4px; }

.kofi-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .15s ease, border-color .15s ease, color .15s ease;
}

.kofi-button:hover { transform: translateY(-2px); border-color: var(--kofi); color: var(--kofi); }

.kofi-cup { width: 19px; height: 15px; object-fit: contain; animation: kofi-wiggle 3s infinite; }

@keyframes kofi-wiggle {
  0%, 60% { transform: rotate(0) scale(1); }
  75% { transform: rotate(0) scale(1.12); }
  80% { transform: rotate(0) scale(1.1); }
  84%, 92% { transform: rotate(-10deg) scale(1.1); }
  88%, 96% { transform: rotate(10deg) scale(1.1); }
  100% { transform: rotate(0) scale(1); }
}

@media (max-width: 560px) {
  footer.smallprint { flex-direction: column; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .drift { animation: none; }
  .card { transition: none; }
  .kofi-cup { animation: none; }
  .kofi-button { transition: none; }
  .kofi-button:hover { transform: none; }
  .card[href]:hover { transform: none; }
  .card[data-state="checking"] .dot,
  .summary[data-state="checking"] .dot { animation: none; }
}
