/* One sheet for every page of ldn.garden.
 *
 * The app's design language, moved to the web: warm paper, deep botanical
 * green, a serif for anything that is a fact and a sans for anything that is
 * a label. Colours are the values in ios/Sources/Design/Theme.swift, so the
 * site and the app are the same object seen twice. Rules are hairlines, the
 * width of a printed one. Nothing is a card.
 */

:root {
  /* Theme.swift */
  --canopy: #1c4d2e;
  --leaf: #4a7d45;
  --moss: #8ca166;
  --bark: #5c4533;
  --blossom: #de858c;

  --ground: #f7f5e8;
  --ink: #212e1f;
  --quiet: #6b7563;
  --display: var(--canopy);
  --rule: rgba(33, 46, 31, 0.14);
  --rule-firm: rgba(33, 46, 31, 0.3);
  --plate: var(--canopy);
  --plate-strength: 1;
  --action: var(--canopy);
  --action-ink: var(--ground);
  --field: rgba(255, 255, 255, 0.6);

  /* New York on Apple hardware, which is the face the app is set in. */
  --serif: ui-serif, "New York", "Iowan Old Style", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;

  /* One column, set to a comfortable line rather than a wide container with
     the text pushed against its left edge. */
  --page: 40rem;
  --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #171c17;
    --ink: #e7e6d6;
    --quiet: #9aa393;
    --display: #cfe0b8;
    --leaf: #9ab882;
    --rule: rgba(231, 230, 214, 0.16);
    --rule-firm: rgba(231, 230, 214, 0.32);
    --plate: var(--moss);
    --plate-strength: 0.85;
    --action: #cfe0b8;
    --action-ink: #171c17;
    --field: rgba(255, 255, 255, 0.05);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(74, 125, 69, 0.22); }

a { color: var(--leaf); text-underline-offset: 0.18em; text-decoration-thickness: 0.5px; }
a:hover { color: var(--display); }

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

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

/* Sticky, but it steps aside on the way down and returns on the way up, so a
   long read is not spent under a bar. See site.js. */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ground);
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
}
.masthead.is-hidden { transform: translateY(-105%); }
.masthead.is-stuck { box-shadow: 0 1px 0 var(--rule); }

.bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  max-width: var(--page);
  margin: 0 auto;
  padding: 1.1rem var(--gutter);
}

.mark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: auto;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--display);
  text-decoration: none;
}

/* The mark is painted rather than drawn, so it takes the colour of the text
   it sits beside and needs no second file for the dark page. */
.mark::before {
  content: "";
  width: 1.35em;
  height: 1.75em;
  background: currentColor;
  -webkit-mask: url(/ldn-mark.svg) center / contain no-repeat;
  mask: url(/ldn-mark.svg) center / contain no-repeat;
}

/* The homepage opens on the plate, which is its own rule. Every other page
   needs one under the running head, until the page scrolls and the masthead
   grows a full-width one of its own. */
.masthead:has(+ main) .bar { border-bottom: 1px solid var(--rule); }
.masthead.is-stuck .bar { border-bottom-color: transparent; }

.bar nav { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.bar nav a {
  font-size: 0.9rem;
  color: var(--quiet);
  text-decoration: none;
}
.bar nav a:hover { color: var(--display); }
.bar nav a[aria-current] { color: var(--ink); }

/* ------------------------------------------------------------------- plate */

/* Every tree in the record, drawn at its recorded position. The file is an
   alpha mask, so the ink is a CSS colour and the same file serves the light
   page and the dark one. Built by data/build_plate.py. */
.plate {
  position: relative;
  margin: 0.5rem 0 0;
  border-top: 1px solid var(--rule);
  overflow: hidden;
}

.plate-ink {
  height: min(80vh, 46rem);
  background: var(--plate);
  opacity: var(--plate-strength);
  -webkit-mask: url(/plate-trees.png) center 42% / cover no-repeat;
  mask: url(/plate-trees.png) center 42% / cover no-repeat;
  animation: settle 1400ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* The ink settles onto the paper. The one piece of motion on the site. */
@keyframes settle {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: var(--plate-strength); transform: none; }
}

/* The same fade the app uses at the foot of a specimen plate: the picture
   ends in the paper rather than against an edge. */
.plate::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 62%;
  background: linear-gradient(to bottom, transparent, var(--ground) 72%);
  pointer-events: none;
}

/* The title sits in the plate, in the part where the ink has already given
   way to paper, so the map runs behind the words rather than under them. */
.plate-titles {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter) 1.7rem;
  text-align: center;
}
.plate-titles h1 { margin: 0; }
.plate-titles .lede {
  max-width: 32rem;
  margin: 1rem auto 0;
}

