/* Yuanya · 源芽. A herbarium specimen sheet: one pressed seedling, a label, nothing else. */

@font-face {
  font-family: "Spectral";
  src: url("fonts/spectral-400-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("fonts/spectral-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-latin.woff2") format("woff2");
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
/* Only the two characters 源 and 芽. */
@font-face {
  font-family: "Yuanya Han";
  src: url("fonts/noto-serif-sc-yuanya.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
  unicode-range: U+6E90, U+82BD;
}

:root {
  --page: #FBFBF9;
  --sheet: #FFFFFF;
  --band: #ECF1E6;
  --ink: #22261F;
  --muted: #5A6154;
  --line: rgba(34, 38, 31, 0.16);
  --leaf: #8DAA5B;
  --leaf-edge: #4E6B33;
  --stem: #5C7A3E;
  --root: #8A7A63;
  --seed: #9C7B4F;
  --tape: rgba(226, 219, 196, 0.82);
  --green: #3C5E2E;
  --green-2: #4A7139;
  --on-green: #F1F5EC;
  --on-green-muted: #C5D3BA;
  --error: #A12A22;

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --han: "Yuanya Han", "Noto Serif SC", "Songti SC", "SimSun", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, dl, dd, figure { margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: 500; text-wrap: balance; }
a { color: inherit; }

.han { font-family: var(--han); font-weight: 500; font-style: normal; letter-spacing: 0.04em; }
.py { font-style: italic; }

.wrap { width: 100%; max-width: 72rem; margin-inline: auto; padding-inline: clamp(20px, 5vw, 48px); }

.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; top: 12px; left: 12px; z-index: 10; padding: 10px 14px; background: var(--green); color: var(--on-green); border-radius: 3px; transform: translateY(-160%); font-family: var(--sans); }
.skip:focus { transform: none; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

/* ---------- bar ---------- */
.bar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 22px; }
.brand { display: inline-flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand-name { font-family: var(--serif); font-weight: 500; font-size: 1.5rem; line-height: 1; letter-spacing: 0.01em; }
.brand .han { font-size: 1rem; color: var(--muted); }
.bar-go { font-family: var(--sans); font-size: 1rem; font-weight: 500; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.bar-go:hover { text-decoration-thickness: 2px; }

/* ---------- hero ---------- */
.hero-in {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(40px, 7vw, 112px);
  padding-block: clamp(24px, 5vh, 64px) clamp(56px, 10vh, 112px);
}

.hero h1 {
  font-size: clamp(2.5rem, 1.4rem + 3.4vw, 4.25rem);
  line-height: 1.06;
  letter-spacing: -0.012em;
  max-width: 11em;
}

.lede { margin-top: 24px; max-width: 32rem; font-size: 1.3125rem; line-height: 1.55; }
.hero .join { margin-top: 36px; max-width: 32rem; }

/* the specimen sheet */
.sheet {
  position: relative;
  justify-self: center;
  height: clamp(360px, 68svh, 640px);
  aspect-ratio: 3 / 4;
  container-type: size;
  background: var(--sheet);
  box-shadow: 0 1px 0 rgba(34, 38, 31, 0.06), 0 18px 40px -22px rgba(34, 38, 31, 0.35);
  transform: rotate(0.6deg);
}

.plant { position: absolute; left: 8%; top: 4%; width: 84%; height: 60%; overflow: visible; }
.roots path { fill: none; stroke: var(--root); stroke-width: 1.6; stroke-linecap: round; }
.seed { fill: var(--seed); }
.stem { fill: none; stroke: var(--stem); stroke-width: 3; stroke-linecap: round; }
.leaf path:first-child { fill: var(--leaf); stroke: var(--leaf-edge); stroke-width: 1.4; stroke-linejoin: round; }
.leaf .vein { fill: none; stroke: var(--leaf-edge); stroke-width: 1; opacity: 0.7; }
.tape { fill: var(--tape); }

.label {
  position: absolute;
  right: 6%;
  bottom: 5%;
  width: 70%;
  padding: 0.7em 0.85em 0.55em;
  border: 1px solid var(--ink);
  background: var(--sheet);
  /* the label scales with the sheet, like a real one would */
  font-size: clamp(0.75rem, 3.8cqw, 0.9375rem);
  line-height: 1.35;
}
.label div { display: grid; grid-template-columns: 5.8em 1fr; gap: 0.6em; padding-block: 0.3em; border-bottom: 1px solid var(--line); }
.label div:last-child { border-bottom: 0; }
.label dt { font-family: var(--sans); font-size: 0.86em; color: var(--muted); padding-top: 0.1em; }
.label dd { font-family: var(--serif); }

/* One motion: the seedling grows once, root first. */
.js .roots path, .js .stem { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.9s cubic-bezier(.3, .7, .3, 1) forwards; }
.js .roots path:nth-child(1) { animation-delay: 0.15s; }
.js .roots path:nth-child(2) { animation-delay: 0.35s; }
.js .roots path:nth-child(3) { animation-delay: 0.45s; }
.js .roots path:nth-child(4) { animation-delay: 0.55s; }
.js .stem { animation-duration: 1.1s; animation-delay: 0.6s; }
.js .leaf { opacity: 0; transform: scale(0.2); animation: unfold 0.8s cubic-bezier(.3, .7, .3, 1) 1.45s forwards; }
.js .leaf-l { transform-origin: 151px 94px; }
.js .leaf-r { transform-origin: 152px 92px; animation-delay: 1.6s; }
.js .tape { opacity: 0; animation: show 0.3s ease 2.1s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes unfold { to { opacity: 1; transform: none; } }
@keyframes show { to { opacity: 1; } }

/* ---------- form ---------- */
.row { display: flex; gap: 8px; }
.field {
  flex: 1 1 auto; min-width: 0; height: 54px; padding: 0 16px;
  font-family: var(--sans); font-size: 1.0625rem; color: var(--ink);
  background: var(--sheet); border: 1.5px solid #9BA394; border-radius: 3px;
}
.field::placeholder { color: #666D60; }
.field:focus-visible { border-color: var(--green); outline-offset: 2px; }
.field[aria-invalid="true"] { border-color: var(--error); }
.btn {
  flex: none; height: 54px; padding: 0 22px;
  font-family: var(--sans); font-size: 1.0625rem; font-weight: 600;
  color: var(--on-green); background: var(--green); border: 0; border-radius: 3px; cursor: pointer;
}
.btn:hover { background: var(--green-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: progress; opacity: 0.75; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; }
.fine { margin-top: 12px; font-family: var(--sans); font-size: 0.9375rem; color: var(--muted); }
.oops { margin-top: 10px; font-family: var(--sans); font-size: 0.9375rem; font-weight: 500; color: var(--error); }
.oops:empty { display: none; }
.nojs { display: none; margin-top: 8px; font-family: var(--sans); font-size: 0.9375rem; color: var(--error); }
html:not(.js) .nojs { display: block; }
.done-line { display: flex; align-items: center; gap: 10px; font-size: 1.1875rem; }
.done-line b { font-weight: 500; }
.tick { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--green); stroke-width: 1.6; }
.tick path { stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.again { padding: 0; font: inherit; color: inherit; background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.when-joined { display: none; }
.is-joined .when-open { display: none; }
.is-joined .when-joined { display: inline; }

/* ---------- name ---------- */
.band { padding-block: clamp(72px, 11vw, 136px); }
#name { background: var(--band); }
.band h2 { font-size: clamp(1.875rem, 1.35rem + 1.6vw, 2.5rem); line-height: 1.15; }

.name-in {
  display: grid;
  grid-template-columns: auto minmax(0, 34rem);
  grid-template-areas: "head head" "chars prose";
  column-gap: clamp(40px, 8vw, 128px);
  row-gap: 48px;
  align-items: start;
}
.name-in h2 { grid-area: head; }
.chars { grid-area: chars; display: flex; gap: clamp(28px, 4vw, 56px); }
.char dt .han { display: block; font-size: clamp(4.5rem, 3rem + 5vw, 7.5rem); line-height: 1; letter-spacing: 0; }
.char dd { margin-top: 14px; max-width: 9.5rem; font-family: var(--sans); font-size: 1rem; line-height: 1.45; color: var(--muted); }
.char dd .py { display: block; font-family: var(--serif); font-size: 1.125rem; color: var(--ink); }
.prose { grid-area: prose; }
.prose p + p { margin-top: 1em; }

/* ---------- questions ---------- */
.qs-in { display: grid; grid-template-columns: minmax(0, 18rem) minmax(0, 40rem); justify-content: space-between; gap: 40px; }
.qs { border-top: 1px solid var(--line); }
.q { border-bottom: 1px solid var(--line); }
.q summary { position: relative; padding: 20px 40px 20px 0; font-weight: 500; cursor: pointer; list-style: none; }
.q summary::-webkit-details-marker { display: none; }
.q summary::before, .q summary::after { content: ""; position: absolute; right: 6px; top: 50%; width: 14px; height: 1.5px; background: var(--ink); transition: transform 0.2s ease; }
.q summary::after { transform: rotate(90deg); }
.q[open] summary::after { transform: rotate(0deg); }
.q p { padding-bottom: 22px; max-width: 36rem; color: var(--muted); }

/* ---------- close ---------- */
.close { padding-block: clamp(80px, 12vw, 144px); background: var(--green); color: var(--on-green); }
.close h2 { color: var(--on-green); font-size: clamp(1.875rem, 1.35rem + 1.6vw, 2.5rem); line-height: 1.15; max-width: 18em; }
.close .lede { color: var(--on-green-muted); }
.close .join { margin-top: 36px; max-width: 32rem; }
.close .field { color: var(--on-green); background: #33522A; border-color: #6E8D60; }
.close .field::placeholder { color: #B5C6A9; }
.close .field:focus-visible { border-color: var(--on-green); }
.close .btn { color: var(--green); background: var(--page); }
.close .btn:hover { background: #FFFFFF; }
.close .fine { color: var(--on-green-muted); }
.close .oops, .close .nojs { color: #F7C2B8; }
.close .tick { stroke: var(--on-green); }
.close :focus-visible { outline-color: var(--on-green); }

.foot { background: var(--green); color: var(--on-green-muted); font-family: var(--sans); font-size: 0.9375rem; }
.foot-in { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 32px; padding-block: 28px 36px; border-top: 1px solid rgba(241, 245, 236, 0.16); }
.foot .brand-name { font-size: 1.125rem; color: var(--on-green); }
.foot a { text-underline-offset: 3px; }
.foot :focus-visible { outline-color: var(--on-green); }

/* ---------- smaller screens ---------- */
@media (max-width: 860px) {
  .hero-in { grid-template-columns: minmax(0, 1fr); gap: 32px; padding-top: 8px; }
  .hero .join { margin-top: 28px; }
  /* the sheet turns landscape: plant on the left, label on the right */
  .sheet { order: -1; width: 100%; max-width: 440px; height: auto; aspect-ratio: 5 / 4; }
  .plant { left: 3%; top: 5%; width: 50%; height: 90%; }
  .label { right: 5%; bottom: auto; top: 50%; transform: translateY(-50%); width: 46%; font-size: clamp(0.75rem, 3.2cqw, 0.875rem); }
  .label div { display: block; padding-block: 5px; }
  .label dt { padding-top: 0; }
  .name-in { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "chars" "prose"; row-gap: 36px; }
  .qs-in { grid-template-columns: minmax(0, 1fr); gap: 28px; }
}
@media (max-width: 460px) {
  .row { flex-direction: column; }
  .btn { width: 100%; }
  .hero h1 { font-size: 2.25rem; }
  .lede { margin-top: 18px; font-size: 1.1875rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .roots path, .js .stem, .js .leaf, .js .tape { animation: none; stroke-dashoffset: 0; opacity: 1; transform: none; }
  .q summary::before, .q summary::after { transition: none; }
  .btn:active { transform: none; }
}
