/* Herbarium homepage. Colours, type and motion come from the app itself (src/app.css):
   Newsreader for reading, Geist for the interface, one green for leaves. */

@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-latin-opsz-normal.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-latin-wght-italic.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("fonts/geist-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #2f3437;
  --soft: #50555a;
  --muted: #6b6a68;
  --rule: #eaeaea;
  --rule-strong: #d9d8d3;
  --fill: #111111;
  --fill-hover: #333333;
  --on-fill: #ffffff;

  --leaf: #346538;
  --sage: #3f6b43;
  --sage-soft: #e7efe5;
  --teal: #1f6e67;
  --teal-soft: #ddefec;
  --rose: #9c3f55;
  --rose-soft: #f7e5ea;
  --amber: #8a5b00;
  --amber-soft: #f6ecd6;
  --clay-soft: #f4e6dd;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: 4.5rem;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --surface: #202020;
    --text: #e6e5e3;
    --soft: #c4c3c0;
    --muted: #9b9a97;
    --rule: #2c2c2b;
    --rule-strong: #3e3e3c;
    --fill: #ededec;
    --fill-hover: #d6d5d2;
    --on-fill: #111111;

    --leaf: #8cbf91;
    --sage: #9cc79f;
    --sage-soft: #24302a;
    --teal: #86cfc6;
    --teal-soft: #1c302e;
    --rose: #e7a0b1;
    --rose-soft: #35232a;
    --amber: #e3bd6e;
    --amber-soft: #33291a;
    --clay-soft: #33261f;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.58;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: var(--sage-soft);
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--rule-strong);
  transition: text-decoration-color 140ms ease;
}
a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--leaf);
  outline-offset: 3px;
  border-radius: 2px;
}

h1,
h2 {
  margin: 0;
  font-weight: 400;
  text-wrap: balance;
}
p {
  margin: 0;
}
p + p {
  margin-top: 1.1em;
}
em {
  font-style: italic;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.8em;
}
kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0 0.375rem;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  line-height: 1.5;
  text-align: center;
  vertical-align: 0.08em;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  padding: 0.5rem 0.75rem;
  background: var(--fill);
  color: var(--on-fill);
  font: 500 0.875rem var(--sans);
  text-decoration: none;
  border-radius: 6px;
}
.skip:focus {
  top: 1rem;
}

.frame {
  max-width: 76rem;
  margin-inline: auto;
  padding-inline: 2rem;
}

/* ---------------------------------------------------------------- masthead */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}
.masthead a {
  text-decoration: none;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}
.wordmark img {
  display: block;
  border-radius: 6px;
}
.masthead nav {
  display: flex;
  gap: 1.75rem;
  color: var(--muted);
}
.masthead nav a {
  transition: color 140ms ease;
}
.masthead nav a:hover {
  color: var(--text);
}

/* ---------------------------------------------------------------- the sheet: text on the left, the specimen beside it */

.sheet {
  display: grid;
  grid-template-columns: minmax(0, 40rem) minmax(15rem, 1fr);
  column-gap: 4rem;
}
.path {
  grid-column: 1;
  min-width: 0;
  padding-left: var(--gutter);
}

.leaf-page {
  padding-top: clamp(6rem, 16vh, 10rem);
}
.leaf-page.first {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100svh - 5rem);
  padding: 2rem 0 7rem;
}

h1 {
  margin-left: -0.04em;
  font-size: clamp(2.5rem, 1.55rem + 3.3vw, 4rem);
  line-height: 1.03;
  letter-spacing: -0.024em;
}
.lede {
  margin-top: 1.75rem;
  color: var(--soft);
  font-size: 1.3125rem;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2.25rem;
  font-family: var(--sans);
  font-size: 0.9375rem;
}
.button {
  display: inline-flex;
  align-items: center;
  height: 2.75rem;
  padding: 0 1.25rem;
  border-radius: 6px;
  background: var(--fill);
  color: var(--on-fill);
  font-weight: 500;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    transform 140ms var(--ease-out);
}
.button:hover {
  background: var(--fill-hover);
}
.button:active {
  transform: scale(0.98);
}

.aside-note {
  margin-top: 1.25rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.6;
}

h2 {
  position: relative;
  margin-bottom: 1.5rem;
  scroll-margin-top: 4rem;
  font-size: clamp(1.75rem, 1.45rem + 1.1vw, 2.25rem);
  line-height: 1.12;
  letter-spacing: -0.016em;
}
/* The page number, written the way the app counts a path: read/total. */
.folio {
  position: absolute;
  right: 100%;
  bottom: 0.5em;
  width: var(--gutter);
  color: var(--muted);
  font: 400 0.75rem var(--mono);
  letter-spacing: 0;
}

/* ---------------------------------------------------------------- page 3: a ledger, not cards */

