/*
 * themrmatt.net
 *
 * The measurements come from the GIMP mockup, a 1920 x 1080 canvas: a
 * 1120px page in two columns, a 310px one for pictures and the rest for
 * text, 18px apart. Narrower than 768px there is one column, and only the
 * header keeps its picture beside its text.
 */

/* ---- Inter (SIL Open Font License, see ../fonts/OFL.txt) ---- */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- the mockup's colours and sizes ---- */

:root {
  --color-bg: #fff;
  --color-text: #000;
  --color-muted: #828282;       /* "Cool Site" */
  --color-rule: #8d8d8d;        /* the lines, and the bar under the current page */
  --color-rule-light: #d9d9d9;
  --color-quiet: #595959;       /* captions and small print: grey, but dark enough to read */
  --color-code-bg: #f3f3f3;
  --color-footer-bg: #464646;
  --color-footer-text: #fff;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --container: 70rem;           /* 1120px */
  --gutter: 1.25rem;            /* the least space left and right of the page */
  --media-col: clamp(5.5rem, 27vw, 7.5rem);   /* one column: just the header's portrait */
  --col-gap: 0.875rem;
  --measure: 40rem;             /* the widest a column of text gets */
  --measure-card: 24rem;        /* a project's blurb in the list: 384px in the mockup */
  --rule-width: 22.8125rem;     /* the line under a heading: 365px in the mockup */

  color-scheme: light;
}

@media (min-width: 48em) {
  :root {
    --gutter: 2rem;
    --media-col: clamp(12rem, 27.7vw, 19.375rem);   /* 310px of the 1120 */
    --col-gap: 1.125rem;                            /* 18px */
  }
}

/* ---- basics ---- */

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

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

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

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

a {
  color: inherit;
  text-decoration-thickness: 0.0625em;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.125em;
}

:focus-visible {
  outline: 0.1875rem solid var(--color-text);
  outline-offset: 0.1875rem;
}

.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 10;
  padding: 0.5rem 0.875rem;
  background: var(--color-text);
  color: var(--color-bg);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.5rem;
}

/* ---- header ---- */

.site-header {
  padding-top: clamp(1.5rem, 6vw, 2.5rem);
}

.site-header__inner {
  display: grid;
  grid-template-columns: var(--media-col) minmax(0, 1fr);
  column-gap: var(--col-gap);
  align-items: end;
  border-bottom: 2px solid var(--color-rule);
}

/* The portrait stands on the line, and covers it. */
.site-header__portrait {
  display: block;
  width: 100%;
  margin-bottom: -3px;
}

.site-title {
  margin: 0;
  font-size: clamp(1.625rem, 1rem + 3.2vw, 3rem);
  font-weight: 900;
  line-height: 1.25;
}

.site-title a {
  display: inline-block;
  text-decoration: none;
}

.site-title span {
  display: block;
}

.site-title__sub {
  color: var(--color-muted);
}

