/* Books that feel like this — direction B "Night Window" (design/PATTERNS.md) */

:root {
  --night: #17162e;
  --night-2: #1f1e3a;
  --ink: #ebe7f3;
  --muted: #8f8ba9;
  --amber: #f2b263;
  --amber-ink: #1a1230;
  --line: rgba(235, 231, 243, 0.09);
  --scene-wall: #1c1b35;
  --scene-floor: #2b2140;
  --tile-bg: #22213f;
  --backdrop: rgba(10, 9, 24, 0.78);
  --panel: #1b1a35;
  --gap: 4px;
  --gutter: 16px;
}
:root[data-theme="light"] {
  --night: #efe3ee;
  --night-2: #e6d7ea;
  --ink: #2a2140;
  --muted: #6f6688;
  --amber: #c9742f;
  --amber-ink: #fff4e6;
  --line: rgba(42, 33, 64, 0.12);
  --tile-bg: #e2d4e6;
  --backdrop: rgba(42, 33, 64, 0.55);
  --panel: #f6eef5;
}

* { box-sizing: border-box; }
html { background: var(--night); }
body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="light"] body {
  background: linear-gradient(180deg, #f6dce6 0%, #efe3ee 420px, #d9cdee 100%) fixed;
}
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- the scene */
.sky {
  height: 168px;
  background: linear-gradient(180deg, var(--scene-wall) 0 78.5%, var(--scene-floor) 78.5% 100%);
  overflow: hidden;
}
.sky { position: relative; }
.scene { height: 100%; }
.scene canvas {                       /* drawn by scene.js, blown up with crisp pixels */
  position: absolute; left: 50%; top: 0;
  transform: translateX(-50%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
:root[data-theme="light"] .sky {
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.2);
}

/* ---------- the bar (sticks; slides off and back with the scroll — app.js) */
.head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--night);
  transition: box-shadow .25s;
}
.head.float { box-shadow: 0 1px 0 var(--line); }
.head.glide, .meta.glide { transition: box-shadow .25s, transform .22s ease; }   /* touch screens: glides off/on — app.js slidingBar */
.sw.labBtn {
  position: absolute; top: 16px; right: var(--gutter); z-index: 6;
  padding: 4px 0;
  color: #8f8ba9;                      /* sits on the scene, which stays dark in both themes */
}
.tools::before {
  /* the lamp's glow leaking onto the page */
  content: "";
  position: absolute; inset: -60px 0 auto 0; height: 140px;
  background: radial-gradient(60% 100% at 82% 0%, rgba(242, 178, 99, 0.14), transparent 70%);
  pointer-events: none;
}
.sw, .search input {
  font-family: "Silkscreen", monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  text-decoration: none;
  position: relative;
}
.sw { color: var(--muted); }

/* ---------- search + pills */
.tools {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px var(--gutter) 16px;
  position: relative;
}
.search { flex: 0 0 260px; }
.search input {
  /* looks like the old site-name mark: pixel font, amber */
  width: 100%;
  color: var(--amber);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
  border-radius: 0;
  -webkit-appearance: none;
}
.search input::placeholder { color: var(--amber); opacity: 1; }
.search input:focus { outline: none; border-bottom-color: var(--amber); }
.pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
  -webkit-overflow-scrolling: touch;
}
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill:hover { color: var(--ink); }
.pill.on { color: var(--amber-ink); background: var(--amber); border-color: var(--amber); }

/* ---------- the wall */
.wall {
  display: flex;
  gap: var(--gap);
  padding: 0 var(--gutter) 60px;
  align-items: flex-start;
  transition: opacity .16s ease-out;
}
.wall.out { opacity: 0; }
/* new search / tag results come in one after another (delay set per tile in app.js) */
.tile.enter { animation: tileIn .4s ease-out both; }
@keyframes tileIn { from { opacity: 0; } to { opacity: 1; } }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.tile {
  position: relative;
  display: block;
  overflow: hidden;
  background-color: var(--tile-bg);
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
  text-decoration: none;
  color: #fff;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
  opacity: 0;
  transition: opacity .25s ease-out;
}
.tile img.in { opacity: 1; transition: none; }
.veil {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  pointer-events: none;
}
:root[data-shape="squares"] .tile { aspect-ratio: 1 / 1 !important; }
:root[data-shape="squares"] .tile img { position: absolute; inset: 0; }
.cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 26px 10px 9px;
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.3;
  background: linear-gradient(transparent, rgba(10, 9, 24, 0.82));
  opacity: 0;
  transition: opacity .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cap b { font-weight: 500; }
.cap span { color: rgba(255,255,255,.7); }
@media (hover: hover) {
  .tile:hover .cap, .tile:focus-visible .cap { opacity: 1; }
}
.sentinel { height: 1px; }
.empty { padding: 40px var(--gutter); color: var(--muted); }
.more { margin: -40px 0 40px; padding: 0 var(--gutter); text-align: center; }
.more[hidden] { display: none; }
.more button { color: var(--muted); border-bottom: 1px solid var(--amber); padding-bottom: 2px; }
.more button:hover { color: var(--ink); }

