/* =============================================
   Stillpoint App — Companion Builder & Chat
   Uses theme.css design tokens.
   ============================================= */

:root {
  --cream: #F5F0E8;
  --charcoal: #1C1C1E;
  --copper: #B87333;
  --sage: #6B7C6F;
  --warm-grey: #8A7F72;
  --light-warm: #EDE8DF;
  --dark-warm: #2C2620;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--cream);
  color: var(--charcoal);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── BACK NAV ── */
.back-bar {
  padding: 20px 8%;
  background: var(--dark-warm);
}
.back-bar a {
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.6);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.2s;
}
.back-bar a:hover { color: var(--copper); }

/* ── APP HEADER ── */
.app-header {
  background: var(--dark-warm);
  color: var(--cream);
  padding: 40px 8%;
  text-align: center;
}
.app-header .eyebrow {
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--copper);
  margin-bottom: 12px;
}
.app-header h1 {
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 16px;
}
.app-header p {
  font-size: 19px;
  font-weight: 300;
  color: rgba(245, 240, 232, 0.75);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ── BUILDER FORM ── */
.builder-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 64px 8% 80px;
}

.builder-card {
  background: var(--light-warm);
  border: 1px solid rgba(184, 115, 51, 0.2);
  border-radius: 4px;
  padding: 48px;
}

.builder-step {
  margin-bottom: 40px;
}
.builder-step:last-of-type { margin-bottom: 0; }

.step-label {
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--copper);
  margin-bottom: 12px;
}

.field-group {
  margin-bottom: 28px;
}
.field-group:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--dark-warm);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.field-sub {
  font-size: 14px;
  color: var(--warm-grey);
  margin-bottom: 10px;
  font-weight: 300;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--cream);
  border: 1px solid rgba(184, 115, 51, 0.3);
  border-radius: 3px;
  padding: 12px 16px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 18px;
  color: var(--charcoal);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--copper);
  box-shadow: 0 0 0 3px rgba(184, 115, 51, 0.15);
}
input::placeholder, textarea::placeholder {
  color: var(--warm-grey);
  font-style: italic;
}

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

/* ── RADIO CARDS ── */
.radio-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.radio-card {
  position: relative;
}
.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.radio-card label {
  display: block;
  background: var(--cream);
  border: 1.5px solid rgba(184, 115, 51, 0.25);
  border-radius: 3px;
  padding: 14px 12px;
  text-align: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--charcoal);
}
.radio-card input:checked + label {
  background: var(--charcoal);
  color: var(--cream);
  border-color: var(--charcoal);
}
.radio-card label:hover {
  border-color: var(--copper);
}

/* ── DISPOSITION ICONS ── */
.disposition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.disposition-option {
  position: relative;
}
.disposition-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.disposition-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--cream);
  border: 1.5px solid rgba(184, 115, 51, 0.25);
  border-radius: 3px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.disposition-icon {
  font-size: 28px;
  line-height: 1;
  color: var(--copper);
}
.disposition-name {
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--dark-warm);
}
.disposition-option input:checked + label {
  background: var(--dark-warm);
  border-color: var(--dark-warm);
}
.disposition-option input:checked + label .disposition-icon,
.disposition-option input:checked + label .disposition-name {
  color: var(--copper);
}
.disposition-option label:hover {
  border-color: var(--copper);
}

/* ── SUBMIT BUTTON ── */
.builder-submit {
  margin-top: 48px;
  display: flex;
  justify-content: center;
}
.btn-primary {
  background: var(--charcoal);
  color: var(--cream);
  border: none;
  border-radius: 3px;
  padding: 16px 48px;
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover {
  background: var(--copper);
}
.btn-primary:active {
  transform: scale(0.98);
}

/* ── CHAT PAGE ── */
.chat-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--cream);
}

.chat-companion-header {
  background: var(--dark-warm);
  color: var(--cream);
  padding: 32px 8%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.companion-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--copper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--cream);
  flex-shrink: 0;
  font-family: Georgia, serif;
}
.chat-companion-info h2 {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 4px;
}
.chat-companion-info p {
  font-size: 14px;
  color: rgba(245, 240, 232, 0.6);
  font-style: italic;
}

/* ── MESSAGE THREAD ── */
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 40px 8%;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.message {
  display: flex;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-family: Georgia, serif;
}
.message-avatar.user {
  background: var(--sage);
  color: var(--cream);
}
.message-avatar.companion {
  background: var(--copper);
  color: var(--cream);
}

.message-body {
  flex: 1;
  padding-top: 4px;
}
.message-role {
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--warm-grey);
  margin-bottom: 4px;
}
.message-text {
  font-size: 18px;
  line-height: 1.7;
  color: var(--charcoal);
}

/* ── INPUT BAR ── */
.chat-input-bar {
  background: var(--light-warm);
  border-top: 1px solid rgba(184, 115, 51, 0.2);
  padding: 20px 8%;
}
.chat-input-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.chat-textarea {
  flex: 1;
  background: var(--cream);
  border: 1px solid rgba(184, 115, 51, 0.3);
  border-radius: 3px;
  padding: 12px 16px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 18px;
  color: var(--charcoal);
  resize: none;
  min-height: 52px;
  max-height: 160px;
  line-height: 1.6;
  transition: border-color 0.2s;
}
.chat-textarea:focus {
  outline: none;
  border-color: var(--copper);
}
.chat-textarea::placeholder {
  color: var(--warm-grey);
  font-style: italic;
}
.btn-send {
  background: var(--charcoal);
  color: var(--cream);
  border: none;
  border-radius: 3px;
  padding: 12px 24px;
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.btn-send:hover { background: var(--copper); }
.btn-send:disabled {
  background: var(--warm-grey);
  cursor: not-allowed;
}

/* ── THINKING INDICATOR ── */
.thinking-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warm-grey);
  animation: bounce 1.2s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* ── EMPTY STATE ── */
.empty-thread {
  text-align: center;
  padding: 80px 0;
  color: var(--warm-grey);
}
.empty-thread p {
  font-size: 20px;
  font-style: italic;
  margin-bottom: 8px;
}
.empty-thread span {
  font-size: 14px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .builder-card { padding: 32px 24px; }
  .radio-cards { grid-template-columns: repeat(3, 1fr); }
  .disposition-grid { grid-template-columns: repeat(3, 1fr); }
  .chat-companion-header { padding: 24px 5%; }
  .chat-thread { padding: 28px 5%; }
  .chat-input-bar { padding: 16px 5%; }
}

/* ── COMPANION LIST ── */
.companions-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 80px 8%;
}
.companions-page h1 {
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 600;
  margin-bottom: 40px;
}
.companion-cards {
  display: grid;
  gap: 20px;
}
.companion-card {
  background: var(--light-warm);
  border: 1px solid rgba(184, 115, 51, 0.2);
  border-radius: 4px;
  padding: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, transform 0.2s;
}
.companion-card:hover {
  border-color: var(--copper);
  transform: translateY(-2px);
}
.companion-card-info h3 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 4px;
}
.companion-card-info p {
  font-size: 15px;
  color: var(--warm-grey);
  font-style: italic;
}
.btn-secondary {
  background: var(--charcoal);
  color: var(--cream);
  border: none;
  border-radius: 3px;
  padding: 12px 28px;
  font-family: 'Cormorant SC', Georgia, serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}
.btn-secondary:hover { background: var(--copper); }