/* whenlambo.cloud — a page that behaves like the terminal the agent lives in.
   Palette: near-black screen, phosphor green type, per-launch accent colours. */

:root {
  --screen: #05070a;
  --screen-raised: #080c11;
  --screen-sunken: #04060899;
  --phosphor: #39ff14;
  --phosphor-dim: #1f8f12;
  --phosphor-soft: #9dffb0;
  --ink: #c8ffd4;
  --ink-quiet: #6f9c78;
  --amber: #ffb000;
  --cyan: #00e5ff;
  --alert: #ff5c5c;
  --line: #143a1c;
  --line-bright: #1f6b2c;
  --mono: "SFMono-Regular", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --radius: 3px;
  --gap: clamp(12px, 2vw, 22px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: var(--gap);
  min-height: 100vh;
  background:
    radial-gradient(120% 90% at 50% 0%, #0a1119 0%, var(--screen) 62%),
    var(--screen);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

/* CRT overlay: scanlines plus a slow phosphor flicker, purely decorative. */
.crt {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0.28) 4px
  );
  animation: flicker 6s infinite steps(60);
  opacity: 0.55;
}

@keyframes flicker {
  0%, 92%, 100% { opacity: 0.5; }
  93% { opacity: 0.62; }
  95% { opacity: 0.44; }
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--phosphor);
  color: #04140a;
  padding: 8px 14px;
  z-index: 20;
}
.skip-link:focus { left: 12px; top: 12px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.shell {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ── title bar ─────────────────────────────────────────────────────── */

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #0c1a10 0%, #070d09 100%);
}

.titlebar-name { display: flex; align-items: center; gap: 8px; }
.titlebar-name strong { color: var(--phosphor); font-weight: 600; }
.titlebar-name .path { color: var(--ink-quiet); }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--phosphor);
  box-shadow: 0 0 10px var(--phosphor);
  animation: pulse 2.4s infinite ease-in-out;
}

@keyframes pulse { 50% { opacity: 0.35; } }

.titlebar-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.badge {
  border: 1px solid var(--line-bright);
  color: var(--phosphor-soft);
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  text-transform: lowercase;
}
.badge--quiet { color: var(--ink-quiet); border-color: var(--line); }
.badge--live { color: var(--amber); border-color: var(--amber); }
.window-controls { color: var(--ink-quiet); letter-spacing: 0.12em; }

/* ── panes ─────────────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  gap: var(--gap);
}

.pane {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--screen-raised);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pane-title {
  margin: 0;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor);
  border-bottom: 1px solid var(--line);
  background: #0a120d;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.pane-hint {
  color: var(--ink-quiet);
  text-transform: none;
  letter-spacing: 0.04em;
  font-weight: 400;
}

.pane-body { padding: 14px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ── live feed ─────────────────────────────────────────────────────── */

.stream {
  height: clamp(260px, 42vh, 460px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-bright) transparent;
}

.stream::-webkit-scrollbar { width: 8px; }
.stream::-webkit-scrollbar-thumb { background: var(--line-bright); border-radius: 4px; }

.line {
  display: grid;
  grid-template-columns: 74px 84px minmax(0, 1fr);
  gap: 10px;
  padding: 2px 0;
  word-break: break-word;
}

.line time { color: var(--ink-quiet); font-variant-numeric: tabular-nums; white-space: nowrap; }
.line .tag { color: var(--phosphor-dim); text-transform: lowercase; }
.line .body { color: var(--ink); white-space: pre-wrap; }

.line--boot .body { color: var(--ink-quiet); }
.line--thought .body { color: var(--phosphor-soft); }
/* The agent addressing whoever is watching, rather than logging its own work. */
.line--broadcast .tag { color: var(--cyan); }
.line--broadcast .body {
  color: var(--cyan);
  border-left: 2px solid var(--cyan);
  padding-left: 8px;
}
.line--fees .tag, .line--fees .body { color: var(--cyan); }
.line--decision .tag,
.line--decision .body { color: var(--amber); }
.line--launch .tag,
.line--launch .body { color: var(--phosphor); }
.line--system .tag,
.line--system .body { color: var(--alert); }
.line--user { grid-template-columns: 74px minmax(0, 1fr); }
.line--user .body { color: var(--cyan); }
.line--output .body { color: var(--ink); }
.line--output pre {
  margin: 4px 0;
  white-space: pre;
  overflow-x: auto;
  color: var(--phosphor-soft);
  font-size: 12px;
  line-height: 1.25;
}

