/* ------------------------------------------------------------------
   How's It Growing
   One stylesheet. Light and dark, both defined with the same tokens.
   ------------------------------------------------------------------ */

:root {
  --bg:          #fbfaf6;
  --surface:     #ffffff;
  --surface-2:   #f2f1ea;
  --ink:         #23281f;
  --ink-soft:    #5c6455;
  --ink-faint:   #858c7c;
  --line:        #dfded3;
  --accent:      #3f6b3a;   /* eucalypt */
  --accent-ink:  #ffffff;
  --accent-soft: #eaf1e6;
  --warn-bg:     #fdf3e3;
  --warn-ink:    #7a5312;
  --bad-bg:      #fceceb;
  --bad-ink:     #8f2c25;
  --good-bg:     #e8f3ea;
  --good-ink:    #1f6b34;
  --radius:      10px;
  --wrap:        62rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #14170f;
    --surface:     #1c2016;
    --surface-2:   #242a1e;
    --ink:         #e8ebe1;
    --ink-soft:    #b3baa8;
    --ink-faint:   #868e7b;
    --line:        #333a2a;
    --accent:      #8dc084;
    --accent-ink:  #14170f;
    --accent-soft: #232d1f;
    --warn-bg:     #2e2617;
    --warn-ink:    #e6c37f;
    --bad-bg:      #2f1c1a;
    --bad-ink:     #f0a49c;
    --good-bg:     #1a2b1f;
    --good-ink:    #94d3a4;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-text-size-adjust: 100%;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }
body.wide .wrap { max-width: 78rem; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.skip {
  position: absolute; left: -9999px;
  background: var(--accent); color: var(--accent-ink);
  padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; top: 0; z-index: 10; }

/* ---------- header ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding-top: .85rem; padding-bottom: .85rem;
}
.brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.brand-mark { width: 34px; height: 34px; flex: none; }
.site-header nav ul {
  display: flex; flex-wrap: wrap; gap: 1.1rem;
  list-style: none; margin: 0; padding: 0;
}
.site-header nav a {
  color: var(--ink-soft); text-decoration: none; padding: .2rem 0;
  border-bottom: 2px solid transparent;
}
.site-header nav a:hover { color: var(--ink); }
.site-header nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.signed-in { margin-left: auto; font-size: .85rem; color: var(--ink-faint); }

/* ---------- content ---------- */

main { padding-top: 2rem; padding-bottom: 3.5rem; min-height: 60vh; }

h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 .4rem; }
p  { margin: 0 0 1rem; }
.lede { font-size: 1.1rem; color: var(--ink-soft); max-width: 44rem; }
.muted { color: var(--ink-faint); font-size: .9rem; }
.binomial { font-style: italic; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem 1.4rem; margin: 0 0 1.25rem;
}

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }

.stat { display: flex; gap: 2rem; flex-wrap: wrap; margin: 1.5rem 0 2rem; }
.stat div { min-width: 7rem; }
.stat b { display: block; font-size: 1.9rem; line-height: 1.1; letter-spacing: -.02em; }
.stat span { color: var(--ink-faint); font-size: .85rem; }

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

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */

label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=email], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .5rem .6rem; max-width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.field { margin-bottom: 1.1rem; }
.hint { color: var(--ink-faint); font-size: .85rem; font-weight: 400; margin: .2rem 0 0; }

/* Heading for a group of controls that has no single input to point a
   <label> at, such as a pair of radios. */
.field-label { display: block; font-weight: 600; margin-bottom: .25rem; }

/* A radio or checkbox sits beside its text, not under a bold block label. */
.choice {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 400; margin: 0 1.2rem .2rem 0;
}
.choice input { margin: 0; }
/* A choice that has hit the group's limit: still readable, clearly inert. */
.choice-off { opacity: .45; cursor: not-allowed; }

/* Checkbox groups. auto-fill rather than a fixed count, so eleven soil types
   are three columns on a laptop and one on a phone without a media query. */
.checkbox-grid {
  display: grid; gap: .1rem .8rem;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
}
.checkbox-grid .choice { margin-right: 0; }

/* The "?" that explains a dropdown's options, and the panel it opens.
   A <details>, so it works by tap and by keyboard with no JavaScript. */
/* The panel hangs off the field, not off the "?" itself. Anchoring it to the
   button would indent it by the width of the label, and a viewport-relative
   width would then run off the right edge of a phone. */
.field-head { display: flex; align-items: baseline; gap: .4rem; position: relative; }
.field-help > summary {
  list-style: none; cursor: help;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.2rem; height: 1.2rem; border-radius: 50%;
  border: 1px solid var(--line); color: var(--ink-faint);
  font-size: .75rem; font-weight: 700; line-height: 1;
  -webkit-user-select: none; user-select: none;
}
.field-help > summary::-webkit-details-marker { display: none; }
.field-help > summary::marker { content: ''; }
.field-help[open] > summary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.field-help-panel {
  position: absolute; z-index: 30; top: 1.7rem; left: 0;
  width: max(16rem, min(28rem, 78vw));
  max-height: 60vh; overflow-y: auto;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .75rem .9rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
  font-weight: 400;
}
.field-help-panel dl { margin: 0; }
.field-help-panel dt { font-weight: 600; margin-top: .55rem; }
.field-help-panel dt:first-child { margin-top: 0; }
.field-help-panel dd {
  margin: .1rem 0 0; color: var(--ink-faint); font-size: .88rem; line-height: 1.45;
}

.measure-field { margin-bottom: 1.1rem; }
.measure-selects { display: flex; align-items: center; gap: .35rem; }
.measure-point { font-weight: 700; }
.measure-unit { color: var(--ink-faint); }

