/* Mike Yam Powers AI */

:root {
  --bg: #f1f0ed;
  --panel: #ffffff;
  --text: #1f1f1d;
  --muted: #6c6c66;
  --border: #dcdbd6;
  --mike-bubble: #eeede9;
  --you-bubble: #262624;
  --accent: #c8232c;
  --accent-dark: #a51b23;
  --header-h: 56px;
  --stage-h: calc(100dvh - var(--header-h));
  color-scheme: light;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- header ---------- */

.site-header {
  flex: none;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand span { color: var(--accent); }

.new-chat {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
.new-chat:hover { background: var(--bg); }

/* ---------- layout ---------- */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 560px);
}

/* ---------- Mike ---------- */

.stage {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 0;
}

/* Everything inside .figure is sized in cqw (1% of the figure's width),
   so the head and body always stay lined up whatever the screen size. */
.figure {
  position: relative;
  flex: none;
  width: min(100%, calc(var(--stage-h) * 0.756));
  aspect-ratio: 620 / 820;
  container-type: inline-size;
  user-select: none;
  -webkit-user-select: none;
}

.torso {
  position: absolute;
  left: -11cqw;
  top: 72.5cqw;
  width: 122cqw;
  height: auto;
  pointer-events: none;
}

/* The chin comes down over the neck: head bottom (about 91cqw) sits just past the collar. */
.head {
  position: absolute;
  left: 24cqw;
  top: 11cqw;
  width: 52cqw;
  aspect-ratio: 360 / 590;
  cursor: default;
}

.head img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  -webkit-user-drag: none;
}
.head img.on { opacity: 1; }

/* ---------- chat ---------- */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 28px 12px;
  scroll-behavior: smooth;
}

.msg { max-width: 82%; }
.msg.mike { align-self: flex-start; }
.msg.you  { align-self: flex-end; }

.who {
  margin: 0 2px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.msg.you .who { text-align: right; }

.bubble {
  padding: 10px 14px;
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.msg.mike .bubble {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--mike-bubble);
  border-top-left-radius: 4px;
}
.msg.you .bubble {
  background: var(--you-bubble);
  color: #fff;
  border-top-right-radius: 4px;
}

/* words fade in as Mike says them */
.w { opacity: 0; }
.w.on { opacity: 1; }

.speak {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: -1px -6px -1px 0;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.speak:hover { color: var(--text); background: rgba(0, 0, 0, 0.07); }

/* "Mike is typing" */
.dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.dots i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #9a9a94;
  animation: blink 1.1s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 70%, 100% { opacity: 0.3; }
  35% { opacity: 1; }
}

/* ---------- composer ---------- */

.composer {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 14px 24px 8px;
  border-top: 1px solid var(--border);
}

.composer input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #c9c8c2;
  border-radius: 8px;
}
.composer input::placeholder { color: #8d8d86; }
.composer input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.composer button {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.composer button:hover:not(:disabled) { background: var(--accent-dark); }
.composer button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.composer button:disabled { background: #d8d7d2; cursor: default; }

.fineprint {
  flex: none;
  margin: 0;
  padding: 0 24px 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.noscript {
  position: fixed; left: 0; right: 0; bottom: 0;
  margin: 0; padding: 12px; text-align: center;
  background: var(--accent); color: #fff;
}

/* ---------- phones and narrow windows ---------- */

@media (max-width: 820px) {
  :root {
    --header-h: 48px;
    --stage-h: 42dvh;
  }

  .site-header { padding: 0 16px; }
  .brand { font-size: 16px; }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--stage-h) minmax(0, 1fr);
  }

  .chat { border-left: 0; border-top: 1px solid var(--border); }
  .messages { padding: 18px 16px 8px; gap: 14px; }
  .msg { max-width: 88%; }
  .composer { padding: 10px 14px 6px; }
  .fineprint { padding: 0 14px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .messages { scroll-behavior: auto; }
  .dots i { animation: none; opacity: 0.6; }
}
