/* Direction G · A short letter. The page reads like a note, under the calling card letterhead. */
/* Self-hosted, latin subset. Both are variable fonts, so one file covers every weight used. */
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 300 700; font-display: swap; src: url("fonts/cormorant-garamond-latin.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("fonts/source-sans-3-latin.woff2") format("woff2"); }

:root {
  --bar-h: 3.6rem;
  --title: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --bg: #000000;
  --text: #e9e7e1;
  --soft: #9b9890;
  --hair: #262624;
  --rule: #55534e;
  --underline: #5d5b56;
  --shape: #6d6b65;
  --hatch: rgba(255, 255, 255, 0.1);
  --accent: #ffd600;
  --on-accent: #000000;
  --anvil: #ffd600;
  --name: #ffffff;
  --cta-line: #ffd600;
  --cta-bg: #ffd600;
  --cta-text: #000000;
  --cta-hover-bg: #ffe24d;
  --cta-hover-text: #000000;
  color-scheme: dark;
}

/* The light version. The anvil stays yellow, a solid shape that holds up on white. Text and titles turn black. */
:root[data-theme="light"] {
  --bg: #ffffff;
  --text: #1a1a1a;
  --soft: #5c5c58;
  --hair: #e4e4e0;
  --rule: #b9b9b3;
  --underline: #a8a8a2;
  --shape: #8a8a84;
  --hatch: rgba(0, 0, 0, 0.08);
  --accent: #000000;
  --on-accent: #ffffff;
  --name: #000000;
  --cta-line: #000000;
  --cta-bg: #000000;
  --cta-text: #ffffff;
  --cta-hover-bg: #ffffff;
  --cta-hover-text: #000000;
  color-scheme: light;
}

/* With no pick stored, the page follows the system, so light systems get the light version too. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff;
    --text: #1a1a1a;
    --soft: #5c5c58;
    --hair: #e4e4e0;
    --rule: #b9b9b3;
    --underline: #a8a8a2;
    --shape: #8a8a84;
    --hatch: rgba(0, 0, 0, 0.08);
    --accent: #000000;
    --on-accent: #ffffff;
    --name: #000000;
    --cta-line: #000000;
    --cta-bg: #000000;
    --cta-text: #ffffff;
    --cta-hover-bg: #ffffff;
    --cta-hover-text: #000000;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Sans 3", system-ui, sans-serif;
  font-weight: 300;
  font-size: 20px;
  line-height: 1.7;
}

a { color: inherit; text-decoration-color: var(--underline); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { text-decoration-color: var(--accent); }
a:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 4px; }

.letter { max-width: 34rem; margin: 0 auto; padding: 16vh 1.5rem 3rem; }

/* The letterhead: the anvil just struck, sparks flying off its face, the name set below.
   The sparks are their own drawing, sitting on the anvil's top edge, so the anvil alone
   travels into the Life Biomes bar when the page changes. */
.letterhead { margin: 0; text-align: center; }
.crest { position: relative; display: inline-block; }
.crest .anvil { display: block; width: 6rem; height: auto; color: var(--anvil); }
.crest .sparks { position: absolute; left: 0; bottom: 100%; width: 100%; height: auto; overflow: visible; color: var(--anvil); }

/* One strike on a fresh load. A hammer appears raised, swings down onto the face and vanishes
   on impact, and the sparks burst out together at that instant. It doesn't replay when you come
   back from the Life Biomes page, and when motion isn't welcome the sparks are simply there. */
.crest .hammer { position: absolute; left: 19%; bottom: calc(100% - 2px); width: 62%; height: auto; overflow: visible; color: var(--name); opacity: 0; pointer-events: none; transform-origin: 6% 50%; }
@media (prefers-reduced-motion: no-preference) {
  .strike .crest .hammer { animation: swing 640ms 160ms both; }
  .strike .crest .sparks { transform-origin: 70% 100%; animation: burst 150ms cubic-bezier(.2, .9, .3, 1.25) 600ms both; }
  @keyframes swing {
    0% { opacity: 0; transform: rotate(-58deg); }
    18% { opacity: 1; transform: rotate(-58deg); animation-timing-function: cubic-bezier(.55, 0, 1, .45); }
    68% { opacity: 1; transform: rotate(0deg); }
    68.01%, 100% { opacity: 0; transform: rotate(0deg); }
  }
  @keyframes burst { from { transform: scale(0); } }
}
.lab-name { display: table; margin: 1.4rem auto 0; font-family: var(--title); font-weight: 500; font-size: clamp(3rem, 10vw, 4.6rem); line-height: 1; letter-spacing: -0.005em; color: var(--name); text-decoration: none; }

/* A small lockup for the sign-off and the Project page bar. The anvil's foot stands on the text baseline. */
/* The anvil is an empty inline-block painted through an anvil-shaped mask. An empty inline-block's
   bottom edge is its baseline in every engine, so the foot lands on the name's baseline in Chrome,
   Safari and Firefox alike. Inline SVG doesn't: Firefox sets it about 0.1em high. */
.lockup { display: inline-block; white-space: nowrap; color: var(--name); text-decoration: none; font-family: var(--title); font-weight: 500; font-size: 1.6rem; line-height: 1; }
.lockup .anvil-mark {
  display: inline-block; vertical-align: baseline; width: 1.62em; height: 0.75em; margin-right: 0.42em;
  background: var(--anvil);
  -webkit-mask: url("images/anvil-on-dark.svg") no-repeat center / contain;
  mask: url("images/anvil-on-dark.svg") no-repeat center / contain;
}
.lockup .anvil-wrap { position: relative; display: inline-block; vertical-align: baseline; margin-right: 0.42em; }
.lockup .anvil-wrap .anvil-mark { margin-right: 0; }
.lockup .sparks { position: absolute; left: 0; bottom: 100%; width: 100%; height: auto; overflow: visible; color: var(--anvil); }
.lockup-name { display: inline-block; }


.letter p { margin: 0 0 1.2rem; }
.opening { margin-top: 4rem !important; font-size: 1.3rem; }
.soft { color: var(--soft); }

/* What I'm doing now: one line after the opening, led by a spark that glows slowly. */
.now { display: flex; align-items: center; gap: 0.7rem; margin: 0.2rem 0 0; font-family: var(--title); font-weight: 500; font-size: 1.45rem; line-height: 1.3; color: var(--name); }
.now a { color: inherit; text-decoration-color: var(--anvil); }
.now-spark { flex: none; width: 0.9rem; height: 0.9rem; color: var(--anvil); }
@media (prefers-reduced-motion: no-preference) {
  .now-spark { animation: now-glow 2.8s ease-in-out infinite; }
  @keyframes now-glow { 50% { opacity: 0.35; } }
}

.bench { list-style: none; margin: 2.4rem 0; padding: 1.4rem 0; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); display: grid; gap: 0.9rem; }
.bench li { display: grid; grid-template-columns: 2.4rem 1fr auto; align-items: center; gap: 1rem; }
.bench .icon { width: 2.4rem; height: 2.4rem; border-radius: 8px; image-rendering: pixelated; }
.bench svg { width: 2.4rem; height: 2.4rem; color: var(--shape); }
.bench .name { color: var(--text); }
.bench .name.soft { color: var(--soft); }
.bench .state { color: var(--soft); font-size: 0.95rem; }