/* ---------- lightbox */
.lightbox { position: fixed; inset: 0; z-index: 10; }
.lightbox[hidden] { display: none; }
.backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.lightbox, .panel { animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.lightbox.out, .lightbox.out .panel { animation: fadeout .15s ease-in forwards; }
@keyframes fadeout { to { opacity: 0; } }
.panel {
  position: absolute;
  inset: 4vh 4vw;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr);
  background: var(--panel);
  color: var(--ink);
  outline: none;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.pics { overflow-y: auto; background: #0e0d1e; display: flex; flex-direction: column; gap: 4px; }
:root[data-theme="light"] .pics { background: #e3d7e8; }
.pics img { display: block; width: 100%; height: auto; background: var(--tile-bg); }
.pics img.thumb { filter: none; }
.side { overflow-y: auto; }                     /* the right-hand column: buttons, then the text, scrolling together */
.text { padding: 0 28px 40px; }
.meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 28px 0; margin-bottom: 16px; }
.nav { display: flex; gap: 4px; }
/* ‹ › × all alike: same box, icon drawn dead centre */
.arrow { width: 32px; height: 32px; display: inline-grid; place-items: center; color: var(--muted); border: 1px solid var(--line); }
.arrow svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.arrow:hover { color: var(--ink); }
.title { font-size: 22px; font-weight: 500; line-height: 1.25; margin: 0 0 8px; }
.tag { display: block; font-family: "Silkscreen", monospace; font-size: 10px; color: var(--amber); margin: 0 0 8px; }
.tag:empty { display: none; }
.sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.sub a { color: var(--muted); }
.sub a:hover { color: var(--ink); }
.comments { list-style: none; margin: 0; padding: 0; max-width: 58ch; }
.comments li {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 15.5px;
  line-height: 1.5;
  word-wrap: break-word;
}
.comments li:first-child { border-top: 0; }
.marks { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.up, .agree {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--night-2);
}
.up .tri { width: 10px; height: 10px; fill: var(--muted); flex: none; }
.agree { color: var(--amber-ink); background: var(--amber); border-color: var(--amber); }
.hot .up { border-color: var(--amber); }
.hot .up .tri { fill: var(--amber); }
/* vote pill position (lab) */
.comments[data-pos="corner"] li { padding-right: 84px; }
.comments[data-pos="corner"] .marks { position: absolute; top: 12px; right: 0; margin: 0; }
.comments[data-pos="below"] .marks { order: 2; margin: 8px 0 0; }
/* highlight style (lab) */
.comments[data-hl="left line"] li.hot { border-left: 2px solid var(--amber); padding-left: 12px; }
.comments[data-hl="bottom line"] li.hot { box-shadow: inset 0 -2px 0 var(--amber); padding-bottom: 14px; }
.comments a { color: var(--amber); text-decoration: none; }
.comments a:hover { text-decoration: underline; }
.comments p { margin: 0 0 8px; }
.comments p:last-child { margin: 0; }

/* ---------- the lab */
.labBtn.on { color: var(--amber); }
.lab {
  position: fixed; top: 12px; right: 12px; z-index: 20;
  width: 300px; max-width: calc(100vw - 24px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  padding: 12px 14px 10px;
}
.lab[hidden] { display: none; }
.labHead { display: flex; justify-content: space-between; align-items: center; font-family: "Silkscreen", monospace; font-size: 11px; color: var(--amber); margin-bottom: 10px; }
.labHead button { font-size: 20px; color: var(--muted); width: 28px; height: 28px; }
.lab .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.lab .lbl { color: var(--muted); white-space: nowrap; }
.lab .opts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.lab .opt { color: var(--muted); padding-bottom: 1px; white-space: nowrap; }
.lab .opt.on { color: var(--ink); border-bottom: 2px solid var(--amber); }
.labNote { margin: 10px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

/* ---------- phones */
@media (max-width: 720px) {
  :root { --gutter: 10px; --gap: 3px; }
  .sky { height: 112px; }
  .search input { font-size: 16px; }   /* phones zoom into smaller text boxes */
  .tools { flex-direction: column; align-items: stretch; gap: 10px; }
  .search { flex-basis: auto; }
  /* one column that scrolls as a whole: buttons on top (they scroll away), pictures, then text */
  .panel { inset: 0; display: flex; flex-direction: column; overflow-y: auto; box-shadow: none; }
  .side { display: contents; }
  .meta { order: 1; padding: 8px var(--gutter); margin: 0; position: sticky; top: 0; z-index: 2; background: var(--panel); }   /* slides with the scroll — app.js */
  .pics { order: 2; flex: none; height: 52vh; flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 0; }
  .pics img { width: 100%; height: 100%; object-fit: contain; flex: 0 0 100%; }
  /* several pictures: a strip like the wall, sideways — each full height, side by side from the left */
  .pics.many { gap: var(--gap); padding-left: var(--gutter); background: none; }
  .pics.many img { width: auto; flex: none; object-fit: cover; }
  .pics.many::after { content: ""; flex: 0 0 calc(var(--gutter) - var(--gap)); }
  .text { order: 3; padding: 16px 16px 60px; }
  .arrow { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile img, .cap, .lightbox, .panel, .head, .meta, .veil, .wall, .tile.enter { transition: none; animation: none; }
}
