/* ============================================================
   Interactive AI-system demo — Notion-style split
   Left: a Notion-like workspace page that builds itself.
   Right: a Notion-AI-style chat panel (pick a prompt).
   Uses site.css custom properties; works in light + dark.
   ============================================================ */

.demo { padding: 84px 0; background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.demo-window {
  margin-top: 44px;
  margin-left: auto; margin-right: auto;
  max-width: 1040px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  /* fixed laptop-screen proportions (16:10, like a MacBook) so every
     demo reads as the same physical device; content scrolls inside. */
  aspect-ratio: 16 / 10;
  display: flex;
  flex-direction: column;
}
/* round the inner scrolling panels so corners read clean in WebKit */
.demo-window .demo-titlebar { border-radius: 16px 16px 0 0; }
@media (min-width: 880px) {
  .demo-window .demo-split > *:first-child { border-bottom-left-radius: 16px; }
  .demo-window .demo-split > *:last-child { border-bottom-right-radius: 16px; }
}

/* browser/app titlebar */
.demo-titlebar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
}
.demo-titlebar .lights { display: flex; gap: 6px; }
.demo-titlebar .lights i { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.demo-titlebar .lights i:nth-child(1) { background: #E8695E; }
.demo-titlebar .lights i:nth-child(2) { background: #F5BD4F; }
.demo-titlebar .lights i:nth-child(3) { background: #61C454; }
.demo-titlebar .t-tab {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 8px 8px 0 0; border-bottom: none;
  padding: 7px 14px; margin-bottom: -11px;
}
.demo-titlebar .t-tab .em { font-style: normal; }
.demo-titlebar .t-spacer { flex: 1; }
.demo-reset {
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft); padding: 5px 11px; border-radius: 7px;
  display: inline-flex; align-items: center; gap: 5px;
}
.demo-reset:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }

/* split: workspace left, chat right — fills the window below the titlebar */
.demo-split { display: grid; grid-template-columns: 1fr; flex: 1 1 auto; min-height: 0; }
@media (min-width: 880px) {
  .demo-split { grid-template-columns: 1fr 376px; }
}

/* ===================================================== */
/* WORKSPACE (left)                                       */
/* ===================================================== */
/* Workspace scrolls inside the fixed window; building auto-scrolls it to
   the freshly-made content (see reveal() in the demo scripts). */
.nb-page {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-y: auto;
  min-height: 0;
}
@media (min-width: 880px) { .nb-page { border-bottom: none; border-right: 1px solid var(--line); } }

.nb-crumb {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--ink-faint);
  padding: 9px 20px;
}
.nb-crumb .em { font-style: normal; }
.nb-crumb .sep { opacity: 0.5; }

/* gradient cover — slimmed to a band so content sits high in view */
.nb-cover {
  height: 54px;
  background: linear-gradient(125deg, #1E0F04 0%, #6B380E 45%, #D9730D 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.nb-cover-word {
  font-size: clamp(16px, 2.6vw, 21px); font-weight: 700; letter-spacing: -0.01em;
  color: #fff; opacity: 0.96; text-shadow: 0 1px 12px rgba(0,0,0,0.18);
}

/* page head — icon + title on one tight row, like Notion */
.nb-pagehead { padding: 0 30px; display: flex; align-items: center; flex-wrap: wrap; gap: 0 12px; }
.nb-icon {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-top: -20px; position: relative; flex: none;
}
.nb-icon svg { width: 22px; height: 22px; }
.nb-h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin-top: 0; color: var(--ink); white-space: nowrap; }
.nb-welcome { flex-basis: 100%; font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); margin-top: 6px; }

/* tabbed workspace — the view tab bar sticks so you always see which
   view you're in while scrolling the content under it. */
