/* ==============================================================================
   AI COACH STARTER THEME VARIABLES
   ------------------------------------------------------------------------------
   Easily customize your brand colors by editing the 3 hex values below!
   ============================================================================== */
:root {
  --primary: var(--brand);          /* Main brand color (header, user bubble, buttons) */
  --primary-deep: var(--ink);       /* Maps to ECC ink */
  --primary-darker: var(--brand-hover); /* Button hover & active states (ink turned green buttons near-black) */
  --muted: var(--ink-muted);        /* Secondary subtext */
  --paper: var(--surface);          /* Card surface */
  --bubble-ai: var(--surface);      /* AI message bubble background */
  --line: var(--border);            /* Subtle borders */
  --shadow: 0 12px 36px rgba(15, 23, 42, 0.18);
  font-family: "Montserrat", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--surface-sunken);
  color: var(--ink);
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 44px;
  color: var(--brand);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-sub {
  font-size: 17px;
  color: var(--ink-muted); /* ECC: gold is identity-only and was 1.70:1 on white */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quiet-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 2px solid var(--border-strong); /* ECC rule 8: controls take border-strong */
  background: var(--surface);
  color: var(--brand);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.quiet-button:hover, .quiet-button:active {
  background: var(--surface-sunken);
  border-color: var(--brand);
}

/* Compact 4-Step Prep Navigation */
.step-nav {
  padding: 4px 12px 10px;
}

.step-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.step-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 2px 4px;
  border: 1px solid var(--border-strong); /* ECC rule 8: controls take border-strong */
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
}

.step-num {
  width: 20px;
  height: 20px;
  min-width: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  border: 1.5px solid var(--border);
  transition: all 0.18s ease;
}

.step-text {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-btn:hover {
  background: var(--surface-sunken);
  border-color: var(--border);
}

.step-btn.active {
  background: var(--brand-tint, #e6f0ec);
  border: 2px solid var(--brand);
  box-shadow: none;
}

.step-btn.active .step-num {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.step-btn.active .step-text {
  color: var(--brand);
}

/* Main Content Workspace */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 12px;
  min-height: 0;
  overflow: hidden;
}

/* Coach Chat Panel */
.coach-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  min-height: 0;
}

.coach-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
  flex-shrink: 0;
}

.coach-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  display: grid;
  place-items: center;
  border: 1.5px solid var(--primary);
}

.coach-info {
  flex: 1;
  min-width: 0;
}

.coach-name {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
}

.mode-label {
  margin: 1px 0 0;
  font-size: 17px;
  color: var(--muted);
  font-weight: 600;
}

.status {
  font-size: 17px;
  font-weight: 700;
  color: var(--brand);
  background: var(--surface);
  padding: 4px 9px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Messages */
.messages {
  flex: 1;
  min-height: 380px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 2rem; /* Section 7a standard: 24px top/bottom, 32px left/right breathing rail */
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 90%;
  padding: 12px 15px;
  border-radius: 16px;
  line-height: 1.48;
  font-size: var(--text-body);
  white-space: pre-wrap;
  word-break: break-word;
}

.message.assistant {
  background: var(--bubble-ai);
  color: var(--ink);
  align-self: flex-start;
  border-top-left-radius: 4px;
  border: 1px solid var(--border);
}

.message.user {
  background: var(--primary);
  color: #ffffff;
  align-self: flex-end;
  border-top-right-radius: 4px;
}

.message small {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.75;
}

/* Suggested Prompts (Key Interaction Starters) */
.suggestions-wrap {
  padding: 8px 14px 10px;
  background-color: var(--surface-sunken);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.suggestions-header {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 7px;
}

.suggestions-header .suggestions-icon {
  font-size: 17px;
  color: var(--ink-muted);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  gap: 8px;
  padding-bottom: 2px;
}

.suggestions::-webkit-scrollbar {
  display: none;
}

.suggestions button {
  border: 2px solid var(--border-strong); /* ECC rule 8: controls take border-strong */
  border-radius: 20px;
  background: var(--surface);
  color: var(--primary);
  padding: 6px 12px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  white-space: normal;
  text-align: left;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.suggestions button:hover, .suggestions button:active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
  transform: translateY(-1px);
}

/* Composer Form (Obvious, Visible, High-Contrast Area to Type) */
.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0.875rem 2rem 1.25rem; /* Mirrors .messages 2rem (32px) horizontal rail */
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.08);
  background: var(--surface);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.composer-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.composer-label-icon {
  font-size: 17px;
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

textarea#message-input {
  flex: 1;
  font-family: inherit;
  font-size: var(--text-body);
  padding: 12px 14px;
  border: 2px solid var(--input-border);
  border-radius: 12px;
  resize: none;
  min-height: 48px;
  max-height: 110px;
  line-height: 1.45;
  outline: none;
  background-color: var(--input-fill);
  color: var(--ink);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea#message-input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
  background-color: var(--surface);
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

textarea#message-input::placeholder {
  color: var(--ink-muted);
  font-size: 17px;
}

.composer button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #ffffff;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.composer button:hover {
  background: var(--primary-darker);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 102, 69, 0.28);
}

