/* Cella app UI kit — layout + component styles.
   Depends on ../../colors_and_type.css for tokens. */

html, body, #root { height: 100%; }
body {
  background: var(--bg-cream);
  color: var(--fg-primary);
  font-family: var(--font-serif);
  overflow: hidden;
}

/* ── Shell scaffold ──────────────────────────────────────────────── */
.cella-shell {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: var(--rail-width) 1fr var(--chat-pane-width-cur, var(--chat-pane-width));
  grid-template-rows: 52px var(--phase-bar-height) 1fr var(--coaching-bar-height);
  grid-template-areas:
    "rail header header"
    "rail phase  phase"
    "rail editor chat"
    "rail coach  coach";
}
.cella-shell.chat-closed { --chat-pane-width-cur: 0px; }

/* ── Header ──────────────────────────────────────────────────────── */
.cella-header {
  grid-area: header;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  background: var(--shell-sky);
  box-shadow: var(--shell-sky-shadow);
  z-index: 2;
}
.hdr-left { display: flex; align-items: center; gap: 12px; }
.cella-mark { color: var(--fg-primary); display: flex; }
.hdr-crumbs { display: flex; align-items: baseline; gap: 8px; font-size: 15px; color: var(--fg-secondary); }
.crumb-garden { color: var(--fg-tertiary); }
.crumb-sep { color: var(--fg-muted); }
.crumb-title {
  font-family: var(--font-serif); font-size: 15px;
  background: transparent; border: none; outline: none;
  color: var(--fg-primary); min-width: 240px; padding: 4px 0;
}
.crumb-title:focus { border-bottom: 1px solid var(--copper-day); }
.hdr-right { display: flex; align-items: center; gap: 14px; }
.hdr-meta { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--hud-dim); }
.theme-toggle {
  background: transparent; border: none; cursor: pointer;
  font-family: var(--font-serif); font-size: 18px; color: var(--fg-tertiary);
  width: 28px; height: 28px; border-radius: 9999px;
}
.theme-toggle:hover { color: var(--fg-primary); background: rgba(28,26,23,0.04); }
.account-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--copper-day); opacity: 0.6; }

/* ── Left rail ───────────────────────────────────────────────────── */
.left-rail {
  grid-area: rail;
  display: flex; flex-direction: column; align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  background: var(--shell-wall);
  border-right: none;
  z-index: 3;
}
.rail-stack { display: flex; flex-direction: column; gap: 4px; }
.rail-btn {
  width: 32px; height: 32px; border-radius: 9999px;
  background: transparent; border: none; cursor: pointer;
  color: var(--fg-tertiary); font-family: var(--font-serif);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--dur-fast), background var(--dur-fast);
}
.rail-btn:hover { color: var(--fg-primary); background: rgba(28,26,23,0.04); }
.rail-btn.is-active { color: var(--fg-primary); background: var(--bg-warm); box-shadow: var(--shadow-sm); }
.rail-glyph { font-size: 16px; line-height: 1; }

/* ── Phase bar ──────────────────────────────────────────────────── */
.phase-bar {
  grid-area: phase;
  background: var(--bg-cream);
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
}
.phase-bar-inner {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 9999px;
  background: rgba(28,26,23,0.03);
}
.phase-pill {
  font-family: var(--font-serif); font-size: 13px;
  padding: 5px 14px; border-radius: 9999px;
  background: transparent; border: none; cursor: pointer;
  color: var(--fg-secondary); letter-spacing: 0.01em;
  display: inline-flex; align-items: center; gap: 6px;
}
.phase-pill:hover { color: var(--fg-primary); }
.phase-pill.is-active { background: var(--bg-warm); color: var(--fg-primary); box-shadow: var(--shadow-sm); }
.phase-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.55; display: inline-block; }
.phase-pill.is-active .phase-dot { opacity: 1; }

/* ── Editor ─────────────────────────────────────────────────────── */
.editor {
  grid-area: editor;
  overflow: hidden;
  background: var(--bg-cream);
}
.editor-scroll { height: 100%; overflow-y: auto; padding: 48px 64px 120px; }
.writing-surface {
  max-width: var(--zen-max-width);
  margin: 0 auto;
  font-size: var(--text-md); line-height: 1.8;
  color: var(--fg-primary);
}
.writing-surface p { margin: 0 0 22px; }
.writing-surface em { font-style: italic; }
.doc-h1 { font-size: 36px; line-height: 1.1; letter-spacing: -0.015em; margin: 0 0 6px; }
.doc-sub { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 40px; }

.cursor-line { position: relative; color: var(--fg-secondary); }
.caret {
  color: var(--copper-day);
  animation: cellaCaret 1200ms var(--ease-smooth) infinite;
  margin-left: 2px;
}
@keyframes cellaCaret {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Mark-observational (inline amber) ──────────────────────────── */
.mark-wrap { position: relative; display: inline; }
.mark-observational {
  text-decoration: underline wavy var(--amber);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  cursor: pointer;
  transition: background var(--dur-fast);
}
.mark-observational:hover { background: rgba(245,158,11,0.08); }
.mark-observational.is-open { background: rgba(245,158,11,0.12); }
.mark-tip {
  position: absolute; left: 0; top: calc(100% + 10px);
  width: 320px; padding: 12px 14px;
  background: var(--bg-warm); border-left: 2px solid var(--amber);
  border-radius: 0 8px 8px 0;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 8px;
  font-style: normal;
  z-index: 10;
  animation: tipRise 250ms var(--ease-out);
}
@keyframes tipRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mark-tip-eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber-dark); }
.mark-tip-body { font-size: 14px; line-height: 1.55; color: var(--fg-secondary); }
.mark-tip-actions { display: flex; gap: 6px; }
.btn-ghost-sm {
  font-family: var(--font-serif); font-size: 12px;
  padding: 4px 10px; border-radius: 9999px;
  border: 1px solid var(--border-medium); background: transparent;
  color: var(--fg-secondary); cursor: pointer;
}
.btn-ghost-sm:hover { border-color: var(--fg-tertiary); color: var(--fg-primary); }

