/* Phone companion (mobile.html), in the site's look. site.css gives the tokens, type, buttons and the
   light and dark switch; this file lays out the companion's three screens: sign in, ready, and a session
   where you tap when a question starts and tap again when it ends. */

html, body { height: 100%; }
body.cp { display: flex; flex-direction: column; min-height: 100dvh; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
.cp-pad { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* top bar */
.cp-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding-top: calc(env(safe-area-inset-top, 0px) + 10px); padding-bottom: 10px; background: color-mix(in srgb, var(--ground) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.cp-brand { display: flex; align-items: center; gap: 8px; margin-right: auto; min-width: 0; text-decoration: none; }
.cp-brand img { width: 26px; height: 26px; }
.cp-brand span { font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; white-space: nowrap; }
.cp-balance { display: none; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px; background: var(--emerald-deep); color: var(--emerald); font-weight: 700; font-size: 13px; white-space: nowrap; }
.cp-balance svg { width: 14px; height: 14px; }
.cp-icon-btn { display: none; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--raised); color: var(--cream-soft); place-items: center; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.cp-icon-btn svg { width: 17px; height: 17px; }

/* the three screens: mobile.js switches them with .active */
main.cp-main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cp-view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.cp-view.active { display: flex; }
.cp-screen { width: 100%; max-width: 520px; margin: 0 auto; padding-block: 30px 32px; display: grid; gap: 22px; align-content: start; }
.cp-screen h1 { font-size: clamp(38px, 11vw, 46px); }
.cp-lead { margin: 0; color: var(--cream-soft); font-size: 17px; line-height: 1.45; }
.cp-note { margin: 0; color: var(--cream-muted); font-size: 14px; line-height: 1.5; text-align: center; }
.cp-note a { color: var(--emerald); font-weight: 600; }

/* sign in: what the companion does, in three steps */
.cp-how { list-style: none; margin: 0; padding: 0; display: grid; counter-reset: how; border-top: 1px solid var(--line); }
.cp-how li { counter-increment: how; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: baseline; padding-block: 14px; border-bottom: 1px solid var(--line); font-size: 16px; line-height: 1.4; color: var(--cream-soft); }
.cp-how li::before { content: counter(how); font-family: var(--display); font-weight: 900; font-size: 26px; line-height: 0.8; color: transparent; -webkit-text-stroke: 1.3px var(--emerald); }
.cp-how b { color: var(--cream); font-weight: 600; }
.cp-signin-btn { height: 54px; }

/* ready */
.cp-context { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); color: inherit; text-align: left; cursor: pointer; }
.cp-context-ico { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--emerald-deep); color: var(--emerald); }
.cp-context-ico svg { width: 20px; height: 20px; }
.cp-context b { display: block; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-context small { display: block; color: var(--cream-muted); font-size: 13px; margin-top: 2px; }
.cp-context .cp-edit { color: var(--emerald); font-weight: 700; font-size: 14px; }
/* Call language: the whole row opens the phone's own list */
.cp-lang { position: relative; }
.cp-lang-pick { position: relative; display: flex; align-items: center; gap: 6px; color: var(--emerald); font-weight: 700; font-size: 14px; }
.cp-lang-pick::after { content: ""; width: 7px; height: 7px; margin-top: -4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); pointer-events: none; }
.cp-lang select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: inherit; font: inherit; text-align: right; text-align-last: right; padding: 0; max-width: 130px; cursor: pointer; }
.cp-lang select:focus-visible { outline: 2px solid var(--emerald); outline-offset: 4px; border-radius: 4px; }
.cp-lang select option { color: var(--cream); background: var(--raised); }
.cp-tip { display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start; margin: 0; padding: 14px; border-radius: 16px; background: color-mix(in srgb, var(--emerald) 7%, var(--ground)); border: 1px solid color-mix(in srgb, var(--emerald) 30%, var(--line)); color: var(--cream-soft); font-size: 15px; line-height: 1.45; }
.cp-tip svg { width: 22px; height: 22px; color: var(--emerald); margin-top: 1px; }
.cp-start { height: 58px; }
.cp-start .loader { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--ground) 40%, transparent); border-top-color: var(--ground); animation: cp-spin 0.8s linear infinite; }
.cp-start svg { width: 18px; height: 18px; }

