/* Patron Reader — quiet paper, blue-black ink. */

:root {
  --paper: #E8EBE3;
  --ink: #1E2522;
  --quiet: #616B65;
  --rule: #CDD3CA;
  --accent: #24406B;        /* fountain-pen blue-black: unread, links, focus */
  --locked: #9AA39C;
  --wash: #DDE2D7;          /* pressed rows, inputs */
  --error: #8A2F2F;

  --serif: Charter, "Iowan Old Style", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --measure: 34rem;
  --gutter: 1.25rem;
  --reader-size: 1.1875rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #191D1B;
    --ink: #D6DBD2;
    --quiet: #8B958E;
    --rule: #2E3531;
    --accent: #93B2E0;
    --locked: #5D6661;
    --wash: #222826;
    --error: #E08F8F;
  }
}
:root[data-theme="dark"] {
  --paper: #191D1B;
  --ink: #D6DBD2;
  --quiet: #8B958E;
  --rule: #2E3531;
  --accent: #93B2E0;
  --locked: #5D6661;
  --wash: #222826;
  --error: #E08F8F;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- top bar ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: calc(env(safe-area-inset-top) + .5rem) var(--gutter) .5rem;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.bar-title {
  flex: 1;
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-back {
  text-decoration: none;
  font-size: 1.0625rem;
  padding: .35rem .25rem .35rem 0;
  white-space: nowrap;
}
.bar-actions { display: flex; gap: .25rem; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--quiet);
  cursor: pointer;
}
.icon-btn svg { width: 1.35rem; height: 1.35rem; }
.icon-btn:active { background: var(--wash); }
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .icon-btn.spinning svg { animation: none; opacity: .5; }
}

.status {
  padding: .5rem var(--gutter);
  font-size: .9375rem;
  color: var(--quiet);
  border-bottom: 1px solid var(--rule);
}
.status.error { color: var(--error); }

main { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; }

/* ---------- creator filter ---------- */

.filters {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .75rem var(--gutter);
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: .3rem .8rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  font-size: .9375rem;
  color: var(--quiet);
  text-decoration: none;
  white-space: nowrap;
}
.chip[aria-current="true"] {
  border-color: var(--ink);
  color: var(--ink);
}
.chip .count { color: var(--accent); margin-left: .3rem; }

/* ---------- feed ---------- */

.day {
  margin: 1.25rem var(--gutter) .25rem;
  font-size: .9375rem;
  font-style: italic;
  font-weight: 400;
  color: var(--quiet);
}
.posts { list-style: none; margin: 0; padding: 0; }
.post-row a {
  position: relative;
  display: block;
  padding: .7rem var(--gutter) .75rem calc(var(--gutter) + .25rem);
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.post-row:last-child a { border-bottom: 0; }
.post-row a:active { background: var(--wash); }
.post-title {
  display: block;
  font-size: 1.125rem;
  line-height: 1.3;
  font-weight: 400;
  color: var(--quiet);
}
.post-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .2rem;
  font-size: .875rem;
  color: var(--quiet);
}
.post-row.unread .post-title { color: var(--ink); font-weight: 700; }
.post-row.unread a::before {
  /* the ink blot */
  content: "";
  position: absolute;
  left: calc(var(--gutter) - .55rem);
  top: 1.15rem;
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--accent);
}
.post-row.locked .post-title { color: var(--locked); font-weight: 400; }
.post-row.locked .post-meta { color: var(--locked); }
.lock { width: .8em; height: .8em; vertical-align: -.05em; margin-right: .3em; }
.progress { color: var(--accent); }

.more {
  display: block;
  margin: 1.5rem auto 2.5rem;
  padding: .55rem 1.2rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  color: var(--quiet);
  cursor: pointer;
}

.empty {
  margin: 3rem var(--gutter);
  color: var(--quiet);
  text-align: center;
}

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

.reader {
  padding: 1.5rem var(--gutter) 3rem;
  font-size: var(--reader-size);
}
.running-head {
  display: inline-block;
  margin: 0 0 .75rem;
  padding-bottom: .3rem;
  border-bottom: 2px solid var(--accent);
  font-size: .9375rem;
  color: var(--quiet);
  text-decoration: none;
}
.reader h1 {
  margin: 0 0 .4rem;
  font-size: 1.9rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.reader .dateline {
  margin: 0 0 2rem;
  font-size: .9375rem;
  font-style: italic;
  color: var(--quiet);
}
.body {
  line-height: 1.65;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}
.body p { margin: 0 0 .9em; }
.body h2, .body h3, .body h4 { line-height: 1.25; margin: 1.6em 0 .6em; }
.body h2 { font-size: 1.35em; }
.body h3 { font-size: 1.15em; }
.body h4 { font-size: 1em; }
.body blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 2px solid var(--rule);
  color: var(--quiet);
}
.body hr {
  border: 0;
  margin: 2em 0;
  text-align: center;
}
.body hr::after { content: "⁂"; color: var(--quiet); }
.body img, .cover {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.25em auto;
  border-radius: 4px;
}
.body ul, .body ol { padding-left: 1.4em; }
.body table { border-collapse: collapse; font-size: .9em; display: block; overflow-x: auto; }
.body td, .body th { border: 1px solid var(--rule); padding: .3em .5em; }

.locked-note {
  padding: 1rem 0;
  color: var(--quiet);
  font-style: italic;
}

.reader-end {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 1rem;
}
.reader-end .next {
  padding: .55rem 1.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  text-decoration: none;
}

.size-controls { display: inline-flex; gap: .25rem; }
.size-controls button {
  min-width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  cursor: pointer;
  color: var(--quiet);
}

/* ---------- settings ---------- */

.settings { padding: 1.5rem var(--gutter) 3rem; }
.settings h2 { font-size: 1.5rem; margin: 0 0 .5rem; }
.settings .lede { color: var(--quiet); margin: 0 0 1.75rem; }
.field { margin-bottom: 1.4rem; }
.field label { display: block; font-weight: 700; margin-bottom: .3rem; }
.field input[type="password"], .field input[type="text"], .field select {
  width: 100%;
  padding: .65rem .75rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--wash);
  font-size: 1rem;
}
.field .hint { margin: .35rem 0 0; font-size: .9375rem; color: var(--quiet); }
.field details { margin-top: .4rem; font-size: .9375rem; color: var(--quiet); }
.settings summary { cursor: pointer; color: var(--accent); }
.field details ol { margin: .5rem 0 0; padding-left: 1.3rem; }
.field .check { font-weight: 400;
}
.check { display: flex; gap: .6rem; align-items: flex-start; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--accent); }
.primary {
  padding: .7rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  cursor: pointer;
}
.secondary {
  margin-left: .5rem;
  padding: .7rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: none;
  color: var(--quiet);
  cursor: pointer;
}
.form-error { color: var(--error); margin: 1rem 0 0; }
