/* ═══════════════════════════════════════════════════════════
   Aurora App — Stylesheet
   Brand tokens match aurora-landing.html
═══════════════════════════════════════════════════════════ */

:root {
  --bg: #F7F4FC;
  --surface: #FFFFFF;
  --surface2: #F0ECF9;
  --text: #201B36;
  --muted: #635C7A;
  --border: #DAD5E8;
  --purple: #5B3F9E;
  --purple-dark: #46317D;
  --purple-tint: #EFE9FB;
  --teal: #1FA98C;
  --teal-dark: #0A7862;
  --teal-tint: #E3F6F1;
  --pink: #E0559C;
  --pink-dark: #C13E86;
  --pink-tint: #FBE7F1;
  --crisis: #C23B5C;
  --crisis-tint: #FBE9ED;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(32, 27, 54, 0.08);
  --shadow-lg: 0 12px 32px rgba(32, 27, 54, 0.18);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-head: 'Poppins', sans-serif;
  --font-quote: 'Fraunces', serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); min-height: 100vh; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; }
p { margin: 0; }
button, input, textarea, select { font-family: inherit; }
a { color: var(--purple); }

.af-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); position: relative; }

/* ─── Loading ────────────────────────────────────────────── */
#loading-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 1000; transition: opacity .25s;
}
#loading-overlay.hide { opacity: 0; pointer-events: none; }
.af-spinner {
  width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--purple);
  border-radius: 50%; animation: af-spin .7s linear infinite; margin-bottom: 14px;
}
@keyframes af-spin { to { transform: rotate(360deg); } }
.af-loading-brand { font-family: var(--font-head); font-size: 1.2rem; font-weight: 600; color: var(--purple); }

/* ─── Auth ───────────────────────────────────────────────── */
#auth-view { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; }
#auth-view.active { display: flex; }
.af-auth-box { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 400px; }
.af-auth-logo { display: flex; align-items: center; gap: 8px; justify-content: center; font-family: var(--font-head); font-weight: 600; font-size: 1.3rem; color: var(--purple); margin-bottom: 4px; }
.af-auth-tagline { text-align: center; color: var(--muted); font-size: .88rem; margin-bottom: 24px; }
.af-auth-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.af-auth-tab { flex: 1; padding: 10px; text-align: center; font-weight: 600; font-size: .88rem; color: var(--muted); cursor: pointer; border: none; background: transparent; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.af-auth-tab.active { color: var(--purple); border-bottom-color: var(--purple); }
.af-auth-form { display: none; }
.af-auth-form.active { display: block; }
.af-form-group { margin-bottom: 14px; }
.af-form-group label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.af-form-group .af-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.af-input, .af-textarea, .af-select {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .95rem; background: var(--surface); color: var(--text); outline: none; transition: border-color .15s;
}
.af-input:focus, .af-textarea:focus, .af-select:focus { border-color: var(--purple); }
.af-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.af-auth-error { background: var(--crisis-tint); color: var(--crisis); padding: 10px 14px; border-radius: 8px; font-size: .85rem; margin-bottom: 14px; display: none; }
.af-auth-error.show { display: block; }
.af-auth-footer { text-align: center; margin-top: 14px; font-size: .85rem; color: var(--muted); }
.af-auth-footer a { cursor: pointer; font-weight: 600; }
.af-lang-row { display: flex; justify-content: center; margin-bottom: 18px; }

/* ─── Buttons ────────────────────────────────────────────── */
.af-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 20px; border-radius: 999px; border: none; font-size: .92rem; font-weight: 600; cursor: pointer; transition: opacity .15s, transform .1s; }
.af-btn:active { transform: scale(.98); }
.af-btn:disabled { opacity: .5; cursor: not-allowed; }
.af-btn-primary { background: var(--purple); color: #fff; }
.af-btn-primary:not(:disabled):hover { background: var(--purple-dark); }
.af-btn-secondary { background: var(--surface2); color: var(--text); }
.af-btn-secondary:hover { background: var(--border); }
.af-btn-danger { background: var(--crisis); color: #fff; }
.af-btn-full { width: 100%; }
.af-btn-sm { padding: 7px 14px; font-size: .82rem; }
.af-btn-icon { width: 38px; height: 38px; border-radius: 50%; border: none; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text); flex-shrink: 0; }
.af-btn-icon:hover { background: var(--surface2); }

/* ─── App shell / top bar ────────────────────────────────── */
#app { display: none; flex-direction: column; min-height: 100vh; flex: 1; }
#app.active { display: flex; }
.af-topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--bg); border-bottom: 1px solid var(--border); }
.af-topbar-brand { display: flex; align-items: center; gap: 8px; flex: 1; }
.af-topbar-brand span { font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; color: var(--purple); }
.af-topbar-actions { display: flex; align-items: center; gap: 4px; }

