/* Nostrbook stylesheet — bearblog-style redesign.
   Sections: base → apex type scale → site chrome → buttons & forms →
   landing → info pages → discover/search feed → editor → blog polish.
   Blog-facing rules stay single-class so per-user theme CSS (which loads
   after this sheet) always wins on equal specificity. */

/* --- Base -------------------------------------------------------------- */
:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #ffffff;
  --accent: #8250df;
  --muted: #6b6b6b;
  --border: #e5e5e5;
  --code-bg: #f5f4f8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e6e6;
    --bg: #121212;
    --accent: #a685f5; /* AA on #121212 */
    --muted: #9b9b9b;
    --border: #2b2b2b;
    --code-bg: #1d1b22;
  }
}

body {
  margin: 0 auto;
  max-width: 42rem;
  padding: 2rem 1rem;
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
}

a {
  color: var(--accent);
}

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

hr {
  border: 0;
  border-top: 1px solid var(--border);
}

/* --- Apex type scale (never leaks onto blog pages) ---------------------- */
.apex h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.apex h2 {
  font-size: 1.2rem;
  margin: 2.25rem 0 0.5rem;
}

.apex h3 {
  font-size: 1rem;
  margin: 1.5rem 0 0.25rem;
}

.apex p {
  margin: 0.6rem 0;
}

/* --- Site chrome (SiteHeader / SiteFooter) ------------------------------ */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

/* The mark is an <img> (static /logo.svg with its own light/dark colors). */
.site-brand img {
  flex: none;
  display: block;
}

.site-nav-links {
  display: flex;
  gap: 1rem;
  font-size: 0.95rem;
}

.site-nav-links a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav-links a:hover,
.site-nav-links a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
}

.site-footer {
  margin-top: 4.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0.35rem 0;
}

.site-footer a {
  color: var(--muted);
}

.site-footer a:hover {
  color: var(--accent);
}

/* --- Buttons & forms (apex only; MUST precede the editor section so the
       toolbar/tab button rules below override these generics) ------------ */
.apex button,
.cta-button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
  padding: 0.5rem 1.1rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
  text-decoration: none;
}

.apex button:hover,
.cta-button:hover {
  filter: brightness(1.08);
}

.apex button.danger {
  background: transparent;
  color: #c62828;
  border-color: currentColor;
}

/* Contrast (WCAG AA), dark scheme: white on the lightened accent is only
   2.88:1, so filled-button text flips dark (#121212 on #a685f5 = 6.51:1);
   the outline danger button needs the lighter red (#ef5350 = 5.37:1).
   Placed HERE, before the editor section, so the transparent toolbar/tab
   button rules further down still win on source order in dark mode. */
@media (prefers-color-scheme: dark) {
  .apex button,
  .cta-button {
    color: #121212;
  }

  .apex button.danger {
    color: #ef5350;
  }
}

.cta-secondary {
  margin-left: 0.75rem;
}

.apex input[type="text"],
.apex input[type="search"],
.apex input[type="url"],
.apex textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
}

.apex input[type="text"]:focus,
.apex input[type="search"]:focus,
.apex input[type="url"]:focus,
.apex textarea:focus {
  border-color: var(--accent);
}

