/* Zesty full-page chat, in the SA Home Loans brand: white, signal orange
   (#FF4F00), ink and greys, Inter, square corners, stepped orange stripes.
   The one loud element is the answer's steps: orange number blocks with the
   screenshot hung off an orange rail. */

@font-face {
  font-family: "Inter";
  src: url("vendor/inter-5.3.0-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #ffffff;
  --mist: #f4f4f4;
  --tile: #ededed;
  --orange: #ff4f00;
  --orange-deep: #d94300;
  --ink: #1d1e1f;
  --charcoal: #58595b;
  --silver: #a7a9ac;
  --error: #c4170c;
  --step: 2rem; /* number block size; the rail and screenshots hang from it */
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* Layout rules (display: grid/flex) must not un-hide hidden elements. */
[hidden] {
  display: none !important;
}

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

body {
  display: flex;
  flex-direction: column;
  background: var(--mist);
  color: var(--ink);
  font:
    400 1rem/1.6 "Inter",
    system-ui,
    sans-serif;
  font-feature-settings: "cv11", "ss01";
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

/* ── Top bar, with SAHL's stepped orange stripe on its lower edge ───────── */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 48px) 18px;
  background: var(--paper);
}

.topbar::before,
.topbar::after {
  content: "";
  position: absolute;
  bottom: 0;
  height: 6px;
  background: var(--orange);
}

.topbar::before {
  left: 0;
  width: 34%;
}

.topbar::after {
  left: 30%;
  width: 18%;
  bottom: -6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wordmark {
  width: 132px;
  height: auto;
}

.owner {
  padding-left: 14px;
  border-left: 1px solid var(--silver);
  color: var(--charcoal);
  font-size: 0.8125rem;
  line-height: 1.35;
}

.secondary {
  padding: 8px 16px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9375rem;
}

.secondary:hover {
  border-color: var(--orange);
  color: var(--orange-deep);
}

/* ── Conversation column ─────────────────────────────────────────────── */

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 40px 16px 24px;
}

.welcome,
.log {
  max-width: 760px;
  margin: 0 auto;
}

/* Welcome: Zesty's poster as a black "screen" beside the intro. */
.welcome {
  display: grid;
  grid-template-columns: minmax(180px, 280px) 1fr;
  gap: 32px;
  align-items: center;
}

.poster {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
}

.intro h1 {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.25rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.intro p {
  max-width: 34em;
  margin: 0 0 20px;
  color: var(--charcoal);
}

.examples {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.examples button {
  padding: 9px 14px;
  border: 0;
  border-left: 4px solid var(--orange);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9375rem;
  text-align: left;
}

.examples button:hover {
  background: var(--ink);
  color: var(--paper);
}

.log {
  list-style: none;
  padding: 0;
}

.turn {
  margin: 0 0 28px;
}

.question {
  display: flex;
  justify-content: flex-end;
}

.question .bubble {
  max-width: 80%;
  margin: 0;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--paper);
  white-space: pre-wrap;
}

.answer {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: start;
}

.avatar {
  width: 48px;
  height: auto;
}

.answer-column {
  min-width: 0;
}

.answer .bubble {
  padding: 18px 22px;
  background: var(--paper);
  border-top: 4px solid var(--orange);
}

/* Thinking: the wordmark's row of orange dashes, filling in turn. */
.thinking {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--charcoal);
}

.dashes {
  display: inline-flex;
  gap: 4px;
  transform: skewX(-20deg);
}

.dash {
  width: 7px;
  height: 14px;
  background: var(--orange);
  opacity: 0.25;
  animation: charge 1.2s infinite steps(1);
}

.dash:nth-child(2) {
  animation-delay: 0.15s;
}
.dash:nth-child(3) {
  animation-delay: 0.3s;
}
.dash:nth-child(4) {
  animation-delay: 0.45s;
}
.dash:nth-child(5) {
  animation-delay: 0.6s;
}
.dash:nth-child(6) {
  animation-delay: 0.75s;
}

@keyframes charge {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0.25;
  }
}

.answer-error {
  margin: 0;
  color: var(--error);
}

/* ── Answer Markdown: the steps ──────────────────────────────────────── */

.markdown > :first-child {
  margin-top: 0;
}

.markdown > :last-child {
  margin-bottom: 0;
}

.markdown p {
  margin: 0 0 12px;
}

/* Numbered steps: an orange block per number (the list-item counter keeps
   the guide's numbering when a screenshot splits the list). */
.markdown ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.markdown ol > li {
  position: relative;
  min-height: var(--step);
  margin: 0 0 8px;
  padding: 3px 0 0 calc(var(--step) + 14px);
}

