/* ────────────────────────────────────────────────────
   Blog + admin — extends the editorial design system
   (design tokens come from style.css :root)
──────────────────────────────────────────────────── */

.blog-page {
  border-top: none;
  padding-top: 4rem;
}

.blog-empty {
  color: var(--faint);
}

/* ─── Blog index ──────────────────────────────────── */

.blog-list {
  display: flex;
  flex-direction: column;
}

.blog-entry {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 2rem;
  padding: 1.9rem 0;
  border-bottom: 1px solid var(--line);
}

.blog-entry:first-child {
  padding-top: 0;
}

.blog-date,
.blog-date a {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent-ink);
  white-space: nowrap;
}

.blog-date a:hover {
  text-decoration: underline;
}

.blog-entry-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.45rem;
}

.blog-entry-title a:hover {
  color: var(--accent-ink);
}

.blog-entry-summary {
  font-size: 0.97rem;
  margin-bottom: 0.7rem;
}

.blog-readmore {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent-ink);
}

.blog-readmore:hover {
  text-decoration: underline;
}

.blog-entry.note .note-body {
  font-size: 0.97rem;
}

/* ─── Post page ───────────────────────────────────── */

.post-container {
  max-width: 760px;
}

.blog-breadcrumb {
  font-family: var(--mono);
  font-size: 0.78rem;
  margin-bottom: 2.2rem;
}

.blog-breadcrumb a {
  color: var(--accent-ink);
}

.blog-breadcrumb a:hover {
  text-decoration: underline;
}

.post-head {
  margin-bottom: 2.2rem;
}

.post-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 4.5vw, 2.7rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 0.8rem;
}

.post-meta {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--faint);
}

.post-kind {
  color: var(--accent-ink);
}

/* ─── Prose (rendered markdown) ───────────────────── */

.prose {
  font-size: 1.02rem;
  color: var(--muted);
  line-height: 1.75;
}

.prose > * + * {
  margin-top: 1rem;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin-top: 2.2rem;
}

.prose h1 { font-size: 1.7rem; }
.prose h2 { font-size: 1.45rem; }
.prose h3 { font-size: 1.2rem; }
.prose h4 { font-size: 1.05rem; }

.prose a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: var(--line-dark);
  text-underline-offset: 3px;
}

.prose a:hover {
  text-decoration-color: var(--accent-ink);
}

.prose strong {
  color: var(--ink);
}

.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.prose pre {
  background: var(--ink);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--paper);
  font-size: 0.86rem;
  line-height: 1.6;
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 1.2rem;
  font-style: italic;
}

.prose ul, .prose ol {
  padding-left: 1.4rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.prose img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.prose th, .prose td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
}

.prose th {
  background: var(--paper-soft);
  color: var(--ink);
}

/* ─── Admin shared ────────────────────────────────── */

.admin-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-head {
  margin-bottom: 1.5rem;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.flash {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1.5rem;
  overflow-wrap: anywhere;
}

/* ─── Connection cards ────────────────────────────── */

.conn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2.5rem;
}

.conn-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
}

.conn-title {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-bottom: 0.5rem;
}

.conn-status {
  font-size: 0.88rem;
}

.conn-status.ok    { color: var(--accent-ink); }
.conn-status.warn  { color: #b45309; }

.conn-btn {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  padding: 0.45rem 1rem;
}

.conn-fallback {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  color: var(--faint);
}

.conn-fallback summary {
  cursor: pointer;
}

.paste-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.paste-form input[type="password"] {
  flex: 1;
}

/* ─── Post table ──────────────────────────────────── */

.post-table-wrap {
  overflow-x: auto;
}

.post-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.post-table th {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line-dark);
}

.post-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.cell-title {
  max-width: 42ch;
}

.cell-title a {
  color: var(--ink);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.cell-title a:hover {
  color: var(--accent-ink);
}

.cell-kind {
  display: inline-block;
  margin-left: 0.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cell-mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--faint);
  white-space: nowrap;
}

.badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--line-dark);
  color: var(--faint);
}

.badge.published {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.badge.draft {
  color: #b45309;
  border-color: #f5d9ad;
  background: #fdf6ec;
  margin-left: 0.35rem;
}

.cell-network {
  white-space: nowrap;
}

.xpost {
  font-family: var(--mono);
  font-size: 0.76rem;
}

.xpost.ok   { color: var(--accent-ink); }
.xpost.fail { color: #b91c1c; cursor: help; }
.xpost.none { color: var(--line-dark); }

.inline-form {
  display: inline;
}

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--accent-ink);
  padding: 0 0 0 0.5rem;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: #b91c1c;
}

.cell-actions {
  white-space: nowrap;
  text-align: right;
}

