/* ==========================================================================
   Hampton Network · AI CEO — Stylesheet
   Brand colors: Black #000000 · Red #DC2626 · Grey #6B7280 · White #FFFFFF
   ========================================================================== */

:root {
  /* Brand */
  --hn-black:    #000000;
  --hn-red:      #DC2626;
  --hn-red-700:  #B91C1C;
  --hn-grey:     #6B7280;
  --hn-white:    #FFFFFF;

  /* Light theme (default) */
  --bg:          #FAFAFA;
  --bg-elev:     #FFFFFF;
  --bg-muted:    #F3F4F6;
  --text:        #0A0A0A;
  --text-muted:  #4B5563;
  --border:      #E5E7EB;
  --accent:      var(--hn-red);
  --accent-ink:  #FFFFFF;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:   0 20px 40px rgba(0,0,0,.12), 0 8px 16px rgba(0,0,0,.08);

  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   22px;
  --radius-pill: 999px;

  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg:          #0A0A0A;
  --bg-elev:     #141414;
  --bg-muted:    #1C1C1C;
  --text:        #F5F5F5;
  --text-muted:  #A3A3A3;
  --border:      #2A2A2A;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,.45);
  --shadow-lg:   0 20px 40px rgba(0,0,0,.6);
}

/* =========== Reset / base ================================================ */
*,*::before,*::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
img, video { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 2.4vw, 2rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p  { margin: 0 0 1em; }
code { font-family: var(--font-mono); background: var(--bg-muted); padding: 2px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.accent { color: var(--accent); }

/* =========== Nav ========================================================= */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: .9rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--text);
  font-weight: 700;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 40px;
  height: 40px;
  display: block;
  object-fit: contain;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.04);
}
[data-theme="dark"] .brand-logo {
  box-shadow: 0 0 0 1px rgba(255,255,255,.08);
}
.brand-name { font-size: 1rem; }
.brand-sub  { color: var(--text-muted); font-weight: 500; }

.icon-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  display: grid; place-items: center;
  transition: transform .12s ease, background .2s ease;
}
.icon-btn:hover { transform: translateY(-1px); background: var(--bg-muted); }

/* =========== Buttons ===================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid transparent;
  background: var(--bg-elev);
  color: var(--text);
  padding: .7rem 1.1rem;
  font-size: .95rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease, border-color .2s ease;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary {
  background: var(--hn-red);
  color: var(--hn-white);
  border-color: var(--hn-red);
}
.btn-primary:hover { background: var(--hn-red-700); border-color: var(--hn-red-700); }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg-muted); }
.btn-lg { padding: .95rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: .45rem .8rem; font-size: .85rem; border-radius: 10px; }

/* =========== Hero ======================================================== */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4.5rem) 1.2rem 3rem;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
}
@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
}
.eyebrow {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--hn-red);
  margin-bottom: .8rem;
}
.lede {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 58ch;
  margin: 1rem 0 1.7rem;
}
.hero-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.8rem;
}
.hero-badges {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.hero-badges li {
  padding: .45rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-elev);
  font-size: .85rem;
  color: var(--text-muted);
}

/* Avatar preview (hero) */
.hero-visual { display: grid; place-items: center; }
.avatar-preview {
  position: relative;
  width: min(420px, 90%);
  aspect-ratio: 1 / 1.1;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--hn-black) 0%, #1a1a1a 60%, #2a0a0a 100%);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.avatar-preview::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(closest-side at 50% 40%, rgba(220,38,38,.22), transparent 65%);
  z-index: 1;
  pointer-events: none;
}

/* Perry's portrait on the hero */
.hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  z-index: 2;
}
.hero-photo.failed { display: none; }

