/* ============================
   DAMINICODESPHERE BLOG — CSS
   write-up style, editorial
   ============================ */

:root {
  --bg: #0C0F15;
  --card: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.09);
  --text: #E7ECF3;
  --muted: #9AA4B2;
  --accent: #7EE7BB;
  --accent-deep: #2fae7a;
  --danger: #ff6b6b;
  --font-head: "Sora", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: clip; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #08120e; }
a { color: inherit; text-decoration: none; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 24px; }

/* ---------- header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: rgba(12, 15, 21, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.head-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 16px; padding-bottom: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 700; font-size: 1rem;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #7EE7BB, #2fae7a);
  color: #08120e; font-family: var(--font-mono); font-weight: 700; font-size: .95rem;
}
.head-nav { display: flex; gap: 20px; align-items: center; }
.head-nav a { color: var(--muted); font-size: .88rem; font-weight: 500; transition: color .2s; }
.head-nav a:hover { color: var(--text); }

/* ---------- intro ---------- */
.blog-intro { padding: 72px 0 44px; }
.blog-intro h1 {
  font-family: var(--font-head); font-weight: 700;
  font-size: clamp(1.5rem, 3.6vw, 2.1rem); line-height: 1.25;
}
.blog-intro p { color: var(--muted); margin-top: 10px; font-size: .95rem; }

/* ---------- post list (write-up style) ---------- */
.post-list { padding-bottom: 90px; }
.post-row {
  display: grid; grid-template-columns: 130px 1fr; gap: 20px;
  padding: 26px 4px;
  border-top: 1px solid var(--line);
  transition: background .2s ease;
}
.post-row:hover { background: rgba(255, 255, 255, 0.025); }
.post-row time {
  font-family: var(--font-mono); font-size: .78rem; color: var(--muted);
  padding-top: 6px;
}
.row-main h2 {
  font-family: var(--font-head); font-weight: 600;
  font-size: 1.22rem; line-height: 1.4;
  transition: color .2s ease;
}
.post-row:hover .row-main h2 { color: var(--accent); }
.row-excerpt { color: var(--muted); font-size: .92rem; margin-top: 8px; }
.row-tags {
  font-family: var(--font-mono); font-size: .72rem; color: var(--accent);
  opacity: .75; margin-top: 10px; letter-spacing: .04em;
}
.empty-state, .loading-inline { color: var(--muted); padding: 34px 0; }

/* ---------- article ---------- */
.back-link {
  display: inline-block; margin: 40px 0 10px;
  color: var(--muted); font-size: .9rem;
}
.back-link:hover { color: var(--accent); }
.article { padding-bottom: 40px; }
.tags-row { margin-top: 32px; gap: 8px; }
.article-title {
  font-family: var(--font-head); font-weight: 800;
  font-size: clamp(1.7rem, 4.4vw, 2.5rem); line-height: 1.18;
  margin: 10px 0 14px;
}
.article-cover { margin: 28px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.article-cover img { width: 100%; display: block; }
.article-body { margin-top: 26px; font-size: 1.02rem; }
.article-body p { margin: 18px 0; color: #d6dde6; }
.article-body h1, .article-body h2, .article-body h3, .article-body h4 {
  font-family: var(--font-head); margin: 34px 0 12px; line-height: 1.3;
}
.article-body h1 { font-size: 1.7rem; }
.article-body h2 { font-size: 1.4rem; }
.article-body h3 { font-size: 1.15rem; }
.article-body h4 { font-size: 1rem; }
.article-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.article-body ul, .article-body ol { margin: 18px 0 18px 24px; display: grid; gap: 8px; color: #d6dde6; }
.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 8px 0 8px 20px; margin: 24px 0;
  color: var(--muted); font-style: italic;
}
.article-body figure { margin: 24px 0; }
.article-body img { max-width: 100%; border-radius: 12px; }
.article-body hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }
.inline-code {
  font-family: var(--font-mono); font-size: .86em;
  background: rgba(126, 231, 187, 0.1); color: var(--accent);
  padding: 2px 7px; border-radius: 6px;
}
.code-block {
  position: relative; margin: 22px 0;
  background: #090c12; border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; overflow-x: auto;
}
.code-lang {
  font-family: var(--font-mono); font-size: .68rem; color: var(--muted);
  letter-spacing: .12em; text-transform: uppercase; margin-bottom: 10px;
}
.code-block code {
  font-family: var(--font-mono); font-size: .85rem; line-height: 1.6;
  color: #c9f5e3; white-space: pre;
}
.article-cta {
  margin-top: 44px; padding: 24px;
  border: 1px solid rgba(126, 231, 187, 0.3); border-radius: 14px;
  background: rgba(126, 231, 187, 0.05);
  display: flex; flex-direction: column; gap: 14px; align-items: flex-start;
}
.article-cta p { font-family: var(--font-head); font-weight: 600; }
.post-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--muted); font-size: .8rem; font-family: var(--font-mono);
}
.post-meta .dot { opacity: .5; }
.tag {
  font-family: var(--font-mono); font-size: .68rem;
  color: var(--accent); background: rgba(126, 231, 187, 0.09);
  border: 1px solid rgba(126, 231, 187, 0.25);
  padding: 3px 9px; border-radius: 99px;
}

