/*
  Bugni Labs Design System v3.5 ("Foundry + Lane"), as bugni.io uses it
  (http-bugni-io frontend/src/index.css; brand-bugni-io bugni-tokens). Only the tokens and
  components these pages use. Page layout follows the agreed proposal C.
  No inline styles anywhere: the Content-Security-Policy (public/_headers) forbids them.
*/

:root {
  /* neutrals */
  --c-linen: #F5EEDF; --c-paper: var(--c-linen); --c-linen-2: #EFE7D3; --c-plaster: #FBF5E5;
  --c-bark: #1A1A14; --c-bark-surface: #26231B; --c-stone: #5A5450; --c-stone-2: #8A8278;
  --c-rule: #D4CAB1; --c-rule-2: #E8DFC6; --c-rule-dark: #3a352a;
  /* accents */
  --c-iron: #C7401A; --c-iron-text: #B23A1F; --c-amber: #D8862E;
  --c-sage: #4E5B47; --c-sage-deep: #45503E; --c-sage-bright: #8FA582;
  /* states */
  --c-info-bg: #ECE4D2; --c-success-bg: #E7EBE3;
  --cta-secondary-hover-bg: #F4E0D8;

  --font-sans: "Geist", -apple-system, system-ui, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;
  --font-serif: "Fraunces", "Iowan Old Style", Georgia, serif;

  --container-max: 1240px;
  --gutter: 24px;
  --header-h: 72px;
  --ease-cta: cubic-bezier(.4, 0, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-paper);
  color: var(--c-bark);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-weight: 500; letter-spacing: -0.025em; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--c-iron-text); text-decoration: none; transition: color 150ms; }
a:hover { color: var(--c-bark); }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 2px solid var(--c-iron); outline-offset: 2px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: 16px; top: -48px; z-index: 50; background: var(--c-bark-surface); color: var(--c-paper); padding: 10px 16px; }
.skip-link:focus { top: 12px; color: var(--c-paper); }

.label {
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-stone);
}
.label-category { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-iron-text); }
.concept { font-family: var(--font-serif); font-style: italic; font-weight: 300; color: var(--c-sage); font-variation-settings: "opsz" 144, "SOFT" 100; }
.container { max-width: var(--container-max); margin: 0 auto; padding: 0 var(--gutter); }

/* ── AI mark: circled "AI", like © for AI (bugni.io TalkToPenta) ── */
.ai-mark { width: 16px; height: 16px; flex: 0 0 16px; }
.ai-tag {
  font-family: var(--font-mono); font-size: 10px; line-height: 1; letter-spacing: 0.12em;
  border: 1px solid var(--c-sage); color: var(--c-sage); padding: 3px 5px 2px;
}

/* ── Buttons (v3.5 CTA model: sharp, colour-only transitions) ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px; border: 1px solid transparent; border-radius: 0;
  font-family: var(--font-sans); font-weight: 500; font-size: 16px; text-decoration: none;
  transition: background-color 320ms var(--ease-cta), color 320ms var(--ease-cta), border-color 320ms var(--ease-cta);
}
.btn-primary { background: var(--c-bark-surface); border-color: var(--c-bark-surface); color: var(--c-paper); }
.btn-primary:hover:not(:disabled) { background: var(--c-iron); border-color: var(--c-iron); color: var(--c-paper); }
.btn-primary .arrow { font-family: var(--font-mono); color: var(--c-amber); }
.btn-primary:hover:not(:disabled) .arrow { color: var(--c-paper); }
.btn-outline { background: transparent; border-color: var(--c-bark); color: var(--c-bark); }
.btn-outline:hover:not(:disabled) { background: var(--c-linen-2); color: var(--c-bark); }
/* An AI expert, like Penta on light grounds: sage at rest, deepens and grows a rust frame on hover. */
.btn-ai { background: transparent; border-color: var(--c-sage); color: var(--c-sage); min-height: 44px; padding: 0 18px; }
.btn-ai:hover { background: var(--c-sage-deep); border-color: var(--c-iron); color: var(--c-paper); }
.btn-small { min-height: 44px; padding: 0 18px; font-size: 15px; }
.link-button { background: none; border: 0; padding: 0; color: var(--c-iron-text); text-decoration: underline; text-underline-offset: 3px; }
.link-button:hover { color: var(--c-bark); }

