/**
 * 100x Shared Component Styles
 * Chat interface, statement editors, guided questions, sign-in
 * Note: Despite the filename, these styles are shared across modules.
 */

/* ===== CHAT INTERFACE ===== */
.chat-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chat-messages {
  height: 400px;
  overflow-y: auto;
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-secondary);
}

.message {
  max-width: 85%;
  padding: 0.8rem 1.1rem;
  /* Bubbles ease in (motion & polish spec §4) — both on first render and as
     streamed replies land over Turbo Streams. Enter tier, runs once. */
  animation: motion-rise var(--motion-enter) var(--ease-out) backwards;
  /* Chat is the one surface the squared-off design softens (owner,
     2026-08-11): speech wants a rounded voice, so bubbles keep a real
     radius as a deliberate exception to --radius-lg: 0. The corner the
     bubble "speaks from" stays sharp (.ai bottom-left, .user
     bottom-right below). */
  border-radius: 16px;
  line-height: 1.55;
  font-size: calc(15px * var(--text-scale, 1));
}

/* A bubble is sized by its own padding, not by the trailing margin of whatever
   happened to end it. Both voices close with a block element — simple_format
   wraps the member's text in <p>, the markdown renderer ends on a <p>, a list
   or a heading — and that element's bottom margin was landing INSIDE the
   bubble as a band of dead space under the last line (owner, 2026-08-15).
   .step-chat and .help-chat each carried a local `p:last-child` fix; this is
   the same rule where every chat surface can see it, and it covers lists and
   headings too, which the local ones did not. */
.message > :first-child { margin-top: 0; }
.message > :last-child { margin-bottom: 0; }
/* An assistant reply wraps its words in a copy source (messages/_message), so
   the rule above would trim the wrapper rather than the words inside it. */
.message [data-chat-copy-target="source"] > :first-child { margin-top: 0; }
.message [data-chat-copy-target="source"] > :last-child { margin-bottom: 0; }

/* COPY on an assistant reply. A reply taller than the transcript's own scroller
   can't be dragged over to select it, so the button is the way the words come
   out (owner, 2026-08-17).

   It sits OUTSIDE the bubble, in the margin to its right, and is absolutely
   positioned so it reserves no height: in flow it left a band of dead space
   under every unhovered reply (owner, same day). .message.ai stops at 85% width,
   so the room it moves into is room the bubble was never going to use. */
.message {
  position: relative;
}