.apex textarea {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- Landing ------------------------------------------------------------ */
.landing .hero {
  text-align: center;
  padding: 2rem 0 1rem;
}

.landing .hero .logo-hero {
  display: inline-block;
}

.landing .hero h1 {
  font-size: 2.5rem;
  margin: 0.75rem 0 0.5rem;
}

.tagline {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.tagline-sub {
  color: var(--muted);
  max-width: 34rem;
  margin: 0 auto;
}

.landing-cta {
  margin: 1.75rem 0;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 2.5rem 0;
}

.feature-list li {
  position: relative;
  padding: 0.45rem 0 0.45rem 1.7rem;
}

.feature-list li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.landing-links {
  text-align: center;
  font-size: 0.9rem;
}

/* --- Info pages (docs / privacy / terms) -------------------------------- */
.info-page {
  font-size: 0.97rem;
}

.info-page .updated {
  color: var(--muted);
  font-size: 0.85rem;
}

.info-page code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* --- Discover / search feed --------------------------------------------- */
/* Scoped to the discover/search feed only (.feed-list): tenant blog pages
   and the dashboard reuse the .post-* class names and must keep the exact
   base styles P5 shipped with, or per-user theme CSS composes against
   different foundations (review fix). */
.feed-list {
  list-style: none;
  padding: 0;
}

.feed-list .post-item {
  margin-bottom: 1.25rem;
}

.feed-list .post-summary {
  margin: 0.25rem 0 0;
  opacity: 0.85;
}

.feed-list .post-date,
.feed-list .post-author {
  font-size: 0.85rem;
  opacity: 0.75;
}

.search-form input[type="search"] {
  padding: 0.4rem 0.6rem;
  width: 60%;
  max-width: 20rem;
}

.pager {
  display: flex;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

/* .empty is also a tenant-home class — style it only under the P6 pages'
   own <main> wrappers (same review fix as .feed-list above). */
.discover .empty,
.search .empty,
.search-hint {
  opacity: 0.85;
}

/* --- Editor (styles the editor markup contract; overrides the generic
       .apex button rules above by coming later in the sheet) ------------- */
body.editor-wide {
  max-width: 56rem;
}

.editor-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.editor-tabs [role="tab"] {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.editor-tabs [role="tab"][aria-selected="true"] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.editor-toolbar button {
  min-width: 32px;
  min-height: 32px;
  padding: 0.2rem 0.45rem;
  background: transparent;
  color: var(--fg);
  border: 0;
  border-radius: 4px;
  font-weight: 400;
  cursor: pointer;
}

.editor-toolbar button:hover {
  background: var(--code-bg);
}

.toolbar-sep {
  width: 1px;
  background: var(--border);
  margin: 0.25rem 0.35rem;
}

#post-content {
  width: 100%;
  min-height: 24rem;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.55;
}

.editor-meta {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: right;
  margin: 0.35rem 0;
}

.editor-meta.warn {
  color: #b45309;
}

.editor-meta.danger {
  color: #c62828;
}

@media (prefers-color-scheme: dark) {
  .editor-meta.warn {
    color: #fbbf24;
  }

  .editor-meta.danger {
    color: #ef5350;
  }
}

.draft-notice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.draft-notice button {
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}

/* --- Blog polish (ADDITIVE, single-class specificity so per-user theme
       <style> — which loads after this sheet — always wins) -------------- */
.blog-header {
  margin-bottom: 2.25rem;
}

.blog-avatar {
  border-radius: 50%;
}

.blog-name {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0.5rem 0 0;
}

/* Compound blog rules use :where() to zero out the class specificity:
   each computes as a bare element selector, so ANY later per-user theme
   rule (the theme <style> loads after this sheet) ties or beats it. */
:where(.blog-name) a {
  color: var(--fg);
  text-decoration: none;
}

.blog-handle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.blog-about {
  margin-top: 0.5rem;
}

.blog-footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.post-list {
  list-style: none;
  padding-left: 0;
}

.post-item {
  margin-bottom: 1.1rem;
}

.post-link {
  font-weight: 600;
}

.post-date,
.post-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.post-summary {
  margin: 0.15rem 0 0;
  color: var(--muted);
}

:where(.post-content) img,
:where(.post-content) video {
  max-width: 100%;
  height: auto;
}

:where(.post-content) pre {
  overflow-x: auto;
  padding: 0.75rem 1rem;
  background: var(--code-bg);
  border-radius: 6px;
}

:where(.post-content) code {
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}

:where(.post-content pre) code {
  background: none;
  padding: 0;
}

:where(.post-content) blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
