/* Byrd-IT, LLC
   Brand: high-contrast serif wordmark in black, hummingbird mark in blue.
   Type pairs a Didone-style display serif with a plain system sans for reading. */

:root {
  color-scheme: light dark;

  --brand:        #0760dd;
  --brand-deep:   #0b4aa2;
  --ink:          #14161a;
  --ink-soft:     #4c525c;
  --bg:           #ffffff;
  --bg-alt:       #f5f6f8;
  --line:         #e2e5ea;
  --focus:        #1268e3;
  --urgent:       #b3261e;

  --serif: "Playfair Display", "Didot", "Bodoni MT", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --measure: 34rem;
  --wide: 68rem;
  --step: clamp(1rem, 0.6rem + 1.4vw, 1.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand:      #6ba5f7;
    --brand-deep: #9cc4fa;
    --ink:        #eceef2;
    --ink-soft:   #a8aeb9;
    --bg:         #101216;
    --bg-alt:     #191c22;
    --line:       #2b303a;
    --urgent:     #f2837b;
  }
}

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

/* Author display rules (such as #chat-panel { display:flex }) override the
   browser default for hidden elements, so preserve the HTML hidden contract. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--sans);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 1.3rem + 3vw, 3.25rem); }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.125rem); margin-top: 2.5rem; }
h3 { font-size: 1.1875rem; margin-top: 1.75rem; font-family: var(--sans); font-weight: 650; }

p, li { max-width: var(--measure); }
p { margin: 0 0 1.1rem; }

a { color: var(--brand); text-underline-offset: 0.15em; }
a:hover { color: var(--brand-deep); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

img, svg { max-width: 100%; height: auto; }

.wrap { width: min(100% - 2.5rem, var(--wide)); margin-inline: auto; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--bg); color: var(--ink); padding: 0.75rem 1rem;
  border: 2px solid var(--brand);
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- Header ---------- */

.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.site-header .wrap {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.9rem 0; flex-wrap: wrap;
}

.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { height: 2rem; width: auto; max-width: min(15rem, 55vw); }
@media (max-width: 30rem) { .brand img { height: 1.6rem; } }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav a { color: var(--ink-soft); text-decoration: none; font-size: 0.9375rem; padding: 0.25rem 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--brand); }
.site-nav a[aria-current="page"] { border-bottom: 2px solid var(--brand); }

