/*
 * The terminal.
 *
 * Green phosphor on near-black, but not a costume: the type is a real
 * monospace stack at a readable size, contrast stays above 4.5:1, and the
 * scanlines are faint enough to read through. A CRT pastiche you cannot read
 * is a screenshot, not an interface.
 */

:root {
  --void: #05070a;
  --panel: #090d12;
  --edge: #16301f;
  --edge-hot: #2f7d4f;
  --green: #5dfca0;
  --green-dim: #3aa06a;
  --green-deep: #1d6440;
  --amber: #ffcf6b;
  --red: #ff5f56;
  --text: #cfe9d9;
  --muted: #6d8a7b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --gap: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(120% 80% at 50% -10%, #0c1a13 0%, transparent 60%),
    var(--void);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Faint, and switched off for anyone who asked for less motion or more
   contrast - it is decoration, and decoration is the first thing to go. */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(93, 252, 160, 0.035) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: screen;
}
@media (prefers-reduced-motion: reduce), (prefers-contrast: more) {
  .scanlines { display: none; }
}

/* --- header --------------------------------------------------------------- */

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--edge);
  background: linear-gradient(to bottom, #0a1410, transparent);
  flex: 0 0 auto;
}

.mark {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.32em;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 14px rgba(93, 252, 160, 0.45);
}

.tick { animation: blink 1.1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tick { animation: none; } }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-deep);
  box-shadow: 0 0 10px currentColor;
  color: var(--green-deep);
}
.dot[data-state="listening"] { background: var(--green); color: var(--green); animation: pulse 1.1s ease-in-out infinite; }
.dot[data-state="thinking"]  { background: var(--amber); color: var(--amber); animation: pulse 0.7s ease-in-out infinite; }
.dot[data-state="speaking"]  { background: #6bd2ff; color: #6bd2ff; }
.dot[data-state="error"]     { background: var(--red);  color: var(--red); }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none !important; } }

.caps {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cap {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 7px;
  border: 1px solid var(--edge);
  border-radius: 3px;
  color: var(--muted);
}
.cap[data-live="true"] { color: var(--green); border-color: var(--edge-hot); }

/* --- layout --------------------------------------------------------------- */

.grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: var(--gap);
  padding: var(--gap);
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "console video"
    "console news";
}

.console { grid-area: console; }
.video   { grid-area: video; }
.news    { grid-area: news; }

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  overflow: hidden;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--edge);
  color: var(--green-dim);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.muted { color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 11px; }

.ghostBtn {
  background: none;
  border: 1px solid var(--edge);
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
}
.ghostBtn:hover, .ghostBtn:focus-visible { color: var(--green); border-color: var(--edge-hot); }

/* --- console -------------------------------------------------------------- */

.log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--edge-hot) transparent;
}

.line { margin: 0 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.line .who { color: var(--green-dim); }
.line.user .who { color: var(--muted); }
.line.doom { color: var(--green); }
.line.sys  { color: var(--muted); font-size: 12px; }
.line.err  { color: var(--red); }

.entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--edge);
  flex: 0 0 auto;
}
.prompt { color: var(--green); }
.entry input {
  flex: 1 1 auto;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  outline: none;
}
.entry input::placeholder { color: var(--muted); }

/* --- video ---------------------------------------------------------------- */

.screen {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #04060a;
  display: grid;
  place-items: center;
}
.screen iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.placeholder { color: var(--muted); font-size: 12px; padding: 12px; text-align: center; }
.placeholder b { color: var(--green-dim); }

.reel {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 6px;
  overflow-x: auto;
  border-top: 1px solid var(--edge);
  scrollbar-width: thin;
}
.thumb {
  flex: 0 0 auto;
  width: 104px;
  background: none;
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  font: inherit;
}
.thumb:hover, .thumb:focus-visible { border-color: var(--edge-hot); }
.thumb img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }
.thumb span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.35;
  padding: 4px 5px;
  color: var(--muted);
}

/* --- news ----------------------------------------------------------------- */

.feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--edge-hot) transparent;
}

.story {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 9px;
  padding: 8px 10px;
  border-bottom: 1px solid #0f1d15;
  text-decoration: none;
  color: inherit;
}
.story:hover, .story:focus-visible { background: #0c1712; outline: none; }
.story img { width: 56px; height: 42px; object-fit: cover; border-radius: 2px; background: #0d1a13; }
.story h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.story .src { font-size: 10px; color: var(--green-deep); letter-spacing: 0.08em; text-transform: uppercase; }

.empty { padding: 14px; color: var(--muted); font-size: 12px; }

/* --- dock ----------------------------------------------------------------- */

.dock {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  border-top: 1px solid var(--edge);
  background: linear-gradient(to top, #0a1410, transparent);
}

.mic {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 1px solid var(--edge-hot);
  color: var(--green);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.18em;
  padding: 7px 14px;
  border-radius: 3px;
  cursor: pointer;
}
.mic[aria-pressed="true"] { background: #0e2418; box-shadow: 0 0 18px -4px var(--green-deep) inset; }
.micRing {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-deep);
}
.mic[aria-pressed="true"] .micRing { background: var(--green); animation: pulse 1.1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .mic[aria-pressed="true"] .micRing { animation: none; } }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.toggle input { accent-color: var(--green-deep); }

.interim {
  margin-left: auto;
  color: var(--green-dim);
  font-size: 12px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45%;
}

/* --- phone ---------------------------------------------------------------- */

@media (max-width: 860px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(180px, 1fr) minmax(0, 1fr);
    grid-template-areas: "video" "console" "news";
    overflow-y: auto;
  }
  .video { min-height: 190px; }
  .interim { display: none; }
  .dock { flex-wrap: wrap; gap: 10px; }
}
