/* Dopsie — "operator's notebook"
   Calm, precise, provenance-forward. The signature is the source readout under
   every answer and the deliberately un-embarrassed "outside the sources" state.
   Type: Instrument Serif (display) / IBM Plex Sans (UI) / IBM Plex Mono (data). */

:root {
  --paper: #eef1f0;
  --surface: #ffffff;
  --ink: #16241f;
  --muted: #5b6b64;
  --line: #d6ddda;
  --signal: #0f766e;
  --signal-soft: #e2efec;
  --flag: #b45309;
  --flag-soft: #f6ecdf;

  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Instrument Serif", Georgia, serif;

  --maxw: 46rem;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  /* faint ruled-notebook texture, very low contrast */
  background-image: linear-gradient(
    var(--line) 1px,
    transparent 1px
  );
  background-size: 100% 2.4rem;
  background-position: 0 -1px;
}

.frame {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) 1.25rem 4rem;
}

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

/* ---- Masthead ----------------------------------------------------------- */
.masthead {
  border-bottom: 1px solid var(--line);
  padding-bottom: 1.25rem;
  margin-bottom: 2rem;
}

.wordmark {
  font-family: var(--serif);
  font-size: clamp(3.2rem, 11vw, 5rem);
  line-height: 0.9;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.wordmark::after {
  /* a single signal mark — the "operating" dot */
  content: ".";
  color: var(--signal);
}

.tagline {
  margin: 0.5rem 0 0;
  max-width: 32rem;
  color: var(--muted);
  font-size: 0.98rem;
}

/* ---- Ask ---------------------------------------------------------------- */
.thesis {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
  line-height: 1.18;
  margin: 0 0 1.25rem;
  color: var(--ink);
}

#ask-form {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

#q {
  flex: 1;
  resize: vertical;
  min-height: 3.4rem;
  padding: 0.85rem 1rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#q::placeholder {
  color: #9aa8a2;
}

#q:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

#ask-btn {
  flex: 0 0 auto;
  align-self: stretch;
  padding: 0 1.6rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--surface);
  background: var(--signal);
  border: 1px solid var(--signal);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.06s ease;
}

#ask-btn:hover {
  background: #0c5f59;
}

#ask-btn:active {
  transform: translateY(1px);
}

#ask-btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

#ask-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---- Suggestions -------------------------------------------------------- */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.suggestions__label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.chip {
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  border-color: var(--signal);
  background: var(--signal-soft);
}

.chip--edge {
  border-style: dashed;
}

.chip:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* ---- Thread ------------------------------------------------------------- */
.thread {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1.25rem 1.35rem;
}

.entry--in {
  animation: rise 0.32s ease both;
}

.entry__q {
  margin: 0 0 0.9rem;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.entry__qlabel {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--signal);
  border: 1px solid var(--signal-soft);
  background: var(--signal-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  flex: 0 0 auto;
  transform: translateY(-1px);
}

.entry__qtext {
  font-weight: 500;
}

.entry__a {
  white-space: pre-wrap;
}

.entry__a p {
  margin: 0 0 0.7rem;
}

.entry__a p:last-child {
  margin-bottom: 0;
}

/* thinking state */
.thinking {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.thinking::after {
  content: "reading the sources";
  animation: dots 1.2s steps(4, end) infinite;
}

/* ---- Provenance (the signature) ----------------------------------------- */
.entry__sources {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
}

.sources__label {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.sources__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.source {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.25rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.source::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--signal);
  border-radius: 50%;
  flex: 0 0 auto;
}

/* ---- Outside-the-sources state ------------------------------------------ */
.entry--flagged {
  border-color: #e6cba6;
  background: var(--flag-soft);
}

.entry--flagged .entry__qlabel {
  color: var(--flag);
  background: #f0dcc4;
  border-color: #f0dcc4;
}

.flag-note {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
}

.flag-note__tag {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--flag);
  border: 1px solid var(--flag);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  flex: 0 0 auto;
  transform: translateY(-1px);
}

.error {
  color: var(--flag);
  font-size: 0.95rem;
  margin: 0;
}

/* ---- Colophon ----------------------------------------------------------- */
.colophon {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.colophon p {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---- Motion ------------------------------------------------------------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dots {
  0% {
    content: "reading the sources";
  }
  25% {
    content: "reading the sources.";
  }
  50% {
    content: "reading the sources..";
  }
  75% {
    content: "reading the sources...";
  }
}

@media (prefers-reduced-motion: reduce) {
  .entry--in {
    animation: none;
  }
  .thinking::after {
    animation: none;
    content: "reading the sources…";
  }
  #ask-btn:active {
    transform: none;
  }
}

@media (max-width: 30rem) {
  #ask-form {
    flex-direction: column;
  }
  #ask-btn {
    padding: 0.75rem;
  }
}

/* ---- Unlock page -------------------------------------------------------- */
.frame--narrow {
  max-width: 30rem;
}

.unlock {
  margin-top: 1rem;
}

.unlock__lede {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.25;
  margin: 0 0 1.1rem;
  color: var(--ink);
}

#unlock-form {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

#pw {
  flex: 1;
  padding: 0.85rem 1rem;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#pw:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

#unlock-btn {
  flex: 0 0 auto;
  padding: 0 1.5rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--surface);
  background: var(--signal);
  border: 1px solid var(--signal);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease;
}

#unlock-btn:hover {
  background: #0c5f59;
}

#unlock-btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

#unlock-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.unlock__msg {
  min-height: 1.2rem;
  margin: 0.8rem 0 0;
  font-size: 0.9rem;
  color: var(--flag);
}

@media (max-width: 30rem) {
  #unlock-form {
    flex-direction: column;
  }
}
