/* Public blog pages (index, tag, post) — retro-desktop palette shared with
   assets/css/style.css and blog/admin/admin.css. */

:root {
  /* A characterful serif for post titles and content headings only - the
     desktop-shell chrome (buttons, titlebars, meta text) stays on the site's
     usual Tahoma stack so posts read like articles without the page losing
     its identity as a surya.place window. */
  --blog-serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;
}

.user-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  display: inline-block;
  margin-right: 6px;
  background-color: #ccc;
  border: 1px solid #000;
}
.user-avatar-fallback {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
  background-color: #ccc;
  border: 1px solid #000;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: "Tahoma", "Segoe UI", Verdana, sans-serif;
  background: #e8e6e2;
  color: #3a3a4a;
  margin: 0;
  padding: 24px;
}

a { color: #4a78d6; }
a:hover { color: #35599e; }

/* ---------- buttons (shared button look for every admin action) ---------- */
button, .btn {
  font-family: inherit;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  color: #3a3a4a;
  text-decoration: none;
  cursor: pointer;
  background: linear-gradient(180deg, #fdfdfd, #dedcd8);
  border: 1px solid #8f8f9a;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
}
button:hover, .btn:hover {
  background: linear-gradient(180deg, #ffffff, #e9e7e3);
}
button:active, .btn:active {
  color: #1b2c52;
  background: linear-gradient(180deg, #9fbdec, #cddcf4);
  border-color: #4a78d6;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.22);
}

/* --- DARK MODE OVERRIDES --- */
:root[data-theme="dark"] body { background: #1a1a24; color: #e6e6ee; }
:root[data-theme="dark"] a { color: #6f9ce8; }
:root[data-theme="dark"] a:hover { color: #a9c6ff; }
:root[data-theme="dark"] button, :root[data-theme="dark"] .btn {
  background: linear-gradient(180deg, #323340, #262732);
  border-color: #4a4b5c;
  color: #e6e6ee;
  box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset;
}
:root[data-theme="dark"] button:hover, :root[data-theme="dark"] .btn:hover {
  background: linear-gradient(180deg, #383a4a, #2a2b38);
}
:root[data-theme="dark"] button:active, :root[data-theme="dark"] .btn:active {
  background: linear-gradient(180deg, #262732, #1a1a24);
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.4);
}
:root[data-theme="dark"] .btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #4f6ca8, #3d5382);
  border-color: #2b3a5c;
}
:root[data-theme="dark"] .btn-primary:hover { background: linear-gradient(180deg, #5a7bbf, #476199); }
:root[data-theme="dark"] .btn-primary:active { background: linear-gradient(180deg, #3d5382, #2b3a5c); color: #fff; }
:root[data-theme="dark"] .win-panel { background: #262732; border-color: #4a4b5c; }
:root[data-theme="dark"] .win-panel-title { background: linear-gradient(90deg, #4a4b5c, #383a4a); }
:root[data-theme="dark"] .post-card { background: #262732; border-color: #4a4b5c; color: #e6e6ee; box-shadow: 2px 3px 8px rgba(0,0,0,0.4); }
:root[data-theme="dark"] .post-card:hover { box-shadow: 3px 5px 12px rgba(0,0,0,0.6); }
:root[data-theme="dark"] .post-card-title { color: #e6e6ee; }
:root[data-theme="dark"] .post-card-excerpt { color: #a9a9b8; }
:root[data-theme="dark"] .post-card-cover { border-bottom-color: #4a4b5c; }
:root[data-theme="dark"] .post-card-cover-empty { background: linear-gradient(135deg, #2c2d3a, #24252f 45%, #2b2530); }
:root[data-theme="dark"] .post-card-meta { color: #8a8a9e; border-top-color: #383a4a; }
:root[data-theme="dark"] #post-mount .ProseMirror { color: #e6e6ee; }
:root[data-theme="dark"] #post-mount .ProseMirror h1,
:root[data-theme="dark"] #post-mount .ProseMirror h2,
:root[data-theme="dark"] #post-mount .ProseMirror h3 { color: #e6e6ee; }
:root[data-theme="dark"] #post-mount .ProseMirror blockquote { border-left-color: #4a4b5c; color: #a9a9b8; }
:root[data-theme="dark"] #post-mount .ProseMirror pre { background: #1a1a24; color: #e6e6ee; border-color: #4a4b5c; }
:root[data-theme="dark"] #post-mount .ProseMirror code { background: rgba(255,255,255,0.1); color: #ffb6d9; }
:root[data-theme="dark"] #post-mount .ProseMirror img,
:root[data-theme="dark"] #post-mount .ProseMirror iframe { border-color: #4a4b5c; }
:root[data-theme="dark"] #post-mount .ProseMirror hr { border-top-color: #4a4b5c; }
:root[data-theme="dark"] #post-mount .ProseMirror th,
:root[data-theme="dark"] #post-mount .ProseMirror td { border-color: #4a4b5c; }
:root[data-theme="dark"] #post-mount .ProseMirror th { background: #323340; }
:root[data-theme="dark"] #post-mount .ProseMirror mark { background: #a67c00; color: #1a1a24; }
:root[data-theme="dark"] #post-mount .ProseMirror div[data-type="details"] { background: #262732; border-color: #4a4b5c; }
:root[data-theme="dark"] .post-header-cover { border-color: #4a4b5c; }
:root[data-theme="dark"] .post-header-title { color: #e6e6ee; }
:root[data-theme="dark"] .post-header-meta { border-bottom-color: #4a4b5c; color: #8a8a9e; }
:root[data-theme="dark"] .post-header-tag { background: #2d3348; color: #a9c6ff; }
:root[data-theme="dark"] .post-header-tag:hover { background: #384062; color: #cfe0ff; }
:root[data-theme="dark"] .related-posts-heading { color: #e6e6ee; }
:root[data-theme="dark"] .comment-section { border-top-color: #4a4b5c; }
:root[data-theme="dark"] .comment-item { background: #262732; border-color: #4a4b5c; color: #e6e6ee; }
:root[data-theme="dark"] .comment-item .comment-username { color: #fff; }
:root[data-theme="dark"] .comment-textarea { background: #1a1a24; border-color: #4a4b5c; color: #e6e6ee; }
:root[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.6); }
:root[data-theme="dark"] .btn-danger {
  color: #f2a89c;
  background: linear-gradient(180deg, #6b1d1d, #4a1313);
  border-color: #8b2b2b;
}
:root[data-theme="dark"] .btn-danger:hover { background: linear-gradient(180deg, #8b2b2b, #6b1d1d); }
:root[data-theme="dark"] .btn-danger:active { background: linear-gradient(180deg, #5a1717, #4a1313); color: #f2a89c; }
button:disabled, .btn:disabled {
  cursor: default;
  opacity: 0.55;
  background: linear-gradient(180deg, #fdfdfd, #dedcd8);
  box-shadow: none;
}

/* primary action */
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #6f9ce8, #4a78d6);
  border-color: #35599e;
}
.btn-primary:hover { background: linear-gradient(180deg, #7fa8ec, #5583df); }
.btn-primary:active { background: linear-gradient(180deg, #4a78d6, #35599e); color: #fff; }

.btn-danger {
  color: #7a2019;
  background: linear-gradient(180deg, #fbdcd6, #f2b3a6);
  border-color: #c0594a;
}
.btn-danger:hover { background: linear-gradient(180deg, #ffe2dd, #f6b6ab); }
.btn-danger:active { background: linear-gradient(180deg, #f2a89c, #d98878); color: #5a1717; }

/* ---------- toasts + confirm dialog (replace alert()/confirm()) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,30,40,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.modal-panel { width: 480px; max-width: calc(100vw - 32px); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; }
.blog-confirm-panel { width: 360px; }
.blog-confirm-message { margin: 4px 0 14px; font-size: 13px; line-height: 1.5; white-space: pre-line; }

#blog-toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.blog-toast {
  pointer-events: auto;
  max-width: 320px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #fff;
  background: #3a3a4a;
  border-radius: 4px;
  box-shadow: 2px 4px 12px rgba(0,0,0,0.25);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.blog-toast.is-visible { opacity: 1; transform: translateY(0); }
.blog-toast-error { background: #a3352f; }
.blog-toast-success { background: #1f8a4c; }

/* ---------- window chrome (shared with admin.css) ---------- */
.win-panel {
  background: #f4f2f0;
  border: 1px solid #8f8f9a;
  border-radius: 3px;
  box-shadow: 4px 6px 18px rgba(0,0,0,0.18);
  max-width: 900px;
  margin: 0 auto 20px;
}
.win-panel-title {
  height: 24px;
  display: flex; align-items: center;
  padding: 0 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(90deg, #6f9ce8, #4a78d6);
}
.win-panel-body { padding: 16px; }

/* When this page is loaded inside a desktop-shell window (assets/js/script.js
   opens a real OS-style window with its own titlebar/close/min/max), the
   page's own fake title bar would just duplicate that chrome - hide it and
   let the content fill the real window instead. See assets/js/blog-embed.js. */
html.blog-embedded .win-panel-title { display: none; }
html.blog-embedded .win-panel {
  border: none;
  box-shadow: none;
  border-radius: 0;
  max-width: 100%;
  margin: 0;
}
html.blog-embedded body { padding: 0; }

/* ---------- status badges (mirrors blog/admin/admin.css) ---------- */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 10px;
  border: 1px solid transparent;
}
.status-draft      { color: #55556a; background: #e4e2de; border-color: #c7c5c0; }
.status-scheduled  { color: #8a5a12; background: linear-gradient(180deg,#ffe2c2,#f6c48c); border-color: #d9a85c; }
.status-published  { color: #1f5c33; background: linear-gradient(180deg,#cdeed8,#a3dcb5); border-color: #6fb98a; }
.status-private    { color: #7a2a5c; background: linear-gradient(180deg,#ffd3e6,#ff9fc7); border-color: #e274a6; }
.status-template   { color: #2d4b91; background: linear-gradient(180deg,#c3d6ff,#8fadf7); border-color: #5a75d1; }

/* ---------- misc small chrome ---------- */
.blog-toolbar { text-align: center; margin: 0 0 1rem; }
.blog-toolbar:last-child { margin: 1rem 0 0; }

/* ---------- post grid (index.php, tag.php) ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}
.post-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1rem;
  color: #8b8b98;
  font-size: 13px;
}
.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid #8f8f9a;
  border-radius: 4px;
  background: #fff;
  text-decoration: none;
  color: #3a3a4a;
  overflow: hidden;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.1);
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 4px 8px 18px rgba(0,0,0,0.16);
}
.post-card-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid #8f8f9a;
}
.post-card-cover-empty {
  background: linear-gradient(135deg, #eef0f6, #dfe3ee 45%, #eae2e8);
}
.post-card-badge-row { margin: 0 0 6px; }
.post-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 14px 16px 16px;
}
.post-card-title {
  margin: 0 0 6px;
  font-family: var(--blog-serif);
  font-size: 18px;
  line-height: 1.3;
  color: #232330;
}
.post-card-excerpt {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: #55556a;
  line-height: 1.5;
  flex: 1;
}
.post-card-meta {
  display: block;
  font-size: 11px;
  letter-spacing: 0.01em;
  color: #8b8b98;
  padding-top: 8px;
  border-top: 1px solid #ece9e5;
}

/* ---------- post layout (post.php) ---------- */
.post-layout {
  display: flex;
  gap: 24px;
}
.post-toc {
  width: 200px;
  flex-shrink: 0;
  align-self: flex-start;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.post-toc a {
  display: block;
  padding: 4px 0;
  font-size: 12px;
  color: #4a78d6;
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 8px;
}
.post-toc a:hover {
  color: #35599e;
  border-left-color: #6f9ce8;
  background: rgba(111,156,232,0.1);
}
.post-main { flex: 1; min-width: 0; }

/* ---------- post header (post.php: cover, title, byline) ---------- */
.post-header:empty { display: none; }
.post-header-cover {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border: 1px solid #8f8f9a;
  border-radius: 4px;
  margin: 0 0 1em;
}
.post-header-badge-row { margin: 0 0 0.6em; }
.post-header-title {
  margin: 0 0 0.4em;
  font-family: var(--blog-serif);
  font-size: 30px;
  line-height: 1.2;
  color: #232330;
}
.post-header-meta {
  margin: 0 0 1.6em;
  padding-bottom: 1.2em;
  border-bottom: 1px solid #d9d7d3;
  font-size: 12px;
  color: #8b8b98;
}
.post-header-tags { margin-left: 6px; }
.post-header-tag {
  display: inline-block;
  margin: 0 0 0 6px;
  padding: 2px 8px;
  font-size: 11px;
  color: #4a78d6;
  text-decoration: none;
  background: #eef1fa;
  border-radius: 10px;
}
.post-header-tag:hover { background: #e0e7f9; color: #35599e; }

/* ---------- rendered post body (TipTap output via renderer/src/main.js) ----------
   The Editor mounts a `.ProseMirror` element inside #post-mount and fills it
   with the document's HTML (h1-h6, p, ul/ol/li, blockquote, pre>code, img,
   iframe for youtube embeds, etc). */
#post-mount .ProseMirror {
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  outline: none;
}
#post-mount .ProseMirror h1,
#post-mount .ProseMirror h2,
#post-mount .ProseMirror h3 {
  font-family: var(--blog-serif);
  color: #2f2f3a;
  line-height: 1.3;
  margin: 1.4em 0 0.5em;
}
#post-mount .ProseMirror h1:first-child,
#post-mount .ProseMirror h2:first-child,
#post-mount .ProseMirror h3:first-child {
  margin-top: 0;
}
#post-mount .ProseMirror h1 { font-size: 22px; }
#post-mount .ProseMirror h2 { font-size: 18px; }
#post-mount .ProseMirror h3 { font-size: 15px; }
#post-mount .ProseMirror p { margin: 0 0 1em; }
#post-mount .ProseMirror ul,
#post-mount .ProseMirror ol {
  margin: 0 0 1em;
  padding-left: 24px;
}
#post-mount .ProseMirror li { margin: 0 0 4px; }
#post-mount .ProseMirror blockquote {
  margin: 0 0 1em;
  padding-left: 12px;
  border-left: 3px solid #8f8f9a;
  color: #55556a;
  font-style: italic;
}
#post-mount .ProseMirror pre {
  margin: 0 0 1em;
  padding: 10px 12px;
  overflow-x: auto;
  background: #2d2d3a;
  color: #f2f2f5;
  border-radius: 3px;
  font-family: "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.5;
}
#post-mount .ProseMirror code {
  font-family: "Courier New", monospace;
  background: #eceaf2;
  color: #3a3a4a;
  padding: 1px 4px;
  border-radius: 2px;
  font-size: 12.5px;
}
#post-mount .ProseMirror pre code {
  background: none;
  color: inherit;
  padding: 0;
}
#post-mount .ProseMirror img {
  max-width: 100%;
  /* Paired with the `width` attribute an author sets by dragging a corner
     handle in the editor: width is honoured until the column gets narrower,
     and height:auto keeps the aspect ratio in both cases. */
  height: auto;
  border: 1px solid #8f8f9a;
  border-radius: 3px;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.12);
  display: block;
  margin: 0.5em 0;
}
#post-mount .ProseMirror iframe {
  max-width: 100%;
  border: 1px solid #8f8f9a;
  border-radius: 3px;
  display: block;
  margin: 0.5em 0;
}
#post-mount .ProseMirror hr {
  border: none;
  border-top: 1px solid #d9d7d3;
  margin: 1.5em 0;
}
/* See matching comment in blog/admin/admin.css: margin:auto centers a table
   once it has an explicit (narrower-than-100%) width from column resizing. */
#post-mount .ProseMirror table {
  border-collapse: collapse;
  margin: 0 auto 1em;
  width: 100%;
  table-layout: fixed;
  font-size: 13px;
}
#post-mount .ProseMirror th,
#post-mount .ProseMirror td {
  border: 1px solid #8f8f9a;
  padding: 6px 10px;
  vertical-align: top;
  text-align: left;
}
#post-mount .ProseMirror th {
  background: #ebe9e5;
  font-weight: 700;
}
#post-mount .ProseMirror ul[data-type="taskList"] {
  list-style: none;
  padding-left: 4px;
  margin: 0 0 1em;
}
#post-mount .ProseMirror ul[data-type="taskList"] li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 4px;
}
#post-mount .ProseMirror ul[data-type="taskList"] li > label { margin-top: 3px; }
#post-mount .ProseMirror ul[data-type="taskList"] li > div { flex: 1; }
#post-mount .ProseMirror mark {
  background: #ffe27a;
  border-radius: 2px;
  padding: 0 1px;
}
/* The Details extension renders a [data-type="details"] node view in the
   live DOM (toggle <button> + <summary> + hidden content <div>), not a
   literal <details> element. */
#post-mount .ProseMirror div[data-type="details"] {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 1em;
  padding: 8px 10px;
  border: 1px solid #8f8f9a;
  border-radius: 3px;
  background: #fbfbfa;
}
#post-mount .ProseMirror div[data-type="details"] > button {
  flex: none;
  width: 16px;
  height: 16px;
  min-width: 0;
  padding: 0;
  margin-top: 3px;
  background: none;
  border: none;
  box-shadow: none;
  cursor: pointer;
}
#post-mount .ProseMirror div[data-type="details"] > button::before {
  content: '\25B6';
  font-size: 10px;
  display: inline-block;
  transition: transform 0.1s;
}
#post-mount .ProseMirror div[data-type="details"] > button[aria-label="Collapse details content"]::before {
  transform: rotate(90deg);
}
#post-mount .ProseMirror div[data-type="details"] summary {
  cursor: pointer;
  font-weight: 700;
}
#post-mount .ProseMirror div[data-type="details"] div[data-type="detailsContent"] {
  margin-top: 4px;
}

/* ---------- related posts ---------- */
.related-posts-heading {
  margin: 2em 0 0.5em;
  padding-top: 1.5em;
  border-top: 1px solid #d9d7d3;
  font-family: var(--blog-serif);
  font-size: 16px;
  color: #2f2f3a;
}
:root[data-theme="dark"] .related-posts-heading { border-top-color: #4a4b5c; }
.related-posts-list { display: flex; flex-direction: column; gap: 2px; }
.related-post-link {
  display: block;
  padding: 3px 0;
  font-size: 13px;
}

/* ---------- comments ---------- */
.comment-section {
  margin-top: 1.5em;
  padding-top: 1em;
  border-top: 1px solid #d9d7d3;
}
.comment-list { margin-bottom: 12px; }
.comment-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: #fff;
  border: 1px solid #d9d7d3;
  border-radius: 3px;
  font-size: 12.5px;
  color: #3a3a4a;
}
.comment-item .comment-username {
  font-weight: 700;
  color: #2f2f3a;
}
.comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comment-textarea {
  font-family: inherit;
  font-size: 12.5px;
  min-height: 70px;
  resize: vertical;
  border: 1px solid #8f8f9a;
  border-radius: 2px;
  padding: 6px 8px;
}
.comment-submit {
  align-self: flex-start;
  font-family: inherit;
  font-size: 12px;
  padding: 4px 14px;
  color: #3a3a4a;
  cursor: pointer;
  background: linear-gradient(180deg, #fdfdfd, #dedcd8);
  border: 1px solid #8f8f9a;
  border-radius: 2px;
}
.comment-submit:hover {
  background: linear-gradient(180deg, #ffffff, #e9e7e3);
}
.comment-submit:active {
  background: linear-gradient(180deg, #9fbdec, #cddcf4);
  border-color: #4a78d6;
}

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  body { padding: 10px; }
  .win-panel { max-width: 100%; }
  .post-layout { flex-direction: column; }
  .post-toc { width: auto; position: static; max-height: none; }
  .post-card { width: 100%; }
}
