/* Plant Witch. Spec: BRANDING.md. Order: tokens, base, primitives, shell, components, pages.
   The only place colors are defined. */
:root {
  --paper: #f7f0da; --paper-2: #efe3c0; --panel: #fffaf0; --ink: #2b1d0e; --ink-soft: #665536;
  --rule: #d8c89a; --magic: #6a3fb8; --leaf: #3f8a3a; --leaf-ink: #2f6b2c; --gold: #f2c230; --danger: #a3341f;
  --head: "Pixelify Sans", system-ui, sans-serif; --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --say: "VT323", ui-monospace, monospace;
}

/* base */
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.5 var(--body); }
a { color: var(--magic); }
:focus-visible { outline: 3px solid var(--magic); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.15; }
h1 { font-size: 28px; margin: 0 0 14px; overflow-wrap: anywhere; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 2px 4px; border-bottom: 2px dotted var(--rule); text-align: left; vertical-align: top; font-weight: 400; }
th { color: var(--ink-soft); }
caption { font: 600 18px/1.2 var(--head); color: var(--magic); text-align: left; padding: 0 0 6px; }
.latin { font-style: italic; color: var(--ink-soft); margin: 0; overflow-wrap: anywhere; }
.err { color: var(--danger); }
code { font: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* primitives */
.px { border: 0; margin: 2px;
  box-shadow: 0 -2px 0 0 var(--ink), 0 2px 0 0 var(--ink), -2px 0 0 0 var(--ink), 2px 0 0 0 var(--ink); }
.btn { display: inline-block; font: 600 16px/1 var(--head); background: var(--panel); color: var(--ink);
  padding: 12px 14px; min-height: 40px; cursor: pointer; text-decoration: none; }
.btn.go { background: var(--leaf-ink); color: var(--panel); }
input.px, select.px { font: 16px var(--body); background: var(--panel); color: var(--ink); padding: 4px 8px; min-height: 40px; }
.bar { display: inline-flex; gap: 2px; vertical-align: middle; margin-right: 6px; }
.bar i { width: 9px; height: 11px; background: var(--leaf); }
.bar i.off { background: transparent; box-shadow: inset 0 0 0 2px var(--rule); }
.slot { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; background: var(--paper); }
.sprite { display: block; flex: none; image-rendering: pixelated; }
.say { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 0; padding: 6px 12px; background: var(--panel); font: 20px/1.15 var(--say); }
.say[hidden] { display: none; }
.say p { margin: 0; flex: 1; }
.say p::after { content: " ▼"; color: var(--leaf-ink); animation: blink 1s steps(1) 10; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .say p::after { animation: none; } }
.box { background: var(--panel); padding: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin: 0 0 14px; }

/* shell */
div.site { display: grid; min-height: 100vh; grid-template-columns: 210px minmax(0, 1fr);
  grid-template-areas: "hd hd" "nav main" "ft ft"; grid-template-rows: auto 1fr auto; }
header.site { grid-area: hd; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 2px solid var(--ink); }
.logo { display: flex; align-items: center; gap: 10px; font: 600 24px/1 var(--head); color: var(--ink); text-decoration: none; }
.logo small { font-size: 15px; color: var(--magic); }
header.site .zone { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menubtn { display: none; }
aside.menu { grid-area: nav; display: flex; flex-direction: column; gap: 16px; padding: 16px 14px;
  background: var(--paper-2); border-right: 2px solid var(--ink); }
aside.menu h2 { font-size: 15px; margin: 0 0 6px; color: var(--magic); }
aside.menu ul { list-style: none; margin: 0; padding: 0; }
aside.menu li a { position: relative; display: block; min-height: 28px; padding: 2px 0 2px 16px; color: var(--ink); text-decoration: none; }
aside.menu li a:hover { text-decoration: underline; }
aside.menu a[aria-current]::before { content: "▶"; position: absolute; left: 0; top: .55em; font-size: .6em; color: var(--leaf-ink); }
aside.menu input { width: calc(100% - 8px); }
aside.menu summary { cursor: pointer; }
aside.menu summary a { display: inline-block; }
aside.menu details ul { padding-left: 12px; }
aside.menu small { color: var(--ink-soft); }
aside.menu .toolbar { margin: 0; }
main { grid-area: main; width: 100%; max-width: 1100px; padding: 18px; }
footer.site { grid-area: ft; display: flex; flex-wrap: wrap; gap: 4px 24px; padding: 8px 16px;
  border-top: 2px solid var(--ink); font-size: 18px; color: var(--ink-soft); }
footer.site a { color: var(--ink-soft); }
footer.site a:first-of-type { margin-left: auto; }
.sources { color: var(--ink-soft); }
@media (max-width: 700px) {
  div.site { grid-template-columns: minmax(0, 1fr); grid-template-areas: "hd" "nav" "main" "ft"; grid-template-rows: auto auto 1fr auto; }
  .menubtn { display: inline-block; }
  aside.menu { display: none; border-right: 0; border-bottom: 2px solid var(--ink); }
  body.menu-open aside.menu { display: flex; }
  header.site .zone span { display: none; }
  .logo { font-size: 20px; }
  header.site { flex-wrap: wrap; }
  header.site .say { order: 9; flex-basis: 100%; }
}

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; align-content: start; }
.grid.single { grid-template-columns: minmax(270px, 340px); }
/* Each card spans 3 subgrid rows (top, stats, facts) so those line up across a row of cards.
   Names wrap to 2 lines at most, latin to 2; table cells stay on one line (values are short buckets). */
.card { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 6px; padding: 12px; background: var(--panel); font-size: 16px; }
.card .top { display: flex; gap: 10px; align-items: center; min-width: 0; color: inherit; text-decoration: none; }
.card .top:hover h2 { text-decoration: underline; }
.card h2 { margin: 0; font-size: 20px; color: var(--magic); }
.card h2, .card .latin { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.card th { width: 6.5em; padding-right: 14px; white-space: nowrap; }
.card td { white-space: nowrap; }

/* requirement filters (index): pips are big buttons, "on" = up to that level */
.filterbar { margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { font: 15px/1 var(--body); background: var(--panel); color: var(--ink); padding: 6px 8px; min-height: 32px; cursor: pointer; }
.filters { max-width: 560px; margin: 0 0 18px; }
.filters th { width: 6em; vertical-align: middle; }
.fval { white-space: nowrap; }
.filters td { vertical-align: middle; }
.fpips { display: inline-flex; gap: 4px; vertical-align: middle; margin-right: 8px; }
.fpips button { width: 24px; height: 28px; padding: 0; border: 0; cursor: pointer; background: transparent; box-shadow: inset 0 0 0 3px var(--rule); }
.fpips button:hover { box-shadow: inset 0 0 0 3px var(--leaf); }
.fpips button.on { background: var(--leaf); box-shadow: none; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg button { font: 15px/1 var(--body); background: var(--panel); color: var(--ink); padding: 6px 8px; min-height: 32px; cursor: pointer; }
.seg button.on { background: var(--leaf-ink); color: var(--panel); }
.filters .more { margin: 10px 0 0; text-align: right; }
.hint { color: var(--ink-soft); font-size: 14px; padding-top: 0 !important; }
.seg.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; max-width: 320px; margin-top: 4px; }
.seg.months button { padding: 4px; text-align: center; }

/* plant page */
/* one vertical rhythm: every block on the page is 18px from the next */
.detail { display: flex; flex-direction: column; gap: 18px; }
.detail > * { margin: 0; }
.detail > :empty { display: none; }
.detail .sources { margin: 0; }
.detail h2 { font-size: 18px; margin: 0 0 8px; color: var(--magic); }
.detail .title { display: flex; gap: 14px; align-items: center; min-width: 0; }
.detail .title .slot { width: 64px; height: 64px; }
.detail .title .slot img { width: 48px; height: 48px; }
.detail h1 { margin: 0; }
.detail .title .zones { margin: 0 0 0 auto; font: 600 18px/1.2 var(--head); color: var(--magic); white-space: nowrap; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.cols .wide { grid-column: 1 / -1; overflow-x: auto; }
.cal th, .cal td { text-align: center; }
.cal td.cal-note { text-align: left; color: var(--ink-soft); }
.cal tr > :first-child { text-align: left; width: 6em; }
.cal td.on i { display: inline-block; width: 14px; height: 14px; background: var(--leaf); }
.cal tr.harvest td.on i { background: var(--gold); box-shadow: inset 0 0 0 2px var(--ink); }
.slots { display: flex; flex-wrap: wrap; gap: 14px; }
.slots a { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 84px;
  text-align: center; font-size: 18px; line-height: 1; color: var(--ink); text-decoration: none; }

/* sources page */
.prose { max-width: 72ch; }
.prose .box { margin: 0 0 16px; }
.prose h2 { margin-top: 0; }
.prose .cite { font-style: italic; color: var(--ink-soft); }
