/* ==========================================================================
   The Library (library.html)
   Charcoal title band -> paper shelves and paths -> day-theme list.
   Mobile-first. No thumbnails. Motion only via .reveal (site.css).
   ========================================================================== */

/* Mirrored from story.css (not loaded on this page) */
.quote--xs { font-size: var(--step-1); line-height: 1.35; }
.band { height: clamp(96px, 16vh, 180px); }
.band--charcoal-paper { background: linear-gradient(var(--charcoal), #3b3935 45%, var(--paper)); }

/* ---- Header band ------------------------------------------------------- */
.lib-head { position: relative; padding: clamp(112px, 16vh, 176px) 0 clamp(48px, 8vh, 96px); overflow: clip; isolation: isolate; }
.lib-head::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vmax 40vmax at 85% 0%, rgba(200,184,154,.08), transparent 60%),
    radial-gradient(70vmax 50vmax at 0% 100%, rgba(91,63,140,.14), transparent 60%);
}
.lib-head__eyebrow { display: flex; align-items: center; gap: .9rem; margin-bottom: 1.6rem; }
.lib-head__eyebrow .rule { width: 48px; background: var(--brass); opacity: .6; }
.lib-head__grid { display: grid; gap: 2.4rem; align-items: end; }
.lib-head h1 { font-weight: 300; }
.lib-head h1 em { color: var(--accent); }
.lib-head__line { margin-top: 1.4rem; font-family: var(--serif); font-weight: 300; font-size: var(--step-2); line-height: 1.2; color: var(--muted); max-width: 22ch; }
.lib-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0; background: var(--hair); border: 1px solid var(--hair); border-radius: 16px; overflow: hidden; }
.lib-counts > div { background: var(--bg); padding: 16px 18px; display: flex; flex-direction: column-reverse; gap: .2rem; }
.lib-counts dt { font-size: .74rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.lib-counts dd { margin: 0; font-family: var(--serif); font-weight: 300; font-size: clamp(2rem, 1.5rem + 2vw, 3.2rem); line-height: 1; letter-spacing: -.02em; }
.lib-head__actions { margin-top: 1.4rem; display: flex; flex-wrap: wrap; gap: .8rem; }
@media (min-width: 960px) {
  .lib-head__grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: clamp(32px, 6vw, 96px); }
}

/* The key to the badges */
.voice-key { margin-top: clamp(40px, 7vh, 80px); padding-top: 1.6rem; border-top: 1px solid var(--hair); }
.voice-key h2 { margin-bottom: 1.1rem; }
.voice-key__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem 2rem; }
.voice-key__list li { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem .7rem; font-size: .9rem; color: var(--muted); }
@media (min-width: 720px) { .voice-key__list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .voice-key__list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---- Voice badges -------------------------------------------------------- */
/* Honesty is the point: the summary badge must never look like Stuart's own words. */
.badge {
  display: inline-flex; align-items: center; gap: .4rem; flex: none;
  padding: .26rem .6rem; border-radius: 999px; border: 1px solid var(--hair);
  font: 600 .68rem/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); white-space: nowrap;
}
.badge--words { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 50%, transparent); }
.badge--words::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--joel { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 30%, transparent); }
.badge--joel::before { content: ""; width: 6px; height: 6px; border-radius: 50%; border: 1px solid currentColor; background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.badge--summary {
  color: var(--fg); border: 1px dashed var(--faint); font-style: italic; text-transform: none; letter-spacing: .01em; font-size: .74rem;
  background: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in oklab, var(--fg) 6%, transparent) 5px 6px);
}
.badge--summary::before { content: "≠"; font-style: normal; font-weight: 700; }
.badge--scan::before { content: ""; width: 7px; height: 9px; border: 1px solid currentColor; border-radius: 1px; }
.badge--video::before { content: ""; width: 0; height: 0; border-style: solid; border-width: 4px 0 4px 6px; border-color: transparent transparent transparent currentColor; }
.badge--audio::before { content: ""; width: 2px; height: 7px; margin-right: 6px; background: currentColor; box-shadow: 3px -1.5px 0 currentColor, 6px 1px 0 currentColor; }

/* ---- Sections ---------------------------------------------------------- */
.lib-sec { padding: clamp(64px, 11vh, 140px) 0; }
.lib-sec__head { margin-bottom: clamp(32px, 6vh, 64px); display: grid; gap: 1rem; }
.lib-sec__head .display em { color: var(--accent); }
.lib-sec__head--row { align-items: end; }
@media (min-width: 860px) {
  .lib-sec__head--row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 3rem; }
  .lib-sec__head--row > p { justify-self: end; max-width: 26rem; }
}
.lib-sec--paths { padding-top: 0; }

