/* Native Plant Journal — botanical field-guide styling.
   Self-contained: system font stacks only, no external requests. */

:root {
  --paper: #f7f4ec;
  --surface: #fffdf8;
  --surface-2: #f0ecdf;
  --ink: #24271f;
  --muted: #6c6f60;
  --faint: #8f9280;
  --line: #e3ddcd;
  --line-strong: #d3ccb7;
  --green: #3f6b3f;
  --green-deep: #2c4a2c;
  --berry: #9b3535;
  --gold: #a97e1f;
  --amber: #b5651d;
  --shadow: 0 1px 2px rgba(40, 38, 25, .05), 0 8px 24px -12px rgba(40, 38, 25, .18);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Hoefler Text", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --wrap: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14160e;
    --surface: #1c1f14;
    --surface-2: #23271a;
    --ink: #ece7d6;
    --muted: #a7a993;
    --faint: #83866f;
    --line: #2e3220;
    --line-strong: #3c4029;
    --green: #94b47c;
    --green-deep: #b6cfa0;
    --berry: #e29a9a;
    --gold: #d8b45a;
    --amber: #dc9a58;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --paper: #14160e; --surface: #1c1f14; --surface-2: #23271a; --ink: #ece7d6;
  --muted: #a7a993; --faint: #83866f; --line: #2e3220; --line-strong: #3c4029;
  --green: #94b47c; --green-deep: #b6cfa0; --berry: #e29a9a; --gold: #d8b45a; --amber: #dc9a58;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
}
:root[data-theme="light"] {
  --paper: #f7f4ec; --surface: #fffdf8; --surface-2: #f0ecdf; --ink: #24271f;
  --muted: #6c6f60; --faint: #8f9280; --line: #e3ddcd; --line-strong: #d3ccb7;
  --green: #3f6b3f; --green-deep: #2c4a2c; --berry: #9b3535; --gold: #a97e1f; --amber: #b5651d;
  --shadow: 0 1px 2px rgba(40,38,25,.05), 0 8px 24px -12px rgba(40,38,25,.18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--green); text-underline-offset: 2px; }
a:hover { color: var(--green-deep); }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 22px; }

/* ---------- Masthead ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--surface), var(--paper));
}
.masthead .wrap { padding-top: 30px; padding-bottom: 26px; }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  letter-spacing: .2px;
  margin: 0;
  line-height: 1.1;
}
.brand h1 a { color: inherit; text-decoration: none; }
.brand .leaf { color: var(--green); }
.tagline {
  color: var(--muted);
  font-size: .98rem;
  margin: 10px 0 0;
  max-width: 62ch;
}
.masthead nav { margin-top: 16px; display: flex; gap: 18px; font-size: .9rem; }
.masthead nav a { color: var(--muted); text-decoration: none; }
.masthead nav a:hover { color: var(--green); }

/* ---------- Mission band ---------- */
.mission {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.mission .wrap { padding: 28px 22px; }
.mission p { margin: 0 auto; max-width: 74ch; color: var(--ink); }
.mission .lede { font-family: var(--serif); font-size: 1.15rem; line-height: 1.55; }
.mission .sub { margin-top: 10px; color: var(--muted); font-size: .96rem; }

/* ---------- Section headers ---------- */
section { padding: 34px 0; }
.section-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin: 0 0 4px;
  font-weight: 600;
}
.section-note { color: var(--muted); font-size: .9rem; margin: 0 0 20px; }

