/* Old Standard TT, self-hosted. Latin subset only; see scripts/vendor.mjs. */
@font-face {
  font-family: "Old Standard TT";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/old-standard-tt-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Old Standard TT";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/old-standard-tt-latin-400-italic.woff2") format("woff2");
}

/* Layout: black, with a moving figure and one column of text.
   In a landscape window the text sits on the left and the figure stays fixed beside it,
   so a long text scrolls past a figure that does not move.
   In a portrait window the figure goes on top and the text reads below it. */
:root {
  color-scheme: dark;
  --void: #000000;
  --starlight: #d9d4c7;
  --dust: #858074;
  --sun-a: #a9c4ff;
  --sun-b: #e6ad45;
  --sun-c: #cf4a2e;
  --planet: #8db9d0;
  --gutter: clamp(1.25rem, 5vw, 5rem);
  /* Stacked layout: the figure takes the height the text leaves, between these two bounds. */
  --figure-min: max(18rem, 42vh);
  --figure-max: 62vh;
  --serif: "Old Standard TT", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}
/* Small-viewport units keep the figure from jumping when a phone's address bar hides. */
@supports (height: 1svh) {
  :root { --figure-min: max(18rem, 42svh); --figure-max: 62svh; }
}

* { box-sizing: border-box; }
::selection { background: var(--starlight); color: var(--void); }
html {
  background: var(--void);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--void);
  color: var(--starlight);
  font-family: var(--serif);
  /* Beside the figure, type follows the height of the window, so as much of the text as
     possible fits one screen on a laptop and it grows on a large monitor. */
  font-size: clamp(0.9375rem, 0.45rem + 1.15vh, 1.25rem);
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.figure {
  position: fixed;
  inset: 0;
  /* The figure fades out before it reaches the text. The script measures where the text ends. */
  -webkit-mask-image: linear-gradient(to right, transparent 0, transparent calc(var(--text-edge, 30vw) * 0.5), #000 calc(var(--text-edge, 30vw) + 5vw));
  mask-image: linear-gradient(to right, transparent 0, transparent calc(var(--text-edge, 30vw) * 0.5), #000 calc(var(--text-edge, 30vw) + 5vw));
}
#sim {
  /* Fills the figure's box without giving it a size of its own. */
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  /* Sideways drags turn the figure; up-and-down swipes still scroll the page on a phone. */
  touch-action: pan-y pinch-zoom;
}

.page {
  position: relative;
  pointer-events: none; /* drags on the empty parts of the column reach the figure */
  min-height: 100vh;
  min-height: 100svh;
  /* Wide enough to keep the text short, never more than about half of a narrow window. */
  max-width: calc(min(34em, 52vw) + max(var(--gutter), env(safe-area-inset-left, 0px)));
  padding-block: clamp(1.25rem, 5vh, 2.5rem) clamp(1rem, 4.5vh, 4.5rem);
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: 0;
  /* Short text sits at the bottom of the screen. Long text starts at the top and scrolls. */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.page > * { pointer-events: auto; }

h1 {
  margin: 0;
  font-weight: 400;
  font-style: italic;
  font-size: clamp(2rem, min(6vw, 10vh), 7rem);
  line-height: 1;
  letter-spacing: -0.015em;
}

.about { margin: clamp(0.75rem, 2.5vh, 1.5rem) 0 0; }
.about p { margin: 0; text-wrap: pretty; }
.about p + p { margin-top: 0.55em; }

/* Each era is marked with the colour of one of the three suns in the figure. */
.era::before {
  content: "";
  display: inline-block;
  width: 0.4em;
  height: 0.4em;
  margin-right: 0.55em;
  border-radius: 50%;
  vertical-align: 0.14em;
  background: var(--sun);
}
.era-a { --sun: var(--sun-a); }
.era-b { --sun: var(--sun-b); }
.era-c { --sun: var(--sun-c); }

.reach {
  margin: clamp(0.75rem, 3vh, 1.75rem) 0 0;
  padding: 0;
  list-style: none;
  font-style: italic;
  color: var(--dust);
}
.reach li + li { margin-top: 0.1rem; }

a {
  color: var(--starlight);
  text-decoration: underline;
  text-decoration-color: var(--dust);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 140ms ease-out, color 140ms ease-out;
}
a:hover { color: #fff; text-decoration-color: currentColor; }
a:focus-visible {
  outline: 1px solid var(--planet);
  outline-offset: 4px;
  border-radius: 1px;
}

.is-dragging, .is-dragging * {
  cursor: grabbing !important;
  -webkit-user-select: none;
  user-select: none;
}

/* A phone on its side: a wider column and tighter lines, so less of the text is below the fold. */
@media (orientation: landscape) and (max-height: 30rem) {
  body { line-height: 1.5; }
  .page { max-width: calc(min(36em, 58vw) + max(var(--gutter), env(safe-area-inset-left, 0px))); }
}

/* Stacked layout, for portrait windows and very narrow ones. The figure and the text share
   the height of the screen: the figure takes what the text leaves, within its two bounds,
   and anything left over sits between them so the text stays at the bottom. */
@media (orientation: portrait), (max-width: 30rem) {
  body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: clamp(1rem, 0.9rem + 0.8vw, 1.25rem);
    line-height: 1.6;
  }
  .figure {
    position: relative;
    inset: auto;
    flex: 1 1 auto;
    min-height: var(--figure-min);
    max-height: var(--figure-max);
    -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent);
    mask-image: linear-gradient(to bottom, #000 78%, transparent);
  }
  .page {
    flex: none;
    display: block;
    min-height: 0;
    max-width: none;
    padding-block: 0.25rem 2.5rem;
    padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  }
  h1 { font-size: clamp(2.5rem, 12vw, 5.25rem); }
  .about { margin-top: 1.25rem; max-width: 32em; }
  .reach { margin-top: 1.5rem; }
}

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