.header-cta {
  background: var(--brand); color: #fff; text-decoration: none;
  padding: 0.5rem 0.95rem; border-radius: 6px; font-weight: 600; font-size: 0.9375rem;
  white-space: nowrap;
}
.header-cta:hover { background: var(--brand-deep); color: #fff; }
@media (prefers-color-scheme: dark) { .header-cta, .header-cta:hover { color: #10131a; } }

/* ---------- Hero ---------- */

.hero { padding: clamp(2.5rem, 1rem + 6vw, 5rem) 0 clamp(2rem, 1rem + 4vw, 3.5rem); border-bottom: 1px solid var(--line); }
.hero p.lede { font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem); color: var(--ink-soft); max-width: 40rem; }
.hero .license { font-size: 0.875rem; color: var(--ink-soft); margin-top: 1.5rem; }

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1.75rem 0 0; }
.btn {
  display: inline-block; padding: 0.7rem 1.25rem; border-radius: 6px;
  text-decoration: none; font-weight: 600; border: 2px solid var(--brand);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn-secondary { color: var(--brand); background: transparent; }
.btn-secondary:hover { background: var(--bg-alt); }
@media (prefers-color-scheme: dark) { .btn-primary, .btn-primary:hover { color: #10131a; } }

/* ---------- Sections and cards ---------- */

section { padding: clamp(2rem, 1rem + 4vw, 3.5rem) 0; }
section.alt { background: var(--bg-alt); border-block: 1px solid var(--line); }
section > .wrap > h2:first-child { margin-top: 0; }

.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); margin-top: 1.75rem; }
.grid p, .grid li { max-width: none; }

.card {
  border: 1px solid var(--line); border-radius: 10px; padding: 1.4rem;
  background: var(--bg); display: flex; flex-direction: column;
}
.card h3 { margin-top: 0; font-family: var(--serif); font-size: 1.25rem; font-weight: 700; }
.card p { color: var(--ink-soft); flex: 1; margin-bottom: 1rem; }
.card a { font-weight: 600; text-decoration: none; }
.card a::after { content: " \2192"; }
.card a:hover { text-decoration: underline; }

.checklist { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.checklist li { padding: 0.9rem 0; border-bottom: 1px solid var(--line); max-width: 42rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist strong { display: block; font-size: 1rem; }
.checklist span { color: var(--ink-soft); }

.note {
  border-left: 4px solid var(--brand); background: var(--bg-alt);
  padding: 1rem 1.25rem; border-radius: 0 8px 8px 0; margin: 1.75rem 0;
  max-width: 42rem;
}
.note p:last-child { margin-bottom: 0; }

.area-list { columns: 2; column-gap: 2rem; list-style: none; padding: 0; max-width: 26rem; }
.area-list li { padding: 0.2rem 0; break-inside: avoid; }

/* ---------- Contact ---------- */

.contact-grid { display: grid; gap: 2.5rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); align-items: start; }
.contact-grid p, .contact-grid li { max-width: none; }

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.9375rem; }
.field input, .field select, .field textarea {
  font: inherit; width: 100%; padding: 0.6rem 0.7rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--ink);
}
.field textarea { min-height: 8rem; resize: vertical; }
.field .hint { font-size: 0.8125rem; color: var(--ink-soft); margin: 0.3rem 0 0; }

/* Consent checkbox. The form's inputs are full-width by default, which stretches a
   checkbox into a stray box above its own label, so this opts out of that. */
.field.consent { margin-top: 1.5rem; }
.field.consent label {
  display: flex; align-items: center; gap: 0.55rem;
  font-weight: 600; margin-bottom: 0.4rem; cursor: pointer;
}
.field.consent input[type="checkbox"] {
  width: 1.1rem; height: 1.1rem; flex: none; margin: 0;
  accent-color: var(--brand);
}
.field.consent .hint { max-width: 34rem; }

/* Signup preferences: categories remain independently selectable, with an
   explicit channel choice beside each one rather than a blanket consent. */
.narrow { max-width: 46rem; }
.preferences-form fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 1.5rem 0; padding: 1rem; }
.preferences-form legend { font-weight: 700; padding: 0 0.3rem; }
.preference-grid { display: grid; gap: 0.8rem; }
.preference-row { display: grid; grid-template-columns: minmax(12rem, 1fr) auto auto; gap: 0.6rem 1rem; align-items: center; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.preference-row:first-child { border-top: 0; }
.preference-row label { white-space: nowrap; }
.preference-row input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); vertical-align: middle; }
.preference-row .hint { grid-column: 1 / -1; margin: -0.2rem 0 0; }
@media (max-width: 34rem) { .preference-row { grid-template-columns: 1fr 1fr; } .preference-row strong, .preference-row .hint { grid-column: 1 / -1; } }

/* ---------- Footer ---------- */

.site-footer { border-top: 1px solid var(--line); background: var(--bg-alt); padding: 2.5rem 0 3rem; margin-top: 2rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.footer-grid h2 { font-family: var(--sans); font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 0.7rem; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { padding: 0.2rem 0; }
.footer-grid a { color: var(--ink); text-decoration: none; }
.footer-grid a:hover { color: var(--brand); text-decoration: underline; }
.footer-bottom { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: 0.875rem; color: var(--ink-soft); }
.footer-bottom p { max-width: none; margin: 0.2rem 0; }
.footer-legal { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.6rem !important; }
.footer-legal a { color: var(--ink-soft); text-decoration: underline; }
.footer-legal a:hover { color: var(--brand); }

/* ---------- Chat widget ---------- */

#chat-launcher {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 60;
  background: var(--brand); color: #fff; border: 0; border-radius: 999px;
  padding: 0.85rem 1.35rem; font: 600 1rem var(--sans); cursor: pointer;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.22);
}
#chat-launcher:hover { background: var(--brand-deep); }
@media (prefers-color-scheme: dark) { #chat-launcher { color: #10131a; } }

#chat-panel {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 61;
  width: min(23rem, calc(100vw - 2.5rem));
  height: min(32rem, calc(100dvh - 2.5rem));
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 0.24); overflow: hidden;
}

#chat-panel header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--line); background: var(--bg-alt);
}
#chat-panel header h2 { margin: 0; font-family: var(--sans); font-size: 0.9375rem; font-weight: 650; }
#chat-minimize, #chat-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--ink-soft); min-width: 48px; min-height: 48px; padding: 0 0.25rem; }
#chat-minimize { margin-left: auto; }
#chat-minimize:hover, #chat-close:hover { color: var(--ink); }

