/* The Statement — private-client advisory stationery. Operate surface.
   World lends: type, palette (firm colour owns the masthead rail), density, one
   signature move (footnote citations). Standard controls, no SaaS chat bubbles. */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal; font-weight: 200 900; font-display: swap;
  src: url("fonts/source-serif-4-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Archivo";
  font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/archivo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* firm colour (overridden per firm by widget.js from /config) */
  --primary: #0B5345;
  --accent: #148F77;
  /* firm colour darkened toward ink, for SMALL text on the cream ground so a light
     firm colour (gold, red) still clears 4.5:1. Large/rail uses keep raw --primary. */
  --primary-ink: color-mix(in srgb, var(--primary) 62%, #1C1B19);
  /* stationery world */
  --paper: #F3EFE7;
  --paper-rail-ink: #F6F2EA;   /* text on the coloured rail */
  --ink: #1C1B19;
  --clay: #9A8F7B;             /* secondary text + hairlines, tinted warm, never grey */
  --rule: #D8CFBE;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --grotesque: "Archivo", system-ui, sans-serif;
  --gutter: clamp(20px, 4vw, 44px);
  --measure: 66ch;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--serif);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums lining-nums;
}

/* browser surfaces carry the world */
::selection { background: color-mix(in srgb, var(--primary) 22%, transparent); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
::-webkit-scrollbar { width: 11px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--rule); border: 3px solid var(--paper); border-radius: 0; }
a { color: var(--primary); text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* ---- layout: masthead rail + conversation column ---- */
#app { min-height: 100%; display: grid; grid-template-columns: clamp(160px, 24%, 260px) 1fr; }

.rail {
  background: var(--primary);
  color: var(--paper-rail-ink);
  padding: var(--gutter);
  display: flex; flex-direction: column; gap: 10px;
  position: sticky; top: 0; align-self: start; height: 100vh;
}
.rail .firm {
  font-weight: 600;
  font-size: clamp(1.15rem, 0.4rem + 1.7vw, 2.1rem);
  line-height: 1.06; letter-spacing: -0.015em; margin: 0;
  text-wrap: balance; overflow-wrap: normal; word-break: normal;
  max-width: 100%;
}
.rail .role {
  font-family: var(--grotesque);
  font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: color-mix(in srgb, var(--paper-rail-ink) 90%, transparent);
}
.rail .mark { height: 30px; width: auto; align-self: start; margin-bottom: 6px; filter: saturate(0) brightness(0) invert(1); opacity: .92; }
/* seal is the only thing pinned to the bottom of the rail */
.rail .seal { font-family: var(--grotesque); font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: color-mix(in srgb, var(--paper-rail-ink) 78%, transparent); margin-top: auto; }

/* Explicit top-level call-to-action in the masthead rail: paper button on the firm colour. */
.rail-cta {
  margin-top: 20px; align-self: start;
  font-family: var(--grotesque); font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase;
  background: var(--paper-rail-ink); color: var(--primary-ink);
  border: 0; border-radius: 0; padding: 12px 20px; cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.rail-cta:hover, .rail-cta:focus-visible { background: var(--paper); color: var(--ink); }

/* ---- conversation column ---- */
/* Fill the whole paper area and centre a reading-measure content column inside it,
   so the conversation + input sit in the middle of the page, not jammed left.
   Children keep max-width: var(--measure) for legible line length. */
.sheet {
  display: flex; flex-direction: column; align-items: center; min-height: 100vh;
  width: 100%;
  padding: 0 var(--gutter);
}
.sheet > * { width: 100%; max-width: var(--measure); }
/* Before any chat, the greeting + questions sit as a composed page centered in the
   column, not a top-stuck fragment over a void. Empty .log must not eat the space. */
#app[data-chat="idle"] .log { flex: 0 0 auto; }
#app[data-chat="idle"] .greeting { margin-top: auto; }
#app[data-chat="idle"] .chips { margin-bottom: auto; }
.greeting {
  font-size: clamp(1.2rem, 1rem + 0.8vw, 1.6rem);
  line-height: 1.42; margin: var(--gutter) 0 0; max-width: var(--measure);
  color: var(--ink); text-wrap: pretty;
}
.greeting .lede { color: var(--clay); font-size: 0.95rem; margin-top: 10px; display: block; font-family: var(--grotesque); letter-spacing: 0.01em; }

/* starter questions: ruled text links, not pills */
.chips { display: flex; flex-direction: column; margin: 22px 0 8px; max-width: var(--measure); }
.chip {
  font-family: var(--serif); font-size: 1.02rem; color: var(--ink);
  background: none; border: 0; border-top: 1px solid var(--rule);
  text-align: left; padding: 13px 26px 13px 0; cursor: pointer; position: relative;
  transition: padding-left .18s ease, color .18s ease;
}
.chips .chip:last-child { border-bottom: 1px solid var(--rule); }
.chip::after { content: "\2192"; position: absolute; right: 2px; color: var(--clay); opacity: 0; transition: opacity .18s ease, transform .18s ease; }
.chip:hover, .chip:focus-visible { padding-left: 10px; color: var(--primary-ink); }
.chip:hover::after, .chip:focus-visible::after { opacity: 1; transform: translateX(0); }

/* ---- log: correspondence, no bubbles ---- */
.log { flex: 1; display: flex; flex-direction: column; gap: 26px; padding: 26px 0; max-width: var(--measure); }
.msg { line-height: 1.55; white-space: pre-wrap; }
.msg .who {
  font-family: var(--grotesque); font-size: 0.68rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--clay); display: block; margin-bottom: 7px;
  padding-bottom: 7px; border-bottom: 1px solid var(--rule);
}
.msg.user .who { color: var(--primary-ink); }
.msg.user .body { font-size: 1.08rem; }
.msg.bot .body { font-size: 1.05rem; }
.msg .body { max-width: var(--measure); }
.msg .body a { color: var(--primary); }

/* signature move: footnote citations */
.cites { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); counter-reset: fn; }
.cites .cites-label { font-family: var(--grotesque); font-size: 0.64rem; letter-spacing: 0.17em; text-transform: uppercase; color: var(--clay); display: block; margin-bottom: 8px; }
.cites a {
  display: grid; grid-template-columns: 1.6em 1fr; gap: 6px; align-items: baseline;
  font-family: var(--grotesque); font-size: 0.86rem; line-height: 1.45;
  color: var(--ink); text-decoration: none; padding: 3px 0;
}
.cites a::before { counter-increment: fn; content: counter(fn); font-variant-numeric: tabular-nums; color: var(--primary-ink); font-weight: 600; }
.cites a span { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 2px; }
.cites a:hover span { text-decoration-color: var(--primary); }

