:root {
  --bg: #0a1420;
  --bg-raise: #13233a;
  --bg-raise-2: #171c19;
  --text: #e7efe9;
  --text-dim: #eeefee;
  --text-mute: #dde0de;
  --phosphor: #07f86b;
  --phosphor-dim: #13b65c;
  --amber: #ffb454;
  --hairline: #346367;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  background-image:
    radial-gradient(ellipse 1900px 1500px at 15% 10%, rgba(124,255,178,0.35), transparent 30%);

  background-attachment: fixed;
}

a { color: inherit; }

::selection { background: var(--phosphor-dim); color: #fff; }

:focus-visible {
  outline: 2px solid var(--phosphor);
  outline-offset: 3px;
}

.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 24px;
  max-width: 920px;
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
}

header.site .mark {
  color: var(--text);
  letter-spacing: 0.02em;
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
}

header.site nav a {
  color: var(--text-dim);
  text-decoration: none;
  margin-left: 22px;
  transition: color 0.15s ease;
}
header.site nav a:hover { color: var(--phosphor); }

/* ---------- Hero ---------- */

.hero {
  padding: 64px 0 8px;
}

.prompt-line {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--phosphor-dim);
  margin: 0 0 18px;
}
.prompt-line .cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: var(--phosphor);
  margin-left: 2px;
  vertical-align: -2px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

h1.wordmark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(38px, 7vw, 66px);
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  color: var(--text);
}
h1.wordmark .dot { color: var(--phosphor); }

.tagline {
  font-size: clamp(17px, 2.4vw, 20px);
  color: var(--text-dim);
  max-width: 46ch;
  margin: 0 0 40px;
  font-weight: 400;
}

.bio-intro {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 0 0 40px;
}
.bio-intro .tagline { margin: 0; }

.bio-photo {
  width: 96px;
  max-width: 96px;
  height: 96px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .prompt-line .cursor { animation: none; }
}

/* ---------- Section labels ---------- */

.section-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

/* ---------- Flagship ---------- */

.flagship {
  background: var(--bg-raise);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 32px;
  margin-bottom: 64px;
  position: relative;
  overflow: hidden;
}
.flagship::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--phosphor), transparent 70%);
}

.flagship-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.status-badge {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 4px;
  text-transform: uppercase;
}
.status-live {
  color: #0b0e0c;
  background: var(--amber);
}
.status-active { color: var(--phosphor); border: 1px solid var(--phosphor-dim); }
.status-experimental { color: var(--text-dim); border: 1px solid var(--hairline); }
.status-archived { color: var(--text-mute); border: 1px solid var(--hairline); }

.flagship-body {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.flagship-photo {
  width: 140px;
  max-width: 140px;
  height: 140px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}

.flagship h3 {
  font-family: var(--mono);
  font-size: 24px;
  margin: 0 0 10px;
  font-weight: 600;
}

.flagship p.desc {
  color: var(--text-dim);
  max-width: 62ch;
  margin: 0 0 22px;
}

.flagship .links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 13px;
}
.flagship .links a {
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--phosphor-dim);
  padding-bottom: 2px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.flagship .links a:hover { color: var(--phosphor); border-color: var(--phosphor); }

/* ---------- Project list ---------- */

.projects { margin-bottom: 72px; }

.project-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 20px;
  align-items: start;
  padding: 20px 0;
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: inherit;
}
.section-label + .project-row { border-top: 1px solid var(--hairline); }

.project-row .name-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.project-row .desc {
  grid-column: 1 / 2;
  color: var(--text-dim);
  font-size: 14.5px;
  max-width: 58ch;
}

.project-row .badge-col {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: start;
  justify-self: end;
}

.project-row .arrow {
  font-family: var(--mono);
  color: var(--text-mute);
  transition: transform 0.15s ease, color 0.15s ease;
  display: inline-block;
}
.project-row:hover .arrow { transform: translateX(3px); color: var(--phosphor); }
.project-row:hover .name-line { color: var(--phosphor); }

/* ---------- Footer ---------- */

footer {
  padding: 40px 0 64px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-mute);
  border-top: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.footer-main { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
footer a { color: var(--text-dim); text-decoration: none; }
footer a:hover { color: var(--phosphor); }
.footer-privacy { margin: 0; font-size: 11px; color: var(--text-mute); opacity: 0.55; }

/* ---------- Lucy chat ---------- */

.lucy-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  font-family: var(--sans);
}

.lucy-chat__toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 17px;
  border: 1px solid var(--phosphor-dim);
  border-radius: 8px;
  background: var(--bg-raise);
  color: var(--text);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  font: 600 13px var(--mono);
}

.lucy-chat__toggle:hover { color: var(--phosphor); border-color: var(--phosphor); }
.lucy-chat__toggle-dot { color: var(--phosphor); font-size: 18px; line-height: 1; }