/* ── Header ── */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--c-paper); border-bottom: 1px solid var(--c-rule); }
.site-header .container { min-height: var(--header-h); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: inline-flex; align-items: center; gap: 14px; color: var(--c-bark); }
.brand:hover { color: var(--c-bark); }
.brand img { height: 28px; width: auto; display: block; }
.brand-site { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-stone); }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 28px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.nav a:not(.btn) { color: var(--c-bark); }
.nav a:not(.btn):hover { color: var(--c-iron-text); }
.nav .btn { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }

/* ── Home ── */
.hero { padding: clamp(64px, 10vw, 104px) 0 clamp(48px, 8vw, 88px); }
.hero .label-category { margin-bottom: 24px; }
.hero h1 { font-size: clamp(44px, 6vw + 12px, 88px); line-height: 1.04; letter-spacing: -0.035em; }
.hero .lede { margin-top: 32px; max-width: 640px; font-size: 19px; line-height: 1.7; color: var(--c-stone); }

.band { background: var(--c-linen-2); border-top: 1px solid var(--c-rule); border-bottom: 1px solid var(--c-rule); }
.band .container { padding-top: clamp(48px, 8vw, 72px); padding-bottom: clamp(48px, 8vw, 80px); display: flex; flex-direction: column; gap: 28px; }
.section-title { font-size: clamp(32px, 3vw + 10px, 36px); line-height: 1.15; }

.expert-card { background: var(--c-plaster); border: 1px solid var(--c-rule); display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); transition: border-color 200ms; }
.expert-card:hover { border-color: var(--c-bark); }
.expert-card > div { padding: clamp(24px, 4vw, 36px) clamp(20px, 4vw, 40px); display: flex; flex-direction: column; gap: 20px; }
.expert-card > div + div { border-left: 1px solid var(--c-rule-2); }
/* Side by side, the expert's side is the narrower one, so its text fills more of the card's height. */
@media (min-width: 861px) { .expert-card { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.expert-id { display: flex; align-items: center; gap: 20px; }
.avatar { background: var(--c-sage); color: var(--c-paper); display: flex; align-items: center; justify-content: center; font-weight: 500; flex: none; }
.avatar-lg { width: 72px; height: 72px; font-size: 34px; }
.avatar-md { width: 32px; height: 32px; font-size: 16px; }
.avatar-sm { width: 24px; height: 24px; font-size: 13px; }
.expert-name { display: flex; align-items: center; gap: 10px; }
.expert-name h3, .expert-name h1 { font-size: 32px; line-height: 1.1; letter-spacing: -0.02em; }
.expert-topic { font-size: 18px; }
.expert-blurb { color: var(--c-stone); max-width: 480px; }
.expert-actions { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; }

.ask-own { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; gap: 8px; }
.field {
  flex: 1 1 auto; min-width: 0; font: inherit; font-size: 16px; color: var(--c-bark);
  background: var(--c-paper); border: 1px solid var(--c-rule); border-radius: 2px;
  padding: 0 16px; min-height: 52px;
}
.field:focus { border-color: var(--c-iron); outline: none; box-shadow: 0 0 0 2px var(--c-linen-2); }
textarea.field { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.5; }

.suggestions { border-top: 1px solid var(--c-rule-2); border-bottom: 1px solid var(--c-rule-2); display: flex; flex-direction: column; margin: 0 -16px; }
.suggestions a, .suggestions button {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 16px; min-height: 52px; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--c-bark); font-size: 16px;
}
.suggestions > * + * { border-top: 1px solid var(--c-rule-2); }
.suggestions a:hover, .suggestions button:hover:not(:disabled) { background: var(--c-paper); color: var(--c-bark); }
.suggestions .arrow { font-family: var(--font-mono); color: var(--c-iron-text); }
.suggestions.boxed { margin: 0; background: var(--c-plaster); border: 1px solid var(--c-rule); }

.how { padding: clamp(64px, 10vw, 88px) 0 clamp(64px, 10vw, 104px); }
.how .container { display: flex; flex-direction: column; gap: 40px; }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 40px; }
.how-grid > div { border-top: 2px solid var(--c-sage); padding-top: 20px; display: flex; flex-direction: column; gap: 8px; }
.how-grid .num { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; color: var(--c-sage); }
.how-grid h3 { font-size: 20px; letter-spacing: -0.01em; }
.how-grid p { color: var(--c-stone); }

