:root {
  color-scheme: dark;

  --black: #000;
  --line: #262420;
  --paper: #f2ede2;
  --body: #c9c2b4;
  --dim: #7f786c;
  --accent: #ff6b14;

  --display: "Noto Serif Display", "Times New Roman", serif;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;

  /* One type scale for the whole site; phones step each size down (see the 560px query). */
  --text-label: 12px;   /* uppercase terminal labels, counts, tags */
  --text-small: 13px;   /* secondary lines: hooks, bylines, details */
  --text-ui: 14px;      /* links, filters, list titles */
  --text-body: 15px;    /* descriptions */
  --text-lead: 17px;    /* the hook under a file title */
  --text-card: 20px;    /* project titles in lists */

  /* Motion curves: things glide to rest, windows sweep, targeting brackets overshoot as they lock. */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);

  --gutter: clamp(16px, 2.4vw, 40px);
  --sidebar: clamp(280px, 24vw, 360px);
}

*, *::before, *::after { box-sizing: border-box; }

/* Elements styled with a display value still hide when marked hidden. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--black);
  color: var(--body);
  font: 400 var(--text-body)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Small uppercase labels: counts and file numbers. */
.label {
  margin: 0;
  font: 500 var(--text-label)/1.4 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.label b { color: var(--paper); font-weight: 600; }

/* Text links and buttons: an accent underline draws across on hover, and the arrow leans forward. */
.link {
  padding: 0 0 1px;
  border: 0;
  background:
    linear-gradient(var(--accent), var(--accent)) left bottom / 0 1px no-repeat,
    linear-gradient(var(--dim), var(--dim)) left bottom / 100% 1px no-repeat;
  font: 500 var(--text-ui)/1.4 var(--sans);
  color: var(--paper);
  text-decoration: none;
  transition: color 0.2s, background-size 0.35s var(--ease-out), transform 0.12s;
}

.link:hover { color: var(--accent); background-size: 100% 1px, 100% 1px; }

.arrow { display: inline-block; transition: transform 0.3s var(--ease-out); }
:hover > .arrow { transform: translateX(3px); }
:hover > .arrow.is-back { transform: translateX(-3px); }

/* Everything pressable sinks a little under the pointer. */
.link:active, .ticker:active, .scan:active, .memo-open:active { transform: translateY(1px); }

/* ---------- Title card type ---------- */

.titlecard {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 62.5%;
  line-height: 0.84;
  text-transform: uppercase;
  color: var(--paper);
}

/* Each line is stretched to the full width by app.js, so lines land at different sizes. */
.fit { display: inline-block; white-space: nowrap; }
/* Sizes until app.js fits each line to its width. */
.masthead .fit { font-size: 72px; }
.masthead .fit[data-ratio] { font-size: 36px; }

/* ---------- One-screen layout ----------
   Nothing scrolls at page level: the sidebar holds the title and filters, and
   only the grid scrolls, loading more cards as it nears the end. */

.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: var(--gutter);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

/* A faint hexagon field behind the title, like a command-center display. */
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='49' viewBox='0 0 28 49'%3E%3Cpath d='M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z' fill='%23ff6b14' fill-opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.07;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 45%);
  mask-image: linear-gradient(to bottom, #000, transparent 45%);
}

.masthead { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; justify-items: start; }
.masthead .titlecard { width: 100%; }

.lede { margin: 0; font-size: var(--text-small); line-height: 1.5; color: var(--paper); }

/* Readout that types out a different file every few seconds; click to open it. */
.ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 0 0 0 2px;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  font: 500 var(--text-label)/1.3 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  transition: transform 0.12s;
}

.ticker:hover .ticker-text { color: var(--paper); }
.ticker:hover .ticker-light { box-shadow: 0 0 14px 2px var(--accent); }

.ticker-light {
  flex: none;
  width: 7px;
  height: 7px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  transition: box-shadow 0.3s;
}

.ticker-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: color 0.2s; }

/* Filters: search and sort share a row, categories wrap below as chips, Sources sits at the bottom. */
.controls {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 8px 16px;
  min-height: 0;
}

