/* Public Thai-herb encyclopedia. Palette from the book: deep green + gold on warm paper. */
:root {
  --bg: #f7f4ec;
  --paper: #fffdf8;
  --ink: #1d231e;
  --muted: #5f655c;
  --line: #e2dccd;
  --green: #1d5130;
  --green-2: #2f6b47;
  --green-soft: #e4eee5;
  --gold: #b58d2f;
  --gold-soft: #f4ead2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(29, 35, 30, .06), 0 6px 20px rgba(29, 35, 30, .07);
  --serif: "Noto Serif Thai", "Noto Serif", serif;
  --sans: Sarabun, "Noto Sans Thai", system-ui, sans-serif;
  --latin-serif: "Noto Serif", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16.5px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--green-2); }
a:hover { color: var(--green); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.3; color: var(--ink); }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 8px 12px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
i { font-family: var(--latin-serif); }

/* ---------- header / footer ---------- */
.site-head { position: sticky; top: 0; z-index: 20; background: rgba(247, 244, 236, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--green); font-family: var(--serif); font-weight: 700; font-size: 18px; }
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: 15px; }
.nav a { text-decoration: none; color: var(--ink); padding: 4px 0; }
.nav a:hover { color: var(--green); }
.nav-books { color: var(--green-2) !important; font-weight: 600; }