.message .message-copy {
  position: absolute;
  left: calc(100% + 0.4rem);
  bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: calc(0.7rem + var(--text-bump));
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.message:hover .message-copy,
.message:focus-within .message-copy {
  opacity: 1;
}

.message .message-copy:hover,
.message .message-copy:focus-visible {
  opacity: 1;
  color: var(--teal-ink);
  border-color: var(--border-light);
}

/* Touch has no hover to reveal it with, and the 15% margin is too narrow to
   stand a labelled button in on a phone. There it goes back into the bubble,
   under the words, where it is always visible and the space it takes is space
   something is using. */
@media (hover: none) {
  .message .message-copy {
    position: static;
    margin-top: 0.5rem;
    opacity: 1;
    transition: none;
  }
}

/* Reduced motion keeps the placement and drops the fade. */
@media (prefers-reduced-motion: reduce) {
  .message .message-copy { transition: none; }
}

/* AI replies render markdown and the model sometimes emits `#` headings, which
   would otherwise balloon into huge h1s in the bubble. Keep every heading level
   only ~2px larger than body text (still bolder for emphasis), with tight
   margins so it reads as a lead-in, not a banner. */
.message :is(h1, h2, h3, h4, h5, h6) {
  font-size: calc(1rem + var(--text-bump) + 2px);
  font-weight: 600;
  line-height: 1.3;
  margin: 0.6em 0 0.3em;
}
.message :is(h1, h2, h3, h4, h5, h6):first-child {
  margin-top: 0;
}

.message.ai {
  /* A warm teal wash instead of hard-bordered white (owner, 2026-08-11):
     the coach's voice reads soft, not clinical. */
  background: var(--teal-light);
  color: var(--text-dark);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: none;
}

.message.user {
  /* Deep teal instead of near-black: distinct but warm, tying the member's
     voice to the action colour. --teal-fill, not --teal-ink: this is teal
     carrying white words, so it has to stay dark in dark theme, where ink
     lightens to be readable AS text. */
  background: var(--teal-fill);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.message.loading {
  color: var(--text-muted);
}

.message.error-message {
  color: var(--text-muted);
  font-style: italic;
  background: transparent;
  border: 1px dashed var(--border-light, #e2e8f0);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Quieter than the old 4px hop (spec §4): the dots breathe rather than
   bounce — thinking, not jumping for attention. */
@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  30% {
    transform: translateY(-2px);
    opacity: 1;
  }
}

/* Chat Input */
.chat-input-container {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.75rem;
  background: var(--bg-primary);
}

.chat-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.7rem 1rem;
  color: var(--text-dark);
  font-family: var(--font-body);
  /* Exactly the 16px iOS floor (Safari zooms the page below it), scaled by
     the member's text-size setting — but no --text-bump: the composer read
     oversized next to 15px bubbles (owner, 2026-08-11). */
  font-size: calc(16px * var(--text-scale, 1));
  resize: none;
}

.chat-input:focus {
  border-color: var(--teal-accent);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: var(--teal-accent);
  border: none;
  border-radius: var(--radius-md);
  width: 48px;
  /* Match the composer's height exactly: the flex row stretches children by
     default, so no fixed height — just a sane floor (owner, 2026-08-11: the
     square button read misaligned beside a taller box). */
  height: auto;
  align-self: stretch;
  min-height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.send-btn:hover {
  background: var(--navy-primary);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn svg,
.send-btn i {
  width: 20px;
  height: 20px;
  color: var(--text-light);
}

/* ===== STATEMENT EDITOR ===== */
.statement-editor {
  background: var(--bg-primary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: var(--spacing-xl);
  box-shadow: var(--shadow-md);
}

.statement-editor.has-content {
  border-color: var(--teal-accent);
}

.statement-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.statement-editor-header-left {
  flex: 1;
}

.statement-editor-title {
  font-family: var(--font-heading);
  font-size: calc(1.25rem + var(--text-bump));
  color: var(--navy-primary);
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.statement-editor-subtitle {
  font-size: calc(0.9rem + var(--text-bump));
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.statement-editor-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: calc(0.8rem + var(--text-bump));
  color: var(--text-muted);
  font-family: var(--font-body);
  padding: 0.35rem 0.75rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.statement-editor-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-medium);
}

.statement-editor.has-content .statement-editor-status .status-dot {
  background: var(--teal-accent);
}

.statement-editor-body {
  margin-bottom: 1rem;
}

/* Trix Editor Customization */
.statement-trix-editor {
  min-height: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: calc(1rem + var(--text-bump));
  line-height: 1.7;
}

.statement-trix-editor:focus {
  border-color: var(--teal-accent);
  box-shadow: var(--focus-ring);
}

.statement-trix-editor:empty:not(:focus)::before {
  color: var(--text-muted);
  font-style: italic;
}

/* Lightweight Trix Toolbar */
trix-toolbar {
  background: transparent;
  border: none;
  padding: 0.25rem 0;
  display: flex;
  align-items: center;
}

/* Remove default Trix button group borders */
trix-toolbar .trix-button-group:not(:first-child) {
  border-left: none !important;
  margin-left: 0 !important;
}

trix-toolbar .trix-button-group + .trix-button-group {
  border: none !important;
}

trix-toolbar .trix-button-row {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: nowrap;
  width: 100%;
}

/* Button styling - minimal icon-only look */
trix-toolbar .trix-button {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  width: 24px;
  height: 24px;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

trix-toolbar .trix-button:hover {
  background: transparent;
  opacity: 0.8;
}

trix-toolbar .trix-button.trix-active {
  background: transparent;
  opacity: 1;
  color: var(--teal-ink);
}

trix-toolbar .trix-button::before {
  width: 15px;
  height: 15px;
}

/* Hide ALL button groups first */
trix-toolbar .trix-button-group {
  display: none;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Show text tools (bold/italic) */
trix-toolbar .trix-button-group--text-tools {
  display: flex;
  gap: 0;
}

/* Show block tools (lists) */
trix-toolbar .trix-button-group--block-tools {
  display: flex;
  gap: 0;
  margin-left: 0.25rem !important;
}

/* Show history tools (undo/redo) - push to right */
trix-toolbar .trix-button-group--history-tools {
  display: flex;
  gap: 0;
  margin-left: auto !important;
}

/* Hide extra buttons within shown groups */
trix-toolbar .trix-button--icon-strike,
trix-toolbar .trix-button--icon-link,
trix-toolbar .trix-button--icon-heading-1,
trix-toolbar .trix-button--icon-quote,
trix-toolbar .trix-button--icon-code,
trix-toolbar .trix-button--icon-decrease-nesting-level,
trix-toolbar .trix-button--icon-increase-nesting-level {
  display: none;
}

/* Dialog panels */
trix-toolbar .trix-dialogs {
  display: none;
}

.statement-editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.statement-editor-actions {
  display: flex;
  gap: 0.75rem;
}

.statement-editor-hint {
  font-size: calc(0.85rem + var(--text-bump));
  color: var(--text-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.statement-editor-hint i {
  color: var(--teal-ink);
}

/* ===== GUIDED QUESTIONS ===== */
.guided-questions-container {
  display: none;
}

.guided-questions-container.active {
  display: block;
}

.guided-question {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.guided-question.completed {
  border-color: var(--teal-accent);
  border-left: 4px solid var(--teal-accent);
}

.guided-question-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.guided-question-number {
  font-size: calc(0.75rem + var(--text-bump));
  color: var(--navy-primary);
  font-weight: 600;
}

.guided-question-status {
  font-size: calc(0.7rem + var(--text-bump));
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.guided-question-status.answered {
  color: var(--teal-ink);
}

.guided-question-text {
  font-size: calc(0.95rem + var(--text-bump));
  line-height: 1.5;
  margin-bottom: 0.75rem;
  color: var(--text-dark);
}

.guided-question textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: calc(0.9rem + var(--text-bump));
  line-height: 1.5;
  min-height: 80px;
  resize: vertical;
}

.guided-question textarea:focus {
  border-color: var(--teal-accent);
}

.guided-question textarea::placeholder {
  color: var(--text-muted);
}

.guided-progress-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.guided-progress {
  font-size: calc(0.85rem + var(--text-bump));
  color: var(--text-muted);
}

.guided-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.guided-nav-buttons {
  display: flex;
  gap: 0.5rem;
}

/* ===== PRINT PREVIEW STYLES ===== */
.export-content.print-preview h1 {
  font-family: var(--font-heading);
  color: var(--navy-primary);
  font-size: calc(1.5rem + var(--text-bump));
  margin-bottom: 0.5rem;
  border-bottom: 2px solid var(--teal-accent);
  padding-bottom: 0.5rem;
}

.export-content.print-preview h2 {
  font-family: var(--font-heading);
  color: #0a1628;
  font-size: calc(1.1rem + var(--text-bump));
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.export-content.print-preview h3 {
  font-family: var(--font-heading);
  color: #152238;
  font-size: calc(0.95rem + var(--text-bump));
  margin-top: 1rem;
  margin-bottom: 0.25rem;
}

.export-content.print-preview p {
  margin: 0.25rem 0;
  line-height: 1.5;
}

.export-content.print-preview .section {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e5e5;
}

.export-content.print-preview .empty {
  color: #999;
  font-style: italic;
}

/* ===== CLOUD SIGN IN ===== */
.cloud-signin-section {
  margin-top: 1rem;
  text-align: center;
}

.signin-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.google-signin-btn {
  width: 100%;
  justify-content: center;
  padding: 0.75rem 1rem;
  font-size: calc(0.95rem + var(--text-bump));
}

/* Sign-in divider */
.signin-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: calc(0.85rem + var(--text-bump));
}

.signin-divider::before,
.signin-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light, #e5e5e5);
}

/* Email sign-in form */
.email-signin-form {
  text-align: left;
}

.email-input-group {
  display: flex;
  gap: 0.5rem;
}

.email-signin-input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border-light, #e5e5e5);
  border-radius: var(--radius-md, 6px);
  font-size: calc(0.95rem + var(--text-bump));
  background: var(--bg-primary, #fff);
  color: var(--text-dark);
}

.email-signin-input:focus {
  border-color: var(--teal-accent);
  box-shadow: var(--focus-ring);
}

.email-signin-btn {
  white-space: nowrap;
  padding: 0.625rem 1rem;
}

.email-signin-hint {
  font-size: calc(0.8rem + var(--text-bump));
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
}

/* Email sent confirmation */
.email-sent-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem;
  background: rgba(74, 155, 181, 0.08);
  border-radius: var(--radius-md, 6px);
  text-align: center;
}

.email-sent-message i {
  font-size: calc(2rem + var(--text-bump));
  color: var(--teal-ink);
}

.email-sent-message p {
  margin: 0;
  font-weight: 500;
  color: var(--text-dark);
}

.email-sent-address {
  font-size: calc(0.85rem + var(--text-bump));
  color: var(--text-muted);
}

.cloud-signin-note {
  font-size: calc(0.8rem + var(--text-bump));
  color: var(--text-muted);
  margin-top: 0.75rem;
}

/* Signed In State */
.cloud-signedin-section {
  margin-top: 1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

/* Rails-only: initial-letter fallback when the user has no avatar photo.
   Matches the original .user-avatar circle so the signed-in card looks the
   same whether or not a photo exists. */
.user-avatar-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-accent);
  color: var(--text-light, #fff);
  font-weight: 600;
  font-size: calc(1rem + var(--text-bump));
  text-transform: uppercase;
}

/* User avatar with upload overlay */
.user-avatar-wrapper {
  position: relative;
  width: 40px;
  height: 40px;
  cursor: pointer;
  flex-shrink: 0;
}

.user-avatar-wrapper .user-avatar {
  width: 100%;
  height: 100%;
}

.user-avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--motion-quick) var(--ease-out);
}

.user-avatar-overlay i {
  color: white;
  font-size: calc(1rem + var(--text-bump));
}

.user-avatar-wrapper:hover .user-avatar-overlay {
  opacity: 1;
}

.user-avatar-wrapper.uploading .user-avatar-overlay {
  opacity: 1;
}

.user-avatar-wrapper.uploading .user-avatar-overlay i::before {
  content: "\F130";  /* Bootstrap Icons spinner */
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.user-details {
  flex: 1;
}

.user-name {
  font-weight: 600;
  color: var(--navy-primary);
}

.user-email {
  font-size: calc(0.85rem + var(--text-bump));
  color: var(--text-muted);
}

/* "Remove photo" link under the name (only shown when an avatar is uploaded). */
.btn-link-remove-avatar {
  background: none;
  border: none;
  padding: 0;
  margin-top: 0.25rem;
  font-size: calc(0.78rem + var(--text-bump));
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}

.btn-link-remove-avatar:hover {
  color: var(--danger, #dc3545);
}

.avatar-upload-error {
  margin: 0.5rem 0 0;
  font-size: calc(0.8rem + var(--text-bump));
  color: var(--danger, #dc3545);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: calc(0.85rem + var(--text-bump));
  color: var(--teal-ink);
}

/* Memory sync toggle (inside cloud signed-in section) */
.memory-sync-row {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

/* ===== RESPONSIVE - MOBILE ===== */
@media (max-width: 768px) {
  /* Statement editor */
  .statement-editor {
    padding: 0.75rem;
  }

  .statement-editor textarea {
    min-height: 80px;
    padding: 0.75rem;
    font-size: calc(0.9rem + var(--text-bump));
  }

  .statement-editor-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .statement-editor-actions .btn {
    padding: 0.5rem 0.75rem;
    font-size: calc(0.8rem + var(--text-bump));
  }
}

/* ===== Dark Theme ===== */
[data-theme="dark"] trix-toolbar {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

[data-theme="dark"] trix-toolbar .trix-button {
  background: transparent;
}

[data-theme="dark"] trix-toolbar .trix-button:hover {
  background: var(--bg-secondary);
}

[data-theme="dark"] trix-toolbar .trix-button.trix-active {
  background: rgba(91, 184, 212, 0.2);
}

/* Trix button icons - invert for dark mode */
[data-theme="dark"] trix-toolbar .trix-button::before {
  filter: invert(1);
}

[data-theme="dark"] trix-toolbar .trix-button-group--block-tools {
  border-left-color: var(--border-medium) !important;
}

[data-theme="dark"] .statement-trix-editor {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
  color: #e8ecf4;
}

[data-theme="dark"] .statement-trix-editor:focus {
  border-color: var(--teal-accent);
}

/* Dark theme email sign-in */
[data-theme="dark"] .signin-divider::before,
[data-theme="dark"] .signin-divider::after {
  background: var(--border-medium);
}

[data-theme="dark"] .email-signin-input {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
  color: #e8ecf4;
}

[data-theme="dark"] .email-signin-input:focus {
  border-color: var(--teal-accent);
}

[data-theme="dark"] .email-sent-message {
  background: rgba(91, 184, 212, 0.15);
}

[data-theme="dark"] .email-sent-message p {
  color: #e8ecf4;
}

/* ===== FOUNDATION CARDS (2026-08-10 redesign) =====
   Transcribed from docs/design-reference/extracted/module-roadmap.html: an
   unrounded white card with a 4px accent left edge and --shadow-md, laid out
   in .module-grid's auto-fit columns. The capture only ever shows finished
   cards (teal edge); unfinished ones take the neutral border tokens. */

/* The wrapper is now only the Turbo-replace target and the glow gutter — the
   columns live on .module-grid inside it. */
.foundation-grid {
  display: block;
}

/* Three columns, two rows (owner, 2026-08-18). There are exactly six
   statements and there always will be — Roadmap::FOUNDATION_SECTIONS is a
   fixed list — so the count is a fact this page can lay out to, not a number
   to auto-fit. .module-grid's shared auto-fit rule packed four or five across
   on a laptop and orphaned the rest on a second row.

   Fixed track counts, not auto-fit, so the shape is the same on every screen
   of the same class. Phone takes one column; from 768px (iPad portrait) up it
   is 3x2. */
.foundation-grid .module-grid {
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .foundation-grid .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .foundation-grid .module-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.foundation-card {
  background: var(--bg-primary);
  border: none;
  border-left: 4px solid var(--border-light);
  border-radius: 0;
  height: 100%;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.foundation-card--complete { border-left-color: var(--teal-accent); }
.foundation-card--in-progress { border-left-color: var(--border-medium); }

/* Hover grammar (spec §6): 1px lift, one shadow step, hover-capable
   pointers only so an iPad tap never sticks a lifted card. */
@media (hover: hover) {
  .foundation-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
  }
}

.foundation-card-body {
  padding: var(--spacing-lg);
  flex: 1;
}

.foundation-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.foundation-card-title {
  font-family: var(--font-heading);
  color: var(--navy-primary);
  font-size: calc(1rem + var(--text-bump));
  font-weight: 500;
  margin: 0;
}

.foundation-card-text {
  font-size: calc(0.85rem + var(--text-bump));
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.foundation-card-text--empty {
  color: var(--text-muted);
  font-style: italic;
}

/* The video strip is a quiet bordered footer in the capture, not the filled
   teal button components.css draws for the pre-redesign card. */
.foundation-card--with-video .foundation-card-body {
  border-bottom: none;
}

.foundation-card .foundation-card-video-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  width: auto;
  padding: 0.6rem var(--spacing-lg);
  background: none;
  border: none;
  border-top: 1px solid var(--border-light);
  color: var(--teal-ink);
  font-size: calc(0.8rem + var(--text-bump));
  font-weight: 400;
  text-align: left;
}

.foundation-card .foundation-card-video-btn:hover,
.foundation-card .foundation-card-video-btn:focus-visible {
  background: var(--teal-light);
  color: var(--teal-ink);
}

.foundation-card .foundation-card-video-btn i {
  font-size: calc(0.95rem + var(--text-bump));
}

/* ── The roadmap's optional verse ──────────────────────────────────────────
   Lloyd's own sheet carries one line under the title band. It is a line the
   member carries, not a seventh foundation statement, so it is drawn as a
   quiet rule under the six cards: no card, no shadow, no status pill, nothing
   that competes with the grid above it. The editor stays folded away in a
   <details> until someone asks for it. */

.roadmap-verse {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border-light);
  text-align: center;
}

.roadmap-verse-line {
  margin: 0 auto 0.6rem;
  max-width: 46rem;
}

.roadmap-verse-text {
  margin: 0;
  padding: 0;
  border: none;
  font-family: var(--font-heading);
  font-size: calc(18px * var(--text-scale));
  font-style: italic;
  line-height: 1.55;
  color: var(--text-heading);
}

/* The reference is a name, not a label: "1 Peter 1:13" set in caps reads as
   shouting, so it keeps its own case. */
.roadmap-verse-reference {
  display: block;
  margin-top: 0.45rem;
  font-family: var(--font-ui);
  font-size: calc(14px * var(--text-scale));
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* One muted line of controls under the verse: the "add / change" trigger
   opens the Choose-a-verse dialog, Remove clears the line. button_to wraps
   its buttons in forms; keep the row one line. */
.roadmap-verse-controls {
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}

.roadmap-verse-controls form {
  display: inline-flex;
  margin: 0;
}

.roadmap-verse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  padding: 0;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  color: var(--teal-ink);
}

.roadmap-verse-toggle:hover span {
  text-decoration: underline;
}

.roadmap-verse-remove {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: calc(14.5px * var(--text-scale));
  color: var(--text-muted);
}

.roadmap-verse-remove:hover {
  text-decoration: underline;
}

/* ── The "Choose a verse" dialog ─────────────────────────────────────────
   The house <dialog> pattern (same family as the faith scripture modal): the
   dialog sizes and centers the card, the backdrop is the shared scrim,
   corners are square. A picker is a utility panel, so it stays narrower than
   the faith reading surface. */
dialog.roadmap-verse-picker {
  border: none;
  padding: 0;
  background: none;
  margin: auto;
  max-width: 560px;
  width: calc(100% - 2rem);
  max-height: calc(100dvh - 4rem);
}

.roadmap-verse-picker::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.roadmap-verse-picker .modal-content {
  display: flex;
  flex-direction: column;
  /* components.css caps every .modal-content at 500px / 90%; take the width
     the dialog gives. */
  width: 100%;
  max-width: none;
  max-height: calc(100dvh - 4rem);
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
}

.roadmap-verse-picker .modal-header {
  background: transparent;
  border-bottom: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 0;
  flex-shrink: 0;
}

.roadmap-verse-picker .modal-title {
  font-family: var(--font-heading);
  font-weight: var(--weight-heading, 500);
  font-size: calc(1.5rem + var(--text-bump));
  line-height: 1.2;
  color: var(--text-dark);
  margin: 0;
}

.roadmap-verse-picker .modal-body {
  padding: 1rem 1.5rem 1.5rem;
  overflow-y: auto;
  text-align: left;
}

.roadmap-verse-picker-eyebrow {
  margin: 0 0 2px;
  font-family: var(--font-ui);
  line-height: 1.65;
}

[data-theme="dark"] .roadmap-verse-picker .modal-content {
  background: var(--bg-secondary);
}

.roadmap-verse-picker-label {
  margin: 0 0 0.5rem;
  font-family: var(--font-ui);
  font-size: calc(13px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.roadmap-verse-picker-label + .roadmap-verse-picker-label,
.roadmap-verse-choices + .roadmap-verse-picker-label,
.roadmap-verse-picker-empty + .roadmap-verse-picker-label {
  margin-top: 1.1rem;
}

.roadmap-verse-picker-empty {
  margin: 0;
  font-size: calc(14.5px * var(--text-scale));
  color: var(--text-muted);
}

/* The lookup row: reference in, one button. */
.roadmap-verse-lookup {
  display: flex;
  gap: 0.5rem;
}

.roadmap-verse-lookup-input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  font-family: var(--font-body);
  font-size: calc(15px * var(--text-scale));
  color: var(--text-body);
}

/* The translation, compact: the codes readers know (NIV, ESV, KJV…), one
   narrow select beside the reference. */
.roadmap-verse-lookup-translation {
  padding: 0.55rem 0.4rem;
  border: 1px solid var(--border-light);
  background: var(--bg-primary);
  font-family: var(--font-ui);
  font-size: calc(14px * var(--text-scale));
  letter-spacing: 0.04em;
  color: var(--text-body);
}

/* ── Browse by theme: one quiet row of chips ─────────────────────────────
   No visual weight until a chip is tapped; then that topic's references
   unfold as small pills that feed the same preview → set path. */
.roadmap-verse-topics {
  margin-top: 0.7rem;
}

.roadmap-verse-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.roadmap-verse-topic-chip {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border-light);
  background: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: calc(12.5px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.roadmap-verse-topic-chip:hover {
  border-color: var(--teal-accent);
  color: var(--teal-ink);
}

.roadmap-verse-topic-chip.is-open {
  border-color: var(--teal-ink);
  background: var(--teal-light);
  color: var(--teal-ink);
}

.roadmap-verse-topic-verses {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}

.roadmap-verse-topic-verses form {
  margin: 0;
}

.roadmap-verse-topic-verse {
  padding: 0.3rem 0.6rem;
  border: none;
  border-left: 2px solid var(--border-light);
  background: var(--bg-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: calc(14px * var(--text-scale));
  color: var(--text-secondary);
}

.roadmap-verse-topic-verse:hover {
  border-left-color: var(--teal-accent);
  color: var(--teal-ink);
}

/* The stage under the lookup: empty, a preview, or an error. */
.roadmap-verse-stage:not(:empty) {
  margin-top: 1rem;
}

.roadmap-verse-preview {
  padding: 0.9rem 1rem;
  background: var(--bg-secondary);
  border-left: 3px solid var(--teal-accent);
}

.roadmap-verse-preview-ref {
  margin: 0 0 0.4rem;
  font-family: var(--font-ui);
  font-size: calc(14px * var(--text-scale));
  letter-spacing: 0.05em;
  color: var(--teal-ink);
}

.roadmap-verse-preview-translation {
  color: var(--text-muted);
}

.roadmap-verse-preview-text {
  margin: 0 0 0.8rem;
  font-family: var(--font-heading);
  font-style: italic;
  font-size: calc(16px * var(--text-scale));
  line-height: 1.55;
  color: var(--text-heading);
}

.roadmap-verse-picker-error {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  font-size: calc(14.5px * var(--text-scale));
  color: var(--text-secondary);
}

/* Saved scripture offered as one-click picks: the member should never retype
   a verse they already kept in the faith collection. */
.roadmap-verse-choices {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 15rem;
  overflow-y: auto;
}

.roadmap-verse-choices form {
  margin: 0;
}

.roadmap-verse-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-left: 3px solid var(--border-light);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
}

.roadmap-verse-choice:hover {
  background: var(--teal-light);
  border-left-color: var(--teal-accent);
}

.roadmap-verse-choice.is-current {
  background: var(--teal-light);
  border-left-color: var(--teal-ink);
}

.roadmap-verse-choice-ref {
  font-family: var(--font-ui);
  font-size: calc(14px * var(--text-scale));
  letter-spacing: 0.05em;
  color: var(--teal-ink);
}

.roadmap-verse-choice-text {
  font-size: calc(14.5px * var(--text-scale));
  color: var(--text-secondary);
  line-height: 1.45;
}

.roadmap-verse-choice-mark {
  font-family: var(--font-ui);
  font-size: calc(12px * var(--text-scale));
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Printing the roadmap: the verse is part of the page, its controls are not. */
@media print {
  .roadmap-verse-controls {
    display: none;
  }

  .roadmap-verse {
    border-top: none;
  }
}
