/* ─── DRAGNOSIS ── clean white, purple accents ───────────────────────── */

:root {
  --purple-deep: #6c00a8;
  --purple: #8a05cf;
  --purple-soft: #b25ce6;
  --lilac: #e7cdf5;
  --lilac-bg: #f8f1fd;
  --ink: #241b2f;
  --muted: #756c80;
  --line: #eae4f0;
  --bg: #ffffff;
  --danger: #d6336c;
  --body-font: "Space Grotesk", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(108, 0, 168, 0.10);
  --shadow-sm: 0 2px 10px rgba(36, 27, 47, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

body {
  font-family: var(--body-font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 17px;
}

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

.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px 80px; }

/* ─── public header ─── */

.site-header { text-align: center; padding: 60px 20px 48px; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  text-decoration: none;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3rem);
  letter-spacing: -0.03em;
  color: var(--ink);
}
.wordmark img { width: 72px; height: 72px; transition: transform 0.25s ease; }
.wordmark:hover img { transform: rotate(12deg) scale(1.06); }
.wordmark em { font-style: normal; color: var(--purple); }

/* ─── post cards ─── */

.post-list { display: flex; flex-direction: column; gap: 22px; }

.post-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 30px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.post-card:hover {
  border-color: var(--purple-soft);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.post-card h2 { font-size: 1.55rem; line-height: 1.25; letter-spacing: -0.02em; margin: 10px 0 4px; }
.post-card h2 a { text-decoration: none; color: var(--ink); }
.post-card h2 a:hover { color: var(--purple); }

.post-card-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.82rem; font-weight: 500; color: var(--muted);
}

.tag-pill {
  background: var(--lilac-bg);
  color: var(--purple-deep);
  border-radius: 999px;
  padding: 2px 12px;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 700;
}
.tag-pill:hover { background: var(--lilac); }

.post-card-excerpt { margin: 6px 0 14px; color: var(--muted); }

.read-more {
  font-weight: 700; font-size: 0.9rem; text-decoration: none; color: var(--purple);
}
.read-more:hover { color: var(--purple-deep); text-decoration: underline; }

.tag-heading {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--purple-deep);
  background: var(--lilac-bg);
  border-radius: 999px;
  display: inline-block;
  padding: 6px 20px;
  margin-bottom: 28px;
}

/* ─── single post ─── */

.post-header { margin-bottom: 34px; }
.post-header h1 {
  font-size: clamp(1.9rem, 6vw, 2.8rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
  margin-top: 14px;
}

.draft-banner {
  background: var(--lilac-bg);
  color: var(--purple-deep);
  border: 1px solid var(--lilac);
  border-radius: var(--radius);
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.8rem;
  padding: 10px 16px; margin-bottom: 26px; text-align: center;
}

.back-link { margin-top: 54px; }
.back-link a { font-weight: 700; text-decoration: none; }
.back-link a:hover { text-decoration: underline; }

/* ─── prose (rendered markdown, shared with editor preview) ─── */

.prose { font-size: 1.05rem; }
.prose > * + * { margin-top: 1.15em; }
.prose h1, .prose h2, .prose h3 { line-height: 1.3; letter-spacing: -0.02em; margin-top: 1.7em; }
.prose h2 { font-size: 1.45rem; }
.prose h3 { font-size: 1.15rem; }
.prose img {
  max-width: 100%; height: auto; display: block;
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin: 1.8em auto;
}
.prose a { color: var(--purple); font-weight: 600; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
.prose a:hover { color: var(--purple-deep); }
.prose blockquote {
  border-left: 4px solid var(--purple);
  background: var(--lilac-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 22px;
  font-style: italic;
  color: var(--ink);
}
.prose code {
  background: var(--lilac-bg); color: var(--purple-deep);
  padding: 2px 7px; font-size: 0.88em; border-radius: 6px;
}
.prose pre {
  background: var(--ink); color: #f4effa;
  padding: 18px 20px; overflow-x: auto; border-radius: var(--radius);
}
.prose pre code { background: none; padding: 0; color: inherit; }
.prose hr {
  border: none; height: 2px; margin: 2.4em auto; width: 120px;
  background: linear-gradient(90deg, var(--lilac), var(--purple), var(--lilac));
  border-radius: 2px;
}
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li { margin-top: 0.4em; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; }
.prose th { background: var(--lilac-bg); color: var(--purple-deep); }

/* footnotes = references */
.prose .footnotes {
  margin-top: 3em; padding: 20px 24px;
  background: var(--lilac-bg); border-radius: var(--radius);
  font-size: 0.92rem;
}
.prose .footnotes::before {
  content: "References";
  display: block;
  font-weight: 700;
  color: var(--purple-deep);
  margin-bottom: 10px;
}
.prose .footnotes hr { display: none; }
.prose .footnote-ref { font-weight: 700; text-decoration: none; color: var(--purple); }

/* ─── footer ─── */

.site-footer {
  text-align: center; padding: 30px 20px 50px;
  color: var(--muted); font-size: 0.85rem;
}

/* ─── subscribe form (footer) ─── */

.subscribe {
  max-width: 420px; margin: 0 auto 28px; text-align: left;
  padding: 22px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--lilac-bg);
}
.subscribe-label {
  display: block; font-weight: 700; color: var(--ink);
  font-size: 0.95rem; margin-bottom: 10px; text-align: center;
}
.subscribe-row { display: flex; gap: 8px; }
.subscribe-input {
  flex: 1 1 auto; font-family: var(--body-font); font-size: 1rem;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); padding: 10px 14px; width: 100%;
}
.subscribe-input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--lilac); }
.subscribe .btn { white-space: nowrap; }
.subscribe .cf-turnstile { margin-top: 12px; }
/* honeypot: off-screen, never shown to real users */
.hp-field {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}

