/* ==========================================================================
   YehNav: pages (hash routing) + sidebar rail / drawer
   Tokens come from the page (:root --yh-*), with neutral fallbacks.
   ========================================================================== */
:root { --yh-rail: 76px; --yh-rail-wide: 272px; --yh-nav-top: 72px; }

/* ---- pages mode: only the active page's sections are shown (JS adds html.yh-pages) ---- */
html.yh-pages [data-yh-page]:not(.yh-pg-on) { display: none !important; }
[data-yh-page] [id] { scroll-margin-top: calc(var(--yh-nav-top) + 16px); }
.yh-pg-in { animation: yhPgIn .55s cubic-bezier(.2,.7,.2,1) both; }
@keyframes yhPgIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---- docked rail pushes the page ---- */
html.yh-dock body { padding-left: var(--yh-rail); }

/* ---- the sidebar ---- */
.yh-nav {
  position: fixed; left: 0; top: var(--yh-nav-top); bottom: 118px; z-index: 950; /* stops above the chat launcher corner */
  width: var(--yh-rail); max-width: 100vw;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--yh-paper, #f7f2e8) 94%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-right: 1px solid color-mix(in srgb, var(--yh-ink, #1b2240) 12%, transparent);
  box-shadow: 0 10px 30px -18px rgba(0,0,0,.35);
  color: var(--yh-ink, #1b2240);
  font-family: var(--yh-sans, system-ui, sans-serif);
  transition: width .28s cubic-bezier(.2,.7,.2,1), transform .32s cubic-bezier(.2,.7,.2,1);
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.yh-nav.is-wide, .yh-nav:hover, .yh-nav:focus-within { width: var(--yh-rail-wide); }
.yh-nav__hd { display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 3px 10px 3px 14px; border-bottom: 1px solid color-mix(in srgb, var(--yh-ink, #1b2240) 10%, transparent); }
.yh-nav__tg {
  flex: 0 0 auto; width: 44px; height: 44px; display: inline-grid; place-items: center;
  border: 0; border-radius: 999px; background: transparent; color: inherit; cursor: pointer; font: inherit;
}
.yh-nav__tg:hover { background: color-mix(in srgb, var(--yh-accent, #7b1e35) 10%, transparent); }
.yh-nav__tg svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.yh-nav__ttl { white-space: nowrap; opacity: 0; transform: translateX(-6px); transition: opacity .2s, transform .25s; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: .72rem; color: var(--yh-muted, #5e6478); }
.yh-nav.is-wide .yh-nav__ttl, .yh-nav:hover .yh-nav__ttl, .yh-nav:focus-within .yh-nav__ttl { opacity: 1; transform: none; }

.yh-nav__list { list-style: none; margin: 0; padding: 4px 0; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.yh-nav__a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 2px 12px 2px 0;
  color: inherit; text-decoration: none; position: relative; white-space: nowrap;
}
.yh-nav__a::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--yh-accent, #7b1e35); transform: scaleY(0); transition: transform .2s; }
.yh-nav__a:hover { background: color-mix(in srgb, var(--yh-accent, #7b1e35) 7%, transparent); }
/* "you are here": tinted row, solid bar, bold label, plus a "You are here" tag when expanded */
.yh-nav__a[aria-current="page"] { color: var(--yh-accent, #7b1e35); background: color-mix(in srgb, var(--yh-accent, #7b1e35) 13%, transparent); }
.yh-nav__a[aria-current="page"]::before { transform: none; width: 4px; }
.yh-nav__a[aria-current="page"] .yh-nav__ab { font-weight: 700; }
.yh-nav__a[aria-current="page"] .yh-nav__lbl { font-weight: 700; }
/* collapsed rail: short English label */
.yh-nav__ab {
  flex: 0 0 var(--yh-rail); width: var(--yh-rail); padding: 0 6px; text-align: center; white-space: normal;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: .7rem; font-weight: 600; line-height: 1.15; letter-spacing: .01em;
}
.yh-nav__ab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.yh-nav__here { display: none; align-self: flex-start; margin-top: 4px; padding: 2px 8px; border-radius: 999px; background: var(--yh-accent, #7b1e35); color: #fff; font-size: .64rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.yh-nav__a[aria-current="page"] .yh-nav__here { display: inline-block; }
/* expanded rail and drawer: the full label replaces the short one */
.yh-nav.is-wide .yh-nav__ab, .yh-nav:hover .yh-nav__ab, .yh-nav:focus-within .yh-nav__ab, html:not(.yh-dock) .yh-nav .yh-nav__ab { display: none; }
.yh-nav.is-wide .yh-nav__lbl, .yh-nav:hover .yh-nav__lbl, .yh-nav:focus-within .yh-nav__lbl, html:not(.yh-dock) .yh-nav .yh-nav__lbl { padding-left: 22px; }
.yh-nav__lbl { display: flex; flex-direction: column; line-height: 1.2; font-size: .95rem; font-weight: 500; opacity: 0; transform: translateX(-6px); transition: opacity .18s, transform .25s; }
.yh-nav__lbl small { font-size: .74rem; font-weight: 400; color: var(--yh-muted, #5e6478); margin-top: 2px; }
.yh-nav.is-wide .yh-nav__lbl, .yh-nav:hover .yh-nav__lbl, .yh-nav:focus-within .yh-nav__lbl { opacity: 1; transform: none; }

.yh-nav__ft { border-top: 1px solid color-mix(in srgb, var(--yh-ink, #1b2240) 10%, transparent); padding: 8px 0; display: flex; flex-direction: column; gap: 2px; }
.yh-nav__call { display: flex; align-items: center; gap: 12px; min-height: 48px; color: var(--yh-accent, #7b1e35); text-decoration: none; font-weight: 600; white-space: nowrap; }
.yh-nav__call:hover { background: color-mix(in srgb, var(--yh-accent, #7b1e35) 8%, transparent); }
.yh-nav__mode { display: flex; align-items: center; gap: 12px; min-height: 44px; border: 0; background: transparent; color: var(--yh-muted, #5e6478); cursor: pointer; font: inherit; font-size: .82rem; padding: 0; white-space: nowrap; text-align: left; }
.yh-nav__mode:hover { color: var(--yh-ink, #1b2240); }

/* ---- drawer mode (below 1100px): hidden rail + edge tab + backdrop ---- */
.yh-nav__tab {
  position: fixed; left: 0; top: 50%; z-index: 949; transform: translateY(-50%);
  width: 34px; min-height: 128px; padding: 14px 0; border: 0; border-radius: 0 12px 12px 0; cursor: pointer;
  background: var(--yh-accent, #7b1e35); color: #fff; font: inherit; font-size: .74rem; letter-spacing: .16em; text-transform: uppercase;
  writing-mode: vertical-rl; text-orientation: mixed; display: none; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 24px -10px rgba(0,0,0,.5);
}
/* the drawer and its backdrop sit above the chat launcher (z 8000) but below the open chat sheet */
.yh-nav__bg { position: fixed; inset: 0; z-index: 8490; background: rgba(20,14,16,.46); opacity: 0; pointer-events: none; transition: opacity .25s; }
html.yh-drawer-open .yh-nav__bg { opacity: 1; pointer-events: auto; }
html:not(.yh-dock) .yh-nav {
  top: 0; bottom: 0; z-index: 8500; width: min(86vw, 320px); transform: translateX(-104%);
  padding-top: env(safe-area-inset-top, 0px); box-shadow: 0 0 60px rgba(0,0,0,.35);
}
html:not(.yh-dock) .yh-nav .yh-nav__ttl, html:not(.yh-dock) .yh-nav .yh-nav__lbl { opacity: 1; transform: none; }
html:not(.yh-dock):not(.yh-has-toggle) .yh-nav__tab { display: flex; }
html.yh-drawer-open .yh-nav { transform: none; }
html.yh-drawer-open .yh-nav__tab { opacity: 0; pointer-events: none; }

/* ---- prev / next page footer ---- */
.yh-pgnav { max-width: 1120px; margin: 0 auto; padding: 8px 20px 36px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; font-family: var(--yh-sans, system-ui, sans-serif); }
.yh-pgnav a {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 16px; text-decoration: none; color: var(--yh-ink, #1b2240);
  border: 1px solid color-mix(in srgb, var(--yh-ink, #1b2240) 14%, transparent); border-radius: var(--yh-radius, 14px);
  background: color-mix(in srgb, var(--yh-paper, #f7f2e8) 70%, transparent); transition: transform .2s, border-color .2s;
}
.yh-pgnav a:hover { transform: translateY(-2px); border-color: var(--yh-accent, #7b1e35); }
.yh-pgnav a.next { justify-content: flex-end; text-align: right; }
.yh-pgnav__ar { flex: 0 0 auto; font-size: 1.3rem; color: var(--yh-accent, #7b1e35); }
.yh-pgnav small { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--yh-muted, #5e6478); }
.yh-pgnav b { font-weight: 600; font-size: 1rem; }
@media (max-width: 640px) { .yh-pgnav { grid-template-columns: 1fr; } .yh-pgnav a.next { justify-content: space-between; } }

/* short desktop viewports: tighter rows so twelve pages fit; the list scrolls if they still don't */
@media (min-width: 1100px) and (max-height: 860px) {
  .yh-nav__hd { min-height: 44px; }
  .yh-nav__a { min-height: 36px; }
  .yh-nav__lbl small { display: none; }
  .yh-nav__call { min-height: 40px; }
  .yh-nav__mode { min-height: 34px; }
  .yh-nav__ft { padding: 4px 0; }
}

/* ---- motion / print ---- */
@media (prefers-reduced-motion: reduce) {
  .yh-nav, .yh-nav__ttl, .yh-nav__lbl, .yh-nav__bg, .yh-pgnav a, .yh-nav__a::before { transition: none !important; }
  .yh-pg-in { animation: none; }
}
@media print { .yh-nav, .yh-nav__tab, .yh-nav__bg, .yh-pgnav { display: none !important; } html.yh-pages [data-yh-page] { display: block !important; } html.yh-dock body { padding-left: 0; } }
