/* Form pieces used by the add-investment wizard and settings. Tokens come from tokens.css. */

a.btn { text-decoration: none; }
.btn--danger { background: transparent; color: var(--negative); border-color: color-mix(in srgb, var(--negative) 45%, transparent); }
@media (hover: hover) { .btn--danger:hover { background: color-mix(in srgb, var(--negative) 10%, transparent); border-color: color-mix(in srgb, var(--negative) 45%, transparent); } }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; }
.page-actions > .page-title { flex: 1 1 auto; }
.row--actions { margin-top: var(--space-4); }
.row--actions > .btn { flex: 0 1 auto; }

/* fields */
.field-label { font: 500 var(--fs-small) var(--font-sans); margin: 0 0 var(--space-2); }
.field .optional { color: var(--text-muted); font-weight: 400; }
.field-error { display: flex; align-items: flex-start; gap: 6px; min-height: 0; margin: var(--space-2) 0 0; color: var(--negative); font-size: var(--fs-small); animation: alert-in var(--dur-base) var(--ease-out); }
.field-error::before { content: ""; flex: none; width: 16px; height: 16px; margin-top: 0.15em; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.5v.01'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.5v.01'/%3E%3C/svg%3E") center / contain no-repeat; }
.field-error:empty { display: none; }
.field.has-error .input { border-color: var(--negative); }
.input--area { min-height: 5.5rem; padding: var(--space-3) var(--space-4); resize: vertical; line-height: 1.5; }
select.input { -webkit-appearance: none; appearance: none; padding-right: 2.6rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%238A918B' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1rem center; background-size: 12px 8px; }
.preview { margin: var(--space-2) 0 0; font-size: var(--fs-small); color: var(--text-muted); font-variant-numeric: tabular-nums; min-height: 1.2em; }
.preview--bad { color: var(--negative); }
.subsection { padding-top: var(--space-6); border-top: 1px solid var(--border); }
.subsection > h2 { font-size: var(--fs-h3); }
.stack > .subsection { margin-top: var(--space-6); }

/* big choices (radio behaviour) */
.choices { display: grid; gap: var(--space-3); }
.choice { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%; min-height: var(--tap-min); padding: var(--space-3) 3.1rem var(--space-3) var(--space-4); border-radius: var(--radius-card); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 400 var(--fs-body) var(--font-sans); cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-spring); touch-action: manipulation; }
@media (hover: hover) { .choice:hover { background: var(--surface-2); } }
.choice:active { transform: scale(0.985); transition-duration: var(--dur-instant); }
.choice::after { content: ""; position: absolute; right: 1.1rem; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%; border: 1.5px solid var(--border-strong); transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out); }
.choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice[aria-checked="true"]::after { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 5px, transparent 6px); }
.choice-title { font-weight: 600; }
.choice-desc { color: var(--text-muted); font-size: var(--fs-small); }

/* category grid */
/* Phones: one full-width chip per line, so long category names read in full.
   From 640px up it is the three-column grid again. */
.cat-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-3); }
@media (min-width: 640px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
.cat { display: flex; align-items: center; gap: var(--space-3); text-align: left; min-height: 64px; padding: var(--space-3); border-radius: var(--radius-card); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 var(--fs-small) var(--font-sans); cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-spring); touch-action: manipulation; }
@media (hover: hover) { .cat:hover { background: var(--surface-2); } }
.cat:active { transform: scale(0.97); transition-duration: var(--dur-instant); }
.cat[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.cat .icon { color: var(--accent); flex: none; }
.cat-name { overflow-wrap: anywhere; }

/* wizard chrome */
.wizard-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wizard-top .sub { margin: 0; }
.back--btn { background: none; border: 0; cursor: pointer; padding: 0; font: 400 var(--fs-small) var(--font-sans); color: var(--text-muted); }
.progress { display: flex; gap: 4px; margin-top: var(--space-2); }
.progress span { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background var(--dur-slow) var(--ease-out); }
.progress span.on { background: var(--accent); }
.wizard-form > .page-title { margin-top: var(--space-6); }
.wizard-form > .page-title:focus { outline: none; }
.wizard-foot { margin-top: var(--space-8); }

/* people */
.person { padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--card-highlight), var(--shadow-1); }
.person > * + * { margin-top: var(--space-4); }
.person-head { display: flex; align-items: center; justify-content: space-between; }
.person-head h2 { font-size: var(--fs-h3); }