.ledger {
  margin: 2.25rem 0 0;
  border-bottom: 1px solid var(--rule);
}
.ledger div {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  padding: 1.125rem 0 1.25rem;
  border-top: 1px solid var(--rule);
}
.ledger dt {
  padding-top: 0.32rem;
  font: 500 0.875rem var(--sans);
}
.ledger dd {
  margin: 0;
  color: var(--soft);
}

/* ---------------------------------------------------------------- page 4: the four grades */

.grades {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.75rem;
  margin: 1.75rem 0;
  padding: 0;
  list-style: none;
  color: var(--soft);
  font-family: var(--sans);
  font-size: 0.9375rem;
}
.grades kbd {
  margin-right: 0.375rem;
  font-size: 0.75rem;
}

/* ---------------------------------------------------------------- page 6: four views */

.views {
  margin-top: 2rem;
}
.view-tabs {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.view-tabs button {
  padding: 0.25rem 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 400 0.875rem var(--sans);
  cursor: pointer;
  box-shadow: inset 0 -1px 0 transparent;
  transition:
    color 140ms ease,
    box-shadow 140ms ease;
}
.view-tabs button:hover {
  color: var(--text);
}
.view-tabs button[aria-selected="true"] {
  color: var(--text);
  box-shadow: inset 0 -1px 0 currentColor;
}
.view {
  margin: 0 0 0 calc(var(--gutter) * -1);
}
.view img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
}
.view figcaption {
  margin: 0.875rem 0 0 var(--gutter);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.875rem;
}
.js .view:not([hidden]) {
  animation: view-in 220ms ease;
}
@keyframes view-in {
  from {
    opacity: 0;
  }
}
/* Without the script every view is shown, one under the other. */
html:not(.js) .view-tabs {
  display: none;
}
html:not(.js) .view[hidden] {
  display: block;
  margin-top: 2.5rem;
}

/* ---------------------------------------------------------------- page 7: install */

.command {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 0.25rem 0.375rem 0.25rem 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
}
.command code {
  flex: 1;
  min-width: 0;
  padding: 0.625rem 0;
  overflow-x: auto;
  font-size: 0.78125rem;
  white-space: nowrap;
  scrollbar-width: none;
}
.command code::-webkit-scrollbar {
  display: none;
}
.command button {
  flex: none;
  min-width: 4.25rem;
  height: 2rem;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--muted);
  font: 500 0.8125rem var(--sans);
  cursor: pointer;
  transition:
    color 140ms ease,
    background-color 140ms ease;
}
.command button:hover {
  background: var(--bg);
  color: var(--text);
}
.command button.copied {
  color: var(--leaf);
}
html:not(.js) .command button {
  display: none;
}
.leaf-page.last .aside-note {
  margin-bottom: 1.75rem;
}

/* ---------------------------------------------------------------- colophon: a specimen label */

.colophon {
  margin-top: clamp(6rem, 16vh, 10rem);
  padding-bottom: 5rem;
}
.label {
  max-width: 23rem;
  margin: 0;
  padding: 0.875rem 1rem 0.75rem;
  border: 1px solid var(--soft);
  font: 400 0.75rem/1.7 var(--mono);
}
.label div {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
}
.label dt {
  color: var(--muted);
}
.label dd {
  margin: 0;
}
.label .label-title {
  display: block;
  margin-bottom: 0.625rem;
  padding-bottom: 0.625rem;
  border-bottom: 1px solid var(--rule-strong);
  text-align: center;
}
.label .label-title dt {
  color: var(--text);
  font: 500 1.0625rem/1.3 var(--serif);
  font-variant-caps: all-small-caps;
  letter-spacing: 0.08em;
}
.label .label-title dd {
  font: italic 400 0.9375rem/1.4 var(--serif);
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: 2rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.875rem;
}
.links a {
  text-decoration: none;
  transition: color 140ms ease;
}
.links a:hover {
  color: var(--text);
}

/* ---------------------------------------------------------------- the specimen: one tree, grown by reading */

.specimen {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100svh;
  padding-bottom: 9svh;
  font-family: var(--sans);
  text-align: center;
}
.tree {
  display: block;
  width: auto;
  height: min(60svh, 34rem);
  max-width: 100%;
  overflow: visible;
  color: var(--soft);
}
.stage {
  display: flex;
  align-items: baseline;
  gap: 0.625rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}
.count {
  color: var(--muted);
  font: 400 0.75rem var(--mono);
}
.hint {
  max-width: 15rem;
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
  transition: opacity 400ms ease;
}
.hint[data-quiet] {
  opacity: 0;
}
html:not(.js) .hint,
.bar-link {
  display: none;
}

