/* Budget Bear — screen-specific styles */

/* ------- Home ------- */

.home-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.points-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 7px 9px;
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-14);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur-fast) var(--ease-out);
}
.points-pill:active { transform: scale(0.95); }

.hero-card {
  background: linear-gradient(160deg, var(--green-800), var(--green-600) 90%);
  border: none;
  color: var(--white);
  padding: var(--sp-5);
}
.hero-card .card-title { color: rgba(255, 255, 255, 0.75); }
.hero-card .hero-meta { color: rgba(255, 255, 255, 0.72); margin-top: 6px; }
.hero-card .progress { background: rgba(255, 255, 255, 0.18); }
.hero-card .progress > i { background: var(--green-400); }

.chev { color: var(--text-3); font-size: 20px; line-height: 1; }

.coach-card { border-color: var(--green-100); background: linear-gradient(180deg, var(--surface), var(--tint)); }

/* ------- Onboarding wizard ------- */

.wizard {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: 0;
}

.wizard-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-bottom: var(--sp-5);
  flex-shrink: 0;
}
.wizard-back[hidden] {
  display: none;
}
.wizard-back {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  color: var(--text-2);
  flex-shrink: 0;
}
.wizard-back:active { background: var(--tint); }
.wizard-progress {
  flex: 1;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--green-50);
  overflow: hidden;
}
.wizard-progress i {
  display: block;
  height: 100%;
  background: var(--green-600);
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease-out);
}
.wizard-step-count {
  font-size: var(--fs-12);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.wizard-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: var(--sp-4);
}

.wizard-title { margin-bottom: var(--sp-2); }
.wizard-subtitle { color: var(--text-2); font-size: var(--fs-15); margin-bottom: var(--sp-6); line-height: 1.45; }

/* Colored emoji badge at the top of each step. Tint (--c) is mixed with the
   surface so it stays legible in every light/dark theme. */
.wizard-icon {
  width: 56px; height: 56px;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  border-radius: 18px;
  margin-bottom: var(--sp-4);
  background: color-mix(in srgb, var(--c, var(--green-600)) 15%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c, var(--green-600)) 34%, transparent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--c, var(--green-600)) 22%, transparent);
  animation: wizard-icon-in var(--dur-slow) var(--ease-out);
}
@keyframes wizard-icon-in {
  from { opacity: 0; transform: translateY(6px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .wizard-icon { animation: none; }
}

/* Editable amount rows on the summary step. */
.wizard-summary-card .row-item.wizard-edit-row {
  align-items: center;
  padding: 8px 10px 8px 15px;
}
.wizard-edit-amount {
  width: 118px;
  flex-shrink: 0;
}
.wizard-edit-amount .input {
  min-height: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-semibold);
}

.wizard-footer {
  flex-shrink: 0;
  padding: var(--sp-3) 0 calc(var(--sp-4) + var(--safe-b));
}

.wizard-welcome {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  justify-content: center;
  gap: var(--sp-3);
  padding-bottom: var(--sp-8);
}
.wizard-welcome img { width: 84px; margin: 0 auto var(--sp-4); }
.wizard-welcome h1 { text-align: center; margin-bottom: var(--sp-2); }
.wizard-welcome p { text-align: center; color: var(--text-2); margin-bottom: var(--sp-6); }

.wizard-option {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  width: 100%;
  text-align: left;
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
.wizard-option:active { transform: scale(0.98); }
.wizard-option .icon-bubble { width: 44px; height: 44px; border-radius: 14px; font-size: 20px; flex-shrink: 0; }
.wizard-option h3 { font-size: var(--fs-15); margin-bottom: 2px; }
.wizard-option p { font-size: var(--fs-13); color: var(--text-2); margin: 0; text-align: left; }
.wizard-option.primary { border-color: var(--green-600); background: var(--tint); }

.wizard-choice-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.wizard-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-15);
  font-weight: var(--fw-medium);
  text-align: left;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.wizard-choice[aria-pressed="true"] {
  border-color: var(--green-600);
  background: var(--tint);
  color: var(--green-800);
}
.wizard-choice .check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
}
.wizard-choice[aria-pressed="true"] .check {
  border-color: var(--green-600);
  background: var(--green-600);
  position: relative;
}
.wizard-choice[aria-pressed="true"] .check::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--white);
}

.wizard-goal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}

.wizard-summary-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.wizard-summary-card .row-item {
  display: flex;
  justify-content: space-between;
  padding: 11px 15px;
  font-size: var(--fs-14);
}
.wizard-summary-card .row-item + .row-item { border-top: 1px solid var(--border); }
.wizard-summary-card .row-item span:first-child { color: var(--text-2); }
.wizard-summary-card .row-item strong { font-variant-numeric: tabular-nums; }
.wizard-summary-card.total .row-item { background: var(--tint); font-weight: var(--fw-semibold); }

/* Coach screen reuses chat bubbles */

.ob-bubble {
  display: flex;
  gap: 10px;
  max-width: 92%;
  animation: bubble-in var(--dur-base) var(--ease-out);
}
@keyframes bubble-in {
  from { transform: translateY(8px); }
  to   { transform: none; }
}
.ob-bubble.me { align-self: flex-end; }
.ob-avatar {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--tint);
  object-fit: contain;
  padding: 2px;
  align-self: flex-end;
}
.ob-msg {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: var(--fs-15);
  line-height: 1.45;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}