/* ── Expert page ── */
.page-expert { min-height: 100vh; display: flex; flex-direction: column; }
.expert-layout {
  flex: 1 1 auto; width: 100%; max-width: 1288px; margin: 0 auto; padding: 48px var(--gutter) 0;
  display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: 72px;
}
.expert-aside { position: sticky; top: calc(var(--header-h) + 32px); align-self: start; display: flex; flex-direction: column; gap: 24px; }
.expert-aside .expert-blurb { font-size: 15px; }
.facts { margin: 0; padding: 16px 0; border-top: 1px solid var(--c-rule); border-bottom: 1px solid var(--c-rule); display: flex; flex-direction: column; gap: 4px; }
.facts dd { margin: 0; }
.small-print { font-size: 13px; color: var(--c-stone); }
.small-print a { text-decoration: underline; text-underline-offset: 3px; }

.conversation { min-width: 0; max-width: 760px; width: 100%; display: flex; flex-direction: column; }
.log { flex: 1 1 auto; display: flex; flex-direction: column; gap: 36px; padding-bottom: 40px; }
.greeting { display: flex; flex-direction: column; gap: 28px; padding-top: 8px; }
.greeting-line { font-size: 22px; line-height: 1.4; letter-spacing: -0.01em; }
.speaker { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }

.you { align-self: flex-end; max-width: 80%; background: var(--c-bark-surface); color: var(--c-paper); padding: 12px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply { display: flex; flex-direction: column; gap: 14px; }
.reply-body { display: flex; flex-direction: column; gap: 14px; font-size: 17px; line-height: 1.65; overflow-wrap: anywhere; }
.reply-body ul, .reply-body ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.block-label { font-weight: 600; }
.block-note { display: flex; gap: 12px; background: var(--c-info-bg); padding: 14px 18px; font-size: 16px; }
.cite {
  display: inline-block; margin-left: 6px; padding: 0 6px; vertical-align: 1px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.05em; line-height: 18px;
  border: 1px solid var(--c-rule); color: var(--c-iron-text); background: var(--c-plaster);
}
.cite:hover { border-color: var(--c-bark); color: var(--c-bark); }
.reply-sub { font-size: 14px; color: var(--c-stone); }

.notice { display: flex; gap: 12px; background: var(--c-info-bg); color: var(--c-bark); padding: 14px 18px; }
.notice svg { flex: 0 0 18px; margin-top: 3px; }
.notice .sub { font-size: 14px; color: var(--c-stone); }
.quiet { font-size: 14px; color: var(--c-stone); }

.pending { display: flex; flex-direction: column; gap: 12px; }
.dots { display: flex; gap: 6px; padding-left: 34px; }
.dots span { width: 6px; height: 6px; background: var(--c-stone-2); display: inline-block; opacity: .6; }
@media (prefers-reduced-motion: no-preference) {
  .dots span { animation: blink 1.2s infinite; }
  .dots span:nth-child(2) { animation-delay: .2s; }
  .dots span:nth-child(3) { animation-delay: .4s; }
}
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: -10px; padding-top: 2px; }
.thumb { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--c-stone-2); }
.thumb:hover:not(:disabled) { color: var(--c-sage); }
.thumb[aria-pressed="true"] { color: var(--c-sage); }
.thumb[aria-pressed="true"] svg { fill: currentColor; }
.actions .label { margin-left: 10px; }
.feedback-note { font-size: 14px; color: var(--c-sage); }
.feedback-note.problem { color: var(--c-stone); }

.ask-form { position: sticky; bottom: 0; background: var(--c-paper); padding: 16px 0 20px; border-top: 1px solid var(--c-rule); display: flex; flex-direction: column; gap: 10px; }
.ask-form .btn { min-height: 52px; padding: 0 24px; }

