/* =========================================================
   FEED — /etc notebook
   Reading-first prose, code, math, footnotes
   ========================================================= */

/* Feed page inherits .subpage's width and padding from foundation.css so
   the brand and back-link line up with every other subpage. The narrow
   reading column lives on .feed-shell.entry .prose. */
.feed-shell {
  overflow-wrap: anywhere;
}
.feed-shell,
.feed-shell * {
  min-width: 0;
}
.feed-shell h1,
.feed-shell h2,
.feed-shell h3 {
  overflow-wrap: anywhere;
}
.prose pre {
  white-space: pre;
}
.prose pre code {
  white-space: pre;
}
.prose .katex-display {
  max-width: 100%;
}

/* =========================================================
   FILES DISCOVERY — search + tag chips + note-card grid
   Obsidian-style scattered notebook surface.
   ========================================================= */

.feed-controls {
  --tile-bg: var(--cream-deep);
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* Cancel the .subpage flex-gap so search sits right above the grid. */
  margin: 0 0 calc(var(--s-3) - var(--subpage-gap));
  padding: 16px;
}
.feed-search {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.feed-search .field {
  width: 100%;
}
.feed-view {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.view-label {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink-mute);
  margin-right: 4px;
}
.view-chip {
  font-family: var(--font-display);
  font-size: 13px;
  padding: 8px 14px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  cursor: pointer;
  background: transparent;
  border: none;
}
.view-chip.is-active {
  --tile-bg: var(--ink);
  color: var(--cream);
}

.feed-grid {
  display: grid;
  /* Three columns inside the 64rem content band; downsteps to
     two on tablet and one on phone. Matches /work card grid. */
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3);
}
@media (max-width: 720px) {
  .feed-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 480px) {
  .feed-grid {
    grid-template-columns: 1fr;
  }
}

/* List view — table-style rows. Title + summary stack in column 1,
   tags occupy column 2, arrow column 3. Aligned via subgrid so every
   row's columns match the header. */
.list-head {
  display: none;
}
.feed-grid[data-view='list'] {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto;
  gap: 0;
  background: var(--cream);
  border: var(--border-thin);
  box-shadow: var(--shadow-md);
}
.feed-grid[data-view='list'] .list-head {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink-mute);
  background: var(--cream-deep);
  border-bottom: 2px solid var(--ink);
  padding: 10px var(--s-3);
  column-gap: var(--s-3);
}
/* List-view rows: clear the per-card tile chrome via the custom-property
   API so the rows read as a table inside the outer feed-grid card. Hover
   tints the row by overriding --tile-bg only. */
.feed-grid[data-view='list'] .note-card {
  --tile-bg: transparent;
  --tile-border: 0;
  --tile-shadow: none;
  --tile-shadow-hover: none;
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  column-gap: var(--s-3);
  row-gap: 4px;
  padding: 14px var(--s-3);
  border-bottom: 2px dashed var(--ink-mute);
}
.feed-grid[data-view='list'] .note-card:last-of-type {
  border-bottom: 0;
}
.feed-grid[data-view='list'] .note-card:hover {
  --tile-bg: var(--cream-deep);
}
.feed-grid[data-view='list'] .note-card:hover,
.feed-grid[data-view='list'] .note-card:active {
  transform: none;
}
.feed-grid[data-view='list'] .note-title {
  grid-column: 1;
  grid-row: 1;
  font-size: 18px;
  letter-spacing: -0.005em;
  margin: 0;
}
.feed-grid[data-view='list'] .note-summary {
  grid-column: 1;
  grid-row: 2;
  font-size: 14px;
  margin: 0;
  color: var(--ink-mute);
}
.feed-grid[data-view='list'] .note-meta {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  flex-wrap: wrap;
  gap: 6px;
}
.feed-grid[data-view='list'] .note-arrow {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 16px;
}

/* On narrow widths the table collapses gracefully. */
@media (max-width: 640px) {
  .feed-grid[data-view='list'] {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .feed-grid[data-view='list'] .list-head span:nth-child(2) {
    display: none;
  }
  .feed-grid[data-view='list'] .note-meta {
    grid-column: 1;
    grid-row: 3;
  }
  .feed-grid[data-view='list'] .note-arrow {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
}

.feed-grid .empty {
  font-family: var(--font-display);
  color: var(--ink-mute);
  padding: 24px;
  grid-column: 1 / -1;
}

.note-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: var(--s-4);
  text-decoration: none;
  color: var(--ink);
}
.note-card:hover {
  color: var(--ink);
}
.note-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--ink-mute);
}
.note-title {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.01em;
}
.note-summary {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink-mute);
  margin: 0;
  line-height: 1.5;
  flex: 1 1 auto;
}
.note-arrow {
  font-family: var(--font-display);
  font-size: 18px;
  align-self: flex-end;
  color: var(--ink);
}
.note-card:hover .note-arrow {
  color: var(--lavender);
}

