/* ============================================================
   chatbot.birennayak.in — build-log page
   Design tokens, type, spacing and card styles mirror birennayak.in
   ============================================================ */
:root {
  --ink: #241f1c;
  --ink-soft: #6b6259;
  --paper: #fbf6ef;
  --paper-alt: #f3ead9;
  --clay: #c1663e;
  --clay-deep: #a34e2c;
  --clay-soft: #e6b797;
  --sage: #74846f;
  --line: #e7dcc9;
  --max-w: 1040px;
  --max-w-text: 760px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: var(--clay-deep); text-decoration: none; }
a:hover { color: var(--clay); }
img { display: block; max-width: 100%; }

::selection { background: var(--clay-soft); color: var(--ink); }

/* decorative blobs */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

/* ---------- NAV ---------- */
nav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(251, 246, 239, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Fraunces', serif;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  flex: none;
}
.brand .brand-mark { color: var(--clay); font-weight: 400; }
nav .links { display: flex; gap: 22px; flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; }
nav .links a {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 500;
  white-space: nowrap;
}
nav .links a:hover { color: var(--clay-deep); }

/* ---------- HERO ---------- */
.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 76px 24px 40px;
  position: relative;
  overflow: visible;
}
.hero .blob-a { width: 340px; height: 340px; background: var(--clay-soft); top: -60px; left: -120px; opacity: 0.32; }
.hero .blob-b { width: 260px; height: 260px; background: var(--sage); opacity: 0.16; bottom: -40px; right: 6%; }
.hero-text { position: relative; z-index: 1; max-width: 760px; }

.eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clay-deep);
  font-weight: 600;
  margin-bottom: 18px;
  display: inline-block;
}
.hero h1 {
  font-size: clamp(2.3rem, 5.4vw, 3.5rem);
  line-height: 1.1;
}
.hero .tagline {
  margin-top: 20px;
  font-size: 1.14rem;
  color: var(--ink-soft);
  max-width: 640px;
  font-weight: 300;
}
.hero .tagline a { font-weight: 500; border-bottom: 1px solid var(--clay-soft); }

.hero-meta { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: 0 2px 8px rgba(90, 60, 30, 0.05);
}

.hero-cta { margin-top: 30px; display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--clay);
  color: var(--paper);
  border: 1px solid var(--clay);
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn:hover { color: var(--paper); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(193, 102, 62, 0.28); }
.btn-ghost { background: transparent; color: var(--clay-deep); }
.btn-ghost:hover { background: #fff; color: var(--clay-deep); }

/* ---------- SECTIONS ---------- */
main { position: relative; z-index: 1; }
section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 72px 24px;
  position: relative;
}
section + section { border-top: 1px solid var(--line); }

.section-label {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clay-deep);
  font-weight: 600;
  margin-bottom: 14px;
  display: block;
}
section h2 { font-size: clamp(1.7rem, 3vw, 2.15rem); margin-bottom: 18px; }
.lede {
  color: var(--ink-soft);
  font-size: 1.06rem;
  max-width: var(--max-w-text);
  margin: 0 0 32px;
}
.lede code, p code, li code, td code { font-family: var(--mono); font-size: 0.86em; background: var(--paper-alt); padding: 1px 5px; border-radius: 5px; }

/* ---------- FADE-IN ----------
   Only hidden when JS is present (html.js); otherwise always visible so the
   page is fully readable for no-JS, crawlers, print, and if the observer
   never fires. app.js also force-reveals everything after a short timeout. */