.site-foot { margin-top: 72px; background: var(--green); color: #e8efe7; padding: 40px 0 24px; }
.site-foot a { color: #fff; }
.site-foot .brand { color: #fff; }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 28px; }
.site-foot h2 { color: #fff; font-size: 16px; margin: 4px 0 8px; }
.site-foot ul { list-style: none; margin: 0; padding: 0; font-size: 15px; }
.site-foot li { margin: 4px 0; }
.site-foot p { font-size: 15px; color: #cfdccf; }
.disclaimer { border-top: 1px solid rgba(255, 255, 255, .18); margin-top: 24px; padding-top: 16px; font-size: 13.5px !important; }

/* ---------- hero: the walkable herb garden fills the whole section ---------- */
/* A little of the next section stays visible so people know the page continues
   (scroll gestures over the iframe go to the garden, not the page). */
.hero { position: relative; height: calc(100svh - 61px - 40px); min-height: 560px; overflow: hidden; background: #dfe7dc; border-bottom: 1px solid var(--line); }
.hero-scene { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.hero-overlay { position: absolute; left: max(16px, calc((100% - 1180px) / 2)); bottom: 92px; right: 16px; pointer-events: none; } /* clear of the scroll button */
.hero-card {
  pointer-events: auto; max-width: 470px; padding: 22px 24px 18px;
  background: rgba(255, 253, 248, .9); backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border: 1px solid rgba(29, 81, 48, .14); border-radius: 20px; box-shadow: 0 18px 50px -20px rgba(15, 40, 24, .55);
}
.eyebrow { margin: 0 0 4px; color: var(--gold); font-weight: 600; font-size: 13.5px; letter-spacing: .04em; }
.hero h1 { font-size: clamp(30px, 3.6vw, 44px); margin: 0 0 8px; color: var(--green); }
.lead { font-size: 17px; color: var(--muted); margin: 0 0 16px; max-width: 34em; }
.hero .lead { font-size: 15.5px; line-height: 1.6; }
.search { display: flex; background: var(--paper); border: 1.5px solid var(--line); border-radius: 999px; padding: 5px; box-shadow: var(--shadow); max-width: 560px; }
.search:focus-within { border-color: var(--green-2); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 17px; padding: 8px 16px; outline: none; color: var(--ink); }
.search button { border: 0; border-radius: 999px; background: var(--green); color: #fff; font: inherit; font-weight: 600; padding: 8px 22px; cursor: pointer; }
.search button:hover { background: var(--green-2); }
.stats { display: flex; gap: 20px; list-style: none; padding: 0; margin: 14px 0 0; color: var(--muted); font-size: 14.5px; }
.stats b { font-family: var(--serif); font-size: 22px; color: var(--green); margin-right: 4px; }
.hero-open, .scroll-cue {
  position: absolute; z-index: 2; text-decoration: none; font-size: 14.5px; font-weight: 600;
  background: rgba(255, 253, 248, .9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(29, 81, 48, .14); border-radius: 999px; padding: 7px 14px; color: var(--green);
  box-shadow: 0 8px 24px -12px rgba(15, 40, 24, .5);
}
.hero-open { right: max(16px, calc((100% - 1180px) / 2)); bottom: 28px; }
/* The way out of the garden: big, solid green with a gold ring so it reads against any scene. */
.scroll-cue {
  left: 50%; bottom: 18px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 26px 12px 30px; font-size: 18px; font-weight: 700; letter-spacing: .01em;
  background: var(--green); color: #fff; border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px rgba(181, 141, 47, .28), 0 14px 32px -10px rgba(15, 40, 24, .7);
  animation: glow 2.4s ease-in-out infinite;
}
.scroll-cue span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #fff; font-size: 16px; animation: nudge 1.6s ease-in-out infinite; }
.scroll-cue:hover { background: var(--green-2); color: #fff; transform: translateX(-50%) translateY(-2px); }
@keyframes nudge { 50% { transform: translateY(4px); } }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgba(181, 141, 47, .12), 0 14px 32px -10px rgba(15, 40, 24, .7); } }
.hero-open:hover { background: #fff; color: var(--green); }

/* ---------- categories ---------- */
.cats h2, .browse h2, .catpage h1 { color: var(--green); }
.cats h2 { font-size: 26px; margin: 44px 0 14px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s; }
.cat:hover { border-color: var(--green-2); transform: translateY(-2px); color: var(--ink); }
.cat b { font-family: var(--serif); font-size: 17px; }
.cat span { color: var(--muted); font-size: 14px; }

/* ---------- browse: filters + cards ---------- */
.browse { margin-top: 40px; }
.browse-head { display: flex; align-items: baseline; gap: 12px 18px; flex-wrap: wrap; margin-bottom: 14px; }
.browse-head h2 { font-size: 26px; margin: 0; }
.result-count { margin: 0; color: var(--muted); }
.browse-tools { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.sort { font-size: 15px; color: var(--muted); }
.sort select, .filter-toggle { font: inherit; font-size: 15px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.filter-toggle { display: none; cursor: pointer; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; }
.active-filters button { font: inherit; font-size: 14px; border: 0; border-radius: 999px; background: var(--green-soft); color: var(--green); padding: 3px 12px; cursor: pointer; }
.active-filters button::after { content: " ✕"; }

.browse-grid { display: grid; grid-template-columns: 250px 1fr; gap: 28px; align-items: start; }
.filters { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.filters-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.filters-head b { font-family: var(--serif); flex: 1; }
.filters-head .clear { font: inherit; font-size: 14px; border: 0; background: none; color: var(--green-2); cursor: pointer; padding: 0; }
.filters-head .close { display: none; }
.fgroup { border: 0; padding: 10px 0 6px; margin: 0; border-top: 1px solid var(--line); }
.fgroup:first-of-type { border-top: 0; }
.fgroup legend { font-weight: 700; font-size: 14.5px; padding: 0 0 4px; }
.fopt { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 15px; cursor: pointer; }
.fopt input { accent-color: var(--green); width: 16px; height: 16px; margin: 0; }
.fopt span { flex: 1; }
.fopt small { color: var(--muted); font-size: 13px; }
.fopt .fam { font-size: 13px; letter-spacing: .03em; }
.fscroll { max-height: 220px; overflow: auto; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.cards-4 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.card { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; transition: transform .18s, box-shadow .18s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card[hidden] { display: none; }
.card-link { display: block; text-decoration: none; color: inherit; flex: 1; }
.card-img { aspect-ratio: 4 / 3; background: #e7ebe2; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 6px; }
.card h3 { margin: 0; font-size: 19px; }
.card .sci { margin: 0; font-size: 14px; color: var(--muted); }
.card .sum { margin: 6px 0 0; font-size: 14.5px; line-height: 1.55; color: #3b423a; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px 14px; }
.chip { display: inline-block; font-size: 13px; line-height: 1.4; padding: 2px 10px; border-radius: 999px; background: var(--green-soft); color: var(--green); text-decoration: none; white-space: nowrap; }
.chip-part { background: var(--gold-soft); color: #7a5c14; }
.chip-form { background: #ece9f3; color: #4b4366; }
a.chip:hover { filter: brightness(.96); }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }
.linkish { font: inherit; border: 0; background: none; color: var(--green-2); text-decoration: underline; cursor: pointer; padding: 0 4px; }

/* ---------- herb page ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 24px 0 8px; font-size: 14px; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--muted); }
.herb-head h1 { font-size: clamp(34px, 5vw, 48px); margin: 0; color: var(--green); }
.herb-head .en { margin: 0; font-size: 18px; color: var(--muted); }
.herb-head .sci { margin: 2px 0 0; font-size: 19px; }
.herb-head .fam { font-size: 14px; letter-spacing: .06em; color: var(--muted); }
.herb-sum { margin: 14px 0 0; font-size: 18px; max-width: 46em; padding-left: 14px; border-left: 3px solid var(--gold); }
.herb-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 28px; margin-top: 26px; align-items: start; }
.herb-photos { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 10px; }
.herb-photos .ph { display: block; border-radius: var(--radius); overflow: hidden; background: #e7ebe2; }
.herb-photos .ph img { width: 100%; height: 100%; object-fit: cover; }
.herb-photos .ph-0 { grid-column: 1 / span 2; aspect-ratio: 4 / 3; }
.herb-photos .ph-1, .herb-photos .ph-2 { aspect-ratio: 4 / 3; }
.facts { margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 18px; }
.facts div { display: grid; grid-template-columns: 112px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt { font-weight: 700; font-size: 15px; color: var(--green); }
.facts dd { margin: 0; font-size: 15.5px; }
.herb-section { margin-top: 34px; max-width: 820px; }
.herb-section h2 { font-size: 24px; margin: 0 0 10px; color: var(--green); }
.herb-section p { margin: 0 0 12px; font-size: 17.5px; line-height: 1.85; }
.herb-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.refs p { font-size: 15.5px !important; color: var(--muted); }
.refs a { word-break: break-all; }
.caution { margin-top: 30px; max-width: 820px; background: var(--gold-soft); border: 1px solid #ead9ad; border-radius: var(--radius); padding: 12px 16px; font-size: 15px; color: #5d4710; }
.herb .cards { max-width: none; }
.herb-section:has(.cards) { max-width: none; }

/* ---------- category page ---------- */
.catpage h1 { font-size: clamp(30px, 4.5vw, 42px); margin: 0 0 6px; }
.catpage .lead { margin-bottom: 24px; }
.other-cats { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.other-cats h2 { width: 100%; font-size: 20px; margin: 0 0 4px; color: var(--green); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
    .herb-grid { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-grid > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .browse-grid { grid-template-columns: 1fr; }
  .filter-toggle { display: inline-block; }
  .filters { position: fixed; inset: 0 0 0 auto; width: min(340px, 88vw); max-height: none; top: 0; border-radius: 0; z-index: 40; transform: translateX(100%); visibility: hidden; transition: transform .2s, visibility 0s .2s; padding-top: 18px; }
  .filters.open { transform: none; visibility: visible; transition: transform .2s; box-shadow: -10px 0 30px rgba(0, 0, 0, .15); }
  .filters-head .close { display: inline-block; border: 0; background: none; font-size: 20px; cursor: pointer; padding: 0 4px; }
  .nav { font-size: 14px; gap: 2px 14px; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .hero { height: calc(100svh - 61px - 64px); min-height: 520px; }
  .hero-overlay { left: 12px; right: 12px; bottom: 78px; }
  .scroll-cue { font-size: 16.5px; padding: 10px 20px 10px 24px; bottom: 16px; white-space: nowrap; }
  .hero-card { padding: 16px 16px 12px; border-radius: 16px; }
  .hero .lead, .eyebrow { display: none; }
  .hero h1 { font-size: 26px; margin-bottom: 10px; }
  .stats { margin-top: 10px; gap: 14px; font-size: 13.5px; }
  .stats b { font-size: 18px; }
  .hero-open { display: none; } /* the header already links to the garden; this would cover its own menu */
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card h3 { font-size: 17px; }
  .card .sum { display: none; }
  .card-body { padding: 10px 10px 4px; }
  .card-tags { padding: 6px 10px 10px; }
  .search button { padding: 8px 16px; }
  .facts div { grid-template-columns: 96px 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