.search { grid-column: 1 / -1; }

/* The prompt's rule lights up from the left while typing. */
.search input {
  width: 100%;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(var(--accent), var(--accent)) left bottom / 0 1px no-repeat,
    linear-gradient(var(--dim), var(--dim)) left bottom / 100% 1px no-repeat;
  font-size: var(--text-ui);
  color: var(--paper);
  transition: background-size 0.45s var(--ease-out);
}

.search input::placeholder { color: var(--dim); }
.search input:focus-visible { outline: none; background-size: 100% 1px, 100% 1px; }

/* Category picker: a cd path that opens a directory listing. */
.dir { position: relative; min-width: 0; }

.dir-path, .sort {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  border-bottom: 1px solid var(--dim);
  font: 500 var(--text-label)/1 var(--mono, monospace);
  letter-spacing: 0.04em;
  color: var(--paper);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.2s;
}
.dir-path { list-style: none; }
.dir-path::-webkit-details-marker { display: none; }
.dir-path::after { content: "▾"; margin-left: auto; color: var(--dim); transition: transform 0.3s var(--ease-out), color 0.2s; }
.dir[open] .dir-path, .dir-path:hover, .sort:hover { border-color: var(--accent); }
.dir[open] .dir-path::after { transform: rotate(180deg); color: var(--accent); }
.dir-path:focus-visible { outline: none; border-color: var(--accent); }
#dir-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--accent); }
.dir-cmd { color: var(--dim); }

.dir-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 100%;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  border: 1px solid var(--line);
  background: var(--black);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.6);
}

.cat {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 6px 12px;
  border: 0;
  background: none;
  font: 500 var(--text-label)/1.4 var(--mono, monospace);
  letter-spacing: 0.04em;
  color: var(--body);
  white-space: nowrap;
  text-align: left;
  transition: background-color 0.15s, color 0.15s, padding-left 0.25s var(--ease-out);
}
.cat:hover, .cat:focus-visible { outline: none; padding-left: 16px; background: rgb(255 107 20 / 0.08); color: var(--paper); }
.cat[aria-pressed="true"] { color: var(--accent); }
.cat[aria-pressed="true"] span:first-child::before { content: "> "; }
.cat-count { color: var(--dim); }

.sort select {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: var(--paper);
  cursor: pointer;
}
.sort:focus-within { border-color: var(--accent); }
.sort select:focus-visible { outline: none; }

/* Desktop only: the ticker's file, drawn in whatever height the sidebar has left. */
.scan {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font-size: var(--text-small);
  line-height: 1.4;
  color: var(--body);
  transition: color 0.2s, transform 0.12s;
}
.scan:hover { color: var(--paper); }
.scan:hover .scan-art { filter: brightness(1.3) drop-shadow(0 0 6px rgb(255 107 20 / 0.35)); }
.scan-art-wrap { position: relative; display: block; flex: 0 1 auto; min-height: 48px; aspect-ratio: 4 / 3; }
.scan-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: filter 0.3s; }
.scan-art:not([src]) { visibility: hidden; }

/* Desktop-only status panel (public/signals.js): link, carrier, clocks, files read. */
.signals {
  grid-column: 1 / -1;
  align-self: end;
  display: grid;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font: 500 var(--text-label)/1.6 var(--mono, monospace);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}
.signals div { display: grid; grid-template-columns: 9ch minmax(0, 1fr); gap: 8px; }
.signals b { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 500; color: var(--paper); white-space: nowrap; overflow: hidden; }
.signal-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.signal-bars i { width: 3px; background: var(--line); }
.signal-bars i:nth-child(1) { height: 4px; }
.signal-bars i:nth-child(2) { height: 7px; }
.signal-bars i:nth-child(3) { height: 10px; }
.signal-bars i:nth-child(4) { height: 12px; }
.signal-bars i.on { background: var(--accent); box-shadow: 0 0 4px var(--accent); }
.signal-wave { display: block; width: 100%; height: 32px; margin: 4px 0; }

