/* tsai/web/style.css */
:root {
  --ink: #f7f5f2;
  --ink-dim: #c9c4bd;
  --panel: rgba(18, 18, 20, 0.9);
  --edge: rgba(255, 255, 255, 0.14);
  --accent: #e9c46a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #101013;
}

.backdrop {
  position: fixed;
  inset: 0;
  /* Moderate tint: enough for the copy to read over busy artwork, light
     enough that a dark image is not flattened to black. Chat bubbles carry
     their own opaque backgrounds. */
  background-image: linear-gradient(rgba(8, 8, 10, 0.4), rgba(8, 8, 10, 0.6)),
                    url("/bg.jpg");
  background-size: cover;
  background-position: center;
  /* z-index 0 (not -1): a negative value drops the layer beneath the
     body's own opaque background, which then paints over the image. */
  z-index: 0;
}

.shell {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(1rem, 6vh, 5rem) 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 100vh;
  justify-content: center;
  transition: justify-content 0.3s ease;
  position: relative;
  z-index: 1;
}

.shell.answering { justify-content: flex-start; }

.title {
  font-size: clamp(1.9rem, 5vw, 3rem);
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
}

.subtitle { margin: 0; color: var(--ink-dim); }
.subtitle a { color: var(--accent); }

.intro { transition: opacity 0.3s ease; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9); }
.intro.compact { opacity: 0.55; }

.intro-logo {
  display: block;
  max-height: 3.5rem;
  max-width: 60%;
  margin-bottom: 1rem;
  padding: 0.5rem 0.8rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 10px;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.msg { display: flex; gap: 0.7rem; }

.msg.user { justify-content: flex-end; }

.bubble {
  margin: 0;
  max-width: 85%;
  padding: 0.75rem 1.05rem;
  /* Opaque enough that a busy background image never competes with the
     answer text; the user bubble keeps a warm tint over the same base. */
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.user .bubble { background: rgba(70, 58, 30, 0.92); }

.avatar {
  flex: 0 0 auto;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #17161a;
  /* Light chip so a dark or transparent site logo stays visible. */
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--edge);
  border-radius: 50%;
  overflow: hidden;
}

.avatar img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
}

.msg-body {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1.1rem 1.3rem;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

.answer { line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }

.citation {
  display: inline-block;
  min-width: 1.4em;
  margin: 0 0.15em;
  padding: 0 0.35em;
  font-size: 0.78em;
  text-align: center;
  color: var(--accent);
  border: 1px solid var(--edge);
  border-radius: 999px;
  text-decoration: none;
}

.sources {
  margin: 1.1rem 0 0;
  padding-left: 1.2rem;
  font-size: 0.86rem;
  color: var(--ink-dim);
}

.sources a { color: var(--ink-dim); }

.ask { display: flex; gap: 0.6rem; }

.ask-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.95rem 1.1rem;
  font-size: 1rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
}

.ask-input::placeholder { color: var(--ink-dim); }

.ask-button, .reset {
  padding: 0.95rem 1.3rem;
  font-size: 1rem;
  font-weight: 600;
  color: #17161a;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.reset { background: transparent; color: var(--ink-dim); border: 1px solid var(--edge); }

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

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

@media (max-width: 30rem) {
  .ask { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
