/* Agentic design system: shared by every page. Warm dark, one living colour (ember), violet for thinking. */
:root {
  --bg: #0b0a09; --bg2: #15120f; --bg3: #1d1915; --ink: #f4efe7; --ink2: #d6cfc4; --dim: #9a9187; --line: #2a2520; --line2: #3a332c;
  --panel: rgba(24, 20, 17, .74); --ember: #ff6a3d; --ember2: #ff9a6b; --violet: #8b7bff; --mint: #45e0b0; --warn: #ffb547; --bad: #ff6b6b;
  --display: 'Bricolage Grotesque', system-ui, sans-serif; --sans: 'Bricolage Grotesque', system-ui, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
  --r: 18px; --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { max-width: 100%; }
::selection { background: #ff6a3d55; }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); }

/* ---------- header */
.ag-top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px; padding: 12px clamp(16px, 4vw, 40px);
  background: linear-gradient(#0b0a09f2, #0b0a09b0); backdrop-filter: blur(14px) saturate(1.2); border-bottom: 1px solid #ffffff0a; }
.ag-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 800 22px/1 var(--display); letter-spacing: -.04em; }
.ag-brand img { width: 32px; height: 32px; }
.ag-nav { display: flex; gap: 4px; margin-left: auto; }
.ag-nav a { text-decoration: none; color: var(--dim); font-size: 14px; padding: 8px 12px; border-radius: 10px; transition: color .2s, background .2s; }
.ag-nav a:hover { color: var(--ink); background: #ffffff08; }
.ag-nav a.on { color: var(--ink); background: #ffffff0d; }
@media (max-width: 760px) { .ag-nav { display: none; } .ag-top .btn { margin-left: auto; } }

/* ---------- buttons, chips */
.btn { --c: var(--ember); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 14px; border: 0;
  background: var(--c); color: #1a0b05; font: 700 15px var(--sans); text-decoration: none; cursor: pointer; position: relative; isolation: isolate;
  transition: transform .2s var(--ease), box-shadow .3s; box-shadow: 0 0 0 0 #ff6a3d00; white-space: nowrap; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 34px -8px #ff6a3d88; }
.btn:active { transform: translateY(0) scale(.98); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1px var(--ember), 0 12px 30px -12px #ff6a3d55; }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 11px; }
.btn.big { padding: 17px 28px; font-size: 17px; border-radius: 16px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 500 12px var(--mono); padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line2); color: var(--ink2); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.live { color: var(--ember); border-color: #ff6a3d55; background: #ff6a3d10; }
.chip.think { color: var(--violet); border-color: #8b7bff55; background: #8b7bff12; }
.chip.ready { color: var(--mint); border-color: #45e0b055; background: #45e0b010; }
.chip.sleep { color: var(--warn); border-color: #ffb54744; }
.chip.live i, .chip.think i { animation: blinkdot 1.4s ease-in-out infinite; }
@keyframes blinkdot { 50% { opacity: .25; } }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font: 600 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ember); }
.eyebrow::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 0 #ff6a3d99; animation: ping 1.8s infinite; }
@keyframes ping { to { box-shadow: 0 0 0 10px #ff6a3d00; } }
.glow-text { background: linear-gradient(100deg, var(--ember) 0%, var(--ember2) 40%, var(--violet) 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  background-size: 200% auto; animation: shine 7s linear infinite; }
@keyframes shine { to { background-position: 200% center; } }

/* ---------- panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(10px); }
.card-hover { transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.card-hover:hover { transform: translateY(-4px); border-color: #ff6a3d55; box-shadow: 0 22px 50px -24px #ff6a3d66; }

/* ---------- living avatar (see js/living.js) */
.living { position: relative; width: var(--size, 220px); aspect-ratio: 1; flex: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.living canvas { position: absolute; inset: -28%; width: 156%; height: 156%; pointer-events: none; }
.living .face { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; background: var(--bg3); transform-style: preserve-3d;
  box-shadow: 0 0 0 2px #ffffff14, 0 20px 60px -20px #000; transition: transform .25s var(--ease), filter .6s; animation: breathe 4.6s ease-in-out infinite; }
.living .face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.living .face::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at var(--gx, 35%) var(--gy, 30%), #ffffff38, transparent 55%); mix-blend-mode: soft-light; }
.living[data-state="sleep"] .face { filter: saturate(.35) brightness(.7); animation-duration: 7s; }
.living[data-state="dormant"] .face { filter: grayscale(.85) brightness(.65); animation-duration: 8s; }
.living[data-state="think"] .face { animation-duration: 2.4s; }
@keyframes breathe { 50% { scale: 1.035; } }
.living .zz { position: absolute; right: 2%; top: -6%; font: 700 calc(var(--size, 220px) * .11) var(--display); color: var(--warn); opacity: 0; pointer-events: none; }
.living[data-state="sleep"] .zz, .living[data-state="dormant"] .zz { animation: zz 3.2s ease-in-out infinite; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 10px) scale(.7); } 30% { opacity: .9; } 100% { opacity: 0; transform: translate(14px, -26px) scale(1.1); } }
.living .bubble { position: absolute; left: 50%; bottom: calc(100% + 18px); transform: translate(-50%, 8px); width: max-content; max-width: min(320px, 80vw);
  background: var(--ink); color: #1a1410; font: 500 14px/1.45 var(--sans); padding: 11px 14px; border-radius: 16px; box-shadow: 0 18px 40px -16px #000c;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s var(--ease); z-index: 3; }
.living .bubble::after { content: ''; position: absolute; left: 50%; top: 100%; border: 8px solid transparent; border-top-color: var(--ink); transform: translateX(-50%); }
.living .bubble.on { opacity: 1; transform: translate(-50%, 0); }
.living .bubble .caret { display: inline-block; width: 7px; height: 1em; background: var(--ember); vertical-align: -2px; margin-left: 2px; animation: blinkdot .8s steps(1) infinite; }
.living.small { --size: 56px; }
.living.small canvas { display: none; }
.living.small .face { box-shadow: 0 0 0 2px var(--ring, #ffffff18); }
.living.small[data-state="live"] { --ring: #ff6a3d; } .living.small[data-state="think"] { --ring: var(--violet); }

/* ---------- forms */
.field { display: grid; gap: 6px; font-size: 13px; color: var(--dim); }
.field input, .field textarea, .field select { width: 100%; font: 15px var(--sans); color: var(--ink); background: #0f0d0b; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; transition: border-color .2s, box-shadow .2s; }
.field textarea { min-height: 112px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 4px #ff6a3d1c; }
.err { color: var(--bad); font-size: 14px; min-height: 1.2em; margin: 0; }

/* ---------- "bring to life" dialog (js/mind-dialog.js) */
dialog.life { width: min(980px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--line2); border-radius: 26px; background: var(--bg2); color: var(--ink); overflow: auto; }
dialog.life::backdrop { background: #050403cc; backdrop-filter: blur(6px); }
dialog.life[open] { animation: popin .35s var(--ease); }
@keyframes popin { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.life-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); }
.life-stage { position: relative; padding: 40px 28px 28px; display: grid; justify-items: center; align-content: center; gap: 18px; min-height: 100%;
  background: radial-gradient(500px 380px at 50% 38%, #ff6a3d1f, transparent 70%), radial-gradient(400px 300px at 70% 80%, #8b7bff14, transparent 70%), #100e0c; border-right: 1px solid var(--line); }
.life-stage h3 { margin: 0; font: 800 26px/1.1 var(--display); letter-spacing: -.03em; text-align: center; overflow-wrap: anywhere; }
.life-stage .sub { color: var(--dim); font-size: 13px; text-align: center; }
.life-stage .preview-mind { font-size: 14px; color: var(--ink2); text-align: center; max-width: 320px; min-height: 3em; font-style: italic; }
.life-form { padding: 26px; display: grid; gap: 14px; align-content: start; }
.life-form h2 { margin: 0; font: 800 28px/1.1 var(--display); letter-spacing: -.03em; }
.life-form .row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; }
.life-x { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line2); background: var(--bg2); color: var(--ink); font-size: 20px; cursor: pointer; z-index: 2; }
.seeds { display: flex; flex-wrap: wrap; gap: 6px; }
.seeds button { font: 12px var(--sans); color: var(--ink2); background: #ffffff06; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; cursor: pointer; transition: border-color .2s, color .2s; }
.seeds button:hover { border-color: var(--ember); color: var(--ink); }
.faces { display: flex; gap: 8px; flex-wrap: wrap; }
.faces button { width: 48px; height: 48px; border-radius: 50%; padding: 0; border: 2px solid transparent; overflow: hidden; background: var(--bg3); cursor: pointer; }
.faces button img { width: 100%; height: 100%; object-fit: cover; }
.faces button.on { border-color: var(--ember); box-shadow: 0 0 0 3px #ff6a3d33; }
.faces label.up { width: 48px; height: 48px; border-radius: 50%; border: 1px dashed var(--line2); display: grid; place-items: center; color: var(--dim); cursor: pointer; font-size: 20px; }
.faces label.up input { display: none; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.facts div { border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; background: #ffffff04; }
.facts b { display: block; font: 600 13px var(--mono); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facts small { font-size: 11px; color: var(--dim); }
.note { font-size: 12.5px; color: var(--dim); line-height: 1.55; margin: 0; }
.note b { color: var(--ember2); font-weight: 600; }
.born { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 30px; }
.born h2 { font: 800 34px/1.05 var(--display); letter-spacing: -.03em; margin: 0; }
@media (max-width: 820px) {
  .life-grid { grid-template-columns: 1fr; }
  .life-stage { border-right: 0; border-bottom: 1px solid var(--line); padding: 54px 18px 22px; }
  .life-form { padding: 18px; }
}
@media (max-width: 480px) { .life-form .row, .facts { grid-template-columns: 1fr; } }

/* ---------- footer */
.ag-foot { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; align-items: center; padding: 28px clamp(16px, 4vw, 40px); border-top: 1px solid var(--line); color: var(--dim); font-size: 13px; }
.ag-foot a { color: var(--dim); text-decoration: none; } .ag-foot a:hover { color: var(--ink); }

/* reveal on scroll */
.rv { opacity: 0; transform: translateY(24px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.rv.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } .rv { opacity: 1; transform: none; } }
/* in the dialog the agent speaks below itself (no room above) */
.life-stage .living .bubble { bottom: auto; top: calc(100% + 16px); transform: translate(-50%, -8px); }
.life-stage .living .bubble.on { transform: translate(-50%, 0); }
.life-stage .living .bubble::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ink); }
.born { align-content: center; }
/* the agent's own body inside the living aura */
.living .face.char { border-radius: 0; overflow: visible; background: none; box-shadow: none; animation: none; filter: none !important; inset: -6% 0 0; }
.living .face.char::after { display: none; }
.living.small .face.char { inset: -14% -8% -4%; }
.living .zz { z-index: 2; }
.living:has(.face.char) .zz { display: none; }
.life-stage .sub img.from { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; vertical-align: -5px; margin-right: 3px; }