/* -------------------------------------------------------------------- page */

main {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter) 1rem;
}

.titles { padding-top: 0.6rem; }

h1 {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 7vw, 3.9rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.022em;
  color: var(--display);
  text-wrap: balance;
}

/* The line of provenance under a specimen's name. */
.provenance {
  margin-top: 0.9rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--leaf);
}

.lede {
  font-family: var(--serif);
  font-size: 1.28rem;
  line-height: 1.5;
  margin-top: 1.3rem;
  color: var(--ink);
}

h2 {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.012em;
  line-height: 1.2;
  color: var(--display);
  margin-bottom: 0.8rem;
}

h3 {
  font-family: var(--serif);
  font-size: 1.16rem;
  font-weight: 600;
  color: var(--display);
  margin-bottom: 0.35rem;
}

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

ul, ol { margin: 0 0 1rem 1.1rem; }
li { margin-bottom: 0.5rem; }
li::marker { color: var(--moss); }

strong { font-weight: 600; }

/* A section opens with its label set into the rule rather than under a
   full-width one. A hairline with a word in it can only be a section head; a
   plain hairline can only be a row. The two stop being the same mark. */
section { margin-top: 3.4rem; }
/* The plate already ends in a wide margin of paper; the first section under
   it does not need a second one. */
main > section:first-child { margin-top: 1.3rem; }

section > .eyebrow {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}
section > .eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.eyebrow {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--leaf);
}

/* ----------------------------------------------------------------- figures */

/* The extent of the survey, read at a glance. Serif figures because they are
   facts, sans labels because they are labels, hairlines between rather than
   three boxes. */
.figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.figures div {
  padding: 0.9rem 1.2rem 1rem 0;
}
.figures div + div {
  padding-left: 1.5rem;
  border-left: 1px solid var(--rule);
}
.figures b {
  display: block;
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.6rem, 4.2vw, 2.3rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--display);
  font-variant-numeric: tabular-nums;
}
.figures span {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--quiet);
}
@media (max-width: 34rem) {
  .figures { grid-template-columns: 1fr; }
  .figures div { display: flex; align-items: baseline; gap: 0.8rem; padding: 0.75rem 0; }
  .figures div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--rule); }
  .figures span { margin-top: 0; }
}

/* ------------------------------------------------------------ ruled tables */

/* Label in a fixed column, value in the rest of the line. The app sets a
   measurement flush right because it is a number; these are sentences, and a
   sentence ragged down its left edge is unreadable. */
.facts { margin-bottom: 0.5rem; }
.facts div:last-child { border-bottom: 0; }
.facts div {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0 1.6rem;
  align-items: baseline;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
}
.facts dt {
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--quiet);
}
.facts dd {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 34rem) {
  .facts div { grid-template-columns: 1fr; gap: 0.15rem; }
}
.facts dd a { text-decoration-color: var(--rule-firm); }

/* The commonest trees. The bar is the count: printing the figure as well
   would say the same thing twice, and the shape is the easier read. */
.ranking {
  list-style: none;
  margin: 0;
}
.ranking li {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin: 0;
  padding: 0.62rem 0;
  border-bottom: 1px solid var(--rule);
}
.ranking .name { font-family: var(--serif); font-size: 1.05rem; }
.ranking .taxon {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--quiet);
}
.ranking li:last-child { border-bottom: 0; }
.ranking .name { width: 9rem; flex: none; }
.ranking .taxon { width: 9.5rem; flex: none; }
.ranking .share {
  flex: 1;
  min-width: 3rem;
  align-self: center;
  height: 5px;
  background: linear-gradient(
    to right,
    var(--leaf) var(--share),
    var(--rule) var(--share)
  );
}
@media (max-width: 38rem) {
  .ranking .taxon { display: none; }
  .ranking .name { width: 8.5rem; }
}

/* ----------------------------------------------------------------- entries */

/* Three things the app does, set as guide entries: the heading in the margin,
   the prose in the column. Not cards, because a field guide has no cards. */