/* in a session */
.cp-status { display: flex; align-items: center; gap: 10px; padding-block: 10px; border-bottom: 1px solid var(--line); background: var(--ground); }
.cp-live { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.cp-live i { width: 9px; height: 9px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sun) 25%, transparent); animation: cp-pulse 1.8s ease-in-out infinite; }
@keyframes cp-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--sun) 0%, transparent); } }
.cp-timer { font-variant-numeric: tabular-nums; color: var(--cream-soft); font-weight: 600; }
.cp-free:not(:empty) { padding: 2px 8px; border-radius: 999px; background: var(--raised-2); color: var(--cream-muted); font-size: 12px; font-weight: 600; }
.cp-fill { flex: 1; }
.cp-end { height: 36px; padding: 0 16px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); font-weight: 700; font-size: 15px; cursor: pointer; }

.cp-chat { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 14px; padding-block: 16px 12px; }
.cp-empty { margin: auto; max-width: 30ch; display: grid; justify-items: center; gap: 10px; text-align: center; color: var(--cream-soft); font-size: 16px; line-height: 1.45; }
.cp-empty-steps { display: flex; align-items: center; gap: 10px; color: var(--cream-muted); font-size: 13px; font-weight: 600; }
.cp-empty-steps span { display: inline-flex; align-items: center; gap: 6px; }
.cp-empty-steps i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--emerald); color: var(--ground); font-style: normal; font-size: 12px; font-weight: 800; }
.cp-empty-steps i.stop { background: var(--sun); color: #fff; }
.cp-empty b { color: var(--cream); font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: -0.02em; text-transform: lowercase; }

/* one question and its answer */
.cp-turn { display: grid; gap: 10px; padding: 14px 14px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); }
.cp-q { display: flex; gap: 8px; align-items: flex-start; color: var(--cream-muted); font-size: 14px; line-height: 1.45; }
.cp-q-tag { flex: none; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--raised-2); color: var(--cream-soft); font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 20px; }
.cp-a { color: var(--cream); font-size: 17px; line-height: 1.55; overflow-wrap: anywhere; }
.cp-a p { margin: 0 0 10px; }
.cp-a p:last-child { margin-bottom: 0; }
.cp-a ol, .cp-a ul { margin: 6px 0 10px; padding-left: 22px; }
.cp-a li { margin-bottom: 6px; }
.cp-a strong { font-weight: 700; }
.cp-a .md-h1, .cp-a .md-h2, .cp-a .md-h3 { font-weight: 700; margin: 4px 0 8px; }
.cp-a.streaming::after { content: ""; display: inline-block; width: 8px; height: 17px; margin-left: 3px; vertical-align: -3px; border-radius: 2px; background: var(--emerald); animation: cp-blink 1s step-end infinite; }
@keyframes cp-blink { 50% { opacity: 0; } }
.cp-turn-foot { display: flex; align-items: center; justify-content: space-between; color: var(--cream-muted); font-size: 12px; }
.cp-copy { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px; margin-right: -6px; border: 0; border-radius: 8px; background: none; color: var(--cream-muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.cp-copy svg { width: 13px; height: 13px; }
.cp-copy.copied { color: var(--emerald); }
/* what it hears while you hold the question open */
.cp-hearing { display: grid; gap: 6px; padding: 14px; border: 1.5px dashed color-mix(in srgb, var(--sun) 55%, var(--line)); border-radius: 16px; color: var(--cream); font-size: 17px; line-height: 1.5; }
.cp-hearing small { display: flex; align-items: center; gap: 7px; color: var(--sun); font-size: 12px; font-weight: 700; }
.cp-hearing small i { width: 7px; height: 7px; border-radius: 50%; background: var(--sun); animation: cp-pulse 1.4s ease-in-out infinite; }
.cp-hearing.empty .cp-hearing-text::before { content: "Listening for the question"; color: var(--cream-muted); }

/* the big tap button */
.cp-dock { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-top: 12px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--ground) 28%); }
.cp-side { justify-self: start; display: grid; justify-items: center; gap: 3px; padding: 6px 8px; border: 0; background: none; color: var(--cream-muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.cp-side svg { width: 20px; height: 20px; }
.cp-mic-wrap { display: grid; justify-items: center; gap: 8px; }
.cp-mic { position: relative; width: 86px; height: 86px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--emerald); color: #fff; cursor: pointer; box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--emerald) 80%, transparent); transition: transform 0.12s ease, background 0.2s ease; touch-action: manipulation; }
.cp-mic:active { transform: scale(0.95); }
.cp-mic .mic-icon { width: 34px; height: 34px; }
.cp-mic .stop-icon { display: none; width: 26px; height: 26px; }
.cp-mic.recording { background: var(--sun); box-shadow: 0 0 0 0 color-mix(in srgb, var(--sun) 50%, transparent); animation: cp-ring 1.5s ease-out infinite; }
.cp-mic.recording .mic-icon { display: none; }
.cp-mic.recording .stop-icon { display: block; }
@keyframes cp-ring { 70%, 100% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--sun) 0%, transparent); } }
.cp-mic.thinking { background: var(--raised-2); color: var(--cream); box-shadow: none; }
.cp-mic.thinking .mic-icon, .cp-mic.thinking .stop-icon { display: none; }
.cp-mic .mic-spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--emerald); animation: cp-spin 0.8s linear infinite; }
@keyframes cp-spin { to { transform: rotate(360deg); } }
.cp-mic-label { min-height: 20px; color: var(--cream); font-weight: 700; font-size: 15px; text-align: center; white-space: nowrap; }