.sidebar-foot { grid-column: 1 / -1; }

@media (max-height: 700px) {
  .signals { display: none; }
}
@media (max-height: 560px) {
  .scan { display: none; }
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: var(--gutter) var(--gutter) 12px;
}

/* ---------- Card grid ---------- */

.results-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
}

.results-head > .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pager-btn {
  min-width: 36px;
  height: 32px;
  border: 1px solid var(--line);
  background: none;
  color: var(--paper);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s, transform 0.12s;
}

.pager-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background-color: rgb(255 107 20 / 0.08); }
.pager-btn:active:not(:disabled) { transform: scale(0.94); }
.pager-btn:disabled { color: var(--line); cursor: default; }

.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  align-content: start;
  gap: 24px clamp(16px, 2vw, 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: inherit;
  text-decoration: none;
  text-align: left;
}

/* The card's rule draws across in the accent as it is targeted. */
.card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease-out);
}
.card:hover::before, .card.is-source::before { transform: scaleX(1); }

.card-title, .card-meta, .card-blurb { display: block; }

.card-art-wrap { position: relative; display: block; flex: none; aspect-ratio: 3 / 2; overflow: hidden; }

/* The renders have generous empty black space, so they are cropped to fill the cell. */
.card-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--black);
  transition: filter 0.3s, transform 0.8s var(--ease-out);
}

.card:hover .card-art, .card.is-source .card-art { filter: brightness(1.35) drop-shadow(0 0 6px rgb(255 107 20 / 0.35)); transform: scale(1.04); }
.card:active .card-art { transform: scale(1.01); transition-duration: 0.3s, 0.15s; }

/* Targeting brackets lock onto the art on hover. */
.card-art-wrap::before, .scan-art-wrap::before {
  --b: linear-gradient(var(--accent), var(--accent));
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  background:
    var(--b) top left / 14px 1px no-repeat, var(--b) top left / 1px 14px no-repeat,
    var(--b) top right / 14px 1px no-repeat, var(--b) top right / 1px 14px no-repeat,
    var(--b) bottom left / 14px 1px no-repeat, var(--b) bottom left / 1px 14px no-repeat,
    var(--b) bottom right / 14px 1px no-repeat, var(--b) bottom right / 1px 14px no-repeat;
  transition: inset 0.35s var(--ease-snap), opacity 0.2s;
}

.card:hover .card-art-wrap::before, .card.is-source .card-art-wrap::before, .scan-art-wrap::before { inset: 4px; opacity: 1; }

.card-meta { font-size: var(--text-label); line-height: 1.4; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Project titles: the display serif at normal width in title case, for easy reading.
   The condensed capitals are kept for the wordmark and masthead. */
.card-title, .file-title {
  font-family: var(--display);
  font-weight: 700;
  font-stretch: 100%;
  letter-spacing: -0.01em;
  color: var(--paper);
  text-wrap: balance;
}

.card-title {
  font-size: var(--text-card);
  line-height: 1.12;
  color: var(--paper);
  text-wrap: balance;
  overflow-wrap: break-word;
}

.card-title { transition: color 0.2s; }
.card:hover .card-title, .card.is-source .card-title { color: var(--accent); }

.card-blurb {
  font-size: var(--text-small);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.empty { grid-column: 1 / -1; margin: 0; padding: 40px 0; color: var(--dim); }

/* The last line of the grid: how far through the list it is, then the batch decrypting as it loads. */
.grid-status {
  grid-column: 1 / -1;
  margin: 0;
  padding: 4px 0 8px;
  border-top: 1px solid var(--line);
  font-size: var(--text-label);
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid-status.is-loading { color: var(--accent); }

/* ---------- File page: one screen, only a long description scrolls ---------- */

.file {
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--black);
  color: var(--body);
  overflow: hidden;
}

.file[open] { display: flex; flex-direction: column; }
/* A pre-rendered file page shows its file before the app takes over (and without JavaScript). */
.file[open]:not(:modal) { position: fixed; inset: 0; z-index: 10; }
/* The index stays in view, dimmed, around the file as its window opens and closes (app.js). */
.file::backdrop { background: none; }
.app { transition: opacity 0.5s var(--ease-in-out); }
.is-reading .app { opacity: 0.35; }

/* The glowing edge of the window as it opens and closes; app.js moves it. */
.file-frame {
  position: fixed;
  inset: 0;
  z-index: 3;
  border: 1px solid var(--accent);
  box-shadow: 0 0 12px rgb(255 107 20 / 0.6), inset 0 0 24px rgb(255 107 20 / 0.25);
  opacity: 0;
  pointer-events: none;
}
.file:focus-visible { outline: none; }

/* The top bar on file pages and the sources page: wordmark, terminal path, keys, and a
   progress line showing how far through the archive the open file is. */
.bar {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 10px var(--gutter);
  border-bottom: 1px solid var(--line);
}
.bar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: var(--progress, 0%);
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  transition: width 0.7s var(--ease-out);
}

.bar-home {
  flex: none;
  font: 900 18px/1 var(--display);
  font-stretch: 62.5%;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--paper);
}
.bar-home { transition: color 0.2s; }
.bar-home:hover { color: var(--accent); }

