/* Native Plant Finder. Site tokens come from /root.css; map colours match Flora's static maps
   (STYLE in flora-map.js): present #10b981, state tint #c9efe0, hatch #9aa39c, borders #064e3b. */

.npf {
    --npf-present: #10b981;
    --npf-tint: #c9efe0;
    --npf-norec: #9aa39c;
    --npf-ink: #064e3b;
    --npf-home: var(--secondary-dark);
    max-width: 1440px;
    margin: 0 auto;
    padding: 8px 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: var(--special);
    color: var(--black);
}

/* Author `display` rules would otherwise override the hidden attribute. */
.npf [hidden] { display: none !important; }

.npf a { text-decoration: underline; color: var(--primary-dark); }
.npf i { font-style: italic; }
.npf button { font: inherit; cursor: pointer; }
.npf button:disabled { cursor: default; opacity: 0.5; }
.npf :focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

.npf-label {
    display: block;
    font-size: 0.8125em;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.npf-button {
    background: var(--primary-dark);
    color: var(--white);
    border: 2px solid var(--primary-dark);
    border-radius: 4px;
    padding: 0 16px;
    font-weight: 600;
    box-shadow: var(--subtleShadow);
}
.npf-button:hover { background: var(--primary); border-color: var(--primary); }

/* ------------------------------------------------------------- search bar */

.npf-searchbar {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.npf-search { position: relative; flex: 1 1 320px; max-width: 560px; }
/* styles.css makes every form a flex row; this one stacks its label. */
.npf-zipform { flex: 0 0 auto; display: block; margin-top: 0; }
.npf-zipfield { display: flex; gap: 6px; height: 40px; }

.npf input[type="text"] {
    height: 40px;
    width: 100%;
    box-sizing: border-box;
    border: 2px solid var(--primary-dark);
    border-radius: 4px;
    padding: 0 10px;
    background: var(--white);
}
#npf-zip { width: 7.5em; }

.npf-suggestions {
    position: absolute;
    z-index: 50;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 420px;
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    background: var(--white);
    border-radius: 4px;
    box-shadow: var(--standardShadow);
}
.npf-suggestions li {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
}
.npf-suggestions li[aria-selected="true"], .npf-suggestions li:hover { background: var(--primary-x-light); }
.npf-suggestions li.npf-empty { cursor: default; color: var(--neutral-dark); }
.npf-suggestions img, .npf-suggestions .npf-noimg { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; flex: none; }
.npf-suggestions li > span { display: flex; flex-direction: column; }

.npf-noimg {
    display: inline-block;
    background: var(--neutral-light) url("/assets/images/leaf-outline.svg") center / 55% no-repeat;
}

.npf-notice-bar {
    margin: 0;
    padding: 8px 12px;
    border-left: 4px solid var(--yellow);
    background: var(--background);
}

/* ------------------------------------------------------------- layout */

.npf-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
    gap: 16px;
    align-items: start;
}

.npf-mapcol { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.npf-panel {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--standardShadow);
    padding: 16px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* ------------------------------------------------------------- map */

.npf-mapwrap {
    position: relative;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--standardShadow);
    overflow: hidden;
}

.npf-map { aspect-ratio: 975 / 610; }
.npf-map > .npf-loading, .npf-map > .npf-error { padding: 24px; }

.npf-map-svg {
    display: block;
    width: 100%;
    height: 100%;
    user-select: none;
    -webkit-user-select: none;
}
.npf-map-svg.npf-zoomed { cursor: grab; }
.npf-map-svg.npf-panning { cursor: grabbing; }

.npf-counties path { fill: transparent; cursor: pointer; }
.npf-counties path.npf-norec { fill: url(#npf-norec); }
.npf-counties path.npf-present { fill: var(--npf-present); }

.npf-county-mesh, .npf-state-mesh, .npf-outline { fill: none; pointer-events: none; vector-effect: non-scaling-stroke; }
/* County lines are darker here than in the shared renderer's STYLE.countyBorder (#d6dcd6), which was
   tuned for the static 975 px images and nearly disappears on screen. A translucent dark green
   darkens whatever it crosses, so it reads on the pale land and on painted (green) counties alike. */
.npf-county-mesh { stroke: #064e3b; stroke-width: 0.75; stroke-opacity: 0.55; }
/* County lines are noise at full view; they fade in as the map zooms. */
.npf-map-svg:not(.npf-zoomed) .npf-county-mesh { stroke-width: 0.45; stroke-opacity: 0.28; }
.npf-state-mesh { stroke-width: 1.1; stroke-opacity: 0.6; stroke-linejoin: round; }
.npf-outline { stroke-linejoin: round; }
.npf-outline-selected { stroke: var(--npf-ink); stroke-width: 2.5; }
.npf-outline-home { stroke: var(--npf-home); stroke-width: 2.5; stroke-dasharray: 5 3; }
.npf-outline-hover { stroke: var(--black); stroke-width: 1.5; }
.npf-land { pointer-events: none; }

.npf-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 260px;
    padding: 6px 10px;
    background: var(--white);
    border-radius: 4px;
    box-shadow: var(--standardShadow);
    font-size: 0.875em;
    line-height: 1.3;
}
.npf-tip-muted { color: var(--neutral-dark); }
.npf-tip-yes { color: var(--npf-ink); font-weight: 600; }

.npf-mapctl {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: flex;
    gap: 4px;
}
.npf-mapctl button {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: var(--white);
    border: 1px solid var(--neutral);
    border-radius: 4px;
    box-shadow: var(--subtleShadow);
    font-size: 1em;
    font-weight: 600;
}
.npf-mapctl button:hover { background: var(--primary-x-light); }
.npf-mapctl .npf-reset { font-size: 0.8125em; }

.npf-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    font-size: 0.8125em;
    color: var(--npf-ink);
}
.npf-legend span { display: inline-flex; align-items: center; gap: 6px; }
.npf-swatch { display: inline-block; width: 18px; height: 12px; }
.npf-sw-present { background: var(--npf-present); }
.npf-sw-tint { background: var(--npf-tint); }
.npf-sw-norec {
    background: repeating-linear-gradient(45deg, var(--npf-norec) 0 1.2px, transparent 1.2px 5px);
    outline: 0.5px solid #b9c2bb;
}
.npf-sw-home { border: 2px dashed var(--npf-home); box-sizing: border-box; }

.npf-pickers { display: flex; gap: 12px; flex-wrap: wrap; }
.npf-pickers label { flex: 1 1 200px; }

.npf select {
    width: 100%;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--neutral-dark);
    border-radius: 4px;
    background: var(--white);
    font: inherit;
    font-size: 0.9375em;
}

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

.npf-panel h2 { font-size: 1.5em; margin: 4px 0 2px; }
.npf-panel h2:focus { outline: none; }
.npf-panel h3 {
    font-size: 1em;
    font-weight: 600;
    color: var(--primary-dark);
    margin: 16px 0 6px;
}
.npf-panel p { margin: 6px 0; line-height: 1.4; }
.npf-note { color: #4d4d4d; font-size: 0.9375em; }
.npf-loading { color: var(--neutral-dark); }

.npf-intro ol { margin: 12px 0 12px 20px; list-style: decimal; }
.npf-intro li { margin: 8px 0; line-height: 1.4; }

.npf-back {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary-dark);
    text-decoration: underline;
    margin-bottom: 8px;
}

.npf-photo { margin: 0; }
.npf-photo img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 6px;
    background: var(--neutral-light);
}
.npf-photo-none {
    aspect-ratio: 4 / 3;
    display: grid;
    place-items: center;
    background: var(--neutral-light);
    border-radius: 6px;
    color: var(--neutral-dark);
}
.npf-credit { font-size: 0.75em; color: #4d4d4d; margin-top: 4px; line-height: 1.3; }

.npf-thumbs { display: flex; gap: 6px; margin-top: 6px; }
.npf-thumb { padding: 0; border: 2px solid transparent; border-radius: 4px; background: none; }
.npf-thumb[aria-pressed="true"] { border-color: var(--npf-present); }
.npf-thumb img { display: block; width: 52px; height: 52px; object-fit: cover; border-radius: 2px; }

.npf-sci { color: #4d4d4d; }
.npf-aka { font-size: 0.875em; color: #4d4d4d; }

.npf-status { display: flex; flex-wrap: wrap; gap: 6px; }
.npf-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--primary-x-light);
    color: var(--primary-dark);
    font-size: 0.8125em;
    font-weight: 600;
}
.npf-badge-muted { background: var(--neutral-light); color: #4d4d4d; }

.npf-near {
    margin-top: 12px;
    padding: 4px 12px;
    border-left: 4px solid var(--npf-home);
    background: var(--secondary-x-light);
}
.npf-near h3 { margin-top: 6px; }
.npf-yes { color: var(--npf-ink); font-weight: 600; }

.npf-facts dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 0.9375em; }
.npf-facts dt { color: #4d4d4d; }
.npf-habitat { font-size: 0.9375em; }

.npf-safety .npf-warn { font-weight: 600; color: var(--red-dark); }
.npf-safety ul { list-style: disc; margin: 4px 0 4px 20px; font-size: 0.9375em; }
.npf-notice {
    font-size: 0.8125em;
    padding: 8px 10px;
    background: var(--background-light);
    border: 1px solid var(--background-dark);
    border-radius: 4px;
}

.npf-cta {
    margin-top: 16px !important;
    padding: 10px 12px;
    background: var(--primary-x-light);
    border-radius: 6px;
    font-size: 0.9375em;
}

.npf-home {
    padding: 8px 12px;
    margin-bottom: 8px;
    border-left: 4px solid var(--npf-home);
    background: var(--secondary-x-light);
}
.npf-home p { margin: 2px 0; }
.npf-home-title { font-weight: 600; }

.npf-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin: 10px 0;
}
.npf-filters span { display: block; font-size: 0.75em; font-weight: 600; color: #4d4d4d; margin-bottom: 2px; }
.npf-filters select { height: 32px; font-size: 0.875em; }

.npf-count { font-weight: 600; }

.npf-plants { list-style: none; margin: 8px 0; padding: 0; }
.npf-plants li + li { border-top: 1px solid var(--neutral-light); }
.npf-plants button {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 6px 4px;
    background: none;
    border: none;
    text-align: left;
    border-radius: 4px;
}
.npf-plants button:hover { background: var(--primary-x-light); }
.npf-plants img, .npf-plants .npf-noimg { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; flex: none; }
.npf-plant-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.npf-plant-name { font-weight: 600; }
.npf-plant-text i, .npf-suggestions i { font-size: 0.875em; color: #4d4d4d; }
.npf-plant-facts { font-size: 0.8125em; color: #4d4d4d; }

.npf-pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; }
.npf-pager button {
    padding: 6px 10px;
    background: var(--white);
    border: 1px solid var(--neutral-dark);
    border-radius: 4px;
}

.npf-error { padding: 12px; border-left: 4px solid var(--red); background: var(--red-x-light); }
.npf-error .npf-button { height: 36px; }

.npf-turnstile { display: flex; justify-content: center; margin: 12px 0; }

.npf-attribution {
    margin: 0;
    font-size: 0.8125em;
    color: #4d4d4d;
    text-align: center;
}

.npf-about {
    margin: 4px auto 0;
    max-width: 820px;
    padding: 8px 16px;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--subtleShadow);
    font-size: 0.9375em;
}
.npf-about summary { cursor: pointer; font-weight: 600; color: var(--primary-dark); }
.npf-about p { margin: 8px 0; line-height: 1.45; }

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

@media (max-width: 900px) {
    .npf-body { grid-template-columns: minmax(0, 1fr); }
    .npf-panel { max-height: none; overflow: visible; }
}

@media (max-width: 480px) {
    .npf { padding: 8px 12px 16px; }
    .npf-search { flex-basis: 100%; }
    .npf-mapctl button { min-width: 36px; height: 36px; }
    .npf-panel { padding: 12px; }
}