/* Inside the 64rem prose band, narrow the text-flow elements to
   66ch for line-length, but let figures, code blocks, and other
   set-pieces fill the full 64rem so they read as deliberate
   call-outs against the narrower paragraphs. */
.entry .prose > :is(p, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, hr) {
  max-width: var(--reading-default);
}
.entry .prose > .footnotes {
  max-width: var(--reading-default);
}
.entry-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--ink-mute);
}

/* Base prose typography lives in foundation.css (.prose primitive).
   This file only adds essay-specific extras: KaTeX, footnotes,
   anchor links, and the responsive overrides at the bottom. */

/* KaTeX overrides on cream paper */
.prose .katex {
  font-size: 1.05em;
  color: var(--ink);
}
.prose .katex-display {
  margin: 1.6em 0;
  padding: 16px;
  background: var(--cream-deep);
  border: var(--border-thin);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

/* ---------- Footnotes — first-class citation style ----------
   Inline ref renders as a small lavender pill; the endnotes block
   at the bottom of an essay sits behind a labelled "Notes" header
   with a subtle dashed top rule. The backref arrow gets a hover
   bump so readers can tab through references.
   markdown-it-footnote emits:
     inline:    <sup class="footnote-ref"><a id="fnref1" href="#fn1">[1]</a></sup>
     block:     <hr class="footnotes-sep">
                <section class="footnotes">
                  <ol class="footnotes-list">
                    <li id="fn1" class="footnote-item">
                      <p>… <a href="#fnref1" class="footnote-backref">↩︎</a></p>
                    </li>
                  </ol>
                </section> */
.prose .footnote-ref {
  font-size: 0.65em;
  vertical-align: super;
  line-height: 0;
  margin: 0 1px 0 2px;
}
.prose .footnote-ref a {
  text-decoration: none;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--lavender);
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--lavender) 12%, transparent);
  transition:
    background var(--dur-press) var(--ease-press),
    color var(--dur-press) var(--ease-press);
}
.prose .footnote-ref a:hover,
.prose .footnote-ref a:focus-visible {
  background: var(--lavender);
  color: var(--offwhite);
}
/* Highlight the target footnote when the reader jumps to it. */
.prose .footnote-item:target {
  background: color-mix(in srgb, var(--lavender) 12%, transparent);
  border-left: 3px solid var(--lavender);
  padding-left: 12px;
  margin-left: -15px;
  transition: background 600ms ease;
}

.prose .footnotes-sep {
  display: none;
}
.prose .footnotes {
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 2px dashed var(--ink-mute);
  font-size: 0.9em;
  line-height: 1.55;
  color: var(--ink);
  position: relative;
}
.prose .footnotes::before {
  content: 'Notes';
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 1em;
}
.prose .footnotes ol,
.prose .footnotes-list {
  padding-left: 1.5em;
  margin: 0;
  counter-reset: footnote;
}
.prose .footnote-item {
  margin: 0 0 1em 0;
  padding: 0.25em 0;
}
.prose .footnote-item p {
  margin: 0;
}
.prose .footnote-backref {
  text-decoration: none;
  display: inline-block;
  margin-left: 8px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  transition:
    color var(--dur-press) var(--ease-press),
    transform var(--dur-press) var(--ease-press);
}
.prose .footnote-backref:hover,
.prose .footnote-backref:focus-visible {
  color: var(--lavender);
  transform: translate(-1px, -1px);
}

/* Anchor link on headings */
.prose .header-anchor {
  text-decoration: none;
  color: inherit;
}

/* End nav */
.entry-end {
  margin-top: var(--s-8);
  padding-top: var(--s-3);
  border-top: 2px dashed var(--ink-mute);
}
.entry-end a {
  font-family: var(--font-display);
  font-size: 14px;
  text-decoration: none;
}

/* Footer */
.feed-footer {
  margin-top: var(--s-8);
  padding-top: var(--s-3);
  border-top: 2px dashed var(--ink-mute);
  font-family: var(--font-display);
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.feed-footer a {
  color: var(--ink-mute);
}

/* =========================================================
   FEED — Tiered responsive layers
   ========================================================= */

/* ---------- Watch tier (281–359px) ----------
   Essays switch to a system font on the smallest screens —
   Birdie's display proportions get cramped at 14px. Reading
   measure narrows to 28ch so lines don't run too long against
   the tighter shell. */
@media (max-width: 359px) {
  .prose {
    font-family:
      system-ui,
      -apple-system,
      sans-serif;
    line-height: 1.6;
    max-width: 28ch;
  }
  .feed-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- Wrist band (≤280px) — tighter measure still. */
@media (max-width: 280px) {
  .prose {
    line-height: 1.55;
    max-width: 26ch;
  }
}