.bar-path { flex: 1 1 auto; min-width: 0; padding-left: 16px; border-left: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar-keys { flex: none; display: flex; align-items: center; gap: 8px; }
.bar-count { min-width: 9ch; text-align: center; }

.bar .pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font: 500 var(--text-label)/1 var(--mono, monospace);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}
.bar kbd { padding: 2px 4px; border: 1px solid var(--line); font: inherit; font-size: 0.85em; color: var(--dim); transition: border-color 0.2s, color 0.2s; }
.bar .pager-btn:hover kbd { border-color: var(--accent); color: var(--accent); }

.file-page {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px);
  padding: clamp(16px, 4vh, 48px) var(--gutter);
}

/* The whole text column scrolls, so the title moves out of the way of a long report. */
.file-text { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

.file-title { width: 100%; flex: none; margin: 0; font-size: clamp(28px, 3.6vw + 12px, 56px); line-height: 1.05; }

.file-hook { margin: 0; flex: none; font-size: var(--text-lead); line-height: 1.4; color: var(--paper); }

.file-about p { margin: 0 0 0.8em; font-size: var(--text-body); line-height: 1.55; }
.file-about p:last-child { margin-bottom: 0; }

/* Descriptions read as declassified reports: a typed header block and numbered sections. */
.memo-head {
  margin: 0 0 16px;
  padding: 8px 0 12px;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  font: 400 var(--text-label)/1.6 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--dim);
}
.memo-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.file-about .memo-stamp {
  display: inline-block;
  margin: 0;
  font-size: inherit;
  line-height: 1.6;
  padding: 0 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
}
/* The page's main action: a key like the ones in the top bar, which fills with the accent from the left on hover. */
.memo-open {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  background: linear-gradient(var(--accent), var(--accent)) left / 0 100% no-repeat rgb(255 107 20 / 0.1);
  color: var(--paper);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s, background-size 0.4s var(--ease-out), transform 0.12s;
}
.memo-open:hover { background-size: 100% 100%; color: var(--black); }
.memo-open.is-pending { border-color: var(--line); background: none; color: var(--dim); }
.memo-head dl { margin: 0; display: grid; gap: 0; }
.memo-head dl div { display: grid; grid-template-columns: 8ch minmax(0, 1fr); gap: 8px; }
.memo-head dt::after { content: ":"; }
.memo-head dd { margin: 0; color: var(--body); overflow-wrap: anywhere; }

.file-about .memo-para { font-family: var(--mono); font-size: var(--text-small); line-height: 1.65; }
.memo-label { font-weight: 500; letter-spacing: 0.04em; color: var(--paper); }

.file-more { margin-top: 24px; }
.file-more .label { margin-bottom: 4px; }