/* ---- Question shelves ------------------------------------------------------- */
.shelves { display: grid; gap: 16px; }
@media (min-width: 900px) { .shelves { grid-template-columns: 1fr 1fr; gap: 20px; } }
.shelf {
  display: flex; flex-direction: column; gap: 1.4rem;
  padding: clamp(22px, 3vw, 36px); border-radius: 22px;
  background: var(--card); border: 1px solid var(--hair);
  transition: box-shadow var(--med) var(--ease-out);
}
.shelf:hover { box-shadow: 0 24px 60px rgba(60,40,20,.10); }
.shelf:hover .shelf__head .port, .shelf:focus-within .shelf__head .port { --angle: 0deg; }
.shelf__head { display: flex; align-items: flex-start; gap: 1rem; }
.shelf__head .port { --size: 34px; color: var(--brass-deep); margin-top: .3rem; }
.shelf__q { font-family: var(--serif); font-weight: 350; font-size: var(--step-3); line-height: 1.05; letter-spacing: -.015em; text-wrap: balance; }
.shelf__quote { padding-left: 1rem; border-left: 2px solid color-mix(in oklab, var(--accent) 55%, transparent); }
.shelf__quote .cite { margin-top: .6rem; font-size: .7rem; }
.shelf__list, .path__list { list-style: none; margin: 0; padding: 0; }
.shelf__list { border-top: 1px solid var(--hair); }
.shelf__more { align-self: flex-start; margin-top: auto; }
.shelf__fine { font-size: .82rem; color: var(--muted); margin-top: -.4rem; }
.shelf--still:hover { box-shadow: none; } /* Flight 811: no flourish */

