/* PULP — a terminal-flavoured reader.
   Ported from the PULP Reader TUI design component. Every colour and metric
   here comes from that file; the design's inline `style-hover` attributes
   become ordinary :hover rules. */

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/jetbrains-mono-400-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/jetbrains-mono-400-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono-500-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/jetbrains-mono-500-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(fonts/jetbrains-mono-700-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(fonts/jetbrains-mono-700-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0f110d;
  --panel: #12150f;
  --text: #d6d3c4;
  --title: #e4e1d2;
  --title-strong: #f2efe1;
  --muted: #5c6150;
  --blurb: #6e7362;
  --blurb-strong: #c9c6b7;
  --rule: #2a2e24;
  --hover: #1d2117;
  --footer: #14170f;
  --amber: #ffc53d;
  --teal: #56d4c4;
  --red: #ff6b5e;
  --violet: #b79cff;
  /* Panes set --feed to their own accent; this is the fallback. */
  --feed: var(--amber);
  --statusbar-height: 34px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
}

body {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: var(--statusbar-height);
}

a {
  color: var(--teal);
  text-decoration: none;
}
a:hover,
a:focus-visible {
  color: var(--amber);
}

::selection {
  background: var(--amber);
  color: var(--bg);
}

:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 1px;
}

/* Screen-reader-only text, for labels the TUI conveys with glyphs alone. */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- topbar -- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--amber);
  color: var(--bg);
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.topbar a {
  color: var(--bg);
}
.topbar a:hover {
  color: var(--bg);
  opacity: 0.6;
}

.topbar__brand {
  letter-spacing: 0.14em;
}

