/* Sage Rivers PWA - Dark Mountain Theme */

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

:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-input: #21262d;
  --text: #c9d1d9;
  --text-dim: #8b949e;
  --accent: #3fb950;
  --accent-dim: #2d5a3d;
  --sage: #58a6ff;
  --warn: #d2991d;
  --error: #f85149;
  --border: #30363d;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Screens ── */
.screen { display: none; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

/* ── Welcome Screen ── */
#welcome-screen {
  justify-content: center;
  align-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #0d1117 0%, #1a2a1a 60%, #0d1117 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.welcome-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 24px 0;
}
.welcome-photo {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent-dim);
  box-shadow: 0 0 32px rgba(63, 185, 80, 0.15);
  margin-bottom: 20px;
}
.welcome-card h1 {
  font-size: 26px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
}
.welcome-card .tagline {
  color: var(--accent);
  font-size: 14px;
  font-style: italic;
  margin-bottom: 24px;
  line-height: 1.5;
}
.welcome-bio {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
.welcome-warning {
  background: rgba(210, 153, 29, 0.1);
  border: 1px solid rgba(210, 153, 29, 0.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--warn);
}
.welcome-warning strong {
  color: #e2b73b;
}
/* ── Age Gate ── */
.age-gate {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.age-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  user-select: none;
}
.age-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--sage);
  cursor: pointer;
  flex-shrink: 0;
}
.restore-link {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
  text-align: center;
}
.restore-link .link-btn {
  background: none;
  border: none;
  color: var(--sage);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
}
#recover-form input {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
}

.btn-enter {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn-enter:disabled {
  background: var(--accent-dim);
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.6;
}
.btn-enter:active {
  transform: scale(0.97);
  background: #2d8a3e;
}

/* ── Chat Screen ── */
#chat-screen { background: var(--bg); }

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.chat-header .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent-dim);
  object-fit: cover;
}
.chat-header .info { flex: 1; }
.chat-header .name { font-weight: 600; font-size: 15px; color: #fff; }
.chat-header .status { font-size: 12px; color: var(--text-dim); }

/* Discover nav — site links visible in PWA layout */
.discover-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 5px 12px 6px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.discover-nav a {
  color: var(--text-dim);
  font-size: 11px;
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 4px;
  transition: color .2s;
  white-space: nowrap;
}
.discover-nav a:hover {
  color: var(--sage);
  background: #1a233220;
}
/* Messages */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: fadeIn .2s ease;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent-dim);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.sage {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg .time {
  font-size: 11px;
  opacity: 0.5;
  margin-top: 4px;
  display: block;
}
.msg.image {
  padding: 4px;
  background: transparent;
  border: none;
}
.msg.image img {
  max-width: 240px;
  border-radius: 12px;
  display: block;
}
.msg.audio audio {
  max-width: 240px;
  height: 40px;
}
.typing {
  align-self: flex-start;
  display: none;
  padding: 12px 16px;
  margin: 4px 0;
}
.typing.visible { display: flex; align-items: center; gap: 4px; }
.typing .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
  opacity: 0.4;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing .dot:nth-child(1) { animation-delay: 0s; }
.typing .dot:nth-child(2) { animation-delay: 0.2s; }
.typing .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Waiting indicator in input area */
.waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px 4px;
  min-height: 28px;
  background: var(--bg-card);
}
.waiting .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  opacity: 0.5;
  animation: bounce 1.4s infinite ease-in-out both;
}
.waiting .dot:nth-child(2) { animation-delay: .2s; }
.waiting .dot:nth-child(3) { animation-delay: .4s; }
.waiting-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* Input */
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  align-items: center;
}
.chat-input .input-row {
  flex: 1;
  display: flex;
  gap: 8px;
  background: var(--bg-input);
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  align-items: center;
}
.chat-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
  padding: 8px 0;
}
.chat-input button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .2s;
}
.btn-send {
  background: var(--accent);
  color: #fff;
}
.btn-selfie {
  background: var(--bg-input);
  color: var(--sage);
  width: auto;
  border-radius: 20px;
  padding: 0 12px;
  font-size: 13px;
  gap: 4px;
}
.btn-voice {
  background: var(--bg-input);
  color: var(--warn);
}
.chat-input button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Selfie viewer */
.selfie-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 100;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.selfie-overlay.visible { display: flex; }
.selfie-overlay img {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
}
.selfie-overlay .close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile optimizations */
@media (max-width: 480px) {
  .msg { max-width: 90%; font-size: 14px; }
  .chat-header { padding: 8px 12px; }
  .chat-input { padding: 8px 12px; }
}