.site-nav {
  margin-top: clamp(0.625rem, 3.6vw, 2.5rem);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  column-gap: clamp(1.375rem, 7vw, 6.1875rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  position: relative;
  display: block;
  padding-bottom: 0.25rem;
  font-size: clamp(1.125rem, 0.9rem + 1vw, 1.5rem);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

/* The bar under the current page's link, laid over the header's line. */
.site-nav a::after {
  content: "";
  position: absolute;
  left: -0.125rem;
  right: -0.125rem;
  bottom: -5px;
  height: 7px;
}

.site-nav a[aria-current]::after {
  background: var(--color-rule);
}

.site-nav a:not([aria-current]):hover::after {
  background: var(--color-rule-light);
}

@media (min-width: 48em) {
  .site-header {
    /* 130px on the mockup's 1080 lines, less on a shorter screen */
    padding-top: clamp(2.5rem, 12vh, 8.125rem);
  }

  /* 187px of the 310, 48px in from the column's right edge */
  .site-header__portrait {
    justify-self: end;
    width: 60.3%;
    max-width: 11.6875rem;
    margin-right: 15.5%;
  }
}

/* ---- the page ---- */

.site-main {
  flex: 1 0 auto;
  padding-top: clamp(2rem, 5.5vw, 3.8125rem);
  padding-bottom: clamp(3rem, 9vw, 6rem);
}

/* Two columns: pictures (.page__media) on the left, everything else on the right. */
@media (min-width: 48em) {
  .page {
    display: grid;
    grid-template-columns: var(--media-col) minmax(0, 1fr);
    column-gap: var(--col-gap);
  }

  .page > * {
    grid-column: 2;
  }

  .page > .page__media {
    grid-column: 1;
  }
}

.section-heading {
  max-width: var(--rule-width);
  margin: 0;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--color-rule);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.more-link {
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--color-quiet);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
}

/* ---- the list of projects ---- */

.category + .category {
  margin-top: 4rem;
}

.project-card {
  margin-top: 2rem;
}

.project-card__media {
  display: block;
  max-width: 26rem;
  margin-bottom: 1rem;
}

.project-card__media img,
.shot img {
  display: block;
  width: 100%;
  background: #e8e8e8;
}

/*
 * A thumbnail made from the game's own pixels is a little too wide, because
 * those pixels aren't square. Its class says what shape the picture really
 * is, and the browser stretches it the last 7%.
 */
.ratio-16-9 {
  aspect-ratio: 16 / 9;
}

.ratio-16-10 {
  aspect-ratio: 16 / 10;
}

.ratio-4-3 {
  aspect-ratio: 4 / 3;
}

.project-card__text {
  max-width: var(--measure-card);
}

.project-card__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.project-card__title a {
  text-decoration: none;
}

.project-card__title a:hover {
  text-decoration: underline;
}

.project-card__summary {
  margin: 0.625rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.project-card__more {
  margin: 1rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.4;
}

@media (min-width: 48em) {
  .project-card {
    margin-top: 3rem;
  }

  .project-card__media {
    align-self: start;
    max-width: none;
    margin-bottom: 0;
  }

  /* the heading's capitals level with the top of the picture */
  .project-card__title {
    margin-top: -0.3rem;
  }

  /* the mockup's 14px on 18px, which ends the blurb level with the picture */
  .project-card__summary,
  .project-card__more {
    font-size: 0.875rem;
    line-height: 1.2857;
  }
}

/* ---- a project's page ---- */

.project__title {
  margin: 0;
  font-size: clamp(2rem, 1.5rem + 2vw, 2.5rem);
  font-weight: 800;
  line-height: 1.1;
}

.project__lead {
  max-width: var(--measure);
  margin: 0.875rem 0 0;
  font-size: 1.125rem;
  line-height: 1.5;
}

.shots {
  margin: 0;
  padding: 0;
  list-style: none;
}

.shot {
  margin: 0;
}

.shot a {
  display: block;
  /* (a phone's grey flash on a tap would show through the viewer as it opens) */
  -webkit-tap-highlight-color: transparent;
}

.shot figcaption {
  margin-top: 0.5rem;
  color: var(--color-quiet);
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* One column: the pictures are a strip to swipe through, all the same height. */
@media (max-width: 47.9375em) {
  .project__shots {
    margin: 1.75rem calc(-1 * var(--gutter)) 0;
  }

  .shots {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0 var(--gutter) 0.75rem;
    scroll-padding-inline: var(--gutter);
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
  }

  .shots > li {
    flex: none;
    scroll-snap-align: start;
  }

  .shot {
    display: flex;
    flex-direction: column;
    width: min-content;
  }

  .shot img {
    width: auto;
    max-width: none;
    height: clamp(9.5rem, 46vw, 15rem);
  }

  .project__body {
    margin-top: 2rem;
  }
}

/* Two columns: the pictures run down the left, beside the text. */
@media (min-width: 48em) {
  .project {
    grid-template-rows: auto 1fr;
    row-gap: 2.5rem;
  }

  .project__intro {
    grid-row: 1;
  }

  .project__shots {
    grid-row: 1 / span 2;
  }

  .project__body {
    grid-row: 2;
  }

  .shots {
    display: grid;
    gap: 1.75rem;
  }

  /* the small line above the title level with the top of the first picture */
  .eyebrow {
    margin-top: -0.2rem;
  }
}

/* ---- running text ---- */

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

.prose > :first-child {
  margin-top: 0;
}

.prose p,
.prose ul,
.prose ol,
.prose pre,
.prose .table-wrap {
  margin: 1rem 0 0;
}

.prose h2 {
  margin-top: 3.25rem;
}

.prose h2 + * {
  margin-top: 1.25rem;
}

.prose h3 {
  margin: 2.25rem 0 0;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
}

.prose h3 + * {
  margin-top: 0.625rem;
}

.prose ul,
.prose ol {
  padding-left: 1.375rem;
}

.prose li + li {
  margin-top: 0.375rem;
}

.prose code,
.prose kbd,
.prose pre {
  font-family: var(--font-mono);
}

.prose code {
  padding: 0.1em 0.3em;
  background: var(--color-code-bg);
  font-size: 0.875em;
  overflow-wrap: anywhere;
}

/* Where there's room, a file name stays in one piece. */
@media (min-width: 48em) {
  .prose code {
    white-space: nowrap;
  }
}

.prose pre {
  padding: 0.875rem 1rem;
  overflow-x: auto;
  background: var(--color-code-bg);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  overflow-wrap: normal;
  white-space: inherit;
}

.prose kbd {
  padding: 0.05em 0.35em;
  border: 1px solid #b3b3b3;
  border-bottom-width: 2px;
  background: #fafafa;
  font-size: 0.8125em;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.prose th,
.prose td {
  padding: 0.5rem 1rem 0.5rem 0;
  text-align: left;
  vertical-align: top;
}

.prose th:last-child,
.prose td:last-child {
  padding-right: 0;
}

.prose th {
  border-bottom: 2px solid var(--color-rule);
  font-weight: 700;
  white-space: nowrap;
}

.prose td {
  border-bottom: 1px solid var(--color-rule-light);
}

.prose .fine-print {
  margin-top: 3.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-rule-light);
  color: var(--color-quiet);
  font-size: 0.8125rem;
  line-height: 1.5;
}

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

.site-footer {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  font-size: 0.875rem;
  line-height: 1.2143;          /* 17px, for a 71px bar as in the mockup */
  text-align: center;
}

.site-footer p {
  margin: 0;
  padding: 1.6875rem 0;
}

/* ---- the screenshot viewer (assets/js/lightbox.js) ---- */

.has-lightbox {
  overflow: hidden;
}

.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(17 17 17 / 0.96);
  color: #fff;
}

.lightbox::backdrop {
  background: #111;
}

.lightbox__frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.lightbox__stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 0.75rem;
}

.lightbox__image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.15s;
}

