/* Site-wide menu, search and Back (assets/site.js). Loaded on every page, before polish.css. */
:root { --sbb: 0px; }

/* ---------- Header ---------- */
.nav { gap: .6rem; min-height: 52px; }
.nav > .brand { flex: none; }
.nav > nav[aria-label="Sections"] { flex: 1 1 auto; }
.nav .sb-tabs { display: flex; align-items: center; gap: 2px; padding: 3px; margin-left: auto; border: 1px solid var(--line); border-radius: 999px; background: rgba(251, 248, 242, .8); flex: none; }
.nav .sb-tabs a { display: flex; align-items: center; gap: .35rem; min-height: 36px; padding: 0 .8rem; border-radius: 999px; text-decoration: none; font: 500 .82rem var(--sans); color: var(--ink-2); white-space: nowrap; transition: background .2s, color .2s; }
.nav .sb-tabs a::after { content: none; }
.nav .sb-tabs a i { font-style: normal; font-size: .95rem; }
.nav .sb-tabs .s { display: none; }
@media (max-width: 1240px) { .nav .sb-tabs .f { display: none; } .nav .sb-tabs .s { display: inline; } }
@media (max-width: 1560px) { .pg-home .nav .sb-tabs .f { display: none; } .pg-home .nav .sb-tabs .s { display: inline; } .pg-home .nav .sb-tabs a { padding: 0 .65rem; } }
.nav .sb-tabs a:hover { background: var(--paper-2); color: var(--ink); }
.nav .sb-tabs a.on { background: var(--ink); color: var(--paper); }
.pg-home .nav > nav[aria-label="Sections"] + .sb-tabs { margin-left: 0; }

/* Search: an input in the header on wide screens; on phones a bar across the top, opened by 🔍 */
.sb-search { position: relative; flex: 0 1 260px; min-width: 210px; margin: 0; }
.sb-in { display: flex; align-items: center; gap: .4rem; height: 40px; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); transition: border-color .2s, box-shadow .2s; cursor: text; }
.sb-in:focus-within { border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(242, 106, 27, .18); }
.sb-in i { font-style: normal; font-size: .85rem; opacity: .7; }
.sb-in input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 16px var(--sans); color: var(--ink); padding: 0; }
.sb-in input::placeholder { color: var(--muted); font-size: .86rem; }
.sb-in input::-webkit-search-cancel-button { -webkit-appearance: none; }
.sb-x, .sb-open { display: none; }
.sb-list { position: absolute; top: calc(100% + 6px); right: 0; width: min(440px, 92vw); max-height: min(70vh, 520px); overflow-y: auto; overscroll-behavior: contain; padding: .35rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card); box-shadow: 0 24px 60px rgba(60, 35, 10, .22); z-index: 60; }
.sb-list[hidden] { display: none; }
.sb-r { display: flex; align-items: center; gap: .7rem; padding: .55rem .6rem; border-radius: 10px; text-decoration: none; color: var(--ink); }
.sb-r:hover, .sb-r.sel { background: var(--paper-2); }
.sb-r > i { flex: none; display: grid; place-content: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--paper); font-style: normal; font-size: 1rem; }
.sb-r.m > i { background: #FDE9DB; }
.sb-r > span { display: grid; min-width: 0; }
.sb-r b { font: 500 .92rem/1.25 var(--sans); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sb-r small { font: .7rem var(--mono); letter-spacing: .03em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-none { margin: .3rem .6rem .5rem; font-size: .88rem; color: var(--ink-2); }

/* Back: after a search took you somewhere */
.sb-back { display: inline-flex; align-items: center; gap: .3rem; flex: none; height: 36px; padding: 0 .8rem 0 .6rem; border: 0; border-radius: 999px; background: var(--saffron-btn); color: #fff; font: 600 .8rem var(--sans); cursor: pointer; }
.sb-back b { font-size: 1rem; line-height: 1; }
.sb-back[hidden] { display: none; }

/* Home: on mid-size screens the section links take their own row under the brand, tabs and search */
html { scroll-padding-top: calc(var(--hdrh, 52px) + 8px); }
.dx-nav { top: calc(var(--hdrh, 50px) + 10px); }
@media (max-width: 1100px) and (min-width: 761px) {
  .pg-home .nav { flex-wrap: wrap; row-gap: 0; }
  .pg-home .nav > nav[aria-label="Sections"] { order: 5; flex-basis: 100%; }
  .pg-home .nav > .sb-tabs { margin-left: auto; }
}

/* ---------- Phones: tabs move to a bottom bar; search becomes a 🔍 button that opens a bar across the top ---------- */
.sb-bar { display: none; }
@media (max-width: 760px) {
  :root { --sbb: 56px; }
  .nav .sb-tabs, .nav > .sb-search { display: none; }
  .sb-open { display: grid; place-content: center; flex: none; width: 40px; height: 40px; margin-left: auto; border: 1px solid var(--line); border-radius: 50%; background: var(--card); font-size: 1rem; cursor: pointer; }
  .pg-home .sb-open { margin-left: 0; }
  .sb-on .nav > .sb-search { display: flex; align-items: center; gap: .4rem; position: fixed; left: 0; right: 0; top: 0; z-index: 70; min-width: 0; padding: .5rem .6rem; background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: 0 10px 30px rgba(60, 35, 10, .15); }
  .sb-on .sb-in { flex: 1; }
  .sb-on .sb-x { display: grid; place-content: center; flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--paper-2); font-size: 1rem; color: var(--ink); cursor: pointer; }
  .sb-list { position: fixed; top: 58px; left: 0; right: 0; width: auto; max-height: calc(100vh - 58px - var(--sbb)); max-height: calc(100dvh - 58px - var(--sbb)); border-radius: 0 0 14px 14px; border-width: 0 0 1px; }
  .sb-back span { display: none; }
  .sb-back { width: 36px; padding: 0; justify-content: center; }

  .sb-bar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: var(--sbb); padding-bottom: env(safe-area-inset-bottom); background: rgba(251, 248, 242, .97); backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-sizing: content-box; }
  .sb-bar a, .sb-bar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; padding: 0 2px; border: 0; background: none; text-decoration: none; color: var(--ink-2); font: 500 .66rem/1.1 var(--sans); cursor: pointer; text-align: center; }
  .sb-bar i { font-style: normal; font-size: 1.15rem; line-height: 1.2; filter: grayscale(.6); opacity: .8; }
  .sb-bar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sb-bar a.on { color: var(--saffron-ink); font-weight: 600; }
  .sb-bar a.on i { filter: none; opacity: 1; }
  .sb-bar a.on::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px; background: var(--saffron); }
  body.sb-has-bar { padding-bottom: calc(var(--sbb) + env(safe-area-inset-bottom)); }
  /* Home's fixed bottom pieces sit above the bar */
  .road { bottom: calc(var(--sbb) + env(safe-area-inset-bottom)); }
  .tm { bottom: calc(1rem + var(--sbb)); }
  .tm:not(.show) { transform: translate(-50%, calc(150% + var(--sbb) + 1rem)); }
  body.road-on .tm { bottom: calc(58px + var(--sbb)); }
  #toast { bottom: calc(5rem + var(--sbb)); }
  body.road-on #toast { bottom: calc(9rem + var(--sbb)); }
}
@media (max-width: 380px) { .sb-bar a, .sb-bar button { font-size: .6rem; } }
