/* ==========================================================================
   Fonts (self-hosted, SIL Open Font License; see assets/fonts/)
   ========================================================================== */

@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-300.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("../fonts/newsreader-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* ==========================================================================
   Tokens
   ========================================================================== */

:root {
  --bg: #15181b;
  --surface: #1c2024;
  --line: #31373c;
  --text: #ebe8e2;
  --muted: #a9aeb2;
  --accent: #dcae6a;
  --placeholder: #9cc4d4;

  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", Menlo, Consolas, monospace;

  --measure: 42rem;
  --wrap: 72rem;
  --gutter: clamp(1rem, 6vw, 5.5rem);
  --section-gap: 4.5rem;
  --side-column: 14rem;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-wrap: break-word;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}

main { flex: 1; width: 100%; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

a { color: var(--accent); text-underline-offset: 0.2em; }
a:hover { color: var(--text); }

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

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

h1, h2, h3 { text-wrap: balance; }

/* Missing information. See "Replace placeholders" in the README. */
mark {
  background: none;
  color: var(--placeholder);
}

.print-only { display: none; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  color: var(--bg);
  z-index: 10;
}
.skip-link:focus { top: 0.5rem; color: var(--bg); }

/* ==========================================================================
   Site header and footer
   ========================================================================== */

.site-header { border-bottom: 1px solid var(--line); }

.site-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  padding-block: 0.75rem;
}

.site-name {
  padding-block: 0.5rem;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.site-header ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header nav a {
  display: inline-block;
  padding-block: 0.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
}
.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
}

.site-footer {
  margin-top: var(--section-gap);
  padding-block: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

/* ==========================================================================
   Page headers
   ========================================================================== */

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-block: clamp(3.5rem, 8vw, 6.5rem) 3.5rem;
}

.portrait {
  flex-shrink: 0;
  width: 10rem;
  height: 10rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
}

.hero h1, .page-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 300;
  letter-spacing: -0.015em;
}

.hero h1 {
  max-width: 61rem;
  font-size: clamp(2.375rem, 5.4vw, 4.25rem);
  line-height: 1.08;
}

.page-header { padding-block: clamp(3rem, 6vw, 5rem) 3rem; }

.page-header h1 {
  font-size: clamp(2.375rem, 4.6vw, 3.5rem);
  line-height: 1.1;
}

.lede {
  max-width: 40rem;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1.5;
}

.back-link { margin: 0 0 1.25rem; font-size: 0.9375rem; }

/* ==========================================================================
   Facts (label and value pairs)
   ========================================================================== */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr));
  gap: 1.25rem 2rem;
  margin: 0;
  padding-block: 1.5rem;
  border-block: 1px solid var(--line);
}

.facts dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.facts dd { margin: 0.25rem 0 0; }
.facts .highlight-value { color: var(--accent); }

.facts mark {
  padding: 0 0.375rem;
  border: 1px dashed var(--placeholder);
  font-size: 0.9375rem;
}

/* ==========================================================================
   Prose (rendered Markdown)
   ========================================================================== */

.prose > * { max-width: var(--measure); }

.prose h2, .experience-side h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.875rem;
  line-height: 1.2;
}

.prose > h2 { margin: 3rem 0 0.75rem; }

.prose h3 { margin: 2rem 0 0.5rem; font-size: 1.1875rem; font-weight: 500; }

.prose p, .prose ul, .prose ol { margin-block: 0 1rem; }
.prose li { margin-bottom: 0.35rem; }
.prose li::marker { color: var(--muted); }

