/* Library layout, after Project Meadow's reading room: a side menu of sections and documents, a main column with the
   newest change first. Colours come from admin.css (the landing page v19 palette). */
:root { --nav-w: 268px; --nav-bg: #FFFFFF; --nav-active: var(--accent); --gap: clamp(1rem, 3vw, 2.25rem); }

body.lib { background: var(--bg); }
.lib-shell { display: grid; grid-template-columns: var(--nav-w) 6px minmax(0, 1fr); min-height: 100vh; }
.lib-shell[hidden] { display: none; }

/* ---- side menu ---- */
aside.nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--nav-bg); border-right: 1px solid var(--line); padding: 1.4rem 1rem 2rem;
  scrollbar-width: thin;
}
.nav-brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); padding: 0 .35rem; }
.nav-brand img { width: 30px; height: 30px; }
.nav-brand span { font: 400 1.75rem/1 var(--display); font-variation-settings: "opsz" 72, "SOFT" 100; letter-spacing: -.01em; }
.nav-eyebrow { margin: 1.1rem .35rem .9rem; font: 700 .68rem/1.2 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.nav-find { margin: 0 0 1rem; }
.nav-find input {
  width: 100%; font: inherit; font-size: .9rem; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
}
.nav-find input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; background: #fff; }
.nav-home {
  display: block; padding: .6rem .8rem; border-radius: 8px; font-weight: 600; font-size: .93rem; text-decoration: none; color: var(--ink);
  border: 1px solid transparent;
}
.nav-home.is-current { background: var(--nav-active); color: var(--accent-ink); box-shadow: inset 4px 0 0 rgba(255,255,255,.35); }
.nav-sec { margin-top: 1.35rem; }
.nav-sec h2 { margin: 0 .35rem .35rem; font: 700 .68rem/1.3 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.nav-sec ul { list-style: none; margin: 0; padding: 0; }
.nav-sec a {
  display: block; padding: .38rem .8rem; border-radius: 7px; font-size: .9rem; line-height: 1.35; color: var(--ink); text-decoration: none;
}
.nav-sec a:hover { background: var(--accent-soft); }
.nav-sec a.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-sec a .ext { color: var(--muted); font-size: .8em; }
.nav-none { padding: .4rem .8rem; color: var(--muted); font-size: .88rem; }

.nav-resize { cursor: col-resize; position: sticky; top: 0; height: 100vh; background: transparent; touch-action: none; }
.nav-resize:hover, .nav-resize.dragging, .nav-resize:focus-visible { background: var(--accent-soft); outline: none; }
body.resizing { user-select: none; cursor: col-resize; }

/* ---- main column ---- */
.lib-main { padding: var(--gap); min-width: 0; }
.lib-main > * { max-width: 1120px; margin-left: auto; margin-right: auto; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 1.1rem 1.4rem;
}
.banner p { margin: 0; }
.banner .b-title { font-weight: 700; font-size: 1.05rem; }
.banner .b-sub { color: rgba(255,255,255,.78); font-size: .88rem; margin-top: .15rem; }
.banner .button { background: #fff; color: var(--ink); }

.crumbs {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 1.4rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); font-size: .88rem; color: var(--muted);
}
.crumbs a { font-weight: 600; color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.crumbs .who-inline { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.crumbs .link-button { font-size: .88rem; }

.hero {
  position: relative; overflow: hidden; margin-top: 1.25rem; border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(115deg, #FFFFFF 0%, #FFFFFF 46%, #EEF1FD 100%); padding: clamp(1.6rem, 5vw, 3.4rem);
}
.hero::after { /* quiet rings of water, drawn, not decorative clutter: one motif */
  content: ""; position: absolute; right: -120px; top: 50%; width: 520px; height: 520px; transform: translateY(-50%);
  background: repeating-radial-gradient(circle, transparent 0 38px, rgba(35,72,220,.07) 38px 39px);
  border-radius: 50%; pointer-events: none;
}
.hero .eyebrow { margin: 0 0 1rem; font: 700 .72rem/1.2 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 0; font: 400 clamp(2.4rem, 6vw, 4.6rem)/1 var(--display); font-variation-settings: "opsz" 144, "SOFT" 50; letter-spacing: -.025em; }
.hero .lede { max-width: 38rem; margin: 1.1rem 0 0; font-size: 1.12rem; color: var(--ink); }
.hero .meta { margin: 1.2rem 0 0; font-size: .84rem; color: var(--muted); }
.hero .stats { display: flex; gap: 2rem; flex-wrap: wrap; margin-top: 1.6rem; position: relative; z-index: 1; }
.hero .stat b { display: block; font: 400 2rem/1 var(--display); }
.hero .stat span { font-size: .82rem; color: var(--muted); }

.block { margin-top: 2.4rem; }
.block > h2 { margin: 0 0 .25rem; font: 400 1.9rem/1.15 var(--display); font-variation-settings: "opsz" 72; letter-spacing: -.01em; }
.block > p.sub { margin: 0 0 1.1rem; color: var(--muted); }

.latest-rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.latest-rows li + li { border-top: 1px solid var(--line); }
.latest-rows a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .85rem 1.1rem; text-decoration: none; color: var(--ink); }
.latest-rows a:hover { background: var(--accent-soft); }
.latest-rows .t { font-weight: 600; }
.latest-rows .n { grid-column: 1; color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-rows .w { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; font-size: .84rem; color: var(--muted); white-space: nowrap; }
.latest-rows .w b { display: block; color: var(--accent); font-weight: 700; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; }
.card {
  display: flex; flex-direction: column; gap: .45rem; min-height: 9.5rem; padding: 1.05rem 1.15rem; border: 1px solid var(--line);
  border-radius: 14px; background: #fff; text-decoration: none; color: var(--ink);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.card:hover { border-color: var(--accent); box-shadow: 0 6px 22px rgba(32,38,34,.07); transform: translateY(-1px); }
.card .c-title { font-weight: 650; line-height: 1.3; }
.card .c-sum { color: var(--muted); font-size: .88rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .c-foot { margin-top: auto; display: flex; justify-content: space-between; gap: .6rem; font-size: .8rem; color: var(--muted); }
.tag { display: inline-block; padding: .08rem .5rem; border-radius: 99px; font: 700 .68rem/1.5 var(--ui); letter-spacing: .04em; text-transform: uppercase; background: var(--accent-soft); color: var(--accent); }
.tag.quiet { background: #EFEFEA; color: var(--muted); }
.lib-empty { padding: 1.4rem; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); background: #fff; }

/* ---- reading page ---- */
.doc-head { margin-top: 1.2rem; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.doc-head .eyebrow { margin: 0 0 .4rem; font: 700 .72rem/1.2 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.doc-head h1 { margin: 0; font: 400 clamp(1.8rem, 4vw, 2.7rem)/1.08 var(--display); font-variation-settings: "opsz" 96; letter-spacing: -.015em; }
.doc-head .meta { margin: .5rem 0 0; color: var(--muted); font-size: .88rem; }
.doc-tools { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.doc-tools select { font: inherit; font-size: .9rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.old-version {
  margin-top: 1rem; padding: .75rem 1rem; border-radius: 10px; background: #FFF6DB; border: 1px solid #EAD48A; color: #4A3B07; font-size: .92rem;
}
.old-version a { color: #4A3B07; font-weight: 700; }
.frame-wrap { margin-top: 1rem; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.frame-wrap iframe { display: block; width: 100%; height: calc(100vh - 13rem); min-height: 520px; border: 0; background: #fff; }
.versions-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.versions-list li { display: grid; grid-template-columns: 4rem minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .75rem 1rem; align-items: baseline; }
.versions-list li + li { border-top: 1px solid var(--line); }
.versions-list .v { font-weight: 700; }
.versions-list .note { color: var(--ink); overflow-wrap: anywhere; }
.versions-list .when { color: var(--muted); font-size: .84rem; white-space: nowrap; }
.versions-list li.is-current { background: var(--accent-soft); }

/* phone: the side menu becomes a "Go to" picker, as in Meadow */
.goto { display: none; margin-top: 1rem; }
.goto label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
.goto select { width: 100%; font: inherit; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
@media (max-width: 900px) {
  .lib-shell { grid-template-columns: minmax(0, 1fr); }
  aside.nav, .nav-resize { display: none; }
  .goto { display: block; }
  .hero::after { width: 320px; height: 320px; right: -160px; }
  .frame-wrap iframe { height: 78vh; min-height: 420px; }
  .versions-list li { grid-template-columns: 3rem minmax(0, 1fr); }
  .versions-list .when { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }

/* Markdown reports inside the frame */
body.framed { background: #fff; }
body.framed .prose { max-width: 46rem; margin: 0 auto; padding: clamp(1rem, 4vw, 2.5rem); }

/* small public pages (versions list, not found) */
body.plain { background: var(--bg); }
.notfound { max-width: 34rem; margin: 12vh auto; padding: 0 1.25rem; }
.notfound.wide { max-width: 46rem; }
.notfound .eyebrow { font: 700 .72rem/1.2 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.notfound h1 { font: 400 2.6rem/1.05 var(--display); margin: .4rem 0 .6rem; }
.versions { list-style: none; padding: 0; margin: 1.5rem 0; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.versions .ver { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: .2rem 1rem; padding: .85rem 1.1rem; }
.versions .ver + .ver { border-top: 1px solid var(--line); }
.versions .ver-link { font-weight: 700; display: flex; gap: .5rem; align-items: center; }
.versions .ver-when { color: var(--muted); font-size: .86rem; }
.versions .ver-note { grid-column: 2; }
.notfound .foot { color: var(--muted); }
.button.quiet { background: transparent; color: var(--accent); border: 1px solid var(--line); }

/* buttons that are links: no underline */
a.button { text-decoration: none; }
a.button:hover { text-decoration: underline; text-decoration-thickness: 1px; }

/* the reading page tools line up: same height and corners as the version picker */
.doc-tools .button { padding: .45rem .85rem; border-radius: 8px; font-size: .9rem; line-height: 1.35; }
