/* =========================================================================
   TYGR Academy
   Tokens, fonts and type follow tygrwellness.com (src/styles/global.css in
   tygr_landing). Dark is the default; light follows the device setting.
   The Academy accent (gold) marks only Academy things: badges, borders, icons.
   ========================================================================= */

/* ---------- Fonts ---------- */
@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/bricolage-grotesque-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/bricolage-grotesque-latin-800-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/figtree-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/figtree-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/figtree-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/figtree-latin-ext-600-normal.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Figtree Fallback'; src: local('Arial'), local('Roboto'), local('Helvetica Neue'); size-adjust: 101.72%; ascent-override: 93.39%; descent-override: 24.58%; line-gap-override: 0%; }
@font-face { font-family: 'Bricolage Fallback'; src: local('Arial'), local('Roboto'), local('Helvetica Neue'); size-adjust: 112.14%; ascent-override: 82.93%; descent-override: 24.08%; line-gap-override: 0%; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #0b0a09;
  --surface: #151311;
  --surface-2: #1e1b18;
  --text: #f5f1ea;
  --muted: #a39b8f;
  --fire: #ff6a00;
  --gold: #ffb300;
  --gradient: linear-gradient(135deg, #ff6a00, #ffb300);
  --on-gradient: #1a0d02;
  --line: rgb(245 241 234 / 0.1);
  --line-strong: rgb(245 241 234 / 0.2);
  --focus: #ffb300;
  --danger: #ff8f80;
  --success: #5fd8a8;
  --academy: #ffb300;
  --academy-ink: #ffb300;
  --user-bubble: #2a2520;

  --font-display: 'Bricolage Grotesque', 'Bricolage Fallback', system-ui, sans-serif;
  --font-body: 'Figtree', 'Figtree Fallback', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --step--1: 0.882rem;
  --step-0: 1rem;
  --step-1: 1.2rem;
  --step-2: clamp(1.4rem, 1.25rem + 0.6vw, 1.7rem);
  --step-3: clamp(1.75rem, 1.45rem + 1.3vw, 2.4rem);
  --step-4: clamp(2.1rem, 1.6rem + 2.2vw, 3.3rem);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --pill: 999px;
  --gutter: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    color-scheme: light;
    --bg: #faf7f2;
    --surface: #ffffff;
    --surface-2: #f1ece4;
    --text: #1a1714;
    --muted: #6b6358;
    --fire: #c2410c;
    --gold: #b45309;
    --line: rgb(26 23 20 / 0.12);
    --line-strong: rgb(26 23 20 / 0.24);
    --focus: #c2410c;
    --danger: #b42318;
    --success: #067647;
    --academy-ink: #b45309;
    --user-bubble: #f1ece4;
  }
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f1ece4;
  --text: #1a1714;
  --muted: #6b6358;
  --fire: #c2410c;
  --gold: #b45309;
  --line: rgb(26 23 20 / 0.12);
  --line-strong: rgb(26 23 20 / 0.24);
  --focus: #c2410c;
  --danger: #b42318;
  --success: #067647;
  --academy-ink: #b45309;
  --user-bubble: #f1ece4;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  font-size: 106.25%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}
@media (min-width: 960px) { html { font-size: 112.5%; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  overflow-x: clip;
}
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h1 { font-weight: 800; font-size: var(--step-4); line-height: 1.06; letter-spacing: -0.025em; }
h2 { font-weight: 800; font-size: var(--step-3); line-height: 1.1; letter-spacing: -0.02em; }
h3 { font-weight: 600; font-size: var(--step-1); line-height: 1.3; }
p, ul, ol { margin: 0; }
p { text-wrap: pretty; }
strong { font-weight: 600; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--fire); text-underline-offset: 0.2em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
main:focus { outline: none; }
::selection { background: color-mix(in srgb, var(--fire) 35%, transparent); color: var(--text); }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -100px; z-index: 200;
  padding: 12px 18px;
  background: var(--text); color: var(--bg);
  font-weight: 600; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }

/* ---------- Icons: Lucide SVGs used as masks, so they take the text colour ---------- */
.icon {
  display: inline-block;
  flex: none;
  width: 1.15em; height: 1.15em;
  background: currentColor;
  mask: var(--i) center / contain no-repeat;
  vertical-align: -0.2em;
}
.i-apple { --i: url('/icons/apple.svg'); }
.i-arrow-right { --i: url('/icons/arrow-right.svg'); }
.i-arrow-up { --i: url('/icons/arrow-up.svg'); }
.i-book { --i: url('/icons/book.svg'); }
.i-brain { --i: url('/icons/brain.svg'); }
.i-chats { --i: url('/icons/chats.svg'); }
.i-clock { --i: url('/icons/clock.svg'); }
.i-dumbbell { --i: url('/icons/dumbbell.svg'); }
.i-exit { --i: url('/icons/exit.svg'); }
.i-heart-pulse { --i: url('/icons/heart-pulse.svg'); }
.i-lifebuoy { --i: url('/icons/lifebuoy.svg'); }
.i-lock { --i: url('/icons/lock.svg'); }
.i-plus { --i: url('/icons/plus.svg'); }
.i-square { --i: url('/icons/square.svg'); }
.i-trash { --i: url('/icons/trash.svg'); }
.i-user { --i: url('/icons/user.svg'); }
.i-x { --i: url('/icons/x.svg'); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.3rem;
  border: 1px solid transparent;
  border-radius: var(--pill);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background-color 0.15s var(--ease);
}
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-fire { background: var(--gradient); color: var(--on-gradient); }
.btn-fire:hover:not(:disabled) { transform: translateY(-1px); }
.btn-quiet { min-height: 44px; padding: 0 1rem; background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-quiet:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px;
  padding: 0;
  border: 0; border-radius: var(--pill);
  background: transparent; color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.link-btn {
  min-height: 44px;
  padding: 0;
  border: 0; background: none;
  color: var(--fire);
  text-decoration: underline; text-underline-offset: 0.2em;
  cursor: pointer;
}

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 64px;
  padding: 10px max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo { display: inline-flex; align-items: center; gap: 0.55rem; min-height: 44px; color: var(--text); text-decoration: none; }
.logo-mark { width: 26px; }
.logo-word { font: 800 1.35rem / 1 var(--font-display); letter-spacing: 0.02em; }
.logo-wing {
  padding: 0.15rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--academy) 55%, transparent);
  border-radius: var(--pill);
  color: var(--academy-ink);
  font: 600 var(--step--1) / 1.4 var(--font-body);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-email { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: var(--step--1); }
@media (max-width: 640px) { .account-email { display: none; } }
/* Small phones: the mark and the Academy badge carry the brand, so the
   header still fits Sign out and Exit on one line at 360px. */
@media (max-width: 400px) {
  .logo-word { display: none; }
  .topbar-actions { gap: 6px; }
  .btn-quiet { padding: 0 0.85rem; }
}
.exit {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 44px;
  padding: 0 0.95rem 0 1.05rem;
  border-radius: var(--pill);
  background: var(--text); color: var(--bg);
  font: 700 var(--step--1) / 1 var(--font-body);
  text-decoration: none;
}

/* ---------- Page ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }
.hero { padding: clamp(3rem, 2rem + 5vw, 6rem) 0 clamp(2.5rem, 2rem + 3vw, 4rem); max-width: 46rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin-bottom: 1rem;
  color: var(--academy-ink);
  font-weight: 600; font-size: var(--step--1);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.lede { margin-top: 1.1rem; color: var(--muted); font-size: var(--step-1); max-width: 38rem; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; margin-top: 2rem; }
.hero-note { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: var(--step--1); }

.tracks { padding: 2rem 0 3rem; border-top: 1px solid var(--line); }
.section-lede { margin-top: 0.5rem; color: var(--muted); }
.track-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  margin-top: 1.75rem; padding: 0; list-style: none;
}
.track {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.track-icon { font-size: 1.4rem; color: var(--academy-ink); margin-bottom: 0.25rem; }
.track p { color: var(--muted); font-size: var(--step--1); flex: 1; }
.track-ask {
  align-self: flex-start;
  min-height: 44px;
  margin-top: 0.4rem; padding: 0 1rem;
  border: 1px solid color-mix(in srgb, var(--academy) 50%, transparent);
  border-radius: var(--pill);
  background: transparent; color: var(--text);
  font-weight: 600; font-size: var(--step--1);
  cursor: pointer;
}
.track-ask:hover { background: color-mix(in srgb, var(--academy) 12%, transparent); }

.crisis {
  display: flex; gap: 1rem; align-items: flex-start;
  margin: 0 0 3rem; padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
}
.crisis > .icon { font-size: 1.5rem; color: var(--danger); margin-top: 0.15rem; }
.crisis h2 { font-size: var(--step-1); font-weight: 600; margin-bottom: 0.3rem; }

.footer {
  max-width: 1120px; margin: 0 auto;
  padding: 2rem var(--gutter) calc(6rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: var(--step--1);
  display: grid; gap: 0.6rem;
}

/* ---------- Chat launcher ---------- */
.chat-launcher {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-flex; align-items: center; gap: 0.55rem;
  min-height: 56px;
  padding: 0 1.35rem 0 1.15rem;
  border: 0; border-radius: var(--pill);
  background: var(--gradient); color: var(--on-gradient);
  font-weight: 700;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.35);
  cursor: pointer;
}
.chat-launcher .icon { font-size: 1.3rem; }