/* call details: a sheet from the bottom */
.cp-sheet-wrap { position: fixed; inset: 0; z-index: 40; display: none; align-items: flex-end; justify-content: center; background: rgb(0 0 0 / 0.55); }
.cp-sheet-wrap.active { display: flex; }
.cp-sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; display: grid; gap: 16px; padding: 10px max(16px, env(safe-area-inset-left, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 20px 20px 0 0; background: var(--raised); border: 1px solid var(--line); border-bottom: 0; animation: cp-up 0.28s cubic-bezier(.2, .8, .2, 1); }
@keyframes cp-up { from { transform: translateY(40px); opacity: 0; } }
.cp-sheet .grab { justify-self: center; width: 38px; height: 4px; border-radius: 4px; background: var(--line); }
.cp-sheet h2 { font-size: 32px; }
.cp-sheet > p { margin: -6px 0 0; color: var(--cream-soft); }
.cp-field { display: grid; gap: 6px; }
.cp-field label { font-weight: 600; font-size: 15px; }
.cp-field label span { color: var(--cream-muted); font-weight: 500; }
.cp-field input, .cp-field textarea { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--ground); color: var(--cream); font: inherit; font-size: 16px; line-height: 1.4; }
.cp-field textarea { resize: vertical; min-height: 90px; }
.cp-field input:focus, .cp-field textarea:focus { outline: none; border-color: var(--emerald); box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 20%, transparent); }
.cp-field small { color: var(--cream-muted); font-size: 12px; text-align: right; }
.cp-sheet-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.cp-ghost { height: 56px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--cream); font-weight: 600; font-size: 17px; cursor: pointer; }

/* messages */
.cp-toast { position: fixed; z-index: 60; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px; background: var(--cream); color: var(--ground); font-size: 14px; font-weight: 600; line-height: 1.35; text-align: center; box-shadow: 0 16px 40px -14px rgb(0 0 0 / 0.5); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity 0.2s ease, transform 0.2s ease; }
.cp-toast.show { opacity: 1; transform: translate(-50%, 0); }
.cp-desk-tip { position: fixed; z-index: 50; top: calc(env(safe-area-inset-top, 0px) + 66px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px); padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--cream); color: var(--ground); font-size: 14px; font-weight: 600; box-shadow: 0 16px 40px -14px rgb(0 0 0 / 0.5); }
.cp-desk-tip a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.cp-desk-tip button { width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: inherit; opacity: 0.7; cursor: pointer; font-size: 18px; line-height: 1; }


/* the words it hears right now, under the timer */
.cp-heard { display: flex; align-items: center; gap: 9px; padding-block: 9px; border-bottom: 1px solid var(--line); background: var(--raised); color: var(--cream-muted); font-size: 14px; }
.cp-heard i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--cream-muted); }
/* the dot grows with the sound the phone hears (--lvl, 0 to 1, set by mobile.js) */
.cp-heard i { transform: scale(calc(1 + var(--lvl, 0) * 0.9)); transition: transform .12s ease-out, background-color .2s; }
.cp-heard.sound i { background: var(--emerald); }
.cp-heard.on { color: var(--cream-soft); }
.cp-heard.on i { background: var(--emerald); box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 22%, transparent); }
.cp-heard-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; }
.cp-heard-text bdi { direction: ltr; unicode-bidi: isolate; }

