/* ===== Coach page ===== */

.coach-body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--transition-interactive);
}
.header-link:hover {
  color: var(--color-primary);
}

.coach-main {
  flex: 1;
  max-width: 780px;
  width: 100%;
  margin-inline: auto;
  padding-inline: clamp(var(--space-4), 4vw, var(--space-8));
  padding-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Chat stays centered on the page regardless of sidebar state; the sidebar
   is an overlay pinned to the viewport left, not a flex sibling that
   pushes the chat sideways. */
.coach-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  position: relative;
}

.coach-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

/* ---------- Thread sidebar (collapsible overlay) ---------- */
.thread-sidebar {
  position: fixed;
  top: 88px; /* clears the site header */
  left: var(--space-4);
  width: 240px;
  max-height: calc(100dvh - 120px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  transform: translateX(0);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.thread-sidebar[hidden] {
  display: none;
}

.thread-sidebar-header {
  margin-bottom: var(--space-3);
}

.thread-new-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-3);
  background: var(--color-bg-subtle, rgba(0,0,0,0.03));
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s ease;
}
.thread-new-btn:hover {
  background: var(--color-bg-subtle-hover, rgba(0,0,0,0.06));
}

.thread-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.thread-sidebar-note {
  margin: var(--space-3) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-subtle);
  font-size: var(--text-xs, 0.75rem);
  color: var(--color-text-subtle, rgba(0,0,0,0.5));
  text-align: center;
  flex-shrink: 0;
}

.thread-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}
.thread-item:hover {
  background: var(--color-bg-subtle, rgba(0,0,0,0.04));
}
.thread-item.active {
  background: var(--color-primary-highlight, rgba(0,0,0,0.06));
}

.thread-item-preview {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item.closed .thread-item-preview {
  color: var(--color-text-faint);
}

.thread-item-closed-badge {
  flex-shrink: 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-faint);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm, 4px);
  padding: 1px 5px;
}

.thread-item-delete {
  flex-shrink: 0;
  display: none;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--color-text-faint);
  border-radius: var(--radius-sm, 4px);
}
.thread-item:hover .thread-item-delete {
  display: inline-flex;
}
.thread-item-delete:hover {
  color: var(--color-error);
}

.thread-list-empty {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  padding: var(--space-3);
  text-align: center;
}

/* Coach-page header override: flush the logo to the left edge and let the
   sidebar toggle sit right next to it. .header-actions gets pushed to the
   right via margin-inline-start: auto so the middle child doesn't get
   spaced out by justify-content: space-between. */
.site-header--coach {
  padding-left: var(--space-4);
  padding-right: clamp(var(--space-4), 4vw, var(--space-8));
  justify-content: flex-start;
  gap: var(--space-3);
}
.site-header--coach .header-actions {
  margin-inline-start: auto;
}

/* Shared button styling for both mobile and desktop sidebar toggles. */
.sidebar-toggle {
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm, 4px);
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-toggle:hover {
  background: var(--color-bg-subtle, rgba(0,0,0,0.04));
  color: var(--color-text);
}
.sidebar-toggle.is-active {
  color: var(--color-text);
}

/* Desktop toggle: inline right after the logo, nudged down a touch so
   it visually anchors below the logo baseline. */
.sidebar-toggle--desktop {
  display: inline-flex;
  align-self: flex-end;
  margin-bottom: -6px;
}

/* Mobile toggle lives inline in .header-actions; hidden on desktop. */
.sidebar-toggle--mobile {
  display: none;
}

@media (max-width: 640px) {
  .sidebar-toggle--desktop {
    display: none;
  }
  .sidebar-toggle--mobile {
    display: inline-flex;
  }
  .thread-sidebar {
    left: 0;
    right: 0;
    width: auto;
    margin-inline: var(--space-3);
    max-width: 320px;
  }
}

/* When chat is active, transcript is the sole scroll container; composer pins at bottom */
.coach-shell.chat-active .chat-transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: var(--space-2);
}

