/* Styles for /chat and /facts. Same palette as the main site (style.css). */

:root {
  --bg-page:      #0d1117;
  --bg-raised:    #161b22;
  --border:       #30363d;
  --text-primary: #e6edf3;
  --text-muted:   #8b949e;
  --accent:       #4ecca3;
  --focus:        #4ecca3;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-page);
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  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: 16px; top: -48px; padding: 8px 12px; background: var(--bg-raised); z-index: 10; }
.skip-link:focus { top: 8px; }


/* Header */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 0;
  font-size: 15px;
}
.back-link, .header-action { color: var(--text-muted); text-decoration: none; }
.back-link:hover, .header-action:hover { color: var(--text-primary); }

.page-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 16px 48px;
}

h1 { font-size: 32px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
.lede { margin-top: 12px; color: var(--text-muted); max-width: 60ch; }
.meta { margin-top: 8px; font-size: 14px; color: var(--text-muted); }


/* Chat */

.chat-main { padding-bottom: 220px; } /* room for the dock */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.chips[hidden] { display: none; }
.chip {
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  text-align: left;
}
.chip:hover { border-color: var(--accent); }

.log { list-style: none; margin-top: 32px; display: flex; flex-direction: column; gap: 24px; }
.turn { scroll-margin-bottom: 200px; } /* keep the latest answer clear of the dock when scrolled into view */

.turn-user { align-self: flex-end; max-width: 85%; }
.turn-user .bubble {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.turn-assistant { max-width: 100%; }
.answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-status { color: var(--text-muted); font-style: italic; }
.answer-notice { margin-top: 8px; color: var(--text-muted); }

.cite {
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  padding: 0 3px;
  margin-left: 1px;
  border-radius: 4px;
  background: rgba(78, 204, 163, 0.12);
}
.cite:hover { background: rgba(78, 204, 163, 0.25); }

.sources {
  margin-top: 12px;
  padding: 10px 14px 10px 32px;
  border-left: 2px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
}
.sources li + li { margin-top: 4px; }
.sources a { color: var(--text-primary); }


/* Dock: composer + persistent actions (FR-8) */

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(to bottom, rgba(13, 17, 23, 0), var(--bg-page) 24px);
  padding: 24px 16px calc(12px + env(safe-area-inset-bottom));
}
.composer, .actions { max-width: 720px; margin: 0 auto; }
.notice { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  font: inherit;
  font-size: 16px; /* prevents zoom on iOS */
  color: var(--text-primary);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  resize: none;
  max-height: 160px;
}
.composer textarea:focus-visible { border-color: var(--accent); outline-offset: 0; }
.composer button {
  font: inherit;
  font-weight: 600;
  color: var(--bg-page);
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
  cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: progress; }

.actions { display: flex; gap: 20px; margin-top: 10px; font-size: 14px; }
.actions[hidden], .action[hidden] { display: none; }


/* Facts page */

.facts-toc { margin-top: 28px; padding: 16px 20px; border: 1px solid var(--border); border-radius: 12px; }
.facts-toc ol { padding-left: 20px; columns: 2; column-gap: 32px; font-size: 15px; }
.facts-toc a { color: var(--text-primary); text-decoration: none; }
.facts-toc a:hover { color: var(--accent); }

.facts-section { margin-top: 48px; scroll-margin-top: 16px; }
.facts-section h2 { font-size: 22px; line-height: 1.3; font-weight: 600; }
.facts-section h2 a { color: inherit; text-decoration: none; }
.facts-section h3 { margin-top: 20px; font-size: 15px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.facts-updated { font-size: 13px; color: var(--text-muted); }
.facts-section ul { margin-top: 10px; padding-left: 20px; }
.facts-section li { margin-top: 6px; padding: 2px 6px; margin-left: -6px; border-radius: 6px; scroll-margin-top: 80px; }
.facts-section li:target, .facts-section h2:target { background: rgba(78, 204, 163, 0.14); }

@media (max-width: 560px) {
  h1 { font-size: 26px; }
  .facts-toc ol { columns: 1; }
  .turn-user { max-width: 92%; }
}