/* Settings / Contact buttons in chat header */
.btn-contact-hdr {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 10px;
  color: var(--sage);
  font-family: inherit;
  transition: background .2s, color .2s;
}
.btn-contact-hdr:hover { background: var(--bg-input); color: #fff; }
.btn-settings {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
  opacity: 0.7;
  color: var(--text-dim);
  transition: opacity .2s, color .2s;
}
.btn-settings:hover { opacity: 1; color: var(--text); }

/* Upgrade / Settings modals */
.upgrade-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.upgrade-overlay.visible { display: flex; }

.upgrade-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: fadeIn .3s ease;
}
.upgrade-modal h2 {
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--text);
}
.upgrade-reason {
  color: var(--warn);
  font-size: 14px;
  margin: 0 0 16px;
}
.upgrade-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  font-size: 15px;
}
.upgrade-price {
  color: var(--sage);
  font-size: 15px;
  margin: 16px 0 8px;
}
.upgrade-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}
.upgrade-form input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 15px;
  box-sizing: border-box;
}
.upgrade-form .btn-enter {
  margin: 0;
}
.btn-cancel {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  margin-top: 8px;
}
.btn-secondary {
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: background .2s, color .2s;
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}
.upgrade-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 12px;
}
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
#settings-tier {
  color: var(--text-dim);
  font-size: 16px;
}
.settings-email {
  color: var(--text-dim);
  font-size: 13px;
  margin: 4px 0 0;
}
.settings-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
}
.settings-links a {
  color: var(--sage);
  text-decoration: none;
}
.settings-links a:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}
.footer-links a, .footer-links .link-btn {
  color: var(--text-dim);
  margin: 0 8px;
  text-decoration: none;
  background: none;
  border: none;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.footer-links a:hover, .footer-links .link-btn:hover {
  color: var(--sage);
}

/* Contact form */
#contact-form input,
#contact-form textarea {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
#contact-form textarea {
  resize: vertical;
  min-height: 80px;
}
#contact-form input:focus,
#contact-form textarea:focus {
  outline: none;
  border-color: var(--sage);
}

/* Welcome screen nav links */
.welcome-nav {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
}
.welcome-nav a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color .2s;
}
.welcome-nav a:hover {
  color: var(--sage);
}
.welcome-nav .sep {
  color: var(--border);
  margin: 0 8px;
}

/* ── Daily Moment / Journal Card (Idea 1 + 6) ── */
.moment-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  text-align: center;
  animation: fadeIn 0.5s ease;
}
.moment-date {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.moment-thought {
  font-size: 15px;
  color: var(--text);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 12px;
  padding: 0 8px;
}
.moment-photo {
  width: 100%;
  max-width: 300px;
  border-radius: 10px;
  margin: 8px auto;
  display: block;
  cursor: pointer;
  transition: transform 0.2s;
}
.moment-photo:hover {
  transform: scale(1.02);
}
.moment-fanvue {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}
.moment-fanvue a {
  color: var(--sage);
  text-decoration: none;
  font-weight: 500;
}
.moment-fanvue a:hover {
  text-decoration: underline;
}

/* ── Re-engagement Nudge (Idea 5) ── */
.reengage-nudge {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 12px 16px;
  margin: 8px 0;
  font-style: italic;
  animation: fadeIn 0.8s ease;
  border-left: 2px solid var(--sage);
  background: rgba(88, 166, 255, 0.05);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── Fanvue Bridge in Welcome (Idea 3) ── */
.welcome-fanvue {
  margin-top: 16px;
  padding: 12px;
  background: linear-gradient(135deg, rgba(88,166,255,0.08), rgba(63,185,80,0.05));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.6;
}
.welcome-fanvue a {
  color: var(--sage);
  text-decoration: none;
  font-weight: 600;
}
.welcome-fanvue a:hover {
  text-decoration: underline;
}

/* ── Enhanced Chat Greeting Photo ── */
.msg.sage.image img {
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.2s;
  display: block;
}
.msg.sage.image img:hover {
  transform: scale(1.02);
}

/* ── Activity Indicator (Idea 6) ── */
.activity-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Fade-in animation ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