.toast-btn { margin-left: var(--space-3); min-height: 0; padding: 0; color: var(--accent); font-weight: 600; }
.toast { display: flex; align-items: center; }
.action-row { margin: var(--space-4) 0 0; }
.hint[hidden], .alert[hidden] { display: none; }
.flow > .row--actions { margin-top: var(--space-4); }
.flow > .page-actions + * { margin-top: var(--space-6); }

/* ---- validation: the box shakes once and a red glow shows where to look ---- */
.field.has-error .input { animation: field-shake 360ms var(--ease-out); }
.field.has-error .input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--negative) 18%, transparent); }
@keyframes field-shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* ---- forms as focused tasks ---- */
/* From tablet width the wizard and record forms sit in one centred card instead of stretching across the page. */
@media (min-width: 768px) {
  .wizard, .form-page { max-width: 40rem; margin-inline: auto; padding: var(--space-8); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--card-highlight), var(--shadow-2); }
}
/* On phones the tab bar steps aside and the action buttons stay in reach at the bottom of the screen. */
@media (max-width: 1023.98px) { .ws.is-focus .tabbar { display: none; } .ws.is-focus .ws-main { padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); } }
@media (max-width: 767.98px) {
  .sticky-actions { position: sticky; bottom: 0; z-index: 5; margin-inline: calc(var(--space-4) * -1); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3); border-top: 1px solid var(--border); }
  .wizard-foot.sticky-actions { margin-top: var(--space-6); }
}