/* Fallback (ring + "AI CEO" text) only shows if photo fails to load */
.hero-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  z-index: 1;
}
.hero-photo:not(.failed) ~ .hero-fallback { display: none; }
.avatar-face {
  position: relative;
  z-index: 2;
  width: 58%; aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(145deg, #2c2c2c, #0a0a0a);
  border: 3px solid var(--hn-red);
  display: grid; place-items: center;
  color: var(--hn-white);
  font-weight: 800;
  font-size: 1.35rem;
  text-align: center;
  line-height: 1.05;
  letter-spacing: .04em;
  box-shadow: 0 10px 40px rgba(220,38,38,.35);
}
.avatar-face.lg { width: 72%; font-size: 1.9rem; }
.avatar-initials { display: block; }
.avatar-ring {
  position: absolute;
  width: 78%; aspect-ratio: 1;
  border-radius: 50%;
  border: 2px dashed rgba(220,38,38,.5);
  animation: spin 22s linear infinite;
  z-index: 1;
}
.avatar-ring.lg { width: 88%; }
@keyframes spin { to { transform: rotate(360deg); } }
.avatar-caption {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 28px 14px 14px;
  text-align: center;
  color: rgba(255,255,255,.96);
  font-size: .85rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  z-index: 3;
  background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
  text-shadow: 0 1px 4px rgba(0,0,0,.65);
}

/* =========== How ========================================================= */
.how {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}
.how h2 { margin-bottom: 1.5rem; }
.how-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 800px) { .how-steps { grid-template-columns: 1fr; } }
.step {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
}
.step-num {
  position: absolute; top: -14px; left: 16px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--hn-red);
  color: var(--hn-white);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: .85rem;
  box-shadow: var(--shadow-sm);
}
.step h3 { margin-top: .25rem; }
.step p  { margin: 0; color: var(--text-muted); font-size: .95rem; }

/* =========== Modal (onboarding) ========================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 1rem;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal[hidden] { display: none; }
.modal-panel {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem;
  border: 1px solid var(--border);
}
.modal-header { margin-bottom: 1.2rem; }
.modal-header h2 { margin: 0 0 .3rem; }
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; }
.field > span { font-weight: 600; font-size: .95rem; }
.field em { font-style: normal; }
.field input, .field select {
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--hn-red);
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .7rem;
  margin-top: .5rem;
}

/* =========== Conversation view =========================================== */
.conv {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.2rem;
}
.conv[hidden] { display: none; }
.conv-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 1.2rem;
  align-items: start;
}
@media (max-width: 900px) {
  .conv-layout { grid-template-columns: 1fr; }
}

/* Avatar panel */
.conv-avatar {
  position: sticky;
  top: 80px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 900px) {
  .conv-avatar { position: relative; top: 0; }
}
.avatar-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.05;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(160deg, var(--hn-black), #1a1a1a 60%, #2a0a0a);
}
.avatar-video {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Perry's portrait — fills the stage. If it fails to load, the .failed class
   hides it and the animated placeholder takes over. */
.avatar-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center top;
  z-index: 2;
}
.avatar-photo.failed { display: none; }

/* When the portrait loads successfully, hide the animated placeholder. */
.avatar-photo:not(.failed) ~ .avatar-placeholder { display: none; }

.avatar-placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  z-index: 1;
}
.avatar-placeholder::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(closest-side at 50% 40%, rgba(220,38,38,.25), transparent 60%);
}

/* Audio waveform canvas — bottom band of the stage */
.waveform {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 72px;
  display: block;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
}
.waveform.active { opacity: 1; }