/* ---------- Chat panel ---------- */
.chat-panel {
  position: fixed; z-index: 70;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
  width: min(420px, calc(100vw - 32px));
  height: min(680px, calc(100dvh - 96px));
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.45);
  overflow: hidden;
}
@media (max-width: 640px) {
  /* Phones: the guide takes the whole screen, under the header's Exit button. */
  .chat-panel {
    inset: 64px 0 0 0;
    width: 100%; height: auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
  }
  html.chat-open { overflow: hidden; }
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 8px 8px 18px;
  border-bottom: 1px solid var(--line);
}
.chat-title { font-size: var(--step-1); font-weight: 600; display: flex; align-items: center; gap: 0.5rem; }
.chat-title::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--academy);
}
.chat-head-actions { display: flex; gap: 2px; }
.chat-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Sign in */
.chat-signin { overflow-y: auto; padding: 22px 20px; }
.signin-form { display: grid; gap: 0.75rem; }
.signin-form h3 { font-size: var(--step-2); font-weight: 800; letter-spacing: -0.01em; }
.signin-form .muted { font-size: var(--step--1); }
.field-label { font-weight: 600; font-size: var(--step--1); margin-top: 0.4rem; }
.field {
  width: 100%; min-height: 48px;
  padding: 0.6rem 0.9rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font: inherit;
}
.field:focus-visible { outline-offset: 1px; }
.field[aria-invalid='true'] { border-color: var(--danger); }
.field-code { font-size: 1.5rem; letter-spacing: 0.4em; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--fire); }
.form-error { color: var(--danger); font-size: var(--step--1); font-weight: 600; }
.form-error:empty { display: none; }
.form-error.is-info { color: var(--success); }
.signin-links { display: flex; flex-wrap: wrap; gap: 0 1.25rem; font-size: var(--step--1); }