/* ─── Views ──────────────────────────────────────────────── */
main.af-main { flex: 1; padding: 18px 18px 96px; overflow-y: auto; }
.af-view { display: none; }
.af-view.active { display: block; animation: af-fade .18s ease; }
@keyframes af-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.af-greeting { font-size: .88rem; color: var(--muted); margin-bottom: 2px; }
.af-headline { font-size: 1.5rem; margin-bottom: 16px; }
.af-quote-card { background: var(--pink-tint); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.af-quote-card p { font-family: var(--font-quote); font-style: italic; font-size: 1rem; color: var(--pink-dark); }
.af-eyebrow { display: block; font-size: .74rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.af-pill-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.af-pill-nav { padding: 8px 16px; border-radius: 999px; border: none; font-size: .85rem; font-weight: 600; cursor: pointer; }
.af-pill-nav.journal { background: var(--teal-tint); color: var(--teal-dark); }
.af-pill-nav.mood { background: var(--purple-tint); color: var(--purple); }
.af-pill-nav.community { background: var(--purple-tint); color: var(--purple-dark); }

/* ─── Card ───────────────────────────────────────────────── */
.af-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.af-card-title { font-size: 1.02rem; font-weight: 700; color: var(--purple-dark); margin-bottom: 14px; }

/* ─── Tag chips (mood + journal) ─────────────────────────── */
.af-chip-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.af-chip { padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); font-size: .86rem; font-weight: 600; color: var(--text); cursor: pointer; transition: all .12s; }
.af-chip.selected { border-color: transparent; }
.af-chip[data-tag="dysphoria"].selected       { background: #E3E1FA; color: #4B3FA0; }
.af-chip[data-tag="discrimination"].selected  { background: #FBE3D3; color: #B15A19; }
.af-chip[data-tag="family_rejection"].selected{ background: var(--pink-tint); color: var(--pink-dark); }
.af-chip[data-tag="anxiety"].selected         { background: #FBF0D2; color: #8A6A0E; }
.af-chip[data-tag="affirming_joy"].selected   { background: var(--pink-tint); color: var(--pink-dark); }
.af-chip[data-tag="community"].selected       { background: var(--teal-tint); color: var(--teal-dark); }
.af-chip[data-tag="loneliness"].selected      { background: var(--surface2); color: var(--muted); }
.af-chip[data-tag="pride"].selected           { background: var(--purple-tint); color: var(--purple); }

/* ─── Intensity slider ───────────────────────────────────── */
.af-intensity-label { font-size: .88rem; font-weight: 600; margin-bottom: 10px; }
input[type="range"].af-slider {
  -webkit-appearance: none; width: 100%; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--purple), var(--pink)); outline: none;
}
input[type="range"].af-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--purple); cursor: pointer; box-shadow: var(--shadow);
}
input[type="range"].af-slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 3px solid var(--purple); cursor: pointer;
}

/* ─── Journal prompt block ───────────────────────────────── */
.af-prompt-box { background: var(--surface2); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; }
.af-prompt-box p { font-family: var(--font-quote); font-style: italic; font-size: 1rem; line-height: 1.5; }

/* ─── Entry list ─────────────────────────────────────────── */
.af-entry-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.af-entry-item:last-child { border-bottom: none; }
.af-entry-date { font-size: .76rem; color: var(--muted); margin-bottom: 4px; }
.af-entry-text { font-size: .92rem; line-height: 1.55; }
.af-empty-state { text-align: center; padding: 32px 12px; color: var(--muted); font-size: .9rem; }

/* ─── Bottom tab bar ─────────────────────────────────────── */
.af-tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
}
.af-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; padding: 6px 2px; cursor: pointer; color: var(--muted); font-size: .68rem; font-weight: 600;
}
.af-tab.active { color: var(--purple); }
.af-tab svg { width: 22px; height: 22px; }