button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent; border-radius: 8px;
  padding: .55rem 1.1rem; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { filter: brightness(1.08); }
.button-quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }

/* The honeypot. Off-screen rather than display:none, because some bots
   skip hidden inputs and the whole point is that they fill it in. */
.hp {
  position: absolute; left: -10000px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}

input[type=file] {
  font: inherit; color: var(--ink-soft); max-width: 100%;
  padding: .4rem 0;
}
textarea { width: 100%; resize: vertical; }

/* ---------- browse ---------- */

.genus-card { display: block; text-decoration: none; color: inherit; }
.genus-card:hover { border-color: var(--accent); }
.genus-card h3 { margin: 0 0 .3rem; color: var(--accent); }
.genus-card p { margin: 0; }

.count-badge {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: .05rem .6rem;
  font-size: .82rem; font-weight: 600; font-variant-numeric: tabular-nums;
}

.filters { margin: 0 0 1rem; }

.letters { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 1.5rem; }
.letters a, .letters span {
  display: inline-block; min-width: 1.7rem; text-align: center;
  padding: .1rem .25rem; border-radius: 6px; text-decoration: none;
  border: 1px solid var(--line); font-size: .88rem;
}
.letters a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.letters .off { color: var(--ink-faint); opacity: .45; border-color: transparent; }

.taxon-list { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.taxon {
  display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem;
  align-items: baseline; padding: .45rem 0; border-bottom: 1px solid var(--line);
}
.taxon-main .muted { margin-left: .5rem; }

/* An empty taxon is not a link, has no hover and no pointer, so there is
   nothing about it that invites a click that would lead nowhere. */
.taxon-empty > .taxon-main,
.subspecies-list li.taxon-empty { color: var(--ink-faint); }
.taxon-empty .binomial { opacity: .75; }

.add-first { font-size: .82rem; color: var(--ink-faint); }
.add-first:hover { color: var(--accent); }

.subspecies-list {
  grid-column: 1 / -1; list-style: none; margin: .15rem 0 0; padding: 0 0 0 1.5rem;
  font-size: .93rem;
}
.subspecies-list li { padding: .12rem 0; }
.subspecies-list .muted { margin-left: .4rem; font-size: .85rem; }

/* ---------- plant cards ---------- */

.plant-card { padding: 1.25rem 1.4rem 1rem; }
.plant-head h2 { margin: 0; font-size: 1.15rem; }
.plant-head p { margin: .1rem 0 .75rem; font-size: .9rem; }

.plant-size {
  font-size: 1.25rem; margin: 0 0 .6rem; letter-spacing: -.01em;
}
.plant-size strong { font-variant-numeric: tabular-nums; }

/* The conditions are as readable as the numbers, because without filters
   the reader is comparing them by eye. */
.conditions {
  display: flex; flex-wrap: wrap; gap: .4rem .5rem;
  list-style: none; margin: 0 0 1rem; padding: 0; font-size: .88rem;
}
.conditions li {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .1rem .7rem;
}

.history { font-size: .9rem; margin-bottom: 1rem; }
.plant-notes { font-size: .92rem; color: var(--ink-soft); margin: 0 0 1rem; }
.plant-comments {
  font-size: .92rem; color: var(--ink-soft); margin: 0 0 1rem;
  border-left: 3px solid var(--line); padding-left: .7rem; border-radius: 0;
}
.plant-foot { font-size: .85rem; border-top: 1px solid var(--line); padding-top: .6rem; }

/* ---------- photos ---------- */

.photo-row {
  display: flex; flex-wrap: wrap; gap: 1rem; margin: 0 0 1.5rem;
}
.photo-row figure { margin: 0; }
.photo-row img {
  display: block; max-width: 100%; height: auto;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface-2);
}
.photo-row figcaption {
  font-size: .82rem; color: var(--ink-faint); margin-top: .3rem;
}

/* ---------- admin ---------- */

.admin-nav {
  display: flex; flex-wrap: wrap; gap: 1rem;
  padding-bottom: .75rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line); font-size: .9rem;
}
.admin-nav a.on { font-weight: 600; }

.admin-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.admin-actions form { display: inline; }

.button-small { padding: .2rem .6rem; font-size: .82rem; }

.inline-form { display: flex; gap: .35rem; align-items: center; }
.inline-form input[type=text] { padding: .25rem .4rem; font-size: .88rem; }

.add-row {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
  margin: .5rem 0 2rem;
}
.add-row input { padding: .3rem .45rem; font-size: .9rem; }

/* A hidden or retired row still has to be readable, just obviously not live. */
.row-hidden td { opacity: .55; }
.row-hidden td:first-child { border-left: 3px solid var(--warn-ink); padding-left: .5rem; }

.filters a.on { font-weight: 600; text-decoration: none; }
.filters a { margin-right: 1rem; }

/* ---------- messages ---------- */

.flash {
  border-radius: var(--radius); padding: .7rem 1rem; margin: 0 0 1.25rem;
  border: 1px solid transparent;
}
.flash-notice { background: var(--warn-bg); color: var(--warn-ink); }
.flash-bad    { background: var(--bad-bg);  color: var(--bad-ink); }
.flash-good   { background: var(--good-bg); color: var(--good-ink); }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 1.75rem 0; font-size: .9rem; color: var(--ink-soft);
}
.site-footer p { margin: 0 0 .4rem; max-width: 48rem; }

/* ---------- narrow screens ---------- */

@media (max-width: 40rem) {
  h1 { font-size: 1.55rem; }
  .site-header .wrap { gap: .35rem 1rem; }
  .signed-in { margin-left: 0; width: 100%; }
  .stat { gap: 1.25rem; }
}