/* A list of outside links: learn-more on file pages. The sources page reuses its parts. */
.link-list { margin: 0; padding: 0; list-style: none; }
.link-list a {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  column-gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--body);
  text-decoration: none;
  transition: padding-left 0.3s var(--ease-out);
}
.link-list a:hover { padding-left: 6px; }
.link-kind { grid-row: 1 / 3; font: 500 var(--text-label)/1.75 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.link-title { font-size: var(--text-ui); line-height: 1.4; color: var(--paper); transition: color 0.2s; }
.link-title::after { content: "\00a0↗"; display: inline-block; color: var(--dim); transition: color 0.2s, transform 0.3s var(--ease-out); }
.link-list a:hover .link-title::after { transform: translate(2px, -2px); }
.link-by { font-size: var(--text-small); line-height: 1.4; color: var(--dim); }
.link-list a:hover .link-title, .link-list a:hover .link-title::after { color: var(--accent); }

.file-side { display: flex; flex-direction: column; justify-content: center; min-height: 0; }

.file-art-wrap { position: relative; display: block; flex: 1; min-height: 0; }
.file-art { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--black); }


/* ---------- Sources page: the only page that scrolls ---------- */

.sources-page { display: flex; flex-direction: column; height: 100dvh; }

.sources { flex: 1; min-height: 0; overflow-y: auto; padding: clamp(16px, 4vh, 48px) var(--gutter) 64px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

.sources-head { display: grid; gap: 12px; justify-items: start; margin-bottom: clamp(24px, 5vh, 48px); }
.sources-title { font-size: clamp(56px, 9vw, 112px); }
.sources-lede { margin: 0; font-size: var(--text-body); color: var(--paper); }

.sources-archive { margin-bottom: 32px; }
.sources-archive > .label { padding-bottom: 8px; color: var(--accent); }

.sources-docs { margin: 0; padding: 0; list-style: none; }
.sources-docs li {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  column-gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.sources-docs a { text-decoration: none; }
.sources-docs .link-by a { color: var(--body); }
.sources-docs a:hover, .sources-docs a.link-title:hover::after { color: var(--accent); }

/* ---------- Tablet and phone: everything stacks in one column ---------- */

@media (max-width: 960px) {
  .app { display: flex; flex-direction: column; }

  .sidebar {
    flex: none;
    gap: 12px;
    padding: 16px var(--gutter) 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .masthead { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr); align-items: end; column-gap: 24px; }
  .masthead .titlecard { grid-row: 1 / 3; }

  /* The category listing drops over the grid, so the sidebar must not clip it. */
  .sidebar { z-index: 2; overflow: visible; }
  .controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
  .search { flex: 1 1 100%; }
  .dir { flex: 1 1 0; }

  .signals, .scan { display: none; }
  .sidebar-foot { order: 4; flex: none; margin: 0; padding-left: 12px; border-left: 1px solid var(--line); }

  .main { flex: 1; padding: 12px var(--gutter) 8px; }

  .file-page { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 16px; }
  .file-side { flex-direction: row; }
  .file-art-wrap { flex: 1 1 50%; }
}

@media (max-width: 560px) {
  :root { --text-label: 11px; --text-small: 12px; --text-ui: 13px; --text-body: 14px; --text-card: 18px; }

  .sidebar { gap: 8px; padding-top: 12px; }
  .masthead { grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; }
  .masthead .titlecard { grid-row: auto; width: 100%; }
  .lede { display: none; }
  .ticker { min-height: 28px; }
  .controls { gap: 4px 16px; }

  .main { padding-top: 8px; }
  .results-head { gap: 12px; padding: 4px 0; }

  .bar { gap: 8px; }
  .bar-path, .bar kbd { display: none; }
  .bar-keys { margin-left: auto; gap: 4px; }
  .bar-count { min-width: 0; padding: 0 4px; }
  .bar .pager-btn { min-width: 36px; height: 36px; padding: 0 8px; }

  /* Phone file page: no hook or document title, tighter rows. */
  .file-hook { display: none; }
  .file-about p { line-height: 1.5; }
  .file-more { margin-top: 16px; }
  .link-list a { grid-template-columns: 56px minmax(0, 1fr); column-gap: 12px; padding: 4px 0; }

  .sources-docs li { padding: 6px 0; }
}

/* Phones and short landscape screens get compact rows: square thumbnail beside the date and title. */
@media (max-width: 560px), (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
  .grid { grid-template-columns: 1fr; gap: 0; }
  .card {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    grid-template-rows: 1fr auto auto auto 1fr;
    gap: 2px 12px;
    padding: 6px 0;
  }
  .card-art-wrap { grid-column: 1; grid-row: 1 / 6; align-self: center; height: 64px; aspect-ratio: auto; }
  .card-meta { grid-column: 2; grid-row: 2; min-height: 1.4em; }
  .card-title { grid-column: 2; grid-row: 3; font-size: 17px; }
  .card-blurb { grid-column: 2; grid-row: 4; -webkit-line-clamp: 1; }
  .grid-status { padding-top: 8px; }
}

/* Phones and portrait tablets: art first, then title, description, details;
   only the description scrolls. */
@media (max-width: 560px), (max-width: 960px) and (orientation: portrait) {
  /* Here the whole page scrolls instead of a box inside it. */
  .file-page { display: flex; flex-direction: column; gap: 8px; padding: 12px var(--gutter) 24px; overflow-y: auto; }
  .file-text, .file-side { display: contents; }
  .file-art-wrap { order: 0; flex: none; height: clamp(100px, 40dvh - 120px, 320px); margin-bottom: 4px; }
  .file-decrypt { order: 1; }
  .file-title { order: 2; margin-bottom: 4px; }
  .file-hook { order: 3; }
  .file-about { order: 5; }
}

/* Narrowest phones: the bar drops its counter and shrinks the wordmark so Close keeps its margin. */
@media (max-width: 380px) {
  .bar-count { display: none; }
  .bar-home { font-size: 15px; }
}

/* Phones on their side: sidebar beside the grid again, file text beside its art. */
@media (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
  .app { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar { gap: 8px; padding: 12px var(--gutter); border-right: 1px solid var(--line); border-bottom: 0; overflow-y: auto; scrollbar-width: none; }
  .masthead { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .masthead .titlecard { grid-row: auto; width: 75%; }
  .lede, .ticker { display: none; }
  .controls { display: grid; gap: 8px 12px; }
  .sidebar-foot { padding-left: 0; border-left: 0; }
  .main { padding-top: 8px; }
  .grid { grid-template-columns: 1fr 1fr; column-gap: 24px; }

  .file-page { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); grid-template-rows: none; gap: 24px; padding: 12px var(--gutter); }
  .file-text { gap: 8px; }
  .file-hook { display: none; }
  .file-side { flex-direction: column; gap: 8px; }
}

/* ---------- Motion ----------
   Terminal motion: wireframe art scans in behind a scan line, readouts type out,
   and everything else glides to rest on --ease-out. index.html adds .motion to <html>
   only when the viewer allows motion, so without it everything is simply visible. */

/* Keyframes give only their starting point, so hover styles still apply once they finish. */
@keyframes scan-reveal { from { clip-path: inset(0 0 100% 0); filter: brightness(2); } }
@keyframes scan-down { 0% { top: 0; opacity: 1; } 99% { top: 100%; opacity: 1; } 100% { top: 100%; opacity: 0; } }
@keyframes type-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes focus-in { from { opacity: 0; transform: translateY(0.3em); filter: blur(8px); } }
@keyframes step-in { from { opacity: 0; transform: translateX(calc(var(--step, 0) * 28px)); } }
@keyframes blink { 50% { opacity: 0.2; } }
@keyframes hex-pulse { 50% { opacity: 0.12; } }
@keyframes flick { 0% { opacity: 1; } 30% { opacity: 0.2; } 60%, 100% { opacity: 1; } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-6px); clip-path: inset(0 0 100% 0); } }

/* Hover and press transitions settle at once for viewers who prefer less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  opacity: 0;
  pointer-events: none;
}

/* Ambient: the status light blinks and the hexagon field breathes. */
.motion .ticker-light { animation: blink 1.4s steps(2, jump-none) infinite; }
.motion .ticker-text.is-typing { animation: type-in 900ms steps(36) both; }
.motion .sidebar::before { animation: hex-pulse 6s ease-in-out infinite; }

/* Opening sequence after the login: the title lines come into focus, then the rest rises in. */
.motion .masthead .fit { animation: focus-in 900ms var(--ease-out) both; }
.motion .masthead .fit:nth-child(1) { animation-delay: 200ms; }
.motion .masthead .fit:nth-child(2) { animation-delay: 340ms; }
.motion .masthead > :not(.titlecard) { animation: rise 700ms var(--ease-out) 560ms both; }
.motion .ticker { animation: rise 700ms var(--ease-out) 640ms both; }
.motion .controls { animation: rise 700ms var(--ease-out) 720ms both; }
.motion .results-head { animation: rise 700ms var(--ease-out) 600ms both; }

/* The category listing drops open. */
.motion .dir[open] .dir-list { animation: drop-in 260ms var(--ease-out) both; }

/* Cards come in as they appear, a few at a time: the art scans down, then the words rise in. */
.motion .card:not(.is-in) { visibility: hidden; }
.motion .card.is-in .card-art { animation: scan-reveal 760ms var(--ease-out) var(--d, 0ms) both; }
.motion .card.is-in .scanline { animation: scan-down 760ms var(--ease-out) var(--d, 0ms) both; }
.motion .card.is-in .card-meta { animation: rise 600ms var(--ease-out) calc(var(--d, 0ms) + 180ms) both; }
.motion .card.is-in .card-title { animation: rise 600ms var(--ease-out) calc(var(--d, 0ms) + 240ms) both; }
.motion .card.is-in .card-blurb { animation: rise 600ms var(--ease-out) calc(var(--d, 0ms) + 300ms) both; }
.motion .scan.is-scanning .scan-art { animation: scan-reveal 900ms var(--ease-out) both; }
.motion .scan.is-scanning .scanline { animation: scan-down 900ms var(--ease-out) both; }
.motion .grid-status.is-loading { animation: type-in 240ms steps(20) both; }

/* A scan line passes over the art while it is targeted. */
.motion .card-art-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  opacity: 0;
  pointer-events: none;
}
.motion .card:hover .card-art-wrap::after { animation: scan-down 900ms var(--ease-in-out) both; }