.signoff { margin-top: 3rem; }
.signoff .soft { display: block; font-size: 1rem; }


/* Project page */
.title { margin: 0; font-family: var(--title); font-weight: 500; color: var(--name); font-size: clamp(3rem, 12vw, 5.2rem); line-height: 0.95; letter-spacing: -0.012em; }
.hero .kind { margin: 1rem 0 0; font-size: 1.25rem; color: var(--text); }
.hero .by { margin: 0.2rem 0 0; color: var(--soft); font-size: 1rem; }
.hero-cta { margin: 1.5rem 0 0; }

/* The hero: the forest runs edge to edge under the translucent bar and dissolves into the page. */
.hero { position: relative; display: grid; align-items: end; min-height: 64svh; margin-top: calc(-1 * var(--bar-h)); overflow: hidden; }
.hero-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 28% 72%; image-rendering: pixelated;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 42%, rgba(0, 0, 0, 0.35) 72%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 42%, rgba(0, 0, 0, 0.35) 72%, transparent 100%);
}
.hero-text { position: relative; width: 100%; max-width: 34rem; margin: 0 auto; padding: 0 1.5rem 0.5rem; }
.hero-text .title { white-space: nowrap; line-height: 1; text-shadow: 0 1px 24px var(--bg); }
.title .title-text { white-space: nowrap; }
.title .lb-icon, .title .vmm-icon { display: inline-block; vertical-align: baseline; width: 0.66em; height: 0.66em; margin-right: 0.22em; border-radius: 0.14em; image-rendering: pixelated; box-shadow: 0 0 0 1px var(--hair); }
/* Vim My Mac's tile is drawn smooth, not in pixels like Life Biomes' mark. */
.bench .vmm-icon, .title .vmm-icon { image-rendering: auto; }
/* Vim My Mac's card is drawn smooth, and starts under the bar so its NORMAL tab shows whole. */
.hero-img.vmm-hero { top: var(--bar-h); height: calc(100% - var(--bar-h)); object-position: 50% 0%; image-rendering: auto; }
/* The keys sit about a fifth of the width down, so the title always starts below them. */
.hero.vmm { padding-top: calc(var(--bar-h) + 19vw); }
.letter code { font-size: 0.9em; }

