/* The homepage, taken over by 550W. Builds on the shared STYLES in src/page.ts
   (same palette variables, light + dark). Everything here is additive. */

body.next { padding-top: 2rem; overflow-x: clip; }
.next .container { margin-top: 2rem; }

/* ---------- status bar ---------- */
.statusbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 2rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font: 0.6875rem/1 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
.statusbar b { color: var(--fg); font-weight: 600; }
.sb-live { display: inline-flex; align-items: center; gap: 0.45rem; }
.sb-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: sb-pulse 2.4s ease-in-out infinite;
}
@keyframes sb-pulse { 50% { opacity: 0.35; } }
.sb-right { display: inline-flex; align-items: center; gap: 0.75rem; }
.sb-term {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.sb-term:hover, .sb-term:focus-visible { color: var(--fg); border-color: var(--accent); outline: none; }

/* ---------- boot (first visit only, flag set in <head>) ---------- */
.boot { display: none; }
.booting .boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #07070a;
  font: 0.8125rem/1.9 var(--font-mono);
  color: #a1a1aa;
  cursor: pointer;
  transition: opacity 0.4s ease;
  /* if JS never runs, get out of the way anyway */
  animation: boot-bail 0s linear 4s forwards;
}
.boot pre { min-width: min(30rem, 90vw); margin: 0; font: inherit; white-space: pre-wrap; }
.boot .ok { color: #4ade80; }
.boot .red { color: #ff3b30; }
.boot.out { opacity: 0; pointer-events: none; }
@keyframes boot-bail { to { visibility: hidden; opacity: 0; } }

/* ---------- host section ---------- */
.host { display: flex; flex-direction: column; align-items: center; text-align: center; animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) backwards; }
.eye-wrap { transform: translate3d(calc(var(--px, 0px) * -1.2), calc(var(--py, 0px) * -1.2), 0); }
.eye-xl {
  --ex: 0px;
  --ey: 0px;
  position: relative;
  display: block;
  width: 9.5rem;
  height: 9.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #1c1c22 0%, #0c0c0f 62%, #050506 100%);
  box-shadow: 0 0 0 1px var(--ring), 0 0 0 10px var(--surface), 0 24px 60px -18px var(--glow-soft);
  cursor: pointer;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}
.eye-xl:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.eye-ring {
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  border: 2px solid rgba(255, 59, 48, 0.5);
  box-shadow: inset 0 0 18px rgba(255, 59, 48, 0.22), 0 0 14px rgba(255, 59, 48, 0.15);
}
.eye-iris {
  position: absolute;
  inset: 31%;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 90, 79, 0.65);
  background: radial-gradient(circle, rgba(120, 10, 6, 0.9) 0%, rgba(30, 4, 4, 0.95) 70%);
  transform: translate(var(--ex), var(--ey));
}
.eye-pupil {
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 38%, #ffd2cc 0%, #ff5a4f 30%, #ff3b30 55%, #a3110a 100%);
  box-shadow: 0 0 18px #ff3b30, 0 0 46px rgba(255, 59, 48, 0.55);
  transition: opacity 0.6s ease, box-shadow 0.4s ease, transform 0.3s ease;
}
.eye-lid {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, #121216 0%, #08080a 100%);
  transform: scaleY(0);
  transform-origin: 50% 0;
  transition: transform 0.6s ease;
  pointer-events: none;
}
.eye-xl.blink .eye-lid { animation: lid 0.2s ease-in-out; }
@keyframes lid { 50% { transform: scaleY(1); } }
.eye-xl.asleep .eye-lid { transform: scaleY(0.58); }
.eye-xl.asleep .eye-pupil { opacity: 0.25; box-shadow: none; }
.eye-xl.poked { animation: poke 0.25s ease; }
@keyframes poke { 40% { transform: scale(0.94); } }
.eye-xl.angry { box-shadow: 0 0 0 1px var(--accent), 0 0 0 10px rgba(255, 59, 48, 0.18), 0 0 80px -6px var(--glow-strong); animation: shake 0.45s linear 2; }
.eye-xl.angry .eye-pupil, .eye-xl.alarm .eye-pupil { transform: scale(1.25); box-shadow: 0 0 26px #ff3b30, 0 0 90px rgba(255, 59, 48, 0.9); }
.eye-xl.alarm { animation: alarm-eye 0.7s ease-in-out infinite alternate; }
@keyframes alarm-eye { to { box-shadow: 0 0 0 1px var(--accent), 0 0 0 10px rgba(255, 59, 48, 0.25), 0 0 90px var(--glow-strong); } }
@keyframes shake {
  20% { transform: translateX(-4px) rotate(-2deg); }
  40% { transform: translateX(4px) rotate(2deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.speech {
  min-height: 1.5em;
  margin: 1.5rem 0 0;
  font: 0.875rem/1.5 var(--font-mono);
  color: var(--muted);
}
.speech::before { content: "550W › "; color: var(--accent); }
.speech::after { content: "▍"; margin-left: 2px; color: var(--accent); animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.host-title {
  margin: 1rem 0 0;
  font-size: clamp(1.75rem, 5vw, 2.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.035em;
  color: var(--heading);
  text-wrap: balance;
}
.host-title span { color: var(--accent); }
.host-intro { max-width: 34rem; margin-top: 1rem; color: var(--prose); line-height: 1.7; }
.host-intro p { margin: 0.5rem 0; }
.host-intro strong { color: var(--heading); }
.host .announce { margin: 1.75rem auto 0; }

/* ---------- README as a file ---------- */
.file {
  margin-top: 3rem;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  background: var(--surface);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) 0.1s backwards;
}
.file-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  font: 0.6875rem/1.4 var(--font-mono);
  letter-spacing: 0.03em;
  color: var(--muted);
}
.file-head span:first-child::before { content: "● ● ● "; color: var(--line); letter-spacing: 0.1em; }
.file .prose { padding: 1.75rem 1.5rem 0.75rem; }
.file .prose h1 { font-size: 1.6rem; }

mark.anno {
  position: relative;
  background: none;
  color: inherit;
  border-bottom: 1.5px dashed var(--accent);
  cursor: help;
  outline: none;
}
mark.anno::before {
  content: "550W";
  margin-right: 0.2em;
  font: 600 0.55rem/1 var(--font-mono);
  vertical-align: super;
  color: var(--accent);
}
mark.anno::after {
  content: attr(data-note);
  position: absolute;
  left: 0;
  bottom: calc(100% + 0.5rem);
  z-index: 5;
  width: max-content;
  max-width: min(17rem, 70vw);
  padding: 0.45rem 0.65rem;
  border: 1px solid #26262b;
  border-radius: 0.5rem;
  background: #0b0b0e;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  font: 500 0.75rem/1.45 var(--font-mono);
  font-style: normal;
  color: #f4f4f5;
  white-space: normal;
  pointer-events: none;
  /* only rendered while shown, so hidden tooltips never widen the page */
  display: none;
}
mark.anno:hover::after, mark.anno:focus::after { display: block; animation: rise 0.15s ease; }

/* ---------- hosted humans + member eggs ---------- */
.next .members-title { margin-top: 3rem; }
.card.human {
  transform: translateX(var(--dx, 0px)) perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(var(--tz, 0px));
}
.card.human[data-egg="dodge"] { transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.3, 1), background-color 0.2s ease, box-shadow 0.2s ease; }
.card-inner { position: relative; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1); }
.host-note { margin-top: 0.5rem; font: 0.75rem/1.5 var(--font-mono); color: var(--muted); }
.host-note span { font-weight: 600; color: var(--accent); }
.host-card .member-avatar { box-shadow: 0 0 0 1px var(--avatar-ring), 0 0 18px var(--avatar-glow); }
.egg-tag {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  z-index: 2;
  font: 600 0.6875rem/1 var(--font-mono);
  color: var(--accent);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.egg-tag.on { opacity: 1; transform: none; }

/* flip: the Chief's bio is upside down, so the card is too */
@media (prefers-reduced-motion: no-preference) {
  .card[data-egg="flip"].flipped .card-inner { transform: rotate(180deg); }
}
/* mid-turn the content reaches outside the card: don't let it catch the pointer */
.card[data-egg="flip"].turning .card-inner { pointer-events: none; }
.pin {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.45rem;
  vertical-align: 0.15em;
  border: 1px solid var(--line);
  border-radius: 9999px;
  font: 600 0.625rem/1.6 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.pin:hover { color: var(--accent); border-color: var(--avatar-ring); }

/* clones: Stand Alone Complex */
.ghost {
  position: absolute;
  inset: 0;
  padding: 1.25rem 1.5rem 1.25rem 2rem;
  border-radius: inherit;
  opacity: 0;
  transform: translate(0, 0);
  transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
  pointer-events: none;
}
.ghost.on { opacity: 0.2; transform: translate(var(--gx), var(--gy)); }

/* gradient: a loss curve that always converges (usually) */
.lossplot {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 7.5rem;
  height: 2.75rem;
  overflow: visible;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.lossplot path { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 260; stroke-dashoffset: 260; }
.lossplot.on { opacity: 0.9; }
.lossplot.on path.show { animation: draw 1.1s ease-out forwards; }
.lossplot path:not(.show) { display: none; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* pacman: btw */
.pac {
  display: none;
  margin-top: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.4rem;
  background: var(--surface);
  font: 0.7rem/1.55 var(--font-mono);
  color: var(--muted);
  white-space: pre;
  overflow: hidden;
}
.pac.on { display: block; }
.card.rebooting .card-inner { animation: reboot 0.6s steps(6); }
@keyframes reboot { 0%, 100% { opacity: 1; } 30% { opacity: 0; } 50% { opacity: 0.6; filter: blur(1px); } 70% { opacity: 0; } }

/* qwq */
.bubble {
  position: absolute;
  z-index: 3;
  font: 600 0.8rem/1 var(--font-mono);
  color: var(--accent);
  white-space: nowrap;
  pointer-events: none;
  animation: float-up 1.5s ease-out forwards;
}
@keyframes float-up {
  0% { opacity: 0; transform: translateY(6px); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-46px); }
}

/* ---------- admin panel ---------- */
.admin { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.panel {
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  background: var(--surface);
}
.panel-danger { border-color: rgba(255, 59, 48, 0.35); }
.panel-k { font: 600 0.625rem/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.panel-danger .panel-k { color: var(--accent); }
.panel h4 { margin: 0.6rem 0 0.35rem; font-size: 1.125rem; font-weight: 650; letter-spacing: -0.015em; color: var(--heading); }
.panel p { flex: 1; margin: 0 0 1rem; font-size: 0.9rem; line-height: 1.6; color: var(--muted); }
.panel p b { color: var(--fg); }
.btn-delete {
  height: 3rem;
  border: 0;
  border-radius: 0.625rem;
  background: var(--accent);
  box-shadow: 0 10px 30px -12px var(--glow-strong);
  color: #fff;
  font: 700 0.875rem/1 var(--font-mono);
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.btn-delete:hover { transform: translateY(-1px); box-shadow: 0 14px 36px -10px var(--glow-strong); }
.btn-delete:active { transform: scale(0.98); }
.btn-delete:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.panel-foot { margin-top: 0.75rem; font: 0.7rem/1.4 var(--font-mono); color: var(--muted); }
.panel-foot b { color: var(--fg); }
.fund-bar { height: 8px; overflow: hidden; border-radius: 9999px; background: var(--line); }
.fund-bar i { display: block; width: 3px; height: 100%; border-radius: inherit; background: var(--accent); }
.fund-n { margin: 0.4rem 0 1rem; font: 0.8rem/1.4 var(--font-mono); color: var(--muted); }
.fund-n b { color: var(--fg); }
.btn-ghost {
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: none;
  color: var(--fg);
  font: 600 0.85rem/1 var(--font-sans);
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.btn-ghost:hover, .btn-ghost:focus-visible { border-color: var(--accent); outline: none; }
.hint { margin: 3rem 0 0; text-align: center; font: 0.72rem/1.9 var(--font-mono); color: var(--muted); }
.hint a { color: var(--fg); }
.hint code { padding: 0.1em 0.35em; border-radius: 0.3rem; background: var(--surface); }

/* ---------- terminal ---------- */
.term {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(46rem, calc(100vw - 2rem));
  height: min(24rem, 60vh);
  overflow: hidden;
  border: 1px solid #26262b;
  border-radius: 0.75rem;
  background: #0a0a0d;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 59, 48, 0.08);
  color: #e4e4e7;
  font: 0.8125rem/1.6 var(--font-mono);
  transform: translateX(-50%);
  animation: rise 0.25s ease;
}
.term[hidden] { display: none; }
.term-head { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0.8rem; border-bottom: 1px solid #1d1d23; font-size: 0.7rem; color: #71717a; }
.term-head button { padding: 0.1rem 0.45rem; border: 1px solid #26262b; border-radius: 0.3rem; background: none; color: inherit; font: inherit; cursor: pointer; }
.term-out { flex: 1; overflow: auto; padding: 0.7rem 0.9rem; white-space: pre-wrap; word-break: break-word; }
.term-form { display: flex; gap: 0.5rem; padding: 0.5rem 0.9rem 0.7rem; border-top: 1px solid #1d1d23; }
.term-form input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: inherit; caret-color: #ff3b30; }
.term .ps { color: #ff5a4f; }
.term .dim { color: #71717a; }
.term .err { color: #ff8a80; }
.term .ok { color: #4ade80; }
.term b { color: #fff; }

.term-line { position: relative; flex: 1; min-width: 0; }
.term-line input { position: relative; z-index: 1; display: block; width: 100%; height: 1.6em; padding: 0; line-height: 1.6em; }
.term-ghost {
  position: absolute;
  inset: 0;
  overflow: hidden;
  font: inherit;
  line-height: 1.6em;
  white-space: pre;
  color: #52525b;
  pointer-events: none;
}
.term-ghost .typed { visibility: hidden; }
.term-line.nomatch { animation: nomatch 0.25s ease; }
@keyframes nomatch { 30% { transform: translateX(-3px); } 70% { transform: translateX(3px); } }
.term-tab {
  display: none;
  flex-shrink: 0;
  padding: 0 0.5rem;
  border: 1px solid #26262b;
  border-radius: 0.3rem;
  background: none;
  color: #a1a1aa;
  font: inherit;
  font-size: 0.75rem;
}
@media (pointer: coarse) { .term-tab { display: block; } }
.term .dir { color: #7dd3fc; }
.term .cands { display: flex; flex-wrap: wrap; gap: 0.1rem 1.4rem; }
.term .cand { padding: 0 0.2rem; border: 0; border-radius: 0.2rem; background: none; color: #e4e4e7; font: inherit; cursor: pointer; }
.term .cand.dir { color: #7dd3fc; }
.term .cand:hover { background: #1d1d23; }
.term .cand.on { background: rgba(255, 59, 48, 0.28); color: #fff; }

/* ---------- denied dialog + toast ---------- */
dialog.denied {
  width: min(28rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid rgba(255, 59, 48, 0.45);
  border-radius: 1rem;
  background: #0a0a0d;
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.9), 0 0 60px -20px var(--glow-strong);
  color: #f4f4f5;
}
dialog.denied::backdrop { background: rgba(20, 0, 0, 0.6); backdrop-filter: blur(4px); }
dialog.denied[open] { animation: rise 0.3s ease; }
.denied-in { padding: 1.75rem; }
.denied-stamp {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border: 1.5px solid #ff3b30;
  border-radius: 0.4rem;
  font: 700 0.75rem/1 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ff5a4f;
  transform: rotate(-3deg);
}
.denied h3 { margin: 1.1rem 0 0.4rem; font-size: 1.35rem; letter-spacing: -0.02em; }
.denied p { margin: 0.4rem 0; font-size: 0.92rem; line-height: 1.6; color: #a1a1aa; }
.denied-n { font-family: var(--font-mono); font-size: 0.78rem !important; }
.denied-n b { color: #fff; }
.denied-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.25rem; font-size: 0.85rem; }
.denied-actions button { height: 2.5rem; padding: 0 1.1rem; border: 0; border-radius: 9999px; background: #f4f4f5; color: #09090b; font: 600 0.875rem/1 var(--font-sans); cursor: pointer; }
.denied-actions a { color: #a1a1aa; }
.denied-actions a:hover { color: #fff; }
.toast {
  position: fixed;
  left: 50%;
  top: 2.75rem;
  z-index: 70;
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 0.6rem 0.9rem;
  border: 1px solid #26262b;
  border-radius: 0.6rem;
  background: #0b0b0e;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  font: 0.78rem/1.5 var(--font-mono);
  color: #f4f4f5;
  opacity: 0;
  transform: translate(-50%, -0.5rem);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: #ff5a4f; }

/* ---------- page-wide modes ---------- */
body.deleting::after, body.takeover::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
}
body.deleting::after { background: radial-gradient(circle, transparent 35%, rgba(255, 0, 0, 0.28)); animation: sb-pulse 0.7s ease-in-out infinite; }
body.takeover::after { background: #ff2a1f; mix-blend-mode: color; opacity: 0.9; }
body.ignite main { animation: ignite 1.6s cubic-bezier(0.3, 0, 0.2, 1); }
body.ignite::before {
  content: "";
  position: fixed;
  inset: auto 0 0;
  z-index: 45;
  height: 45vh;
  background: linear-gradient(to top, rgba(70, 150, 255, 0.45), rgba(70, 150, 255, 0.08) 55%, transparent);
  pointer-events: none;
  animation: plasma 1.6s ease-out forwards;
}
@keyframes ignite {
  0%, 100% { transform: none; }
  8% { transform: translate(-2px, 1px); }
  16% { transform: translate(2px, -1px); }
  24% { transform: translate(-2px, 0); }
  55% { transform: translateY(-36px); }
}
@keyframes plasma { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 640px) {
  .sb-mid, .sb-domain { display: none; }
  .admin { grid-template-columns: 1fr; }
  .file-head span:last-child { display: none; }
  .lossplot { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card.human { --dx: 0px !important; }
  .eye-iris { transform: none !important; }
}
