:root {
  --bg: #ffffff;
  --fg: #0d0d0d;
  --muted: #1a1a1a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .5s cubic-bezier(.2,.7,.2,1), color .5s cubic-bezier(.2,.7,.2,1);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('circuit.svg');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  pointer-events: none;
  opacity: 0;
  transition: opacity .5s cubic-bezier(.2,.7,.2,1);
  z-index: 0;
}
body:has(.preview--chat.is-active)::before {
  opacity: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 24px 40px;
  font-size: 15px;
  z-index: 10;
}
.topbar-cell {
  opacity: 0;
}
.topbar-cell a {
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.topbar-cell a:hover { border-bottom-color: currentColor; }
.topbar-cell--end {
  justify-self: end;
}
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none !important;
  opacity: 0.85;
  transition: opacity .2s ease, transform .2s ease;
}
.icon-link:hover {
  opacity: 1;
  transform: translateY(-1px);
}
.icon-link svg { display: block; }

.stage {
  position: relative;
  min-height: 100vh;
  padding: 140px 40px 64px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
}

.projects {
  grid-column: 1 / 2;
  justify-self: end;
  width: 100%;
  max-width: 560px;
}

.eyebrow {
  font-size: 15px;
  font-weight: 400;
  margin: 0 0 24px;
  padding-left: 4px;
  opacity: 0;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project {
  display: inline-flex;
  align-items: baseline;
  gap: 0;
  font-size: clamp(48px, 7vw, 88px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.05;
  padding: 4px 0;
  position: relative;
  opacity: 0;
}

.project .arrow {
  display: inline-block;
  width: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-8px);
  transition:
    width .35s cubic-bezier(.2,.7,.2,1),
    opacity .25s ease,
    transform .35s cubic-bezier(.2,.7,.2,1);
  white-space: nowrap;
}

.project:hover .arrow,
.project:focus-visible .arrow,
.project.is-active .arrow {
  width: 1.05em;
  opacity: 1;
  transform: translateX(0);
}

.previews {
  position: absolute;
  top: 80px;
  right: 0;
  bottom: 32px;
  width: 50%;
  pointer-events: none;
  overflow: visible;
}

.preview {
  position: absolute;
  top: 50%;
  right: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0;
  transform: translate(60px, -50%);
  transition:
    opacity .5s cubic-bezier(.2,.7,.2,1),
    transform .6s cubic-bezier(.2,.7,.2,1);
}

.preview.is-active {
  opacity: 1;
  transform: translate(-80px, -50%);
}

.preview-shot {
  display: block;
  width: clamp(320px, 28vw, 440px);
  height: auto;
  max-height: 100%;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 40px 80px -30px rgba(0,0,0,0.35);
}

/* Jarviz phone chat preview */
.preview--chat {
  pointer-events: auto;
  z-index: 20;
}
.preview--chat.is-active {
  transform: translate(-80px, -50%);
}


.phone {
  position: relative;
  width: 360px;
  height: 660px;
  max-height: calc(100vh - 140px);
  background: #0d0d0d;
  border-radius: 44px;
  padding: 12px;
  box-shadow:
    0 50px 100px -30px rgba(0,0,0,0.45),
    0 0 0 1px rgba(0,0,0,0.06);
  display: flex;
}
.phone-notch {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 84px;
  height: 20px;
  background: #0d0d0d;
  border-radius: 12px;
  z-index: 2;
}
.phone-screen {
  flex: 1;
  background: #fafaf6;
  border-radius: 34px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
  color: #111;
  padding: 44px 14px 12px;
  min-height: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.chat-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 0 3px rgba(46,204,113,0.18);
}
.chat-title {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 14px;
}
.chat-clear {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-family: inherit;
  color: #555;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chat-clear:hover {
  background: #111;
  color: #fafaf6;
  border-color: #111;
}

.chat-intro {
  padding: 10px 4px 6px;
  font-size: 11.5px;
  color: #555;
  line-height: 1.45;
}
.chat-intro p { margin: 0 0 6px; }
.chat-details summary {
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  color: #777;
  padding: 4px 0;
  user-select: none;
}
.chat-details summary::-webkit-details-marker { display: none; }
.chat-details summary::before { content: '▸ '; }
.chat-details[open] summary::before { content: '▾ '; }
.chat-details ul {
  margin: 4px 0 0;
  padding-left: 14px;
  font-size: 11px;
  color: #555;
  line-height: 1.5;
}
.chat-details code {
  font-size: 10.5px;
  background: rgba(0,0,0,0.05);
  padding: 1px 4px;
  border-radius: 4px;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.chat-msg--user {
  align-self: flex-end;
  background: #111;
  color: #fafaf6;
  border-bottom-right-radius: 4px;
}
.chat-msg--assistant {
  align-self: flex-start;
  background: #ececec;
  color: #111;
  border-bottom-left-radius: 4px;
}
.chat-msg--error {
  align-self: flex-start;
  background: #fdecec;
  color: #9b1c1c;
  border-bottom-left-radius: 4px;
}
.chat-msg--pending {
  background: #ececec;
}
.dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  height: 14px;
}
.dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #888;
  animation: chatDot 1.1s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .30s; }