.prose img { display: block; margin-block: 1.5rem; border: 1px solid var(--line); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

.prose code {
  padding: 0.1em 0.35em;
  background: var(--surface);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.prose div.highlighter-rouge { min-width: 0; }

.prose pre {
  margin-block: 1rem 1.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  line-height: 1.55;
}
.prose pre code { padding: 0; background: none; font-size: 0.875rem; }

.prose table {
  display: block;
  overflow-x: auto;
  margin-block: 1rem 1.5rem;
  border-collapse: collapse;
}
.prose th, .prose td {
  padding: 0.6rem 1.5rem 0.6rem 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.prose th {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
}

/* Syntax highlighting */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cp { color: var(--muted); }
.highlight .k, .highlight .kd, .highlight .kt, .highlight .kr { color: var(--accent); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .m, .highlight .mi, .highlight .mf { color: var(--placeholder); }

/* ==========================================================================
   Sections: each Markdown h2 sits in a left column, its content on the right.
   Grid auto-placement starts a new row whenever a heading follows content.
   ========================================================================== */

.sections {
  display: grid;
  grid-template-columns: var(--side-column) minmax(0, 1fr);
  column-gap: 3rem;
}

.sections > * { grid-column: 2; min-width: 0; }

/* The span stops a tall heading from stretching the first content row. */
.prose.sections > h2 {
  grid-column: 1;
  grid-row: span 6;
  margin: var(--section-gap) 0 0;
}

.sections > h2 + * { margin-top: var(--section-gap); }

.prose .ruled-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  column-gap: 3rem;
  max-width: none;
  margin-bottom: 0;
  padding: 0;
  list-style: none;
}

.prose .ruled-list li {
  margin: 0;
  padding-block: 0.7rem;
  border-bottom: 1px solid var(--line);
}

/* ==========================================================================
   Project lists
   ========================================================================== */

.prose > .project-list { max-width: none; margin-bottom: 1.25rem; }

.project-row {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.sections .project-row:first-child { padding-top: 0.25rem; }

.project-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
}

.prose .project-row h3 { margin: 0; }
.prose .project-row h3 a { color: var(--text); }
.prose .project-row h3 a:hover { color: var(--accent); }

.prose .project-row-meta {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.prose .project-row-desc { max-width: var(--measure); margin: 0; }

/* Links to other sites get a small arrow. It's drawn as an icon, so it doesn't
   depend on the font and isn't read out by screen readers. */
main a[href^="http"]:not([href*="repsej.github.io"])::after {
  --external-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23000' stroke-width='1.5'%3E%3Cpath d='M3 9 9 3M4 3h5v5'/%3E%3C/svg%3E");
  content: "";
  display: inline-block;
  width: 0.65em;
  height: 0.65em;
  margin-left: 0.2em;
  background: currentColor;
  -webkit-mask: var(--external-icon) center / contain no-repeat;
  mask: var(--external-icon) center / contain no-repeat;
}

/* ==========================================================================
   Project pages
   ========================================================================== */

.gallery {
  width: 20rem;
  max-width: 100%;
  margin: 2.25rem 0 0;
  padding: 0;
  list-style: none;
}

.gallery-item {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  transition: border-color 0.15s;
}
.gallery-item:hover { border-color: var(--accent); }

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  margin: 0; /* undo .prose img when a gallery sits in page text */
  border: 0;
}

.gallery-count {
  position: absolute;
  right: 0.25rem;
  bottom: 0.25rem;
  padding: 0 0.375rem;
  font-size: 0.75rem;
  color: #fff;
  background: rgb(0 0 0 / 0.7);
}

/* Play icon on GIFs that have a still thumbnail */
.gallery-item.is-animated::before,
.gallery-item.is-animated::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.gallery-item.is-animated::before {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.7);
}
.gallery-item.is-animated::after {
  width: 0.9rem;
  height: 1rem;
  margin-left: 0.1rem;
  background: #fff;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

html:has(.viewer[open]) { overflow: hidden; }

/* The viewer shrinks to fit its image, so the buttons sit on top of the image. */
.viewer {
  min-width: 16rem;
  min-height: 10rem;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  overflow: hidden;
  color: #fff;
  background: #000;
}
.viewer::backdrop { background: rgb(0 0 0 / 0.85); }

.viewer-image {
  display: block;
  max-width: min(85vw, 56rem);
  max-height: 80dvh;
}

.viewer-loading,
.viewer-count {
  position: absolute;
  margin: 0;
  padding: 0.125rem 0.625rem;
  font-size: 0.875rem;
  color: #fff;
  background: rgb(0 0 0 / 0.7);
}
.viewer-loading {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.viewer-loading[hidden] { display: none; }
.viewer-count {
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
}
.viewer-count:empty { display: none; }

.viewer-button {
  position: absolute;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  color: #fff;
  background: rgb(0 0 0 / 0.7);
  cursor: pointer;
}
.viewer-button:hover { background: rgb(60 60 60 / 0.9); }
.viewer-close { top: 0.5rem; right: 0.5rem; }
.viewer-prev, .viewer-next { top: 50%; transform: translateY(-50%); }
.viewer-prev { left: 0.5rem; }
.viewer-next { right: 0.5rem; }
.viewer.is-single .viewer-prev,
.viewer.is-single .viewer-next { display: none; }

/* Buttons and the image count fade out unless the mouse is over the image.
   Touchscreens have no hover, so they keep them, and keyboard users see the
   focused button and the count. */
.viewer-loading, .viewer-count { pointer-events: none; }
@media (hover: hover) {
  .viewer-button, .viewer-count { opacity: 0; }
  .viewer:has(.viewer-image:hover, .viewer-button:hover) .viewer-button,
  .viewer:has(.viewer-image:hover, .viewer-button:hover) .viewer-count,
  .viewer:has(.viewer-button:focus-visible) .viewer-count,
  .viewer-button:focus-visible { opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .viewer-button { transition: opacity 0.2s, background-color 0.15s; }
  .viewer-count { transition: opacity 0.2s; }
}

/* ==========================================================================
   Experience
   ========================================================================== */

.prose > .experience-list { max-width: none; }

.experience-entry {
  display: grid;
  grid-template-columns: var(--side-column) minmax(0, 1fr);
  column-gap: 3rem;
  padding-block: 2rem;
  border-top: 1px solid var(--line);
}
.experience-entry:last-child { border-bottom: 1px solid var(--line); }

.prose .experience-period {
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.experience-main { max-width: var(--measure); }
.prose .experience-title { margin: 0 0 0.5rem; font-weight: 500; }
.experience-main > :last-child { margin-bottom: 0; }

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 48rem) {
  :root { --section-gap: 3rem; }

  .site-header ul { column-gap: 0.875rem; }
  .sections { display: block; }
  .prose.sections > h2 { margin-bottom: 0.75rem; }
  .sections > h2 + * { margin-top: 0; }

  .hero { flex-direction: column-reverse; align-items: stretch; gap: 1.5rem; }
  .portrait { align-self: flex-start; width: 6rem; height: 6rem; }

  .experience-entry { grid-template-columns: minmax(0, 1fr); row-gap: 0.75rem; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ==========================================================================
   Print (used to save the experience page as a PDF)
   ========================================================================== */

@media print {
  :root {
    --bg: #fff;
    --surface: #f4f4f4;
    --line: #bbb;
    --text: #000;
    --muted: #444;
    --accent: #000;
    --placeholder: #000;
    --section-gap: 1.25rem;
  }

  @page { margin: 16mm; }

  body { display: block; font-size: 10.5pt; line-height: 1.45; }

  .site-header nav, .site-footer, .skip-link, .back-link { display: none; }
  .print-only { display: block; }

  .site-header { border: 0; }
  .site-header-inner { display: block; padding: 0 0 0.5rem; }
  .site-name { padding: 0; font-size: 16pt; }
  .print-tagline { margin: 0.1rem 0 0; color: var(--muted); }

  .wrap { max-width: none; padding: 0; }
  .prose > * { max-width: none; }

  .hero, .page-header { padding: 0.5rem 0 0.75rem; }
  .hero h1, .page-header h1 { font-size: 16pt; }
  .lede { margin-top: 0.25rem; font-size: 11pt; }

  .prose h2, .experience-side h2 { font-size: 13pt; }

  .experience-entry {
    grid-template-columns: 11rem minmax(0, 1fr);
    padding-block: 0.75rem;
    break-inside: avoid;
  }
  .experience-main { max-width: none; }

  h2, h3 { break-after: avoid; }
  li, pre, img, tr { break-inside: avoid; }

  a { color: #000; text-decoration: none; }
  main a[href^="http"]:not([href*="repsej.github.io"])::after { display: none; }
}