/* ===== Intro ===== */
.coach-intro {
  text-align: center;
  padding-top: var(--space-8);
  padding-bottom: var(--space-4);
  animation: fade-up 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.coach-intro h1 {
  font-size: var(--text-lg);
  font-weight: 500;
  line-height: 1.35;
  max-width: 62ch;
  margin-inline: auto;
  margin-block: var(--space-4);
}

.coach-intro .lede {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 55ch;
  margin-inline: auto;
  margin-bottom: var(--space-4);
}

.disclosure-note {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 60ch;
  margin-inline: auto;
  margin-top: var(--space-4);
  line-height: 1.55;
}

/* Shared clickable/dismissible treatment for the disclosure note and
   privacy card — both are one-time acknowledgments, not persistent text. */
.dismissible-note {
  display: block;
  width: 100%;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.dismissible-note:hover {
  background: var(--color-bg-subtle, rgba(0,0,0,0.05));
}
.dismissible-note:active {
  opacity: 0.8;
}
.dismissible-note .dismissible-note-hint {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-primary, var(--color-text-muted));
  font-weight: 500;
}
.dismissible-note.dismissed {
  display: none;
}

.privacy-note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  max-width: 55ch;
  margin-inline: auto;
  line-height: 1.55;
}

.privacy-note--bottom {
  margin-top: var(--space-8);
  text-align: center;
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
}

.privacy-card {
  margin-top: var(--space-5);
  margin-inline: auto;
  max-width: 60ch;
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-subtle, rgba(0,0,0,0.03));
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.55;
  text-align: left;
}

.disclosure-note.dismissible-note {
  background: none;
  border: none;
  padding: 0;
}

.age-gate-privacy {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: calc(var(--space-3) * -1);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

.composer-privacy {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  margin-top: var(--space-2);
  line-height: 1.5;
}

.thread-lifetime-note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  margin-top: var(--space-2);
  line-height: 1.5;
}

.thread-reset-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-decoration: underline;
  cursor: pointer;
}
.thread-reset-link:hover {
  color: var(--color-text);
}


/* Beta launch card — rendered in transcript at stop points */
.beta-card {
  margin: var(--space-6) auto;
  padding: var(--space-5);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  max-width: 55ch;
  text-align: center;
}
.beta-card-copy {
  font-size: var(--text-base);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}
.beta-card-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
  max-width: 32ch;
  margin: 0 auto;
}
.beta-card-input {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}
.beta-card-input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.beta-card-note {
  min-height: 1.2em;
}
.beta-card-foot {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}
.beta-card--maintenance {
  background: var(--color-neutral-highlight, #f5f5f5);
}

/* Age gate */
.age-gate {
  margin-top: var(--space-6);
  padding: var(--space-5);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  max-width: 55ch;
  margin-inline: auto;
  text-align: center;
}
.age-gate-label {
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}
.age-gate-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}
.age-gate-actions .btn-primary,
.age-gate-actions .btn-secondary {
  flex: 0 0 auto;
  width: auto;
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}
.age-gate-actions .btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.age-gate-actions .btn-secondary:hover {
  background: var(--color-surface-2);
  border-color: var(--color-text-muted);
}
.age-block {
  margin-top: var(--space-6);
  padding: var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  max-width: 55ch;
  margin-inline: auto;
}
.age-block a {
  color: var(--color-primary);
}

/* Hide chat + composer + turnstile until age is confirmed */
.coach-shell:not(.age-confirmed) .chat-transcript,
.coach-shell:not(.age-confirmed) .composer,
.coach-shell:not(.age-confirmed) .turnstile-slot,
.coach-shell:not(.age-confirmed) .composer-note,
.coach-shell:not(.age-confirmed) .composer-privacy,
.coach-shell:not(.age-confirmed) .thread-lifetime-note,
.coach-shell:not(.age-confirmed) .coach-feedback-line {
  display: none;
}

body:not(.age-confirmed) .thread-sidebar,
body:not(.age-confirmed) .sidebar-toggle {
  display: none !important;
}

.coach-feedback-line {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-3);
  line-height: 1.5;
}
.coach-feedback-line a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.coach-feedback-line a:hover {
  color: var(--color-primary-hover);
}

/* When age confirmed, hide the age-gate control */
.coach-shell.age-confirmed .age-gate {
  display: none;
}

.gate-notice {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 55ch;
  margin-inline: auto;
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  line-height: 1.5;
}

/* Once chat is active, collapse intro */
.coach-shell.chat-active .coach-intro {
  display: none;
}

/* ===== Chat transcript ===== */
.chat-transcript {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding-block: var(--space-4);
  min-height: 200px;
}

