/* Labrarium — terrarium intro. A dark room; the globe holds its own daylight. */

@font-face {
  font-family: "Libre Caslon Display";
  src: url("../fonts/libre-caslon-display-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+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Libre Caslon Display";
  src: url("../fonts/libre-caslon-display-latin-ext-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Libre Caslon Text";
  src: url("../fonts/libre-caslon-text-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+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Libre Caslon Text";
  src: url("../fonts/libre-caslon-text-latin-ext-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Libre Caslon Text";
  src: url("../fonts/libre-caslon-text-latin-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Libre Caslon Text";
  src: url("../fonts/libre-caslon-text-latin-ext-400-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Kalam";
  src: url("../fonts/kalam-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --night: #0a0e0d;
  --ivory: #efe7d3;
  --ivory-soft: rgba(239, 231, 211, 0.66);
  --brass: #c9a35b;
  --sky-ink: #12263a;      /* words written on the sky (home.css registers --ink as a length) */
  --ink-blue: #1f3a8a;     /* the notebook's blue, deepened to read on sky */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--night);
  color: var(--ivory);
  scrollbar-color: rgba(239, 231, 211, 0.22) transparent;
  scrollbar-width: thin;
}

body {
  margin: 0;
  background: var(--night);
  font-family: "Libre Caslon Text", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 4px;
  border-radius: 2px;
}

#world {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  opacity: 0;
  transition: opacity 1.6s var(--ease-out);
}
.ready #world { opacity: 1; }
.no-webgl #world { display: none; }

.headline {
  margin: 0;
  padding: 0 16px;
  font-family: "Libre Caslon Display", "Libre Caslon Text", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.4rem, min(6.1vw, 9.4vh), 5.6rem);
  line-height: 1.02;
  letter-spacing: -0.012em;
  text-align: center;
  text-wrap: balance;
  color: var(--ivory);
}
.headline__free {
  display: block;
  margin-top: 0.32em;
  font-family: "Libre Caslon Text", Georgia, serif;
  font-style: italic;
  font-size: clamp(1.2rem, min(2.1vw, 3.3vh), 1.9rem);
  line-height: 1.15;
  letter-spacing: 0;
  color: var(--brass-bright, #e9c070);
}

.line {
  margin: 0 auto;
  max-width: 17ch;
  padding: 0 16px;
  font-family: "Libre Caslon Display", "Libre Caslon Text", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.1rem, 5vw, 4.7rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-align: center;
  text-wrap: balance;
  color: var(--sky-ink);
}
.line em {
  font-family: "Libre Caslon Text", Georgia, serif;
  font-style: italic;
  color: var(--ink-blue);
}
.line:first-child { max-width: 21ch; }
.line--hold { max-width: 14ch; }

/* With the scene running, the words sit over it. JS sets --o (0..1, how present a stop's
   words are) and --dir (1 coming in, -1 leaving); the rest of the motion is here. */
.js .headline,
.js .line,
.js .panel {
  --o: 0;
  --dir: 1;
  position: fixed;
  z-index: 2;
  opacity: var(--o);
  visibility: hidden;
}
.js .headline {
  --o: 1;
  visibility: visible;
  top: clamp(58px, 7.4vh, 100px);
  left: 0; right: 0;
  transform: translateY(calc((1 - var(--o)) * -40px));
}
.js .line {
  top: 47%;
  left: 0; right: 0;
  transform: translateY(calc(-50% + (1 - var(--o)) * var(--dir) * 18px));
  filter: blur(calc((1 - var(--o)) * 7px));
}

/* the sea and forest words */
.panel {
  max-width: 30rem;
  margin: 0;
  padding: 0 16px;
}
.panel h2 {
  margin: 0 0 0.45em;
  font-family: "Libre Caslon Display", "Libre Caslon Text", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.panel p {
  margin: 0;
  font-size: clamp(1.02rem, 1.3vw, 1.22rem);
  line-height: 1.55;
  max-width: 34ch;
  text-wrap: pretty;
}
.js .panel {
  left: clamp(16px, 7vw, 120px);
  top: 50%;
  color: var(--ivory);
  transform: translateY(calc(-50% + (1 - var(--o)) * var(--dir) * 22px));
  filter: blur(calc((1 - var(--o)) * 6px));
}
.panel p { color: rgba(239, 231, 211, 0.86); }
.js .panel--intro {
  left: 0; right: 0;
  top: 22%;
  max-width: none;
  text-align: center;
}
.panel--intro p { margin: 0 auto; }
.panel--intro::before {
  content: ""; position: absolute; inset: -30% 18% -40%; z-index: -1;
  background: radial-gradient(closest-side, rgba(4, 30, 42, 0.55), rgba(4, 30, 42, 0));
}
.panel--intro h2 { font-size: clamp(2.6rem, 5.4vw, 5rem); }
/* by the lab's tree the words sit on the left over a soft shade, the tree to their right */
.forest-shade {
  position: fixed; inset: 0 auto 0 0; width: min(60vw, 740px); z-index: 1; pointer-events: none;
  background: linear-gradient(to right, rgba(10, 14, 13, 0.6), rgba(10, 14, 13, 0.32) 55%, rgba(10, 14, 13, 0));
  opacity: 0; transition: opacity 0.9s var(--ease-out);
}
.in-forest .forest-shade { opacity: 1; }
.sea-shade {
  position: fixed; inset: 0 auto 0 0; width: min(62vw, 760px); z-index: 1; pointer-events: none; opacity: 0;
  background: linear-gradient(to right, rgba(4, 30, 42, 0.68), rgba(4, 30, 42, 0.38) 55%, rgba(4, 30, 42, 0));
}
@media (max-aspect-ratio: 1/1) {
  .sea-shade { inset: 0 0 auto 0; width: auto; height: 66vh; background: linear-gradient(to bottom, rgba(4, 30, 42, 0.82), rgba(4, 30, 42, 0.66) 55%, rgba(4, 30, 42, 0)); }
  .forest-shade { inset: 0 0 auto 0; width: auto; height: 62vh; background: linear-gradient(to bottom, rgba(10, 14, 13, 0.72), rgba(10, 14, 13, 0.5) 55%, rgba(10, 14, 13, 0)); }
}

/* under water: a darker rim round the view, and a flash where the camera breaks the surface */
.veil {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(120% 90% at 50% 40%, rgba(6, 40, 52, 0) 45%, rgba(4, 26, 36, 0.55) 100%);
}
.splash {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(90% 70% at 50% 45%, rgba(235, 252, 255, 0.9), rgba(140, 214, 230, 0.55) 60%, rgba(60, 150, 175, 0.3));
}

/* The page itself does not scroll; gestures step through the story. */
html.js, .js body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.no-webgl, .no-webgl body { height: auto; overflow: auto; }

.cue {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 4;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ivory-soft);
  margin: 0;
  padding: 8px 14px;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.6s var(--ease-out);
}
.cue:hover { color: var(--ivory); }
.cue:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }
.cue i {
  display: block;
  width: 1px;
  height: 28px;
  background: linear-gradient(currentColor, transparent);
  transform-origin: top;
  animation: cue 2.4s var(--ease-out) infinite;
}
/* behind the canvas, so the sky lines stay readable even before the scene has drawn */
html.in-sky, .in-sky body { background: #a9cfe9; }
html.in-sea, .in-sea body { background: #0d5670; }
.in-sky .cue { color: rgba(18, 38, 58, 0.62); }
.in-sky .cue:hover { color: var(--sky-ink); }
@keyframes cue {
  0% { transform: scaleY(0); opacity: 1; }
  60% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

/* skipping the story: plain paper covers it, and clears once the notebook's page is in place */
.cut {
  position: fixed; inset: 0; z-index: 6; pointer-events: none;
  background: #f7f1e3;
  opacity: 0; visibility: hidden;
  transition: opacity 0.5s ease, visibility 0s linear 0.5s;
}
.cutting .cut { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.32s ease, visibility 0s; }

/* ---- the regular website: a page of the notebook -------------------------------------------- */
.site {
  --o: 0;
  --c: 0;
  --grid: 26px;
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
  visibility: hidden;
  opacity: var(--o);
  color: #16223f;
  background-color: #f7f1e3;
  /* the paper comes first (--o); its grid and the words are drawn in after it (--c) */
  background-image:
    linear-gradient(rgba(110, 150, 205, calc(0.2 * var(--c))) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110, 150, 205, calc(0.2 * var(--c))) 1px, transparent 1px);
  background-size: var(--grid) var(--grid);
  background-position: center top;
}
.js .site > .home { opacity: var(--c); }
.js .site .home__intro { transform: translateY(calc((1 - var(--c)) * 16px)); }
.no-webgl .site > .home { opacity: 1; }
.no-webgl .site { --c: 1; }
.on-site .site { pointer-events: auto; }
.site { pointer-events: none; }
.sheet {
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 64px) clamp(16px, 5vw, 64px) 30vh;
  transform: translateY(calc((1 - var(--o)) * 30px));
}
.sheet__head {
  display: flex;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(29, 47, 107, 0.55);
  font-size: 0.95rem;
  color: rgba(29, 47, 107, 0.75);
}
.sheet__title {
  margin: clamp(48px, 10vh, 120px) 0 0.3em;
  font-family: "Libre Caslon Display", "Libre Caslon Text", Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.012em;
  color: #16223f;
}
.sheet__lede {
  max-width: 38ch;
  margin: 0;
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  line-height: 1.55;
}
.sheet__note {
  margin-top: 3em;
  font-family: "Kalam", cursive;
  font-size: 1.3rem;
  color: #2f4aa8;
}
.site ::selection { background: #2f4aa8; color: #f7f1e3; }

/* No WebGL (or no JavaScript): the story reads as plain text on the dark ground. */
.no-webgl .headline, .no-webgl .line, .no-webgl .panel { position: static; opacity: 1; visibility: visible; transform: none; filter: none; }
.no-webgl .story, .no-webgl .sea-story, .no-webgl .forest-story { padding: 12vh 16px 0; display: grid; gap: 8vh; }
.no-webgl .headline { padding-top: calc(var(--bar) + 5vh); }   /* clear of the top bar */
.no-webgl .panel--intro::before { display: none; }
.no-webgl .line { color: var(--ivory); }
.no-webgl .line em { color: var(--brass); }
.no-webgl .cue, .no-webgl .veil, .no-webgl .splash { display: none; }
.no-webgl .site { position: static; visibility: visible; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .cue i { animation: none; transform: none; }
  #world { transition: none; }
  .js .line, .js .panel { filter: none; }
}

@media (max-aspect-ratio: 1/1) {
  .js .line { top: 31%; }
  .js .panel { top: 15%; left: 0; right: 0; transform: translateY(calc((1 - var(--o)) * var(--dir) * 22px)); }
  .panel { max-width: none; }
}

@media (max-width: 640px) {
  .js .headline { top: 64px; }
}