.entry {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0 2.5rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.entry:last-child { border-bottom: 0; }
.entry h3 { margin: 0; }
@media (max-width: 44rem) {
  .entry { grid-template-columns: 1fr; gap: 0.4rem; }
}

/* ------------------------------------------------------------------ ledger */

/* What the phone keeps to itself, one line each. */
.ledger {
  list-style: none;
  margin: 1.4rem 0 0;
}
.ledger li {
  padding: 0.5rem 0;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.45;
}
.ledger li + li { border-top: 1px solid var(--rule); }

/* A link out of a section, set on its own line with the arrow a reader
   expects rather than buried mid-sentence. */
.more {
  margin-top: 1.2rem;
  font-size: 0.95rem;
}
.more a {
  text-decoration: none;
  border-bottom: 1px solid var(--rule-firm);
  padding-bottom: 2px;
}
.more a::after { content: " \2192"; }
.more a:hover { border-bottom-color: currentColor; }

/* ------------------------------------------------------------------ signup */

.signup {
  margin: 1.4rem 0 0.7rem;
  max-width: 30rem;
}
.signup label {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--leaf);
}
.signup .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.signup input {
  flex: 1 1 12rem;
  min-width: 0;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--rule-firm);
  border-radius: 4px;
  -webkit-appearance: none;
  padding: 0.62rem 0.75rem;
}
.signup input::placeholder { color: var(--quiet); }
.signup input:focus { border-color: var(--leaf); }
.signup button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--action-ink);
  background: var(--action);
  border: 0;
  border-radius: 4px;
  padding: 0.62rem 1.2rem;
  cursor: pointer;
  transition: background-color 150ms ease;
}
.signup button:hover { background: var(--leaf); color: var(--ground); }

.note {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--quiet);
}

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

/* The address, set at the size it deserves rather than buried in a sentence. */
.contact {
  margin: 1.2rem 0;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 4vw, 1.7rem);
  letter-spacing: -0.015em;
}
.contact a { text-decoration-thickness: 1px; text-underline-offset: 0.14em; }

/* --------------------------------------------------------------- long-form */

table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td {
  text-align: left;
  padding: 0.65rem 0.9rem 0.65rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--leaf);
  border-bottom-color: var(--rule-firm);
}
.wrap { overflow-x: auto; }

/* A pulled-out statement, the weight a printed guide gives its one rule of
   thumb. Serif, behind a green rule, never a coloured box. */
.principle {
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.45;
  padding-left: 1.2rem;
  border-left: 2px solid var(--leaf);
  color: var(--display);
}

.facts + p, .ranking + p, .wrap + p { margin-top: 1.3rem; }

/* --------------------------------------------------------------- accordion */

.accordion details { border-bottom: 1px solid var(--rule); }
.accordion details:last-child { border-bottom: 0; }

.accordion summary {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.95rem 0;
  cursor: pointer;
  list-style: none;
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--display);
}
.accordion summary::-webkit-details-marker { display: none; }

/* A hairline cross that loses its upright when the answer is open. */
.accordion summary::after {
  content: "";
  flex: none;
  margin-left: auto;
  width: 11px;
  height: 11px;
  align-self: center;
  background:
    linear-gradient(var(--leaf), var(--leaf)) center / 11px 1px no-repeat,
    linear-gradient(var(--leaf), var(--leaf)) center / 1px 11px no-repeat;
  transition: transform 200ms ease;
}
.accordion details[open] summary::after {
  background: linear-gradient(var(--leaf), var(--leaf)) center / 11px 1px no-repeat;
  transform: rotate(180deg);
}
.accordion summary:hover { color: var(--leaf); }
.accordion details p { padding: 0 0 1.1rem; margin: 0; }

/* --------------------------------------------------------------- footnotes */

footer {
  max-width: var(--page);
  margin: 3.5rem auto 0;
  padding: 1.8rem var(--gutter) 4rem;
  position: relative;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--quiet);
}
footer p + p { margin-top: 0.5rem; }

/* Inset to the text column so it lines up with the section rules rather than
   running out to the container's padding edge. */
footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  height: 1px;
  background: var(--rule);
}
footer .links {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
footer .links a { color: var(--ink); text-decoration: none; }
footer .links a:hover { color: var(--display); text-decoration: underline; }

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

/* --- Error pages ---
   They ARE the homepage hero, with different words, so almost nothing is
   needed here: the eyebrow above the heading, and the two ways out. */
.plate-titles .eyebrow { display: block; margin-bottom: 0.5rem; }
.plate-links {
  margin: 1.4rem 0 0;
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}
.plate-links a {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 0.45rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid var(--rule-firm);
  color: var(--ink);
}
.plate-links a.primary {
  background: var(--action);
  border-color: var(--action);
  color: var(--action-ink);
}
.plate-links a:hover { border-color: var(--leaf); }
.plate-links a:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }

/* The hero fills the window on an error page, where there is nothing below it
   to scroll to. On the homepage it deliberately does not. */
body:has(.plate-links) .plate { min-height: 100vh; display: flex; }
body:has(.plate-links) .plate-ink { flex: 1; height: auto; min-height: 100vh; }