/* ---------- buttons ---------- */
.btn-solid, .btn-ghost, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: .95rem;
  padding: 13px 24px; border-radius: 11px; cursor: pointer;
  border: 1px solid transparent; transition: all .2s ease;
}
.btn-sm { padding: 8px 14px; font-size: .84rem; border-radius: 9px; }
.btn-solid {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #08120e; box-shadow: 0 6px 22px rgba(126, 231, 187, 0.25);
}
.btn-solid:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(126, 231, 187, 0.35); }
.btn-solid:disabled { opacity: .6; cursor: wait; transform: none; }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); }
.btn-danger { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.4); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 107, 107, 0.2); }

/* ---------- footer ---------- */
.site-foot {
  margin-top: 30px; border-top: 1px solid var(--line);
  padding: 34px 0;
}
.foot-copy { color: var(--muted); font-size: .78rem; text-align: center; }
.foot-copy a { color: var(--accent); }
.foot-brand { font-family: var(--font-head); font-weight: 700; }
.foot-note { color: var(--muted); font-size: .88rem; margin-top: 6px; }

/* ============ ADMIN (private, /admin) ============ */
.admin-body .wrap { max-width: 980px; }
.gate { display: flex; justify-content: center; padding: 90px 0; }
.gate-card, .token-card {
  width: min(460px, 100%);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 36px;
}
.gate-card h1 { font-family: var(--font-head); font-size: 1.5rem; margin-bottom: 8px; }
.gate-card p, .token-card p { color: var(--muted); font-size: .92rem; margin-bottom: 18px; }
.gate-hint { font-size: .78rem !important; color: var(--muted); margin-top: 16px !important; }
.gate-hint code { font-family: var(--font-mono); color: var(--accent); }

.gate-card input, .token-card input, .editor-fields input, .editor-fields textarea {
  width: 100%; padding: 12px 14px; margin-bottom: 14px;
  background: #090c12; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); font-family: var(--font-body); font-size: .95rem;
  transition: border-color .2s;
}
.gate-card input:focus, .token-card input:focus, .editor-fields input:focus, .editor-fields textarea:focus {
  outline: none; border-color: rgba(126, 231, 187, 0.5);
}

.token-setup { display: flex; justify-content: center; padding: 60px 0; }
.token-note {
  font-size: .8rem !important;
  border-left: 3px solid var(--accent); padding-left: 14px;
}
.token-actions { display: flex; align-items: center; gap: 14px; }
.token-actions .btn-solid { margin-bottom: 14px; }
.token-status { font-size: .85rem; color: var(--accent); }

.manager-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 40px 0 20px;
}
.manager-head h1 { font-family: var(--font-head); font-size: 1.7rem; }
.post-list-admin { display: grid; gap: 12px; padding-bottom: 60px; }
.post-row-admin {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 13px; padding: 16px 20px;
}
.post-row-admin strong { display: block; font-family: var(--font-head); font-size: .98rem; }
.post-row-admin span { color: var(--muted); font-size: .8rem; font-family: var(--font-mono); }
.row-actions { display: flex; gap: 8px; flex-shrink: 0; }

.editor-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 30px 0 20px; gap: 12px; flex-wrap: wrap;
}
.editor-actions { display: flex; gap: 10px; }

.editor-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 26px; padding-bottom: 60px; }
.editor-fields label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.editor-fields label em { font-style: normal; opacity: .6; font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.md-toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.md-toolbar button {
  background: var(--card); border: 1px solid var(--line);
  color: var(--muted); border-radius: 8px;
  min-width: 34px; height: 32px; padding: 0 8px;
  font-family: var(--font-mono); font-size: .78rem; cursor: pointer;
  transition: all .15s;
}
.md-toolbar button:hover { color: var(--accent); border-color: rgba(126, 231, 187, 0.4); }

.editor-preview { position: sticky; top: 90px; align-self: start; }
.preview-label {
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted);
  letter-spacing: .14em; text-transform: uppercase; margin-bottom: 10px;
}
.preview-pane {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 24px; min-height: 300px; max-height: 70vh;
  overflow-y: auto;
}
.preview-pane.fullscreen { position: fixed; inset: 20px; z-index: 200; max-height: none; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 300;
  transform: translate(-50%, 90px);
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #08120e; font-weight: 700; font-size: .9rem;
  padding: 12px 22px; border-radius: 12px;
  box-shadow: 0 14px 40px rgba(126, 231, 187, 0.35);
  opacity: 0; pointer-events: none;
  transition: transform .35s cubic-bezier(.2,.9,.3,1.3), opacity .3s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.bad { background: linear-gradient(135deg, #ff8a8a, #e05555); color: #2a0808; }

/* ---------- responsive ---------- */
@media (max-width: 620px) {
  .post-row { grid-template-columns: 1fr; gap: 6px; padding: 22px 4px; }
  .post-row time { padding-top: 0; }
  .head-nav a { font-size: .82rem; }
  .head-nav { gap: 14px; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-preview { position: static; }
  .post-row-admin { flex-direction: column; align-items: flex-start; }
  .field-row { grid-template-columns: 1fr; }
}
