/* Same winter night as stianmelhus.no: the painted night landscape, Cormorant Garamond and Albert Sans,
   brass and candle light. The whole page stays dark, because it is read aloud in a dim room at bedtime. */

@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-display: block;
}
@font-face {
  font-family: "Albert Sans";
  src: url("fonts/albert-sans-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: block;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: block;
}

:root {
  --sky: #0a162d;
  --night-2: #14254a;
  --snow: #f1f4f8;
  --soft: #dfe5ef;
  --dim: #9aa6bf;
  --brass: #c79a3c;
  --flame: #ffd98c;
  --line: #2b3d66;
  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --text: "Albert Sans", "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--sky); }
body { margin: 0; background: var(--sky); color: var(--snow); font: 400 1.125rem/1.6 var(--text); overflow-wrap: break-word; }
h1, h2, p, ol, ul, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: var(--flame); font-weight: 600; text-underline-offset: 0.2em; }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 3px; }
.w {
  max-width: 64rem; margin: 0 auto;
  padding-left: max(clamp(16px, 4vw, 64px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(16px, 4vw, 64px), env(safe-area-inset-right, 0px));
}
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 5; background: var(--flame); color: var(--sky); padding: 0.6rem 1rem; }
.skip:focus { top: 0.5rem; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.name { font: 700 1.0625rem/1 var(--text); letter-spacing: 0.02em; }
.name a { color: inherit; text-decoration: none; display: inline-block; padding-block: 0.75rem; }
.name a:hover { text-decoration: underline; }

/* Painted landscape, anchored to the bottom edge and sized by width, fading into the flat sky colour. */
.scene { position: relative; isolation: isolate; overflow: hidden; --iw: max(100vw, 60rem); }
.scene::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; z-index: -1;
  height: calc(var(--iw) * 0.4286);
  background: url("img/topp.webp") 72% 100% / var(--iw) auto no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 62%, transparent 97%);
  mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 62%, transparent 97%);
}
.hero .w { padding-block: 0.5rem calc(var(--iw) * 0.4286 * 0.32 + 1.5rem); }
h1 { font: 600 clamp(2.75rem, 9vw, 5.5rem)/0.98 var(--display); letter-spacing: -0.01em; text-wrap: balance; }
.hero h1 { margin-top: clamp(1rem, 4vh, 3rem); max-width: 12ch; }
.lede { margin-top: 1.25rem; max-width: 34rem; font-size: 1.1875rem; color: var(--soft); }

/* The doors. An open door is lit from inside, a locked one is dark until its day. */
/* Today's chapter on the front page, set as a page from a book: a sheet lit by a lamp, lifted a little
   onto the snow. On a phone the sheet has no frame, so the text gets the whole width. */
.latest { padding-block: 0.5rem 1.5rem; }
.sheet { max-width: 46rem; margin-inline: auto; }
.next { margin-top: 1.25rem; text-align: center; color: var(--dim); font-size: 1rem; }
@media (min-width: 44rem) {
  .latest { margin-top: -3.5rem; position: relative; }
  .sheet {
    padding: 3.25rem 4rem 3rem; border: 1px solid var(--line); border-top-color: var(--brass); border-radius: 3px;
    background: linear-gradient(to bottom, #14254a, #0e1c3a 22rem);
    box-shadow: 0 0 7rem rgba(255, 217, 140, 0.1), 0 1.5rem 3rem rgba(4, 9, 20, 0.5);
  }
}
.doors { padding-block: 2.5rem 4rem; }
.doors h2 { font: 600 2.25rem/1.1 var(--display); }
.doors ol { margin-top: 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.75rem; }
.door {
  display: flex; flex-direction: column; justify-content: space-between; gap: 0.5rem;
  min-height: 7.5rem; height: 100%; padding: 0.6rem 0.75rem 0.75rem;
  border: 1px solid var(--line); border-radius: 3px; text-decoration: none; color: var(--dim);
}
.door .nr { font: 600 2.75rem/1 var(--display); font-variant-numeric: lining-nums; }
.door .t { font: 500 0.875rem/1.3 var(--text); }
.door.open { border-color: var(--brass); background: var(--night-2); color: var(--snow); box-shadow: 0 0 1.75rem rgba(255, 217, 140, 0.14); }
.door.open .nr { color: var(--flame); }
.door.today { border-width: 2px; border-color: var(--flame); }
.door:hover { border-color: var(--flame); }

/* A chapter, set for reading aloud from a phone held at arm's length. */
.bar { border-bottom: 1px solid var(--line); }
.bar .w { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 1.5rem; padding-block: 0.25rem; }
.bar > .w > a { font-size: 0.9375rem; color: var(--soft); padding-block: 0.75rem; }
.chapter, .denied { max-width: 44rem; padding-block: clamp(2rem, 6vw, 4rem) 3rem; }
.story { max-width: 42rem; margin-inline: auto; }
.story h1, .story h2, .denied h1 { font: 600 clamp(2.5rem, 8vw, 4.25rem)/0.98 var(--display); letter-spacing: -0.01em; text-wrap: balance; }
.date { margin-top: 1rem; display: flex; align-items: center; gap: 1rem; color: var(--flame); font: 500 1.375rem/1 var(--display); font-variant-numeric: lining-nums; }
.date::after { content: ""; flex: 1; height: 1px; background: linear-gradient(to right, var(--brass), transparent); }
.story figure { margin-top: 2rem; }
.story img { display: block; width: 100%; height: auto; border-radius: 3px; }
.story > p:not(.date) { margin-top: 1.15em; font-size: 1.25rem; line-height: 1.65; color: var(--soft); overflow-wrap: anywhere; }
.story > .date + p, .story figure + p { margin-top: 2rem; }
/* Storybook opening: a large first letter in candle colour. */
.story > .date + p::first-letter, .story figure + p::first-letter {
  float: left; font: 600 3.3em/0.86 var(--display); color: var(--flame); padding: 0.04em 0.07em 0 0;
}
.story::after { content: ""; display: block; width: 4.5rem; height: 1px; margin: 2.75rem auto 0; background: var(--brass); }
.chapter nav { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.chapter nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 2rem; }
.chapter nav a { display: inline-block; padding-block: 0.6rem; }
.denied p { margin-top: 1.25rem; max-width: 34rem; }
.denied p > a:only-child { display: inline-block; padding-block: 0.5rem; }
.denied .remus { font: 500 1.0625rem/1.5 var(--mono); color: var(--flame); border-left: 2px solid var(--brass); padding-left: 1rem; }

.foot { border-top: 1px solid var(--line); }
.foot .w { padding-block: 1.5rem 2.5rem; font-size: 1rem; color: var(--soft); }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print {
  html, body { background: #fff; color: #000; }
  .bar, .foot, .chapter nav, .skip { display: none; }
  .story > p:not(.date) { color: #000; }
}