.nb-tabs { margin-top: 12px; }
.nb-tabbar {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 0 30px;
  overflow-x: auto;
  overflow-y: hidden;
  position: sticky; top: 0; z-index: 5;
  background: var(--card);
}
.nb-tab {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  color: var(--ink-faint); background: none; border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 11px; cursor: pointer; white-space: nowrap; margin-bottom: -1px;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.nb-tab .em { font-style: normal; }
.nb-tab:hover { color: var(--ink-soft); }
.nb-tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.nb-tab.tab-new { animation: msg-in 0.3s ease both; }
.nb-panes { padding: 16px 30px 22px; }
.nb-pane { display: none; }
.nb-pane-sub { font-size: 12px; color: var(--ink-faint); margin-bottom: 12px; }

.nb-empty {
  border: 1.5px dashed var(--line);
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 14px;
}
.nb-empty .big { font-size: 26px; display: block; margin-bottom: 8px; opacity: 0.8; }

/* working badge */
.nb-working {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  padding: 5px 12px;
}
.nb-working .spin {
  width: 11px; height: 11px; flex: none;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes msg-in { from { transform: translateY(6px); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .nb-section, .chat-msg, .nb-tr, .nb-card, .nb-check { animation: none !important; } }

/* table */
.nb-table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; font-size: 13.5px; box-shadow: var(--shadow-sm); }
.nb-tr { display: grid; grid-template-columns: 1.4fr 1fr 0.9fr 0.6fr; border-bottom: 1px solid var(--line); }
.nb-tr:last-child { border-bottom: none; }
.nb-tr.head { background: var(--bg-alt); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); }
.nb-td { padding: 9px 12px; display: flex; align-items: center; gap: 7px; min-width: 0; border-right: 1px solid var(--line); }
.nb-td:last-child { border-right: none; }
.nb-tr.head .nb-td { border-right-color: transparent; }
.nb-td .cell-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-tr.row-enter { animation: msg-in 0.3s ease both; }
.nb-tr.row-flash { animation: row-flash 1.8s ease both; }
@keyframes row-flash {
  0% { background: color-mix(in srgb, var(--accent) 20%, transparent); }
  100% { background: transparent; }
}
.nb-name { font-weight: 600; color: var(--ink); }

.pill { font-size: 11.5px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.pill-green { background: color-mix(in srgb, #2E9E63 18%, transparent); color: #2E9E63; }
html[data-theme="dark"] .pill-green { color: #5FCE96; }
.pill-orange { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.pill-gray { background: color-mix(in srgb, var(--ink-faint) 18%, transparent); color: var(--ink-soft); }

.nb-avatar {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  background: var(--line); color: var(--ink-soft);
  font-size: 9.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

/* board */
.nb-board { display: grid; grid-template-columns: repeat(4, minmax(112px, 1fr)); gap: 10px; overflow-x: auto; }
.nb-col { min-width: 0; }
.nb-col-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; padding: 0 2px; }
.nb-col-head .count { color: var(--ink-faint); font-weight: 600; }
.nb-cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.nb-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}
.nb-card .card-tag { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint); margin-top: 5px; }
.nb-card.card-enter { animation: msg-in 0.3s ease both; }
.nb-card.card-leave { opacity: 0; transform: translateY(-6px) scale(0.97); transition: all 0.3s ease; }
.nb-card.card-arrive { animation: card-arrive 0.45s ease both; }
@keyframes card-arrive {
  0% { transform: translateY(-10px) scale(0.96); box-shadow: 0 8px 20px rgba(0,0,0,0.12); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

/* checklist */
.nb-checklist { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow-sm); }
.nb-check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-soft); padding: 4px 0; animation: msg-in 0.3s ease both; }
.nb-check .box {
  width: 15px; height: 15px; border-radius: 4px; flex: none;
  border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #fff;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.nb-check.done .box { background: var(--accent); border-color: var(--accent); }
.nb-check.done { color: var(--ink); }
.nb-check .when { margin-left: auto; font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }

/* ===================================================== */
/* AI CHAT PANEL (right)                                  */
/* ===================================================== */
.ai-panel { display: flex; flex-direction: column; background: var(--card); min-height: 0; min-width: 0; overflow: hidden; }
/* the panel fills the window column; the body (flex:1) scrolls to the
   newest message while head + input stay pinned. */
@media (min-width: 880px) { .ai-panel { height: 100%; } }

.ai-head {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.ai-head .ai-title { font-size: 14px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 5px; }
.ai-head .ai-title svg { width: 13px; height: 13px; color: var(--ink-faint); }
.ai-head .ai-head-r { margin-left: auto; display: flex; gap: 4px; color: var(--ink-faint); }
.ai-head .ai-head-r svg { width: 16px; height: 16px; }

.ai-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; }
@media (min-width: 880px) { .ai-body { min-height: 220px; } }

/* welcome state */
.ai-welcome { display: flex; flex-direction: column; }
.ai-logo {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(140deg, #f0eee9, #d9d5cc);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 14px;
}
html[data-theme="dark"] .ai-logo { background: linear-gradient(140deg, #34322e, #45413b); }
.ai-welcome-h { font-size: 16.5px; font-weight: 700; color: var(--ink); margin-bottom: 12px; letter-spacing: -0.01em; }

/* messages */
.chat-log { display: flex; flex-direction: column; gap: 12px; }
.chat-msg { font-size: 14px; line-height: 1.55; animation: msg-in 0.25s ease both; }
.chat-msg.user {
  align-self: flex-end; max-width: 90%;
  background: var(--bg-alt); color: var(--ink);
  padding: 9px 13px; border-radius: 13px; border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-msg.ai {
  align-self: stretch;
  color: var(--ink);
  padding-left: 26px; position: relative;
}
.chat-msg.ai::before {
  content: ""; position: absolute; left: 0; top: 2px;
  width: 15px; height: 15px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='9.5' cy='10' r='1.3' fill='%23D9730D'/%3E%3Ccircle cx='14' cy='9.5' r='1.3' fill='%23D9730D'/%3E%3Cpath d='M16 6.5C14 4.5 10.5 4 7.5 6C4.5 8 4 12 6 14.5C8 17 12.5 17.5 15.5 15.5C17.5 14 17.5 11.5 16 9.5' stroke='%23D9730D' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}
.chat-msg .chat-cta {
  display: inline-block; margin-top: 8px;
  font-weight: 600; font-size: 14px; color: var(--accent); text-decoration: none;
}
.chat-msg .chat-cta:hover { text-decoration: underline; }

/* typing */
.chat-typing { align-self: flex-start; display: flex; gap: 4px; padding: 8px 4px 8px 26px; position: relative; }
.chat-typing::before { content: ""; position: absolute; left: 0; top: 9px; width: 15px; height: 15px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='9.5' cy='10' r='1.3' fill='%23D9730D'/%3E%3Ccircle cx='14' cy='9.5' r='1.3' fill='%23D9730D'/%3E%3Cpath d='M16 6.5C14 4.5 10.5 4 7.5 6C4.5 8 4 12 6 14.5C8 17 12.5 17.5 15.5 15.5C17.5 14 17.5 11.5 16 9.5' stroke='%23D9730D' stroke-width='2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); background-size: contain; background-repeat: no-repeat; }
.chat-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); animation: dot-bounce 1s infinite ease-in-out; }
.chat-typing i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce { 0%, 60%, 100% { transform: none; opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* suggestions (Notion-style rows) */
.ai-sugs { display: flex; flex-direction: column; margin-top: 14px; }
.ai-sugs.with-convo { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.ai-sugs .sug-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint); padding: 2px 6px 6px; }
.ai-sug {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--ink); background: none; border: none;
  border-radius: 8px; padding: 9px 8px; cursor: pointer;
  transition: background 0.14s ease;
}
.ai-sug:hover { background: var(--bg-alt); }
.ai-sug .ic { flex: none; width: 18px; height: 18px; color: var(--accent); display: flex; align-items: center; justify-content: center; }
.ai-sug .ic svg { width: 17px; height: 17px; }
.ai-sug .new-tag { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 5px; padding: 1px 6px; }

/* bottom input bar */
.ai-input { flex: none; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.ai-input-box {
  border: 1px solid var(--line); border-radius: 13px;
  background: var(--bg); padding: 10px 12px; box-shadow: var(--shadow-sm);
}
.ai-ctx { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-soft); background: var(--card); border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px; }
.ai-ctx .em { font-style: normal; }
.ai-ph { font-size: 14px; color: var(--ink-faint); margin: 9px 2px 11px; }
.ai-ctrls { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); }
.ai-ctrls svg { width: 17px; height: 17px; }
.ai-ctrls .ai-auto { font-size: 12.5px; font-weight: 600; margin-left: auto; }
.ai-ctrls .ai-send {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.ai-ctrls .ai-send svg { width: 14px; height: 14px; }

/* demo footnote */
.demo-note { text-align: center; font-size: 13.5px; color: var(--ink-faint); margin-top: 18px; }

/* ===================================================== */
/* DRAG & DROP (shared with demo-drag.js)                 */
/* ===================================================== */
.drag-item { touch-action: none; }
.nb-card.drag-item { cursor: grab; transition: border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease; }
.nb-card.drag-item:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.nb-tr.drag-item:not(.head) { cursor: grab; }
.nb-tr.drag-item:not(.head):hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* the lifted element while dragging */
.is-dragging { cursor: grabbing !important; z-index: 999; }
.nb-card.is-dragging { box-shadow: 0 12px 28px rgba(0,0,0,0.18); border-color: var(--accent); transform: scale(1.02); }
.nb-tr.is-dragging { background: var(--card); border: 1px solid var(--accent); border-radius: 9px; box-shadow: 0 12px 28px rgba(0,0,0,0.18); }
.nb-ms.is-dragging { background: var(--card); border: 1px solid var(--accent); border-radius: 8px; box-shadow: 0 12px 28px rgba(0,0,0,0.18); }

/* gap the lifted element leaves behind */
.drag-ph {
  box-sizing: border-box; border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  border: 1.5px dashed color-mix(in srgb, var(--accent) 42%, var(--line));
}
body.drag-active { cursor: grabbing; -webkit-user-select: none; user-select: none; }

/* the "drag to reorder" affordance line */
.nb-draghint { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-faint); margin-top: 10px; font-weight: 500; }
.nb-draghint svg { width: 13px; height: 13px; opacity: 0.7; }

/* ===================================================== */
/* MOBILE — drop the fixed aspect, stack with capped panels */
/* ===================================================== */
@media (max-width: 879px) {
  .demo-window { aspect-ratio: auto; display: block; }
  .demo-split { display: block; }
  .nb-page { max-height: 56vh; }
  .ai-panel { height: 70vh; max-height: 560px; }
}