.chat-msg {
  display: flex;
  gap: var(--space-3);
  max-width: 100%;
  animation: msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-msg--user {
  flex-direction: row-reverse;
}

.chat-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chat-msg--assistant .chat-avatar {
  background: #3e5040;
  border-color: #3e5040;
  color: #ffffff;
  font-weight: 600;
  font-size: var(--text-sm);
  font-family: var(--font-heading, inherit);
  line-height: 1;
}

.chat-msg--user .chat-avatar {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-weight: 600;
  font-size: var(--text-xs);
}

.chat-bubble {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-top-left-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--text-base);
  line-height: 1.55;
  max-width: min(560px, 82%);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-msg--user .chat-bubble {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-sm);
}

.chat-msg--streaming .chat-bubble::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--color-primary);
  margin-left: 2px;
  vertical-align: middle;
  animation: cursor-blink 0.9s steps(2) infinite;
  border-radius: 1px;
}

@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.chat-msg--error .chat-bubble {
  background: color-mix(in oklab, var(--color-error) 8%, var(--color-surface));
  border-color: color-mix(in oklab, var(--color-error) 32%, var(--color-border));
  color: var(--color-text);
}

.chat-msg--error .chat-bubble strong {
  color: var(--color-error);
}

/* ===== Composer ===== */
.composer {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: sticky;
  bottom: var(--space-4);
  transition: border-color var(--transition-interactive), box-shadow var(--transition-interactive);
}

.composer:focus-within {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm), 0 0 0 3px color-mix(in oklab, var(--color-primary) 15%, transparent);
}

.composer textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  padding: var(--space-2) var(--space-3);
  min-height: 24px;
  max-height: 200px;
  overflow-y: auto;
  outline: none;
}
.composer textarea::placeholder {
  color: var(--color-text-faint);
}

.composer-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-interactive), transform var(--transition-interactive);
}
.composer-send:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: scale(1.05);
}
.composer-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.composer-note {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
  min-height: 1.2em;
  margin-top: var(--space-2);
}
.composer-note.error { color: var(--color-error); }
.composer-note.success { color: var(--color-success); }

/* ===== Turnstile slot ===== */
.turnstile-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}
.turnstile-slot[hidden] {
  display: none;
}
.turnstile-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ===== Gate ===== */
.coach-gate {
  animation: msg-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.gate-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(var(--space-5), 3vw, var(--space-8));
  box-shadow: var(--shadow-md);
}

.gate-card h2 {
  font-size: var(--text-xl);
  font-weight: 500;
  margin-bottom: var(--space-3);
  text-align: center;
}

.gate-card p {
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: var(--space-5);
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

#gate-form input[type='email'] {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--transition-interactive);
}
#gate-form input[type='email']:focus {
  border-color: var(--color-primary);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.checkbox-row input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ===== Footer ===== */
.coach-footer {
  padding-block: var(--space-8);
  gap: var(--space-2);
}
.coach-footer a {
  color: var(--color-text-muted);
  text-decoration: none;
}
.coach-footer a:hover {
  color: var(--color-primary);
}
.footer-mini {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* Hide composer when gate is showing */
.coach-shell.gate-active .composer,
.coach-shell.gate-active .composer-note {
  display: none;
}

/* Disable composer while streaming */
.coach-shell.is-streaming .composer-send {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== Contact page ===== */
.contact-shell {
  max-width: 620px;
  margin-inline: auto;
}
.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-6);
}
.form-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}
.form-hint {
  color: var(--color-text-faint);
  font-weight: 400;
}
.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: var(--text-base);
  transition: border-color 0.15s ease;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
}
.form-textarea {
  resize: vertical;
  min-height: 140px;
  font-family: inherit;
  line-height: 1.5;
}
.contact-form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.contact-thanks {
  padding: var(--space-4) 0;
  color: var(--color-text);
  font-size: var(--text-base);
}

/* ===== Delete conversation confirmation ===== */
.delete-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 8, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
}
.delete-confirm-overlay[hidden] {
  display: none;
}
.delete-confirm-dialog {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  max-width: 380px;
  width: 100%;
}
.delete-confirm-dialog p {
  margin: 0 0 var(--space-5);
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: 1.5;
}
.delete-confirm-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-wrap: wrap;
}
.delete-confirm-actions .btn-secondary,
.delete-confirm-actions .btn-danger {
  flex: 0 0 auto;
  width: auto;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: background var(--transition-interactive), border-color var(--transition-interactive);
}
.delete-confirm-actions .btn-secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.delete-confirm-actions .btn-secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-text-muted);
}
.delete-confirm-actions .btn-danger {
  background: var(--color-error);
  color: var(--color-text-inverse);
  border: none;
}
.delete-confirm-actions .btn-danger:hover {
  filter: brightness(0.92);
}
