@font-face {
  font-family: 'Inter';
  src: url('/inter.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* A soft, slightly chunky serif: it reads like a book and looks cut from the same card as the park.
   Trimmed to the softness and weights the headings use (see README). */
@font-face {
  font-family: 'Fraunces';
  src: url('/fraunces.woff2') format('woff2');
  font-weight: 600 700;
  font-display: swap;
}

/* Local fonts stretched to the real ones' size, so text doesn't re-wrap when the real fonts arrive. */
@font-face {
  font-family: 'Inter fallback';
  src: local('Arial');
  size-adjust: 107.57%;
  ascent-override: 90.06%;
  descent-override: 22.42%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Fraunces fallback';
  src: local('Georgia');
  size-adjust: 111.08%;
  ascent-override: 88.05%;
  descent-override: 22.96%;
  line-gap-override: 0%;
}

:root {
  --forest: #0e2a1f;
  --green: #5aad81;
  --mint: #cfe8d2;
  --paper: #fbfcfa;
  --muted: #536559;
  --line: #e2eae4;
  --sky: #eef6ef;
  --card: #fbf6ea;
  --card-edge: #e4d9c0;
  --ink: #3f5146;
  --wood: #c99a66;
  --wood-ink: #3b2a18;
  color: var(--forest);
  background: var(--sky);
  font-family: 'Inter', 'Inter fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  background: var(--sky);
  transition: background-color 0.2s linear;
}

h1,
h2 {
  font-family: 'Fraunces', 'Fraunces fallback', Georgia, serif;
  letter-spacing: -0.015em;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 4.4vw, 56px);
  line-height: 1.05;
  font-weight: 650;
}

h2 {
  margin: 0 0 12px;
  font-size: clamp(28px, 3.4vw, 38px);
  line-height: 1.12;
  font-weight: 620;
}

.panel .lede {
  max-width: 34ch;
  margin: 18px 0 0;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.55;
}

.button {
  display: inline-flex;
  align-items: center;
  height: 46px;
  padding: 0 20px;
  border-radius: 8px;
  background: var(--forest);
  color: var(--paper);
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}

/* The scene fills the window behind the text and moves as the page scrolls. */
.stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Hidden inside a point at the loader, then revealed by a circle growing past the corners. */
  clip-path: circle(0 at 50% 50%);
  transition: clip-path 1.2s cubic-bezier(0.65, 0, 0.25, 1);
}

.story {
  position: relative;
}

.story .chapter:first-child .panel {
  transition:
    opacity 0.5s ease 0.35s,
    visibility 0s 0.35s;
}

/* The opening words arrive with the park. If it never opens, they still show up after a while,
   so the page stays readable without WebGL or the script. */
.stage:not(.ready) ~ .story .chapter:first-child .panel {
  opacity: 0;
  visibility: hidden;
  animation: show-anyway 0s 8s forwards;
}

@keyframes show-anyway {
  to {
    opacity: 1;
    visibility: visible;
  }
}

.chapter {
  display: flex;
  align-items: center;
  min-height: 100vh;
  padding-inline: max(20px, calc((100vw - 1120px) / 2));
}

.chapter.right {
  justify-content: flex-end;
}

/* Cards are card stock pinned into the diorama: grain, a thick bottom edge and a slight tilt. */
.panel {
  max-width: 420px;
  padding: 28px 30px 30px;
  border-radius: 6px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .18 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E"),
    var(--card);
  box-shadow:
    0 1px 0 var(--card-edge),
    0 3px 0 #d6c9ab,
    0 22px 34px -20px rgb(40 48 28 / 0.45);
  transform: rotate(-0.6deg);
}

.chapter.right .panel {
  transform: rotate(0.6deg);
}

/* The opening card gets more room around its headline than the rest. */
#start .panel {
  max-width: 460px;
  padding: 40px 44px 42px;
}

.panel p {
  margin: 0;
  color: var(--ink);
}

/* Same wood and ink as the signposts in the park. */
.kicker {
  display: inline-block;
  margin-bottom: 14px;
  padding: 2px 10px;
  border-radius: 3px;
  background: var(--wood);
  color: var(--wood-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  box-shadow: 0 2px 0 #9c7448;
  transform: rotate(-1.5deg);
}

@media (max-width: 860px) {
  .chapter,
  .chapter.right {
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 40px;
  }
}

/* The same dark board and chalk as the self-hosting chalkboard in the park. */
.command {
  position: relative;
  margin-top: 14px;
  border-radius: 6px;
  background: #2c3a33;
  color: #eef3ef;
}

.command code {
  display: block;
  padding: 10px 48px 10px 12px;
  font: 500 13px/1.5 ui-monospace, 'SF Mono', Menlo, monospace;
  overflow-wrap: anywhere;
  user-select: all;
}

.copy {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: rgb(255 255 255 / 0.08);
  color: #eef3ef;
  cursor: pointer;
}

.copy:hover {
  background: rgb(255 255 255 / 0.16);
}

.copy:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.copy svg,
.dock-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy .tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--forest);
  color: var(--paper);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  pointer-events: none;
}