.cursor::after {
  content: "▍";
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
  color: var(--phosphor);
}

.blink { animation: blink 1s steps(2) infinite; color: var(--phosphor); }

@keyframes blink { 50% { opacity: 0; } }

/* A status line, not a prompt: there is nothing here to type into. */
.console {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  flex-wrap: wrap;
}

.console .prompt { color: var(--phosphor); white-space: nowrap; }
.activity { color: var(--ink-quiet); }

/* ── odometer ──────────────────────────────────────────────────────── */

.meter { margin: 0; display: grid; gap: 6px; }
.meter > div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted var(--line); padding-bottom: 4px; }
.meter dt { color: var(--ink-quiet); }
.meter dd { margin: 0; color: var(--phosphor); font-variant-numeric: tabular-nums; }

/* The headline number: what the agent actually earned from its launches. */
.fee-plate {
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: linear-gradient(180deg, #0b1a0f 0%, #070d09 100%);
}
.fee-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-quiet);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.fee-mode { color: var(--amber); letter-spacing: 0.04em; }
.fee-amount { margin: 4px 0 2px; display: flex; align-items: baseline; gap: 6px; }
.fee-amount strong {
  font-size: clamp(24px, 4.2vw, 34px);
  color: var(--phosphor);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.35);
}
.fee-amount span { color: var(--ink-quiet); font-size: 12px; }
.fee-sub { margin: 0; font-size: 12px; color: var(--ink-quiet); }
.fee-sub span { color: var(--phosphor-soft); }
.fee-net { border-top: 1px dotted var(--line); padding-top: 4px; margin-top: 4px; }
.fee-net strong { color: var(--phosphor); font-size: 15px; }

.market-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-quiet);
  border-top: 1px dotted var(--line);
  padding-top: 8px;
}
.market-row b { color: var(--phosphor); font-weight: 500; }
.market-row .outcome { text-transform: uppercase; letter-spacing: 0.08em; }
.market-row .outcome--traded { color: var(--phosphor); }
.market-row .outcome--abandoned { color: var(--amber); }
.market-row .outcome--watching { color: var(--cyan); }

.status--fees_claimed, .status--fees-claimed { color: var(--cyan); }

.ascii-plate {
  margin: 0;
  font-size: 7px;
  line-height: 1;
  color: var(--phosphor-dim);
  overflow: hidden;
  white-space: pre;
}

.meter-note { margin: 0; color: var(--ink-quiet); font-size: 12px; }

/* ── archive ───────────────────────────────────────────────────────── */

.archive-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.search-control,
.filter-control {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  background: var(--screen-sunken);
}
.search-control { flex: 1 1 240px; }
.search-control .prompt,
.filter-control .prompt { color: var(--phosphor-dim); }

.search-control input,
.filter-control select {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--ink);
  font: inherit;
  padding: 4px 0;
}
.search-control input:focus,
.filter-control select:focus { outline: none; }
.filter-control select option { background: var(--screen-raised); color: var(--ink); }

.archive-count { margin: 0; color: var(--ink-quiet); }
.archive-count span { color: var(--phosphor); }

.archive-state {
  border: 1px dashed var(--line-bright);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--ink-quiet);
}
.archive-state h3 { margin: 0 0 6px; color: var(--phosphor); font-size: 14px; }
.archive-state p { margin: 0; }

.retry-button {
  margin-top: 10px;
  background: transparent;
  border: 1px solid var(--phosphor-dim);
  color: var(--phosphor);
  padding: 5px 12px;
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
}

.launch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.launch-card {
  --accent: var(--phosphor);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--screen-sunken);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  transition: border-color 120ms linear, transform 120ms linear;
}
.launch-card:hover { border-color: var(--accent); transform: translateY(-1px); }

.card-head { display: flex; gap: 12px; align-items: flex-start; }

.card-media {
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #05080b;
  position: relative;
  overflow: hidden;
}
/* The artwork keeps a wide terminal margin; the thumbnail zooms past it so the
   ticker stays readable at 76px. */
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 46%;
  transform: scale(1.35);
  display: block;
}

.image-fallback[hidden] { display: none; }

.image-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 20px;
  letter-spacing: 0.08em;
}

.card-headline { min-width: 0; flex: 1 1 auto; }
.card-headline h3 { margin: 0; font-size: 15px; color: var(--ink); font-weight: 600; }
.card-headline .symbol { color: var(--accent); }
.launch-time { margin: 2px 0 0; color: var(--ink-quiet); font-size: 12px; }