/* ─── Chat ───────────────────────────────────────────────── */
#view-chat.af-view { position: fixed; inset: 0; max-width: 480px; margin: 0 auto; background: var(--bg); z-index: 50; display: none; flex-direction: column; }
#view-chat.af-view.active { display: flex; }
.af-chat-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.af-chat-header strong { font-family: var(--font-head); color: var(--purple-dark); }
.af-chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.af-msg { max-width: 82%; padding: 11px 15px; border-radius: 16px; font-size: .92rem; line-height: 1.5; }
.af-msg.user { align-self: flex-end; background: var(--purple); color: #fff; border-bottom-right-radius: 4px; }
.af-msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.af-msg.typing { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-style: italic; }
.af-chat-input-row { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.af-chat-input-row textarea { flex: 1; resize: none; max-height: 100px; }
.af-chat-input-row button { flex-shrink: 0; }

/* ─── Crisis resource card ───────────────────────────────── */
.af-crisis-card { background: var(--crisis-tint); border: 2px solid var(--crisis); border-radius: var(--radius); padding: 16px 18px; margin: 4px 0 12px; }
.af-crisis-card .af-crisis-kicker { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--crisis); display: block; margin-bottom: 6px; }
.af-crisis-card p { font-size: .86rem; line-height: 1.5; margin-bottom: 10px; }
.af-resource-list { display: grid; gap: 8px; }
.af-resource-row { background: #fff; border-radius: 8px; padding: 8px 12px; font-size: .8rem; }
.af-resource-row strong { display: block; color: var(--text); }
.af-resource-row span { color: var(--crisis); font-weight: 600; }

/* ─── Community ──────────────────────────────────────────── */
.af-composer textarea { margin-bottom: 10px; }
.af-post { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.af-post-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.af-post-name { font-weight: 700; font-size: .88rem; }
.af-badge-safe { font-size: .68rem; font-weight: 700; background: var(--teal-tint); color: var(--teal-dark); padding: 2px 9px; border-radius: 999px; }
.af-post-time { font-size: .74rem; color: var(--muted); margin-left: auto; }
.af-post-body { font-size: .9rem; line-height: 1.55; margin-bottom: 10px; }
.af-post-actions { display: flex; gap: 10px; }
.af-link-btn { background: none; border: none; color: var(--muted); font-size: .78rem; font-weight: 600; cursor: pointer; padding: 2px; }
.af-link-btn:hover { color: var(--purple); }
.af-status-pill { font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.af-status-pill.pending { background: var(--surface2); color: var(--muted); }
.af-status-pill.flagged { background: var(--crisis-tint); color: var(--crisis); }

/* ─── Settings ───────────────────────────────────────────── */
.af-setting-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.af-setting-row:last-child { border-bottom: none; }
.af-lang-toggle { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.af-lang-btn { border: none; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 700; padding: 6px 14px; cursor: pointer; }
.af-lang-btn.active { background: var(--purple); color: #fff; }

/* ─── Modal ──────────────────────────────────────────────── */
.af-modal-overlay { position: fixed; inset: 0; background: rgba(32,27,54,.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.af-modal-overlay.hidden { display: none; }
.af-modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 24px; max-width: 400px; width: 100%; max-height: 85vh; overflow-y: auto; }
.af-modal-title { font-size: 1.1rem; font-weight: 700; color: var(--purple-dark); margin-bottom: 6px; }
.af-modal-sub { font-size: .85rem; color: var(--muted); margin-bottom: 16px; }
.af-modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.af-reason-option { display: flex; align-items: center; gap: 8px; padding: 8px 0; font-size: .88rem; cursor: pointer; }

/* ─── Toast ──────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; width: calc(100% - 32px); max-width: 440px; align-items: center; }
.af-toast { padding: 11px 18px; border-radius: 10px; color: #fff; font-size: .85rem; font-weight: 600; box-shadow: var(--shadow-lg); }
.af-toast.success { background: var(--teal-dark); }
.af-toast.error { background: var(--crisis); }
.af-toast.info { background: var(--purple-dark); }

.af-not-configured { background: #FFF6DE; border: 1px solid #E8C766; color: #7A5B00; border-radius: var(--radius-sm); padding: 12px 14px; font-size: .82rem; margin-bottom: 16px; }
