/* RapidCloud Blog — public SSR styles.
   Brand: indigo #7c6cff → cyan #6ad0ff → teal #4ad6c8, near-black #0b0c10 (dark,
   default) / near-white (light), 16px radius, Inter stack. Dark is default;
   both themes are sanctioned. Mobile-first; body never scrolls horizontally. */

:root {
  --brand: #7c6cff;
  --brand-hi: #8b7cff;
  --brand2: #4ad6c8;
  --accent: #4ad6c8;
  --cyan: #6ad0ff;
  --grad: linear-gradient(110deg, #8b7cff 0%, #6ad0ff 55%, #4ad6c8 100%);
  --radius: 16px;
  --radius-sm: 11px;
  --maxw: 1120px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;

  /* dark (default) */
  --bg: #0b0c10;
  --bg2: #111219;
  --card: #15171f;
  --card2: #1a1d27;
  --line: #262a36;
  --text: #e9ecf2;
  --muted: #9aa3b2;
  --hero-glow: radial-gradient(1100px 600px at 70% -10%, #1a1740 0%, rgba(26,23,64,0) 60%);
  --card-soft: linear-gradient(180deg, rgba(124,108,255,0.08), rgba(124,108,255,0.02));
  --shadow: 0 30px 60px -30px rgba(0,0,0,0.6);
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --bg2: #f5f7fb;
  --card: #ffffff;
  --card2: #f5f7fb;
  --line: #e4e8f0;
  --text: #1a1d27;
  --muted: #5b6472;
  --hero-glow: radial-gradient(1100px 600px at 70% -10%, rgba(124,108,255,0.14) 0%, rgba(124,108,255,0) 60%);
  --card-soft: linear-gradient(180deg, rgba(124,108,255,0.07), rgba(124,108,255,0.01));
  --shadow: 0 30px 60px -34px rgba(40,40,90,0.28);
  --accent: #0e7b6e;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--hero-glow), var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font: 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .2s ease, color .2s ease;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { letter-spacing: -0.02em; }

:where(a, button, summary, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px;
}
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; }
.skip-link:focus { left: 12px; top: 10px; background: var(--card); color: var(--text); padding: 9px 15px; border: 1px solid var(--brand); border-radius: 10px; font-size: 14px; font-weight: 600; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; width: 100%; }
.narrow { max-width: 760px; }
.narrow-wide { max-width: 940px; margin-left: auto; margin-right: auto; }
.muted { color: var(--muted); }
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dot { color: var(--muted); opacity: .6; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14.5px; border: 1px solid transparent; cursor: pointer; font-family: inherit; transition: transform .08s ease, background .15s ease, border .15s ease, box-shadow .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 10px 32px -14px var(--brand); }
.btn-primary:hover { background: var(--brand-hi); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }

/* Nav */
.nav { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 14px; height: 64px; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -0.03em; white-space: nowrap; }
.brand span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand small { font-weight: 600; font-size: 13px; color: var(--muted); letter-spacing: 0; }
.brand.small { font-size: 18px; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.search { display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 3px 3px 12px; transition: border .15s ease; }
.search:focus-within { border-color: var(--brand); }
.search input { border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; padding: 6px 4px; width: 190px; max-width: 40vw; outline: none; }
.search input::placeholder { color: var(--muted); }
.search button { border: 0; background: transparent; color: var(--muted); width: 32px; height: 32px; border-radius: 999px; cursor: pointer; display: grid; place-items: center; }
.search button:hover { color: var(--text); }
.theme-toggle { background: transparent; border: 1px solid var(--line); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; transition: border .15s ease; }
.theme-toggle:hover { border-color: var(--brand); }
.theme-ic-light { display: none; }
:root[data-theme="light"] .theme-ic-dark { display: none; }
:root[data-theme="light"] .theme-ic-light { display: inline; }

/* Feed hero */
.feed-hero { padding: 62px 0 30px; position: relative; }
.feed-hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.05; margin: 0 0 14px; }
.feed-hero .eyebrow, .eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 12.5px; font-weight: 600; color: var(--accent); margin: 0 0 10px; }
.lede { font-size: clamp(15px, 2vw, 19px); color: var(--muted); max-width: 60ch; margin: 0; }

/* Feed / card grid */
.feed-wrap { padding-bottom: 72px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }

.post-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease; }
.post-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: var(--shadow); }
.post-cover-link { display: block; }
.post-cover { height: 176px; background-size: cover; background-position: center; border-bottom: 1px solid var(--line); }
.post-cover.ph { display: grid; place-items: center; background: var(--grad); position: relative; }
.post-cover.ph::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 120% at 20% 10%, rgba(255,255,255,.22), transparent 55%); }
.post-cover.ph span { font-size: 54px; font-weight: 800; color: rgba(11,12,16,.82); position: relative; z-index: 1; }
.post-body { padding: 18px 20px 22px; display: flex; flex-direction: column; flex: 1; }
.tagrow { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.tagchip { text-transform: lowercase; letter-spacing: 0.02em; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; color: #0b0c10; background: var(--brand2); }
.tagchip:hover { filter: brightness(1.06); }
.post-title { margin: 0 0 9px; font-size: 19px; line-height: 1.25; }
.post-title a:hover { color: var(--accent); }
.post-excerpt { color: var(--muted); font-size: 14.5px; margin: 0 0 14px; flex: 1; }
.post-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 13px; color: var(--muted); }
.post-meta .byline { color: var(--text); font-weight: 600; }
.post-meta .blog-link:hover { color: var(--accent); }
.post-meta.sub { margin-top: 5px; font-size: 12.5px; }

/* Empty state */
.empty { text-align: center; color: var(--muted); padding: 70px 20px; }
.empty-glyph { font-size: 44px; margin-bottom: 12px; }
.empty h2 { margin: 0 0 8px; color: var(--text); }
.empty .btn { margin-top: 18px; }

/* Blog header */
.blog-header { padding: 54px 0 26px; border-bottom: 1px solid var(--line); }
.blog-header-inner { display: flex; gap: 22px; align-items: flex-start; }
.blog-avatar { width: 84px; height: 84px; border-radius: 20px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }
.blog-avatar.mono { display: grid; place-items: center; background: var(--grad); color: #0b0c10; font-size: 38px; font-weight: 800; }
.blog-header-body { min-width: 0; }
.blog-chips { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.handle { font-size: 13px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.blog-header-body h1 { font-size: clamp(28px, 5vw, 42px); margin: 0 0 10px; }
.blog-actions { margin-top: 16px; }
.btn-rss { font-size: 13.5px; padding: 8px 15px; }

/* Article */
.article { padding: 40px 0 20px; }
.backlink { color: var(--muted); font-size: 14px; display: inline-block; margin-bottom: 22px; }
.backlink:hover { color: var(--text); }
.head-tags { margin-bottom: 16px; }
.article-title { font-size: clamp(30px, 5.4vw, 48px); line-height: 1.08; margin: 0 0 14px; max-width: 20ch; }
.article-sub { font-size: clamp(17px, 2.4vw, 22px); color: var(--muted); margin: 0 0 26px; max-width: 46ch; }
.article-byline { display: flex; align-items: center; gap: 13px; padding: 16px 0 4px; border-top: 1px solid var(--line); }
.ab-avatar { width: 42px; height: 42px; border-radius: 999px; background: var(--grad); color: #0b0c10; display: grid; place-items: center; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.ab-line1 { font-size: 14.5px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.ab-author { font-weight: 700; }
.ab-blog:hover { color: var(--accent); }
.ab-line2 { font-size: 13px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 2px; }
.article-cover { width: 100%; height: auto; max-height: 520px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); margin: 30px auto; }

/* Prose (rendered markdown body) */
.article-body { margin: 34px 0 40px; }
.prose { font-size: 17px; line-height: 1.78; overflow-wrap: break-word; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.7em 0 0.5em; line-height: 1.25; }
.prose h2 { font-size: 27px; }
.prose h3 { font-size: 21px; }
.prose h4 { font-size: 18px; }
.prose p { margin: 0 0 1.05em; }
.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.35em; }
.prose li { margin: 0.35em 0; }
.prose strong { font-weight: 700; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--line); margin: 1.2em auto; }
.prose figure { margin: 1.4em 0; }
.prose figcaption { font-size: 13.5px; color: var(--muted); text-align: center; margin-top: 8px; }
.prose code { background: var(--card2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 0.9em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.prose pre { background: var(--card2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 18px; overflow-x: auto; margin: 1.3em 0; }
.prose pre code { background: transparent; border: 0; padding: 0; font-size: 13.5px; line-height: 1.6; }
.prose blockquote { border-left: 3px solid var(--brand); margin: 1.3em 0; padding: 4px 0 4px 18px; color: var(--muted); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 9px 13px; text-align: left; }
.prose thead th { background: var(--card2); font-weight: 700; }

/* Reactions */
.reactions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 22px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 8px 0 40px; }
.clap { display: inline-flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 9px 18px 9px 14px; cursor: pointer; font: inherit; color: var(--text); transition: transform .1s ease, border .15s ease, background .15s ease; }
.clap:hover { border-color: var(--brand); }
.clap:active { transform: scale(.95); }
.clap.bumped { animation: clapPop .35s ease; }
@keyframes clapPop { 0% { transform: scale(1);} 40% { transform: scale(1.16);} 100% { transform: scale(1);} }
.clap-ic { font-size: 20px; }
.clap-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.clap-hint { font-size: 13.5px; }

/* Comments */
.comments { padding-bottom: 80px; }
.comments-head { font-size: 22px; margin: 0 0 22px; }
.comment-list { list-style: none; padding: 0; margin: 0 0 36px; display: grid; gap: 16px; }
.comment { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 18px; }
.comment-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.comment-author { font-weight: 700; font-size: 14.5px; }
.comment-date { font-size: 12.5px; }
.comment-body { color: var(--text); font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: break-word; }
.no-comments { margin: 0 0 30px; }
.comments-closed { margin: 0; }

.comment-form { background: var(--card-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.comment-form h3 { margin: 0 0 6px; font-size: 18px; }
.form-note { font-size: 13px; margin: 0 0 16px; }
.comment-form label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.comment-form label.block { display: block; }
.comment-form .opt { font-weight: 400; opacity: .8; }
.form-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.comment-form input, .comment-form textarea { display: block; width: 100%; margin-top: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); font: inherit; font-size: 15px; padding: 10px 12px; }
.comment-form input:focus, .comment-form textarea:focus { outline: none; border-color: var(--brand); }
.comment-form textarea { resize: vertical; min-height: 96px; }
/* honeypot — visually hidden, off-screen; bots fill it, humans never see it */
.hp { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.form-status { font-size: 13.5px; color: var(--muted); }
.form-status.ok { color: var(--accent); }
.form-status.err { color: #ff6b7a; }

/* Footer */
.footer { border-top: 1px solid var(--line); background: var(--bg2); margin-top: 20px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding-top: 30px; padding-bottom: 30px; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); font-size: 14px; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { font-size: 13px; }

/* Reader chat bubble */
.chat-widget { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.chat-fab { width: 56px; height: 56px; border-radius: 999px; border: 0; background: var(--brand); color: #fff; cursor: pointer; box-shadow: 0 12px 30px -8px var(--brand); display: grid; place-items: center; transition: transform .12s ease, background .15s ease; }
.chat-fab:hover { background: var(--brand-hi); transform: translateY(-2px); }
.chat-fab-ic { font-size: 24px; line-height: 1; }
.chat-widget.open .chat-fab { transform: scale(.9); opacity: .9; }
.chat-panel { width: min(360px, calc(100vw - 32px)); height: min(500px, calc(100vh - 120px)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-title { display: flex; flex-direction: column; line-height: 1.3; }
.chat-title strong { font-size: 15px; }
.chat-title .muted { font-size: 12px; }
.chat-close { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; width: 28px; height: 28px; border-radius: 8px; }
.chat-close:hover { color: var(--text); background: var(--card2); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg .bubble { max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; overflow-wrap: break-word; white-space: pre-wrap; }
.chat-msg.bot .bubble { background: var(--card2); border: 1px solid var(--line); border-top-left-radius: 4px; }
.chat-msg.user .bubble { background: var(--brand); color: #fff; border-top-right-radius: 4px; }
.chat-msg.typing .bubble { display: inline-flex; gap: 4px; align-items: center; }
.chat-msg.typing .dot-t { width: 6px; height: 6px; border-radius: 999px; background: var(--muted); animation: typing 1.2s infinite ease-in-out; }
.chat-msg.typing .dot-t:nth-child(2) { animation-delay: .15s; }
.chat-msg.typing .dot-t:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0);} 30% { opacity: 1; transform: translateY(-3px);} }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; color: var(--text); font: inherit; font-size: 14px; padding: 9px 14px; outline: none; }
.chat-input input:focus { border-color: var(--brand); }
.chat-input .btn { padding: 9px 14px; border-radius: 999px; }

/* Responsive */
@media (max-width: 720px) {
  .wrap { padding: 0 18px; }
  .nav-inner { height: 58px; }
  .brand small { display: none; }
  .search input { width: 120px; }
  .blog-header-inner { flex-direction: column; gap: 16px; }
  .blog-avatar { width: 68px; height: 68px; }
  .form-row.two { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
}
@media (max-width: 480px) {
  .search { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .chat-widget { right: 14px; bottom: 14px; }
}

/* ---------------- viewport preview (Fill / Desktop / Laptop / Galaxy S24) ---------------- */
/* Ported from rc-nexus/rc-provisioning. Scales #shell to a fixed pixel box so a
   desktop browser can see the real phone/laptop layout. */
.nav-right { position: relative; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); width: 38px; height: 38px;
  border-radius: 10px; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; transition: border .15s ease; }
.icon-btn:hover { border-color: var(--brand); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.size-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 220px; z-index: 60; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 44px rgba(0,0,0,.35); padding: 6px; display: none; }
.size-menu.open { display: block; }
.size-menu .sm-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: none; background: none;
  border-radius: 8px; font: inherit; font-size: 13px; color: var(--text); text-align: left; cursor: pointer; }
.size-menu .sm-item:hover { background: var(--card2); }
.size-menu .sm-item svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.size-menu .sm-item .check { margin-left: auto; color: var(--brand); visibility: hidden; }
.size-menu .sm-item.on .check { visibility: visible; }
body.sim { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #0c0d11; overflow: auto; padding: 20px; }
body.sim #shell { flex: none; overflow: auto; background: var(--bg); border: 1px solid #23262e; border-radius: 12px;
  box-shadow: 0 30px 90px rgba(0,0,0,.55); transform-origin: center center; }
body.sim.sim-s24 #shell { border: 10px solid #08090b; border-radius: 30px; box-shadow: 0 30px 90px rgba(0,0,0,.65), inset 0 0 0 2px #1c1e24; }
body.sim::after { content: attr(data-sim-label); position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 70; font-size: 11px; letter-spacing: .08em; color: #8b93a3; background: #12141a; border: 1px solid #22252e;
  border-radius: 999px; padding: 5px 14px; }
/* keep the preview button reachable on a REAL phone (else there'd be no way out) */
body.phone:not(.sim) #size-toggle { display: none; }

/* Phone layout. Media queries measure the real window, so they never fire inside a
   simulated S24 — the @media rules above are mirrored here on body.phone, which the
   simulator sets whenever the effective width is <=700px (real or simulated). */
body.phone .wrap { padding: 0 18px; }
body.phone .nav-inner { height: 58px; }
body.phone .brand small { display: none; }
body.phone .blog-header-inner { flex-direction: column; gap: 16px; }
body.phone .blog-avatar { width: 68px; height: 68px; }
body.phone .form-row.two { grid-template-columns: 1fr; }
body.phone .footer-inner { flex-direction: column; align-items: flex-start; gap: 14px; }
/* <=480 equivalents — the S24 preview is 360px wide, so these apply too */
body.phone .search { display: none; }
body.phone .card-grid { grid-template-columns: 1fr; }
body.phone .chat-widget { right: 14px; bottom: 14px; }
/* .nav's backdrop-filter would make it the containing block for the fixed chat
   widget; drop it on phone so the widget anchors to the shell instead. */
body.phone .nav { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