.avatar-status {
  position: absolute;
  bottom: 14px; left: 0; right: 0;
  text-align: center;
  margin: 0;
  color: rgba(255,255,255,.95);
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 600;
  z-index: 4;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
.avatar-meta {
  margin-top: .75rem;
  padding: .5rem .25rem 0;
  display: grid;
  gap: .15rem;
}

/* Chat panel */
.conv-chat {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: .75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .9rem;
  min-height: 70vh;
  box-shadow: var(--shadow-sm);
}
.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  justify-content: space-between;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}
.toolbar-right { display: flex; flex-wrap: wrap; gap: .4rem; }
.inline {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.inline select {
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
}

/* Chat log */
.chat-log {
  overflow-y: auto;
  padding: .5rem .25rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  max-height: 60vh;
}
.msg {
  display: flex;
  gap: .65rem;
  max-width: 85%;
  animation: pop .2s ease;
}
@keyframes pop { from { transform: translateY(4px); opacity: 0; } }
.msg.user { margin-left: auto; flex-direction: row-reverse; }
.msg-bubble {
  padding: .7rem .9rem;
  border-radius: 14px;
  background: var(--bg-muted);
  color: var(--text);
  font-size: .95rem;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
/* User/system bubbles keep line breaks from plain text */
.msg.user .msg-bubble,
.msg.system .msg-bubble { white-space: pre-wrap; }

/* Rich-text elements inside bot bubbles */
.msg.bot .msg-bubble p            { margin: 0 0 .6em; }
.msg.bot .msg-bubble p:last-child { margin-bottom: 0; }
.msg.bot .msg-bubble h1,
.msg.bot .msg-bubble h2,
.msg.bot .msg-bubble h3,
.msg.bot .msg-bubble h4 {
  margin: .6em 0 .35em;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}
.msg.bot .msg-bubble h1 { font-size: 1.1rem; }
.msg.bot .msg-bubble h2 { font-size: 1.05rem; }
.msg.bot .msg-bubble h3 { font-size: 1rem; }
.msg.bot .msg-bubble h4 { font-size: .95rem; }
.msg.bot .msg-bubble ul,
.msg.bot .msg-bubble ol {
  margin: .4em 0 .6em;
  padding-left: 1.35em;
}
.msg.bot .msg-bubble li           { margin: .2em 0; }
.msg.bot .msg-bubble li::marker   { color: var(--hn-red); font-weight: 700; }
.msg.bot .msg-bubble strong,
.msg.bot .msg-bubble b            { font-weight: 700; color: var(--text); }
.msg.bot .msg-bubble em,
.msg.bot .msg-bubble i            { font-style: italic; }
.msg.bot .msg-bubble a {
  color: var(--hn-red);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}
.msg.bot .msg-bubble a:hover      { color: var(--hn-red-700); }
.msg.bot .msg-bubble code {
  font-family: var(--font-mono);
  font-size: .88em;
  padding: 1px 5px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--hn-red) 12%, transparent);
  color: var(--text);
}
.msg.bot .msg-bubble pre {
  margin: .5em 0;
  padding: .6em .75em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: .85em;
  line-height: 1.45;
}
.msg.bot .msg-bubble pre code {
  background: transparent;
  padding: 0;
}
.msg.bot .msg-bubble blockquote {
  margin: .5em 0;
  padding: .35em .8em;
  border-left: 3px solid var(--hn-red);
  color: var(--text-muted);
  font-style: italic;
}
.msg.bot .msg-bubble hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: .75em 0;
}
.msg.user .msg-bubble {
  background: var(--hn-red);
  color: var(--hn-white);
  border-bottom-right-radius: 4px;
}
.msg.bot .msg-bubble { border-bottom-left-radius: 4px; }
.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: .75rem;
  font-weight: 800;
  flex-shrink: 0;
  background: var(--hn-black);
  color: var(--hn-white);
  border: 2px solid var(--hn-red);
}
.msg.user .msg-avatar {
  background: var(--hn-red);
  border-color: var(--hn-black);
}
.msg.system .msg-bubble {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: .85rem;
  font-style: italic;
}
.typing .msg-bubble::after {
  content: "…";
  animation: dots 1.2s infinite;
}
@keyframes dots {
  0%, 20% { content: "."; }
  40%     { content: ".."; }
  60%,100% { content: "..."; }
}

/* Chat input */
.chat-input {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding-top: .6rem;
  border-top: 1px solid var(--border);
}
.chat-input input {
  flex: 1;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
}
.chat-input input:focus {
  outline: none;
  border-color: var(--hn-red);
  box-shadow: 0 0 0 3px rgba(220,38,38,.15);
}
.mic-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s ease, transform .12s ease, box-shadow .2s ease;
  flex-shrink: 0;
}
.mic-btn:hover { transform: translateY(-1px); background: var(--bg-muted); }
.mic-btn.listening {
  background: var(--hn-red);
  color: var(--hn-white);
  border-color: var(--hn-red);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.45); }
  50%      { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
}

/* =========== Footer ====================================================== */
.foot {
  margin-top: 3rem;
  padding: 1.5rem 1.2rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.foot-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: .9rem;
}

/* =========== Utilities =================================================== */
[hidden] { display: none !important; }
::selection { background: var(--hn-red); color: var(--hn-white); }