.composer button:active {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Footer */
.app-footer {
  padding: 16px 16px 24px;
  text-align: center;
}

.footer-privacy {
  margin: 0;
  font-size: 17px;
  color: var(--ink-muted);
}

/* Tablet & Desktop Enhancements */
@media (min-width: 860px) {
  .app-container {
    padding: 0 20px;
  }

  .topbar {
    padding: 20px 0 14px;
  }

  .brand {
    font-size: 26px;
  }

  .step-nav {
    padding: 6px 0 16px;
  }

  .step-list {
    gap: 12px;
  }

  .step-btn {
    min-height: 44px;
    padding: 4px 12px;
    gap: 8px;
  }

  .step-num {
    width: 24px;
    height: 24px;
    font-size: 17px;
  }

  .step-text {
    font-size: 17px;
  }

  .main-content {
    padding: 0;
  }

  .coach-panel {
    min-height: 540px;
  }

  .messages {
    max-height: 440px;
    padding: 20px;
  }

  .suggestions {
    flex-wrap: wrap;
  }
}

/* Feedback Controls */
.answer-feedback {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.feedback-prompt {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--muted);
  font-weight: 600;
}

.feedback-controls,
.feedback-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.feedback-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong); /* ECC rule 8: controls take border-strong */
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.feedback-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--brand-tint, #e6f0ec);
}

.feedback-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedback-up {
  color: var(--brand);
}

.feedback-down {
  color: var(--danger-text, #991b1b); /* ECC danger token, was raw #b91c1c */
}

.feedback-submit {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  min-height: 44px;
}

.feedback-submit:hover:not(:disabled) {
  background: var(--primary-darker);
  color: #ffffff;
}

.feedback-form {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.feedback-form[hidden],
.feedback-form.hidden {
  display: none !important;
}

.feedback-form label {
  display: block;
  margin: 6px 0 3px;
  font-size: 17px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.feedback-form textarea {
  width: 100%;
  padding: 10px 14px; /* ECC field standard: 14px sides, radius-md */
  border: 2px solid var(--input-border);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--text-body);
  color: var(--ink);
  background: var(--input-fill);
  resize: vertical;
  min-height: 44px;
  box-shadow: var(--shadow-card);
}

.feedback-form textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-focus);
}

.feedback-warning {
  margin: 5px 0 8px;
  font-size: 17px;
  color: var(--muted);
  line-height: 1.35;
}

.feedback-status {
  margin: 6px 0 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.feedback-status.feedback-success {
  color: var(--brand);
}

.feedback-status.feedback-error {
  color: var(--danger-text, #991b1b); /* ECC danger token, was raw #b91c1c */
}

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

/* Mobile-First Responsive Adjustments */
@media (max-width: 640px) {
  .app-container {
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
  }
  .topbar {
    padding: 8px 12px 6px;
  }
  .brand {
    font-size: 17px;
  }
  .brand-sub {
    display: none;
  }
  .step-nav {
    padding: 4px 8px 6px;
  }
  .step-btn {
    min-height: 44px;
    padding: 2px 2px;
  }
  .step-text {
    display: none;
  }
  .step-num {
    width: 22px;
    height: 22px;
    min-width: 22px;
    font-size: 17px;
  }
  .main-content {
    padding: 0;
  }
  .coach-panel {
    border-radius: 0;
    box-shadow: none;
  }
  .coach-head {
    padding: 8px 12px;
  }
  .messages {
    min-height: 320px;
    padding: 10px 12px;
    gap: 10px;
  }
  .message {
    max-width: 95%;
    padding: 10px 12px;
    font-size: var(--text-body);
  }
  .suggestions-wrap {
    padding: 6px 10px 8px;
  }
  .suggestions {
    flex-wrap: wrap;
  }
  .suggestions button {
    padding: 8px 12px;
    font-size: 17px;
    white-space: normal;
  }
  .composer {
    padding: 8px 10px 10px;
    box-shadow: 0 -3px 12px rgba(15, 23, 42, 0.12);
  }
  .composer textarea#message-input {
    font-size: var(--text-body);
    padding: 10px 12px;
    min-height: 44px;
  }
  .composer button {
    min-height: 44px;
    padding: 0 14px;
  }
  .app-footer {
    display: none;
  }
}

/* CES Brand Versioning & WCAG 2.2 AA Interaction Enhancements */
.ces-version-tag {
  display: inline-block;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--ces-radius-full, 9999px);
  padding: 0.1rem 0.45rem;
  margin-left: 0.4rem;
  vertical-align: middle;
  letter-spacing: 0.03em;
}

button, input, select, textarea, .step-btn, .quiet-button, .feedback-button {
  min-height: 44px;
}

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (forced-colors: active) {
  button, a, input, textarea, select {
    border: 2px solid ButtonText !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Phones: composer field takes its own row */
@media (max-width: 640px) {
  .composer-row {
    flex-wrap: wrap;
  }

  .composer-row textarea#message-input {
    flex: 1 1 100%;
  }

  .composer .composer-row button {
    flex: 1 1 auto;
    justify-content: center;
  }
}
/* ECC: form controls do not inherit font by default, so they rendered in Arial */
button, input, select, textarea { font-family: inherit; }
