/* === Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Feral Empire HQ — green + gold variant (differentiates from Graeae's burgundy + gold) */
  --bg-primary: #1a2e22;
  --bg-secondary: #142118;
  --bg-card: #1f3a2b;
  --bg-input: #253d2f;
  --text-primary: #f4efe2;
  --text-secondary: #c9c2b5;
  --text-muted: #8a9a88;
  --accent-gold: #d4a843;
  --accent-gold-dim: #a8832e;
  --accent-serpent: #4a7c5c;
  --accent-serpent-deep: #294534;
  --border-subtle: rgba(212, 168, 67, 0.2);
  --border-glow: rgba(212, 168, 67, 0.35);
  --shadow-glow: 0 0 30px rgba(212, 168, 67, 0.15);
  --font-heading: 'Cinzel', serif;
  --font-body: 'Raleway', sans-serif;
  --chat-max-width: 800px;
}

html, body {
  height: 100%;
  overflow: hidden;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* === Particle Canvas === */
#particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* === App Layout === */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 1;
  overflow-x: hidden;
}

/* === Header === */
.header {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  overflow: hidden;
  background-image: url('images/feral-empire-hero.png');
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border-subtle);
}

.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 33, 24, 0.45) 0%, rgba(20, 33, 24, 0.85) 100%);
  pointer-events: none;
}

.header-inner {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 18px 24px;
  max-width: 900px;
  margin: 0 auto;
}

.sam-portrait {
  flex-shrink: 0;
  width: 120px;
  height: 150px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--accent-gold-dim);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.sam-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}

.header-text {
  flex: 1;
  min-width: 0;
}

.welcome-prefix {
  font-family: var(--font-body);
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin-bottom: 2px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.title {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 5px;
  text-transform: uppercase;
  text-shadow: 0 0 40px rgba(212, 168, 67, 0.5), 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 6px;
  line-height: 1.1;
}

.tagline {
  font-family: var(--font-body);
  color: var(--text-primary);
  font-weight: 500;
  letter-spacing: 0.5px;
  font-size: 0.92rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  margin-bottom: 2px;
}

.tagline-sub {
  font-family: var(--font-heading);
  color: var(--accent-gold);
  font-style: italic;
  font-weight: 600;
  letter-spacing: 2px;
  font-size: 0.9rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* === Chat Container === */
.chat-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: var(--chat-max-width);
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--accent-gold-dim);
  border-radius: 4px;
}

/* === Messages === */
.message {
  display: flex;
  gap: 12px;
  animation: fadeIn 0.4s ease;
  max-width: 90%;
  min-width: 0;
}

.message-content {
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.bot {
  align-self: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
}

.sam-avatar {
  /* Placeholder — replaced when Sam supplies a headshot */
  background: linear-gradient(135deg, var(--accent-serpent-deep), var(--accent-serpent));
  color: var(--accent-gold);
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 0.9rem;
  border-color: var(--accent-gold-dim);
}

.message.user .message-avatar {
  background: var(--accent-serpent-deep);
  border-color: var(--accent-serpent);
}

.message-content {
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.65;
  font-size: 1rem;
  font-weight: 400;
}

.message.bot .message-content {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}

.message.user .message-content {
  background: linear-gradient(135deg, var(--accent-serpent-deep), var(--accent-serpent));
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}

.message-content p {
  margin-bottom: 8px;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content strong {
  color: var(--accent-gold);
  font-weight: 600;
}

.message-content a {
  color: var(--accent-gold);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-gold-dim);
  transition: border-color 0.3s;
}

.message-content a:hover {
  border-color: var(--accent-gold);
}

/* === Offer Card === */
.offer-card {
  background: rgba(41, 69, 52, 0.4);
  border: 1px solid var(--border-glow);
  border-radius: 12px;
  padding: 14px 16px 16px;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.offer-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.offer-card h4 {
  font-family: var(--font-heading);
  color: var(--accent-gold);
  font-size: 1rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 0;
}

.offer-card-status {
  font-size: 0.7rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.offer-card-status[data-status="waitlist"] {
  color: var(--accent-gold);
  border-color: var(--accent-gold-dim);
}

.offer-card-status[data-status="TBD"] {
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.offer-card-status[data-status="free"] {
  color: var(--accent-serpent);
  border-color: var(--accent-serpent);
}

.offer-card p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin: 0;
}

.offer-card-cta {
  display: inline-block;
  align-self: flex-start;
  margin-top: 4px;
  background: linear-gradient(135deg, var(--accent-gold), #e8bc5a);
  color: var(--bg-primary) !important;
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-size: 0.8rem;
  padding: 10px 18px;
  border-radius: 10px;
  text-decoration: none !important;
  border: none !important;
  border-bottom: none !important;
  transition: transform 0.2s ease, box-shadow 0.25s ease;
  box-shadow: 0 2px 10px rgba(212, 168, 67, 0.25);
}

.offer-card-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 168, 67, 0.4);
  border-bottom: none !important;
}

.offer-card-missing {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* === Quick Actions === */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  max-width: 100%;
}

.quick-action-btn {
  padding: 9px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.quick-action-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(212, 168, 67, 0.08);
}

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

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold-dim);
  animation: typingBounce 1.4s infinite;
}

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