/* ---- confirmation dialog: a sheet from the bottom on phones, a centred card elsewhere ---- */
html.dialog-open { overflow: hidden; }
.scrim { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; background: var(--overlay); animation: fade var(--dur-base) var(--ease-out) both; }
.scrim.out { animation: fade-out var(--dur-fast) var(--ease-out) forwards; }
.dialog { width: 100%; max-width: 28rem; padding: var(--space-3) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; box-shadow: var(--shadow-3); outline: none; animation: sheet-in var(--dur-slow) var(--ease-out) both; }
.scrim.out .dialog { animation: sheet-out var(--dur-fast) var(--ease-in-out) forwards; }
.dialog-handle { width: 40px; height: 4px; margin: 0 auto var(--space-4); border-radius: 2px; background: var(--border-strong); }
.dialog h2 { font-size: var(--fs-h3); }
.dialog p { margin: var(--space-2) 0 0; color: var(--text-muted); }
.dialog-actions { display: grid; gap: var(--space-3); margin-top: var(--space-6); }
.dialog-actions > :last-child { order: -1; }
.btn--danger-solid { background: var(--negative); border-color: var(--negative); color: #fff; }
@supports (color: light-dark(#000, #fff)) { .btn--danger-solid { color: light-dark(#fff, #200E09); } }
@media (hover: hover) { .btn--danger-solid:hover { background: var(--negative); border-color: var(--negative); filter: brightness(0.93); } }
@media (min-width: 640px) {
  .scrim { align-items: center; padding: var(--space-4); }
  .dialog { padding: var(--space-6); border-bottom: 1px solid var(--border); border-radius: var(--radius-lg); animation-name: dialog-in; }
  .scrim.out .dialog { animation-name: dialog-out; }
  .dialog-handle { display: none; }
  .dialog-actions { grid-template-columns: 1fr 1fr; }
  .dialog-actions > :last-child { order: 0; }
}
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { to { opacity: 0; transform: scale(0.97); } }

/* ======== 4E: onboarding polish ======== */
/* Choice chips never overflow and never break inside a word. Segments share the width equally, words wrap between
   words only, and a segment can never be narrower than its longest word (min-content), even at the largest text size. */
.wizard .seg, .settings .seg, .form-page .seg { display: flex; width: 100%; }
.wizard .seg button, .settings .seg button, .form-page .seg button { flex: 1 1 0; min-width: min-content; min-height: 44px; padding: 8px var(--space-3); white-space: normal; line-height: 1.2; text-wrap: balance; overflow-wrap: normal; word-break: normal; hyphens: none; }
@media (max-width: 359.98px) { .wizard .seg button, .settings .seg button, .form-page .seg button { padding-inline: var(--space-2); } }

/* Header: a quiet close, a count, a slim progress bar. */
.wizard-top { align-items: center; }
.wizard-count { margin: 0; color: var(--text-muted); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.wizard-count strong { color: var(--text); font-weight: 600; }
.progress { gap: 6px; margin-top: var(--space-4); }
.progress span { height: 4px; border-radius: 4px; }
.wizard-head { margin-top: var(--space-8); }
.wizard-title { font-size: calc(2.15rem * var(--text-scale)); line-height: 1.08; letter-spacing: -0.02em; }
.wizard-lede { margin: var(--space-3) 0 0; max-width: 30rem; color: var(--text-muted); font-size: var(--fs-body); line-height: 1.5; text-wrap: pretty; }
.wizard-body { margin-top: var(--space-8); }
.step-in { animation: rise var(--dur-slow) var(--ease-out) both; }
.wizard-body.step-in { animation-delay: 60ms; }

/* More air between each question and its answer, and between one question and the next. */
.wizard .stack > * + * { margin-top: var(--space-6); }
.wizard .field > label, .wizard .field-label { display: block; margin-bottom: var(--space-3); font-weight: 600; }
.wizard .field .hint { margin-top: var(--space-2); }
.wizard .subsection { margin-top: var(--space-8); padding-top: var(--space-8); }
.wizard .subsection > h2 { margin-bottom: var(--space-2); }

/* Big choices: an icon tile on the left, words on the right. */
.choices { gap: var(--space-3); }
.choice { flex-direction: row; align-items: center; gap: var(--space-3); min-height: 68px; padding: var(--space-3) 3.1rem var(--space-3) var(--space-3); }
.choice-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice:not(.choice--icon) { padding-left: var(--space-4); }
.choice-ico { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); color: var(--accent); transition: background var(--dur-fast) var(--ease-out); }
.choice[aria-checked="true"] .choice-ico { background: var(--surface); }
.cat { min-height: 68px; font-size: var(--fs-body); }
.cat .tile { width: 42px; height: 42px; }

/* Footer buttons: Back stays small, the main button takes the room and never wraps. */
.row > .btn--back { flex: 0 0 auto; min-width: 6.5rem; padding-inline: var(--space-6); }
.row > .btn--grow { flex: 1 1 0; white-space: nowrap; }
.sticky-actions .btn { white-space: nowrap; }
.wizard-foot { gap: var(--space-3); }

/* ---- step slider (Settings > Text size; stepSlider in formkit.js) ---- */
.slider { --thumb: 28px; }
.slider-row { display: flex; align-items: center; gap: var(--space-3); }
.slider-a { flex: none; width: 1.5rem; text-align: center; font-family: var(--font-serif); line-height: 1; color: var(--text-muted); user-select: none; -webkit-user-select: none; }
.slider-a--small { font-size: 0.95rem; }
.slider-a--large { font-size: 1.9rem; color: var(--text); }
.slider-track { position: relative; flex: 1; min-width: 0; height: var(--tap-min); display: flex; align-items: center; }
.slider-input { --p: 0; -webkit-appearance: none; appearance: none; position: relative; z-index: 1; width: 100%; height: var(--tap-min); margin: 0; padding: 0; background: transparent; cursor: pointer; touch-action: pan-y; }
.slider-input:focus { outline: none; }
.slider-input::-webkit-slider-runnable-track { height: 6px; border-radius: var(--radius-pill); background: linear-gradient(to right, var(--accent) calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--p)), var(--border-strong) 0); }
.slider-input::-moz-range-track { height: 6px; border-radius: var(--radius-pill); background: var(--border-strong); }
.slider-input::-moz-range-progress { height: 6px; border-radius: var(--radius-pill); background: var(--accent); }
.slider-input::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: var(--thumb); height: var(--thumb); margin-top: calc((6px - var(--thumb)) / 2); border: 2px solid var(--accent); border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-2); transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.slider-input::-moz-range-thumb { box-sizing: border-box; width: var(--thumb); height: var(--thumb); border: 2px solid var(--accent); border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-2); transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.slider-input:active::-webkit-slider-thumb { transform: scale(1.1); }
.slider-input:active::-moz-range-thumb { transform: scale(1.1); }
.slider-input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus-ring) 30%, transparent), var(--shadow-2); }
.slider-input:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus-ring) 30%, transparent), var(--shadow-2); }
.slider-ticks { position: absolute; left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); top: calc(50% + 11px); display: flex; justify-content: space-between; pointer-events: none; }
.slider-ticks > span { width: 2px; height: 7px; margin-inline: -1px; border-radius: 1px; background: var(--border-strong); }