.copy .tooltip:empty {
  display: none;
}

/* Back to the start and the list of every card, pinned to the top corner like two buttons on a board. */
.dock {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: flex;
  gap: 8px;
}

.dock[hidden] {
  display: none;
}

.dock-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--forest);
  box-shadow:
    0 2px 0 #d6c9ab,
    0 10px 18px -10px rgb(40 48 28 / 0.5);
  cursor: pointer;
  transition:
    opacity 0.25s ease,
    visibility 0.25s;
}

.dock-button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.dock .back:not(.shown) {
  opacity: 0;
  visibility: hidden;
}

/* Every card in one list, to read at once or jump to. */
.contents {
  inset: 70px 16px auto auto;
  width: min(400px, calc(100vw - 32px));
  max-height: calc(100vh - 86px);
  max-height: calc(100svh - 86px);
  margin: 0;
  overflow-y: auto;
  border: 0;
  color: var(--forest);
  transform: none;
}

.contents::backdrop {
  background: rgb(14 42 31 / 0.12);
}

.contents h2 {
  font-size: 24px;
}

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

.contents a {
  display: block;
  margin: 0 -12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}

.contents a:hover,
.contents a:focus-visible {
  background: rgb(201 154 102 / 0.16);
  outline: none;
}

.contents .label {
  display: block;
  color: #8a6a44;
  font-size: 12px;
  font-weight: 600;
}

.contents .label:empty {
  display: none;
}

.contents strong {
  display: block;
  font-family: 'Fraunces', 'Fraunces fallback', Georgia, serif;
  font-size: 18px;
  font-weight: 620;
  line-height: 1.3;
}

.contents .text {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.download {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 22px;
}

.download .platform {
  color: var(--muted);
  font-size: 14px;
}

.download .button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.notify {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.notify input {
  flex: 1 1 200px;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--card-edge);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--forest);
  font: inherit;
}

.notify input:focus-visible,
.notify .button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.notify .button {
  border: 0;
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

.notify .button:disabled {
  opacity: 0.6;
}

.panel .notify-status {
  flex-basis: 100%;
  margin: 0;
  font-size: 14px;
}

.panel .notify-status:empty {
  display: none;
}

.captcha:empty {
  display: none;
}

.captcha {
  flex-basis: 100%;
}

.stage.ready {
  clip-path: circle(75vmax at 50% 50%);
}

/* The dino waits at the centre with a ping, and the park opens out of that same spot. */
.park-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  transform: translate(-50%, -50%);
  transition:
    opacity 0.5s ease,
    transform 0.5s ease,
    visibility 0.5s;
}

.park-loading::before,
.park-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--mint);
  animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.park-loading::after {
  animation-delay: 1s;
}

.park-loading img {
  position: relative;
  width: 72px;
  height: 72px;
  animation: breathe 2s ease-in-out infinite;
}

.stage.ready ~ .park-loading {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -50%) scale(0.6);
}

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

@keyframes ping {
  from {
    transform: scale(0.7);
    opacity: 0.9;
  }
  to {
    transform: scale(2.6);
    opacity: 0;
  }
}

@keyframes breathe {
  50% {
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage,
  .park-loading,
  .story .chapter:first-child .panel,
  .dock-button {
    transition: none;
  }

  .park-loading::before,
  .park-loading::after,
  .park-loading img {
    animation: none;
  }
}

/* Phones: the card sits under the scene, so it stays compact and leaves the top for the park. */
@media (max-width: 600px) {
  .chapter,
  .chapter.right {
    min-height: 100svh;
    padding-inline: 14px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .panel,
  #start .panel {
    padding: 18px 20px 20px;
  }

  h1 {
    font-size: 34px;
  }

  .dock {
    top: 12px;
    right: 12px;
  }

  .dock-button {
    width: 38px;
    height: 38px;
  }

  .contents {
    inset: 60px 12px auto auto;
    width: calc(100vw - 24px);
    max-height: calc(100svh - 72px);
  }

  h2 {
    margin-bottom: 8px;
    font-size: 26px;
  }

  .kicker {
    margin-bottom: 10px;
    font-size: 12px;
  }

  .panel p,
  .panel .lede {
    font-size: 15px;
    line-height: 1.5;
  }

  .panel .lede {
    margin-top: 10px;
  }

  .download {
    margin-top: 14px;
  }

  .command {
    margin-top: 10px;
  }

  .command code {
    font-size: 11.5px;
  }

  .download .button {
    height: 42px;
    padding: 0 16px;
  }

  .download .platform {
    font-size: 13px;
  }

  .notify {
    margin-top: 14px;
  }

  .notify input {
    flex-basis: 120px;
    height: 42px;
  }

  .notify .button {
    height: 42px;
    padding: 0 16px;
  }
}