/* an <img> with nothing in it yet draws nothing, not a broken-picture icon */
.lightbox__image:not([src]) {
  visibility: hidden;
}

.lightbox.is-loading .lightbox__image {
  opacity: 0.4;
}

@media (prefers-reduced-motion: reduce) {
  .lightbox__image {
    transition: none;
  }
}

.lightbox__caption {
  min-height: 3.5rem;
  margin: 0;
  padding: 0.875rem 1.25rem 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.4;
  text-align: center;
}

.lightbox__button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.lightbox__button:hover {
  background: rgb(255 255 255 / 0.16);
}

.lightbox__button:focus-visible {
  outline-color: #fff;
  outline-offset: -0.1875rem;
}

.lightbox__button svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lightbox__step {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgb(17 17 17 / 0.6);
}

.lightbox__step:hover {
  background: rgb(60 60 60 / 0.85);
}

.lightbox__step--previous {
  left: 0.5rem;
}

.lightbox__step--next {
  right: 0.5rem;
}

@media (min-width: 48em) {
  .lightbox__stage {
    padding: 0 4.25rem;
  }

  .lightbox__step--previous {
    left: 0.75rem;
  }

  .lightbox__step--next {
    right: 0.75rem;
  }
}

@media print {
  .site-nav,
  .skip-link {
    display: none;
  }

  .site-footer {
    background: none;
    color: inherit;
  }
}