/* Keys in the text, as keycaps. Meh is underlined dotted and explains itself on hover or focus. */
.letter kbd { display: inline-block; padding: 0 0.4em; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px; font-family: inherit; font-size: 0.85em; line-height: 1.5; color: var(--name); }
.keys { white-space: nowrap; }
.keys kbd { margin: 0 0.15em; }
.meh { position: relative; cursor: help; }
.meh kbd { text-decoration: underline dotted var(--soft); text-underline-offset: 3px; }
.meh:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; border-radius: 5px; }
.tip { position: absolute; left: 50%; bottom: calc(100% + 0.5rem); z-index: 1; width: max-content; max-width: 16rem; padding: 0.5rem 0.75rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 0.85rem; line-height: 1.4; white-space: normal; transform: translateX(-50%); opacity: 0; visibility: hidden; transition: opacity 120ms ease, visibility 120ms; }
.meh:hover .tip, .meh:focus .tip { opacity: 1; visibility: visible; }

/* The quote reads like the rest of the text. It stays a blockquote for screen readers. */
.pull { margin: 0 0 1.2rem; }
.pull p { margin: 0; }
.cta { display: inline-block; padding: 0.45rem 1.2rem; border: 1px solid var(--cta-line); border-radius: 6px; background: var(--cta-bg); color: var(--cta-text); font-weight: 400; text-decoration: none; }
.cta:hover { background: var(--cta-hover-bg); color: var(--cta-hover-text); }
.small-head { margin: 2.6rem 0 0.5rem; font-family: var(--title); font-weight: 700; color: var(--name); font-size: 1.85rem; line-height: 1.15; }

/* The way back on the Project page: pinned to the top, so it is there however far you scroll. */
.bar { position: sticky; top: 0; z-index: 2; height: var(--bar-h); background: color-mix(in srgb, var(--bg) 72%, transparent); -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2); border-bottom: 1px solid color-mix(in srgb, var(--hair) 70%, transparent); }
.bar-inner { display: flex; align-items: center; height: 100%; max-width: 34rem; margin: 0 auto; padding: 0 1.5rem; }
.bar .lockup { font-size: 1.35rem; }
.lockup .chev { display: inline-block; vertical-align: -0.02em; width: 0.42em; height: 0.68em; margin-right: 0.5em; color: var(--soft); transition: transform 160ms ease; }
.back:hover .chev, .back:focus-visible .chev { transform: translateX(-3px); color: var(--text); }
.letter.project { padding-top: 1.5rem; }

/* Moving between pages. The anvil and name shrink into the bar, the rest of the letter fades,
   and Life Biomes grows from its row into the page title. Going back plays it in reverse.
   Only for readers who are fine with motion, and only in browsers that support it. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  .letterhead .crest .anvil, .bar .anvil-mark { view-transition-name: anvil; }
  .letterhead .lab-name, .bar .lockup-name { view-transition-name: lab-name; }
  .lb-link, .lb-title { view-transition-name: project-title; }
  .bench .lb-icon, .title .lb-icon { view-transition-name: project-icon; }
  .vmm-link, .vmm-title { view-transition-name: vmm-title; }
  .bench .vmm-icon, .title .vmm-icon { view-transition-name: vmm-icon; }
  .theme-switch { view-transition-name: theme-switch; }

  ::view-transition-group(*) { animation-duration: 560ms; animation-timing-function: cubic-bezier(.22, .8, .2, 1); }
  ::view-transition-group(project-title), ::view-transition-group(vmm-title) { animation-delay: 70ms; }

  /* Text keeps its proportions while it grows or shrinks, instead of stretching to the box. */
  ::view-transition-old(lab-name), ::view-transition-new(lab-name),
  ::view-transition-old(project-title), ::view-transition-new(project-title),
  ::view-transition-old(vmm-title), ::view-transition-new(vmm-title) { height: 100%; width: auto; }

  ::view-transition-old(root) { animation: vt-out 180ms ease-out both; }
  ::view-transition-new(root) { animation: vt-in 380ms ease-out 240ms both; }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    .hero-img { animation: drift linear both; animation-timeline: scroll(root); animation-range: 0 70svh; }
    @keyframes drift { to { transform: translateY(14%) scale(1.04); } }
  }
}

/* The theme switch. It only appears when JavaScript runs, since it needs it to work. */
.theme-switch { position: fixed; top: 0.6rem; right: 1rem; z-index: 3; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; padding: 0; border: 1px solid var(--rule); border-radius: 50%; background: var(--bg); color: var(--text); cursor: pointer; }
.theme-switch svg { width: 1.25rem; height: 1.25rem; }
.theme-switch:hover { border-color: var(--accent); }
.theme-switch:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) {
  body { transition: background-color 250ms ease, color 250ms ease; }
}

/* Placeholder copy. It is meant to look unfinished. */

@media (max-width: 560px) {
  body { font-size: 18px; }
  .letter { padding-top: 9vh; }
  .hero { min-height: 56svh; }
  .hero .kind { font-size: 1.1rem; }
  .hero-img { object-position: 12% 75%; }
}