.typing-note {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  margin-top: 4px;
  letter-spacing: 0.5px;
  min-height: 1.1em;
  animation: fadeIn 0.5s ease;
}

/* === Input === */
.input-container {
  padding: 12px 20px max(20px, env(safe-area-inset-bottom, 20px));
  max-width: var(--chat-max-width);
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 8px 8px 8px 18px;
  transition: border-color 0.3s;
}

.input-wrapper:focus-within {
  border-color: var(--accent-gold);
  box-shadow: var(--shadow-glow);
}

#userInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  padding: 6px 0;
}

#userInput::placeholder {
  color: var(--text-muted);
}

#sendBtn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dim));
  color: var(--bg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  flex-shrink: 0;
}

#sendBtn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(212, 168, 67, 0.3);
}

#sendBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 0.3px;
}

.privacy-note {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  opacity: 0.7;
}

.privacy-note a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: rgba(138, 154, 136, 0.4);
}

.privacy-note a:hover {
  color: var(--accent-gold);
}

/* === Feral Mode (medium intensity visual state) === */
body.feral-mode::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  box-shadow: inset 0 0 120px rgba(220, 50, 40, 0.35);
  animation: feralPulse 2.2s ease-in-out infinite;
}

body.feral-mode .chat-messages {
  box-shadow: inset 2px 0 0 rgba(255, 90, 60, 0.4), inset -2px 0 0 rgba(255, 90, 60, 0.4);
}

body.feral-mode .title {
  text-shadow: 0 0 36px rgba(255, 90, 60, 0.7), 0 2px 4px rgba(0,0,0,0.8);
}

body.feral-mode .sam-portrait {
  border-color: rgba(255, 90, 60, 0.85);
  box-shadow: 0 4px 30px rgba(255, 90, 60, 0.55);
}

body.feral-mode .input-wrapper:focus-within {
  border-color: rgba(255, 90, 60, 0.9);
  box-shadow: 0 0 30px rgba(255, 90, 60, 0.25);
}

body.feral-mode .message.bot .message-content {
  border-color: rgba(255, 90, 60, 0.25);
}

.path-btn {
  font-weight: 600;
}

.feral-path-btn {
  border-color: rgba(255, 90, 60, 0.5);
  color: #ff8a6a;
}

.feral-path-btn:hover {
  border-color: rgba(255, 90, 60, 0.9);
  color: #ff8a6a;
  background: rgba(255, 90, 60, 0.08);
}

@keyframes feralPulse {
  0%, 100% { box-shadow: inset 0 0 80px rgba(220, 50, 40, 0.22); }
  50% { box-shadow: inset 0 0 160px rgba(220, 50, 40, 0.48); }
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* === Responsive === */
@media (max-width: 768px) {
  .header-inner { padding: 14px 16px; gap: 16px; }
  .sam-portrait { width: 96px; height: 120px; }
  .title { font-size: 1.35rem; letter-spacing: 4px; }
  .tagline { font-size: 0.88rem; }
  .tagline-sub { font-size: 0.82rem; letter-spacing: 1.5px; }
  .chat-container { padding: 0 12px; max-width: 100%; }
  .message { max-width: 85%; }
  .input-container { padding: 10px 14px max(18px, env(safe-area-inset-bottom, 18px)); max-width: 100%; }
  .quick-action-btn { padding: 8px 14px; font-size: 0.85rem; }
}

@media (max-width: 480px) {
  .header-inner { padding: 12px 14px; gap: 12px; }
  .sam-portrait { width: 80px; height: 100px; }
  .title { font-size: 1.1rem; letter-spacing: 3px; }
  .tagline { font-size: 0.8rem; letter-spacing: 0.5px; }
  .tagline-sub { font-size: 0.75rem; letter-spacing: 1px; }
  .chat-container { padding: 0 8px; }
  .message { max-width: 100%; gap: 8px; }
  .message-avatar { width: 32px; height: 32px; }
  .message-content { padding: 12px 14px; font-size: 0.95rem; }
  .offer-card { padding: 12px 14px; }
  .offer-card h4 { font-size: 0.92rem; }
  .input-container { padding: 8px 10px max(16px, env(safe-area-inset-bottom, 16px)); }
  .input-wrapper { padding: 8px 8px 8px 16px; border-radius: 14px; }
  .quick-action-btn { padding: 7px 12px; font-size: 0.82rem; }
}