.markdown ol > li::before {
  content: counter(list-item);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: var(--step);
  height: var(--step);
  background: var(--orange);
  color: var(--paper);
  font-weight: 800;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.markdown ul {
  padding-left: 1.2em;
}

.markdown ul > li::marker {
  color: var(--orange);
}

.markdown strong {
  font-weight: 700;
}

/* Tips: a mist panel with an ink edge, quieter than the steps. */
.markdown blockquote {
  margin: 4px 0 14px calc(var(--step) + 14px);
  padding: 8px 14px;
  border-left: 3px solid var(--ink);
  background: var(--mist);
  color: var(--charcoal);
  font-size: 0.9375rem;
}

.markdown blockquote p {
  margin: 0;
}

.markdown code {
  padding: 1px 5px;
  background: var(--mist);
}

.markdown a {
  color: var(--orange-deep);
}

/* Screenshots hang off an orange rail under their step number. */
.markdown p:has(> img.shot) {
  margin: 0 0 16px calc(var(--step) / 2 - 1px);
  padding: 4px 0 4px calc(var(--step) / 2 + 13px);
  border-left: 2px solid var(--orange);
}

img.shot {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--silver);
  background: var(--mist);
  cursor: zoom-in;
}

img.shot:hover {
  border-color: var(--orange);
}

img.shot.loading {
  background: repeating-linear-gradient(
    -20deg,
    var(--mist) 0 12px,
    var(--tile) 12px 24px
  );
}

img.shot.failed {
  cursor: default;
  opacity: 0.4;
}

/* ── Next steps, sources and feedback ────────────────────────────────── */

/* The offer of the rest of a long procedure: the one action to take next. */
.next-steps {
  display: block;
  margin: 2px 0 0;
  padding: 10px 18px;
  border: 0;
  border-radius: 0;
  background: var(--orange);
  color: var(--paper);
  font-weight: 700;
}

.next-steps:hover {
  background: var(--orange-deep);
}

.sources {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 16px;
  margin: 2px 0 0;
  padding: 12px 22px;
  background: var(--tile);
  font-size: 0.875rem;
}

.sources h3 {
  margin: 0;
  color: var(--charcoal);
  font-size: inherit;
  font-weight: 600;
}

.source-guide {
  grid-column: 2;
}

.sources h3 + .source-guide {
  grid-row: 1;
}

.source-title {
  margin: 0;
  font-weight: 600;
}

.sources ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.source-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--orange-deep);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.feedback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--charcoal);
  font-size: 0.875rem;
}

.feedback-button {
  min-width: 52px;
  padding: 3px 12px;
  border: 2px solid var(--silver);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
}

.feedback-button:hover {
  border-color: var(--ink);
}

.feedback-button[aria-pressed="true"] {
  border-color: var(--orange);
  background: var(--orange);
  color: var(--paper);
}

/* ── Composer ────────────────────────────────────────────────────────── */

.composer {
  padding: 14px 16px 10px;
  background: var(--paper);
  border-top: 1px solid var(--tile);
}

.ask,
.hint,
.error {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.ask {
  display: flex;
  gap: 0;
}

.ask textarea {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-right: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  resize: none;
}

.ask textarea::placeholder {
  color: var(--silver);
}

.ask textarea:focus-visible {
  outline: none;
  border-color: var(--orange);
}

.ask button {
  padding: 0 22px;
  border: 0;
  border-radius: 0;
  background: var(--orange);
  color: var(--paper);
  font-weight: 700;
}

.ask button:hover {
  background: var(--orange-deep);
}

.ask button:disabled {
  background: var(--silver);
  cursor: wait;
}

.hint {
  margin-top: 8px;
  margin-bottom: 0;
  color: var(--charcoal);
  font-size: 0.8125rem;
}

.error {
  margin-top: 0;
  color: var(--error);
  font-weight: 600;
}

/* ── Dialogs: screenshot lightbox and guide page ─────────────────────── */

dialog {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(29 30 31 / 80%);
}

.close {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: var(--orange);
  color: var(--paper);
  font-size: 1.5rem;
  line-height: 1;
}

.lightbox {
  max-width: 96vw;
  max-height: 96vh;
}

.lightbox figure {
  margin: 0;
}

.lightbox img {
  display: block;
  max-width: 96vw;
  max-height: 86vh;
}

.lightbox figcaption {
  max-width: 70ch;
  padding: 12px 16px;
  color: var(--charcoal);
  font-size: 0.875rem;
}

.pdf {
  width: min(1000px, 96vw);
  height: 92vh;
}

.pdf[open] {
  display: flex;
  flex-direction: column;
}

.pdf-bar {
  position: relative;
  min-height: 44px;
  padding: 11px 56px 11px 16px;
  border-bottom: 4px solid var(--orange);
  font-weight: 600;
}

.pdf iframe {
  flex: 1;
  width: 100%;
  border: 0;
}

/* ── Small screens and reduced motion ────────────────────────────────── */

@media (max-width: 640px) {
  .owner {
    display: none;
  }

  .welcome {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .poster {
    max-width: 220px;
  }

  .answer {
    grid-template-columns: 1fr;
  }

  .avatar {
    width: 36px;
  }

  .answer .bubble {
    padding: 16px;
  }

  .question .bubble {
    max-width: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dash {
    animation: none;
    opacity: 1;
  }
}
