/* Aegis demo — styles.
   Matches the Stark Tech Studios look: dark, cyan accent, Orbitron + Inter.
   Layout is a full-height flex column (topbar / main / — main itself flexes
   intro + chat + cta) so the chat is usable without scrolling the page on a
   normal screen; only the message log scrolls internally, as expected for a
   chat panel. Each flex level below needs min-height: 0 alongside flex: 1 —
   without it, a flex child won't shrink and the scroll leaks out to the page. */

:root {
  --bg: #060a12;
  --bg-2: #0b1120;
  --card: #0f1729;
  --accent: #00d4ff;
  --accent-hover: #00b0d8;
  --accent-dim: rgba(0, 212, 255, 0.07);
  --text: #e8edf5;
  --text-2: #8fa3be;
  --border: rgba(0, 212, 255, 0.08);
  --border-hover: rgba(0, 212, 255, 0.28);
  --glow: 0 0 28px rgba(0, 212, 255, 0.18);
  --radius: 14px;
  --radius-lg: 22px;
  --display: 'Orbitron', monospace;
  --body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  line-height: 1.55;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

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

.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;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--bg); padding: 0.6rem 1rem; z-index: 10;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.topbar {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 900px; width: 100%; margin: 0 auto; padding: 0.9rem 1.25rem;
}
.brand {
  font-family: var(--display); font-weight: 800; font-size: 0.9rem;
  letter-spacing: 2px; text-decoration: none; color: var(--accent);
}
.demo-badge {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent); background: var(--accent-dim);
  border: 1px solid var(--border-hover); border-radius: 50px; padding: 0.25rem 0.85rem;
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 900px; width: 100%; margin: 0 auto;
  padding: 0 1.25rem 1rem;
}

.intro { flex-shrink: 0; text-align: center; padding: 0.25rem 0 0.25rem; }
.intro h1 { font-family: var(--display); font-size: clamp(1.5rem, 4.5vw, 2.1rem); margin: 0 0 0.35rem; }
.accent { color: var(--accent); }
.lead { color: var(--text); max-width: 620px; margin: 0 auto 0.35rem; font-size: 1rem; }
.note { color: var(--text-2); max-width: 620px; margin: 0 auto; font-size: 0.78rem; }

.chat-card {
  flex: 1;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  background: var(--card); border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg); box-shadow: var(--glow); padding: 1rem 1rem 0.9rem;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 0.75rem; padding: 0.25rem 0.25rem 0.75rem;
}

.msg { max-width: 85%; padding: 0.7rem 1rem; border-radius: var(--radius); font-size: 0.95rem; }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-assistant { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--border-hover); }
.msg-user { align-self: flex-end; background: var(--accent); color: var(--bg); font-weight: 500; }

.typing { display: flex; gap: 5px; align-items: center; min-height: 2.2rem; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.chips { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 0.75rem; }
.chip {
  background: var(--accent-dim); color: var(--accent); border: 1px solid var(--border-hover);
  border-radius: 50px; padding: 0.4rem 0.9rem; font: inherit; font-size: 0.82rem; cursor: pointer;
}
.chip:hover:not(:disabled) { background: rgba(0, 212, 255, 0.14); }
.chip:disabled { opacity: 0.5; cursor: not-allowed; }

.chat-form { flex-shrink: 0; display: flex; gap: 0.5rem; }
.chat-form input[type="text"] {
  flex: 1; min-width: 0; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-hover); border-radius: 50px; padding: 0.75rem 1.1rem; font: inherit;
}
.chat-form input[type="text"]::placeholder { color: var(--text-2); }
.chat-form input:disabled { opacity: 0.6; }

.btn {
  display: inline-block; border: 0; border-radius: 50px; padding: 0.7rem 1.5rem;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: var(--bg); box-shadow: var(--glow); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  background: var(--bg-2); border: 1px solid var(--border-hover); border-radius: 50%;
  width: 46px; height: 46px; font-size: 1.1rem; cursor: pointer; color: var(--text);
}
.icon-btn[aria-pressed="true"] { border-color: var(--accent); box-shadow: var(--glow); }
.icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.controls { flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; margin-top: 0.6rem; gap: 1rem; }
.toggle { color: var(--text-2); font-size: 0.85rem; cursor: pointer; }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 0.85rem; cursor: pointer; text-decoration: underline; padding: 0.25rem; }

.status { flex-shrink: 0; min-height: 1.2rem; margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text-2); }

.cta {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 50px; padding: 0.6rem 0.6rem 0.6rem 1.25rem;
}
.cta p { color: var(--text-2); margin: 0; font-size: 0.85rem; }

.site-footer {
  flex-shrink: 0;
  text-align: center; padding: 0.85rem 1.25rem; margin-top: 0.25rem;
  border-top: 1px solid var(--border); background: rgba(143, 163, 190, 0.05);
}
.site-footer p { margin: 0.2rem auto; max-width: 720px; font-size: 0.72rem; color: var(--text-2); }

@media (max-width: 600px) {
  .msg { max-width: 92%; }
  .chat-form { flex-wrap: wrap; }
  .chat-form input[type="text"] { flex-basis: 100%; }
  .btn-primary#send-btn { flex: 1; }
  .cta { border-radius: var(--radius-lg); text-align: center; justify-content: center; }
  .cta .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dot { animation: none; opacity: 0.7; }
}