/* An item on a shelf or path */
.pick { border-bottom: 1px solid var(--hair); }
.pick a, .pick .pick__static { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem 1rem; padding: .85rem 0; text-decoration: none; }
.pick a:hover .pick__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.pick__title { font-weight: 600; font-size: 1rem; line-height: 1.35; }
.pick__meta { grid-column: 1; font-size: .82rem; color: var(--muted); }
.pick .badge { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
@media (max-width: 520px) {
  .pick a, .pick .pick__static { grid-template-columns: 1fr; }
  .pick .badge { grid-column: 1; grid-row: auto; justify-self: start; }
}

/* ---- Reading paths ------------------------------------------------------ */
.paths { display: grid; gap: 16px; }
@media (min-width: 960px) { .paths { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
.path { padding: clamp(22px, 2.6vw, 32px); border-radius: 22px; background: var(--card); border: 1px solid var(--hair); display: flex; flex-direction: column; gap: 1rem; }
.path__time { font-family: var(--serif); font-style: italic; font-weight: 300; font-size: var(--step-3); line-height: 1; color: var(--accent); }
.path__title { font-family: var(--sans); font-weight: 600; font-size: 1.05rem; }
.path__list { counter-reset: step; }
.path__list .pick { counter-increment: step; }
.path__list .pick a, .path__list .pick .pick__static { grid-template-columns: 1.6rem minmax(0, 1fr); }
.path__list .pick a::before, .path__list .pick .pick__static::before { content: counter(step); grid-row: 1 / span 2; font-family: var(--serif); font-style: italic; color: var(--muted); padding-top: .05rem; }
.path__list .pick__title, .path__list .pick__meta { grid-column: 2; }
.path__list .pick .badge { grid-column: 2; grid-row: auto; justify-self: start; margin-top: .2rem; }
.path__list .pick a::before, .path__list .pick .pick__static::before { grid-row: 1 / span 3; }
.path__total { margin-top: auto; padding-top: .4rem; font-size: .82rem; color: var(--muted); }
/* The evening path is set on charcoal, like a screening */
.path--dark { background: var(--charcoal); color: var(--bone); border-color: var(--charcoal);
  --fg: var(--bone); --muted: rgba(240,237,232,.66); --faint: rgba(240,237,232,.42); --hair: rgba(240,237,232,.16); --accent: var(--violet-light); }

/* ---- Finder: search + filters ----------------------------------------------- */
.finder { display: grid; gap: .6rem; }
.finder__label { font-size: .74rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.finder__field { position: relative; }
.finder__icon { position: absolute; left: 18px; top: 50%; width: 20px; height: 20px; margin-top: -10px; color: var(--muted); pointer-events: none; }
.finder input {
  width: 100%; appearance: none; -webkit-appearance: none;
  padding: 1.05rem 3.2rem 1.05rem 3.1rem; border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--fg) 22%, transparent); background: #fff; color: var(--fg);
  font: 500 1.08rem/1.2 var(--sans); box-shadow: 0 1px 0 rgba(20,20,20,.03);
  transition: border-color var(--fast) ease, box-shadow var(--fast) ease;
}
.finder input::placeholder { color: var(--muted); }
.finder input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-color: var(--accent); }
.finder input::-webkit-search-cancel-button { cursor: pointer; }
.finder__kbd { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font: 600 .72rem/1 var(--mono); color: var(--muted); border: 1px solid var(--hair); border-radius: 6px; padding: .3rem .45rem; }
.finder__count { font-size: .92rem; color: var(--muted); min-height: 1.5em; }
.finder__count b { color: var(--fg); font-weight: 700; }

.filters { margin-top: 1.2rem; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.filters__toggle { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; font-weight: 600; font-size: .95rem; }
.filters__toggle::-webkit-details-marker { display: none; }
.filters__toggle::after { content: "+"; font-weight: 400; font-size: 1.4rem; line-height: 1; color: var(--muted); }
.filters[open] .filters__toggle::after { content: "–"; }
.filters__n { margin-left: auto; font-size: .82rem; color: var(--accent); font-weight: 600; }
.filters__body { display: grid; gap: 1.2rem; padding: .2rem 0 1.4rem; }
@media (min-width: 900px) {
  /* Desktop: always open, no toggle (library.js keeps [open] set) */
  .filters__toggle { display: none; }
  .filters__body { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1.4rem 3rem; padding: 1.4rem 0; }
}
.chips { border: 0; margin: 0; padding: 0; min-width: 0; }
.chips legend { padding: 0; margin-bottom: .7rem; display: flex; gap: .7rem; align-items: baseline; }
.chips__aside { font-weight: 500; letter-spacing: .04em; text-transform: none; font-size: .78rem; color: var(--muted); }
.chips__row { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem; min-height: 40px;
  padding: .5rem .9rem; border-radius: 999px; border: 1px solid color-mix(in oklab, var(--fg) 16%, transparent);
  background: transparent; color: var(--fg); cursor: pointer;
  font: 500 .88rem/1.1 var(--sans);
  transition: background var(--fast) ease, border-color var(--fast) ease, color var(--fast) ease;
}
.chip:hover { border-color: var(--fg); }
.chip .n { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--linen); }
.chip[aria-pressed="true"] .n { color: rgba(250,248,243,.7); }
.chip:focus-visible { border-radius: 999px; }
.chip[disabled] { opacity: .45; cursor: default; }

/* ---- Year strip (view ports) ---------------------------------------------- */
/* Set on charcoal, like a row of lit cabin windows: the more work that year, the brighter the port. */
.years {
  margin-top: 1.8rem; padding: 18px 20px 12px; border-radius: 18px;
  background: var(--charcoal); color: var(--bone);
  --fg: var(--bone); --muted: rgba(240,237,232,.66); --faint: rgba(240,237,232,.42); --hair: rgba(240,237,232,.16); --accent: var(--violet-light);
}
.years__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .4rem 1rem; margin-bottom: .6rem; }
.years__scroll { position: relative; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: rgba(240,237,232,.25) transparent; padding: 6px 4px 10px; margin-inline: -4px; }
.years__strip { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; min-width: max-content; }
@media (min-width: 1200px) { .years__strip { min-width: 0; gap: 0; } .years__strip > li { flex: 1 1 0; min-width: 0; } .yr-btn { width: 100%; min-width: 0; padding-inline: 0; } .yr-btn .y { font-size: .6rem; letter-spacing: 0; } }
.yr-btn {
  --lum: .2; /* 0..1, set per year from its count */
  position: relative; display: grid; justify-items: center; gap: .45rem; padding: 4px 2px; min-width: 32px;
  background: none; border: 0; cursor: pointer; color: var(--bone); font: inherit;
}
.yr-btn .port {
  --size: 24px; color: var(--brass);
  background: color-mix(in oklab, var(--brass) calc(var(--lum) * 92%), transparent);
  border-color: color-mix(in oklab, var(--brass) calc(30% + var(--lum) * 70%), transparent);
  box-shadow: 0 0 calc(var(--lum) * 14px) color-mix(in oklab, var(--brass) calc(var(--lum) * 45%), transparent);
  transition: transform var(--fast) var(--ease-out);
}
.yr-btn .port__stripe { background: var(--violet-light); }
.yr-btn .y { font-size: .64rem; font-weight: 600; letter-spacing: .04em; color: rgba(240,237,232,.62); font-variant-numeric: tabular-nums; }
.yr-btn:hover .port { transform: scale(1.12); }
.yr-btn:hover .port, .yr-btn[aria-pressed="true"] .port { --angle: 0deg; }
.yr-btn[aria-pressed="true"] .port { border-color: var(--violet-light); box-shadow: 0 0 0 3px color-mix(in oklab, var(--violet-light) 40%, transparent); }
.yr-btn[aria-pressed="true"] .y { color: var(--violet-light); }
.yr-btn.is-empty { cursor: default; }
.yr-btn.is-empty .port { opacity: .3; }
.yr-btn:focus-visible { border-radius: 10px; outline-offset: 0; outline-color: var(--violet-light); }