/* Past chats */
.chat-history { overflow-y: auto; padding: 20px; gap: 0.5rem; }
.chat-history h3 { font-size: var(--step-1); }
.chat-history > .muted { font-size: var(--step--1); margin-bottom: 0.5rem; }
.history-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.history-item {
  display: flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg);
}
.history-item.is-current { border-color: color-mix(in srgb, var(--academy) 60%, transparent); }
.history-open {
  flex: 1; min-width: 0; min-height: 52px;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.5rem 0.4rem 0.5rem 0.9rem;
  border: 0; background: none; text-align: left; cursor: pointer;
}
.history-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-date { flex: none; color: var(--muted); font-size: var(--step--1); }
.history-delete { color: var(--muted); }
.history-delete:hover { color: var(--danger); }

/* Thread */
.chat-log {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 16px;
}
.chat-welcome { display: grid; gap: 0.9rem; color: var(--muted); font-size: var(--step--1); }
.suggestions { list-style: none; padding: 0; display: grid; gap: 8px; }
.suggestions button {
  width: 100%; min-height: 44px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: transparent; color: var(--text);
  text-align: left; font-size: var(--step--1);
  cursor: pointer;
}
.suggestions button:hover { border-color: color-mix(in srgb, var(--academy) 60%, transparent); }
.msg { display: flex; flex-direction: column; max-width: 92%; }
.msg-user { align-self: flex-end; }
.msg-guide { align-self: flex-start; }
.msg-body { overflow-wrap: anywhere; font-size: var(--step--1); line-height: 1.55; }
.msg-user .msg-body {
  padding: 0.6rem 0.9rem;
  background: var(--user-bubble);
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  white-space: pre-wrap;
}
.msg-guide .msg-body { display: grid; gap: 0.6rem; padding: 0.15rem 0.1rem; }
.msg-guide .msg-body:empty { display: none; }
.msg-body ul, .msg-body ol { padding-left: 1.25rem; display: grid; gap: 0.25rem; }
.msg-body .md-heading { font-weight: 600; color: var(--text); }
.msg-body code {
  padding: 0.05rem 0.3rem;
  background: var(--surface-2); border-radius: 6px;
  font-size: 0.92em;
}
.msg-body pre { margin: 0; padding: 0.75rem; overflow-x: auto; background: var(--surface-2); border-radius: var(--radius-sm); }
.msg-body pre code { padding: 0; background: none; }
.msg-note { margin-top: 0.4rem; font-size: var(--step--1); font-weight: 600; color: var(--danger); }
.msg-note.is-info { color: var(--muted); font-weight: 400; }

.typing { display: inline-flex; gap: 5px; padding: 0.6rem 0.1rem; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--academy); opacity: 0.35; animation: typing 1.1s infinite var(--ease); }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 30% { opacity: 1; transform: translateY(-3px); } }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  margin: 0 12px; padding: 6px 6px 6px 14px;
  background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: 24px;
}
.composer:focus-within { border-color: var(--focus); }
.composer-input {
  flex: 1; min-height: 40px; max-height: 168px;
  padding: 0.5rem 0;
  border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: var(--step--1); line-height: 1.45;
  resize: none;
}
.composer-input:focus-visible { outline: none; }
.composer-input::placeholder { color: var(--muted); }
.send-btn {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: var(--gradient); color: var(--on-gradient);
  font-size: 1.15rem;
  cursor: pointer;
}
.stop-btn { background: var(--text); color: var(--bg); font-size: 0.95rem; }
.chat-foot { padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 0.78rem; line-height: 1.45; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