/* while the answer is on its way */
.cp-dots { display: inline-flex; gap: 5px; padding: 6px 0; }
.cp-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--cream-muted); animation: cp-dot 1s ease-in-out infinite; }
.cp-dots i:nth-child(2) { animation-delay: 0.15s; }
.cp-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cp-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cp-a.streaming:has(.cp-dots)::after { display: none; }

/* answers as on the desktop: steps, points, bold, tables and code */
.cp-a h1, .cp-a h2, .cp-a h3, .cp-a h4 { margin: 6px 0 8px; font-size: 17px; font-weight: 700; line-height: 1.35; }
.cp-a ul ul, .cp-a ol ul, .cp-a ul ol { margin: 4px 0; }
.cp-a :not(pre) > code { font-family: var(--mono); font-size: 14px; padding: 1px 5px; border-radius: 5px; background: var(--raised-2); }
.cp-a table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 8px 0 10px; font-size: 15px; }
.cp-a th, .cp-a td { padding: 6px 10px; border: 1px solid var(--line); text-align: left; }
.cp-a blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--cream-soft); }
.cp-a .md-code { margin: 8px 0 12px; overflow: hidden; border: 1px solid #263238; border-radius: 12px; background: #0F1619; }
.cp-a .md-code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 12px; border-bottom: 1px solid #263238; color: #8A9AA1; font: 500 12px var(--mono); }
.cp-a .md-code-copy { height: 28px; padding: 0 10px; border: 1px solid #263238; border-radius: 7px; background: #141D21; color: #D3DCDF; font-size: 12px; font-weight: 600; cursor: pointer; }
.cp-a .md-code-copy.copied { color: #10B981; }
.cp-a .md-code pre { margin: 0; padding: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cp-a .md-code code { padding: 0; background: none; color: #E4E7E6; font-size: 13px; line-height: 1.55; white-space: pre; }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-literal { color: #C586C0; }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: #DCDCAA; }
.hljs-string, .hljs-attr, .hljs-template-string { color: #CE9178; }
.hljs-number, .hljs-symbol { color: #B5CEA8; }
.hljs-comment, .hljs-quote { color: #6A9955; font-style: italic; }
.hljs-type, .hljs-class .hljs-title, .hljs-title.class_ { color: #4EC9B0; }
.hljs-variable, .hljs-params, .hljs-property { color: #9CDCFE; }
.hljs-meta { color: #569CD6; }


/* wider screens: the call details sheet becomes a centred card */
@media (min-width: 760px) {
  .cp-sheet-wrap { align-items: center; padding: 24px; }
  .cp-sheet { border-radius: 20px; border-bottom: 1px solid var(--line); padding: 24px; max-height: calc(100dvh - 48px); }
  .cp-sheet .grab { display: none; }
}

@media (prefers-reduced-motion: reduce) { .cp-mic.recording, .cp-live i, .cp-hearing small i { animation: none; } }

/* "Watch how it works": the how-to video, played over the page */
.cp-watch { justify-self: center; display: inline-flex; align-items: center; gap: 10px; padding: 7px 16px 7px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--raised); color: var(--cream); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; transition: border-color 0.15s ease; }
.cp-watch:hover { border-color: var(--emerald); }
.cp-watch i { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--emerald); color: var(--ground); }
.cp-watch i svg { margin-left: 2px; }
.cp-watch span { color: var(--cream-muted); font-weight: 500; }
.cp-video { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 64px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); background: rgb(5 8 10 / 0.88); }
.cp-video[hidden] { display: none; }
.cp-video-box { position: relative; width: min(1100px, 100%); }
.cp-video video { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; background: #0F1619; box-shadow: 0 30px 80px rgb(0 0 0 / 0.6); }
.cp-video-x { position: absolute; right: 0; top: -50px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgb(255 255 255 / 0.25); background: rgb(255 255 255 / 0.08); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