.lucy-chat__panel {
  position: absolute;
  right: 0;
  bottom: 58px;
  display: flex;
  width: min(360px, calc(100vw - 32px));
  height: min(480px, calc(100vh - 112px));
  height: min(480px, calc(100dvh - 112px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  background: var(--bg-raise);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.lucy-chat__panel[hidden] { display: none; }

.lucy-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
  font: 600 14px var(--mono);
}

.lucy-chat__status { color: var(--phosphor); }
.lucy-chat__close { border: 0; background: transparent; color: var(--text-dim); cursor: pointer; font-size: 22px; line-height: 1; }
.lucy-chat__close:hover { color: var(--phosphor); }

.lucy-chat__transmission {
  position: relative;
  height: 150px;
  flex: 0 0 150px;
  overflow: hidden;
  border-bottom: 1px solid var(--hairline);
  background: #071019;
  animation: lucy-transmission-pulse 4.4s ease-in-out infinite;
}

.lucy-chat__portrait {
  position: absolute;
  inset: 0;
  background-image: url('../images/lucy-transmission-frames.png');
  background-repeat: no-repeat;
  background-position: 0% 5%;
  background-size: 600% auto;
  filter: saturate(0.72) contrast(1.08) brightness(0.86);
  animation: lucy-camera-drift 8s ease-in-out infinite alternate;
  opacity: 0;
  transition-property: opacity;
}
.lucy-chat__portrait--visible { opacity: 1; }

.lucy-chat__transmission::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(4, 20, 27, 0.12) 0, rgba(4, 20, 27, 0.12) 1px, transparent 1px, transparent 3px),
    linear-gradient(90deg, rgba(7, 248, 107, 0.08), transparent 40%, rgba(0, 117, 255, 0.06));
  mix-blend-mode: screen;
  animation:
    lucy-signal-flicker 2.7s steps(1) infinite,
    lucy-analogue-roll 1.8s linear infinite;
}

.lucy-chat__transmission::after {
  content: '';
  position: absolute;
  z-index: 2;
  top: -35%;
  right: 0;
  left: 0;
  height: 25%;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(7, 248, 107, 0.11), transparent);
  animation: lucy-scan 5s linear infinite;
}

.lucy-chat__transmission--glitching .lucy-chat__portrait {
  animation: lucy-signal-glitch 110ms steps(2) infinite;
}

.lucy-chat__transmission--glitching::before {
  background:
    repeating-linear-gradient(0deg, rgba(7, 248, 107, 0.24) 0 2px, transparent 2px 7px),
    linear-gradient(90deg, rgba(0, 170, 255, 0.2), transparent 38%, rgba(7, 248, 107, 0.18));
}

.lucy-chat__signal {
  position: absolute;
  z-index: 3;
  bottom: 8px;
  left: 10px;
  padding: 2px 5px;
  background: rgba(4, 13, 20, 0.72);
  color: var(--phosphor);
  font: 500 9px var(--mono);
  letter-spacing: 0.08em;
}

@keyframes lucy-scan {
  to { transform: translateY(700%); }
}

@keyframes lucy-camera-drift {
  0% { transform: scale(1.015) translate3d(-1px, 0, 0); }
  22% { transform: scale(1.025) translate3d(1px, -1px, 0); }
  47% { transform: scale(1.035) translate3d(2px, -2px, 0); }
  73% { transform: scale(1.028) translate3d(0, 1px, 0); }
  100% { transform: scale(1.02) translate3d(-2px, 1px, 0); }
}

@keyframes lucy-transmission-pulse {
  0%, 100% { filter: brightness(0.97); }
  38% { filter: brightness(1.025); }
  62% { filter: brightness(0.985); }
}

@keyframes lucy-analogue-roll {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 9px, 3px 0; }
}

@keyframes lucy-signal-flicker {
  0%, 17%, 19%, 54%, 57%, 91%, 100% { opacity: 0.72; }
  18%, 55% { opacity: 0.28; }
  56%, 92% { opacity: 0.95; }
}

@keyframes lucy-signal-glitch {
  0% { opacity: 0.32; transform: translateX(-7px) scaleX(1.045); filter: contrast(1.7) hue-rotate(18deg); }
  40% { opacity: 0.78; transform: translateX(5px) scaleX(0.97); filter: brightness(1.25) saturate(1.4); }
  100% { opacity: 0.48; transform: translateX(-2px) scaleX(1.02); filter: contrast(1.4) hue-rotate(-12deg); }
}

.lucy-chat__messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
}

.lucy-chat__message {
  max-width: 88%;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 14px;
  white-space: pre-wrap;
}

.lucy-chat__message--user { align-self: flex-end; border-color: var(--phosphor-dim); color: var(--text); }
.lucy-chat__message--loading { color: var(--text-mute); font-family: var(--mono); }
.lucy-chat__message--error { color: var(--amber); }

.lucy-chat__form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--hairline); }
.lucy-chat__input {
  min-width: 0;
  flex: 1;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  padding: 9px 10px;
  font: 14px var(--sans);
}
.lucy-chat__input::placeholder { color: var(--text-mute); }
.lucy-chat__send {
  border: 1px solid var(--phosphor-dim);
  border-radius: 6px;
  background: transparent;
  color: var(--phosphor);
  cursor: pointer;
  padding: 0 12px;
  font: 600 12px var(--mono);
}
.lucy-chat__send:hover:not(:disabled) { border-color: var(--phosphor); }
.lucy-chat__send:disabled, .lucy-chat__input:disabled { cursor: wait; opacity: 0.55; }

@media (max-width: 560px) {
  header.site { flex-direction: column; align-items: flex-start; gap: 10px; }
  header.site nav a { margin-left: 0; margin-right: 18px; }
  .project-row { grid-template-columns: 1fr; }
  .project-row .badge-col { grid-row: auto; justify-self: start; margin-top: 4px; }
  .bio-intro { flex-direction: column; align-items: flex-start; }
  .flagship-body { flex-direction: column; }
  .lucy-chat { right: 16px; bottom: 16px; }
  .lucy-chat__transmission { height: 120px; flex-basis: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .lucy-chat__transmission,
  .lucy-chat__portrait,
  .lucy-chat__transmission::after,
  .lucy-chat__transmission::before,
  .lucy-chat__transmission--glitching .lucy-chat__portrait {
    animation: none;
  }
}
