/* Nyhem Studios. One typeface, one photograph, one moment of light. */

@font-face {
  font-family: "Jost";
  src: url("/fonts/jost-latin-var.woff2") format("woff2");
  font-weight: 300 500;
  font-style: normal;
  /* The font is preloaded and small: wait for it rather than flash a stand-in. */
  font-display: block;
}

:root {
  --night: #0e1a15;
  --spruce: #18271f;
  --mist: #e6ebe7;
  --lichen: #a9b5ae;
  --first-light: #e8b964;

  --gutter: clamp(1.5rem, 6vw, 5.5rem);
  --measure: 34rem;

  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--night);
  color: var(--mist);
  font-family: "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
  font-weight: 300;
  font-size: 1.0625rem;
  line-height: 1.6;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--first-light);
  color: var(--night);
}

/* The forest stays put behind every page. */
.forest {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 41% 35%;
}

.shade {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 42% at 50% 47%, rgb(14 26 21 / 0.5), rgb(14 26 21 / 0) 72%),
    linear-gradient(to bottom, rgb(14 26 21 / 0.42), rgb(14 26 21 / 0.12) 38%, rgb(14 26 21 / 0.3) 70%, rgb(14 26 21 / 0.86));
}

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

/* No underlines anywhere. Links show themselves by colour and turn to first light. */
a {
  color: inherit;
  text-decoration: none;
  transition: color 160ms ease;
}

a:hover {
  color: var(--first-light);
}

:focus-visible {
  outline: 2px solid var(--first-light);
  outline-offset: 5px;
  border-radius: 2px;
}

.frame {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  padding:
    max(1.75rem, env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(1.75rem, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
}

/* Navigation: three quiet words, the same on every page. */
.site-foot {
  margin-top: auto;
  padding-top: 3rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem clamp(1.5rem, 4vw, 2.75rem);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.015em;
}

.site-nav a {
  color: var(--lichen);
  padding-block: 0.35rem;
}

.site-nav a[aria-current="page"] {
  color: var(--mist);
}

.site-nav a:hover {
  color: var(--first-light);
}

/* Front page: the mark in a clearing. */
.clearing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 2rem;
}

.wordmark {
  margin: 0;
  line-height: 0;
  color: var(--mist);
}

.wordmark svg {
  display: block;
  width: clamp(13.5rem, 27vw, 21rem);
  height: auto;
  filter: drop-shadow(0 1px 18px rgb(14 26 21 / 0.45));
}

.tagline {
  margin: 1.6rem 0 0;
  font-size: clamp(1rem, 0.94rem + 0.3vw, 1.1875rem);
  letter-spacing: 0.04em;
  color: var(--mist);
  text-shadow: 0 1px 14px rgb(14 26 21 / 0.6);
}

.tagline a {
  color: var(--first-light);
}

.tagline a:hover {
  color: var(--mist);
}

.page-home .site-nav,
.page-missing .site-nav {
  justify-content: center;
}

/* The one moment: first light over the forest on the front page. The night
   lifts, the forest settles, the mark comes into focus out of the mist, then
   the words. first-light.js holds all of it at night until the photograph and
   the typeface are ready, and skips it on later pages of the same visit. */
.page-home .shade::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--night);
  opacity: 0;
  animation: first-light 2800ms cubic-bezier(0.3, 0, 0.2, 1) backwards;
}

.page-home .forest {
  animation: settle 7000ms cubic-bezier(0.2, 0, 0, 1) backwards;
}

.page-home .wordmark {
  animation: focus 1700ms cubic-bezier(0.2, 0, 0, 1) 500ms backwards;
}

.page-home .tagline,
.page-home .site-foot {
  animation: surface 1300ms cubic-bezier(0.2, 0, 0, 1) backwards;
}

.page-home .tagline { animation-delay: 1400ms; }
.page-home .site-foot { animation-delay: 1900ms; }

@keyframes first-light {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes settle {
  from { transform: scale(1.06); }
  to { transform: none; }
}

@keyframes focus {
  from { opacity: 0; filter: blur(10px); }
  to { opacity: 1; filter: blur(0); }
}

@keyframes surface {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Waiting for the photograph and the type: everything holds at night. */
.is-waiting .page-home .shade::after,
.is-waiting .page-home .forest,
.is-waiting .page-home .wordmark,
.is-waiting .page-home .tagline,
.is-waiting .page-home .site-foot {
  animation-play-state: paused;
}

/* A first visit that starts on an inner page: the forest fades in whole, never in stripes. */
.forest {
  transition: opacity 1200ms ease;
}

.is-waiting .forest {
  opacity: 0;
}

/* Later pages of the same visit show at once. */
.is-return .page-home .shade::after,
.is-return .page-home .forest,
.is-return .page-home .wordmark,
.is-return .page-home .tagline,
.is-return .page-home .site-foot {
  animation: none;
}

/* Inner pages: the forest steps back so the words can be read. */
.page-projects .shade,
.page-about .shade,
.page-contact .shade {
  background:
    linear-gradient(to right, rgb(14 26 21 / 0.94), rgb(14 26 21 / 0.82) 42%, rgb(14 26 21 / 0.5) 75%, rgb(14 26 21 / 0.38)),
    linear-gradient(to bottom, rgb(14 26 21 / 0.2), rgb(14 26 21 / 0.55));
}

.site-head {
  line-height: 0;
}

.mark {
  display: inline-block;
  color: var(--mist);
}

.mark svg {
  display: block;
  width: 9.25rem;
  height: auto;
}

.mark:hover {
  color: var(--first-light);
}

.sheet {
  width: 100%;
  max-width: var(--measure);
  padding-top: clamp(4rem, 16vh, 10rem);
}

.sheet h1 {
  margin: 0 0 2rem;
  font-weight: 300;
  font-size: clamp(2.25rem, 1.6rem + 2.4vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.sheet p {
  margin: 0 0 1.15rem;
  color: var(--lichen);
}

.sheet .lede {
  font-size: clamp(1.1875rem, 1.1rem + 0.45vw, 1.375rem);
  line-height: 1.5;
  color: var(--mist);
  margin-bottom: 1.5rem;
}

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

.projects li + li {
  margin-top: 2.5rem;
}

.projects h2 {
  margin: 0 0 0.35rem;
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: 0.005em;
}

.projects h2 a {
  color: var(--mist);
}

.projects h2 a:hover {
  color: var(--first-light);
}

.projects p {
  margin-bottom: 0.3rem;
}

.projects .host {
  font-size: 0.9375rem;
  color: rgb(169 181 174 / 0.75);
}

.email {
  margin-top: 2rem;
  font-size: clamp(1.3125rem, 1.15rem + 0.8vw, 1.75rem);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.sheet .email a {
  color: var(--mist);
}

.sheet .email a:hover {
  color: var(--first-light);
}

.sheet .quiet {
  font-size: 0.9375rem;
  margin-top: 1.25rem;
}

@media (max-width: 40rem) {
  .page-projects .shade,
  .page-about .shade,
  .page-contact .shade {
    background: linear-gradient(to bottom, rgb(14 26 21 / 0.86), rgb(14 26 21 / 0.9));
  }

  .site-nav {
    gap: 0.25rem 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .wordmark svg,
  .mark svg {
    filter: none;
  }
}