.typing { color: var(--clay); font-style: italic; }
.typing .dots::after { content: "\2026"; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }

/* ---- ask line at the foot (primary action) ---- */
.bar { position: sticky; bottom: 0; background: linear-gradient(var(--paper) 62%, transparent); padding: 14px 0 var(--gutter); max-width: var(--measure); }
.bar .ask-label { font-family: var(--grotesque); font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--clay); display: block; margin-bottom: 6px; }
.bar .row { display: flex; align-items: baseline; gap: 14px; border-bottom: 2px solid var(--ink); }
.bar input {
  flex: 1; border: 0; background: none; font-family: var(--serif);
  font-size: 1.12rem; color: var(--ink); padding: 8px 0;
}
.bar input::placeholder { color: var(--clay); }
.bar input:focus { outline: none; }
.bar .row:focus-within { border-bottom-color: var(--primary); }
.bar button {
  background: none; border: 0; cursor: pointer; font-family: var(--grotesque);
  font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--primary-ink); padding: 8px 0; white-space: nowrap;
}
.bar button:hover { color: var(--ink); }
.bar button:disabled { color: var(--clay); cursor: default; }

/* ---- lead form: a letterhead callback card ---- */
.lead { border: 1px solid var(--rule); background: color-mix(in srgb, var(--primary) 4%, var(--paper)); padding: var(--gutter); margin: 4px 0 8px; max-width: var(--measure); }
.lead .card-head { font-family: var(--grotesque); font-size: 0.66rem; letter-spacing: 0.17em; text-transform: uppercase; color: var(--primary-ink); display: block; margin-bottom: 4px; }
.lead .note { color: var(--ink); font-size: 1rem; margin: 0 0 16px; max-width: 54ch; }
.lead .field { display: block; margin: 0 0 14px; }
.lead .field .lab { font-family: var(--grotesque); font-size: 0.64rem; letter-spacing: 0.15em; text-transform: uppercase; color: var(--clay); display: block; margin-bottom: 5px; }
.lead input, .lead textarea {
  width: 100%; font-family: var(--serif); font-size: 1rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 0;
  padding: 10px 12px;
}
.lead textarea { min-height: 80px; resize: vertical; }
.lead input:focus, .lead textarea:focus { outline: none; border-color: var(--primary); }
.lead button {
  font-family: var(--grotesque); font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  background: var(--primary); color: var(--paper-rail-ink); border: 0; border-radius: 0;
  padding: 12px 22px; cursor: pointer;
}
.lead button:hover { background: var(--ink); }
.lead button:disabled { background: var(--clay); cursor: default; }
.lead .err { color: #9B2C2C; font-family: var(--grotesque); font-size: 0.82rem; margin: 8px 0 0; letter-spacing: 0.01em; }

.note { color: var(--clay); font-size: 0.95rem; }

/* ---- bad-code entry (unknown firm) ---- */
.entry { grid-column: 1 / -1; display: flex; flex-direction: column; justify-content: center; align-items: start; min-height: 100vh; padding: var(--gutter); max-width: 48ch; margin: 0 auto; gap: 14px; }
.entry h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.6rem, 1rem + 3vw, 2.6rem); margin: 0; letter-spacing: -0.02em; }
.entry input { font-family: var(--serif); font-size: 1.1rem; width: 100%; border: 0; border-bottom: 2px solid var(--ink); background: none; padding: 8px 0; }
.entry input:focus { outline: none; border-bottom-color: var(--primary); }
.entry button { font-family: var(--grotesque); font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase; background: var(--primary); color: var(--paper-rail-ink); border: 0; padding: 12px 22px; cursor: pointer; align-self: start; }
.entry button:hover { background: var(--ink); }

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

/* ---- mobile: rail becomes a top masthead band ---- */
@media (max-width: 680px) {
  #app { grid-template-columns: 1fr; }
  .rail {
    position: static; height: auto; flex-direction: row; align-items: baseline;
    justify-content: space-between; gap: 12px; padding: 18px var(--gutter);
  }
  .rail .firm { font-size: 1.4rem; }
  .rail .role { display: none; }
  .rail .mark { display: none; }
  .rail .seal { display: none; }
  .rail-cta { margin-top: 0; align-self: center; padding: 9px 14px; font-size: 0.68rem; white-space: nowrap; }
  .sheet { max-width: 100%; min-height: auto; }
}