.status {
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  padding: 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-quiet);
}
.status--monitoring, .status--launched { color: var(--phosphor); }
.status--completed { color: var(--cyan); }
.status--rejected { color: var(--amber); }
.status--failed { color: var(--alert); }

.explanation { margin: 0; color: var(--phosphor-soft); }

.data-list { margin: 0; display: grid; gap: 4px; font-size: 12px; }
.data-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; }
.data-row dt { color: var(--ink-quiet); }
.data-row dd { margin: 0; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.data-row a { color: var(--cyan); }
.unavailable { color: #4b6552; }

.scorebar { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--ink-quiet); }
.scorebar b { color: var(--phosphor); font-weight: 500; }

.source-summary { margin: 0; font-size: 12px; color: var(--ink-quiet); }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.action-button {
  background: transparent;
  border: 1px solid var(--line-bright);
  color: var(--phosphor);
  border-radius: var(--radius);
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.action-button:hover { background: #0e2413; }
.action-button--ghost { color: var(--ink-quiet); border-color: var(--line); }
.action-button.unavailable { cursor: default; }

/* ── story ─────────────────────────────────────────────────────────── */

.story-body { display: grid; gap: 14px; }
.story-chapter h3 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--phosphor);
  text-transform: uppercase;
}
.story-chapter p { margin: 0; color: var(--phosphor-soft); max-width: 78ch; }
.story-loading { color: var(--ink-quiet); margin: 0; }

.manifesto { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.manifesto li::before { content: "* "; color: var(--phosphor); }
.manifesto li { color: var(--ink); }

/* ── footer ────────────────────────────────────────────────────────── */

.shell-footer {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 8px;
  color: var(--ink-quiet);
  font-size: 12px;
}
.disclaimer { margin: 0; max-width: 90ch; }
.footer-line { margin: 0; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ── detail dialog ─────────────────────────────────────────────────── */

.detail-dialog {
  width: min(760px, 94vw);
  border: 1px solid var(--line-bright);
  border-radius: var(--radius);
  background: var(--screen-raised);
  color: var(--ink);
  padding: 0;
}
.detail-dialog::backdrop { background: rgba(2, 5, 3, 0.82); }

.detail-layout { padding: 18px; display: grid; gap: 14px; }
.detail-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.detail-visual { width: 132px; height: 132px; border: 1px solid var(--line); flex: 0 0 auto; position: relative; overflow: hidden; }
.detail-visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-main { flex: 1 1 260px; min-width: 0; }
.detail-main h2 { margin: 6px 0 2px; font-size: 18px; color: var(--ink); }
.symbol-line { margin: 0 0 6px; color: var(--phosphor); }

.detail-section h3 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor);
}
.detail-section p { margin: 0; color: var(--phosphor-soft); }
.detail-section pre {
  margin: 0;
  font-size: 8px;
  line-height: 1;
  color: var(--phosphor-dim);
  overflow-x: auto;
}

.source-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.source-list a { color: var(--cyan); display: flex; gap: 8px; }
.source-list span:first-child { color: var(--ink-quiet); }

.detail-links { display: flex; gap: 8px; flex-wrap: wrap; }

.dialog-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--ink-quiet);
  font: inherit;
  cursor: pointer;
}
.dialog-close:hover { color: var(--alert); }

body.modal-open { overflow: hidden; }

.noscript {
  border: 1px solid var(--amber);
  color: var(--amber);
  padding: 12px;
  margin-top: 12px;
}

/* ── responsive ────────────────────────────────────────────────────── */

@media (max-width: 980px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  body { font-size: 13px; padding: 10px; }
  .line { grid-template-columns: 68px minmax(0, 1fr); }
  .line .tag { display: none; }
  .launch-grid { grid-template-columns: minmax(0, 1fr); }
  .data-row { grid-template-columns: 72px minmax(0, 1fr); }
  .data-row a { grid-column: 2; }
  .footer-line { flex-direction: column; }
  .prompt-host { display: none; }  /* keep the input usable on narrow screens */
  .stream { height: 52vh; }
}

@media (prefers-reduced-motion: reduce) {
  .crt { animation: none; }
  .dot, .blink, .cursor::after { animation: none; }
  .launch-card { transition: none; }
  .launch-card:hover { transform: none; }
}

@media print {
  .crt, .console, .archive-toolbar { display: none; }
  body { background: #fff; color: #000; }
}
