/* Palette and type follow plccode.ai (website styles.css :root), so the homepage embed reads as part
   of the site and the standalone page as its sibling. Fonts: the site's faces when the visitor has
   them, then close system faces (CSP is font-src 'self' and we ship no font files yet). */
:root {
  --ink: #0c0b0a;
  --surface: #161513;
  --surface-2: #1d1b18;
  --line: rgba(244, 241, 234, 0.1);
  --line-strong: rgba(244, 241, 234, 0.2);
  --paper: #f4f1ea;
  --paper-dim: #a8a298;
  --paper-faint: #6f6a60;
  --amber: #ffb22e;
  --amber-ink: #0c0b0a;
  --fault: #ef5b53;
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Hanken Grotesk', 'Segoe UI Variable Text', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui,
    sans-serif;
  --display: 'Archivo', 'Segoe UI Variable Display', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui,
    sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* `display: flex` on .composer (and friends) beats the UA's [hidden] rule, which left the composer
   on screen under the sign-in wall. */
[hidden] {
  display: none !important;
}

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

body {
  background:
    radial-gradient(1100px 520px at 50% -10%, rgba(255, 178, 46, 0.07), transparent 70%),
    var(--ink);
  color: var(--paper);
  font: 15.5px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---- top bar (standalone only) ---------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
}

.brand {
  color: var(--paper);
  text-decoration: none;
  font: 800 17px/1 var(--display);
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--amber);
}

.top-actions {
  display: flex;
  gap: 8px;
}

/* ---- controls --------------------------------------------------------------------------------- */

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 14px;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    color 0.15s,
    opacity 0.15s;
}

button:disabled {
  cursor: not-allowed;
}

.primary {
  background: var(--amber);
  color: var(--amber-ink);
  font-weight: 650;
}

.primary:not(:disabled):hover {
  background: #ffc152;
}

.ghost {
  background: transparent;
  color: var(--paper);
  border-color: var(--line-strong);
  font-size: 14px;
}

.ghost:hover {
  background: rgba(244, 241, 234, 0.05);
}

button:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

a.button {
  display: inline-block;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 16px;
  text-decoration: none;
}

button.small {
  padding: 2px 10px;
  font-size: 12px;
}

/* ---- layout ----------------------------------------------------------------------------------- */
/* One column. Fresh (no messages): the heading, composer and example chips sit together in the
   middle of the screen, ChatGPT-style. Once a thread exists the list fills the space and the
   composer docks at the bottom. */

.shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 20px 12px;
}

.fresh .shell {
  justify-content: center;
  padding-bottom: 8vh;
}

.fresh main {
  flex: 0 0 auto;
  overflow: visible;
  padding-top: 0;
}

/* ---- empty state ------------------------------------------------------------------------------ */

.empty {
  text-align: center;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.eyebrow {
  margin: 0 0 14px;
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
}

.empty h1 {
  margin: 0 0 12px;
  font: 900 clamp(28px, 4.6vw, 40px) / 1.06 var(--display);
  letter-spacing: -0.025em;
}

.sub {
  margin: 0 auto;
  max-width: 48ch;
  color: var(--paper-dim);
}

/* ---- messages --------------------------------------------------------------------------------- */

.messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.msg {
  min-width: 0;
  animation: rise 0.25s ease-out both;
}

.msg.user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.assistant {
  padding-left: 14px;
  border-left: 2px solid rgba(255, 178, 46, 0.35);
}

.msg.assistant p {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}

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

.msg.assistant pre {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 10px;
}

.msg code {
  font-family: var(--mono);
  font-size: 13px;
}

.msg.assistant p code {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
}

.msg.pending::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 15px;
  margin-left: 2px;
  background: var(--amber);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}

.msg.failed {
  opacity: 0.55;
}

/* ---- sign-in wall ----------------------------------------------------------------------------- */

.wall {
  margin: 28px 0 8px;
  padding: 22px;
  border: 1px solid rgba(255, 178, 46, 0.45);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 178, 46, 0.06), transparent 70%), var(--surface);
  text-align: center;
  animation: rise 0.35s ease-out both;
}

.wall h2 {
  margin: 0 0 6px;
  font: 800 20px/1.2 var(--display);
  letter-spacing: -0.015em;
}

.wall p {
  margin: 0 auto 16px;
  max-width: 46ch;
  color: var(--paper-dim);
}

/* ---- composer --------------------------------------------------------------------------------- */

.composer-wrap {
  padding: 8px 20px 14px;
}

.fresh .composer-wrap {
  padding-top: 26px;
  animation: rise 0.5s 0.06s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 8px 8px 8px 10px;
  box-shadow: 0 18px 50px -28px rgba(0, 0, 0, 0.9);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.composer:focus-within {
  border-color: rgba(255, 178, 46, 0.55);
  box-shadow:
    0 0 0 3px rgba(255, 178, 46, 0.1),
    0 18px 50px -28px rgba(0, 0, 0, 0.9);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--paper);
  font: inherit;
  max-height: 40vh;
  padding: 7px 6px;
}

.composer textarea::placeholder {
  color: var(--paper-faint);
}

.composer textarea:focus-visible {
  outline: none;
}

.send {
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.send:disabled {
  background: rgba(244, 241, 234, 0.08);
  color: var(--paper-faint);
}

/* Example questions: only on a fresh page. A click fills the box, it never spends a message. */
.examples {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.examples {
  display: none;
}

.fresh .examples {
  display: flex;
}

.chip {
  background: rgba(244, 241, 234, 0.03);
  border: 1px solid var(--line);
  color: var(--paper-dim);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13.5px;
}

.chip:hover {
  color: var(--paper);
  border-color: var(--line-strong);
  background: rgba(244, 241, 234, 0.06);
}

.notice {
  margin: 0 0 8px;
  color: var(--fault);
  font-size: 14px;
}

.challenge:empty {
  display: none;
}

.challenge {
  margin: 0 0 8px;
  display: flex;
  justify-content: center;
}

/* ---- fine print ------------------------------------------------------------------------------- */

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  margin: 12px 0 0;
  color: var(--paper-faint);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}

#counter {
  font: 500 10.5px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}

#counter:empty {
  display: none;
}

.meta a {
  color: var(--paper-dim);
  text-underline-offset: 2px;
}

/* ---- motion ----------------------------------------------------------------------------------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

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

@media (max-width: 560px) {
  .top {
    padding: 12px 16px;
  }
  main {
    padding: 16px 16px 10px;
  }
  .composer-wrap {
    padding: 6px 16px 12px;
  }
  .chip {
    font-size: 13px;
  }
}

/* ---- homepage embed (/?embed=1): an iframe block on plccode.ai ------------------------------- */
/* No top bar and no heading (the homepage section supplies both), a transparent background so the
   site's own panel shows through. The message list scrolls inside the frame. */

.embed body {
  background: transparent;
}

.embed .shell {
  max-width: none;
}

.embed .fresh .shell {
  padding-bottom: 0;
}

.embed main {
  padding: 18px 18px 8px;
}

.embed .composer-wrap {
  padding: 6px 18px 14px;
}

.embed .fresh .composer-wrap {
  padding-top: 0;
}