.ob-bubble.me .ob-msg {
  background: var(--green-600);
  color: var(--white);
  border: none;
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 6px;
}

.chat-sender {
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
  margin: 0 3px 3px;
}
.chat-time {
  font-size: var(--fs-11);
  color: var(--text-2);
  margin: 3px 3px 0;
}
.chat-time-mine {
  text-align: right;
  color: var(--text-2);
}

.coach-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + var(--sp-3));
}
.coach-chat {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
}
.coach-chat .ob-msg { max-width: 100%; }
.coach-chips { padding: var(--sp-2) 0; flex-shrink: 0; }
.coach-inputbar {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.coach-inputbar .btn { min-width: 52px; padding: 0; }

.typing { display: inline-flex; gap: 4px; padding: 15px; }
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green-400);
  animation: typing-dot 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-dot {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Coach answer building blocks */

.coach-block {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--off-white);
}
.coach-block-title {
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-2);
  padding: 8px 12px 0;
}
.coach-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 7px 12px;
  font-size: var(--fs-14);
}
.coach-row + .coach-row { border-top: 1px solid var(--border); }
.coach-row span { color: var(--text-2); }

.coach-reasoning { margin-top: 10px; }
.coach-reasoning .coach-block-title { padding: 0; margin-bottom: 4px; }
.coach-reasoning ul {
  margin: 0;
  padding-left: 18px;
  font-size: var(--fs-14);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.coach-reasoning li::marker { color: var(--green-400); }

.coach-verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-15);
  padding: 8px 14px;
  border-radius: var(--r-full);
  background: var(--tint);
  color: var(--green-800);
}
.coach-verdict .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-500); }
.coach-verdict.v-caution { background: var(--warning-bg); color: #8a6a24; }
.coach-verdict.v-caution .dot { background: var(--warning); }
.coach-verdict.v-no { background: var(--error-bg); color: #9c3835; }
.coach-verdict.v-no .dot { background: var(--error); }

/* ------- Category / template grid ------- */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
}
.cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
.cat-tile span { font-size: 21px; }
.cat-tile small {
  font-size: var(--fs-11);
  color: var(--text-2);
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.cat-tile:active { transform: scale(0.95); }
.cat-tile.selected {
  border-color: var(--green-600);
  background: var(--tint);
}
.cat-tile.selected small { color: var(--green-800); font-weight: var(--fw-semibold); }

/* ------- Goals ------- */

.goal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.goal-stats small {
  display: block;
  font-size: var(--fs-11);
  color: var(--text-2);
  margin-bottom: 2px;
}
.goal-stats strong { font-size: var(--fs-13); }

/* Streak chip on goal cards — lights up when this period's pace is met. */
.streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-11);
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: var(--r-full);
  vertical-align: middle;
  color: var(--text-2);
  background: color-mix(in srgb, #ff8a3d 16%, var(--surface));
  border: 1px solid color-mix(in srgb, #ff8a3d 28%, transparent);
}
.streak-chip.lit {
  color: #b4530e;
  background: color-mix(in srgb, #ff8a3d 26%, var(--surface));
  border-color: color-mix(in srgb, #ff8a3d 45%, transparent);
}

/* Premium forecast teaser (Insights, free accounts) */
.premium-teaser {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--green-400) 14%, var(--surface)),
    var(--surface) 70%);
  border-color: color-mix(in srgb, var(--green-500) 40%, var(--border));
  transition: transform var(--dur-fast), border-color var(--dur-fast);
}
.premium-teaser:active { transform: scale(0.99); }

/* ------- Profile ------- */

.profile-stats {
  display: flex;
  justify-content: center;
  gap: var(--sp-8);
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}
.profile-stats strong { display: block; font-size: var(--fs-20); }
.profile-stats small { color: var(--text-2); font-size: var(--fs-12); }

.ach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}
.ach-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: transform var(--dur-fast) var(--ease-out);
}
.ach-tile:active { transform: scale(0.95); }
.ach-tile img { width: 54px; height: 54px; object-fit: contain; }
.ach-tile small {
  font-size: var(--fs-11);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  text-align: center;
  line-height: 1.25;
}
.ach-tile.locked img { filter: grayscale(1); opacity: 0.35; }
.ach-tile.locked small { opacity: 0.6; }

/* ------- Review list ------- */

.review-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: var(--fs-14);
}

/* ------- Custom category images ------- */
/* A category's icon can be an uploaded photo instead of an emoji. The image
   fills whatever icon container it lands in (list bubble, card bubble, tile). */
.icon-bubble .cat-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.cat-tile span .cat-img {
  width: 30px;
  height: 30px;
  object-fit: cover;
  border-radius: 9px;
  display: block;
}
/* The tappable icon in the Category-budgets sheet — reuses .icon-bubble but is
   a button, so it needs the reset + an affordance. */
button.cat-edit-icon {
  border: none;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  position: relative;
}
button.cat-edit-icon::after {
  content: "✎";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 16px;
  height: 16px;
  font-size: 9px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
}
