/* ==========================================================================
   erin-morris.com — styles
   --------------------------------------------------------------------------
   Every size on the site is a multiple of one "unit" (--u). On a computer the
   unit is 1.44% of the window height, which is exactly what one "rem" was on
   your Cargo site, so the pages scale with the window the same way they did
   there. On a phone (or any window taller than it is wide) the unit grows so
   the paintings fill the width of the screen.

   To change a colour or a spacing, change it in the :root block just below:
   everything else on the site reads from there.
   ========================================================================== */

@font-face {
  font-family: "Libertinus Mono";
  src: url("fonts/libertinus-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  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: "Libertinus Mono";
  src: url("fonts/libertinus-mono-latin-ext-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  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;
}

:root {
  /* The unit. 1.44vh = 1.44% of the window height. */
  --u: 1.44vh;

  /* Colours (copied from your Cargo design). */
  --background: #ffffff;
  --text: rgba(0, 0, 0, 0.75);
  --menu: rgba(255, 162, 0, 0.85);
  --link: #0000ff;                      /* links to other websites */
  --link-here: rgba(255, 162, 0, 0.85); /* links to pages of this website */

  /* Captions under the paintings. "hidden" keeps their space on the page but
     never shows them, not even when someone selects the page or searches
     it, so a caption only appears when its painting is clicked open.
     To show a caption under every painting, change "hidden" to "visible". */
  --feed-captions: hidden;

  /* Spacing, in units. */
  --feed-top: calc(5.4 * var(--u));   /* above the first painting */
  --gap: calc(11.9 * var(--u));       /* between one caption and the next painting */
  --side: max(10px, var(--u));        /* smallest margin left and right */

  /* Text sizes. The menu and the About page are fixed sizes, like on Cargo,
     so they never grow with the window. */
  --menu-size: 19.18px;
  --caption-size: max(11px, calc(1.2 * var(--u)));
  --zoom-caption-size: var(--cv-size);  /* an enlarged painting's caption matches the About text */
  --body-size: max(13px, calc(1.31 * var(--u)));
  --cv-size: 14.5px;                    /* the About page */

  /* The About column is never narrower than this many characters while the
     menu is down the left side (it was about this wide in your screenshot). */
  --cv-min-chars: 43;

  --mono: "Libertinus Mono", "Courier New", Courier, monospace;
}

/* Mobile view: windows 768px wide or less (where Cargo switches too), and
   any window taller than it is wide. The menu moves to the top, and the menu,
   the About text and the caption of an enlarged painting are all the same
   fixed size. */
@media (orientation: portrait), (max-width: 768px) {
  :root {
    --u: max(1.44vh, 2.49vw);
    --feed-top: calc(7.2 * var(--u));
    --side: 10px;
    --menu-size: 16px;
    --cv-size: var(--menu-size);
  }
}

/* --------------------------------------------------------------------------
   Basics
   -------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--body-size);
  line-height: 1.3;
  letter-spacing: 0.015em;
}

/* Links to other websites are blue. Links that stay on this website (they
   have no "https:" or "mailto:" in front, or they point at erin-morris.com)
   are orange. Neither changes colour after it has been visited. */
a {
  color: var(--link);
  text-decoration: none;
}

a:not([href*=":"]),
a[href^="https://erin-morris.com"],
a[href^="https://www.erin-morris.com"],
a[href^="http://erin-morris.com"],
a[href^="http://www.erin-morris.com"] {
  color: var(--link-here);
}

a:hover {
  text-decoration: underline;
}

a:active,
.work-open:active {
  opacity: 0.7;
}

/* After a painting's zoom is closed with a tap or click, focus goes back to the
   painting without a ring around it (site.js adds quiet-focus). Closed with the
   keyboard, the ring shows as usual. */
.work-open.quiet-focus:focus {
  outline: none;
}

/* --------------------------------------------------------------------------
   Menu ("Images" and "About")
   -------------------------------------------------------------------------- */

.menu {
  position: fixed;
  z-index: 10;
  top: calc(2 * var(--u) + 18.8px);
  left: var(--u);
  display: flex;
  flex-direction: column;
  font-size: var(--menu-size);
  line-height: 2.6;
  letter-spacing: 0.027em;
}

.menu a,
.menu a:visited {
  color: var(--menu);
}

@media (orientation: portrait), (max-width: 768px) {
  .menu {
    top: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    justify-content: space-around;
    padding: calc(var(--u) - 2px) 5vw 0;
    line-height: 1.6;
    pointer-events: none; /* clicks between the two words reach the painting underneath */
  }

  .menu a {
    pointer-events: auto;
  }
}

/* --------------------------------------------------------------------------
   The Images page: one column of paintings
   -------------------------------------------------------------------------- */

.feed {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  padding: var(--feed-top) var(--side) 0;
}

.work {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

/* The painting is a button, so it can be opened with a click, a tap or the
   keyboard. These lines remove the button look. */
.work-open {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: zoom-in;
  max-width: 100%;
}

/* Each painting's height is its "scale" (your old "Vert %" column) times the
   unit — so bigger paintings look bigger — unless that would make it wider
   than the screen, in which case it shrinks to fit. --scale and --ratio
   (width ÷ height) are set on each painting by site.js. */
.work img {
  display: block;
  width: auto;
  max-width: 100%;
  height: calc(var(--scale) * var(--u));
  object-fit: contain;
  aspect-ratio: var(--ratio);
  background: #f4f4f4; /* a pale grey box while the picture loads */
}

@supports (width: 1cqw) {
  .work img {
    max-width: none;
    height: min(calc(var(--scale) * var(--u)), calc(100cqw / var(--ratio)));
  }
}

.work img.is-loaded {
  background: none;
}

.work figcaption {
  /* As wide as the painting (a long title wraps onto a second line). */
  width: 0;
  min-width: 100%;
  margin-top: calc(0.8 * var(--u));
  padding-top: calc(0.52 * var(--u));
  font-size: var(--caption-size);
  line-height: 1.3;
  color: var(--text);
  text-align: center;
  visibility: var(--feed-captions);
}

.feed-empty {
  margin: calc(10 * var(--u)) var(--side);
  text-align: center;
}

/* --------------------------------------------------------------------------
   The traffic at the bottom of the Images page
   -------------------------------------------------------------------------- */

/* The movement itself is in assets/site.js (speed and direction are at the
   top of that file). It redraws the text one character at a time, so the
   picture never slides: each spot in the grid just changes character. */
.traffic {
  margin-top: 14px;
  overflow: hidden;
  padding: 0 0 10px;
}

.traffic pre {
  margin: 0;
  font-family: monospace;
  font-size: 14.5px;
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Zoom: a painting shown as large as the window allows
   -------------------------------------------------------------------------- */

body.zoom-open {
  overflow: hidden;
}

.zoom {
  position: fixed;
  z-index: 100;
  inset: 0;
  background: var(--background);
  cursor: zoom-out;
}

.zoom[hidden] {
  display: none;
}

.zoom-image {
  position: absolute;
  display: block;
  /* left, top, width and height are set by site.js to fit the window */
}

.zoom-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2%;
  margin: 0;
  padding: 0 var(--side);
  font-size: var(--zoom-caption-size);
  line-height: 1.3;
  color: var(--text);
  text-align: center;
}

.zoom:focus {
  outline: none;
}

/* How the zoom's caption breaks when it's too long for one line (the rules
   are explained in site.js, above fillCaption).
   The two parts, "Title," and "2025, 16" x 12"", each stay in one piece, so
   the caption breaks right after the title. */
.caption-part {
  display: inline-block;
}

/* A title too long for one line: the lines are evened out instead. */
.zoom-caption.is-balanced {
  text-wrap: balance;
}

/* --------------------------------------------------------------------------
   The About page (CV)
   -------------------------------------------------------------------------- */

/* The same column as on Cargo: it starts a quarter of the way across the
   window plus 13 units, and it is half the window wide minus 25 units, so it
   widens and narrows with the window exactly as it did there. */
.cv {
  margin: 0 0 0 calc(25% + 13 * var(--u));
  /* 5 units and one empty line above your name, as on Cargo. */
  padding: calc(5 * var(--u) + 1.3em) 0 calc(10 * var(--u));
  width: calc(50% - 25 * var(--u));
  min-width: calc(var(--cv-min-chars) * (1ch + 0.015em));
  font-size: var(--cv-size);
  letter-spacing: 0.015em;
}

.cv p,
.cv h1,
.cv h2 {
  margin: 0 0 1.3em;
  font-size: 1em;
  font-weight: 400;
  line-height: 1.3;
}

/* When an entry needs two or three lines, even out their lengths so a word
   or two isn't left hanging on its own last line. Delete this rule to go
   back to Cargo's line breaks. */
.cv p {
  text-wrap: balance;
}

.cv h2 {
  margin-top: 2.6em;
  margin-bottom: 0;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.cv h1 {
  margin-bottom: 0;
}

@media (orientation: portrait), (max-width: 768px) {
  /* Across the screen with a small margin each side, like on Cargo. */
  .cv {
    width: auto;
    min-width: 0;
    margin: 0;
    padding: calc(2.1 * var(--u) + 41.6px) calc(1.2 * var(--u)) 60px;
  }
}

/* --------------------------------------------------------------------------
   Small helpers
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  margin: calc(10 * var(--u)) var(--side);
  text-align: center;
}