/* ─── Forms ───────────────────────────────────────── */

.login-wrap {
  display: grid;
  place-items: center;
  min-height: 50vh;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.5rem 2.25rem;
}

.login-title {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
  margin: 0.4rem 0 1.4rem;
}

.login-btn {
  width: 100%;
  justify-content: center;
  margin-top: 1.2rem;
}

.form-error {
  font-size: 0.88rem;
  color: #b91c1c;
  margin-bottom: 1rem;
}

.field {
  display: block;
  margin-bottom: 1.1rem;
}

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.4rem;
}

.field-hint {
  text-transform: none;
  letter-spacing: 0;
  color: var(--line-dark);
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* ─── Editor ──────────────────────────────────────── */

.edit-form {
  max-width: 860px;
}

.field-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}

.kind-toggle {
  border: none;
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.kind-toggle legend {
  float: left;
  margin-right: 1rem;
}

.kind-toggle label,
.check {
  font-size: 0.9rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.kind-toggle input,
.check input {
  accent-color: var(--accent);
}

.perma {
  font-size: 0.85rem;
  color: var(--faint);
}

.publish-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.publish-group {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.publish-note {
  margin-top: 1.4rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  margin-bottom: -0.4rem;
}

/* When the note already draws the divider, the bar below it shouldn't repeat it. */
.publish-note + .publish-bar {
  border-top: none;
  margin-top: 0.9rem;
  padding-top: 0;
}

/* ─── Cross-post toggle chips ─────────────────────── */

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-body {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--faint);
  background: #fff;
  border: 1px solid var(--line-dark);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip-body:hover {
  border-color: var(--accent);
}

.chip input:checked + .chip-body {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip input:focus-visible + .chip-body {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Cross-post preview cards ────────────────────── */

.xpost-previews {
  margin-top: 1.4rem;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.6rem;
}

.social-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.social-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.social-avatar {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.social-id {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
  flex: 1;
}

.social-id strong {
  font-size: 0.86rem;
  color: var(--ink);
}

.social-sub {
  font-size: 0.75rem;
  color: var(--faint);
}

.social-logo {
  color: var(--ink);
  flex-shrink: 0;
}

.social-logo.li {
  color: #0a66c2;
}

.social-text {
  font-size: 0.88rem;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.li-article {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  background: var(--paper-soft);
}

.li-article strong {
  font-size: 0.84rem;
  color: var(--ink);
}

.li-article span {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--faint);
}

/* EasyMDE theme alignment */
.EasyMDEContainer .CodeMirror {
  border: 1px solid var(--line-dark);
  border-radius: 0 0 var(--radius) var(--radius);
  color: var(--ink);
  font-size: 0.95rem;
}

.editor-toolbar {
  border: 1px solid var(--line-dark);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--paper-soft);
}

.editor-toolbar button.active,
.editor-toolbar button:hover {
  background: #fff;
  border-color: var(--line-dark);
}

.editor-preview {
  background: var(--paper);
}

/* If fullscreen is triggered via keyboard (F11), keep the editor and its
   toolbar above the sticky site header so the exit button stays reachable */
.editor-toolbar.fullscreen {
  z-index: 200;
}

.EasyMDEContainer .CodeMirror-fullscreen,
.EasyMDEContainer .CodeMirror-fullscreen ~ .editor-preview-side {
  z-index: 199;
}

/* ─── Responsive ──────────────────────────────────── */

@media (max-width: 640px) {
  .blog-entry {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .publish-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .publish-group {
    justify-content: space-between;
  }

  /* Post list: collapse the table into stacked cards so it never side-scrolls */
  .post-table-wrap {
    overflow-x: visible;
  }

  .post-table thead {
    display: none;
  }

  .post-table,
  .post-table tbody,
  .post-table tr,
  .post-table td {
    display: block;
    width: 100%;
  }

  .post-table tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.4rem 1.1rem;
    margin-bottom: 1rem;
  }

  .post-table td {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    text-align: right;
  }

  .post-table tr td:last-child {
    border-bottom: none;
  }

  /* data-label becomes the field name on the left; the value group sits right */
  .post-table td::before {
    content: attr(data-label);
    margin-right: auto;
    font-family: var(--mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--faint);
    text-align: left;
  }

  /* Title spans the full width as the card heading */
  .cell-title {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    border-bottom: 1px solid var(--line-dark);
  }

  .cell-title::before {
    display: none;
  }

  .cell-title a {
    font-size: 1.02rem;
  }

  .cell-kind {
    margin-left: 0;
    margin-top: 0.2rem;
  }

  .cell-actions {
    justify-content: flex-end;
  }

  .link-btn {
    padding: 0.2rem 0 0.2rem 0.75rem;
  }
}