#chat-log { flex: 1; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.7rem; }
#chat-log p { max-width: 85%; margin: 0; padding: 0.6rem 0.8rem; border-radius: 12px; font-size: 0.9375rem; white-space: pre-wrap; }
#chat-log .from-bot { background: var(--bg-alt); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 3px; }
#chat-log .from-you { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
@media (prefers-color-scheme: dark) { #chat-log .from-you { color: #10131a; } }
#chat-log .status { align-self: flex-start; color: var(--ink-soft); font-style: italic; background: none; border: 0; padding-left: 0.2rem; }

#chat-form { display: flex; gap: 0.5rem; padding: 0.7rem; border-top: 1px solid var(--line); }
#chat-input { flex: 1; font: inherit; font-size: 0.9375rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
#chat-form button { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 0 1rem; font: 600 0.9375rem var(--sans); cursor: pointer; }
#chat-form button:disabled { opacity: 0.55; cursor: default; }
#chat-form .chat-voice-button { padding: 0; width: 2.5rem; font-size: 1.1rem; }
.chat-voice { flex: 1; min-height: 0; overflow-y: auto; padding: 0.9rem; }
.chat-voice .actions { gap: 0.45rem; }
.chat-voice .btn { font: 600 0.875rem var(--sans); padding: 0.5rem 0.65rem; }
.chat-voice .voice-transcript { max-height: 14rem; }
@media (prefers-color-scheme: dark) { #chat-form button { color: #10131a; } }

/* ---------- Diagnostics popup (assets/diag.js) ---------- */

#diag-panel {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 62;
  width: min(30rem, calc(100vw - 2.5rem));
  height: min(40rem, calc(100vh - 2.5rem));
  display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 32px rgb(0 0 0 / 0.24); overflow: hidden;
}
#diag-panel header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--line); background: var(--bg-alt);
}
#diag-panel header h2 { margin: 0; font-family: var(--sans); font-size: 0.9375rem; font-weight: 650; }
#diag-close { margin-left: auto; background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--ink-soft); padding: 0 0.25rem; }
#diag-close:hover { color: var(--ink); }
#diag-body { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
#diag-body > .status { margin: 1rem; color: var(--ink-soft); font-style: italic; }