/* ---- Active filters line -------------------------------------------------- */
.active { margin-top: 1.4rem; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; padding: .8rem 1rem; border-radius: 14px; background: var(--paper); }
.active[hidden] { display: none; }
.active__text { font-size: .9rem; }
.active__clear { font-size: .86rem; margin-left: auto; }

/* ---- The list ----------------------------------------------------------- */
.results { margin-top: clamp(28px, 5vh, 48px); }
.yr-group + .yr-group { margin-top: clamp(28px, 5vh, 52px); }
.yr-group__h { display: flex; align-items: baseline; gap: 1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--fg); position: sticky; top: 60px; z-index: 2; background: var(--bg); padding-top: .6rem; }
.yr-group__h .yr { font-family: var(--serif); font-weight: 300; font-size: var(--step-3); line-height: 1; letter-spacing: -.02em; font-variant-numeric: lining-nums; }
.yr-group__h .n { font-size: .8rem; color: var(--muted); }
@media (min-width: 861px) { .yr-group__h { top: 72px; } }
.rows { list-style: none; margin: 0; padding: 0; }
.row { border-bottom: 1px solid var(--hair); }
.row__link { display: grid; gap: .3rem .9rem; grid-template-columns: minmax(0, 1fr); padding: 1rem 0; text-decoration: none; color: inherit; }
.row__top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; }
.row__date { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.2rem; }
.row__title { font-family: var(--serif); font-weight: 400; font-size: 1.14rem; line-height: 1.3; letter-spacing: -.005em; text-wrap: pretty; }
.row__link:hover .row__title, .row__link:focus-visible .row__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
.row__meta { font-size: .84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .1rem .5rem; }
.row__meta .sep { opacity: .5; }
.row__sum { font-size: .9rem; color: var(--muted); max-width: 46rem; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row__link[href^="http"] .row__title::after, .pick a[href^="http"] .pick__title::after { content: " ↗"; font-family: var(--sans); font-size: .8em; color: var(--muted); }
.row--nolink .row__link { cursor: default; }
/* Second link to the old site's own page for the item (sitemap-only pages, now accounted for) */
.row__page { display: inline-block; margin: -.55rem 0 .9rem; font-size: .8rem; color: var(--muted); text-underline-offset: .2em; min-height: 24px; line-height: 24px; }
.row__page::before { content: "↳ "; }
.row__page:hover, .row__page:focus-visible { color: var(--fg); }
/* Summary pages: set in the sans, not the serif, so nothing reads as his voice */
.row--summary .row__title { font-family: var(--sans); font-weight: 500; font-style: italic; font-size: 1.04rem; }
.row__link:focus-visible { outline-offset: 2px; border-radius: 8px; }
mark.hit { background: color-mix(in oklab, var(--violet) 16%, transparent); color: inherit; border-radius: 2px; padding: 0 .06em; }

@media (min-width: 760px) {
  .row__link { grid-template-columns: 6.4rem minmax(0, 1fr) 14rem; align-items: baseline; padding: 1.05rem 0; }
  .row__top { display: contents; }
  .row__date { grid-column: 1; grid-row: 1; }
  .row .badge { grid-column: 3; grid-row: 1; justify-self: end; }
  .row__title { grid-column: 2; grid-row: 1; }
  .row__meta, .row__sum { grid-column: 2; }
  .row__page { margin-left: 7.3rem; }
}

.empty { margin-top: 2.4rem; padding: 2rem; border-radius: 16px; background: var(--paper); text-align: center; color: var(--muted); }
.empty[hidden] { display: none; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--fg); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
.more { margin-top: 2.2rem; display: flex; justify-content: center; }
.more .btn { border-color: color-mix(in oklab, var(--fg) 25%, transparent); }
.more .btn[hidden] { display: none; } /* .btn sets display, which would override the hidden attribute */

@media print {
  .finder, .filters, .years, .more, .lib-head__actions, .band { display: none !important; }
}

/* Mobile QA: the year labels (10.2px) and voice badges (10.9px) were below a readable size on phones */
.badge { font-size: .72rem; }
@media (max-width: 1199.98px) { .yr-btn .y { font-size: .72rem; } }
/* ...and on the narrowest phones a long badge ("Co-written with Joel Scambray") may wrap instead of pushing its card off screen */
@media (max-width: 520px) { .badge { white-space: normal; max-width: 100%; } }