/* ─── subscribe result page ─── */

.subscribe-result {
  max-width: 560px; margin: 40px auto; text-align: center;
}
.subscribe-result h1 { font-size: 1.8rem; margin-bottom: 12px; }
.subscribe-result p { color: var(--muted); font-size: 1.05rem; }
.subscribe-result .back-link { margin-top: 24px; }

/* ─── admin: subscriber stats ─── */

.sub-stats { display: flex; gap: 14px; margin: 6px 0 22px; flex-wrap: wrap; }
.sub-stat {
  flex: 1 1 120px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 12px; background: var(--bg);
}
.sub-stat-num { display: block; font-size: 1.8rem; font-weight: 700; color: var(--purple-deep); }
.sub-stat-label { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.status-confirmed { background: var(--purple); color: #fff; }
.status-pending { background: var(--lilac-bg); color: var(--purple-deep); border: 1px solid var(--lilac); }
.status-unsubscribed { background: var(--line); color: var(--muted); }

/* ─── empty states ─── */

.empty-state {
  text-align: center; padding: 60px 20px;
  border: 2px dashed var(--lilac); border-radius: var(--radius);
  color: var(--muted);
}
.empty-big { font-size: 1.4rem; font-weight: 700; color: var(--ink); margin-bottom: 8px; }

/* ─── buttons & forms ─── */

.btn {
  font-family: var(--body-font); font-weight: 700; font-size: 0.9rem;
  background: var(--bg); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 8px 18px; cursor: pointer; text-decoration: none; display: inline-block;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--purple-soft); color: var(--purple-deep); background: var(--lilac-bg); }
.btn-primary { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-deep); border-color: var(--purple-deep); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fdf0f5; border-color: var(--danger); color: var(--danger); }

input[type="text"], input[type="password"], textarea {
  font-family: var(--body-font); font-size: 1rem;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
  padding: 10px 14px; width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px var(--lilac); }

/* ─── admin chrome ─── */

.admin-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 26px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.wordmark-small {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em;
  text-decoration: none; color: var(--ink);
}
.wordmark-small img { width: 30px; height: 30px; }
.backstage {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--lilac-bg); color: var(--purple-deep);
  padding: 3px 10px; border-radius: 999px;
}
.admin-nav { display: flex; align-items: center; gap: 22px; font-weight: 600; font-size: 0.95rem; }
.admin-nav a { text-decoration: none; color: var(--ink); }
.admin-nav a:hover { color: var(--purple); }
.linkish {
  background: none; border: none; font: inherit; font-weight: 600; cursor: pointer;
  padding: 0; color: var(--ink);
}
.linkish:hover { color: var(--purple); }

.admin-main { max-width: 1200px; margin: 0 auto; padding: 34px 26px 80px; }

.admin-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.admin-toolbar h1 { font-size: 1.7rem; letter-spacing: -0.02em; }

.posts-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.posts-table th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
  text-align: left; color: var(--muted); background: var(--lilac-bg);
  padding: 12px 16px; font-weight: 700;
}
.posts-table td { padding: 14px 16px; border-top: 1px solid var(--line); }
.post-title-link { font-weight: 700; text-decoration: none; color: var(--ink); }
.post-title-link:hover { color: var(--purple); }
.muted { color: var(--muted); font-size: 0.9rem; }
.row-actions a { font-weight: 600; font-size: 0.85rem; text-decoration: none; }
.row-actions a:hover { text-decoration: underline; }