/* Feedback dialog */
dialog.feedback {
  width: min(640px, calc(100vw - 32px)); padding: 32px; border: 1px solid var(--c-rule);
  background: var(--c-plaster); color: var(--c-bark);
}
dialog.feedback::backdrop { background: rgba(26, 26, 20, 0.4); }
dialog.feedback form { display: flex; flex-direction: column; gap: 20px; }
dialog.feedback h2 { font-size: 26px; line-height: 1.2; letter-spacing: -0.02em; }
.dialog-head { display: flex; flex-direction: column; gap: 6px; }
.dialog-head .label { color: var(--c-sage); }
.dialog-head p:last-child { font-size: 15px; color: var(--c-stone); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 15px; min-height: 44px; padding: 10px 16px; border: 1px solid var(--c-rule); background: var(--c-paper); color: var(--c-bark); }
.chip[aria-pressed="true"] { border-color: var(--c-bark); background: var(--c-bark); color: var(--c-paper); }
.dialog-field { display: flex; flex-direction: column; gap: 8px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* The compact bar a phone shows in place of the side panel. */
.expert-bar { display: none; }

/* ── Footer (bugni.io master footer, condensed) ── */
.site-footer { background: var(--c-bark-surface); color: var(--c-paper); border-top: 1px solid var(--c-rule-dark); }
.site-footer .container { padding-top: 56px; padding-bottom: 0; }
.footer-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 32px; padding-bottom: 40px; border-bottom: 1px solid rgba(245, 238, 223, 0.1); }
.footer-brand { display: flex; flex-direction: column; gap: 12px; max-width: 360px; }
.footer-brand img { height: 28px; width: auto; align-self: flex-start; }
.footer-brand p { font-size: 14px; color: rgba(245, 238, 223, 0.8); }
.footer-cols { display: flex; flex-wrap: wrap; gap: 32px 56px; }
.footer-cols nav { display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.footer-cols h2 { font-size: 14px; font-weight: 600; letter-spacing: 0; color: var(--c-paper); margin-bottom: 4px; }
.site-footer a { color: rgba(245, 238, 223, 0.6); }
.site-footer a:hover { color: var(--c-paper); }
.legal-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: 24px 0; font-size: 12px; color: rgba(245, 238, 223, 0.4); }
.legal-links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.legal-links a { color: rgba(245, 238, 223, 0.4); }
.legal-links a:hover { color: rgba(245, 238, 223, 0.8); }

/* ── Not found ── */
.plain-page { padding: clamp(64px, 10vw, 128px) 0; display: flex; flex-direction: column; gap: 24px; }
.plain-page h1 { font-size: clamp(36px, 4vw + 10px, 64px); line-height: 1.04; }

/* ── Phones and narrow windows ── */
@media (max-width: 860px) {
  .expert-layout { display: block; padding-top: 20px; }
  .expert-aside { display: none; }
  .page-expert .site-header { display: none; }
  .expert-bar {
    display: flex; position: sticky; top: 0; z-index: 10; align-items: center; gap: 4px;
    background: var(--c-paper); border-bottom: 1px solid var(--c-rule); padding: 6px 4px;
  }
  .expert-bar .icon-button { width: 44px; height: 44px; flex: 0 0 44px; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--c-bark); font-family: var(--font-mono); font-size: 18px; }
  .expert-bar .who { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; }
  .expert-bar .who-text { min-width: 0; display: flex; flex-direction: column; }
  .expert-bar .who-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
  .expert-bar .who-topic { font-size: 13px; color: var(--c-stone); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .you { max-width: 85%; }
  .reply-body { font-size: 16px; }
  .ask-form { padding: 12px 0 24px; }
  .expert-card { grid-template-columns: minmax(0, 1fr); }
  .expert-card > div + div { border-left: 0; border-top: 1px solid var(--c-rule-2); }
  .nav { gap: 8px 20px; }
}

/* The expert page's footer carries only the legal bar. */
.site-footer.slim .container { padding-top: 0; }