.js .fade-in { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .fade-in.visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .fade-in { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- GENERIC PANELS / CODE ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 22px;
  box-shadow: 0 10px 30px -16px rgba(70, 45, 20, 0.18);
}
.panel h3 { font-size: 1.08rem; margin-bottom: 10px; }
.panel { min-width: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 8px; }

pre.code, .prompt-preamble pre {
  margin: 0;
  background: #2a2320;
  color: #f3ead9;
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
}
pre.code code { font-family: inherit; }

/* ---------- DIAGRAM ---------- */
.diagram {
  margin: 8px 0 36px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 10px 30px -16px rgba(70, 45, 20, 0.18);
}
.diagram svg { width: 100%; height: auto; display: block; }
.diagram .d-box { fill: var(--paper); stroke: var(--line); stroke-width: 1.5; }
.diagram .d-box--accent { fill: #fff; stroke: var(--clay-soft); stroke-width: 2; }
.diagram .d-h { font-family: 'Fraunces', serif; font-weight: 600; font-size: 15px; fill: var(--ink); text-anchor: middle; }
.diagram .d-s { font-family: 'Inter', sans-serif; font-size: 11px; fill: var(--ink-soft); text-anchor: middle; }
.diagram .d-lbl { font-family: var(--mono); font-size: 10.5px; fill: var(--clay-deep); text-anchor: middle; }
.diagram .d-arrow { stroke: var(--ink-soft); stroke-width: 1.5; }
.diagram figcaption, figure figcaption {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- STACK TABLE ---------- */
.stack-table { margin-top: 30px; }
.stack-table h3 { font-size: 1.1rem; margin-bottom: 14px; }
.stack-table, .scorecard { max-width: 100%; overflow-x: auto; }
.stack-table table, .scorecard table {
  width: 100%;
  min-width: 340px;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.stack-table th {
  text-align: left;
  vertical-align: top;
  width: 150px;
  padding: 12px 16px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--paper-alt);
  border-bottom: 1px solid var(--line);
}
.stack-table td {
  padding: 12px 16px;
  font-size: 0.92rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.stack-table tr:last-child th, .stack-table tr:last-child td { border-bottom: none; }

/* ---------- PROMPT DOC ---------- */
.prompt-doc {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 10px 30px -16px rgba(70, 45, 20, 0.18);
}
.prompt-preamble pre { font-size: 0.8rem; }
.rules { list-style: none; counter-reset: r; margin: 20px 0 0; padding: 0; }
.rule { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: var(--paper); }
.rule.open { border-color: var(--clay-soft); }
.rule-head {
  width: 100%;
  display: grid;
  grid-template-columns: 30px 1fr 20px;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  text-align: left;
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
}
.rule-n {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--paper);
  background: var(--clay);
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
}
.rule-t { font-size: 0.95rem; font-weight: 500; color: var(--ink); }
.rule-x { font-family: var(--mono); color: var(--clay); font-size: 1.1rem; text-align: center; transition: transform 0.2s ease; }
.rule.open .rule-x { transform: rotate(45deg); }
.rule-body { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.rule.open .rule-body { max-height: 600px; }
.rule-body p { margin: 0; padding: 0 16px 16px 58px; font-size: 0.92rem; color: var(--ink-soft); }
.prompt-foot { margin: 18px 4px 0; font-size: 0.92rem; color: var(--ink-soft); }

/* ---------- TOKEN BAR ---------- */
.tokenbar { margin: 8px 0 28px; }
.tokenbar > figcaption { margin: 0 0 12px; font-style: normal; font-weight: 500; color: var(--ink); font-size: 0.95rem; }
.tokenbar .bar {
  display: flex;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: 92px;
}
.tokenbar .seg {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 8px;
  font-size: 0.78rem;
  text-align: center;
  color: var(--ink);
  line-height: 1.4;
}
.tokenbar .seg b { font-family: var(--mono); font-size: 0.9rem; font-weight: 500; }
.seg-sys { background: var(--clay); color: var(--paper); }
.seg-sys b { color: #fff; }
.seg-hist { background: var(--clay-soft); }
.seg-user { background: var(--paper-alt); }
.tokenbar-note { margin: 12px 2px 0; font-size: 0.9rem; color: var(--ink-soft); }

.callout {
  background: var(--paper-alt);
  border: 1px solid var(--line);
  border-left: 3px solid var(--clay);
  border-radius: 12px;
  padding: 16px 20px;
}
.callout p { margin: 0; font-size: 0.95rem; color: var(--ink-soft); }

/* ---------- BEFORE / AFTER ---------- */
.ba-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 8px 0 24px; }
.ba {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  background: #fff;
}
.ba h3 { font-size: 1.05rem; margin-bottom: 12px; }
.ba-before { background: var(--paper-alt); }
.ba-before h3::before { content: "⚠ "; color: var(--clay-deep); }
.ba-after { border-color: var(--clay-soft); }
.ba-after h3::before { content: "✓ "; color: var(--sage); }
.ba ul { margin: 0; padding-left: 18px; }
.ba li { font-size: 0.9rem; color: var(--ink-soft); margin-bottom: 8px; }
.ba li b { color: var(--ink); font-weight: 600; }
.ba-punch { margin: 14px 0 0; font-size: 0.9rem; font-style: italic; color: var(--ink); }

.honest {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  background: #fff;
  margin-bottom: 24px;
}
.honest h3 { font-size: 1.05rem; margin-bottom: 12px; }
.honest ul { margin: 0; padding-left: 18px; }
.honest li { font-size: 0.92rem; color: var(--ink-soft); margin-bottom: 10px; }
.honest li b { color: var(--ink); }

/* ---------- SCORECARD ---------- */
.scorecard h3 { font-size: 1.1rem; margin-bottom: 14px; }
.scorecard th {
  text-align: left; padding: 11px 16px;
  font-family: 'Fraunces', serif; font-size: 0.9rem;
  background: var(--paper-alt); border-bottom: 1px solid var(--line);
}
.scorecard td { padding: 10px 16px; font-size: 0.9rem; color: var(--ink-soft); border-bottom: 1px solid var(--line); }
.scorecard tr:last-child td { border-bottom: none; }
.s { font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.s-yes { background: #e5ede2; color: #4a5c43; }
.s-part { background: #f6e6d6; color: #92551f; }
.s-no { background: #efe2dc; color: #8a4b3a; }

/* ---------- CALC ---------- */
.calc {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 10px 30px -16px rgba(70, 45, 20, 0.18);
  margin-bottom: 24px;
}
.calc label { font-size: 0.95rem; font-weight: 500; color: var(--ink); display: block; margin-bottom: 12px; }
.calc output { font-family: var(--mono); color: var(--clay-deep); font-weight: 500; }
.calc input[type=range] { width: 100%; accent-color: var(--clay); }
.calc-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 20px; }
.calc-cell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.calc-cell--big { background: var(--clay); border-color: var(--clay); }
.calc-cell--big .calc-k, .calc-cell--big .calc-v { color: var(--paper); }
.calc-k { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin-bottom: 6px; }
.calc-v { display: block; font-family: var(--mono); font-size: 1.3rem; font-weight: 500; color: var(--ink); }
.calc-note { margin: 16px 2px 0; font-size: 0.86rem; color: var(--ink-soft); }

/* ---------- TIMELINE ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl { position: relative; margin-bottom: 26px; }
.tl:last-child { margin-bottom: 0; }
.tl-dot { position: absolute; left: -25px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--clay); border: 2px solid var(--paper); }
.tl h3 { font-size: 1.05rem; margin-bottom: 6px; }
.tl p { margin: 0; font-size: 0.93rem; color: var(--ink-soft); }

/* ---------- SCREENSHOT GRID ---------- */
.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 22px; align-items: start; }
.shot-grid figure { margin: 0; }
.shot-grid img {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--paper-alt);
  box-shadow: 0 14px 30px -18px rgba(70, 45, 20, 0.3);
}
.shot-grid figcaption { margin-top: 10px; font-size: 0.86rem; color: var(--ink-soft); font-style: normal; }

/* ---------- STEPS ---------- */
.steps { counter-reset: s; list-style: none; margin: 0; padding: 0; max-width: var(--max-w-text); }
.steps li {
  position: relative;
  counter-increment: s;
  padding: 14px 0 14px 44px;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.steps li:last-child { border-bottom: 1px solid var(--line); }
.steps li b { color: var(--ink); }
.steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: 12px;
  font-family: var(--mono); font-size: 0.8rem; font-weight: 500;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--paper-alt); color: var(--clay-deep);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- FOOTER ---------- */
footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 40px 24px 64px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
footer a { border-bottom: 1px solid var(--clay-soft); }
.foot-fine { margin-top: 8px; font-size: 0.82rem; }

/* ============================================================
   REPLICA WIDGET — verbatim from the production stylesheet,
   re-docked (static, not fixed) inside .demo-shell
   ============================================================ */
.try-wrap { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 32px; align-items: start; }
.demo-shell { display: flex; justify-content: center; }

#chat-widget[data-demo] #chat-panel {
  position: static;
  width: 360px;
  max-width: 100%;
  height: 520px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(36, 31, 28, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#chat-panel .chat-header {
  background: var(--ink);
  color: var(--paper);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#chat-panel .chat-header img {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  border: 1.5px solid var(--clay-soft);
}
#chat-panel .chat-header .title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 0.98rem; }
#chat-panel .chat-header .subtitle { font-size: 0.75rem; color: #cfc6bb; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--paper);
}
.chat-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.5;
  white-space: pre-wrap;
}
.chat-msg.bot { align-self: flex-start; background: var(--paper-alt); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.user { align-self: flex-end; background: var(--clay); color: var(--paper); border-bottom-right-radius: 4px; }
.chat-msg.typing { color: var(--ink-soft); font-style: italic; }

/* rule tag under guardrail replies (page addition, clearly marked) */
.rule-tag {
  align-self: flex-start;
  margin-top: -4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--clay-deep);
  background: #fff;
  border: 1px solid var(--clay-soft);
  border-radius: 999px;
  padding: 2px 9px;
}
.rule-tag--inline { align-self: auto; margin: 0; display: inline-block; }
a.rule-tag:hover { background: var(--clay-soft); color: var(--ink); }

#chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}
#chat-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  background: #fff;
  color: var(--ink);
  resize: none;
}
#chat-input:focus { outline: none; border-color: var(--clay); }
#chat-send {
  border: none;
  background: var(--clay);
  color: var(--paper);
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
#chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
#chat-send svg { width: 17px; height: 17px; }

/* try-it side panel */
.try-side-label, .try-side .try-note { color: var(--ink-soft); }
.try-side-label { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin: 0 0 12px; }
.prompt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-chips button {
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.prompt-chips button:hover { border-color: var(--clay); transform: translateY(-1px); }
.try-note { margin-top: 16px; font-size: 0.85rem; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 880px) {
  .two-col, .ba-grid { grid-template-columns: minmax(0, 1fr); }
  .try-wrap { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .demo-shell { justify-content: stretch; }
  #chat-widget[data-demo] #chat-panel { width: 100%; }
  .calc-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  section, .hero, .nav-inner, footer { padding-left: 18px; padding-right: 18px; }
  nav .links { gap: 14px; }
  section { padding-top: 56px; padding-bottom: 56px; }
}
