/* Feeder layout on top of Pico (classless). Pico provides typography, forms and dark mode;
   everything about the two-column reading layout lives here. */

:root {
  --pico-font-size: 100%;
  --pico-block-spacing-vertical: 1rem;
  --pico-form-element-spacing-vertical: .45rem;
  --pico-form-element-spacing-horizontal: .8rem;
  --thumb-w: 112px;
  --thumb-h: 80px;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, [type=submit] { width: auto; }
button.small { padding: .25rem .7rem; font-size: .85rem; }
button.link {
  background: none; border: 0; color: var(--pico-muted-color); padding: 0; margin: 0; font: inherit;
}
/* Pico classless ships no button variants; these two are all we need. */
button.outline {
  background: transparent; color: var(--pico-primary); border-color: var(--pico-primary);
}
button.outline:hover { background: var(--pico-primary-focus); }
button.outline.contrast { color: var(--pico-muted-color); border-color: var(--pico-muted-border-color); }
button.outline.contrast:hover { color: #d33a2c; border-color: #d33a2c; background: transparent; }
button.link:hover { color: var(--pico-primary); text-decoration: underline; }
.muted { color: var(--pico-muted-color); }

/* --- top bar ------------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--pico-background-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding: 0 1rem;
}
.topbar nav { max-width: 1200px; margin: 0 auto; min-height: 3rem; }
.topbar nav ul { margin: 0; }
.topbar nav li { padding: .5rem .6rem; display: flex; align-items: center; }
.topbar nav form { margin: 0; display: flex; }
.topbar nav button.link { line-height: inherit; }
.topbar .brand { font-weight: 700; text-decoration: none; }

/* --- page containers ---------------------------------------------------------------- */
main.page { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem; }
main.layout {
  max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem;
  display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 2rem; align-items: start;
}
.toolbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar h1 { font-size: 1.5rem; margin: 0; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar form { margin: 0; }
.filters { display: inline-flex; border: 1px solid var(--pico-muted-border-color); border-radius: 999px; overflow: hidden; }
.filters a { padding: .25rem .9rem; font-size: .9rem; text-decoration: none; color: var(--pico-muted-color); }
.filters a.active { background: var(--pico-primary); color: var(--pico-primary-inverse); }

/* --- sidebar / feed navigation ------------------------------------------------------ */
.sidebar { position: sticky; top: 4rem; }
.feed-nav { display: flex; flex-direction: column; gap: .15rem; }
.feed-link {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .6rem; border-radius: .4rem; text-decoration: none;
  --pico-color: var(--pico-contrast); color: var(--pico-color); font-size: .95rem;
}
.feed-link:hover { background: var(--pico-card-sectioning-background-color); }
.feed-link.active { background: var(--pico-primary-focus); font-weight: 600; }
.feed-link .name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-link .count { font-size: .8rem; color: var(--pico-muted-color); font-variant-numeric: tabular-nums; }
.feed-link.manage { color: var(--pico-muted-color); margin-top: .5rem; font-size: .9rem; }

/* --- entries ------------------------------------------------------------------------ */
.entries { display: flex; flex-direction: column; }
.entry {
  display: grid; grid-template-columns: var(--thumb-w) minmax(0, 1fr) 2.25rem;
  gap: 1rem; align-items: start;
  padding: .9rem 0; margin: 0;
  border-bottom: 1px solid var(--pico-muted-border-color);
  background: none; box-shadow: none; border-radius: 0;
}
.entry.read { opacity: .55; }
.entry.read:hover { opacity: .85; }
.thumb {
  display: block; width: var(--thumb-w); height: var(--thumb-h);
  border-radius: .4rem; overflow: hidden;
  background: var(--pico-card-sectioning-background-color);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-placeholder {
  display: flex; width: 100%; height: 100%; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700; color: var(--pico-muted-color);
}
.entry-main { min-width: 0; }
.entry-title { font-size: 1.05rem; line-height: 1.35; margin: 0 0 .2rem; }
.entry-title a { --pico-color: var(--pico-h3-color); text-decoration: none; }
.entry-title a:hover { --pico-color: var(--pico-primary); text-decoration: underline; }
.entry .meta { font-size: .8rem; color: var(--pico-muted-color); margin: 0 0 .3rem; }
.entry .meta a { --pico-color: var(--pico-muted-color); text-decoration: none; }
.entry .meta a:hover { text-decoration: underline; }
.entry-body { cursor: pointer; }
.excerpt {
  margin: 0; font-size: .9rem; color: var(--pico-muted-color); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.entry-body .full { display: none; font-size: .95rem; margin-top: .5rem; }
.entry-body.open .excerpt { display: none; }
.entry-body.open .full { display: block; }
.full img { max-width: 100%; height: auto; border-radius: .3rem; }
.full p:last-child { margin-bottom: 0; }
.toggle-read {
  width: 1.75rem; height: 1.75rem; margin: .25rem 0 0 .5rem; padding: 0; border-radius: 50%;
  border: 2px solid var(--pico-primary); background: var(--pico-primary);
  box-shadow: inset 0 0 0 3px var(--pico-background-color);
  -webkit-tap-highlight-color: transparent;
}
.entry.read .toggle-read { background: transparent; border-color: var(--pico-muted-border-color); box-shadow: none; }
.toggle-read:hover { filter: brightness(1.1); }
.load-more, .empty { text-align: center; color: var(--pico-muted-color); padding: 2rem 0; }

/* --- feeds page --------------------------------------------------------------------- */
.feed-form { margin-bottom: 1rem; }
.feed-form fieldset { margin: 0; }
.table-wrap { overflow-x: auto; }
.feeds-table td { vertical-align: middle; }
.actions { white-space: nowrap; }
.actions button { margin: 0 .25rem 0 0; }
.health { display: inline-block; width: .7em; height: .7em; border-radius: 50%; background: #9aa0a6; vertical-align: middle; flex: none; }
.health-healthy { background: #2e9e5b; }
.health-degraded { background: #e0a100; }
.health-failing { background: #d33a2c; }
.health-stale { background: #7a8aa0; }
.stats { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; }
.stats dt { font-weight: 600; }
.stats dd { margin: 0; }
tr.fetch-error td { color: #d33a2c; }

/* --- narrow screens ------------------------------------------------------------------ */
@media (max-width: 820px) {
  :root { --thumb-w: 80px; --thumb-h: 60px; }
  main.layout { display: block; padding: .75rem .75rem 1.25rem; }
  main.page { padding: .75rem .75rem 1.25rem; }
  .sidebar { position: static; margin: 0 -.75rem .75rem; }
  .feed-nav {
    flex-direction: row; gap: .35rem; overflow-x: auto; padding: 0 .75rem .25rem;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .feed-nav::-webkit-scrollbar { display: none; }
  .feed-link {
    flex: none; border: 1px solid var(--pico-muted-border-color); border-radius: 999px;
    padding: .3rem .75rem; font-size: .85rem; max-width: 60vw;
  }
  .feed-link.manage { margin-top: 0; }
  .toolbar h1 { font-size: 1.25rem; }
  .entry { grid-template-columns: var(--thumb-w) minmax(0, 1fr) 2.25rem; gap: .75rem; padding: .75rem 0; }
  .entry-title { font-size: 1rem; }
  .excerpt { -webkit-line-clamp: 2; }
  .topbar nav li { padding: .5rem .4rem; }
}