/* ---------- Harvest calendar ---------- */
.calendar { display: grid; gap: 6px; }
.cal-head, .cal-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) repeat(var(--months, 5), 1fr);
  align-items: center;
  gap: 4px;
}
.cal-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.cal-head span { text-align: center; padding-bottom: 4px; }
.cal-head .lead { text-align: left; }
.cal-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.cal-row .name { font-size: .86rem; }
.cal-row .name a { text-decoration: none; }
.cal-row .name em { color: var(--muted); font-size: .78rem; display: block; }
.cal-cell { height: 22px; position: relative; }
.cal-bar {
  position: absolute; top: 4px; bottom: 4px; left: -3px; right: -3px;
  background: var(--green); opacity: .9;
}
.cal-bar.start { left: 3px; border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.cal-bar.end { right: 3px; border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
.cal-bar.ripe { background: var(--gold); }
.cal-legend { display: flex; gap: 18px; margin-top: 12px; font-size: .78rem; color: var(--muted); }
.cal-legend .swatch { display: inline-block; width: 22px; height: 10px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }

/* ---------- Journal search (sticky; filters collections + field guides) ---------- */
.journal-search {
  position: sticky; top: 0; z-index: 20;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 12px 0; margin-bottom: 6px;
}
.search {
  font: inherit; font-size: .9rem; width: 100%;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 9px 16px;
}
.search:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
.search::placeholder { color: var(--faint); }

/* ---------- Collapsible harvest calendar ---------- */
/* Native <details>; auto-collapsed at scale (many rows) via the `open` attr in build.ts. */
.cal-wrap > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: baseline; gap: 10px; padding: 4px 0 12px;
}
.cal-wrap > summary::-webkit-details-marker { display: none; }
.cal-wrap > summary .section-title { margin: 0; }
.cal-toggle-hint {
  margin-left: auto; color: var(--faint); font-size: .8rem;
  display: inline-flex; align-items: center; gap: 8px;
}
.cal-toggle-hint::after { content: "▸"; transition: transform .15s ease; }
.cal-wrap[open] > summary .cal-toggle-hint::after { transform: rotate(90deg); }

/* ---------- Card grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
  text-decoration: none; color: inherit;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 34px -14px rgba(40, 38, 25, .3); }
.card-img { aspect-ratio: 4 / 3; overflow: hidden; background: var(--surface-2); position: relative; }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.card:hover .card-img img { transform: scale(1.04); }
.card-num {
  position: absolute; top: 10px; left: 10px;
  background: rgba(20, 22, 14, .72); color: #f7f4ec;
  font-size: .7rem; letter-spacing: .05em; padding: 3px 8px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.card-body { padding: 15px 16px 17px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0; line-height: 1.2; font-weight: 600; }
.card .sci { font-style: italic; color: var(--muted); font-size: .88rem; margin: -2px 0 0; }
.card .card-tagline { font-size: .85rem; color: var(--ink); margin: 2px 0 0; }
.card .bestbet {
  font-size: .8rem; color: var(--green-deep); margin-top: auto;
  border-top: 1px dashed var(--line-strong); padding-top: 9px;
}
.card .bestbet b { color: var(--green); font-weight: 600; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: .7rem; letter-spacing: .02em;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted);
  white-space: nowrap;
}
.chip.type { text-transform: capitalize; }
.chip.toxic { color: #fff; background: var(--berry); border-color: var(--berry); }
:root[data-theme="dark"] .chip.toxic { color: #241010; }
@media (prefers-color-scheme: dark) { .chip.toxic { color: #241010; } }
.chip.fit-excellent { color: #fff; background: var(--green); border-color: var(--green); }
.chip.fit-good { color: var(--green-deep); background: color-mix(in srgb, var(--green) 18%, transparent); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.chip.fit-fair { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.chip.fit-marginal, .chip.fit-poor { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: color-mix(in srgb, var(--amber) 12%, transparent); }
.chip.ripe { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: color-mix(in srgb, var(--gold) 12%, transparent); }

/* ---------- Detail page ---------- */
.backlink { display: inline-block; margin: 22px 0 4px; font-size: .85rem; color: var(--muted); text-decoration: none; }
.backlink:hover { color: var(--green); }
.detail-head { padding: 8px 0 22px; border-bottom: 1px solid var(--line); }
.detail-head h1 { font-family: var(--serif); font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 6px 0 4px; font-weight: 600; line-height: 1.08; }
.detail-head .sci { font-style: italic; color: var(--muted); font-size: 1.05rem; margin: 0 0 12px; }
.detail-head .sci .fam { font-style: normal; color: var(--faint); font-size: .85rem; }
.detail-head .detail-tagline { font-family: var(--serif); font-size: 1.1rem; max-width: 68ch; color: var(--ink); margin: 12px 0 0; }

.warnbar {
  display: flex; gap: 10px; align-items: flex-start;
  background: color-mix(in srgb, var(--berry) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--berry) 40%, transparent);
  color: var(--ink);
  border-radius: 10px; padding: 12px 15px; margin: 20px 0; font-size: .9rem;
}
.warnbar .icon { color: var(--berry); font-size: 1.1rem; line-height: 1.3; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 22px 0; }
.gallery button { padding: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; overflow: hidden; cursor: zoom-in; aspect-ratio: 1 / 1; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.gallery button:hover img { transform: scale(1.05); }

/* Reference photos (web imagery, e.g. iNaturalist) */
.refs { margin: 30px 0 6px; }
.refs-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.refs-head h2 { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; margin: 0; }
.refs-src { font-size: .8rem; color: var(--faint); }
.refs-note { font-size: .88rem; color: var(--muted); margin: 10px 0 4px; }
.refgallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.refcell { margin: 0; display: flex; flex-direction: column; }
.refcell button { padding: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px 10px 0 0; overflow: hidden; cursor: zoom-in; aspect-ratio: 1 / 1; }
.refcell img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.refcell button:hover img { transform: scale(1.05); }
.refcell figcaption { font-size: .68rem; color: var(--faint); padding: 4px 6px; background: var(--surface-2); border: 1px solid var(--line); border-top: none; border-radius: 0 0 10px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.refcell figcaption a { color: var(--faint); text-decoration: none; }
.refcell figcaption a:hover { color: var(--green); }
.lightbox .lb-src { color: #9ccb8f; margin-left: 4px; }

/* At-a-glance panels */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 26px 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.panel h2 {
  font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--green); margin: 0 0 12px; font-weight: 700;
  display: flex; align-items: center; gap: 7px;
}
.panel dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .88rem; }
.panel dt { color: var(--faint); white-space: nowrap; }
.panel dd { margin: 0; }
.panel .full { grid-column: 1 / -1; }
.flag { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.flag.yes { color: var(--green); }
.flag.no { color: var(--amber); }
.panel .note { margin: 10px 0 0; font-size: .84rem; color: var(--muted); }
.panel .bestbet-line { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-strong); font-size: .86rem; }
.panel .bestbet-line b { color: var(--green); }
.maplink { font-size: .82rem; }

/* Report body (rendered markdown) */
.report {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 30px 30px; margin: 26px 0; box-shadow: var(--shadow);
}
.report h2 { font-family: var(--serif); font-size: 1.4rem; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-weight: 600; }
.report h3 { font-family: var(--serif); font-size: 1.12rem; margin: 22px 0 8px; font-weight: 600; }
.report p, .report li { font-size: .95rem; }
.report a { word-break: break-word; }
.report blockquote {
  margin: 16px 0; padding: 10px 16px; border-left: 3px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 8%, transparent); border-radius: 0 8px 8px 0;
  color: var(--ink);
}
.report code { font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.report table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .85rem; display: block; overflow-x: auto; }
.report th, .report td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.report th { background: var(--surface-2); font-weight: 600; }
.report hr { border: none; border-top: 1px solid var(--line); margin: 26px 0; }
.report ul, .report ol { padding-left: 22px; }

