/* Gabe's Library: a reading room. Green walls, walnut shelves, brass label plates. */
:root {
  color-scheme: light dark;
  --wall: light-dark(#163a2b, #0b1f16);
  --wall2: light-dark(#1d4a37, #10291d);
  --top: light-dark(#1d4a37, #0f2519);
  --on: #eaf1ec;
  --on-mut: #b6cbbe;
  --brass: #c9a24a;
  --wood: #6e4325;
  --wood2: #4a2b16;
  --bg: light-dark(#ffffff, #121a16);
  --ink: light-dark(#14201a, #e6ece8);
  --mut: light-dark(#56645c, #9aaaa1);
  --line: light-dark(#dfe5e1, #2a3730);
  --soft: light-dark(#f2f6f3, #19231e);
  --acc: light-dark(#1d6b4c, #6cc79c);
  --rail-w: 76px;
  --shelf: 214px;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; }
body { background: var(--wall); color: var(--on); font: 16px/1.5 "Public Sans", system-ui, sans-serif; overflow-x: clip; }
button, input, select { font: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1, h2, h3 { font-family: "Libre Caslon Display", Georgia, serif; font-weight: 400; letter-spacing: -.01em; line-height: 1.1; margin: 0; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; background: var(--top); border-bottom: 1px solid #2c5a45;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
.brand { font: 400 26px "Libre Caslon Display", Georgia, serif; color: #fff; text-decoration: none; white-space: nowrap; }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.1); border: 1px solid #4f7a66; border-radius: 10px; padding: 0 12px; }
.search:focus-within { border-color: var(--brass); background: rgba(255,255,255,.14); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--on-mut); stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; background: transparent; color: #fff; padding: 10px 0; font-size: 16px; outline: none; }
.search input::placeholder { color: var(--on-mut); }

/* shell + rail, like gradebook and spending */
.shell { display: flex; align-items: flex-start; }
.main { flex: 1; padding: 18px max(16px, env(safe-area-inset-right, 0px)) 60px 20px; }
.rail { flex: 0 0 var(--rail-w); width: var(--rail-w); display: flex; flex-direction: column; gap: 3px; padding: 14px 8px; position: sticky; top: 62px; border-right: 1px solid #2c5a45; min-height: calc(100vh - 62px); }
.railtab { display: grid; justify-items: center; gap: 3px; padding: 9px 3px 7px; border: 1px solid transparent; border-radius: 12px; color: var(--on-mut); text-decoration: none; text-align: center; }
.railtab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.railtab span { font-size: 10px; line-height: 1.15; }
.railtab:hover { background: rgba(255,255,255,.07); color: #fff; }
.railtab.on { background: rgba(201,162,74,.16); border-color: var(--brass); color: var(--brass); font-weight: 600; }
.railtab:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* header figures + controls */
.figs { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 0 0 14px; }
.figs div { color: var(--on-mut); font-size: 14px; }
.figs b { display: block; color: #fff; font: 800 26px/1.1 "Public Sans"; font-variant-numeric: tabular-nums; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid #4f7a66; background: transparent; color: var(--on); border-radius: 999px; padding: 6px 13px; min-height: 36px; cursor: pointer; font-size: 14px; }
.chip:hover { border-color: var(--on-mut); }
.chip[aria-pressed=true] { background: var(--brass); border-color: var(--brass); color: #20170a; font-weight: 600; }
.sel { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--on-mut); }
.sel select { background: var(--wall2); color: #fff; border: 1px solid #4f7a66; border-radius: 8px; padding: 6px 8px; min-height: 36px; font-size: 15px; }
.roomline { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.roomline h1 { font-size: clamp(26px, 3vw, 34px); color: #fff; }
.clear { border: 1px solid #4f7a66; background: transparent; color: var(--on-mut); border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.count { color: var(--on-mut); font-size: 14px; margin: 0 0 12px; }
.empty { color: var(--on-mut); padding: 40px 0; font-size: 17px; }
.loading { color: var(--on-mut); padding: 40px 0; }

/* sections and shelves */
.sec { margin-bottom: 18px; }
.sechead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.plate { display: inline-block; background: linear-gradient(#e2c579, #b48a32); color: #2a1d05; font: 600 14px "Public Sans"; padding: 3px 11px; border-radius: 3px; margin: 6px 0 4px; box-shadow: inset 0 -1px 0 #8a6820; }
.more { background: none; border: 0; color: var(--brass); cursor: pointer; font-size: 14px; font-weight: 600; padding: 6px 2px; }
.more:hover { text-decoration: underline; }
.shelf { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 3px; padding: 0 12px;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--shelf) - 18px), var(--wood) calc(var(--shelf) - 18px) calc(var(--shelf) - 6px), var(--wood2) calc(var(--shelf) - 6px) var(--shelf)); }
.shelf.collapsed { max-height: calc(var(--shelf) * 3); overflow: hidden; }
.bk { flex: none; height: var(--shelf); padding-bottom: 18px; display: flex; align-items: flex-end; cursor: pointer; background: none; border: 0; margin: 0; color: inherit; }
.sp { height: calc(var(--h) * var(--k, 1)); width: var(--w); background: var(--c); color: var(--t); border-radius: 2px 2px 0 0; writing-mode: vertical-rl; display: flex; justify-content: space-between; align-items: center; padding: 9px 0; font: 600 12px/1.1 "Public Sans"; overflow: hidden;
  box-shadow: inset 3px 0 0 rgba(255,255,255,.14), inset -4px 0 0 rgba(0,0,0,.25); transition: transform .15s; }
.sp em { font-style: normal; max-height: 74%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp i { font-style: normal; font-weight: 400; font-size: 10px; opacity: .85; white-space: nowrap; overflow: hidden; max-height: 24%; }
.sp.thin em { font-size: 10px; }
.sp.thin i { display: none; }
.bk:hover .sp, .bk:focus-visible .sp, .bk.on .sp { transform: translateY(-10px); }
.bk:focus-visible { outline: none; }
.bk:focus-visible .sp, .bk.on .sp { outline: 2px solid var(--brass); }
.bk.lean .sp { transform: rotate(-7deg); transform-origin: bottom left; margin-left: calc(var(--h) * var(--k, 1) * .125); }
.bk.lean:hover .sp, .bk.lean.on .sp { transform: rotate(-7deg) translateY(-10px); }
.face { width: 108px; height: 162px; transition: transform .15s; }
.face .gen { display: flex; }
.face img { display: block; }
.face img, .face .gen { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; box-shadow: 2px 3px 0 rgba(0,0,0,.35); }
.bk:hover .face, .bk.on .face { transform: translateY(-8px); }
.bk.on .face img { outline: 3px solid var(--brass); }
.gen { background: var(--c); color: var(--t); padding: 12px 10px; font: 400 15px/1.15 "Libre Caslon Display", Georgia, serif; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.gen span { overflow-wrap: anywhere; overflow: hidden; }
.gen small { font: 600 11px "Public Sans"; opacity: .85; }

/* rooms */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.room { display: block; background: var(--wall2); border: 1px solid #2c5a45; border-radius: 10px; padding: 14px 14px 0; color: var(--on); text-decoration: none; overflow: hidden; }
.room:hover { border-color: var(--brass); }
.room h2 { font-size: 22px; color: #fff; }
.room p { margin: 2px 0 8px; color: var(--on-mut); font-size: 14px; }
.mini { display: flex; align-items: flex-end; gap: 1px; height: 74px; overflow: hidden; margin: 0 -14px; padding: 0 14px; background: linear-gradient(to bottom, transparent 64px, var(--wood) 64px 70px, var(--wood2) 70px); }
.mini b { display: block; flex: none; width: var(--w); height: var(--h); background: var(--c); border-radius: 1px 1px 0 0; margin-bottom: 10px; }
.bar { height: 6px; background: rgba(255,255,255,.12); border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.bar i { display: block; height: 100%; background: var(--brass); }

/* book card */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
.card { position: fixed; z-index: 31; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--bg); color: var(--ink); overflow-y: auto; overscroll-behavior: contain;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) max(20px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 28px) 22px; box-shadow: -8px 0 30px rgba(0,0,0,.3); outline: none; }
.x { position: sticky; top: 0; float: right; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; z-index: 1; }
.chead { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; margin: 4px 0 14px; clear: none; }
.chead img, .chead .gen { width: 120px; height: 180px; border-radius: 3px; object-fit: cover; box-shadow: 2px 3px 0 rgba(0,0,0,.2); }
.chead h2 { font-size: 27px; margin-right: 40px; }
.sub { color: var(--mut); font-size: 15px; margin: 4px 0; }
.link { background: none; border: 0; padding: 0; color: var(--acc); cursor: pointer; text-align: left; font-size: 15px; }
.link:hover { text-decoration: underline; }
.stars { color: var(--brass); letter-spacing: 2px; font-size: 17px; margin-top: 4px; }
.status { font-weight: 600; margin-top: 6px; font-size: 15px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.bd { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--soft); }
.bd.p { background: light-dark(#e6e9f7, #1c2340); color: light-dark(#2c3a7a, #b9c3f2); border-color: light-dark(#c5cbeb, #313c66); }
.bd.e { background: light-dark(#dff1e7, #12301f); color: light-dark(#14523a, #9fdcbb); border-color: light-dark(#b5dcc6, #24513a); }
.bd.g { background: light-dark(#f6edd6, #2e2410); color: light-dark(#6b4e0c, #e2c579); border-color: light-dark(#e6d4a5, #514019); }
.meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 14px; font-size: 14px; margin: 0 0 14px; }
.meta dt { color: var(--mut); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.card h3 { font: 600 13px "Public Sans"; color: var(--mut); margin: 16px 0 6px; letter-spacing: 0; }
.desc { font-size: 15px; line-height: 1.55; white-space: pre-line; }
.desc.clip { max-height: 9.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.roomchips { display: flex; flex-wrap: wrap; gap: 6px; }
.roomchips a { font-size: 13px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.roomchips a:hover { border-color: var(--acc); }
.files { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.files li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.files li span:first-child { overflow-wrap: anywhere; }
.files li span:last-child { color: var(--mut); white-space: nowrap; }
.out { display: inline-block; margin-top: 16px; color: var(--acc); font-weight: 600; text-decoration: none; }
.out:hover { text-decoration: underline; }
.strip { display: flex; gap: 2px; align-items: flex-end; overflow-x: auto; padding: 4px 2px 0; height: 120px; background: linear-gradient(to bottom, transparent 108px, var(--wood) 108px 114px, var(--wood2) 114px); }
.strip { --k: .5; }
.strip .bk { height: 120px; padding-bottom: 12px; }
.strip .sp { font-size: 9px; padding: 5px 0; }

@media (max-width: 860px) {
  .shell { display: block; }
  .rail { width: auto; min-height: 0; flex-direction: row; gap: 2px; padding: 6px 10px; overflow-x: auto; position: static; border-right: 0; border-bottom: 1px solid #2c5a45; background: var(--wall2); }
  .railtab { flex: 0 0 auto; min-width: 66px; }
  .main { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
}
@media (max-width: 600px) {
  :root { --shelf: 176px; --k: .8; }
  .top { flex-wrap: wrap; gap: 8px; }
  .brand { font-size: 22px; }
  .search { max-width: none; flex-basis: 100%; }
  .shelf.collapsed { max-height: none; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
  .sp { font-size: 11px; }
  .face { width: 88px; height: 132px; }
  .figs b { font-size: 21px; }
  .card { top: auto; width: 100%; max-height: 90vh; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.3); }
  .chead { grid-template-columns: 96px minmax(0, 1fr); }
  .chead img, .chead .gen { width: 96px; height: 144px; }
  .chead h2 { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) { .sp, .face { transition: none; } }