/* Same drawing rules as the app's PathTree. */
.e {
  stroke-linecap: round;
  stroke-linejoin: round;
}
.branch,
.ground,
.mound {
  stroke: currentColor;
}
.branch {
  fill: none;
}
.branch.d1 {
  stroke-opacity: 0.94;
}
.branch.d2 {
  stroke-opacity: 0.88;
}
.branch.d3 {
  stroke-opacity: 0.78;
}
.ground {
  fill: none;
  opacity: 0.85;
}
.mound,
.seed {
  fill: var(--clay-soft);
}
.seed {
  stroke: currentColor;
  stroke-width: 1;
}
.sun {
  fill: var(--amber-soft);
}
.leaf {
  stroke-width: 0.45;
}
.leaf.t0 {
  fill: var(--sage-soft);
  fill-opacity: 0.42;
  stroke: var(--sage);
  stroke-opacity: 0.45;
}
.leaf.t1 {
  fill: var(--teal-soft);
  fill-opacity: 0.55;
  stroke: var(--teal);
  stroke-opacity: 0.4;
}
/* Drawn larger than in the app, the front leaves would pile up into a dark mass:
   the wash is thinner here and the outline carries the leaf. */
.leaf.t2 {
  fill: var(--sage);
  fill-opacity: 0.3;
  stroke: var(--leaf);
  stroke-opacity: 0.75;
}
.leaf.t3 {
  fill: var(--leaf);
  fill-opacity: 0.42;
  stroke: var(--leaf);
  stroke-opacity: 0.9;
}
.leaf.t4 {
  fill: var(--teal);
  fill-opacity: 0.32;
  stroke: var(--teal);
  stroke-opacity: 0.8;
}
.petals {
  fill: var(--rose-soft);
  stroke: var(--rose);
  opacity: 0.85;
}
.heart {
  fill: var(--amber);
  stroke: none;
}
/* The sprout belongs to the first moments; a grown tree has none. */
html:not(.js) .tree [data-h] {
  display: none;
}

/* Growth. A shape is drawn once the reader has passed its threshold (app.js adds .on);
   until then it waits, folded. Nothing else on the page moves. */
.js .tree [data-t],
.js .tree [data-h] {
  transition:
    opacity 500ms ease,
    transform 800ms var(--ease-out);
}
.js .tree [data-t]:not(.on),
.js .tree [data-h].gone {
  opacity: 0;
}
.js .tree .leaf,
.js .tree .petals,
.js .tree .heart {
  transform-box: fill-box;
  transform-origin: center;
}
.js .tree .leaf[data-t]:not(.on),
.js .tree .petals:not(.on),
.js .tree .heart:not(.on) {
  transform: scale(0.55);
}
.js .tree .branch[data-t] {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition:
    opacity 160ms ease,
    stroke-dashoffset 1100ms var(--ease-out);
}
.js .tree .branch[data-t]:not(.on) {
  stroke-dashoffset: 1;
}
/* The plant also gets taller as it grows, rooted at the foot of the trunk. */
.js .tree .plant,
.js .tree .sway {
  transform-box: view-box;
}
.js .tree .plant {
  transition: transform 900ms var(--ease-out);
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .js .tree:hover .sway {
    animation: rustle 800ms cubic-bezier(0.65, 0, 0.35, 1);
  }
}
@keyframes rustle {
  25% {
    transform: rotate(-1.3deg);
  }
  55% {
    transform: rotate(1deg);
  }
  80% {
    transform: rotate(-0.4deg);
  }
}

/* ---------------------------------------------------------------- not found */

.lost {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100svh - 5rem);
  padding-bottom: 6rem;
}
.lost > * {
  max-width: 36rem;
}

/* ---------------------------------------------------------------- narrow screens: the tree rides along the bottom edge */

@media (max-width: 60rem) {
  body {
    font-size: 1.125rem;
    padding-bottom: 4.5rem;
  }
  .frame {
    padding-inline: 1.375rem;
  }
  .masthead {
    height: 4.25rem;
  }
  .sheet {
    display: block;
  }
  .path {
    padding-left: 0;
  }
  .leaf-page.first {
    min-height: 0;
    padding: 3.5rem 0 1rem;
  }
  .lede {
    font-size: 1.1875rem;
  }
  .folio {
    position: static;
    display: block;
    width: auto;
    margin-bottom: 0.875rem;
  }
  .ledger div {
    grid-template-columns: 1fr;
    row-gap: 0.25rem;
  }
  .ledger dt {
    padding-top: 0;
  }
  .grades {
    display: grid;
    grid-template-columns: repeat(4, auto);
    justify-content: space-between;
    font-size: 0.875rem;
  }
  .command {
    padding-left: 0.875rem;
  }
  .command code {
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.5;
  }
  .view {
    margin-left: 0;
  }
  .view figcaption {
    margin-left: 0;
  }
  .colophon {
    padding-bottom: 3rem;
  }

  .specimen {
    position: fixed;
    inset: auto 0 0;
    z-index: 2;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
    height: 4.25rem;
    padding: 0 1.375rem;
    border-top: 1px solid var(--rule);
    background: var(--bg);
    text-align: left;
  }
  .tree {
    flex: none;
    height: 3.375rem;
  }
  .stage {
    margin: 0;
  }
  .hint {
    display: none;
  }
  .bar-link {
    display: block;
    margin-left: auto;
    font-size: 0.875rem;
    font-weight: 500;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