@keyframes chatDot {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.chat-input {
  display: flex;
  gap: 6px;
  padding: 8px 0 4px;
  border-top: 1px solid rgba(0,0,0,0.06);
  margin-top: 6px;
}
.chat-input input {
  flex: 1;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
  color: #111;
  outline: none;
  transition: border-color .15s ease;
  min-width: 0;
}
.chat-input input:focus { border-color: #111; }
.chat-input input:disabled { opacity: .5; }
.chat-input button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #111;
  color: #fafaf6;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, transform .15s ease, opacity .15s ease;
}
.chat-input button:hover:not(:disabled) { background: #000; transform: translateY(-1px); }
.chat-input button:disabled { opacity: .35; cursor: not-allowed; }

.chat-note {
  font-size: 10.5px;
  color: #999;
  margin: 4px 4px 0;
  text-align: center;
  line-height: 1.4;
}

@media (prefers-color-scheme: dark) {
  .phone-screen { background: #141414; color: #f3f3f3; }
  .chat-head { border-bottom-color: rgba(255,255,255,0.08); }
  .chat-clear { color: #aaa; border-color: rgba(255,255,255,0.15); }
  .chat-clear:hover { background: #f3f3f3; color: #141414; border-color: #f3f3f3; }
  .chat-intro, .chat-details summary, .chat-details ul { color: #a8a8a8; }
  .chat-details code { background: rgba(255,255,255,0.08); }
  .chat-msg--user { background: #f3f3f3; color: #141414; }
  .chat-msg--assistant, .chat-msg--pending { background: #1f1f1f; color: #f3f3f3; }
  .chat-msg--error { background: #2a1414; color: #ff8a8a; }
  .chat-input { border-top-color: rgba(255,255,255,0.08); }
  .chat-input input { background: #1a1a1a; color: #f3f3f3; border-color: rgba(255,255,255,0.12); }
  .chat-input input:focus { border-color: #f3f3f3; }
  .chat-input button { background: #f3f3f3; color: #141414; }
  .chat-input button:hover:not(:disabled) { background: #fff; }
  .chat-note { color: #777; }
}

@media (max-width: 900px) {
  .preview--chat { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html, body { transition: none; }
  .topbar-cell, .eyebrow, .project { opacity: 1; }
  .preview { transition: none; }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    padding: 20px 24px;
    font-size: 14px;
  }
  .stage {
    grid-template-columns: 1fr;
    padding: 160px 24px 48px;
  }
  .projects { justify-self: start; }
  .previews { display: none; }
  .project .arrow {
    width: 1.05em;
    opacity: 1;
    transform: translateX(0);
  }
}