/* ---------- Field guides (prospective "hunt list") ---------- */
/* Wants should read differently from haves: a dashed gold accent + a corner "TARGET"
   ribbon in place of the numeric collection badge. */
.card-guide { border-style: dashed; border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
.card-guide:hover { border-color: var(--gold); }
.card-guide .card-img { background: color-mix(in srgb, var(--gold) 8%, var(--surface-2)); }
.card-ribbon {
  position: absolute; top: 13px; left: -31px; transform: rotate(-45deg);
  background: var(--gold); color: #fff;
  font-size: .6rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  padding: 3px 36px; box-shadow: 0 1px 4px rgba(0, 0, 0, .28);
}
:root[data-theme="dark"] .card-ribbon { color: #241d08; }
@media (prefers-color-scheme: dark) { .card-ribbon { color: #241d08; } }

/* Status chips: hunting (gold, open) vs. found (green, solid) */
.chip.hunting { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: color-mix(in srgb, var(--gold) 12%, transparent); }
.chip.found { color: #fff; background: var(--green); border-color: var(--green); }
:root[data-theme="dark"] .chip.found { color: #10240f; }
@media (prefers-color-scheme: dark) { .chip.found { color: #10240f; } }

/* "You've collected this" cross-link banner on a found guide's detail page */
.statusbanner {
  display: flex; gap: 10px; align-items: center;
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--green) 40%, transparent);
  color: var(--ink);
  border-radius: 10px; padding: 12px 15px; margin: 20px 0; font-size: .9rem;
}
.statusbanner .icon { color: var(--green); font-size: 1.1rem; line-height: 1.2; }
.statusbanner a { font-weight: 600; }

/* Field ID checklist (id_key) — quick-scan on the trail */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: .88rem; }
.checklist li { position: relative; padding-left: 26px; }
.checklist li::before {
  content: "✓"; position: absolute; left: 0; top: 1px;
  width: 17px; height: 17px; border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--green) 55%, transparent);
  color: var(--green); font-size: .7rem; line-height: 16px; text-align: center;
}

/* Look-alikes — name ≠ the single deciding character */
.lookalikes { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: .86rem; }
.lookalikes li { position: relative; padding-left: 18px; }
.lookalikes li::before { content: "≠"; position: absolute; left: 0; top: 0; color: var(--amber); font-weight: 700; }
.lookalikes b { font-weight: 600; color: var(--ink); }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 30px; }
footer .wrap { padding: 26px 22px; color: var(--muted); font-size: .82rem; display: flex; flex-wrap: wrap; gap: 8px 26px; justify-content: space-between; }
footer a { color: var(--muted); }
footer .theme-toggle { background: none; border: 1px solid var(--line-strong); color: var(--muted); border-radius: 999px; padding: 3px 11px; font: inherit; font-size: .78rem; cursor: pointer; }
footer .theme-toggle:hover { color: var(--green); border-color: var(--green); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 11, 7, .93);
  display: none; align-items: center; justify-content: center; flex-direction: column;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 82vh; object-fit: contain; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox .caption { color: #e7e3d5; font-size: .85rem; margin-top: 14px; max-width: 80vw; text-align: center; }
.lightbox .lb-btn {
  position: absolute; background: rgba(255,255,255,.1); color: #fff; border: none;
  font-size: 1.8rem; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; line-height: 1;
}
.lightbox .lb-btn:hover { background: rgba(255,255,255,.22); }
.lb-prev { left: 3vw; } .lb-next { right: 3vw; } .lb-close { top: 3vh; right: 3vw; font-size: 1.4rem; width: 44px; height: 44px; }

.hidden { display: none !important; }
.empty-note { color: var(--muted); font-style: italic; padding: 20px 0; }

/* ---------- Request a field guide ---------- */
.request { max-width: 680px; padding: 34px 0 48px; }
.request-title { font-family: var(--serif); font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 600; margin: 8px 0 6px; line-height: 1.1; }
.request-note { color: var(--muted); font-size: .96rem; margin: 0 0 22px; max-width: 60ch; }
.request form { display: flex; flex-direction: column; gap: 12px; }
.request-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.request textarea {
  font: inherit; font-size: 1rem; line-height: 1.55;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 12px; padding: 14px 15px; resize: vertical; min-height: 160px;
  box-shadow: var(--shadow); width: 100%;
}
.request textarea:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: var(--green); }
.request textarea::placeholder { color: var(--faint); }
.request-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.request-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.request-submit {
  font: inherit; font-size: .92rem; font-weight: 600;
  background: var(--green); color: #fff; border: 1px solid var(--green);
  border-radius: 999px; padding: 10px 24px; cursor: pointer; transition: all .15s ease;
}
.request-submit:hover { background: var(--green-deep); border-color: var(--green-deep); }
.request-submit:disabled { opacity: .55; cursor: default; }
.request-status { font-size: .88rem; color: var(--muted); }
.request-status.ok { color: var(--green); }
.request-status.err { color: var(--berry); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .report { padding: 6px 18px 22px; }
  .cal-head, .cal-row { grid-template-columns: minmax(96px, 1.1fr) repeat(var(--months, 5), 1fr); }
  .search { margin-left: 0; width: 100%; }
  .request-submit { width: 100%; }
}