.topbar__meta {
  opacity: 0.65;
  margin-left: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__spacer {
  flex: 1;
}

.topbar__action {
  font: inherit;
  font-weight: 700;
  background: transparent;
  color: var(--bg);
  border: 0;
  padding: 0 12px 0 0;
  cursor: pointer;
  white-space: nowrap;
}
.topbar__action:hover {
  opacity: 0.6;
}

/* The refresh control is a form so it degrades without JS; display:contents
   keeps it out of the topbar's flex layout. */
.topbar__refresh {
  display: contents;
}

/* htmx puts .htmx-request on the form while the sync is in flight, which is
   how the label swaps to "syncing…" without a line of JavaScript. */
.topbar__busy {
  display: none;
}
.htmx-request .topbar__idle {
  display: none;
}
.htmx-request .topbar__busy {
  display: inline;
}
.topbar__action:disabled {
  cursor: default;
  opacity: 0.75;
}

/* The undo slot is empty almost always; display:contents keeps it from
   reserving a gap in the topbar's flex row when it has nothing to show. */
.topbar__undo {
  display: contents;
}
.topbar__action--undo {
  font-weight: 700;
  text-decoration: underline;
}

.topbar__clock {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 10px;
  padding: 12px;
  align-items: start;
}

/* ------------------------------------------------------------------ pane -- */

.pane {
  border: 1px solid var(--feed);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* The header sits *on* the border: each chip paints the panel colour behind
   itself, knocking a hole in the 1px rule the way a TUI box label does. */
.pane__header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  margin-top: -8px;
}

.pane__name {
  background: var(--panel);
  color: var(--feed);
  font-weight: 700;
  font-size: 12px;
  padding: 0 6px;
  white-space: nowrap;
}
.pane__name:hover {
  color: var(--amber);
}

.pane__domain {
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane__count {
  background: var(--panel);
  color: var(--feed);
  font-size: 11px;
  padding: 0 6px;
  white-space: nowrap;
}

.pane__rows {
  display: flex;
  flex-direction: column;
  padding: 4px 0 2px;
}

.pane__empty {
  color: var(--muted);
  font-size: 12px;
  padding: 6px 10px 8px;
}

.pane__error {
  color: var(--red);
  font-size: 11px;
  padding: 0 10px 6px;
  overflow-wrap: anywhere;
}

/* The footer carries the rule now, so its two controls sit on one line under
   a single dashed divider rather than each drawing their own. */
.pane__footer {
  display: flex;
  align-items: stretch;
  border-top: 1px dashed var(--rule);
  margin-top: auto;
}

.pane__more,
.pane__mark {
  font: inherit;
  font-size: 11px;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 4px 10px;
  text-align: left;
  cursor: pointer;
  display: block;
  white-space: nowrap;
}
.pane__more {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pane__mark {
  border-left: 1px dashed var(--rule);
}
.pane__more:hover,
.pane__mark:hover {
  color: var(--amber);
  background: var(--hover);
}
.pane__mark:hover {
  color: var(--teal);
}

/* ------------------------------------------------------------------- row -- */

.row {
  display: grid;
  grid-template-columns: 14px 24px 1fr auto;
  gap: 6px;
  padding: 2px 10px 4px;
  cursor: pointer;
  align-items: baseline;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  /* The row is an anchor so middle-click opens the article; it must not pick
     up the global link styling. */
  text-decoration: none;
}
.row:hover .row__title,
.row:focus-visible .row__title {
  color: var(--amber);
}
.row:hover {
  background: var(--hover);
}
/* The caret is the cursor; keyboard selection is the same state as an open
   entry, so it reads identically whether you got there by key or by mouse. */
.row.is-current {
  background: var(--hover);
}
.row.is-current .row__caret::before {
  content: "▸";
}
.row.is-current .row__title {
  color: var(--amber);
}

.row__caret {
  color: var(--feed);
  font-size: 12px;
  min-height: 1em;
}

.row__num {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row__main {
  min-width: 0;
}

/* The row is a <button>, so its parts are spans; they still need to stack. */
.row__main,
.row__title,
.row__blurb {
  display: block;
}

.row__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--title);
  line-height: 1.35;
  text-wrap: pretty;
}

.row__blurb {
  color: var(--blurb);
  font-size: 12px;
  line-height: 1.4;
  text-wrap: pretty;
}

.row__age {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

/* Read entries only appear in the archive view, where they recede. */
.row.is-read .row__title {
  color: var(--muted);
  font-weight: 400;
}
.row.is-read .row__blurb {
  color: #4d5243;
}

/* ---------------------------------------------------------------- reader -- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 13, 0.72);
  z-index: 40;
  border: 0;
  padding: 0;
  width: 100%;
  cursor: default;
}

.reader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, calc(100% - 40px));
  max-height: 80vh;
  background: var(--panel);
  border: 1px solid var(--feed);
  z-index: 41;
  display: flex;
  flex-direction: column;
}

.reader__header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 8px;
  margin-top: -8px;
  flex-shrink: 0;
}

.reader__close {
  font: inherit;
  background: var(--panel);
  color: var(--red);
  border: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 0 6px;
  cursor: pointer;
}
.reader__close:hover {
  color: var(--amber);
}

.reader__body {
  padding: 12px 18px 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

.reader__meta {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 8px;
}

.reader__title {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--title-strong);
  text-wrap: pretty;
}

.summary {
  border-left: 2px solid var(--violet);
  padding: 2px 0 2px 12px;
}

.summary__label {
  color: var(--violet);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.summary__text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--blurb-strong);
  text-wrap: pretty;
}

.reader__actions {
  display: flex;
  gap: 16px;
  margin-top: 18px;
  font-size: 12px;
  font-weight: 700;
  flex-wrap: wrap;
}

.reader__actions button {
  font: inherit;
  font-weight: 700;
  background: transparent;
  border: 0;
  color: var(--teal);
  padding: 0;
  cursor: pointer;
}
.reader__actions button:hover {
  color: var(--amber);
}

/* Feed-supplied article markup. Kept deliberately plain: this is sanitised
   third-party HTML and it should not be able to fight the surrounding design. */
.article {
  margin-top: 18px;
  border-top: 1px dashed var(--rule);
  padding-top: 14px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.article > :first-child {
  margin-top: 0;
}
.article p,
.article ul,
.article ol,
.article blockquote,
.article pre {
  margin: 0 0 12px;
}
.article h1,
.article h2,
.article h3,
.article h4 {
  color: var(--title);
  font-size: 14px;
  margin: 18px 0 8px;
}
.article img,
.article video,
.article iframe {
  max-width: 100%;
  height: auto;
  display: block;
}
.article blockquote {
  border-left: 2px solid var(--rule);
  padding-left: 12px;
  color: var(--blurb);
}
.article pre,
.article code {
  font-family: inherit;
  font-size: 12px;
}
.article pre {
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 8px 10px;
  overflow-x: auto;
}
.article table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}
.article td,
.article th {
  border: 1px solid var(--rule);
  padding: 3px 6px;
}

/* ------------------------------------------------------------- statusbar -- */

.statusbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--footer);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 11px;
  padding: 5px 10px;
  z-index: 30;
}

.statusbar__mode {
  color: var(--bg);
  background: var(--teal);
  font-weight: 700;
  padding: 0 6px;
}

.statusbar kbd {
  font: inherit;
  color: var(--text);
}

.statusbar__spacer {
  flex: 1;
}

.statusbar__right {
  white-space: nowrap;
}

/* ------------------------------------------------------------- utilities -- */

.page {
  padding: 12px;
  max-width: 900px;
}

.panel {
  border: 1px solid var(--feed);
  background: var(--panel);
  margin-bottom: 12px;
}

.panel__body {
  padding: 8px 12px 12px;
}

.field {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}

input[type="url"],
input[type="text"],
input[type="password"],
input[type="file"] {
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  padding: 4px 8px;
  min-width: 0;
  flex: 1;
}
input::placeholder {
  color: #4d5243;
}
input:focus {
  border-color: var(--amber);
  outline: none;
}

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 12px;
  background: transparent;
  color: var(--teal);
  border: 1px solid currentColor;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  color: var(--amber);
}
.btn--danger {
  color: var(--red);
}
.btn--plain {
  border-color: var(--rule);
  color: var(--muted);
}
.btn--toggle {
  padding: 2px 6px;
  font-size: 11px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn:disabled:hover {
  color: inherit;
}

.feedlist__cadence {
  color: var(--muted);
  white-space: nowrap;
}

.notice {
  padding: 4px 12px;
  font-size: 12px;
  border-left: 2px solid var(--teal);
  margin: 0 0 10px;
  color: var(--blurb-strong);
}
.notice--error {
  border-color: var(--red);
  color: var(--red);
}

.feedlist {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.feedlist th {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  border-bottom: 1px dashed var(--rule);
  padding: 4px 6px;
}
.feedlist td {
  padding: 4px 6px;
  border-bottom: 1px dashed var(--rule);
  vertical-align: top;
}
.feedlist tr:last-child td {
  border-bottom: 0;
}
.feedlist__swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
}
.feedlist__url {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.feedlist__error {
  color: var(--red);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ login -- */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login .panel {
  width: min(380px, 100%);
  margin: 0;
}

/* -------------------------------------------------------------- responsive -- */

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
    padding: 8px;
    gap: 8px;
  }
  /* Keyboard hints are noise on a touch device; the mode and status stay. */
  .statusbar__keys {
    display: none;
  }
  .reader {
    width: calc(100% - 16px);
    max-height: 88vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