.motion .flick { animation: flick 180ms steps(3) both; }

/* A file opens in a window that grows out of whatever was clicked (app.js): the decrypt line
   types out, the title comes into focus, the report rises in a paragraph at a time, and the
   art scans down beside it. */
.motion .file.is-cutting .bar { animation: rise 600ms var(--ease-out) 220ms both; }
.motion .file.is-cutting .file-decrypt { animation: type-in 560ms steps(30) 120ms both; }
.motion .file.is-cutting .file-title { animation: focus-in 800ms var(--ease-out) 280ms both; }
.motion .file.is-cutting .file-hook { animation: rise 700ms var(--ease-out) 400ms both; }
.motion .file.is-cutting .file-about > * { animation: rise 700ms var(--ease-out) calc(480ms + var(--i, 0) * 70ms) both; }
.motion .file.is-cutting .file-art { animation: scan-reveal 1100ms var(--ease-out) 300ms both; }
.motion .file.is-cutting .file-art-wrap .scanline { animation: scan-down 1100ms var(--ease-out) 300ms both; }

/* Stepping to the next or previous file slides the new one in from that side. */
.motion .file.is-stepping :is(.file-decrypt, .file-title, .file-hook, .file-about) { animation: step-in 520ms var(--ease-out) both; }
.motion .file.is-stepping .file-title { animation-delay: 30ms; }
.motion .file.is-stepping .file-hook { animation-delay: 60ms; }
.motion .file.is-stepping .file-about { animation-delay: 90ms; }
.motion .file.is-stepping .file-art { animation: scan-reveal 700ms var(--ease-out) both; }
.motion .file.is-stepping .file-art-wrap .scanline { animation: scan-down 700ms var(--ease-out) both; }
