/* computer.css — a computer's view (its projects, a project's chats) and the
 * dashboard's open / share / leave. The rules are the desktop's (krystal-desktop
 * src/css/projects.css, sidebar.css, live.css, header.css), fitted to a phone;
 * the transcript and composer are in transcript.css. */

:root {
  /* The desktop's tokens this app didn't have yet. */
  --warn: #e29b50; --warn-bg: rgba(226,155,80,0.06); --warn-bd: rgba(226,155,80,0.30);
  --code-bg: #070b08; --radius: 10px; --radius-sm: 6px; --read-w: 760px;
}

.ui-ico {
  width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* ------------------------------- the screen -------------------------------- */

/* The computer's view is the whole window: a head, then one page. A chat's feed
   scrolls inside it, with the composer held at the bottom. */
#computer { height: 100dvh; min-height: 0; background: var(--bg); }
body:has(#computer:not([hidden])) .lang { display: none; }
.cv-page { flex: 1 1 auto; min-height: 0; }
.cv-page[hidden] { display: none; }
.cv-list { overflow-y: auto; padding: 6px 16px calc(36px + var(--safe-bottom)); }
.cv-list > * { max-width: 880px; margin-left: auto; margin-right: auto; }

.cv-head {
  flex: 0 0 auto; position: relative; z-index: 3;
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--bg);
}
.cv-head::after {
  content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 22px;
  background: linear-gradient(var(--bg), transparent); pointer-events: none;
}
.cv-back {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: rgba(255,255,255,0.045); color: var(--fg-muted);
  cursor: pointer; font-size: 17px; transition: color .15s ease, background-color .15s ease;
}
.cv-back:hover { color: var(--fg); background: rgba(255,255,255,0.08); }
.cv-head-text { flex: 1 1 auto; min-width: 0; }
/* The desktop's chat title: a green "$ " before it. */
.cv-title {
  font-size: 15px; font-weight: 600; letter-spacing: 0.01em; color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cv-title::before { content: "$ "; color: var(--accent-2); text-shadow: 0 0 8px rgba(108,199,142,0.5); }
.cv-sub {
  margin-top: 2px; font-size: 12px; color: var(--fg-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* A path reads like the desktop's cwd line: "› C:\…\project". */
.cv-sub.path { font-family: var(--mono); font-size: 11px; }
.cv-sub.path::before { content: "› "; color: var(--accent-2); }
.cv-state {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--fg-dim);
}
.cv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-2); transition: background-color .4s ease; }
.cv-state.on { color: var(--accent-3); }
.cv-state.on .cv-dot { background: var(--accent-2); }
.cv-state.off .cv-dot { background: var(--fg-dim); }

/* What went wrong (offline, outdated, an error), and Try again. */
.cv-note {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px; justify-content: space-between;
  margin: 4px 16px 6px; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.45; color: var(--fg-muted);
  background: var(--warn-bg); border: 1px solid var(--warn-bd);
}
.cv-note[hidden] { display: none; }
.cv-note.in { animation: suggest-in .22s ease; }
.cv-note .link { flex: none; font-size: 13px; }

.cv-loading {
  list-style: none; grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 28px 0; font-size: 13.5px; color: var(--fg-dim);
}
.cv-loading .wl-dot { animation: live-pulse 1.6s ease-out infinite; }

/* -------------------------------- projects --------------------------------- */

.project-list {
  list-style: none; margin: 14px auto 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px;
}
.project-empty {
  grid-column: 1 / -1; text-align: center; color: var(--fg-dim);
  font-size: 14px; padding: 28px 0;
}
.project-card { position: relative; animation: card-rise .34s ease backwards; }
.project-card:nth-child(2) { animation-delay: .04s; }
.project-card:nth-child(3) { animation-delay: .08s; }
.project-card:nth-child(4) { animation-delay: .12s; }
.project-card:nth-child(n+5) { animation-delay: .16s; }
@keyframes card-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.project-card .project-open {
  width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: var(--bg-card); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 15px 16px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color .16s ease, background .16s ease, transform .16s cubic-bezier(.2,.9,.3,1.2), box-shadow .2s ease;
}
.project-card .project-open:hover {
  border-color: var(--accent-2); background: var(--bg-card-2);
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.32), 0 0 0 1px rgba(108,199,142,0.18);
}
.project-card .project-open:active { transform: translateY(-1px); }
.proj-name {
  font-size: 15px; font-weight: 600; color: var(--accent-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proj-name::before { content: "▸ "; color: var(--accent-2); }
.proj-path {
  font-family: var(--mono); font-size: 11px; color: var(--fg-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proj-meta { font-size: 11.5px; color: var(--fg-muted); }

/* ---------------------------------- chats ---------------------------------- */

.new-chat-btn {
  display: block; width: 100%; margin-top: 10px; padding: 11px 12px;
  font-family: var(--sans); font-size: 13px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--accent-3); background: rgba(108,199,142,0.11);
  border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s, border-color .12s;
}
.new-chat-btn:hover { background: rgba(108,199,142,0.18); }
.new-chat-btn:disabled { opacity: .55; cursor: default; }
.sidebar-list {
  list-style: none; margin: 10px auto 0; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-list li { position: relative; }
.sidebar-list a {
  display: flex; flex-direction: column; padding: 10px 12px;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--fg);
  font-size: 14px; line-height: 1.4; border: 1px solid transparent; cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.sidebar-list a:hover { background: rgba(255,255,255,0.04); transform: translateX(2px); }
.sidebar-list .sum {
  order: -1; color: var(--fg-muted); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  transition: color .15s ease;
}
.sidebar-list a:hover .sum, .sidebar-list li.streaming .sum { color: var(--fg); }
.sidebar-list .time { display: block; margin-top: 2px; font-size: 11px; color: var(--fg-dim); letter-spacing: 0.02em; }
.sidebar-list .row-state { color: var(--accent-3); font-weight: 600; }
.sidebar-list .live-dot {
  display: inline-block; width: 6px; height: 6px; margin-left: 7px;
  border-radius: 999px; background: var(--accent-2); vertical-align: middle;
  animation: live-pulse 1.6s ease-out infinite;
}
.sidebar-empty { color: var(--fg-dim); font-size: 13px; padding: 14px 12px; }
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(108,199,142,0.5); opacity: 1; }
  70%  { box-shadow: 0 0 0 5px rgba(108,199,142,0); opacity: .65; }
  100% { box-shadow: 0 0 0 0 rgba(108,199,142,0); opacity: 1; }
}

/* -------------------------- the dashboard's rows -------------------------- */

/* The row opens its computer; the actions sit beside the link. */
.dev-open {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 12px;
  color: inherit; text-decoration: none; border-radius: 10px;
}
.dev-open .dev-name, .dev-open .dev-meta { display: block; }
.dev-row:has(.dev-open:hover) { border-color: var(--border-2); }
.dev-row:has(.dev-open:hover) .dev-name { color: var(--accent-3); }
.dev-name { transition: color .15s ease; }
.dev-row.shared .dev-ico { color: var(--fg-muted); }
.dev-row.sharing { border-color: rgba(108,199,142,0.35); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; }
.dev-share-btn[aria-expanded="true"] { color: var(--accent-3); }

/* Sharing: who has it, and a field to add someone. */
.dev-share {
  margin-top: -4px; padding: 14px; border-radius: 4px 4px 14px 14px;
  background: var(--bg-card); border: 1px solid rgba(108,199,142,0.35); border-top: 0;
  animation: step-in .22s var(--ease-out) both; --step-from: -6px;
}
.dev-share-head { font-weight: 600; font-size: 14.5px; }
.dev-share-sub { margin: 4px 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--fg-muted); }
.share-list { display: grid; gap: 4px; margin-bottom: 10px; }
.share-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; font-size: 14px; }
.share-ico { color: var(--fg-dim); }
.share-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-none { font-size: 13px; color: var(--fg-dim); padding: 2px 2px 4px; }
.share-form { display: flex; gap: 8px; }
.share-form .field { flex: 1; min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  .project-card, .cv-note.in, .dev-share { animation: none; }
  .project-card .project-open:hover, .sidebar-list a:hover { transform: none; }
  .sidebar-list .live-dot, .cv-loading .wl-dot { animation: none; }
}

/* Toasts float above the composer, not on it. */
body:has(#computer:not([hidden])) .toast { bottom: calc(96px + var(--safe-bottom)); }