.diag-step { padding: 1rem 1.1rem; font-size: 0.9375rem; }
.diag-step p { margin: 0 0 0.9rem; }
.diag-step .field { margin-bottom: 0.9rem; }
.diag-step .actions { margin-top: 0.5rem; gap: 0.5rem; }
.diag-step .btn { font: inherit; font-weight: 600; font-size: 0.9375rem; padding: 0.55rem 1rem; cursor: pointer; }
.diag-step .btn:disabled { opacity: 0.55; cursor: default; }
.diag-step select, .diag-step textarea { width: 100%; font: inherit; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.diag-step textarea { min-height: 4.5rem; resize: vertical; }
.diag-step .hint { font-size: 0.8125rem; color: var(--ink-soft); margin-top: 1rem; }
.diag-note { color: var(--ink-soft); margin: 0.75rem 0 0; }
.diag-error { color: #b42318; margin: 0.75rem 0 0; }
@media (prefers-color-scheme: dark) { .diag-error { color: #f97066; } }

.diag-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.diag-session { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 0.75rem; flex-wrap: wrap; padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--line); font-size: 0.8125rem; color: var(--ink-soft); }
.diag-session strong { color: var(--ink); }
.diag-session-actions { display: flex; gap: 0.9rem; }
#diag-panel .linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }
#diag-panel .linklike:hover { color: var(--brand-deep); }
.diag-log { flex: 1; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.7rem; }
.diag-log p { max-width: 90%; margin: 0; padding: 0.6rem 0.8rem; border-radius: 12px; font-size: 0.9375rem; white-space: pre-wrap; }
.diag-log .from-bot { background: var(--bg-alt); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 3px; }
.diag-log .from-you { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
@media (prefers-color-scheme: dark) { .diag-log .from-you { color: #10131a; } }
.diag-log .status { align-self: flex-start; color: var(--ink-soft); font-style: italic; background: none; border: 0; padding-left: 0.2rem; }
.diag-form { display: flex; gap: 0.5rem; padding: 0.7rem; border-top: 1px solid var(--line); }
.diag-form input { flex: 1; font: inherit; font-size: 0.9375rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.diag-form button { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 0 1rem; font: 600 0.9375rem var(--sans); cursor: pointer; }
.diag-form button:disabled { opacity: 0.55; cursor: default; }
@media (prefers-color-scheme: dark) { .diag-form button { color: #10131a; } }

/* Safety banner, shared by the public chat widget and the diagnostic panel.
   Rendered from the server's safetyWarnings array as UI chrome - never from the
   assistant's own text - so a hazard notice cannot be softened or dropped by the
   model's wording. Deliberately the loudest element in either panel. */
#chat-log .safety, .diag-log .safety {
  max-width: 100%; align-self: stretch; margin: 0; padding: 0;
  border: 2px solid #b3261e; border-radius: 10px; overflow: hidden; background: #fff5f5;
}
#chat-log .safety .safety-head, .diag-log .safety .safety-head {
  background: #b3261e; color: #fff; font: 700 0.75rem/1.5 var(--sans);
  letter-spacing: 0.06em; padding: 0.3rem 0.7rem;
}
#chat-log .safety .safety-body, .diag-log .safety .safety-body {
  color: #7f1d1a; padding: 0.6rem 0.7rem; font-size: 0.9rem; white-space: pre-wrap;
}
@media (prefers-color-scheme: dark) {
  #chat-log .safety, .diag-log .safety { background: #2a1513; border-color: #f2837b; }
  #chat-log .safety .safety-head, .diag-log .safety .safety-head { background: #c3352c; }
  #chat-log .safety .safety-body, .diag-log .safety .safety-body { color: #ffc9c4; }
}

/* Browser voice chat (/support/voice, /demo/voice). The transcript is the load-
   bearing part: a caller needs to see what the assistant HEARD, because a misheard
   model number is the most common way a voice conversation goes wrong. */
.voice-status-line { font-weight: 600; margin: 0 0 0.8rem; min-height: 1.4em; }
.voice-transcript {
  margin-top: 1rem; max-height: 22rem; overflow-y: auto; padding: 0.9rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-alt);
  display: flex; flex-direction: column; gap: 0.55rem;
}
.voice-transcript:empty { display: none; }
.voice-transcript p { margin: 0; font-size: 0.9375rem; white-space: pre-wrap; }
.voice-transcript .voice-who { font-weight: 650; color: var(--ink-soft); }
.voice-transcript .voice-note, .voice-transcript .voice-status {
  color: var(--ink-soft); font-style: italic;
}
.voice-audio { display: block; width: 100%; margin-top: 1rem; }
.voice-code {
  margin-top: 1rem; padding: 0.9rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-alt); display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
}
.voice-code label { font-weight: 650; width: 100%; }
.voice-code input {
  font: inherit; letter-spacing: 0.3em; padding: 0.55rem 0.7rem; width: 8em;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink);
}
.voice-code-note { width: 100%; margin: 0; font-size: 0.875rem; color: var(--ink-soft); }

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

@media print {
  .site-nav, #chat-launcher, #chat-panel, .actions { display: none; }
}

/* A note's heading is an h2 for correct document outline, but it sits inside a
   callout and should not compete with the section headings around it. */
.note h2 {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 650;
  margin: 0 0 0.5rem;
}

/* Navigation buttons under an assistant reply. Rendered from the server's navLinks
   array, never from a URL the model typed - #chat-log p uses textContent, so a URL
   inside the reply is not clickable at all. Styled as a button but is a real <a>, so
   middle-click and "open in new tab" work the way people expect from a link.
   Deliberately quieter than .safety: this is a convenience, not a hazard notice. */
#chat-log .chat-nav, .diag-log .chat-nav {
  align-self: flex-start; max-width: 85%;
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0;
}
#chat-log .chat-nav-link, .diag-log .chat-nav-link {
  display: inline-block; padding: 0.45rem 0.8rem;
  background: var(--brand); color: #fff; text-decoration: none;
  border-radius: 999px; font: 600 0.875rem/1.2 var(--sans);
  border: 1px solid transparent;
}
#chat-log .chat-nav-link:hover, .diag-log .chat-nav-link:hover { filter: brightness(1.08); text-decoration: none; }
#chat-log .chat-nav-link:focus-visible, .diag-log .chat-nav-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  #chat-log .chat-nav-link, .diag-log .chat-nav-link { color: #10131a; }
}