/* ── Chat pane ──────────────────────────────────────────────────── */
.chat-pane {
  grid-area: chat;
  display: flex; flex-direction: column;
  background: var(--bg-warm);
  box-shadow: -4px 0 16px rgba(28,26,23,0.04);
  overflow: hidden;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 10px; }
.chat-eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--copper-day); }
.chat-close {
  background: transparent; border: none; cursor: pointer;
  font-family: var(--font-serif); font-size: 20px; color: var(--fg-tertiary);
  width: 24px; height: 24px; border-radius: 9999px; line-height: 1;
}
.chat-close:hover { color: var(--fg-primary); }
.chat-scroll { flex: 1; overflow-y: auto; padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.chat-msg p { font-size: 15px; line-height: 1.55; color: var(--fg-primary); margin: 0; }
.chat-author { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 4px; display: block; }
.chat-msg--user p {
  background: var(--bg-cream); padding: 10px 14px;
  border-radius: 12px 12px 2px 12px;
  align-self: flex-end; max-width: 85%;
}
.chat-msg--user { display: flex; justify-content: flex-end; }
.chat-compose { padding: 12px 20px 20px; }
.chat-compose input {
  width: 100%; font-family: var(--font-serif); font-size: 15px;
  padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border-subtle); background: var(--bg-cream);
  color: var(--fg-primary); outline: none;
}
.chat-compose input:focus { border-color: var(--copper-day); }
.chat-compose input::placeholder { color: var(--fg-muted); font-style: italic; }

/* ── Coaching bar (bottom) ──────────────────────────────────────── */
.coaching-bar {
  grid-area: coach;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 0 20px;
  background: var(--shell-ground);
  box-shadow: var(--shell-ground-shadow);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; color: var(--hud);
}
.dot-pulse { width: 6px; height: 6px; border-radius: 50%; background: #7FA886; animation: cellaPulse 2.5s ease-in-out infinite; }
@keyframes cellaPulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.85; } }
.cb-item { }
.cb-cop { color: var(--copper-day); letter-spacing: 0.12em; text-transform: uppercase; }
.cb-dim { color: var(--hud-dim); }
.cb-sep { width: 1px; height: 10px; background: var(--border-subtle); }
.cb-goal {
  display: inline-block; width: 56px; height: 2px; border-radius: 1px;
  background: var(--border-subtle); position: relative;
}
.cb-goal::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--p, 0%);
  background: var(--copper-day); border-radius: 1px;
}

/* ── Glass Door ─────────────────────────────────────────────────── */
.glass-door {
  position: fixed; inset: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr 1fr;
  pointer-events: none;
}
.gd-left, .gd-right {
  background: rgba(250,250,249,0.88);
  backdrop-filter: blur(30px) saturate(1.1);
  -webkit-backdrop-filter: blur(30px) saturate(1.1);
  transition: transform 1400ms var(--ease-out);
  box-shadow: inset 0 0 80px rgba(144,108,58,0.06);
}
.gd-seam {
  position: absolute; inset: 0 auto 0 50%; width: 1px;
  background: linear-gradient(to bottom, transparent, var(--copper-day), transparent);
  opacity: 0.7; transform: translateX(-0.5px);
  transition: opacity 600ms var(--ease-out);
}
.gd-greeting {
  position: absolute; inset: 50% 0 auto 0; transform: translateY(-50%);
  text-align: center; font-size: 28px; color: var(--fg-secondary);
  font-style: italic; letter-spacing: -0.01em;
  opacity: 1; transition: opacity 600ms var(--ease-in);
}
.glass-door.opening .gd-left  { transform: translateX(-100%); }
.glass-door.opening .gd-right { transform: translateX( 100%); }
.glass-door.opening .gd-seam,
.glass-door.opening .gd-greeting { opacity: 0; }

/* ── Night mode adjustments ─────────────────────────────────────── */
[data-theme="night"] body { background: var(--bg-cream); }
[data-theme="night"] .phase-bar { background: var(--bg-cream); }
[data-theme="night"] .editor { background: var(--bg-cream); }
[data-theme="night"] .chat-pane { background: var(--bg-warm); }
[data-theme="night"] .cella-header { background: var(--shell-sky); }
[data-theme="night"] .coaching-bar { background: var(--shell-ground); color: var(--hud); }
[data-theme="night"] .left-rail { background: var(--shell-wall); }
[data-theme="night"] .crumb-title { color: var(--fg-primary); }
[data-theme="night"] .gd-left, [data-theme="night"] .gd-right { background: rgba(12,10,9,0.88); }

/* ── Scrollbars (quiet) ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-thumb { background: rgba(28,26,23,0.10); border-radius: 9999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(28,26,23,0.18); background-clip: content-box; border: 3px solid transparent; }