.status {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: 999px; padding: 3px 12px;
}
.status-draft { background: var(--lilac-bg); color: var(--purple-deep); border: 1px solid var(--lilac); }
.status-published { background: var(--purple); color: #fff; }

/* ─── auth cards ─── */

.auth-card {
  max-width: 420px; margin: 8vh auto 0; padding: 36px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.5rem; letter-spacing: -0.02em; margin-bottom: 12px; }
.auth-card p { margin-bottom: 16px; color: var(--muted); }
.auth-card label { display: block; font-weight: 600; margin: 16px 0 6px; }
.auth-card input { margin-top: 6px; }
.auth-card .btn { margin-top: 22px; width: 100%; }
.form-error {
  background: #fdf0f5; color: var(--danger); font-weight: 600;
  padding: 10px 14px; border-radius: 10px; border: 1px solid #f5c2d7;
}

/* ─── editor ─── */

.editor { display: flex; flex-direction: column; gap: 14px; height: calc(100vh - 150px); min-height: 560px; }

.editor-top { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.title-input { flex: 1 1 320px; font-weight: 700; font-size: 1.35rem; letter-spacing: -0.02em; padding: 10px 16px; }
.tags-input { font-size: 0.9rem; }

.editor-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.save-note { font-weight: 600; font-size: 0.85rem; min-width: 70px; color: var(--muted); }
.save-note.error { color: var(--danger); }

.editor-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.focus-toggle { margin-left: auto; }
.focus-note { display: none; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.focus-note.error { color: var(--danger); }

/* ─── focus mode: fill the viewport, hide the site chrome ─── */
.editor.editor--fullscreen {
  position: fixed; inset: 0; z-index: 1000;
  height: 100vh; height: 100dvh; min-height: 0; margin: 0;
  padding: 18px clamp(18px, 5vw, 64px);
  background: var(--bg); overflow-y: auto;
}
body.editor-fullscreen-active { overflow: hidden; }
.editor.editor--fullscreen .focus-toggle {
  background: var(--lilac-bg); border-color: var(--purple-soft); color: var(--purple-deep);
}
/* distraction-free: keep only the editing toolbar + the textarea itself */
.editor.editor--fullscreen .editor-top,
.editor.editor--fullscreen .tags-input,
.editor.editor--fullscreen #preview { display: none; }
.editor.editor--fullscreen .editor-panes { grid-template-columns: 1fr; }
.editor.editor--fullscreen .focus-note { display: inline; margin-left: auto; }
.editor-toolbar button, .upload-btn {
  font-family: var(--body-font); font-weight: 600; font-size: 0.88rem;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 8px;
  color: var(--ink);
  padding: 5px 12px; cursor: pointer;
}
.editor-toolbar button:hover, .upload-btn:hover {
  background: var(--lilac-bg); border-color: var(--purple-soft); color: var(--purple-deep);
}

.editor-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; flex: 1; min-height: 0; }
.content-input {
  resize: none; font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.95rem; line-height: 1.6;
}
.preview {
  overflow-y: auto; background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 20px 24px;
}

@media (max-width: 900px) {
  .editor { height: auto; }
  .editor-panes { grid-template-columns: 1fr; }
  .content-input { min-height: 320px; }
  .preview { max-height: 420px; }
}

/* ─── mobile ─── */

@media (max-width: 640px) {
  body { font-size: 16px; }

  /* public */
  .site-header { padding: 34px 16px 26px; }
  .wordmark { font-size: 1.75rem; gap: 12px; }
  .wordmark img { width: 50px; height: 50px; }
  .wrap { padding: 0 16px 56px; }
  .post-list { gap: 16px; }
  .post-card { padding: 20px 18px; }
  .post-card h2 { font-size: 1.28rem; }
  .post-header { margin-bottom: 26px; }
  .prose { font-size: 1rem; }
  .prose blockquote { padding: 12px 16px; }
  .prose .footnotes { padding: 16px 18px; }

  /* admin chrome */
  .admin-header { padding: 10px 16px; }
  .admin-nav { gap: 14px; font-size: 0.88rem; }
  .admin-main { padding: 20px 16px 60px; }
  .admin-toolbar { margin-bottom: 20px; }
  .admin-toolbar h1 { font-size: 1.35rem; }
  .auth-card { padding: 26px 22px; margin-top: 4vh; }

  /* posts table becomes cards */
  .posts-table { border: none; box-shadow: none; background: none; border-radius: 0; }
  .posts-table thead { display: none; }
  .posts-table, .posts-table tbody, .posts-table tr, .posts-table td { display: block; }
  .posts-table tr {
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 14px 16px; margin-bottom: 12px;
  }
  .posts-table td { padding: 2px 0; border: none; }
  .posts-table td:first-child { font-size: 1.05rem; margin-bottom: 4px; }
  .posts-table .row-actions { margin-top: 6px; }

  /* editor */
  .editor { gap: 10px; }
  .title-input { font-size: 1.1rem; padding: 9px 14px; }
  .editor-top, .editor-actions { gap: 8px; }
  .editor-actions .btn { padding: 7px 12px; font-size: 0.8rem; }
  .save-note { min-width: 0; }
  .editor-toolbar { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .editor-toolbar button, .upload-btn { flex-shrink: 0; }
  .content-input { min-height: 260px; font-size: 16px; } /* 16px stops iOS zoom-on-focus */
  .preview { padding: 16px 18px; }
}
